aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-01-17 09:49:52 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-01 08:37:49 +0100
commite77ea6f2fa8e98cb4a03144664a31b6070635a63 (patch)
tree9d95dc1efba9bbc62ddb193ba2da04a9144ba033 /tests/auto/declarative/qjsengine/tst_qjsengine.cpp
parentbe784e3b15068c0677115ca9500531212584cc7d (diff)
Remove QJSEngine::newVariant() function
Rationale: This is a remnant from QtScript. There is no reason one should be able to explicitly wrap an arbitrary C++ type in a QVariant. toScriptValue() will automatically wrap the type in a QVariant if it's a type that's not specifically handled by the meta-type system, or if it can't usefully/losslessly be converted to a native JavaScript type. Task-number: QTBUG-23604 Change-Id: I5790cd92b9ffd5fcfbee1cd73a8eaa16fc74846f Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qjsengine/tst_qjsengine.cpp')
-rw-r--r--tests/auto/declarative/qjsengine/tst_qjsengine.cpp30
1 files changed, 3 insertions, 27 deletions
diff --git a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp b/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
index 7aadabb192..2d49619a8c 100644
--- a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
@@ -654,7 +654,7 @@ void tst_QJSEngine::newVariant()
{
QJSEngine eng;
{
- QJSValue opaque = eng.newVariant(QVariant());
+ QJSValue opaque = eng.toScriptValue(QVariant(QPoint(1, 2)));
QCOMPARE(opaque.isValid(), true);
QCOMPARE(opaque.isVariant(), true);
QVERIFY(!opaque.isCallable());
@@ -662,7 +662,7 @@ void tst_QJSEngine::newVariant()
QCOMPARE(opaque.prototype().isValid(), true);
QEXPECT_FAIL("", "FIXME: newly created QObject's prototype is an JS Object", Continue);
QCOMPARE(opaque.prototype().isVariant(), true);
- QVERIFY(opaque.property("valueOf").callWithInstance(opaque).isUndefined());
+ QVERIFY(opaque.property("valueOf").callWithInstance(opaque).equals(opaque));
}
}
@@ -732,31 +732,7 @@ void tst_QJSEngine::newVariant_valueOfToString()
// valueOf() and toString()
QJSEngine eng;
{
- QJSValue object = eng.newVariant(QVariant(123));
- QJSValue value = object.property("valueOf").callWithInstance(object);
- QVERIFY(value.isNumber());
- QCOMPARE(value.toInt(), 123);
- QCOMPARE(object.toString(), QString::fromLatin1("123"));
- QCOMPARE(object.toVariant().toString(), object.toString());
- }
- {
- QJSValue object = eng.newVariant(QVariant(QString::fromLatin1("hello")));
- QJSValue value = object.property("valueOf").callWithInstance(object);
- QVERIFY(value.isString());
- QCOMPARE(value.toString(), QString::fromLatin1("hello"));
- QCOMPARE(object.toString(), QString::fromLatin1("hello"));
- QCOMPARE(object.toVariant().toString(), object.toString());
- }
- {
- QJSValue object = eng.newVariant(QVariant(false));
- QJSValue value = object.property("valueOf").callWithInstance(object);
- QVERIFY(value.isBool());
- QCOMPARE(value.toBool(), false);
- QCOMPARE(object.toString(), QString::fromLatin1("false"));
- QCOMPARE(object.toVariant().toString(), object.toString());
- }
- {
- QJSValue object = eng.newVariant(QVariant(QPoint(10, 20)));
+ QJSValue object = eng.toScriptValue(QVariant(QPoint(10, 20)));
QJSValue value = object.property("valueOf").callWithInstance(object);
QVERIFY(value.isObject());
QVERIFY(value.strictlyEquals(object));