summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-03-04 03:31:33 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-03-04 03:31:33 (GMT)
commitc425733907910ad04ed3abdefb5108d682858b12 (patch)
tree62bb802c593d3feda2edab515cc90b81cb05972a /tests/auto/declarative
parent4164a11032b64fe5a557515f283fa0e4c6d0260d (diff)
downloadQt-c425733907910ad04ed3abdefb5108d682858b12.zip
Qt-c425733907910ad04ed3abdefb5108d682858b12.tar.gz
Qt-c425733907910ad04ed3abdefb5108d682858b12.tar.bz2
Fix tests failing due to javascript eval errors.
Diffstat (limited to 'tests/auto/declarative')
-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"
-