aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmljsscope
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2022-08-25 18:13:14 +0200
committerSami Shalayel <sami.shalayel@qt.io>2022-09-08 12:46:26 +0200
commitc4d875fa95f33aaca557c3e6f98894bd9de79478 (patch)
tree0179b953f40adb615e5291e7ffa0e40caf81badb /tests/auto/qml/qqmljsscope
parent6b5cf5969889a88d5f506692c859d1bd4f59d5dd (diff)
qqmljsscope: track inline component names
This patch tracks inline component names to qqmljsscope, which will be useful in a later patch in qmltc to support inline components. Also adds a hashable type representing either the document root or the inline component name that will serve later in qmltcvisitor to separate types by inline components/document root. Implementation details: * Extend qqmljsscope + qqmljsimportvisitor ** keep track of inline component names in visitor and qqmljsscope ** types know (through their parent) if they are inside an inline component and their inline component name * added tests: ** see if QQmlJSScope can detect implicitly wrapped components inside of inline components Change-Id: I9b8b4eefe147f8f826820c3e9dabf3733b0f2d6f Task-Id: QTBUG-105946 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmljsscope')
-rw-r--r--tests/auto/qml/qqmljsscope/data/componentWrappedObjects.qml14
-rw-r--r--tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp9
2 files changed, 22 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmljsscope/data/componentWrappedObjects.qml b/tests/auto/qml/qqmljsscope/data/componentWrappedObjects.qml
index e58e3f3148..9483949e02 100644
--- a/tests/auto/qml/qqmljsscope/data/componentWrappedObjects.qml
+++ b/tests/auto/qml/qqmljsscope/data/componentWrappedObjects.qml
@@ -7,4 +7,18 @@ Item {
property Component nonWrapped3: DelegateChooser { property int nonWrapped3 }
property Component wrapped: Text { property int wrapped }
+
+ component MyInlineComponent: Item {
+ property Component wrapped: Text { property int wrapped }
+
+ TableView {
+ delegate: Text { property int wrapped2 }
+ }
+
+ TableView {
+ delegate: ComponentType { property int wrapped3 }
+ }
+ }
+
+ property var wrappedInInlineComponent: MyInlineComponent {}
}
diff --git a/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp b/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp
index 69fc55b05f..315b085f1e 100644
--- a/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp
+++ b/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp
@@ -240,7 +240,7 @@ void tst_qqmljsscope::componentWrappedObjects()
QVERIFY(root);
auto children = root->childScopes();
- QCOMPARE(children.size(), 4);
+ QCOMPARE(children.size(), 6);
const auto isGoodType = [](const QQmlJSScope::ConstPtr &type, const QString &propertyName,
bool isWrapped) {
@@ -252,6 +252,13 @@ void tst_qqmljsscope::componentWrappedObjects()
QVERIFY(isGoodType(children[1], u"nonWrapped2"_s, false));
QVERIFY(isGoodType(children[2], u"nonWrapped3"_s, false));
QVERIFY(isGoodType(children[3], u"wrapped"_s, true));
+ QCOMPARE(children[4]->childScopes().size(), 3);
+ QVERIFY(isGoodType(children[4]->childScopes()[0], u"wrapped"_s, true));
+
+ QCOMPARE(children[4]->childScopes()[1]->childScopes().size(), 1);
+ QVERIFY(isGoodType(children[4]->childScopes()[1]->childScopes()[0], u"wrapped2"_s, true));
+ QCOMPARE(children[4]->childScopes()[2]->childScopes().size(), 1);
+ QVERIFY(isGoodType(children[4]->childScopes()[2]->childScopes()[0], u"wrapped3"_s, false));
}
void tst_qqmljsscope::labsQmlModelsSanity()