aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlvaluetypes
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-11-25 23:35:34 +0100
committerLiang Qi <liang.qi@qt.io>2016-11-25 23:35:34 +0100
commitcc1c3d0e2be6dfea6befebdc5f25e519e3fe79b2 (patch)
treef160486b34c9157f42e12b23f2e0a3dd9aa2ef1b /tests/auto/qml/qqmlvaluetypes
parent7fa08472d32055a3d6e8b775b843f38ef65e9ce6 (diff)
parent4fae8ff1e73eeb48734b28a9c846fbdff1c2ffe1 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.75.7
Conflicts: src/qml/compiler/qv4ssa.cpp src/qml/qml/v8/qqmlbuiltinfunctions.cpp src/quick/util/qquickprofiler_p.h Change-Id: I11a89c2a166115d6697adfba09928805643e709e
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 300f5b90e5..0d9a561378 100644
--- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
+++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
@@ -89,6 +89,7 @@ private slots:
void customValueTypeInQml();
void gadgetInheritance();
void toStringConversion();
+ void enumProperties();
private:
QQmlEngine engine;
@@ -1649,6 +1650,39 @@ void tst_qqmlvaluetypes::toStringConversion()
QCOMPARE(stringConversion.toString(), StringLessGadget_to_QString(g));
}
+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)