diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-06-18 12:23:30 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-06-21 14:31:02 +0200 |
commit | 71085008cecc25b9f635ed3c811f296a15ec0c0d (patch) | |
tree | e739d5d1732079bc5ff6cd19245d15a68b1a2fce /tests/auto/qml/qmltyperegistrar | |
parent | 21c13ab37426f96ab7717cc7b2764b702b382343 (diff) |
Allow extending namespaces with other namespaces
Previously you could only extend types.
Change-Id: I5d0bcea58403a87b9ff878c255ff590f162f8b24
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmltyperegistrar')
-rw-r--r-- | tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp | 18 | ||||
-rw-r--r-- | tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h | 29 |
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp index f11f5d6404..1271090c56 100644 --- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp +++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp @@ -288,4 +288,22 @@ void tst_qmltyperegistrar::namespacesAndValueTypes() check(QMetaType::fromName("ValueTypeWithEnum2"), QMetaType::fromType<ValueTypeWithEnum2>()); } +void tst_qmltyperegistrar::namespaceExtendedNamespace() +{ + QQmlEngine engine; + QQmlComponent c(&engine); + c.setData("import QtQml\n" + "import QmlTypeRegistrarTest\n" + "QtObject {\n" + " property int b: ForeignNamespace.B\n" + " property int f: ForeignNamespace.F\n" + "}", QUrl()); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer o(c.create()); + QVERIFY(!o.isNull()); + + QCOMPARE(o->property("b").toInt(), int(ExtensionValueType::B)); + QCOMPARE(o->property("f").toInt(), int(BaseNamespace::F)); +} + QTEST_MAIN(tst_qmltyperegistrar) diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h index 2a8423c682..d0f3f4d27b 100644 --- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h +++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.h @@ -382,6 +382,34 @@ struct BValueTypeWithEnumForeign2 QML_NAMED_ELEMENT(valueTypeWithEnum2) }; + +namespace BaseNamespace +{ +Q_NAMESPACE +enum BBB { + D, E, F +}; +Q_ENUM_NS(BBB) +} + +struct ExtensionValueType +{ + Q_GADGET +public: + enum EEE { + A, B, C + }; + Q_ENUM(EEE) +}; + +namespace ForeignNamespace +{ +Q_NAMESPACE +QML_FOREIGN_NAMESPACE(BaseNamespace) +QML_NAMESPACE_EXTENDED(ExtensionValueType) +QML_ELEMENT +} + class tst_qmltyperegistrar : public QObject { Q_OBJECT @@ -411,6 +439,7 @@ private slots: void finalProperty(); void parentProperty(); void namespacesAndValueTypes(); + void namespaceExtendedNamespace(); private: QByteArray qmltypesData; |