diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2010-01-18 13:57:21 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2010-01-18 15:48:03 (GMT) |
commit | b5d3b999fa9c52246c8d4e4c1389df105d96cced (patch) | |
tree | 35edc2742f9a170237c7f266fdc89648264c1853 /tests/auto/qnetworkreply/tst_qnetworkreply.cpp | |
parent | c4a842563d40e8b4c3693a8acb77c9aff6f06e29 (diff) | |
download | Qt-b5d3b999fa9c52246c8d4e4c1389df105d96cced.zip Qt-b5d3b999fa9c52246c8d4e4c1389df105d96cced.tar.gz Qt-b5d3b999fa9c52246c8d4e4c1389df105d96cced.tar.bz2 |
Enhance QFileNetworkReply
It is now considered as finished immediatly after creation to avoid
an event loop spin.
Had to change the auto tests a bit to account for the new behaviour.
Reviewed-by: Peter Hartmann
Diffstat (limited to 'tests/auto/qnetworkreply/tst_qnetworkreply.cpp')
-rw-r--r-- | tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 33753f1..3bf06d7 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -838,13 +838,20 @@ void tst_QNetworkReply::stateChecking() QVERIFY(reply->isOpen()); QVERIFY(reply->isReadable()); QVERIFY(!reply->isWritable()); - QCOMPARE(reply->errorString(), QString("Unknown error")); + + // both behaviours are OK since we might change underlying behaviour again + if (!reply->isFinished()) + QCOMPARE(reply->errorString(), QString("Unknown error")); + else + QVERIFY(!reply->errorString().isEmpty()); + QCOMPARE(reply->manager(), &manager); QCOMPARE(reply->request(), req); QCOMPARE(int(reply->operation()), int(QNetworkAccessManager::GetOperation)); - QCOMPARE(reply->error(), QNetworkReply::NoError); - QCOMPARE(reply->isFinished(), false); + // error and not error are OK since we might change underlying behaviour again + if (!reply->isFinished()) + QCOMPARE(reply->error(), QNetworkReply::NoError); QCOMPARE(reply->url(), url); reply->abort(); @@ -1151,7 +1158,8 @@ void tst_QNetworkReply::getErrors() QNetworkReplyPtr reply = manager.get(request); reply->setParent(this); // we have expect-fails - QCOMPARE(reply->error(), QNetworkReply::NoError); + if (!reply->isFinished()) + QCOMPARE(reply->error(), QNetworkReply::NoError); // now run the request: connect(reply, SIGNAL(finished()), @@ -1512,6 +1520,7 @@ void tst_QNetworkReply::ioGetFromFile() QNetworkRequest request(QUrl::fromLocalFile(file.fileName())); QNetworkReplyPtr reply = manager.get(request); + QVERIFY(reply->isFinished()); // a file should immediatly be done DataReader reader(reply); connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); @@ -3170,7 +3179,9 @@ void tst_QNetworkReply::ioPostToHttpEmptyUploadProgress() void tst_QNetworkReply::lastModifiedHeaderForFile() { - QFileInfo fileInfo(SRCDIR "./bigfile"); + QFileInfo fileInfo(SRCDIR "/bigfile"); + QVERIFY(fileInfo.exists()); + QUrl url = QUrl::fromLocalFile(fileInfo.filePath()); QNetworkRequest request(url); |