diff options
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 0fd90e90fd..4217206307 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -64,6 +64,7 @@ private slots: void brokenAs(); void boundComponents(); void callContextPropertyLookupResult(); + void callObjectLookupOnNull(); void callWithSpread(); void colorAsVariant(); void colorString(); @@ -1021,6 +1022,25 @@ void tst_QmlCppCodegen::callContextPropertyLookupResult() QVERIFY(qvariant_cast<QQmlComponent *>(o->property("c")) != nullptr); } +void tst_QmlCppCodegen::callObjectLookupOnNull() +{ + QQmlEngine engine; + const QString urlString = u"qrc:/qt/qml/TestTypes/callObjectLookupOnNull.qml"_s; + QQmlComponent c(&engine, QUrl(urlString)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QVERIFY(o); + + QCOMPARE(o->objectName(), u"horst"_s); + + QTest::ignoreMessage( + QtWarningMsg, + qPrintable(urlString + u":5:5: TypeError: Cannot call method 'getName' of null")); + o->setProperty("person", QVariant::fromValue<Person *>(nullptr)); + + QCOMPARE(o->objectName(), QString()); +} + void tst_QmlCppCodegen::callWithSpread() { QQmlEngine engine; |
