summaryrefslogtreecommitdiffstats
path: root/tests/auto/qnetworkreply
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-02-18 15:11:10 +0100
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-02-18 16:46:20 +0100
commit9d8614d8dcd1ae8389842aa4c48d8c77ae69bf27 (patch)
tree0778f2d7486d6ae6fb0e9c6e6138a1e1d68ad376 /tests/auto/qnetworkreply
parent90c3e1d2110c47ad36e05c04c874d6d932dd772f (diff)
tst_qnetworkreply: Add another testcase
Reviewed-by: Peter Hartmann
Diffstat (limited to 'tests/auto/qnetworkreply')
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 5fecc86be2..049bbb8814 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -257,6 +257,8 @@ private Q_SLOTS:
void httpConnectionCount();
+ void httpRecursiveCreation();
+
#ifndef QT_NO_OPENSSL
void ioPostToHttpsUploadProgress();
void ignoreSslErrorsList_data();
@@ -3788,6 +3790,70 @@ void tst_QNetworkReply::httpConnectionCount()
#endif
}
+class HttpRecursiveCreationHelper : public QObject {
+ Q_OBJECT
+public:
+
+ HttpRecursiveCreationHelper():
+ QObject(0),
+ requestsStartedCount_finished(0),
+ requestsStartedCount_readyRead(0),
+ requestsFinishedCount(0)
+ {
+ }
+ QNetworkAccessManager manager;
+ int requestsStartedCount_finished;
+ int requestsStartedCount_readyRead;
+ int requestsFinishedCount;
+public slots:
+ void finishedSlot() {
+ requestsFinishedCount++;
+
+ QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
+ QVERIFY(!reply->error());
+ QVERIFY(reply->bytesAvailable() == 27906);
+
+ if (requestsFinishedCount == 60) {
+ QTestEventLoop::instance().exitLoop();
+ return;
+ }
+
+ if (requestsStartedCount_finished < 30) {
+ startOne();
+ requestsStartedCount_finished++;
+ }
+
+ reply->deleteLater();
+ }
+ void readyReadSlot() {
+ QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
+ QVERIFY(!reply->error());
+
+ if (requestsStartedCount_readyRead < 30 && reply->bytesAvailable() > 27906/2) {
+ startOne();
+ requestsStartedCount_readyRead++;
+ }
+ }
+ void startOne() {
+ QUrl url = "http://" + QtNetworkSettings::serverName() + "/gif/fluke.gif";
+ QNetworkRequest request(url);
+ QNetworkReply *reply = manager.get(request);
+ reply->setParent(this);
+ connect(reply, SIGNAL(finished()), this, SLOT(finishedSlot()));
+ connect(reply, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
+ }
+};
+
+void tst_QNetworkReply::httpRecursiveCreation()
+{
+ // this test checks if creation of new requests to the same host properly works
+ // from readyRead() and finished() signals
+ HttpRecursiveCreationHelper helper;
+ helper.startOne();
+ QTestEventLoop::instance().enterLoop(30);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+}
+
#ifndef QT_NO_OPENSSL
void tst_QNetworkReply::ignoreSslErrorsList_data()
{