summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilian Wolff <mail@milianw.de>2014-02-06 18:02:04 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-06 20:59:18 +0100
commit35a099243403ee0521474f9c53678c6f4420969c (patch)
tree86a88ffb58f8799d67241b665e730f4b896f3ef0
parentdaf0faa0930b72a78ff940ecbf2a5eb8930fd793 (diff)
downloadqtwebsockets-35a099243403ee0521474f9c53678c6f4420969c.tar.gz
Fix tst_QWebSocket::tst_invalidOpen for catch-all DNS setups.
Instead of relying on a hostname which might still be resolved in some DNS setups (i.e. always forward to google search or intranet), we now try to connect to localhost port 1 which should yield a ConnectionRefusedError. This way, the test passes for me on my setup. Change-Id: I025824796e94e718a42c4999706f647a72b37659 Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
-rw-r--r--tests/auto/qwebsocket/tst_qwebsocket.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/auto/qwebsocket/tst_qwebsocket.cpp b/tests/auto/qwebsocket/tst_qwebsocket.cpp
index 773e824..d1ad0a9 100644
--- a/tests/auto/qwebsocket/tst_qwebsocket.cpp
+++ b/tests/auto/qwebsocket/tst_qwebsocket.cpp
@@ -171,7 +171,7 @@ void tst_QWebSocket::tst_invalidOpen()
QSignalSpy pongSpy(&socket, SIGNAL(pong(quint64,QByteArray)));
QSignalSpy bytesWrittenSpy(&socket, SIGNAL(bytesWritten(qint64)));
- socket.open(QUrl(QStringLiteral("ws://SomeNonExistingWebSocketServer/")), true);
+ socket.open(QUrl(QStringLiteral("ws://127.0.0.1:1/")), true);
QVERIFY(socket.origin().isEmpty());
QCOMPARE(socket.version(), QWebSocketProtocol::VersionLatest);
@@ -185,23 +185,23 @@ void tst_QWebSocket::tst_invalidOpen()
QCOMPARE(socket.pauseMode(), QAbstractSocket::PauseNever);
QVERIFY(socket.peerAddress().isNull());
QCOMPARE(socket.peerPort(), quint16(0));
- QCOMPARE(socket.peerName(), QStringLiteral("somenonexistingwebsocketserver"));
+ QCOMPARE(socket.peerName(), QStringLiteral("127.0.0.1"));
QCOMPARE(socket.state(), QAbstractSocket::ConnectingState);
QCOMPARE(socket.readBufferSize(), 0);
QCOMPARE(socket.resourceName(), QStringLiteral("/"));
- QCOMPARE(socket.requestUrl(), QUrl(QStringLiteral("ws://SomeNonExistingWebSocketServer/")));
+ QCOMPARE(socket.requestUrl(), QUrl(QStringLiteral("ws://127.0.0.1:1/")));
QCOMPARE(socket.closeCode(), QWebSocketProtocol::CloseCodeNormal);
QVERIFY(socket.closeReason().isEmpty());
QVERIFY(!socket.flush()); //flush should fail if socket is in connecting state
QCOMPARE(socket.sendTextMessage(QStringLiteral("A text message")), 0);
QCOMPARE(socket.sendBinaryMessage(QByteArrayLiteral("A text message")), 0);
- errorSpy.wait();
+ QVERIFY(errorSpy.wait());
QCOMPARE(errorSpy.count(), 1);
QList<QVariant> arguments = errorSpy.takeFirst();
QAbstractSocket::SocketError socketError =
qvariant_cast<QAbstractSocket::SocketError>(arguments.at(0));
- QCOMPARE(socketError, QAbstractSocket::HostNotFoundError);
+ QCOMPARE(socketError, QAbstractSocket::ConnectionRefusedError);
QCOMPARE(aboutToCloseSpy.count(), 0);
QCOMPARE(connectedSpy.count(), 0);
QCOMPARE(disconnectedSpy.count(), 1);