diff options
Diffstat (limited to 'tests/auto/declarative/qdeclarativelanguage')
42 files changed, 202 insertions, 196 deletions
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml b/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml index 6362b2d..f62c860 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml @@ -2,7 +2,7 @@ import Test 1.0 import Qt 4.6 QtObject { - property var other + property variant other other: MyTypeObject { id: obj } property alias enumAlias: obj.enumProperty; } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml b/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml index d1e78f8..9050c3a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml @@ -3,7 +3,7 @@ import Qt 4.6 QtObject { property alias obj : otherObj - property var child + property variant child child: QtObject { id: otherObj property int myValue: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml b/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml index dc3b382..df8c851 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml @@ -2,7 +2,7 @@ import Test 1.0 import Qt 4.6 QtObject { - property var child + property variant child child: QtObject { id: obj } property alias objAlias: obj; } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml index e059937..0b968c2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml @@ -1,7 +1,7 @@ import Qt 4.6 QtObject { - property var other + property variant other other: Alias { id: myAliasObject } property alias value: myAliasObject.aliasValue diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml index 4316d0d..125c518 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml @@ -4,7 +4,7 @@ import Test 1.0 QtObject { property alias otherAlias: otherObject - property var other + property variant other other: MyQmlObject { id: otherObject value: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml index 2b9ad85..629dd2a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml @@ -1,7 +1,7 @@ import Qt 4.6 QtObject { - property var other + property variant other other: Alias3 { id: myAliasObject } property int value: myAliasObject.obj.myValue diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml index a2a41a1..7c072e1 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml @@ -1,7 +1,7 @@ import Qt 4.6 QtObject { - property var other + property variant other other: Alias4 { id: myAliasObject } property int value: myAliasObject.obj.myValue diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml new file mode 100644 index 0000000..91fd833 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +QtObject { + property variant test1: 1 + property variant test2: 1.7 + property variant test3: "Hello world!" + property variant test4: "#FF008800" + property variant test5: "10,10,10x10" + property variant test6: "10,10" + property variant test7: "10x10" + property variant test8: "100,100,100" + property variant test9: String("#FF008800") +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml index 0ff9370..774762a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml @@ -2,6 +2,6 @@ import Test 1.0 import Qt 4.6 QtObject { - property var a; + property variant a; a: MyQmlObject {} } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml b/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml index 0a7249a..e745e91 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml @@ -1,7 +1,7 @@ import Qt 4.6 QtObject { - property var test + property variant test test: ComponentComposite {} } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml index bedab8c..6411609 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml @@ -9,5 +9,5 @@ QtObject { property color colorProperty: "red" property url urlProperty: "main.qml" property date dateProperty: "1945-09-02" - property var varProperty: "Hello World!" + property variant varProperty: "Hello World!" } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml b/tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml index 942ed90..e77cb52 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml @@ -1,12 +1,9 @@ import Test 1.0 MyTypeObject { - Script { - function val() { - var áâãäå = 20 - return "Test áâãäå: " + áâãäå - } - + function val() { + var áâãäå = 20 + return "Test áâãäå: " + áâãäå } stringProperty: val() } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml index 90c1483..bf048ea 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml @@ -1,6 +1,6 @@ import Test 1.0 MyContainer { - property var object : myObjectId + property variant object : myObjectId MyTypeObject { id: "myObjectId" diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.errors.txt new file mode 100644 index 0000000..ebc936d --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.errors.txt @@ -0,0 +1 @@ +1:8:Script import requires a qualifier diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.qml new file mode 100644 index 0000000..2b2ab6b --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.qml @@ -0,0 +1,3 @@ +import "test.js" + +Item { } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml index 1167e39..9012aa6 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml @@ -1,6 +1,6 @@ import Qt 4.6 QtObject { - property var o; + property variant o; o.blah: 10 } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml index cd86a48..a4a976e 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml @@ -2,7 +2,7 @@ import Test 1.0 import Qt 4.6 QtObject { - property var child + property variant child child: HelperAlias { objAlias: QtObject {} } } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.1.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.1.errors.txt deleted file mode 100644 index 50518cc..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.1.errors.txt +++ /dev/null @@ -1 +0,0 @@ -3:1:Invalid use of Script block diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.1.qml deleted file mode 100644 index 8dac8b7..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.1.qml +++ /dev/null @@ -1,4 +0,0 @@ -import Qt 4.6 - -Script { -} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.10.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.10.errors.txt deleted file mode 100644 index 13f47d1..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.10.errors.txt +++ /dev/null @@ -1 +0,0 @@ -6:9:Component elements may not contain script blocks diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.10.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.10.qml deleted file mode 100644 index 516e878..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.10.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Qt 4.6 - -Item { - Component { - Item {} - Script {} - } -} - diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.11.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.11.errors.txt deleted file mode 100644 index a664203..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.11.errors.txt +++ /dev/null @@ -1 +0,0 @@ -5:9:Invalid Script block diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.11.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.11.qml deleted file mode 100644 index 6d2d598..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.11.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt 4.6 - -QtObject { - Script { - QtObject {} - } -} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.12.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.12.errors.txt deleted file mode 100644 index f8297f5..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.12.errors.txt +++ /dev/null @@ -1 +0,0 @@ -4:5:JavaScript declaration outside Script element diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.12.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.12.qml deleted file mode 100644 index 9ecb5d9..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.12.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt 4.6 - -QtObject { - var a -} - diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.2.errors.txt deleted file mode 100644 index 8fb3bbd..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.2.errors.txt +++ /dev/null @@ -1 +0,0 @@ -5:9:Properties cannot be set on Script block diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.2.qml deleted file mode 100644 index dce1a41..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.2.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt 4.6 - -QtObject { - Script { - id: myScript - } -} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.3.errors.txt deleted file mode 100644 index 8fb3bbd..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.3.errors.txt +++ /dev/null @@ -1 +0,0 @@ -5:9:Properties cannot be set on Script block diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.3.qml deleted file mode 100644 index 8621a9a..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.3.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt 4.6 - -QtObject { - Script { - hello: world - } -} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.4.errors.txt deleted file mode 100644 index 49a507f..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.4.errors.txt +++ /dev/null @@ -1 +0,0 @@ -5:9:Invalid Script source value diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.4.qml deleted file mode 100644 index d89817c..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.4.qml +++ /dev/null @@ -1,8 +0,0 @@ -import Qt 4.6 - -QtObject { - Script { - source: 10 - } -} - diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.5.errors.txt deleted file mode 100644 index 49a507f..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.5.errors.txt +++ /dev/null @@ -1 +0,0 @@ -5:9:Invalid Script source value diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.5.qml deleted file mode 100644 index 8986b3b..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.5.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Qt 4.6 - -QtObject { - Script { - source: "hello" + ".js" - } -} - - diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.6.errors.txt deleted file mode 100644 index 4e53b6b..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.6.errors.txt +++ /dev/null @@ -1 +0,0 @@ -5:9:Invalid Script block. Specify either the source property or inline script diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.6.qml deleted file mode 100644 index 07e9d78..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.6.qml +++ /dev/null @@ -1,11 +0,0 @@ -import Qt 4.6 - -QtObject { - Script { - source: "test.js" - function helloWorld() {} - } -} - - - diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.7.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.7.errors.txt deleted file mode 100644 index dc15ddf..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.7.errors.txt +++ /dev/null @@ -1 +0,0 @@ -5:9:Variable declarations not allow in inline Script blocks diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.7.qml deleted file mode 100644 index fa905e6..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.7.qml +++ /dev/null @@ -1,11 +0,0 @@ -import Qt 4.6 - -QtObject { - Script { - var a = 10; - } -} - - - - diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt deleted file mode 100644 index 450fc16..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.8.errors.txt +++ /dev/null @@ -1 +0,0 @@ -6:9:Property value set multiple times diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.8.qml deleted file mode 100644 index f600c88..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.8.qml +++ /dev/null @@ -1,9 +0,0 @@ -import Qt 4.6 - -QtObject { - Script { - source: "test.js" - source: "test2.js" - } -} - diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.9.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/script.9.errors.txt deleted file mode 100644 index 41e8d46..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.9.errors.txt +++ /dev/null @@ -1 +0,0 @@ -5:9:Component elements may not contain script blocks diff --git a/tests/auto/declarative/qdeclarativelanguage/data/script.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/script.9.qml deleted file mode 100644 index 79aa504..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/script.9.qml +++ /dev/null @@ -1,7 +0,0 @@ -import Qt 4.6 - -Item { - Component { - Script {} - } -} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 722e161..bfb56ba 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -87,6 +87,7 @@ private slots: void assignBasicTypes(); void assignTypeExtremes(); void assignCompositeToType(); + void assignLiteralToVariant(); void customParserTypes(); void rootAsQmlComponent(); void inlineQmlComponents(); @@ -136,7 +137,7 @@ private slots: private: QDeclarativeEngine engine; - void testType(const QString& qml, const QString& type); + void testType(const QString& qml, const QString& type, const QString& error); }; #define VERIFY_ERRORS(errorfile) \ @@ -283,18 +284,7 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("property.6") << "property.6.qml" << "property.6.errors.txt" << false; QTest::newRow("property.7") << "property.7.qml" << "property.7.errors.txt" << false; - QTest::newRow("Script.1") << "script.1.qml" << "script.1.errors.txt" << false; - QTest::newRow("Script.2") << "script.2.qml" << "script.2.errors.txt" << false; - QTest::newRow("Script.3") << "script.3.qml" << "script.3.errors.txt" << false; - QTest::newRow("Script.4") << "script.4.qml" << "script.4.errors.txt" << false; - QTest::newRow("Script.5") << "script.5.qml" << "script.5.errors.txt" << false; - QTest::newRow("Script.6") << "script.6.qml" << "script.6.errors.txt" << false; - QTest::newRow("Script.7") << "script.7.qml" << "script.7.errors.txt" << false; - QTest::newRow("Script.8") << "script.8.qml" << "script.8.errors.txt" << false; - QTest::newRow("Script.9") << "script.9.qml" << "script.9.errors.txt" << false; - QTest::newRow("Script.10") << "script.10.qml" << "script.10.errors.txt" << false; - QTest::newRow("Script.11") << "script.11.qml" << "script.11.errors.txt" << false; - QTest::newRow("Script.12") << "script.12.qml" << "script.12.errors.txt" << false; + QTest::newRow("importScript.1") << "importscript.1.qml" << "importscript.1.errors.txt" << false; QTest::newRow("Component.1") << "component.1.qml" << "component.1.errors.txt" << false; QTest::newRow("Component.2") << "component.2.qml" << "component.2.errors.txt" << false; @@ -490,6 +480,37 @@ void tst_qdeclarativelanguage::assignCompositeToType() QVERIFY(object != 0); } +// Test that literals are stored correctly in variant properties +void tst_qdeclarativelanguage::assignLiteralToVariant() +{ + QDeclarativeComponent component(&engine, TEST_FILE("assignLiteralToVariant.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").userType(), (int)QVariant::Int); + QCOMPARE(object->property("test2").userType(), (int)QMetaType::Double); + QCOMPARE(object->property("test3").userType(), (int)QVariant::String); + QCOMPARE(object->property("test4").userType(), (int)QVariant::Color); + QCOMPARE(object->property("test5").userType(), (int)QVariant::RectF); + QCOMPARE(object->property("test6").userType(), (int)QVariant::PointF); + QCOMPARE(object->property("test7").userType(), (int)QVariant::SizeF); + QCOMPARE(object->property("test8").userType(), (int)QVariant::Vector3D); + QCOMPARE(object->property("test9").userType(), (int)QVariant::String); + + QVERIFY(object->property("test1") == QVariant(1)); + QVERIFY(object->property("test2") == QVariant((double)1.7)); + QVERIFY(object->property("test3") == QVariant(QString(QLatin1String("Hello world!")))); + QVERIFY(object->property("test4") == QVariant(QColor::fromRgb(0xFF008800))); + QVERIFY(object->property("test5") == QVariant(QRectF(10, 10, 10, 10))); + QVERIFY(object->property("test6") == QVariant(QPointF(10, 10))); + QVERIFY(object->property("test7") == QVariant(QSizeF(10, 10))); + QVERIFY(object->property("test8") == QVariant(QVector3D(100, 100, 100))); + QVERIFY(object->property("test9") == QVariant(QString(QLatin1String("#FF008800")))); + + delete object; +} + // Tests that custom parser types can be instantiated void tst_qdeclarativelanguage::customParserTypes() { @@ -1069,7 +1090,7 @@ void tst_qdeclarativelanguage::declaredPropertyValues() } // Check that first child of qml is of given type. Empty type insists on error. -void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type) +void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type, const QString& expectederror) { QDeclarativeComponent component(&engine); component.setData(qml.toUtf8(), TEST_FILE("empty.qml")); // just a file for relative local imports @@ -1078,6 +1099,13 @@ void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type) if (type.isEmpty()) { QVERIFY(component.isError()); + QString actualerror; + foreach (const QDeclarativeError e, component.errors()) { + if (!actualerror.isEmpty()) + actualerror.append("; "); + actualerror.append(e.description()); + } + QCOMPARE(actualerror,expectederror); } else { VERIFY_ERRORS(0); QObject *object = component.create(); @@ -1097,156 +1125,199 @@ void tst_qdeclarativelanguage::importsBuiltin_data() QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("type"); + QTest::addColumn<QString>("error"); // import built-ins QTest::newRow("missing import") << "Test {}" - << ""; + << "" + << "Test is not a type"; QTest::newRow("not in version 0.0") << "import com.nokia.Test 0.0\n" "Test {}" - << ""; + << "" + << "Test is not a type"; + QTest::newRow("version not installed") + << "import com.nokia.Test 99.0\n" + "Test {}" + << "" + << "module \"com.nokia.Test\" version 99.0 is not installed"; QTest::newRow("in version 0.0") << "import com.nokia.Test 0.0\n" "TestTP {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("qualified in version 0.0") << "import com.nokia.Test 0.0 as T\n" "T.TestTP {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("in version 1.0") << "import com.nokia.Test 1.0\n" "Test {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("qualified wrong") << "import com.nokia.Test 1.0 as T\n" // QT-610 "Test {}" - << ""; + << "" + << "Test is not a type"; QTest::newRow("qualified right") << "import com.nokia.Test 1.0 as T\n" "T.Test {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("qualified right but not in version 0.0") << "import com.nokia.Test 0.0 as T\n" "T.Test {}" - << ""; + << "" + << "T.Test is not a type"; QTest::newRow("in version 1.1") << "import com.nokia.Test 1.1\n" "Test {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("in version 1.3") << "import com.nokia.Test 1.3\n" "Test {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("in version 1.5") << "import com.nokia.Test 1.5\n" "Test {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("changed in version 1.8") << "import com.nokia.Test 1.8\n" "Test {}" - << "TestType2"; + << "TestType2" + << ""; QTest::newRow("in version 1.12") << "import com.nokia.Test 1.12\n" "Test {}" - << "TestType2"; + << "TestType2" + << ""; QTest::newRow("old in version 1.9") << "import com.nokia.Test 1.9\n" "OldTest {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("old in version 1.11") << "import com.nokia.Test 1.11\n" "OldTest {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("multiversion 1") << "import com.nokia.Test 1.11\n" "import com.nokia.Test 1.12\n" "Test {}" - << "TestType2"; + << "TestType2" + << ""; QTest::newRow("multiversion 2") << "import com.nokia.Test 1.11\n" "import com.nokia.Test 1.12\n" "OldTest {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("qualified multiversion 3") << "import com.nokia.Test 1.0 as T0\n" "import com.nokia.Test 1.8 as T8\n" "T0.Test {}" - << "TestType"; + << "TestType" + << ""; QTest::newRow("qualified multiversion 4") << "import com.nokia.Test 1.0 as T0\n" "import com.nokia.Test 1.8 as T8\n" "T8.Test {}" - << "TestType2"; + << "TestType2" + << ""; } void tst_qdeclarativelanguage::importsBuiltin() { QFETCH(QString, qml); QFETCH(QString, type); - testType(qml,type); + QFETCH(QString, error); + testType(qml,type,error); } void tst_qdeclarativelanguage::importsLocal_data() { QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("type"); + QTest::addColumn<QString>("error"); // import locals QTest::newRow("local import") << "import \"subdir\"\n" // QT-613 "Test {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("local import second") << "import Qt 4.6\nimport \"subdir\"\n" "Test {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("local import subsubdir") << "import Qt 4.6\nimport \"subdir/subsubdir\"\n" "SubTest {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("local import QTBUG-7721 A") << "subdir.Test {}" // no longer allowed (QTBUG-7721) - << ""; + << "" + << "subdir.Test is not a type"; QTest::newRow("local import QTBUG-7721 B") << "import \"subdir\" as X\n" "X.subsubdir.SubTest {}" // no longer allowed (QTBUG-7721) - << ""; + << "" + << "X.subsubdir.SubTest is not a type"; QTest::newRow("local import as") << "import \"subdir\" as T\n" "T.Test {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("wrong local import as") << "import \"subdir\" as T\n" "Test {}" - << ""; + << "" + << "Test is not a type"; QTest::newRow("library precedence over local import") << "import \"subdir\"\n" "import com.nokia.Test 1.0\n" "Test {}" - << "TestType"; + << "TestType" + << ""; } void tst_qdeclarativelanguage::importsLocal() { QFETCH(QString, qml); QFETCH(QString, type); - testType(qml,type); + QFETCH(QString, error); + testType(qml,type,error); } void tst_qdeclarativelanguage::importsRemote_data() { QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("type"); + QTest::addColumn<QString>("error"); QString serverdir = "http://127.0.0.1:14445/qtest/declarative/qmllanguage"; - QTest::newRow("remote import") << "import \""+serverdir+"\"\nTest {}" << "QDeclarativeRectangle"; - QTest::newRow("remote import with subdir") << "import \""+serverdir+"\"\nTestSubDir {}" << "QDeclarativeText"; - QTest::newRow("remote import with local") << "import \""+serverdir+"\"\nTestLocal {}" << "QDeclarativeImage"; - QTest::newRow("wrong remote import with undeclared local") << "import \""+serverdir+"\"\nWrongTestLocal {}" << ""; - QTest::newRow("wrong remote import of internal local") << "import \""+serverdir+"\"\nLocalInternal {}" << ""; - QTest::newRow("wrong remote import of undeclared local") << "import \""+serverdir+"\"\nUndeclaredLocal {}" << ""; + QTest::newRow("remote import") << "import \""+serverdir+"\"\nTest {}" << "QDeclarativeRectangle" + << ""; + QTest::newRow("remote import with subdir") << "import \""+serverdir+"\"\nTestSubDir {}" << "QDeclarativeText" + << ""; + QTest::newRow("remote import with local") << "import \""+serverdir+"\"\nTestLocal {}" << "QDeclarativeImage" + << ""; + QTest::newRow("wrong remote import with undeclared local") << "import \""+serverdir+"\"\nWrongTestLocal {}" << "" + << "WrongTestLocal is not a type"; + QTest::newRow("wrong remote import of internal local") << "import \""+serverdir+"\"\nLocalInternal {}" << "" + << "LocalInternal is not a type"; + QTest::newRow("wrong remote import of undeclared local") << "import \""+serverdir+"\"\nUndeclaredLocal {}" << "" + << "UndeclaredLocal is not a type"; } #include "testhttpserver.h" @@ -1255,11 +1326,12 @@ void tst_qdeclarativelanguage::importsRemote() { QFETCH(QString, qml); QFETCH(QString, type); + QFETCH(QString, error); TestHTTPServer server(14445); server.serveDirectory(SRCDIR); - testType(qml,type); + testType(qml,type,error); } void tst_qdeclarativelanguage::importsInstalled_data() @@ -1268,43 +1340,57 @@ void tst_qdeclarativelanguage::importsInstalled_data() QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("type"); + QTest::addColumn<QString>("error"); // import installed QTest::newRow("installed import 0") << "import com.nokia.installedtest 0.0\n" "InstalledTestTP {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("installed import 0 as TP") << "import com.nokia.installedtest 0.0 as TP\n" "TP.InstalledTestTP {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("installed import 1") << "import com.nokia.installedtest 1.0\n" "InstalledTest {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("installed import 2") << "import com.nokia.installedtest 1.3\n" "InstalledTest {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("installed import 3") << "import com.nokia.installedtest 1.4\n" "InstalledTest {}" - << "QDeclarativeText"; - QTest::newRow("installed import 4") + << "QDeclarativeText" + << ""; + QTest::newRow("installed import minor version not available") // QTBUG-9627 << "import com.nokia.installedtest 1.10\n" "InstalledTest {}" - << "QDeclarativeText"; + << "" + << "module \"com.nokia.installedtest\" version 1.10 is not installed"; + QTest::newRow("installed import major version not available") // QTBUG-9627 + << "import com.nokia.installedtest 9.0\n" + "InstalledTest {}" + << "" + << "module \"com.nokia.installedtest\" version 9.0 is not installed"; QTest::newRow("installed import visibility") // QT-614 << "import com.nokia.installedtest 1.4\n" "PrivateType {}" - << ""; + << "" + << "PrivateType is not a type"; } void tst_qdeclarativelanguage::importsInstalled() { QFETCH(QString, qml); QFETCH(QString, type); - testType(qml,type); + QFETCH(QString, error); + testType(qml,type,error); } @@ -1312,65 +1398,77 @@ void tst_qdeclarativelanguage::importsOrder_data() { QTest::addColumn<QString>("qml"); QTest::addColumn<QString>("type"); + QTest::addColumn<QString>("error"); QTest::newRow("installed import overrides 1") << "import com.nokia.installedtest 1.0\n" "import com.nokia.installedtest 1.4\n" "InstalledTest {}" - << "QDeclarativeText"; + << "QDeclarativeText" + << ""; QTest::newRow("installed import overrides 2") << "import com.nokia.installedtest 1.4\n" "import com.nokia.installedtest 1.0\n" "InstalledTest {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; 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 {}" - << "QDeclarativeText"; + << "QDeclarativeText" + << ""; 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 {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("installed import versus builtin 1") << "import com.nokia.installedtest 1.5\n" "import Qt 4.6\n" "Rectangle {}" - << "QDeclarativeRectangle"; + << "QDeclarativeRectangle" + << ""; QTest::newRow("installed import versus builtin 2") << "import Qt 4.6\n" "import com.nokia.installedtest 1.5\n" "Rectangle {}" - << "QDeclarativeText"; + << "QDeclarativeText" + << ""; QTest::newRow("namespaces cannot be overridden by types 1") << "import Qt 4.6 as Rectangle\n" "import com.nokia.installedtest 1.5\n" "Rectangle {}" - << ""; + << "" + << "Namespace Rectangle cannot be used as a type"; 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 {}" - << "QDeclarativeImage"; + << "QDeclarativeImage" + << ""; QTest::newRow("local last 1") << "LocalLast {}" - << "QDeclarativeText"; + << "QDeclarativeText" + << ""; QTest::newRow("local last 2") << "import com.nokia.installedtest 1.0\n" "LocalLast {}" - << "QDeclarativeRectangle"; // i.e. from com.nokia.installedtest, not data/LocalLast.qml + << "QDeclarativeRectangle" + << ""; // i.e. from com.nokia.installedtest, not data/LocalLast.qml } void tst_qdeclarativelanguage::importsOrder() { QFETCH(QString, qml); QFETCH(QString, type); - testType(qml,type); + QFETCH(QString, error); + testType(qml,type,error); } void tst_qdeclarativelanguage::qmlAttachedPropertiesObjectMethod() |