summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-05-05 15:04:31 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-05-15 12:55:13 (GMT)
commitfea180d80112faa1a314e240ab07c37e4c2e0d1d (patch)
tree47ced7a9cc2cda55d40505d51723d4adc02f02ef /tests/auto/qtcpsocket/tst_qtcpsocket.cpp
parentb1749e9052c68dff6089bf5f0d2a41cd88dfcb50 (diff)
downloadQt-fea180d80112faa1a314e240ab07c37e4c2e0d1d.zip
Qt-fea180d80112faa1a314e240ab07c37e4c2e0d1d.tar.gz
Qt-fea180d80112faa1a314e240ab07c37e4c2e0d1d.tar.bz2
Autotest: some improvements to timeout testing of tst_QTcpSocket
Diffstat (limited to 'tests/auto/qtcpsocket/tst_qtcpsocket.cpp')
-rw-r--r--tests/auto/qtcpsocket/tst_qtcpsocket.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
index cd512a1..d195d3c 100644
--- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
@@ -144,6 +144,7 @@ private slots:
void blockingIMAP();
void nonBlockingIMAP();
void hostNotFound();
+ void timeoutConnect_data();
void timeoutConnect();
void delayedClose();
void partialRead();
@@ -544,19 +545,36 @@ void tst_QTcpSocket::hostNotFound()
}
//----------------------------------------------------------------------------------
+void tst_QTcpSocket::timeoutConnect_data()
+{
+ QTest::addColumn<QString>("address");
+ QTest::newRow("host") << QtNetworkSettings::serverName();
+ QTest::newRow("ip") << QtNetworkSettings::serverIP();
+}
void tst_QTcpSocket::timeoutConnect()
{
+ QFETCH(QString, address);
QTcpSocket *socket = newSocket();
- // Outgoing port 53 is firewalled in the Oslo office.
- socket->connectToHost("cisco.com", 53);
+ QElapsedTimer timer;
+ timer.start();
+
+ // Port 1357 is configured to drop packets on the test server
+ socket->connectToHost(address, 1357);
+ QVERIFY(timer.elapsed() < 50);
QVERIFY(!socket->waitForConnected(200));
QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
QCOMPARE(int(socket->error()), int(QTcpSocket::SocketTimeoutError));
- socket->connectToHost("cisco.com", 53);
- QTest::qSleep(50);
+ timer.start();
+ socket->connectToHost(address, 1357);
+ QVERIFY(timer.elapsed() < 50);
+ QTimer::singleShot(50, &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::enterLoop(5);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY(socket->state() == QTcpSocket::ConnectingState
+ || socket->state() == QTcpSocket::HostLookupState);
socket->abort();
QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
QCOMPARE(socket->openMode(), QIODevice::NotOpen);