summaryrefslogtreecommitdiff
path: root/tests/auto
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2015-06-10 19:08:05 +0200
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2015-06-10 22:48:40 +0000
commita5cb3b8ff10fcf1def8bde6f814582be1c19b83b (patch)
tree89a68bc10003df63f9a673f69235f4c0a1084f67 /tests/auto
parent3da642b723667e8ba349291c2a98feca121244bb (diff)
downloadqtwebsockets-a5cb3b8ff10fcf1def8bde6f814582be1c19b83b.tar.gz
Fix flaky test: QTRY_COMPARE instead of qWait
Change-Id: Iad643950d669addf90f68b2bf9be29c755f9c1d9 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qwebsocket/tst_qwebsocket.cpp21
1 files changed, 6 insertions, 15 deletions
diff --git a/tests/auto/qwebsocket/tst_qwebsocket.cpp b/tests/auto/qwebsocket/tst_qwebsocket.cpp
index 4a0e06b..cb4b6bf 100644
--- a/tests/auto/qwebsocket/tst_qwebsocket.cpp
+++ b/tests/auto/qwebsocket/tst_qwebsocket.cpp
@@ -428,11 +428,9 @@ void tst_QWebSocket::tst_sendTextMessage()
socket.open(url);
- if (socketConnectedSpy.count() == 0)
- QVERIFY(socketConnectedSpy.wait(500));
+ QTRY_COMPARE(socketConnectedSpy.count(), 1);
QCOMPARE(socketError.count(), 0);
QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
- QCOMPARE(serverConnectedSpy.count(), 1);
QList<QVariant> arguments = serverConnectedSpy.takeFirst();
QUrl urlConnected = arguments.at(0).toUrl();
QCOMPARE(urlConnected, url);
@@ -464,8 +462,7 @@ void tst_QWebSocket::tst_sendTextMessage()
socket.open(QUrl(QStringLiteral("ws://") + echoServer.hostAddress().toString() +
QStringLiteral(":") + QString::number(echoServer.port())));
- if (socketConnectedSpy.count() == 0)
- QVERIFY(socketConnectedSpy.wait(500));
+ QTRY_COMPARE(socketConnectedSpy.count(), 1);
QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
socket.sendTextMessage(QStringLiteral("Hello world!"));
@@ -509,8 +506,7 @@ void tst_QWebSocket::tst_sendBinaryMessage()
socket.open(QUrl(QStringLiteral("ws://") + echoServer.hostAddress().toString() +
QStringLiteral(":") + QString::number(echoServer.port())));
- if (socketConnectedSpy.count() == 0)
- QVERIFY(socketConnectedSpy.wait(500));
+ QTRY_COMPARE(socketConnectedSpy.count(), 1);
QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
socket.sendBinaryMessage(QByteArrayLiteral("Hello world!"));
@@ -540,8 +536,7 @@ void tst_QWebSocket::tst_sendBinaryMessage()
socket.open(QUrl(QStringLiteral("ws://") + echoServer.hostAddress().toString() +
QStringLiteral(":") + QString::number(echoServer.port())));
- if (socketConnectedSpy.count() == 0)
- QVERIFY(socketConnectedSpy.wait(500));
+ QTRY_COMPARE(socketConnectedSpy.count(), 1);
QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
socket.sendBinaryMessage(QByteArrayLiteral("Hello world!"));
@@ -574,9 +569,7 @@ void tst_QWebSocket::tst_errorString()
socket.open(QUrl(QStringLiteral("ws://someserver.on.mars:9999")));
- if (errorSpy.count() == 0)
- errorSpy.wait(500);
- QCOMPARE(errorSpy.count(), 1);
+ QTRY_COMPARE(errorSpy.count(), 1);
QList<QVariant> arguments = errorSpy.takeFirst();
QAbstractSocket::SocketError socketError =
qvariant_cast<QAbstractSocket::SocketError>(arguments.at(0));
@@ -600,10 +593,8 @@ void tst_QWebSocket::tst_openRequest()
req.setRawHeader("X-Custom-Header", "A custom header");
socket.open(req);
- if (socketConnectedSpy.count() == 0)
- QVERIFY(socketConnectedSpy.wait(500));
+ QTRY_COMPARE(serverRequestSpy.count(), 1);
QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
- QCOMPARE(serverRequestSpy.count(), 1);
QList<QVariant> arguments = serverRequestSpy.takeFirst();
QNetworkRequest requestConnected = arguments.at(0).value<QNetworkRequest>();
QCOMPARE(requestConnected.url(), req.url());