summaryrefslogtreecommitdiff
path: root/tests/auto
diff options
context:
space:
mode:
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());