--- /dev/null
+import QtQuick 2.0
+import "NestedDirOne"
+import "NestedDirOne/NestedDirTwo/../../../SpecificComponent"
+
+// NestedDirectoriesTopLevelComponent
+
+Item {
+ id: ndtlcId
+ property NDComponentOne a: NDComponentOne { }
+ property NDComponentOne b: NDComponentOne { }
+ property SpecificComponent scOne: SpecificComponent { }
+ property SpecificComponent scTwo
+
+ function assignScTwo() {
+ // It seems that doing this in onCompleted doesn't work,
+ // since that handler will be evaluated after the
+ // componentUrlCanonicalization.3.qml onCompleted handler.
+ // So, call this function manually....
+ var c1 = Qt.createComponent("NestedDirOne/NestedDirTwo/NDComponentTwo.qml");
+ var o1 = c1.createObject(ndtlcId);
+ scTwo = o1.sc;
+ }
+}
--- /dev/null
+import QtQuick 2.0
+import "../../SpecificComponent"
+import "NestedDirTwo"
+
+Item {
+ property int a
+ property NDComponentTwo b: NDComponentTwo { }
+ property SpecificComponent sc: SpecificComponent { }
+}
--- /dev/null
+import QtQuick 2.0
+import "../../../SpecificComponent"
+
+Item {
+ property SpecificComponent sc: SpecificComponent { }
+}
--- /dev/null
+NDComponentTwo 1.0 NDComponentTwo.qml
--- /dev/null
+NDComponentOne 1.0 NDComponentOne.qml
--- /dev/null
+NDTLC 1.0 NDTLC.qml
--- /dev/null
+import QtQuick 2.0
+import "../SpecificComponent"
+
+Item {
+ property SpecificComponent sc: SpecificComponent { }
+}
--- /dev/null
+OtherComponent 1.0 OtherComponent.qml
--- /dev/null
+import QtQuick 2.0
+
+Item {
+ // ensure we have a dynamic meta object
+ property int someInt: 5
+ property var someVar: 12
+}
--- /dev/null
+SpecificComponent 1.0 SpecificComponent.qml
--- /dev/null
+import QtQuick 2.0
+import "SpecificComponent"
+
+Item {
+ id: root
+ property SpecificComponent first
+ property SpecificComponent second
+
+ property bool success: false
+
+ Component.onCompleted: {
+ var c1 = Qt.createComponent("./SpecificComponent/SpecificComponent.qml");
+ var o1 = c1.createObject(root);
+ first = o1;
+
+ var c2 = Qt.createComponent("./OtherComponent/OtherComponent.qml");
+ var o2 = c2.createObject(root);
+ second = o2.sc;
+
+ var ft = first.toString().substr(0, first.toString().indexOf('('));
+ var st = second.toString().substr(0, second.toString().indexOf('('));
+ if (ft == st) success = true;
+ }
+}
--- /dev/null
+import QtQuick 2.0
+import "SpecificComponent"
+import "OtherComponent"
+import "NestedDirectories"
+
+Item {
+ id: root
+
+ property SpecificComponent scOne
+ property SpecificComponent scTwo
+ property SpecificComponent scThree
+ property SpecificComponent scFour
+ property SpecificComponent scFive
+ property SpecificComponent scSix
+ property SpecificComponent scSeven
+ property SpecificComponent scEight
+
+ property OtherComponent ocOne: OtherComponent { }
+ property NDTLC ndtlc: NDTLC { }
+
+ property bool success: false
+
+ Component.onCompleted: {
+ var c1 = Qt.createComponent("./SpecificComponent/SpecificComponent.qml");
+ var o1 = c1.createObject(root);
+ scOne = o1;
+ scTwo = ocOne.sc;
+ scThree = ndtlc.a.sc;
+ scFour = ndtlc.b.sc;
+ scFive = ndtlc.a.b.sc;
+ scSix = ndtlc.b.b.sc;
+ scSeven = ndtlc.scOne;
+ ndtlc.assignScTwo(); // XXX should be able to do this in NDTLC.onCompleted handler?!
+ scEight = ndtlc.scTwo;
+
+ // in our case, the type string should be:
+ // SpecificComponent_QMLTYPE_0
+ var t1 = scOne.toString().substr(0, scOne.toString().indexOf('('));
+ var t2 = scTwo.toString().substr(0, scTwo.toString().indexOf('('));
+ var t3 = scThree.toString().substr(0, scThree.toString().indexOf('('));
+ var t4 = scFour.toString().substr(0, scFour.toString().indexOf('('));
+ var t5 = scFive.toString().substr(0, scFive.toString().indexOf('('));
+ var t6 = scSix.toString().substr(0, scSix.toString().indexOf('('));
+ var t7 = scSeven.toString().substr(0, scSeven.toString().indexOf('('));
+ var t8 = scEight.toString().substr(0, scEight.toString().indexOf('('));
+
+ if (t1 == t2 && t2 == t3 && t3 == t4 && t4 == t5 && t5 == t6 && t6 == t7 && t7 == t8) {
+ success = true;
+ } else {
+ success = false;
+ }
+ }
+}
--- /dev/null
+import QtQuick 2.0
+import "SpecificComponent"
+import "OtherComponent"
+
+Item {
+ id: root
+ property SpecificComponent first
+ property SpecificComponent second
+ property OtherComponent oc: OtherComponent { }
+
+ property bool success: false
+
+ Component.onCompleted: {
+ var c1 = Qt.createComponent("./SpecificComponent/SpecificComponent.qml");
+ var o1 = c1.createObject(root);
+ first = o1;
+ second = oc.sc;
+
+ // We want to ensure that the types are the same, ie, that the
+ // component hasn't been registered twice due to failed
+ // canonicalization of the component path when importing.
+ // The type is reported in the toString() output prior to the
+ // instance pointer value.
+
+ // in our case, the type string should be:
+ // SpecificComponent_QMLTYPE_0
+ var ft = first.toString().substr(0, first.toString().indexOf('('));
+ var st = second.toString().substr(0, second.toString().indexOf('('));
+ if (ft == st) success = true;
+ }
+}
void qmlCreateParentReference();
void async();
void asyncHierarchy();
+ void componentUrlCanonicalization();
private:
QQmlEngine engine;
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"