summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-03-04 05:20:37 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-03-04 05:20:37 (GMT)
commit86828e75afcf5c6dae002826564965741bd1710f (patch)
tree1b911e1c12a3091582e8be958913f1099dc657d5 /tests/auto
parente86dc3cbc40824353688db52d9933af26a30aaa0 (diff)
parentba85f14b140c08cbafe263954947d818152146e0 (diff)
downloadQt-86828e75afcf5c6dae002826564965741bd1710f.zip
Qt-86828e75afcf5c6dae002826564965741bd1710f.tar.gz
Qt-86828e75afcf5c6dae002826564965741bd1710f.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml4
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp20
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 9957b50..27ecef4 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);
@@ -169,9 +170,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);
@@ -185,4 +192,3 @@ void tst_QDeclarativeWorkerScript::messaging_sendJsObject()
QTEST_MAIN(tst_QDeclarativeWorkerScript)
#include "tst_qdeclarativeworkerscript.moc"
-