aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmllanguage/data/cppstaticnamespace.2.qml5
-rw-r--r--tests/auto/qml/qqmllanguage/data/cppstaticnamespace.qml6
-rw-r--r--tests/auto/qml/qqmllanguage/qqmllanguage.pro5
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.h41
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp31
5 files changed, 76 insertions, 12 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.2.qml b/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.2.qml
new file mode 100644
index 0000000000..3b37c29b18
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.2.qml
@@ -0,0 +1,5 @@
+import StaticTest 1.0
+
+MyStaticSecondNamespacedType {
+ list: [ MyStaticNamespacedType {} ]
+}
diff --git a/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.qml b/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.qml
new file mode 100644
index 0000000000..2778baadb9
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/cppstaticnamespace.qml
@@ -0,0 +1,6 @@
+import StaticTest 1.0
+
+MyStaticNamespacedType {
+ myEnum: MyStaticNamespace.Key5
+ property int intProperty: MyStaticNamespace.MyOtherNSEnum.OtherKey2
+}
diff --git a/tests/auto/qml/qqmllanguage/qqmllanguage.pro b/tests/auto/qml/qqmllanguage/qqmllanguage.pro
index 724a27320c..6c54525544 100644
--- a/tests/auto/qml/qqmllanguage/qqmllanguage.pro
+++ b/tests/auto/qml/qqmllanguage/qqmllanguage.pro
@@ -1,4 +1,7 @@
-CONFIG += testcase
+CONFIG += testcase qmltypes
+QML_IMPORT_NAME = StaticTest
+QML_IMPORT_VERSION = 1.0
+
TARGET = tst_qqmllanguage
macx:CONFIG -= app_bundle
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h
index 148179cb9c..8852bf7af9 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.h
+++ b/tests/auto/qml/qqmllanguage/testtypes.h
@@ -750,6 +750,47 @@ private:
bool m_ownRWObj;
};
+namespace MyStaticNamespace {
+ Q_NAMESPACE
+ QML_ELEMENT
+
+ enum MyNSEnum {
+ Key1 = 1,
+ Key2,
+ Key5 = 5
+ };
+ Q_ENUM_NS(MyNSEnum);
+
+ enum class MyOtherNSEnum {
+ OtherKey1 = 1,
+ OtherKey2
+ };
+ Q_ENUM_NS(MyOtherNSEnum);
+
+
+ class MyNamespacedType : public QObject
+ {
+ Q_OBJECT
+ Q_PROPERTY(MyStaticNamespace::MyNSEnum myEnum MEMBER m_myEnum)
+ QML_NAMED_ELEMENT(MyStaticNamespacedType)
+ MyStaticNamespace::MyNSEnum m_myEnum = MyNSEnum::Key1;
+ };
+
+ class MySecondNamespacedType : public QObject
+ {
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<MyStaticNamespace::MyNamespacedType> list READ list)
+ QML_NAMED_ELEMENT(MyStaticSecondNamespacedType)
+ public:
+ QQmlListProperty<MyNamespacedType> list()
+ {
+ return QQmlListProperty<MyNamespacedType>(this, &m_list);
+ }
+
+ private:
+ QList<MyNamespacedType *> m_list;
+ };
+}
namespace MyNamespace {
Q_NAMESPACE
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index bd23806e3a..4d4056ba3f 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -1858,21 +1858,30 @@ void tst_qqmllanguage::valueTypes()
void tst_qqmllanguage::cppnamespace()
{
- {
- QQmlComponent component(&engine, testFileUrl("cppnamespace.qml"));
+ QScopedPointer<QObject> object;
+
+ auto create = [&](const char *file) {
+ QQmlComponent component(&engine, testFileUrl(file));
VERIFY_ERRORS(0);
- QScopedPointer<QObject> object(component.create());
+ object.reset(component.create());
QVERIFY(object != nullptr);
+ };
- QCOMPARE(object->property("intProperty").toInt(), (int)MyNamespace::MyOtherNSEnum::OtherKey2);
- }
+ auto createAndCheck = [&](const char *file) {
+ create(file);
+ return !QTest::currentTestFailed();
+ };
- {
- QQmlComponent component(&engine, testFileUrl("cppnamespace.2.qml"));
- VERIFY_ERRORS(0);
- QScopedPointer<QObject> object(component.create());
- QVERIFY(object != nullptr);
- }
+ QVERIFY(createAndCheck("cppnamespace.qml"));
+ QCOMPARE(object->property("intProperty").toInt(),
+ (int)MyNamespace::MyOtherNSEnum::OtherKey2);
+
+ QVERIFY(createAndCheck("cppstaticnamespace.qml"));
+ QCOMPARE(object->property("intProperty").toInt(),
+ (int)MyStaticNamespace::MyOtherNSEnum::OtherKey2);
+
+ QVERIFY(createAndCheck("cppnamespace.2.qml"));
+ QVERIFY(createAndCheck("cppstaticnamespace.2.qml"));
}
void tst_qqmllanguage::aliasProperties()