From bb1c58a6d713feb7daab89449c8eb4185e542e5c Mon Sep 17 00:00:00 2001 From: Sami Shalayel Date: Tue, 29 Sep 2026 11:23:17 +0200 Subject: 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 --- .../qqmlcodemodel/tst_qmlls_qqmlcodemodel.cpp | 43 ++++++++++++---------- 1 file 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() -- cgit v1.2.3