summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-06-03 13:44:20 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-06-03 13:52:24 (GMT)
commit5e0aef012a90598b88b547b1b73785f59ef135c1 (patch)
tree98d4e3b40a0209ffd0aff6192b0627206c39c34d /tests
parentc890793e7a58e1d75d1f88f5e2c88162eddcca44 (diff)
downloadQt-5e0aef012a90598b88b547b1b73785f59ef135c1.zip
Qt-5e0aef012a90598b88b547b1b73785f59ef135c1.tar.gz
Qt-5e0aef012a90598b88b547b1b73785f59ef135c1.tar.bz2
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')
-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 5339fb4..fe60cd0 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);