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 <jason.mcdonald@nokia.com>
bb10
Rohan McGovern 2012-02-08 10:59:38 +10:00 committed by Qt by Nokia
parent 269ef14215
commit f50a84008e
1 changed files with 7 additions and 7 deletions

View File

@ -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");