aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qjsengine/tst_qjsengine.cpp
diff options
context:
space:
mode:
authorTobias Koenig <tobias.koenig@kdab.com>2014-12-17 13:51:55 +0100
committerTobias Koenig <tobias.koenig@kdab.com>2014-12-18 06:29:11 +0100
commit7c0f21ce044eb39c203e524e5ddde53e25d9ed17 (patch)
treea05cb1c4890dcec08773834504a30c587d0af4e8 /tests/auto/qml/qjsengine/tst_qjsengine.cpp
parent7923f9f570e7d765adfea204a0d9dd7c08c0e58f (diff)
Fix handling of enum values encapsulated in QVariant
In case a QJSValue contains a QVariant which wrapps an enum value, the valueOf() method will convert the enum to an int32. Change-Id: I0b92207184f343d53f73884245b90552165c34fc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests/auto/qml/qjsengine/tst_qjsengine.cpp')
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 4e9da046b5..da57d7786a 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -70,6 +70,7 @@ private slots:
void newArray_HooliganTask233836();
void newVariant();
void newVariant_valueOfToString();
+ void newVariant_valueOfEnum();
void newRegExp();
void jsRegExp();
void newDate();
@@ -439,6 +440,17 @@ void tst_QJSEngine::newVariant_valueOfToString()
}
}
+void tst_QJSEngine::newVariant_valueOfEnum()
+{
+ QJSEngine eng;
+ {
+ QJSValue object = eng.toScriptValue(QVariant::fromValue(Qt::ControlModifier));
+ QJSValue value = object.property("valueOf").callWithInstance(object);
+ QVERIFY(value.isNumber());
+ QCOMPARE(value.toInt(), static_cast<qint32>(Qt::ControlModifier));
+ }
+}
+
void tst_QJSEngine::newRegExp()
{
QJSEngine eng;