summaryrefslogtreecommitdiffstats
path: root/tests/auto/qhttpnetworkconnection
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-08-12 09:21:16 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-08-12 09:28:19 (GMT)
commitaa669904ff869a8b4f65a6e5cb87a8e85051a47e (patch)
treeed944c2ba71fa2373173284056eea1669b5afccc /tests/auto/qhttpnetworkconnection
parent26af575213763c8202f1a142f42257d473076529 (diff)
downloadQt-aa669904ff869a8b4f65a6e5cb87a8e85051a47e.zip
Qt-aa669904ff869a8b4f65a6e5cb87a8e85051a47e.tar.gz
Qt-aa669904ff869a8b4f65a6e5cb87a8e85051a47e.tar.bz2
tst_qhttpnetworkconnection: Pipelining auto test
Diffstat (limited to 'tests/auto/qhttpnetworkconnection')
-rw-r--r--tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
index 89f608e..188ed29 100644
--- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
+++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
@@ -110,6 +110,8 @@ private Q_SLOTS:
void getEmptyWithPipelining();
+ void getAndEverythingShouldBePipelined();
+
void getAndThenDeleteObject();
void getAndThenDeleteObject_data();
};
@@ -1036,6 +1038,52 @@ void tst_QHttpNetworkConnection::getEmptyWithPipelining()
qDeleteAll(replies);
}
+class GetAndEverythingShouldBePipelinedReceiver : public QObject
+{
+ Q_OBJECT
+public:
+ int receivedCount;
+ int requestCount;
+ GetAndEverythingShouldBePipelinedReceiver(int rq) : receivedCount(0),requestCount(rq) { }
+public Q_SLOTS:
+ void finishedSlot() {
+ QHttpNetworkReply *reply = (QHttpNetworkReply*) sender();
+ receivedCount++;
+
+ if (receivedCount == requestCount)
+ QTestEventLoop::instance().exitLoop();
+ }
+};
+
+void tst_QHttpNetworkConnection::getAndEverythingShouldBePipelined()
+{
+ quint16 requestCount = 100;
+ // use 1 connection.
+ QHttpNetworkConnection connection(1, QtNetworkSettings::serverName());
+ QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt");
+ QList<QHttpNetworkRequest*> requests;
+ QList<QHttpNetworkReply*> replies;
+
+ GetAndEverythingShouldBePipelinedReceiver receiver(requestCount);
+
+ for (int i = 0; i < requestCount; i++) {
+ QHttpNetworkRequest *request = 0;
+ request = new QHttpNetworkRequest(url, QHttpNetworkRequest::Get);
+ request->setPipeliningAllowed(true);
+ requests.append(request);
+ QHttpNetworkReply *reply = connection.sendRequest(*request);
+ connect(reply, SIGNAL(finished()), &receiver, SLOT(finishedSlot()));
+ replies.append(reply);
+ }
+ QTestEventLoop::instance().enterLoop(40);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ qDeleteAll(requests);
+ qDeleteAll(replies);
+
+}
+
+
void tst_QHttpNetworkConnection::getAndThenDeleteObject_data()
{
QTest::addColumn<bool>("replyFirst");