aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJaeyoon Jung <jaeyoon.jung@lge.com>2021-07-15 11:44:55 +0900
committerJaeyoon Jung <jaeyoon.jung@lge.com>2021-07-21 10:44:52 +0900
commit88e482a9a0355cdf92dda6535168c0c2df9a2655 (patch)
tree9bc1d1b91d36b46986f7ef92a48f6423007fb768 /tests
parent75ca259e523973b674b6a978d7c2284f5dc1ef9f (diff)
Fix qmldir cache inconsistency
If there are multiple qmldir entries for the same QML module in the import list, the one that comes first should take precedence. The same applies when constructing the qmldir cache. We can achieve that by inserting the entries into the cache in the same order they appear in the completeQmldirPaths list. Change-Id: Ic56a0952b16c4be016180c695d79089fc132319a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit dd4a79c36b39415171ca2f4723b3cdd52e5eebd0) Reviewed-by: Jaeyoon Jung <jaeyoon.jung@lge.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlimport/data/importPathOrder/MyModuleTest.qml7
-rw-r--r--tests/auto/qml/qqmlimport/data/importPathOrder/MyView.qml3
-rw-r--r--tests/auto/qml/qqmlimport/data/importPathOrder/path1/MyModule/MyItem.qml6
-rw-r--r--tests/auto/qml/qqmlimport/data/importPathOrder/path1/MyModule/qmldir3
-rw-r--r--tests/auto/qml/qqmlimport/data/importPathOrder/path2/MyModule/MyItem.qml6
-rw-r--r--tests/auto/qml/qqmlimport/data/importPathOrder/path2/MyModule/qmldir3
-rw-r--r--tests/auto/qml/qqmlimport/tst_qqmlimport.cpp16
7 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlimport/data/importPathOrder/MyModuleTest.qml b/tests/auto/qml/qqmlimport/data/importPathOrder/MyModuleTest.qml
new file mode 100644
index 0000000000..5ac9ec4fb2
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/data/importPathOrder/MyModuleTest.qml
@@ -0,0 +1,7 @@
+import QtQuick
+import MyModule
+
+Item {
+ MyItem { objectName: "myItem1" }
+ MyView {}
+}
diff --git a/tests/auto/qml/qqmlimport/data/importPathOrder/MyView.qml b/tests/auto/qml/qqmlimport/data/importPathOrder/MyView.qml
new file mode 100644
index 0000000000..a4fdcb51a0
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/data/importPathOrder/MyView.qml
@@ -0,0 +1,3 @@
+import MyModule
+
+MyItem { objectName: "myItem2" }
diff --git a/tests/auto/qml/qqmlimport/data/importPathOrder/path1/MyModule/MyItem.qml b/tests/auto/qml/qqmlimport/data/importPathOrder/path1/MyModule/MyItem.qml
new file mode 100644
index 0000000000..3da82d1b77
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/data/importPathOrder/path1/MyModule/MyItem.qml
@@ -0,0 +1,6 @@
+import QtQuick
+
+Item {
+ width: 100
+ height: 100
+}
diff --git a/tests/auto/qml/qqmlimport/data/importPathOrder/path1/MyModule/qmldir b/tests/auto/qml/qqmlimport/data/importPathOrder/path1/MyModule/qmldir
new file mode 100644
index 0000000000..edfd2c9462
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/data/importPathOrder/path1/MyModule/qmldir
@@ -0,0 +1,3 @@
+module MyModule
+
+MyItem MyItem.qml
diff --git a/tests/auto/qml/qqmlimport/data/importPathOrder/path2/MyModule/MyItem.qml b/tests/auto/qml/qqmlimport/data/importPathOrder/path2/MyModule/MyItem.qml
new file mode 100644
index 0000000000..ed02d2df7a
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/data/importPathOrder/path2/MyModule/MyItem.qml
@@ -0,0 +1,6 @@
+import QtQuick
+
+Item {
+ width: 200
+ height: 200
+}
diff --git a/tests/auto/qml/qqmlimport/data/importPathOrder/path2/MyModule/qmldir b/tests/auto/qml/qqmlimport/data/importPathOrder/path2/MyModule/qmldir
new file mode 100644
index 0000000000..edfd2c9462
--- /dev/null
+++ b/tests/auto/qml/qqmlimport/data/importPathOrder/path2/MyModule/qmldir
@@ -0,0 +1,3 @@
+module MyModule
+
+MyItem MyItem.qml
diff --git a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
index 4f2b4f6b13..572c8771a0 100644
--- a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
+++ b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
@@ -205,6 +205,22 @@ void tst_QQmlImport::importPathOrder()
engine.addImportPath(qml2Imports);
expectedImportPaths.move(expectedImportPaths.indexOf(qml2Imports), 0);
QCOMPARE(engine.importPathList(), expectedImportPaths);
+
+ // Verify if the type in the module comes first in the import path list
+ // takes the precedence. In the case below, the width of both items
+ // should be the same to that of the type defined in "path2".
+ engine.addImportPath(testFile("importPathOrder/path1"));
+ engine.addImportPath(testFile("importPathOrder/path2"));
+ QQmlComponent component(&engine, testFile("importPathOrder/MyModuleTest.qml"));
+ QScopedPointer<QObject> rootItem(component.create());
+ QVERIFY(component.errorString().isEmpty());
+ QVERIFY(!rootItem.isNull());
+ QQuickItem *item1 = rootItem->findChild<QQuickItem*>("myItem1");
+ QQuickItem *item2 = rootItem->findChild<QQuickItem*>("myItem2");
+ QVERIFY(item1 != nullptr);
+ QVERIFY(item2 != nullptr);
+ QCOMPARE(item1->width(), 200);
+ QCOMPARE(item2->width(), 200);
}
Q_DECLARE_METATYPE(QQmlImports::ImportVersion)