summaryrefslogtreecommitdiffstats
path: root/tests/auto/network
diff options
context:
space:
mode:
authorPeter Hartmann <peter.hartmann@nokia.com>2011-11-17 11:19:33 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-25 21:58:57 +0100
commit1ddecb0aa20c660ab086cbd0b87c8384ed6f444d (patch)
tree780dadd06cc9ad2617d59bd54bea3654c1432963 /tests/auto/network
parentb9acd85b2f92f887521b952f84ced9a2d1a8a57e (diff)
network auto tests: add QNetworkReply test for pipelining
Reviewed-by: Markus Goetz Task-number: QTBUG-21369 (cherry picked from commit a32bfdef6d6b45c916f143dcf8495a2e102c3eec) Change-Id: Iecde23c56f128008c5172675601928d83180358a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/network')
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
index dc1dd4ab68..41972b7811 100644
--- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -165,6 +165,7 @@ public Q_SLOTS:
void gotError();
void authenticationRequired(QNetworkReply*,QAuthenticator*);
void proxyAuthenticationRequired(const QNetworkProxy &,QAuthenticator*);
+ void pipeliningHelperSlot();
#ifndef QT_NO_OPENSSL
void sslErrors(QNetworkReply*,const QList<QSslError> &);
@@ -384,6 +385,7 @@ private Q_SLOTS:
void authenticationCacheAfterCancel();
void authenticationWithDifferentRealm();
void synchronousAuthenticationCache();
+ void pipelining();
// NOTE: This test must be last!
void parentingRepliesToTheApp();
@@ -6663,6 +6665,43 @@ void tst_QNetworkReply::synchronousAuthenticationCache()
}
}
+void tst_QNetworkReply::pipelining()
+{
+ QString urlString("http://" + QtNetworkSettings::serverName() + "/qtest/cgi-bin/echo.cgi?");
+ QList<QNetworkReplyPtr> replies;
+ for (int a = 0; a < 20; a++) {
+ QNetworkRequest request(urlString + QString::number(a));
+ request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, QVariant(true));
+ replies.append(manager.get(request));
+ connect(replies.at(a), SIGNAL(finished()), this, SLOT(pipeliningHelperSlot()));
+ }
+ QTestEventLoop::instance().enterLoop(20);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+}
+
+void tst_QNetworkReply::pipeliningHelperSlot() {
+ static int a = 0;
+
+ // check that pipelining was used in at least one of the replies
+ static bool pipeliningWasUsed = false;
+ QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
+ bool pipeliningWasUsedInReply = reply->attribute(QNetworkRequest::HttpPipeliningWasUsedAttribute).toBool();
+ if (pipeliningWasUsedInReply)
+ pipeliningWasUsed = true;
+
+ // check that the contents match (the response to echo.cgi?3 should return 3 etc.)
+ QString urlQueryString = reply->url().queryItems().at(0).first;
+ QString content = reply->readAll();
+ QVERIFY2(urlQueryString == content, "data corruption with pipelining detected");
+
+ a++;
+
+ if (a == 20) { // all replies have finished
+ QTestEventLoop::instance().exitLoop();
+ QVERIFY2(pipeliningWasUsed, "pipelining was not used in any of the replies when trying to test pipelining");
+ }
+}
+
// NOTE: This test must be last testcase in tst_qnetworkreply!
void tst_QNetworkReply::parentingRepliesToTheApp()
{