diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2023-12-05 13:03:34 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-12-07 13:29:41 +0100 |
| commit | 78b58582baccb2c214dfb07083e91eb47e45358a (patch) | |
| tree | 0808fcb1c423410b54e84e225ae8b7aa6013938a /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | a8aad1afdf6d9ac4ae28c3c4fae75a6bd97302bf (diff) | |
QmlCompiler: Add generic QVariant-to-typed comparison
Since we have a lot more shadowable values now, we need to add this.
Change-Id: Ie9f389730bb6f330b1cd28f9229c5dd143727e4f
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.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 0b86932014..51641a2295 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -89,6 +89,7 @@ private slots: void equalityQUrl(); void equalityTestsWithNullOrUndefined(); void equalityVarAndNonStorable(); + void equalityVarAndStorable(); void equalsUndefined(); void evadingAmbiguity(); void exceptionFromInner(); @@ -1658,6 +1659,44 @@ void tst_QmlCppCodegen::equalityVarAndNonStorable() QVERIFY(object->property("nullIsNotUndefined").toBool()); } +void tst_QmlCppCodegen::equalityVarAndStorable() +{ + QQmlEngine engine; + QQmlComponent planner(&engine, QUrl(u"qrc:/qt/qml/TestTypes/Planner.qml"_s)); + QVERIFY2(!planner.isError(), qPrintable(planner.errorString())); + QScopedPointer<QObject> p(planner.create()); + QVERIFY(!p.isNull()); + + QQmlComponent variable(&engine, QUrl(u"qrc:/qt/qml/TestTypes/Variable.qml"_s)); + QVERIFY2(!variable.isError(), qPrintable(variable.errorString())); + QScopedPointer<QObject> v(variable.create()); + QVERIFY(!v.isNull()); + + QVERIFY(p->objectName().isEmpty()); + QMetaObject::invokeMethod(p.data(), "typeErasedRemoveOne", v.data()); + QCOMPARE(p->objectName(), u"n"); + + v->setProperty("value", 1); + QMetaObject::invokeMethod(p.data(), "typeErasedRemoveOne", v.data()); + QCOMPARE(p->objectName(), u"nd"); + + QQmlComponent constraint(&engine, QUrl(u"qrc:/qt/qml/TestTypes/BaseConstraint.qml"_s)); + QVERIFY2(!constraint.isError(), qPrintable(constraint.errorString())); + QScopedPointer<QObject> c(constraint.create()); + QVERIFY(!c.isNull()); + + c->setProperty("output", QVariant::fromValue(v.data())); + QCOMPARE(v->property("mark").toInt(), 0); + QMetaObject::invokeMethod(p.data(), "typeErasedRun", c.data()); + QCOMPARE(v->property("mark").toInt(), 5); + + QTest::ignoreMessage(QtDebugMsg, "success"); + QMetaObject::invokeMethod(p.data(), "verify", 10); + + QTest::ignoreMessage(QtCriticalMsg, "failed 10 11"); + QMetaObject::invokeMethod(p.data(), "verify", 11); +} + void tst_QmlCppCodegen::equalsUndefined() { QQmlEngine engine; |
