diff options
author | Luca Niccoli <lultimouomo@gmail.com> | 2015-04-02 07:28:20 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-04-08 08:46:04 +0000 |
commit | ba3b71327577f3ea348e9511c1475cf48f821880 (patch) | |
tree | 823caec3379843d8f4b564fe6eed37b5b0204a45 /tests | |
parent | 01eaae540cace513fa73340631dbb3a854c713b5 (diff) | |
download | qtwebsockets-ba3b71327577f3ea348e9511c1475cf48f821880.tar.gz |
Add open(const QNetworkRequest &) and request()
Request headers are not yet handled, only the QNetworkRequest::url() is
taken into consideration.
[ChangeLog][QWebSocket] Added open(const QNetworkRequest &) and request()
Task-number: QTBUG-40842
Change-Id: Ia2e10f22c79b0a085afb9a2eb8437b7a73d4a045
Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qwebsocket/tst_qwebsocket.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qwebsocket/tst_qwebsocket.cpp b/tests/auto/qwebsocket/tst_qwebsocket.cpp index 900f316..ed400ef 100644 --- a/tests/auto/qwebsocket/tst_qwebsocket.cpp +++ b/tests/auto/qwebsocket/tst_qwebsocket.cpp @@ -135,6 +135,7 @@ private Q_SLOTS: void tst_sendTextMessage(); void tst_sendBinaryMessage(); void tst_errorString(); + void tst_openRequest(); #ifndef QT_NO_NETWORKPROXY void tst_setProxy(); #endif @@ -568,6 +569,27 @@ void tst_QWebSocket::tst_errorString() QCOMPARE(socket.errorString(), QStringLiteral("Host not found")); } +void tst_QWebSocket::tst_openRequest() +{ + EchoServer echoServer; + + QWebSocket socket; + + QSignalSpy socketConnectedSpy(&socket, SIGNAL(connected())); + + QUrl url = QUrl(QStringLiteral("ws://") + echoServer.hostAddress().toString() + + QLatin1Char(':') + QString::number(echoServer.port())); + url.addQueryItem("queryitem", "with encoded characters"); + QNetworkRequest req(url); + socket.open(req); + + if (socketConnectedSpy.count() == 0) + QVERIFY(socketConnectedSpy.wait(500)); + QCOMPARE(socket.state(), QAbstractSocket::ConnectedState); + + socket.close(); +} + #ifndef QT_NO_NETWORKPROXY void tst_QWebSocket::tst_setProxy() { |