diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2017-03-02 13:49:11 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2017-03-02 13:49:11 +0100 |
commit | 32c1212f81fcfc7b5e49f85d68b05cd94cd90521 (patch) | |
tree | 795a3175173285f4ba5bd15cdc7ae6ec11c556d2 /tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp | |
parent | 79d3fe1bba4589c7f5780bb505eac7872061ee32 (diff) | |
parent | 78dd18a0cd18449e1289e428ea6eca65e28fb114 (diff) |
Merge remote-tracking branch 'origin/dev' into wip/pointerhandler
Change-Id: I7e43a0a47d49de38617f6afc7548f9a9e212a851
Diffstat (limited to 'tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp')
-rw-r--r-- | tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index 19cda21685..9fbd719d7b 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -26,6 +26,7 @@ ** ****************************************************************************/ +#include <qstandardpaths.h> #include <qtest.h> #include <qqml.h> #include <qqmlprivate.h> @@ -53,6 +54,7 @@ private slots: void invalidQmlTypeName(); void registrationType(); void compositeType(); + void externalEnums(); void isList(); @@ -70,6 +72,20 @@ public: }; QML_DECLARE_TYPE(TestType); +class ExternalEnums : public QObject +{ + Q_OBJECT + Q_ENUMS(QStandardPaths::StandardLocation QStandardPaths::LocateOptions) +public: + ExternalEnums(QObject *parent = nullptr) : QObject(parent) {} + + static QObject *create(QQmlEngine *engine, QJSEngine *scriptEngine) { + Q_UNUSED(scriptEngine); + return new ExternalEnums(engine); + } +}; +QML_DECLARE_TYPE(ExternalEnums); + QObject *testTypeProvider(QQmlEngine *engine, QJSEngine *scriptEngine) { Q_UNUSED(engine); @@ -271,6 +287,23 @@ void tst_qqmlmetatype::compositeType() QCOMPARE(type->sourceUrl(), testFileUrl("ImplicitType.qml")); } +void tst_qqmlmetatype::externalEnums() +{ + QQmlEngine engine; + qmlRegisterSingletonType<ExternalEnums>("x.y.z", 1, 0, "ExternalEnums", ExternalEnums::create); + + QQmlComponent c(&engine, testFileUrl("testExternalEnums.qml")); + QObject *obj = c.create(); + QVERIFY(obj); + QVariant a = obj->property("a"); + QCOMPARE(a.type(), QVariant::Int); + QCOMPARE(a.toInt(), int(QStandardPaths::DocumentsLocation)); + QVariant b = obj->property("b"); + QCOMPARE(b.type(), QVariant::Int); + QCOMPARE(b.toInt(), int(QStandardPaths::DocumentsLocation)); + +} + QTEST_MAIN(tst_qqmlmetatype) #include "tst_qqmlmetatype.moc" |