diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-05-04 15:39:57 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-05-04 18:59:34 +0200 |
commit | 96ac9c2599113b045b4f3ea71c4f20ead93a4c41 (patch) | |
tree | 248f8b24b43c8034da0755e53cbcc6746f8b7a96 /tests/auto | |
parent | 80ed6679cd31165c2bbd2c612e37c2f61e9075a3 (diff) | |
download | qtdeclarative-96ac9c2599113b045b4f3ea71c4f20ead93a4c41.tar.gz |
QmlCompiler: Convert thisObject to correct type
Amends commit 365b781599993aef933228599eaeb6eb909d9a93.
Change-Id: I5775d634ef4e5204cdec2f440b1992b7272866d2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/signalsWithLists.qml | 8 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 24 |
3 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt index ad8bcf32a9..461c84a76b 100644 --- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt +++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt @@ -190,6 +190,7 @@ set(qml_files signal.qml signalHandler.qml signalIndexMismatch.qml + signalsWithLists.qml signatureIgnored.qml specificParent.qml storeElementSideEffects.qml diff --git a/tests/auto/qml/qmlcppcodegen/data/signalsWithLists.qml b/tests/auto/qml/qmlcppcodegen/data/signalsWithLists.qml new file mode 100644 index 0000000000..91967e0bc0 --- /dev/null +++ b/tests/auto/qml/qmlcppcodegen/data/signalsWithLists.qml @@ -0,0 +1,8 @@ +pragma Strict +import QtQml +import TestTypes + +Person { + property list<var> varlist: [1, "foo", this, undefined, true] + property list<QtObject> objlist: [this, null, this] +} diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 20a1bac8af..8f6fdbb004 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -158,6 +158,7 @@ private slots: void shifts(); void signalHandler(); void signalIndexMismatch(); + void signalsWithLists(); void signatureIgnored(); void simpleBinding(); void storeElementSideEffects(); @@ -3310,6 +3311,29 @@ void tst_QmlCppCodegen::signalIndexMismatch() QCOMPARE(visualIndexAfterMoveList, QList<QVariant>({ 0, 1, 2 })); } +void tst_QmlCppCodegen::signalsWithLists() +{ + QQmlEngine engine; + QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/signalsWithLists.qml"_s)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QVERIFY(!o.isNull()); + + QVariantList varlist = o->property("varlist").toList(); + QCOMPARE(varlist.size(), 5); + QCOMPARE(varlist[0], QVariant::fromValue(1)); + QCOMPARE(varlist[1], QVariant::fromValue(u"foo"_s)); + QCOMPARE(varlist[2], QVariant::fromValue(o.data())); + QCOMPARE(varlist[3], QVariant()); + QCOMPARE(varlist[4], QVariant::fromValue(true)); + + QQmlListProperty<QObject> objlist = o->property("objlist").value<QQmlListProperty<QObject>>(); + QCOMPARE(objlist.count(&objlist), 3); + QCOMPARE(objlist.at(&objlist, 0), o.data()); + QCOMPARE(objlist.at(&objlist, 1), nullptr); + QCOMPARE(objlist.at(&objlist, 2), o.data()); +} + void tst_QmlCppCodegen::signatureIgnored() { QQmlEngine engine; |