aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2026-09-29 11:23:17 +0200
committerSami Shalayel <sami.shalayel@qt.io>2026-09-30 16:03:58 +0000
commitbb1c58a6d713feb7daab89449c8eb4185e542e5c (patch)
tree3d2cafc513ad6b13367bf1a0878f1e98732a7b24
parenta3316a5a07f04bce869fe24f01ff738b2b8e79c1 (diff)
tst_qmlls_qqmlcodemodel.cpp: use QQmlJSScope to check loaded file path
Use the QQmlJSScope in the test to check the file paths of loaded dependencies, instead of using's the DOM dependency loading that will be removed in a later commit. QTBUG-150842 aims to remove the DOM dependency loading code, including the code that processes the imports and that loads the .qmldir of imported modules when opening a .qml file in the DOM. Task-number: QTBUG-150842 Change-Id: I590ad5824c66be5e4e8de75705f6fbf3cf76950f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--tests/auto/qmlls/qqmlcodemodel/tst_qmlls_qqmlcodemodel.cpp43
1 files changed, 23 insertions, 20 deletions
diff --git a/tests/auto/qmlls/qqmlcodemodel/tst_qmlls_qqmlcodemodel.cpp b/tests/auto/qmlls/qqmlcodemodel/tst_qmlls_qqmlcodemodel.cpp
index a63fc30cd0..76fe8aa48d 100644
--- a/tests/auto/qmlls/qqmlcodemodel/tst_qmlls_qqmlcodemodel.cpp
+++ b/tests/auto/qmlls/qqmlcodemodel/tst_qmlls_qqmlcodemodel.cpp
@@ -672,17 +672,19 @@ void tst_qmlls_qqmlcodemodel::withQmllsBuildIni()
// sanity check
QCOMPARE_NE(domItemA, domItemB);
- auto loadedQmldir = [](const DomItem &item) {
- return item[Fields::components]
- .key(QString())
- .index(0)[Fields::objects]
- .index(0)[Fields::prototypes]
- .index(0)[Fields::get][Fields::uri]
- .value()
- .toString();
+ auto compareBaseTypePath = [](const DomItem &item, const QString &baseTypePath) {
+ auto scope = item[Fields::components]
+ .key(QString())
+ .index(0)[Fields::objects]
+ .index(0)
+ .nearestSemanticScope();
+ QVERIFY(scope);
+ auto base = scope->baseType();
+ QVERIFY(base);
+ QCOMPARE(base->filePath(), baseTypePath);
};
- QCOMPARE(loadedQmldir(domItemA), "\"%1\""_L1.arg(importPathA + "MyModule/qmldir"_L1));
- QCOMPARE(loadedQmldir(domItemB), "\"%1\""_L1.arg(importPathB + "MyModule/qmldir"_L1));
+ compareBaseTypePath(domItemA, importPathA + "MyModule/MyItem.qml"_L1);
+ compareBaseTypePath(domItemB, importPathB + "MyModule/MyItem.qml"_L1);
}
void tst_qmlls_qqmlcodemodel::updateQmllsBuildIni()
@@ -810,17 +812,18 @@ void tst_qmlls_qqmlcodemodel::withQmllsBuildIniWithoutRootUrls()
DomItem domItemA = manager.snapshotByUrl(fileUrl).validDoc;
- auto loadedQmldir = [](const DomItem &item) {
- return item[Fields::components]
- .key(QString())
- .index(0)[Fields::objects]
- .index(0)[Fields::prototypes]
- .index(0)[Fields::get][Fields::uri]
- .value()
- .toString();
+ auto compareBaseTypePath = [](const DomItem &item, const QString &baseTypePath) {
+ auto scope = item[Fields::components]
+ .key(QString())
+ .index(0)[Fields::objects]
+ .index(0)
+ .nearestSemanticScope();
+ QVERIFY(scope);
+ auto base = scope->baseType();
+ QVERIFY(base);
+ QCOMPARE(base->filePath(), baseTypePath);
};
- QCOMPARE(loadedQmldir(domItemA),
- "\"%1\""_L1.arg(testFile("twoWorkspaces/ImportPathA/MyModule/qmldir")));
+ compareBaseTypePath(domItemA, testFile("twoWorkspaces/ImportPathA/MyModule/MyItem.qml"));
}
void tst_qmlls_qqmlcodemodel::shortestRootUrlForFile()