diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-03-03 23:37:04 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-03-03 23:37:04 (GMT) |
commit | f53ac4f7617bfdefcb62e9b27ee6bf1a91a7ed13 (patch) | |
tree | c9fa636c47d59eeea68a08bf2d683ec494feacf5 /tests | |
parent | 5d4eeb039e92a3e2ac9b31f91a4274e3d5aea459 (diff) | |
download | Qt-f53ac4f7617bfdefcb62e9b27ee6bf1a91a7ed13.zip Qt-f53ac4f7617bfdefcb62e9b27ee6bf1a91a7ed13.tar.gz Qt-f53ac4f7617bfdefcb62e9b27ee6bf1a91a7ed13.tar.bz2 |
Fix test to listen for signal instead of try-waiting for property.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml | 5 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp | 13 |
2 files changed, 11 insertions, 7 deletions
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml index 2982010..bb4028f 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml @@ -4,9 +4,10 @@ WorkerScript { id: worker source: "script.js" - property bool done : false property var response + signal done() + function testSend(value) { worker.sendMessage(value) } @@ -21,7 +22,7 @@ WorkerScript { } onMessage: { - worker.done = true worker.response = messageObject + worker.done() } } diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp index 841a0ee..b0fc212 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp +++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include <qtest.h> #include <QtCore/qdebug.h> +#include <QtCore/qtimer.h> #include <QtScript/qscriptengine.h> #include <QtDeclarative/qdeclarativecomponent.h> @@ -67,11 +68,13 @@ private slots: private: void waitForEchoMessage(QDeclarativeWorkerScript *worker) { - const QMetaObject *mo = worker->metaObject(); - int index = mo->indexOfProperty("done"); - QVERIFY(index >= 0); - QTRY_COMPARE(mo->property(index).read(worker).toBool(), true); - QTRY_COMPARE(mo->property(mo->indexOfProperty("done")).read(worker).toBool(), true); + QEventLoop loop; + QVERIFY(connect(worker, SIGNAL(done()), &loop, SLOT(quit()))); + QTimer timer; + connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + timer.start(1000); + loop.exec(); + QVERIFY(timer.isActive()); } QDeclarativeEngine m_engine; |