aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmltc_qprocess
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2022-09-09 13:47:28 +0200
committerSami Shalayel <sami.shalayel@qt.io>2022-09-26 10:59:15 +0200
commitb89a92053e1a4565d37f75831db1c6c90c21bce6 (patch)
tree56f19730877d4da6c5b0ea1ebf4f7a1d4ac7a3ee /tests/auto/qml/qmltc_qprocess
parent60ca8dae85de1bd0df4d549f237534c68d75091c (diff)
qmltc: support basic inline components
This patch adds basic inline component support to qmltc. Implementation details: * added tests: ** (for all tests: see if QQmlComponent would do the same thing) ** try simple inline components ** try inline components extending other inline components ** try recursive inline components (inline component A contain a B that itself contains a A) ** make sure ids in inline components are in their own context, and ** make sure alias inside of inline components work ** remove qmltc_qprocess that tests the error message when inline components are encountered ** test that inline components get their own context (by aliasing a property that they should not be able to see) ** test that also empty components work ** other tests inspired from those at tst_qqmllanguage * separate types depending on the inline component they belong in qmltcvisitor and qmltccompiler ** mostly by replacing T with QHash<QString, T>, where the belonging inline component name serves as hash key ** added a list of inline component names in qmltc * generate correct qmltc-code for inline components ** as they sometimes have mimic a document root and sometimes not ** generate their own "typeCount"-method ** fixed naming used in qmltc generated code by using the inline component names from the qqmljsscope. There is one missing feature (using inline components from other files, using QmlFileName.MyInlineComponent) that will be added in a separate commit. Fixes: QTBUG-106882 Change-Id: Iabe1a8b787027367d73d34bcd93c5f7b5480d217 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qmltc_qprocess')
-rw-r--r--tests/auto/qml/qmltc_qprocess/CMakeLists.txt2
-rw-r--r--tests/auto/qml/qmltc_qprocess/data/inlineComponent.qml5
-rw-r--r--tests/auto/qml/qmltc_qprocess/data/inlineComponentInvalidAlias.qml11
-rw-r--r--tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp5
4 files changed, 14 insertions, 9 deletions
diff --git a/tests/auto/qml/qmltc_qprocess/CMakeLists.txt b/tests/auto/qml/qmltc_qprocess/CMakeLists.txt
index 53319256c4..7b52c3436f 100644
--- a/tests/auto/qml/qmltc_qprocess/CMakeLists.txt
+++ b/tests/auto/qml/qmltc_qprocess/CMakeLists.txt
@@ -17,7 +17,7 @@ qt6_add_qml_module(tst_qmltc_qprocess
cpptypes/testtype.h
QML_FILES
data/dummy.qml
- data/inlineComponent.qml
+ data/inlineComponentInvalidAlias.qml
data/SingletonThing.qml
data/erroneousFile.qml
data/invalidAliasRevision.qml
diff --git a/tests/auto/qml/qmltc_qprocess/data/inlineComponent.qml b/tests/auto/qml/qmltc_qprocess/data/inlineComponent.qml
deleted file mode 100644
index f8515b6d1b..0000000000
--- a/tests/auto/qml/qmltc_qprocess/data/inlineComponent.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import QtQml
-QtObject {
- component InlineType : QtObject { }
- property QtObject dummy: InlineType {}
-}
diff --git a/tests/auto/qml/qmltc_qprocess/data/inlineComponentInvalidAlias.qml b/tests/auto/qml/qmltc_qprocess/data/inlineComponentInvalidAlias.qml
new file mode 100644
index 0000000000..30ba6ad0bb
--- /dev/null
+++ b/tests/auto/qml/qmltc_qprocess/data/inlineComponentInvalidAlias.qml
@@ -0,0 +1,11 @@
+import QtQuick 2.15
+
+// tests that inline components get their own context
+
+Item {
+ id: root
+ property string hello: "hello"
+ component MyComponent: Item {
+ property alias myHello: root.hello // not allowed: accessing stuff from outside component
+ }
+}
diff --git a/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp b/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp
index 8b894da3da..ac78de3713 100644
--- a/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp
+++ b/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp
@@ -176,9 +176,8 @@ void tst_qmltc_qprocess::noQtQml()
void tst_qmltc_qprocess::inlineComponent()
{
- const auto errors = runQmltc(u"inlineComponent.qml"_s, false);
- QEXPECT_FAIL("", "qmltc does not support inline components at the moment", Continue);
- QVERIFY(!errors.contains(u"Inline components are not supported"_s));
+ const auto errors = runQmltc(u"inlineComponentInvalidAlias.qml"_s, false);
+ QVERIFY(errors.contains(u"Cannot resolve alias \"myHello\" [unresolved-alias]"_s));
}
void tst_qmltc_qprocess::singleton()