aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlengine/tst_qqmlengine.cpp')
-rw-r--r--tests/auto/qml/qqmlengine/tst_qqmlengine.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
index e1dff63e03..e74be6929c 100644
--- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
+++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
@@ -91,6 +91,7 @@ private slots:
void listWrapperAsListReference();
void attachedObjectAsObject();
void listPropertyAsQJSValue();
+ void stringToColor();
public slots:
QObject *createAQObjectForOwnershipTest ()
@@ -1410,6 +1411,31 @@ void tst_qqmlengine::listPropertyAsQJSValue()
QCOMPARE(prop.at(&prop, 0), &c);
}
+void tst_qqmlengine::stringToColor()
+{
+ QQmlEngine engine;
+
+ // Make it import QtQuick, so that color becomes available.
+ QQmlComponent c(&engine);
+ c.setData("import QtQuick\nItem {}", QUrl());
+ QVERIFY(c.isReady());
+ QScopedPointer<QObject> o(c.create());
+
+ const QMetaType metaType(QMetaType::QColor);
+ QVariant color(metaType);
+ QVERIFY(engine.handle()->metaTypeFromJS(
+ engine.handle()->newString(QStringLiteral("#abcdef"))->asReturnedValue(),
+ metaType, color.data()));
+ QVERIFY(color.isValid());
+ QCOMPARE(color.metaType(), metaType);
+
+ QVariant variant(QStringLiteral("#abcdef"));
+ QVERIFY(variant.convert(metaType));
+ QCOMPARE(variant.metaType(), metaType);
+
+ QCOMPARE(color, variant);
+}
+
QTEST_MAIN(tst_qqmlengine)
#include "tst_qqmlengine.moc"