diff options
Diffstat (limited to 'tests/auto/qml/qqmlimport/tst_qqmlimport.cpp')
-rw-r--r-- | tests/auto/qml/qqmlimport/tst_qqmlimport.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp index bd29b8f18b..33a6c6f9cb 100644 --- a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp +++ b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp @@ -52,6 +52,7 @@ class tst_QQmlImport : public QQmlDataTest private slots: void testDesignerSupported(); + void uiFormatLoading(); void cleanup(); }; @@ -95,6 +96,45 @@ void tst_QQmlImport::testDesignerSupported() delete window; } +void tst_QQmlImport::uiFormatLoading() +{ + int size = 0; + + QQmlApplicationEngine *test = new QQmlApplicationEngine(testFileUrl("TestForm.ui.qml")); + test->addImportPath(QT_TESTCASE_BUILDDIR); + QCOMPARE(test->rootObjects().size(), ++size); + QVERIFY(test->rootObjects()[size -1]); + QVERIFY(test->rootObjects()[size -1]->property("success").toBool()); + + QSignalSpy objectCreated(test, SIGNAL(objectCreated(QObject*,QUrl))); + test->load(testFileUrl("TestForm.ui.qml")); + QCOMPARE(objectCreated.count(), size);//one less than rootObjects().size() because we missed the first one + QCOMPARE(test->rootObjects().size(), ++size); + QVERIFY(test->rootObjects()[size -1]); + QVERIFY(test->rootObjects()[size -1]->property("success").toBool()); + + QByteArray testQml("import QtQml 2.0; QtObject{property bool success: true; property TestForm t: TestForm{}}"); + test->loadData(testQml, testFileUrl("dynamicTestForm.ui.qml")); + QCOMPARE(objectCreated.count(), size); + QCOMPARE(test->rootObjects().size(), ++size); + QVERIFY(test->rootObjects()[size -1]); + QVERIFY(test->rootObjects()[size -1]->property("success").toBool()); + + test->load(testFileUrl("openTestFormFromDir.qml")); + QCOMPARE(objectCreated.count(), size); + QCOMPARE(test->rootObjects().size(), ++size); + QVERIFY(test->rootObjects()[size -1]); + QVERIFY(test->rootObjects()[size -1]->property("success").toBool()); + + test->load(testFileUrl("openTestFormFromQmlDir.qml")); + QCOMPARE(objectCreated.count(), size); + QCOMPARE(test->rootObjects().size(), ++size); + QVERIFY(test->rootObjects()[size -1]); + QVERIFY(test->rootObjects()[size -1]->property("success").toBool()); + + delete test; +} + QTEST_MAIN(tst_QQmlImport) #include "tst_qqmlimport.moc" |