summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptextqobject
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-10-22 13:26:28 +0200
committerOlivier Goffart <ogoffart@trolltech.com>2009-10-22 13:44:21 +0200
commit9dec5247be84ae4606d5d9baf5b99612c5feba8d (patch)
treee8eafa402f5104c959dab69d95018c259f8e1fd7 /tests/auto/qscriptextqobject
parentc74240bf4ab182f13b18271831fd6deebfe573f6 (diff)
QtScript: Compatibility with 4.5
We must register the same type as they were registered in Qt 4.5 Reported on qt4-preview-feedback mailing list. Reviewed-by: Kent Hansen
Diffstat (limited to 'tests/auto/qscriptextqobject')
-rw-r--r--tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
index 320a429d04..44adf7e45d 100644
--- a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
+++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
@@ -317,6 +317,11 @@ public:
Q_INVOKABLE QObject* myInvokableReturningMyQObjectAsQObject()
{ m_qtFunctionInvoked = 57; return this; }
+ Q_INVOKABLE QObjectList findObjects() const
+ { return findChildren<QObject *>(); }
+ Q_INVOKABLE QList<int> myInvokableNumbers() const
+ { return QList<int>() << 1 << 2 << 3; }
+
void emitMySignal()
{ emit mySignal(); }
void emitMySignalWithIntArg(int arg)
@@ -493,6 +498,7 @@ protected slots:
}
private slots:
+ void registeredTypes();
void getSetStaticProperty();
void getSetDynamicProperty();
void getSetChildren();
@@ -543,6 +549,24 @@ void tst_QScriptExtQObject::cleanup()
delete m_myObject;
}
+// this test has to be first and test that some types are automatically registered
+void tst_QScriptExtQObject::registeredTypes()
+{
+ QScriptEngine e;
+ QObject *t = new MyQObject;
+ QObject *c = new QObject(t);
+ c->setObjectName ("child1");
+
+ e.globalObject().setProperty("MyTest", e.newQObject(t));
+
+ QScriptValue v1 = e.evaluate("MyTest.findObjects()[0].objectName;");
+ QCOMPARE(v1.toString(), c->objectName());
+
+ QScriptValue v2 = e.evaluate("MyTest.myInvokableNumbers()");
+ QCOMPARE(qscriptvalue_cast<QList<int> >(v2), (QList<int>() << 1 << 2 << 3));
+}
+
+
static QScriptValue getSetProperty(QScriptContext *ctx, QScriptEngine *)
{
if (ctx->argumentCount() != 0)