From f53ac4f7617bfdefcb62e9b27ee6bf1a91a7ed13 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 4 Mar 2010 09:37:04 +1000 Subject: Fix test to listen for signal instead of try-waiting for property. --- .../declarative/qdeclarativeworkerscript/data/worker.qml | 5 +++-- .../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 #include +#include #include #include @@ -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; -- cgit v0.12