summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-10-14 01:32:03 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-10-14 01:32:03 (GMT)
commit0a10af2463d73106c2f1268553aa6e60890f6180 (patch)
tree2ad916b6a98f16a4c3692a9e227da782dd3c42ac /tests/auto
parentc8198d40af104b5555a975b3156e9d5ba1981e25 (diff)
downloadQt-0a10af2463d73106c2f1268553aa6e60890f6180.zip
Qt-0a10af2463d73106c2f1268553aa6e60890f6180.tar.gz
Qt-0a10af2463d73106c2f1268553aa6e60890f6180.tar.bz2
Add Component::onCompleted attached property
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qmllanguage/data/OnCompletedType.qml8
-rw-r--r--tests/auto/declarative/qmllanguage/data/onCompleted.qml17
-rw-r--r--tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp13
3 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmllanguage/data/OnCompletedType.qml b/tests/auto/declarative/qmllanguage/data/OnCompletedType.qml
new file mode 100644
index 0000000..cdba495
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/OnCompletedType.qml
@@ -0,0 +1,8 @@
+import Test 1.0
+import Qt 4.6
+
+MyQmlObject {
+ property int a: Math.max(10, 9)
+ property int b: 11
+ Component.onCompleted: print("Completed " + a + " " + b);
+}
diff --git a/tests/auto/declarative/qmllanguage/data/onCompleted.qml b/tests/auto/declarative/qmllanguage/data/onCompleted.qml
new file mode 100644
index 0000000..ae47d4b
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/onCompleted.qml
@@ -0,0 +1,17 @@
+import Test 1.0
+import Qt 4.6
+
+MyTypeObject {
+ // We set a and b to ensure that onCompleted is executed after bindings and
+ // constants have been assigned
+ property int a: Math.min(6, 7)
+ Component.onCompleted: print("Completed " + a + " " + nestedObject.b)
+
+ objectProperty: OnCompletedType {
+ qmlobjectProperty: MyQmlObject {
+ id: nestedObject
+ property int b: 10
+ Component.onCompleted: print("Completed " + a + " " + nestedObject.b)
+ }
+ }
+}
diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
index cf42792..b99d040 100644
--- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
+++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
@@ -60,6 +60,7 @@ private slots:
void componentCompositeType();
void i18n();
void i18n_data();
+ void onCompleted();
void importsBuiltin_data();
void importsBuiltin();
@@ -705,6 +706,18 @@ void tst_qmllanguage::i18n()
delete object;
}
+// Check that the Component::onCompleted attached property works
+void tst_qmllanguage::onCompleted()
+{
+ QmlComponent component(&engine, TEST_FILE("onCompleted.qml"));
+ VERIFY_ERRORS(0);
+ QTest::ignoreMessage(QtDebugMsg, "Completed 6 10");
+ QTest::ignoreMessage(QtDebugMsg, "Completed 6 10");
+ QTest::ignoreMessage(QtDebugMsg, "Completed 10 11");
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
// Check that first child of qml is of given type. Empty type insists on error.
void tst_qmllanguage::testType(const QString& qml, const QString& type)
{