diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qml/qqmllanguage/testtypes.h | 29 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 21 |
2 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h index 1156d265ed..518f52f4e7 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.h +++ b/tests/auto/qml/qqmllanguage/testtypes.h @@ -1534,6 +1534,35 @@ class UncreatableElementNoReason : public QObject QML_UNCREATABLE("") }; +namespace ExtensionNamespace { +Q_NAMESPACE + +enum Foo { + Bar = 9, + Baz = 12 +}; +Q_ENUM_NS(Foo) +} + +class ExtendedByNamespace : public QObject +{ + Q_OBJECT + QML_ELEMENT + QML_EXTENDED_NAMESPACE(ExtensionNamespace) + + Q_PROPERTY(int own READ own CONSTANT) +public: + + enum OwnEnum { + Moo = 16, + Maeh = 17 + }; + Q_ENUM(OwnEnum) + + ExtendedByNamespace(QObject *parent = nullptr) : QObject(parent) {} + int own() const { return 93; } +}; + void registerTypes(); #endif // TESTTYPES_H diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 4e8e668c18..74b7c0e64e 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -340,6 +340,7 @@ private slots: void checkURLtoURLObject(); void registerValueTypes(); + void extendedNamespace(); private: QQmlEngine engine; @@ -6027,6 +6028,26 @@ void tst_qqmllanguage::accessNullPointerPropertyCache() QVERIFY(!obj.isNull()); } +void tst_qqmllanguage::extendedNamespace() +{ + QQmlEngine engine; + QQmlComponent c(&engine); + c.setData("import StaticTest\n" + "import QtQml\n" + "ExtendedByNamespace {\n" + " property int mine: own\n" + " property int myEnum: ExtendedByNamespace.Moo\n" + " property int fromExtension: ExtendedByNamespace.Bar\n" + "}", QUrl()); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> obj(c.create()); + QVERIFY(!obj.isNull()); + + QCOMPARE(obj->property("mine").toInt(), 93); + QCOMPARE(obj->property("myEnum").toInt(), 16); + QCOMPARE(obj->property("fromExtension").toInt(), 9); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" |