diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-03-05 03:51:10 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-03-05 03:51:10 (GMT) |
commit | 48fd47f64f3f73e82016161d82cdf67908a9c653 (patch) | |
tree | e337d89e525d3a55d2b9aca8c19d2b3b43c65c50 /tests/auto/declarative/qdeclarativeworkerscript | |
parent | a7b46bda37a428ae2e5554aa8e58469c92b310a9 (diff) | |
parent | c9b3309ae1d3a34790d71fdfd7dcaab79433f049 (diff) | |
download | Qt-48fd47f64f3f73e82016161d82cdf67908a9c653.zip Qt-48fd47f64f3f73e82016161d82cdf67908a9c653.tar.gz Qt-48fd47f64f3f73e82016161d82cdf67908a9c653.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Conflicts:
tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp
Diffstat (limited to 'tests/auto/declarative/qdeclarativeworkerscript')
-rw-r--r-- | tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml | 4 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp | 20 |
2 files changed, 13 insertions, 11 deletions
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml index bb4028f..1fce155 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml @@ -12,10 +12,6 @@ WorkerScript { worker.sendMessage(value) } - function testSendLiteral(value) { - eval('worker.sendMessage(' + value +')') - } - function compareLiteralResponse(expected) { var e = eval('(' + expected + ')') return worker.response == e diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp index 56e906e..4f9f21a 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp +++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp @@ -48,9 +48,9 @@ #include <QtDeclarative/qdeclarativeitem.h> #include <private/qdeclarativeworkerscript_p.h> +#include <private/qdeclarativeengine_p.h> #include "../../../shared/util.h" -Q_DECLARE_METATYPE(QList<QObject*>) Q_DECLARE_METATYPE(QScriptValue) class tst_QDeclarativeWorkerScript : public QObject @@ -86,13 +86,14 @@ void tst_QDeclarativeWorkerScript::source() QFETCH(QUrl, source); QFETCH(bool, valid); - QDeclarativeComponent component(&m_engine); - component.setData("import Qt 4.6\nWorkerScript { source: '" + source.toString().toUtf8() + "'; }", QUrl()); - if (!valid) { QByteArray w = "WorkerScript: Cannot find source file \"" + source.toString().toUtf8() + "\""; QTest::ignoreMessage(QtWarningMsg, w.constData()); } + + QDeclarativeComponent component(&m_engine); + component.setData("import Qt 4.6\nWorkerScript { source: '" + source.toString().toUtf8() + "'; }", QUrl()); + QDeclarativeWorkerScript *item = qobject_cast<QDeclarativeWorkerScript*>(component.create()); QVERIFY(item != 0); @@ -172,9 +173,15 @@ void tst_QDeclarativeWorkerScript::messaging_sendJsObject() QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create()); QVERIFY(worker != 0); - QString jsObject = "{'spell power': 3101, 'haste': 1125}"; + QString jsObject = "{'name': 'zyz', 'spell power': 3101, 'haste': 1125}"; - QVERIFY(QMetaObject::invokeMethod(worker, "testSendLiteral", Q_ARG(QVariant, jsObject))); + QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(worker)); + QScriptValue sv = engine->newObject(); + sv.setProperty("name", "zyz"); + sv.setProperty("spell power", 3101); + sv.setProperty("haste", 1125); + + QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, qVariantFromValue(sv)))); waitForEchoMessage(worker); QVariant result = qVariantFromValue(false); @@ -189,4 +196,3 @@ void tst_QDeclarativeWorkerScript::messaging_sendJsObject() QTEST_MAIN(tst_QDeclarativeWorkerScript) #include "tst_qdeclarativeworkerscript.moc" - |