diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2009-11-11 12:33:35 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2009-11-11 13:09:28 (GMT) |
commit | f7a1117cbec5638e32ea04b6a93412b193e07913 (patch) | |
tree | 1eb702f776a1fc387c802480ee9ad2db1f40194b | |
parent | 0739771c29d38a4a2f2cb08560181195ad4e8e0c (diff) | |
download | Qt-f7a1117cbec5638e32ea04b6a93412b193e07913.zip Qt-f7a1117cbec5638e32ea04b6a93412b193e07913.tar.gz Qt-f7a1117cbec5638e32ea04b6a93412b193e07913.tar.bz2 |
tst_qnetworkreply: Test LastModified parsing
Someone complained about it giving wrong values, however this
test passes at least here on my Linux box.
Reviewed-by: Peter Hartmann
-rw-r--r-- | tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 446fb53..bd83c47 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -225,6 +225,9 @@ private Q_SLOTS: void ioPostToHttpUploadProgress(); void ioPostToHttpEmtpyUploadProgress(); + void lastModifiedHeaderForFile(); + void lastModifiedHeaderForHttp(); + void rateControl_data(); void rateControl(); @@ -2964,6 +2967,41 @@ void tst_QNetworkReply::ioPostToHttpEmtpyUploadProgress() server.close(); } +void tst_QNetworkReply::lastModifiedHeaderForFile() +{ + QFileInfo fileInfo(SRCDIR "./bigfile"); + QUrl url = QUrl::fromLocalFile(fileInfo.filePath()); + + QNetworkRequest request(url); + QNetworkReplyPtr reply = manager.head(request); + QSignalSpy spy(reply, SIGNAL(uploadProgress(qint64,qint64))); + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QDateTime header = reply->header(QNetworkRequest::LastModifiedHeader).toDateTime(); + QCOMPARE(header, fileInfo.lastModified()); +} + +void tst_QNetworkReply::lastModifiedHeaderForHttp() +{ + // Tue, 22 May 2007 12:04:57 GMT according to webserver + QUrl url = "http://" + QtNetworkSettings::serverName() + "/gif/fluke.gif"; + + QNetworkRequest request(url); + QNetworkReplyPtr reply = manager.head(request); + QSignalSpy spy(reply, SIGNAL(uploadProgress(qint64,qint64))); + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QDateTime header = reply->header(QNetworkRequest::LastModifiedHeader).toDateTime(); + QDateTime realDate = QDateTime::fromString("2007-05-22T12:04:57", Qt::ISODate); + realDate.setTimeSpec(Qt::UTC); + + QCOMPARE(header, realDate); +} + void tst_QNetworkReply::rateControl_data() { QTest::addColumn<int>("rate"); |