diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-03-17 16:42:06 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-03-17 16:42:06 +0100 |
commit | 01eaae540cace513fa73340631dbb3a854c713b5 (patch) | |
tree | d2099ddf92820d52877f88fd52e4c5e1a4b29ab9 /tests/auto | |
parent | 009ffb330e43b57ed7539ae07c065524a6d4dc65 (diff) | |
parent | 2348cac4fa6baab447a21286ac8680ad6829008f (diff) | |
download | qtwebsockets-01eaae540cace513fa73340631dbb3a854c713b5.tar.gz |
Merge remote-tracking branch 'origin/5.5' into dev
Change-Id: I75fb372eec95215dab2f4807a842c2435ac7344e
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/handshakerequest/tst_handshakerequest.cpp | 22 | ||||
-rw-r--r-- | tests/auto/qwebsocket/tst_qwebsocket.cpp | 10 |
2 files changed, 24 insertions, 8 deletions
diff --git a/tests/auto/handshakerequest/tst_handshakerequest.cpp b/tests/auto/handshakerequest/tst_handshakerequest.cpp index aa203f3..9c579bd 100644 --- a/tests/auto/handshakerequest/tst_handshakerequest.cpp +++ b/tests/auto/handshakerequest/tst_handshakerequest.cpp @@ -65,6 +65,8 @@ private Q_SLOTS: void tst_multipleValuesInConnectionHeader(); void tst_multipleVersions(); + + void tst_qtbug_39355(); }; tst_HandshakeRequest::tst_HandshakeRequest() @@ -290,6 +292,26 @@ void tst_HandshakeRequest::tst_multipleVersions() QCOMPARE(request.versions().at(0), QWebSocketProtocol::Version13); } +void tst_HandshakeRequest::tst_qtbug_39355() +{ + QString header = QStringLiteral("GET /ABC/DEF/ HTTP/1.1\r\nHost: localhost:1234\r\n") + + QStringLiteral("Sec-WebSocket-Version: 13\r\n") + + QStringLiteral("Sec-WebSocket-Key: 2Wg20829/4ziWlmsUAD8Dg==\r\n") + + QStringLiteral("Upgrade: websocket\r\n") + + QStringLiteral("Connection: Upgrade\r\n\r\n"); + QByteArray data; + QTextStream textStream(&data); + QWebSocketHandshakeRequest request(8080, false); + + textStream << header; + textStream.seek(0); + request.readHandshake(textStream); + + QVERIFY(request.isValid()); + QCOMPARE(request.port(), 1234); + QCOMPARE(request.host(), QStringLiteral("localhost")); +} + QTEST_MAIN(tst_HandshakeRequest) #include "tst_handshakerequest.moc" diff --git a/tests/auto/qwebsocket/tst_qwebsocket.cpp b/tests/auto/qwebsocket/tst_qwebsocket.cpp index 92e969b..900f316 100644 --- a/tests/auto/qwebsocket/tst_qwebsocket.cpp +++ b/tests/auto/qwebsocket/tst_qwebsocket.cpp @@ -67,7 +67,7 @@ EchoServer::EchoServer(QObject *parent) : QWebSocketServer::NonSecureMode, this)), m_clients() { - if (m_pWebSocketServer->listen()) { + if (m_pWebSocketServer->listen(QHostAddress(QStringLiteral("127.0.0.1")))) { connect(m_pWebSocketServer, SIGNAL(newConnection()), this, SLOT(onNewConnection())); } @@ -398,8 +398,6 @@ void tst_QWebSocket::tst_invalidOrigin() void tst_QWebSocket::tst_sendTextMessage() { - //TODO: will resolve in another commit -#ifndef Q_OS_WIN EchoServer echoServer; QWebSocket socket; @@ -475,13 +473,10 @@ void tst_QWebSocket::tst_sendTextMessage() socket.close(QWebSocketProtocol::CloseCodeGoingAway, reason); QCOMPARE(socket.closeCode(), QWebSocketProtocol::CloseCodeGoingAway); QCOMPARE(socket.closeReason(), reason); -#endif } void tst_QWebSocket::tst_sendBinaryMessage() { - //TODO: will resolve in another commit -#ifndef Q_OS_WIN EchoServer echoServer; QWebSocket socket; @@ -549,7 +544,6 @@ void tst_QWebSocket::tst_sendBinaryMessage() isLastFrame = arguments.at(1).toBool(); QCOMPARE(frameReceived, QByteArrayLiteral("Hello world!")); QVERIFY(isLastFrame); -#endif } void tst_QWebSocket::tst_errorString() @@ -565,7 +559,7 @@ void tst_QWebSocket::tst_errorString() socket.open(QUrl(QStringLiteral("ws://someserver.on.mars:9999"))); if (errorSpy.count() == 0) - errorSpy.wait(); + errorSpy.wait(500); QCOMPARE(errorSpy.count(), 1); QList<QVariant> arguments = errorSpy.takeFirst(); QAbstractSocket::SocketError socketError = |