aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2025-02-03 17:46:00 +0100
committerUlf Hermann <ulf.hermann@qt.io>2025-02-19 12:40:20 +0100
commitf9fbe137c701941548a16ae81651d2ad21956774 (patch)
treecd47338fb2bb1bc49a2c608fbc992d71456a9f3a /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parentd278c233800fbc1407fe74af1b8e3a8f0764d1d8 (diff)
QmlCompiler: Extend the listConversion test
The actual conversion code suggests that we may be creating a shared list property. However, the assignment code internally won't let that happen. Test as much. Amends commit 3108c58b97074b68ba48f452955727c67c4f77bc Task-number: QTBUG-133047 Change-Id: I66f0f043e0dabd2693aa50a30478461a5db5c5ad Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 61999b5eec..7bbaa0ec19 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -3239,6 +3239,42 @@ void tst_QmlCppCodegen::listConversion()
QCOMPARE(nulls.count(&nulls), 2);
QCOMPARE(nulls.at(&nulls, 0), nullptr);
QCOMPARE(nulls.at(&nulls, 1), nullptr);
+
+ QObject *src = o->property("src").value<QObject *>();
+ QVERIFY(src);
+
+ QCOMPARE(src->property("numbers").value<QList<int>>(), (QList<int>{1, 2}));
+
+ QQmlListProperty<QObject> srcObjects
+ = src->property("objects").value<QQmlListProperty<QObject>>();
+ QVERIFY(srcObjects.object != objects.object);
+ const QObjectList oldObjects = objects.toList<QObjectList>();
+ QCOMPARE(srcObjects.toList<QObjectList>(), oldObjects);
+
+ QQmlListProperty<QQmlBind> srcBindings
+ = src->property("bindings").value<QQmlListProperty<QQmlBind>>();
+ QVERIFY(srcBindings.object != bindings.object);
+ const QObjectList oldBindings = bindings.toList<QObjectList>();
+ QCOMPARE(srcBindings.toList<QObjectList>(), oldBindings);
+
+ QMetaObject::invokeMethod(o.data(), "shuffle");
+
+ QCOMPARE(o->property("numbers").value<QList<int>>(), (QList<int>{1, 3}));
+
+ // List properties stay intact
+ QCOMPARE(objects.count(&objects), 2);
+ QCOMPARE(objects.at(&objects, 1), o.data());
+ QCOMPARE(bindings.count(&bindings), 2);
+ QCOMPARE(bindings.at(&bindings, 1), nullptr);
+ QCOMPARE(objectsFromBindings.count(&objectsFromBindings), 2);
+ QCOMPARE(objectsFromBindings.at(&objectsFromBindings, 1), o.data());
+ QCOMPARE(nulls.count(&nulls), 2);
+ QCOMPARE(nulls.at(&nulls, 1), nullptr);
+
+ // Changes did not propagate back to the source
+ QCOMPARE(src->property("numbers").value<QList<int>>(), (QList<int>{1, 2}));
+ QCOMPARE(srcObjects.toList<QObjectList>(), oldObjects);
+ QCOMPARE(srcBindings.toList<QObjectList>(), oldBindings);
}
void tst_QmlCppCodegen::listIndices()