aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2012-04-19 17:30:59 +1000
committerQt by Nokia <qt-info@nokia.com>2012-04-23 02:05:22 +0200
commit6d2ed5d0b645f5af383a123e869d061b235b4b85 (patch)
tree72034ba88aff417ece70cc3d57e73c50b4a900bb /tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
parentb86b3bb0f44cdbdb21413b967be67d37b7fefa64 (diff)
Add some component path canonicalization tests
Previously, no unit test existed to ensure that url canonicalization worked correctly, which could result in two import statements using relative paths to the same actual component triggering two separate types being generated. This commit adds a unit test with various relative-addressing and both static and dynamic imports, to enforce type-consistency. Change-Id: I7772e3c531069322d5fa44063cbf57a758ed3710 Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp')
-rw-r--r--tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
index 10181aa9b8..eebb558bce 100644
--- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
+++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
@@ -111,6 +111,7 @@ private slots:
void qmlCreateParentReference();
void async();
void asyncHierarchy();
+ void componentUrlCanonicalization();
private:
QQmlEngine engine;
@@ -314,6 +315,42 @@ void tst_qqmlcomponent::asyncHierarchy()
delete root;
}
+void tst_qqmlcomponent::componentUrlCanonicalization()
+{
+ // ensure that url canonicalization succeeds so that type information
+ // is not generated multiple times for the same component.
+ {
+ // load components via import
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("componentUrlCanonicalization.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->property("success").toBool());
+ delete object;
+ }
+
+ {
+ // load one of the components dynamically, which would trigger
+ // import of the other if it were not already loaded.
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("componentUrlCanonicalization.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->property("success").toBool());
+ delete object;
+ }
+
+ {
+ // load components with more deeply nested imports
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("componentUrlCanonicalization.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->property("success").toBool());
+ delete object;
+ }
+}
+
QTEST_MAIN(tst_qqmlcomponent)
#include "tst_qqmlcomponent.moc"