diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2010-02-22 13:48:38 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2010-02-22 14:52:39 (GMT) |
commit | 8aaa61f8ea11c6e5794b5a3f6bf14bbbcb712074 (patch) | |
tree | 1473bfc04dc3dc56c36edacf294edad2d994d89e /tests/auto/qtcpsocket/tst_qtcpsocket.cpp | |
parent | dbdb4c507ac209adc4391c95d312be0ad01e77a9 (diff) | |
download | Qt-8aaa61f8ea11c6e5794b5a3f6bf14bbbcb712074.zip Qt-8aaa61f8ea11c6e5794b5a3f6bf14bbbcb712074.tar.gz Qt-8aaa61f8ea11c6e5794b5a3f6bf14bbbcb712074.tar.bz2 |
QNativeSocketEngine: Fix some error handling related to waitFor*()
Task: QTBUG-7054
Reviewed-by: Peter Hartmann
Diffstat (limited to 'tests/auto/qtcpsocket/tst_qtcpsocket.cpp')
-rw-r--r-- | tests/auto/qtcpsocket/tst_qtcpsocket.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index e638e287..12686bb 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -191,6 +191,7 @@ private slots: void increaseReadBufferSize(); void taskQtBug5799ConnectionErrorWaitForConnected(); void taskQtBug5799ConnectionErrorEventLoop(); + void taskQtBug7054TimeoutErrorResetting(); void invalidProxy_data(); void invalidProxy(); @@ -2236,6 +2237,30 @@ void tst_QTcpSocket::taskQtBug5799ConnectionErrorEventLoop() QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit()); } +void tst_QTcpSocket::taskQtBug7054TimeoutErrorResetting() +{ + QTcpSocket *socket = newSocket(); + + socket->connectToHost(QtNetworkSettings::serverName(), 443); + QVERIFY(socket->waitForConnected(5*1000)); + QVERIFY(socket->error() == QAbstractSocket::UnknownSocketError); + + // We connected to the HTTPS port. Wait two seconds to receive data. We will receive + // nothing because we would need to start the SSL handshake + QVERIFY(!socket->waitForReadyRead(2*1000)); + QVERIFY(socket->error() == QAbstractSocket::SocketTimeoutError); + + // Now write some crap to make the server disconnect us. 4 lines are enough. + socket->write("a\r\nb\r\nc\r\nd\r\n"); + socket->waitForBytesWritten(2*1000); + + // we try to waitForReadyRead another time, but this time instead of a timeout we + // should get a better error since the server disconnected us + QVERIFY(!socket->waitForReadyRead(2*1000)); + // It must NOT be the SocketTimeoutError that had been set before + QVERIFY(socket->error() == QAbstractSocket::RemoteHostClosedError); +} + void tst_QTcpSocket::invalidProxy_data() { QTest::addColumn<int>("type"); |