diff options
Diffstat (limited to 'tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp')
-rw-r--r-- | tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp index 320a429..44adf7e 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) |