diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2010-05-13 12:54:34 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2010-05-13 13:46:44 (GMT) |
commit | 4698e02579a4427c7a4ff7d59b1e37ba28ebc8e0 (patch) | |
tree | c439aebe2f0d29e9f675920cdcbcdf1f6f06f051 /tests/auto/qhttpnetworkconnection | |
parent | d3c54f401d1b8aeab4a911b4be9bcbdd99056e1f (diff) | |
download | Qt-4698e02579a4427c7a4ff7d59b1e37ba28ebc8e0.zip Qt-4698e02579a4427c7a4ff7d59b1e37ba28ebc8e0.tar.gz Qt-4698e02579a4427c7a4ff7d59b1e37ba28ebc8e0.tar.bz2 |
QNAM HTTP: More testcases
Diffstat (limited to 'tests/auto/qhttpnetworkconnection')
-rw-r--r-- | tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index 21f228a..89f608e 100644 --- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -109,6 +109,9 @@ private Q_SLOTS: void getMultipleWithPriorities(); void getEmptyWithPipelining(); + + void getAndThenDeleteObject(); + void getAndThenDeleteObject_data(); }; tst_QHttpNetworkConnection::tst_QHttpNetworkConnection() @@ -1033,6 +1036,47 @@ void tst_QHttpNetworkConnection::getEmptyWithPipelining() qDeleteAll(replies); } +void tst_QHttpNetworkConnection::getAndThenDeleteObject_data() +{ + QTest::addColumn<bool>("replyFirst"); + + QTest::newRow("delete-reply-first") << true; + QTest::newRow("delete-connection-first") << false; +} + +void tst_QHttpNetworkConnection::getAndThenDeleteObject() +{ + // yes, this will leak if the testcase fails. I don't care. It must not fail then :P + QHttpNetworkConnection *connection = new QHttpNetworkConnection(QtNetworkSettings::serverName()); + QHttpNetworkRequest request("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile"); + QHttpNetworkReply *reply = connection->sendRequest(request); + reply->setDownstreamLimited(true); + + QTime stopWatch; + stopWatch.start(); + forever { + QCoreApplication::instance()->processEvents(); + if (reply->bytesAvailable()) + break; + if (stopWatch.elapsed() >= 30000) + break; + } + + QVERIFY(reply->bytesAvailable()); + QCOMPARE(reply->statusCode() ,200); + QVERIFY(!reply->isFinished()); // must not be finished + + QFETCH(bool, replyFirst); + + if (replyFirst) { + delete reply; + delete connection; + } else { + delete connection; + delete reply; + } +} + QTEST_MAIN(tst_QHttpNetworkConnection) |