diff options
author | Sergio Ahumada <sergio.ahumada@nokia.com> | 2011-12-30 12:28:05 (GMT) |
---|---|---|
committer | Sergio Ahumada <sergio.ahumada@nokia.com> | 2011-12-30 12:28:05 (GMT) |
commit | 1353abff11dd3a68884f9c6fd748dcb934383d79 (patch) | |
tree | 0dcc25731cab6523c476cc64246151f8cf8f7c71 /tests | |
parent | 3a4f6f7884c9ea704890cd392bb5a211d2eb5701 (diff) | |
parent | 5e3e9c5600e3089073990fd752e0eaa0336c6301 (diff) | |
download | Qt-1353abff11dd3a68884f9c6fd748dcb934383d79.zip Qt-1353abff11dd3a68884f9c6fd748dcb934383d79.tar.gz Qt-1353abff11dd3a68884f9c6fd748dcb934383d79.tar.bz2 |
Merge branch 4.7 into qt-4.8-from-4.7
Conflicts:
src/network/access/qnetworkaccesshttpbackend.cpp
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 371ac57..ebf667f 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -345,6 +345,8 @@ private Q_SLOTS: void getAndThenDeleteObject_data(); void getAndThenDeleteObject(); + void deleteManagerWhileGetIsInProgress(); + void symbianOpenCDataUrlCrash(); void getFromHttpIntoBuffer_data(); @@ -5659,6 +5661,48 @@ void tst_QNetworkReply::getAndThenDeleteObject() } } +void tst_QNetworkReply::deleteManagerWhileGetIsInProgress() +{ + // yes, this will leak if the testcase fails. I don't care. It must not fail then :P + QNetworkAccessManager *manager = new QNetworkAccessManager(); + QNetworkRequest request("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile"); + QNetworkReply *reply = manager->get(request); + reply->setReadBufferSize(1024); + + // Reset reply's parent to allow it to outlive the manager + reply->setParent(0); + + // Wait until a buffer is received + int totalWait = 0; + while (!reply->bytesAvailable()) { + QTest::qWait(20); + totalWait += 20; + QVERIFY( totalWait <= 5*1000); + } + + QVERIFY(reply->bytesAvailable()); + QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); + QVERIFY(!reply->isFinished()); // must not be finished + + // Read the data to request next buffer's worth from the server + (void)reply->readAll(); + + QSignalSpy replyFinishedSpy(reply, SIGNAL(finished())); + + // Delete the manager + delete manager; + manager = 0; + + // Wait to allow reply to process any pending events + QTest::qWait(100); + + // The reply should be finished + QVERIFY(reply->isFinished()); + QCOMPARE(replyFinishedSpy.count(), 1); + + delete reply; +} + // see https://bugs.webkit.org/show_bug.cgi?id=38935 void tst_QNetworkReply::symbianOpenCDataUrlCrash() { |