diff options
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index acc117d967..bc6fa5a106 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -125,6 +125,7 @@ private slots: void objectInVar(); void testIsnan(); void fallbackLookups(); + void prefixedMetaType(); }; void tst_QmlCppCodegen::simpleBinding() @@ -1880,6 +1881,31 @@ void tst_QmlCppCodegen::fallbackLookups() QCOMPARE(singleton->objectName(), QStringLiteral("dd96")); } +void tst_QmlCppCodegen::prefixedMetaType() +{ + QQmlEngine engine; + + // We need to add an import path here because we cannot namespace the implicit import. + // The implicit import is what we use for all the other tests, even if we explicitly + // import TestTypes. That is because the TestTypes module is in a subdirectory "data". + engine.addImportPath(u":/"_qs); + + const QUrl document(u"qrc:/TestTypes/prefixedMetaType.qml"_qs); + QQmlComponent c(&engine, document); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QVERIFY(o); + + QCOMPARE(o->property("state").toInt(), 2); + QVERIFY(qvariant_cast<QObject *>(o->property("a")) != nullptr); + QVERIFY(qvariant_cast<QObject *>(o->property("b")) != nullptr); + QVERIFY(qvariant_cast<QObject *>(o->property("c")) == nullptr); + + QVERIFY(qvariant_cast<QObject *>(o->property("d")) != nullptr); + QVERIFY(qvariant_cast<QObject *>(o->property("e")) != nullptr); + QVERIFY(qvariant_cast<QObject *>(o->property("f")) == nullptr); +} + void tst_QmlCppCodegen::runInterpreted() { if (qEnvironmentVariableIsSet("QV4_FORCE_INTERPRETER")) |