summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-09-01 05:36:04 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-09-01 05:36:04 (GMT)
commitee980ac0bfead1674d5bdd55614c886fbcf949ca (patch)
tree638e64c3995c0abe1b8b6a14f7ef632d8b115ca2 /tests
parent0484ce38416fd3906cc1165995ecb0db8dd6c308 (diff)
parent6cd1863ca3ff0684e1dd1a8d9c13b8f141800072 (diff)
downloadQt-ee980ac0bfead1674d5bdd55614c886fbcf949ca.zip
Qt-ee980ac0bfead1674d5bdd55614c886fbcf949ca.tar.gz
Qt-ee980ac0bfead1674d5bdd55614c886fbcf949ca.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qmlparser/failingComponent.errors.txt3
-rw-r--r--tests/auto/declarative/qmlparser/importNamespaceConflict.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/importNamespaceConflict.qml4
-rw-r--r--tests/auto/declarative/qmlparser/lib/com/nokia/installedtest/qmldir1
-rw-r--r--tests/auto/declarative/qmlparser/testtypes.h5
-rw-r--r--tests/auto/declarative/qmlparser/tst_qmlparser.cpp130
6 files changed, 127 insertions, 17 deletions
diff --git a/tests/auto/declarative/qmlparser/failingComponent.errors.txt b/tests/auto/declarative/qmlparser/failingComponent.errors.txt
index 190a649..0cf0ef3 100644
--- a/tests/auto/declarative/qmlparser/failingComponent.errors.txt
+++ b/tests/auto/declarative/qmlparser/failingComponent.errors.txt
@@ -1,2 +1 @@
-3:5:Unable to create type FailingComponent
-4:5:Cannot assign to non-existant property "a"
+3:5:Type FailingComponent unavailable
diff --git a/tests/auto/declarative/qmlparser/importNamespaceConflict.errors.txt b/tests/auto/declarative/qmlparser/importNamespaceConflict.errors.txt
new file mode 100644
index 0000000..231998d
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/importNamespaceConflict.errors.txt
@@ -0,0 +1 @@
+4:1:Namespace Rectangle cannot be used as a type
diff --git a/tests/auto/declarative/qmlparser/importNamespaceConflict.qml b/tests/auto/declarative/qmlparser/importNamespaceConflict.qml
new file mode 100644
index 0000000..cd112af
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/importNamespaceConflict.qml
@@ -0,0 +1,4 @@
+import Test 1.0 as Rectangle
+import Qt 4.6
+
+Rectangle { }
diff --git a/tests/auto/declarative/qmlparser/lib/com/nokia/installedtest/qmldir b/tests/auto/declarative/qmlparser/lib/com/nokia/installedtest/qmldir
index f22e179..ba0b42a 100644
--- a/tests/auto/declarative/qmlparser/lib/com/nokia/installedtest/qmldir
+++ b/tests/auto/declarative/qmlparser/lib/com/nokia/installedtest/qmldir
@@ -1,2 +1,3 @@
InstalledTest 1.0-3 InstalledTest.qml
InstalledTest 1.4 InstalledTest2.qml
+Rectangle 1.5 InstalledTest2.qml
diff --git a/tests/auto/declarative/qmlparser/testtypes.h b/tests/auto/declarative/qmlparser/testtypes.h
index ace7ef9..f700484 100644
--- a/tests/auto/declarative/qmlparser/testtypes.h
+++ b/tests/auto/declarative/qmlparser/testtypes.h
@@ -357,12 +357,13 @@ private:
QML_DECLARE_TYPE(MyContainer);
-class MyPropertyValueSource : public QmlPropertyValueSource
+class MyPropertyValueSource : public QObject, public QmlPropertyValueSource
{
Q_OBJECT
+ Q_INTERFACES(QmlPropertyValueSource)
public:
MyPropertyValueSource()
- : QmlPropertyValueSource(0) {}
+ : QmlPropertyValueSource() {}
QmlMetaProperty prop;
virtual void setTarget(const QmlMetaProperty &p)
diff --git a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
index 3047bb0..36471a4 100644
--- a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
+++ b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
@@ -48,14 +48,21 @@ private slots:
void customVariantTypes();
void valueTypes();
- void imports_data();
- void imports();
+ void importsBuiltin_data();
+ void importsBuiltin();
+ void importsLocal_data();
+ void importsLocal();
+ void importsInstalled_data();
+ void importsInstalled();
+ void importsOrder_data();
+ void importsOrder();
// regression tests for crashes
void crash1();
private:
QmlEngine engine;
+ void testType(const QString& qml, const QString& type);
};
#define VERIFY_ERRORS(errorfile) \
@@ -148,6 +155,8 @@ void tst_qmlparser::errors_data()
QTest::newRow("failingComponent") << "failingComponentTest.qml" << "failingComponent.errors.txt" << false;
QTest::newRow("missingSignal") << "missingSignal.qml" << "missingSignal.errors.txt" << false;
QTest::newRow("finalOverride") << "finalOverride.qml" << "finalOverride.errors.txt" << false;
+
+ QTest::newRow("importNamespaceConflict") << "importNamespaceConflict.qml" << "importNamespaceConflict.errors.txt" << false;
}
void tst_qmlparser::errors()
@@ -420,6 +429,10 @@ void tst_qmlparser::autoComponentCreation()
void tst_qmlparser::propertyValueSource()
{
+ QVERIFY(false);
+
+/* Does not compile...
+
QmlComponent component(&engine, TEST_FILE("propertyValueSource.qml"));
VERIFY_ERRORS(0);
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
@@ -432,6 +445,7 @@ void tst_qmlparser::propertyValueSource()
QVERIFY(valueSource != 0);
QCOMPARE(valueSource->prop.object(), object);
QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty")));
+*/
}
void tst_qmlparser::attachedProperties()
@@ -502,6 +516,21 @@ public:
TestType2(QObject *p=0) : QObject(p) {}
};
+// Check that first child of qml is of given type. Empty type insists on error.
+void tst_qmlparser::testType(const QString& qml, const QString& type)
+{
+ QmlComponent component(&engine, qml.toUtf8(), TEST_FILE("empty.qml")); // just a file for relative local imports
+
+ if (type.isEmpty()) {
+ QVERIFY(component.isError());
+ } else {
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(QString(object->metaObject()->className()), type);
+ }
+}
+
QML_DECLARE_TYPE(TestType)
QML_DECLARE_TYPE(TestType2)
@@ -511,7 +540,7 @@ QML_DEFINE_TYPE(com.nokia.Test, 1, 8, 9, Test, TestType2)
QML_DEFINE_TYPE(com.nokia.Test, 1, 12, 13, Test, TestType2)
QML_DEFINE_TYPE(com.nokia.Test, 1, 9, 11, OldTest, TestType)
-void tst_qmlparser::imports_data()
+void tst_qmlparser::importsBuiltin_data()
{
QTest::addColumn<QString>("qml");
QTest::addColumn<QString>("type");
@@ -605,6 +634,19 @@ void tst_qmlparser::imports_data()
"import com.nokia.Test 1.10 as T10\n"
"T10.Test {}"
<< "";
+}
+
+void tst_qmlparser::importsBuiltin()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ testType(qml,type);
+}
+
+void tst_qmlparser::importsLocal_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
// import locals
QTest::newRow("local import")
@@ -624,6 +666,19 @@ void tst_qmlparser::imports_data()
"import com.nokia.Test 1.0\n"
"Test {}"
<< "TestType";
+}
+
+void tst_qmlparser::importsLocal()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ testType(qml,type);
+}
+
+void tst_qmlparser::importsInstalled_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
// import installed
QTest::newRow("installed import")
@@ -636,21 +691,70 @@ void tst_qmlparser::imports_data()
<< "QFxText";
}
-void tst_qmlparser::imports()
+void tst_qmlparser::importsInstalled()
{
QFETCH(QString, qml);
QFETCH(QString, type);
+ testType(qml,type);
+}
- QmlComponent component(&engine, qml.toUtf8(), TEST_FILE("empty.qml")); // just a file for relative local imports
- if (type.isEmpty()) {
- QVERIFY(component.isError());
- } else {
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(QString(object->metaObject()->className()), type);
- }
+void tst_qmlparser::importsOrder_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+
+ QTest::newRow("installed import overrides 1") <<
+ "import com.nokia.installedtest 1.0\n"
+ "import com.nokia.installedtest 1.4\n"
+ "InstalledTest {}"
+ << "QFxText";
+ QTest::newRow("installed import overrides 2") <<
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.0\n"
+ "InstalledTest {}"
+ << "QFxRect";
+ QTest::newRow("installed import re-overrides 1") <<
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.0\n"
+ "import com.nokia.installedtest 1.4\n"
+ "InstalledTest {}"
+ << "QFxText";
+ QTest::newRow("installed import re-overrides 2") <<
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.0\n"
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.0\n"
+ "InstalledTest {}"
+ << "QFxRect";
+
+ QTest::newRow("installed import versus builtin 1") <<
+ "import com.nokia.installedtest 1.5\n"
+ "import Qt 4.6\n"
+ "Rectangle {}"
+ << "QFxRect";
+ QTest::newRow("installed import versus builtin 2") <<
+ "import Qt 4.6\n"
+ "import com.nokia.installedtest 1.5\n"
+ "Rectangle {}"
+ << "QFxText";
+ QTest::newRow("namespaces cannot be overridden by types 1") <<
+ "import Qt 4.6 as Rectangle\n"
+ "import com.nokia.installedtest 1.5\n"
+ "Rectangle {}"
+ << "";
+ QTest::newRow("namespaces cannot be overridden by types 2") <<
+ "import Qt 4.6 as Rectangle\n"
+ "import com.nokia.installedtest 1.5\n"
+ "Rectangle.Image {}"
+ << "QFxImage";
+}
+
+void tst_qmlparser::importsOrder()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ testType(qml,type);
}
void tst_qmlparser::crash1()