summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptengine/tst_qscriptengine.cpp
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-06-03 15:44:20 +0200
committerKent Hansen <khansen@trolltech.com>2009-06-03 15:52:24 +0200
commit5e0aef012a90598b88b547b1b73785f59ef135c1 (patch)
tree98d4e3b40a0209ffd0aff6192b0627206c39c34d /tests/auto/qscriptengine/tst_qscriptengine.cpp
parentc890793e7a58e1d75d1f88f5e2c88162eddcca44 (diff)
fix silly typo
Yeesh. The function worked for the common case of the argument being a plain script object (obviously, otherwise this would have been discovered sooner), but it would never pick the less expensive path when replacing the QObject pointer of an existing proxy. And if you passed in a QVariant proxy (now who would ever do something like that...?), it would assert.
Diffstat (limited to 'tests/auto/qscriptengine/tst_qscriptengine.cpp')
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index 5339fb4c0a..fe60cd08b3 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -636,9 +636,21 @@ void tst_QScriptEngine::newQObject()
QScriptValue val = ret.property("objectName");
QVERIFY(val.isString());
}
+ // "promote" variant object to QObject
+ {
+ QScriptValue obj = eng.newVariant(123);
+ QVERIFY(obj.isVariant());
+ QScriptValue originalProto = obj.prototype();
+ QScriptValue ret = eng.newQObject(obj, this);
+ QVERIFY(ret.isQObject());
+ QVERIFY(ret.strictlyEquals(obj));
+ QVERIFY(obj.isQObject());
+ QCOMPARE(ret.toQObject(), (QObject *)this);
+ QVERIFY(ret.prototype().strictlyEquals(originalProto));
+ }
// replace QObject* of existing object
{
- QScriptValue object = eng.newQObject(this);
+ QScriptValue object = eng.newVariant(123);
QScriptValue originalProto = object.prototype();
QObject otherQObject;
QScriptValue ret = eng.newQObject(object, &otherQObject);