summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-10-22 01:11:27 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-10-22 01:12:36 (GMT)
commitfa3a9815a3c4b1b7cd464648e67c16d299773f87 (patch)
treeeb008ba1175cb82b2b5cefce919418dfda2e0d1b /tests/auto
parent9570e6ada20e34a1427a151118a3c0e510423a2d (diff)
downloadQt-fa3a9815a3c4b1b7cd464648e67c16d299773f87.zip
Qt-fa3a9815a3c4b1b7cd464648e67c16d299773f87.tar.gz
Qt-fa3a9815a3c4b1b7cd464648e67c16d299773f87.tar.bz2
Test createQmlObject URL resolution (must be relative to calling context).
Task-number:QT-2339 See also c1a241652c587e6da92bf853608aed37938e1e48 Also make test more data-driven (and hence independently reported).
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qmlecmascript/data/TypeForDynamicCreation.qml2
-rw-r--r--tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml5
-rw-r--r--tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp29
3 files changed, 25 insertions, 11 deletions
diff --git a/tests/auto/declarative/qmlecmascript/data/TypeForDynamicCreation.qml b/tests/auto/declarative/qmlecmascript/data/TypeForDynamicCreation.qml
new file mode 100644
index 0000000..56e0625
--- /dev/null
+++ b/tests/auto/declarative/qmlecmascript/data/TypeForDynamicCreation.qml
@@ -0,0 +1,2 @@
+import Qt.test 1.0
+MyQmlObject{objectName:"objectThree"}
diff --git a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml b/tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml
index ef39590..ed5e571 100644
--- a/tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml
+++ b/tests/auto/declarative/qmlecmascript/data/dynamicCreation.qml
@@ -13,4 +13,9 @@ MyQmlObject{
var component = createComponent('dynamicCreation.helper.qml');
obj.objectProperty = component.createObject();
}
+
+ function createThree()
+ {
+ obj.objectProperty = createQmlObject('TypeForDynamicCreation{}', obj);
+ }
}
diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
index f24882a..34b49e6 100644
--- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
+++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp
@@ -56,6 +56,7 @@ private slots:
void signalParameterTypes();
void objectsCompareAsEqual();
void scriptAccess();
+ void dynamicCreation_data();
void dynamicCreation();
void dynamicDestruction();
void objectToString();
@@ -639,27 +640,33 @@ void tst_qmlecmascript::scriptAccess()
QCOMPARE(object->property("test3").toInt(), 0);
}
+void tst_qmlecmascript::dynamicCreation_data()
+{
+ QTest::addColumn<QString>("method");
+ QTest::addColumn<QString>("createdName");
+
+ QTest::newRow("One") << "createOne" << "objectOne";
+ QTest::newRow("Two") << "createTwo" << "objectTwo";
+ QTest::newRow("Three") << "createThree" << "objectThree";
+}
+
/*
Test using createQmlObject to dynamically generate an item
Also using createComponent is tested.
*/
void tst_qmlecmascript::dynamicCreation()
{
+ QFETCH(QString, method);
+ QFETCH(QString, createdName);
+
QmlComponent component(&engine, TEST_FILE("dynamicCreation.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != 0);
- QObject *createdQmlObject = 0;
- QObject *createdComponent = 0;
-
- QMetaObject::invokeMethod(object, "createOne");
- createdQmlObject = object->objectProperty();
- QVERIFY(createdQmlObject);
- QCOMPARE(createdQmlObject->objectName(), QString("objectOne"));
- QMetaObject::invokeMethod(object, "createTwo");
- createdComponent = object->objectProperty();
- QVERIFY(createdComponent);
- QCOMPARE(createdComponent->objectName(), QString("objectTwo"));
+ QMetaObject::invokeMethod(object, method.toUtf8());
+ QObject *created = object->objectProperty();
+ QVERIFY(created);
+ QCOMPARE(created->objectName(), createdName);
}
/*