summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-02-22 13:48:38 (GMT)
committerSamuli Piippo <samuli.piippo@digia.com>2011-06-09 10:04:54 (GMT)
commit18ac6c1bcb80b85a4e9e2f280ed5d454ad82f20f (patch)
treeb8dee58563e47bb0f0987306a717fbb5bc12070e /tests/auto
parente214c6fa5da0b139cfc35be105c8e678a8243dc9 (diff)
downloadQt-18ac6c1bcb80b85a4e9e2f280ed5d454ad82f20f.zip
Qt-18ac6c1bcb80b85a4e9e2f280ed5d454ad82f20f.tar.gz
Qt-18ac6c1bcb80b85a4e9e2f280ed5d454ad82f20f.tar.bz2
QNativeSocketEngine: Fix some error handling related to waitFor*()
Task: QTBUG-7054 Reviewed-by: Peter Hartmann (cherry picked from commit 8aaa61f8ea11c6e5794b5a3f6bf14bbbcb712074)
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qtcpsocket/tst_qtcpsocket.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
index 41acf08..9644152 100644
--- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
@@ -193,6 +193,7 @@ private slots:
void increaseReadBufferSize();
void taskQtBug5799ConnectionErrorWaitForConnected();
void taskQtBug5799ConnectionErrorEventLoop();
+ void taskQtBug7054TimeoutErrorResetting();
void invalidProxy_data();
void invalidProxy();
@@ -2245,6 +2246,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");