From f50a84008eb24d164df4e375084df457e9c85ce7 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 8 Feb 2012 10:59:38 +1000 Subject: Improved stability of tst_qhttpsocketengine This autotest assumed that various network operations could always be completed within 5 seconds. Notably, it assumed that an attempt to resolve a nonexistent hostname would always result in an error within 5 seconds. In my testing, it usually takes 4-6 seconds to complete, but occasionally takes as much as 13 seconds. (cherry picked from qt4 commit c85faef67b6a7e8fcedb4ce800282d41f5b79ec1) Change-Id: I982ecf6ebc1bb8ee2184cf5592cb2684474c870b Reviewed-by: Jason McDonald --- .../socket/qhttpsocketengine/tst_qhttpsocketengine.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp') diff --git a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp index 9b8391d6be..43b1f225c4 100644 --- a/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp +++ b/tests/auto/network/socket/qhttpsocketengine/tst_qhttpsocketengine.cpp @@ -294,7 +294,7 @@ void tst_QHttpSocketEngine::errorTest() connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop())); - QTestEventLoop::instance().enterLoop(5); + QTestEventLoop::instance().enterLoop(30); QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(int(socket.error()), expectedError); @@ -371,7 +371,7 @@ void tst_QHttpSocketEngine::simpleErrorsAndStates() QVERIFY(socketDevice.state() == QAbstractSocket::UnconnectedState); QVERIFY(!socketDevice.connectToHost(QHostAddress(QtNetworkSettings::serverName()), 8088)); QVERIFY(socketDevice.state() == QAbstractSocket::ConnectingState); - if (socketDevice.waitForWrite(15000)) { + if (socketDevice.waitForWrite(30000)) { QVERIFY(socketDevice.state() == QAbstractSocket::ConnectedState || socketDevice.state() == QAbstractSocket::UnconnectedState); } else { @@ -425,7 +425,7 @@ void tst_QHttpSocketEngine::tcpLoopbackPerformance() QTime timer; timer.start(); qlonglong readBytes = 0; - while (timer.elapsed() < 5000) { + while (timer.elapsed() < 30000) { qlonglong written = serverSocket.write(message1.data(), message1.size()); while (written > 0) { client.waitForRead(); @@ -458,7 +458,7 @@ void tst_QHttpSocketEngine::tcpSocketBlockingTest() QCOMPARE(socket.state(), QTcpSocket::ConnectedState); // Read greeting - QVERIFY(socket.waitForReadyRead(5000)); + QVERIFY(socket.waitForReadyRead(30000)); QString s = socket.readLine(); QVERIFY2(QtNetworkSettings::compareReplyIMAP(s.toLatin1()), qPrintable(s)); @@ -466,7 +466,7 @@ void tst_QHttpSocketEngine::tcpSocketBlockingTest() QCOMPARE((int) socket.write("1 NOOP\r\n", 8), 8); if (!socket.canReadLine()) - QVERIFY(socket.waitForReadyRead(5000)); + QVERIFY(socket.waitForReadyRead(30000)); // Read response s = socket.readLine(); @@ -476,14 +476,14 @@ void tst_QHttpSocketEngine::tcpSocketBlockingTest() QCOMPARE((int) socket.write("2 LOGOUT\r\n", 10), 10); if (!socket.canReadLine()) - QVERIFY(socket.waitForReadyRead(5000)); + QVERIFY(socket.waitForReadyRead(30000)); // Read two lines of respose s = socket.readLine(); QCOMPARE(s.toLatin1().constData(), "* BYE LOGOUT received\r\n"); if (!socket.canReadLine()) - QVERIFY(socket.waitForReadyRead(5000)); + QVERIFY(socket.waitForReadyRead(30000)); s = socket.readLine(); QCOMPARE(s.toLatin1().constData(), "2 OK Completed\r\n"); -- cgit v1.2.3