diff options
Diffstat (limited to 'tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp')
-rw-r--r-- | tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp index 66090ce7ff..2c85040f5f 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp +++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp @@ -53,8 +53,6 @@ #include <private/qdeclarativeengine_p.h> #include "../../../shared/util.h" -Q_DECLARE_METATYPE(QScriptValue) - #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir #define SRCDIR "." @@ -82,6 +80,7 @@ private slots: void script_included(); void scriptError_onLoad(); void scriptError_onCall(); + void stressDispose(); private: void waitForEchoMessage(QDeclarativeWorkerScript *worker) { @@ -191,13 +190,12 @@ void tst_QDeclarativeWorkerScript::messaging_sendJsObject() // QVariant roundtrip, since the properties will be stored in a QVariantMap. QString jsObject = "{'haste': 1125, 'name': 'zyz', 'spell power': 3101}"; - QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(worker)); - QScriptValue sv = engine->newObject(); - sv.setProperty("haste", 1125); - sv.setProperty("name", "zyz"); - sv.setProperty("spell power", 3101); + QVariantMap map; + map.insert("haste", 1125); + map.insert("name", "zyz"); + map.insert("spell power", 3101); - QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, qVariantFromValue(sv)))); + QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, qVariantFromValue(map)))); waitForEchoMessage(worker); QVariant result = qVariantFromValue(false); @@ -261,7 +259,7 @@ void tst_QDeclarativeWorkerScript::scriptError_onLoad() QVERIFY(worker != 0); QTRY_COMPARE(qdeclarativeworkerscript_lastWarning, - TEST_FILE("data/script_error_onLoad.js").toString() + QLatin1String(":3: SyntaxError: Parse error")); + TEST_FILE("data/script_error_onLoad.js").toString() + QLatin1String(":3: SyntaxError: Unexpected identifier")); qInstallMsgHandler(previousMsgHandler); qApp->processEvents(); @@ -286,6 +284,18 @@ void tst_QDeclarativeWorkerScript::scriptError_onCall() delete worker; } +// Rapidly create and destroy worker scripts to test resources are being disposed +// in the correct isolate +void tst_QDeclarativeWorkerScript::stressDispose() +{ + for (int ii = 0; ii < 100; ++ii) { + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, SRCDIR "/data/stressDispose.qml"); + QObject *o = component.create(); + QVERIFY(o); + delete o; + } +} QTEST_MAIN(tst_QDeclarativeWorkerScript) |