summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-04-14 15:24:53 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-04-16 11:31:34 (GMT)
commit46faa5d37e2dbe30f7683ae9e4f70b1c8723da96 (patch)
treeb813a730260435187d59635fbeddb8867af464f8 /tests
parent94119f30748e21440275535f3d681e45e28183e4 (diff)
downloadQt-46faa5d37e2dbe30f7683ae9e4f70b1c8723da96.zip
Qt-46faa5d37e2dbe30f7683ae9e4f70b1c8723da96.tar.gz
Qt-46faa5d37e2dbe30f7683ae9e4f70b1c8723da96.tar.bz2
Add a simple event-loop based test
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtcpsocket_stresstest/tst_qtcpsocket_stresstest.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qtcpsocket_stresstest/tst_qtcpsocket_stresstest.cpp b/tests/auto/qtcpsocket_stresstest/tst_qtcpsocket_stresstest.cpp
index 1763158..6a57d20 100644
--- a/tests/auto/qtcpsocket_stresstest/tst_qtcpsocket_stresstest.cpp
+++ b/tests/auto/qtcpsocket_stresstest/tst_qtcpsocket_stresstest.cpp
@@ -63,6 +63,7 @@ private Q_SLOTS:
void blockingConnectDisconnect();
void blockingPipelined();
void blockingMultipleRequests();
+ void connectDisconnect();
};
tst_QTcpSocket_stresstest::tst_QTcpSocket_stresstest()
@@ -201,6 +202,31 @@ void tst_QTcpSocket_stresstest::blockingMultipleRequests()
}
}
+void tst_QTcpSocket_stresstest::connectDisconnect()
+{
+ QFETCH_GLOBAL(QString, hostname);
+ QFETCH_GLOBAL(int, port);
+
+ for (int i = 0; i < AttemptCount; ++i) {
+ qDebug("Attempt %d", i);
+ QTcpSocket socket;
+ socket.connectToHost(hostname, port);
+ QTestEventLoop::instance().connect(&socket, SIGNAL(connected()), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(30);
+ QVERIFY2(!QTestEventLoop::instance().timeout(), "Timeout");
+
+ socket.write("GET /qtest/bigfile HTTP/1.1\r\n"
+ "Connection: close\r\n"
+ "User-Agent: tst_QTcpSocket_stresstest/1.0\r\n"
+ "Host: " + hostname.toLatin1() + "\r\n"
+ "\r\n");
+
+ QTestEventLoop::instance().connect(&socket, SIGNAL(disconnected()), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(30);
+ QVERIFY2(!QTestEventLoop::instance().timeout(), "Timeout");
+ }
+}
+
QTEST_MAIN(tst_QTcpSocket_stresstest);
#include "tst_qtcpsocket_stresstest.moc"