summaryrefslogtreecommitdiffstats
path: root/tests/auto/qnetworkreply
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-05-13 12:54:34 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-05-13 13:46:44 (GMT)
commit4698e02579a4427c7a4ff7d59b1e37ba28ebc8e0 (patch)
treec439aebe2f0d29e9f675920cdcbcdf1f6f06f051 /tests/auto/qnetworkreply
parentd3c54f401d1b8aeab4a911b4be9bcbdd99056e1f (diff)
downloadQt-4698e02579a4427c7a4ff7d59b1e37ba28ebc8e0.zip
Qt-4698e02579a4427c7a4ff7d59b1e37ba28ebc8e0.tar.gz
Qt-4698e02579a4427c7a4ff7d59b1e37ba28ebc8e0.tar.bz2
QNAM HTTP: More testcases
Diffstat (limited to 'tests/auto/qnetworkreply')
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 038610d..74ed7fc 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -276,6 +276,9 @@ private Q_SLOTS:
void ignoreSslErrorsListWithSlot();
#endif
+ void getAndThenDeleteObject_data();
+ void getAndThenDeleteObject();
+
// NOTE: This test must be last!
void parentingRepliesToTheApp();
};
@@ -4108,6 +4111,50 @@ void tst_QNetworkReply::ignoreSslErrorsListWithSlot()
#endif // QT_NO_OPENSSL
+void tst_QNetworkReply::getAndThenDeleteObject_data()
+{
+ QTest::addColumn<bool>("replyFirst");
+
+ QTest::newRow("delete-reply-first") << true;
+ QTest::newRow("delete-qnam-first") << false;
+}
+
+void tst_QNetworkReply::getAndThenDeleteObject()
+{
+ // 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(1);
+ reply->setParent((QObject*)0); // must be 0 because else it is the manager
+
+ QTime stopWatch;
+ stopWatch.start();
+ forever {
+ QCoreApplication::instance()->processEvents();
+ if (reply->bytesAvailable())
+ break;
+ if (stopWatch.elapsed() >= 30000)
+ break;
+ }
+
+ QVERIFY(reply->bytesAvailable());
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200);
+ QVERIFY(!reply->isFinished()); // must not be finished
+
+ QFETCH(bool, replyFirst);
+
+ if (replyFirst) {
+ delete reply;
+ delete manager;
+ } else {
+ delete manager;
+ delete reply;
+ }
+}
+
+
+
// NOTE: This test must be last testcase in tst_qnetworkreply!
void tst_QNetworkReply::parentingRepliesToTheApp()
{