diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-11-19 10:06:55 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-11-19 10:10:24 (GMT) |
commit | 83525ca84ba7adadaeeb65ffa55a6d0f2630caaa (patch) | |
tree | 83a26fc42ba3811baf38776d266d4bf600684715 /tests/auto/qnetworkreply | |
parent | b115770cc3bba68740a6848c7ccaed932399aca9 (diff) | |
parent | 4082e4711a1c54947429b15504caf778c6da22d0 (diff) | |
download | Qt-83525ca84ba7adadaeeb65ffa55a6d0f2630caaa.zip Qt-83525ca84ba7adadaeeb65ffa55a6d0f2630caaa.tar.gz Qt-83525ca84ba7adadaeeb65ffa55a6d0f2630caaa.tar.bz2 |
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts:
qmake/generators/win32/msbuild_objectmodel.cpp
src/gui/kernel/qgesturemanager.cpp
tools/qdoc3/test/qt-build-docs.qdocconf
tools/qdoc3/test/qt.qdocconf
Changes in qmake/generators/win32/msvc_objectmodel.cpp come
from commit 4ba3dadcae97bfde6216c32cfa339f8f0e0253c7
Diffstat (limited to 'tests/auto/qnetworkreply')
-rw-r--r-- | tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 56 |
1 files changed, 39 insertions, 17 deletions
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 936dc57..fff7f66 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -309,6 +309,8 @@ private Q_SLOTS: void httpWithNoCredentialUsage(); + void qtbug15311doubleContentLength(); + // NOTE: This test must be last! void parentingRepliesToTheApp(); }; @@ -4142,8 +4144,23 @@ void tst_QNetworkReply::httpProxyCommands() QCOMPARE(receivedHeader, expectedCommand); } +class ProxyChangeHelper : public QObject { + Q_OBJECT +public: + ProxyChangeHelper() : QObject(), signalCount(0) {}; +public slots: + void finishedSlot() { + signalCount++; + if (signalCount == 2) + QMetaObject::invokeMethod(&QTestEventLoop::instance(), "exitLoop", Qt::QueuedConnection); + } +private: + int signalCount; +}; + void tst_QNetworkReply::proxyChange() { + ProxyChangeHelper helper; MiniHttpServer proxyServer( "HTTP/1.0 200 OK\r\nProxy-Connection: keep-alive\r\n" "Content-Length: 1\r\n\r\n1"); @@ -4153,30 +4170,15 @@ void tst_QNetworkReply::proxyChange() manager.setProxy(dummyProxy); QNetworkReplyPtr reply1 = manager.get(req); - QSignalSpy finishedspy(reply1, SIGNAL(finished())); + connect(reply1, SIGNAL(finished()), &helper, SLOT(finishedSlot())); manager.setProxy(QNetworkProxy()); QNetworkReplyPtr reply2 = manager.get(req); + connect(reply2, SIGNAL(finished()), &helper, SLOT(finishedSlot())); - connect(reply2, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); -#ifdef Q_OS_SYMBIAN - // we need more time as: - // 1. running from the emulator - // 2. not perfect POSIX implementation - // 3. embedded device QTestEventLoop::instance().enterLoop(20); -#else - QTestEventLoop::instance().enterLoop(10); -#endif QVERIFY(!QTestEventLoop::instance().timeout()); - if (finishedspy.count() == 0) { - // wait for the second reply as well - connect(reply1, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); - QTestEventLoop::instance().enterLoop(1); - QVERIFY(!QTestEventLoop::instance().timeout()); - } - // verify that the replies succeeded QCOMPARE(reply1->error(), QNetworkReply::NoError); QCOMPARE(reply1->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); @@ -4996,6 +4998,26 @@ void tst_QNetworkReply::httpWithNoCredentialUsage() QCOMPARE(reply->error(), QNetworkReply::AuthenticationRequiredError); } +void tst_QNetworkReply::qtbug15311doubleContentLength() +{ + QByteArray response("HTTP/1.0 200 OK\r\nContent-Length: 3\r\nServer: bogus\r\nContent-Length: 3\r\n\r\nABC"); + MiniHttpServer server(response); + server.doClose = true; + + QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort()))); + QNetworkReplyPtr reply = manager.get(request); + + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(reply->isFinished()); + QCOMPARE(reply->error(), QNetworkReply::NoError); + QCOMPARE(reply->size(), qint64(3)); + QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), qint64(3)); + QCOMPARE(reply->rawHeader("Content-length"), QByteArray("3, 3")); + QCOMPARE(reply->readAll(), QByteArray("ABC")); +} + // NOTE: This test must be last testcase in tst_qnetworkreply! |