aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlvaluetypes
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-11-26 12:53:14 +0100
committerUlf Hermann <ulf.hermann@qt.io>2016-11-28 12:24:13 +0100
commit9044800083ccffe4d0b732f8b3b60512f32d8f8a (patch)
treecdd6d2038d53e99a5a9326be6b47a68553830480 /tests/auto/qml/qqmlvaluetypes
parent8bf579d8d4feb13ca8651e98dd762b28483abe9e (diff)
parentcc1c3d0e2be6dfea6befebdc5f25e519e3fe79b2 (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
The renderers added in 5.8 had to be adapted to the changed profiling macros from 5.6. Conflicts: src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp src/quick/util/qquickprofiler_p.h tests/auto/qml/qjsengine/tst_qjsengine.cpp tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp Change-Id: Icb370b7c95aab12589ad73881ac6d178759a5c6b
Diffstat (limited to 'tests/auto/qml/qqmlvaluetypes')
-rw-r--r--tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
index 803bad197a..9e915ac451 100644
--- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
+++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
@@ -91,6 +91,7 @@ private slots:
void gadgetInheritance();
void toStringConversion();
void enumerableProperties();
+ void enumProperties();
private:
QQmlEngine engine;
@@ -1703,6 +1704,39 @@ void tst_qqmlvaluetypes::enumerableProperties()
QVERIFY(names.contains(QStringLiteral("derivedProperty")));
}
+struct GadgetWithEnum
+{
+ Q_GADGET
+public:
+
+ enum MyEnum { FirstValue, SecondValue };
+
+ Q_ENUM(MyEnum)
+ Q_PROPERTY(MyEnum enumProperty READ enumProperty)
+
+ MyEnum enumProperty() const { return SecondValue; }
+};
+
+void tst_qqmlvaluetypes::enumProperties()
+{
+ QJSEngine engine;
+
+ // When creating the property cache for the gadget when MyEnum is _not_ a registered
+ // meta-type, then QMetaProperty::type() will return QMetaType::Int and consequently
+ // property-read meta-calls will return an int (as expected in this test). However if we
+ // explicitly register the gadget, then QMetaProperty::type() will return the user-type
+ // and QQmlValueTypeWrapper should still handle that and return an integer/number for the
+ // enum property when it is read.
+ qRegisterMetaType<GadgetWithEnum::MyEnum>();
+
+ GadgetWithEnum g;
+ QJSValue value = engine.toScriptValue(g);
+
+ QJSValue enumValue = value.property("enumProperty");
+ QVERIFY(enumValue.isNumber());
+ QCOMPARE(enumValue.toInt(), int(g.enumProperty()));
+}
+
QTEST_MAIN(tst_qqmlvaluetypes)