aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
diff options
context:
space:
mode:
authorJaeyoon Jung <jaeyoon.jung@lge.com>2021-07-15 11:44:55 +0900
committerUlf Hermann <ulf.hermann@qt.io>2021-07-16 14:13:27 +0200
commitdd4a79c36b39415171ca2f4723b3cdd52e5eebd0 (patch)
tree8a2e6e43529394ee145065be94ebf69326d03154 /tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
parent98e60bef156f1606c3cf83a64965c9688bdbea17 (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. Pick-to: 6.2 Change-Id: Ic56a0952b16c4be016180c695d79089fc132319a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlimport/tst_qqmlimport.cpp')
-rw-r--r--tests/auto/qml/qqmlimport/tst_qqmlimport.cpp16
1 files changed, 16 insertions, 0 deletions
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)