summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qmllanguage
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-11-17 06:13:06 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-11-17 06:13:06 (GMT)
commit4e126f5222a3c62a46037c4ac40743f9f2ee9026 (patch)
tree296c7b4bfce7246cfb6384e4e2b0da025a78a727 /tests/auto/declarative/qmllanguage
parentc68f26e2d36b57c3872087722b278ce96829b692 (diff)
downloadQt-4e126f5222a3c62a46037c4ac40743f9f2ee9026.zip
Qt-4e126f5222a3c62a46037c4ac40743f9f2ee9026.tar.gz
Qt-4e126f5222a3c62a46037c4ac40743f9f2ee9026.tar.bz2
tests
Diffstat (limited to 'tests/auto/declarative/qmllanguage')
-rw-r--r--tests/auto/declarative/qmllanguage/data/DynamicPropertiesNestedType.qml6
-rw-r--r--tests/auto/declarative/qmllanguage/data/dynamicProperties.qml1
-rw-r--r--tests/auto/declarative/qmllanguage/data/dynamicPropertiesNested.qml9
-rw-r--r--tests/auto/declarative/qmllanguage/data/dynamicSignalsAndSlots.qml3
-rw-r--r--tests/auto/declarative/qmllanguage/data/listProperties.qml9
-rw-r--r--tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp34
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()