diff options
Diffstat (limited to 'tests/auto/declarative')
6 files changed, 62 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmllanguage/data/DynamicPropertiesNestedType.qml b/tests/auto/declarative/qmllanguage/data/DynamicPropertiesNestedType.qml new file mode 100644 index 0000000..5c2edb4 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/DynamicPropertiesNestedType.qml @@ -0,0 +1,6 @@ +import Qt 4.6 + +Object { + property int super_a: 10 + property int super_c: 14 +} diff --git a/tests/auto/declarative/qmllanguage/data/dynamicProperties.qml b/tests/auto/declarative/qmllanguage/data/dynamicProperties.qml index f93e446..17fa974 100644 --- a/tests/auto/declarative/qmllanguage/data/dynamicProperties.qml +++ b/tests/auto/declarative/qmllanguage/data/dynamicProperties.qml @@ -7,6 +7,7 @@ Object { property real realProperty: -19.9 property string stringProperty: "Hello World!" property color colorProperty: "red" + property url urlProperty: "main.qml" property date dateProperty: "1945-09-02" property var varProperty: "Hello World!" property variant variantProperty: 12 diff --git a/tests/auto/declarative/qmllanguage/data/dynamicPropertiesNested.qml b/tests/auto/declarative/qmllanguage/data/dynamicPropertiesNested.qml new file mode 100644 index 0000000..7bfab67 --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/dynamicPropertiesNested.qml @@ -0,0 +1,9 @@ +import Qt 4.6 + +DynamicPropertiesNestedType { + property int a: 13 + property int b: 12 + + super_a: 11 +} + diff --git a/tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml b/tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml index b0ca970..72ec218 100644 --- a/tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml +++ b/tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml @@ -4,4 +4,7 @@ Object { function slot1() {} signal signal2 function slot2() {} + + property int test: 0 + function slot3(a) { print(1921); test = a; } } diff --git a/tests/auto/declarative/qmllanguage/data/listProperties.qml b/tests/auto/declarative/qmllanguage/data/listProperties.qml new file mode 100644 index 0000000..c39ceae --- /dev/null +++ b/tests/auto/declarative/qmllanguage/data/listProperties.qml @@ -0,0 +1,9 @@ +import Qt 4.6 + +Object { + property list<Object> listProperty + property int test: listProperty.length + + listProperty: [ Object{}, Object {} ] +} + diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp index d5c5c4d..892d2eb 100644 --- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp +++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp @@ -91,6 +91,8 @@ private slots: void idProperty(); void assignSignal(); void dynamicProperties(); + void dynamicPropertiesNested(); + void listProperties(); void dynamicObjectProperties(); void dynamicSignalsAndSlots(); void simpleBindings(); @@ -554,12 +556,40 @@ void tst_qmllanguage::dynamicProperties() QCOMPARE(object->property("doubleProperty"), QVariant(-10.1)); QCOMPARE(object->property("realProperty"), QVariant((qreal)-19.9)); QCOMPARE(object->property("stringProperty"), QVariant("Hello World!")); + QCOMPARE(object->property("urlProperty"), QVariant(TEST_FILE("main.qml"))); QCOMPARE(object->property("colorProperty"), QVariant(QColor("red"))); QCOMPARE(object->property("dateProperty"), QVariant(QDate(1945, 9, 2))); QCOMPARE(object->property("varProperty"), QVariant("Hello World!")); QCOMPARE(object->property("variantProperty"), QVariant(12)); } +// Test that nested types can use dynamic properties +void tst_qmllanguage::dynamicPropertiesNested() +{ + QmlComponent component(&engine, TEST_FILE("dynamicPropertiesNested.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("super_a").toInt(), 11); // Overridden + QCOMPARE(object->property("super_c").toInt(), 14); // Inherited + QCOMPARE(object->property("a").toInt(), 13); // New + QCOMPARE(object->property("b").toInt(), 12); // New + + delete object; +} + +// Tests the creation and assignment to dynamic list properties +void tst_qmllanguage::listProperties() +{ + QmlComponent component(&engine, TEST_FILE("listProperties.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toInt(), 2); +} + // Tests the creation and assignment of dynamic object properties // ### Not complete void tst_qmllanguage::dynamicObjectProperties() @@ -584,6 +614,10 @@ void tst_qmllanguage::dynamicSignalsAndSlots() QVERIFY(object->metaObject()->indexOfMethod("signal2()") != -1); QVERIFY(object->metaObject()->indexOfMethod("slot1()") != -1); QVERIFY(object->metaObject()->indexOfMethod("slot2()") != -1); + + QCOMPARE(object->property("test").toInt(), 0); + QMetaObject::invokeMethod(object, "slot3", Qt::DirectConnection, Q_ARG(QVariant, QVariant(10))); + QCOMPARE(object->property("test").toInt(), 10); } void tst_qmllanguage::simpleBindings() |