summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSami Nurmenniemi <sami.nurmenniemi@qt.io>2017-12-28 13:43:03 +0200
committerLars Knoll <lars.knoll@qt.io>2017-12-28 16:42:34 +0000
commitd2f9396f048ef8fdd494626d92b3d7106fb10304 (patch)
tree333fa335ac20f0e4d4dc22331aa7e2f3a3660c19 /tests
parentd05fc61c3953aee73bf3a912f30706ca092732f7 (diff)
downloadqtwebchannel-d2f9396f048ef8fdd494626d92b3d7106fb10304.tar.gz
Fix TestWebChannel::testAsyncObject
If signal is emitted directly, QSignalSpy::wait() is called too late. In that case the correct information about emitted signal can be checked with QSignalSpy::count(). Task-number: QTBUG-63152 Change-Id: I0c3da52ab17f9138ad1a7a17f5065b8a87911b8f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/webchannel/tst_webchannel.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/auto/webchannel/tst_webchannel.cpp b/tests/auto/webchannel/tst_webchannel.cpp
index f214b7e..4309647 100644
--- a/tests/auto/webchannel/tst_webchannel.cpp
+++ b/tests/auto/webchannel/tst_webchannel.cpp
@@ -770,6 +770,11 @@ void TestWebChannel::testInfiniteRecursion()
void TestWebChannel::testAsyncObject()
{
+ auto waitForSignal = [] (QSignalSpy& spy) {
+ for (int i=0; (i<5) && (spy.count() == 0); i++)
+ spy.wait(1000);
+ };
+
QWebChannel channel;
channel.connectTo(m_dummyTransport);
@@ -788,7 +793,8 @@ void TestWebChannel::testAsyncObject()
{
QSignalSpy spy(&obj, &TestObject::propChanged);
channel.d_func()->publisher->invokeMethod(&obj, method, args);
- QVERIFY(spy.wait());
+ waitForSignal(spy);
+ QCOMPARE(spy.count(), 1);
QCOMPARE(spy.at(0).at(0).toString(), args.at(0).toString());
}
@@ -804,10 +810,13 @@ void TestWebChannel::testAsyncObject()
{
QSignalSpy spy(&obj, &TestObject::replay);
QMetaObject::invokeMethod(&obj, "fire");
- QVERIFY(spy.wait());
+ waitForSignal(spy);
+ QCOMPARE(spy.count(), 1);
channel.deregisterObject(&obj);
QMetaObject::invokeMethod(&obj, "fire");
- QVERIFY(spy.wait());
+ spy.takeFirst();
+ waitForSignal(spy);
+ QCOMPARE(spy.count(), 1);
}
thread.quit();