aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-02-21 11:47:08 +0100
committerUlf Hermann <ulf.hermann@qt.io>2023-03-09 21:36:30 +0100
commit2a21efb5f7a6cac6f6101f2f42fe38f16dc68149 (patch)
tree9e499bb9ac29f76faa73a43a972ce86de4fa891c /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parente37d2dac8ae680d36a531f0388ec3216e5dfb366 (diff)
QmlCompiler: Use value type ctors
This allows us to do the relevant conversions in a more civilized way, dropping the outputVariantConversion() method. The latter is brittle because you have to manually add it to each instruction, and it uses QMetaType::convert() which is actually not guaranteed to give the same results as a QML type coercion. Task-number: QTBUG-94807 Change-Id: I4d6d05a60beb3b4dfc3da6f0142de25667510904 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 131724c5ec..01268408ca 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -1,6 +1,7 @@
// Copyright (C) 2021 The Qt Company Ltd.
#include "data/druggeljug.h"
+#include "data/withlength.h"
#include <data/birthdayparty.h>
#include <data/cppbaseclass.h>
#include <data/enumproblems.h>
@@ -172,6 +173,7 @@ private slots:
void mathMinMax();
void enumFromBadSingleton();
void objectLookupOnListElement();
+ void multipleCtors();
};
void tst_QmlCppCodegen::initTestCase()
@@ -3425,6 +3427,18 @@ void tst_QmlCppCodegen::objectLookupOnListElement()
QCOMPARE(zOrders, (QList<int>()));
}
+void tst_QmlCppCodegen::multipleCtors()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/multipleCtors.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(!o.isNull());
+ QCOMPARE(o->property("wr").value<ValueTypeWithLength>().length(), 3);
+ QCOMPARE(o->property("wp").value<ValueTypeWithLength>().length(), 11);
+ QCOMPARE(o->property("wi").value<ValueTypeWithLength>().length(), 17);
+}
+
QTEST_MAIN(tst_QmlCppCodegen)
#include "tst_qmlcppcodegen.moc"