diff options
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 9b7eff5507..3496ca25dd 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -168,6 +168,7 @@ private slots: void popContextAfterRet(); void prefixedType(); void propertyOfParent(); + void readEnumFromInstance(); void registerElimination(); void registerPropagation(); void revisions(); @@ -3497,6 +3498,33 @@ void tst_QmlCppCodegen::propertyOfParent() } } +void tst_QmlCppCodegen::readEnumFromInstance() +{ + QQmlEngine engine; + + const QString url = u"qrc:/qt/qml/TestTypes/readEnumFromInstance.qml"_s; + + QQmlComponent component(&engine, QUrl(url)); + QVERIFY2(component.isReady(), component.errorString().toUtf8()); + + QTest::ignoreMessage( + QtWarningMsg, qPrintable(url + ":7:5: Unable to assign [undefined] to int"_L1)); + + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + QCOMPARE(object->property("priority"), QVariant::fromValue<int>(0)); + QCOMPARE(object->property("prop2"), QVariant::fromValue<int>(1)); + QCOMPARE(object->property("priorityIsVeryHigh"), QVariant::fromValue<bool>(false)); + + QTest::ignoreMessage( + QtWarningMsg, qPrintable(url + ":13: Error: Cannot assign [undefined] to int"_L1)); + + int result = 0; + QMetaObject::invokeMethod(object.data(), "cyclePriority", Q_RETURN_ARG(int, result)); + QCOMPARE(result, 0); +} + void tst_QmlCppCodegen::registerElimination() { QQmlEngine engine; |
