diff options
Diffstat (limited to 'tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp')
-rw-r--r-- | tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 354087da8a..d30766f982 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -235,6 +235,7 @@ private slots: void rewriteMultiLineStrings(); void revisionErrors(); void revision(); + void invokableWithQObjectDerived(); void automaticSemicolon(); void unaryExpression(); @@ -6017,6 +6018,45 @@ void tst_qdeclarativeecmascript::tryStatement() } } +class CppInvokableWithQObjectDerived : public QObject +{ + Q_OBJECT +public: + CppInvokableWithQObjectDerived() {} + ~CppInvokableWithQObjectDerived() {} + + Q_INVOKABLE MyQmlObject *createMyQmlObject(QString data) + { + MyQmlObject *obj = new MyQmlObject(); + obj->setStringProperty(data); + return obj; + } + + Q_INVOKABLE QString getStringProperty(MyQmlObject *obj) + { + return obj->stringProperty(); + } +}; + +void tst_qdeclarativeecmascript::invokableWithQObjectDerived() +{ + CppInvokableWithQObjectDerived invokable; + + { + QDeclarativeEngine engine; + engine.rootContext()->setContextProperty("invokable", &invokable); + + QDeclarativeComponent component(&engine, testFileUrl("qobjectDerivedArgument.qml")); + + QObject *object = component.create(); + + QVERIFY(object != 0); + QVERIFY(object->property("result").value<bool>() == true); + + delete object; + } +} + QTEST_MAIN(tst_qdeclarativeecmascript) #include "tst_qdeclarativeecmascript.moc" |