summaryrefslogtreecommitdiffstats
path: root/tests/auto/qnetworkreply
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-05-18 14:31:07 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-05-18 14:31:07 (GMT)
commitf3988241faa59596c1702b31e7bec9538f33ee79 (patch)
tree39cc06b8455545cd1fd754c44838afcc3a0bdaac /tests/auto/qnetworkreply
parent7e4d4474d10cb17047d95e3a4820388468c74507 (diff)
parent5c25207628fbcc94e92b129ac7660af14613ad85 (diff)
downloadQt-f3988241faa59596c1702b31e7bec9538f33ee79.zip
Qt-f3988241faa59596c1702b31e7bec9538f33ee79.tar.gz
Qt-f3988241faa59596c1702b31e7bec9538f33ee79.tar.bz2
Merge commit 'origin/4.5'
Conflicts: src/corelib/kernel/qobject.cpp src/corelib/kernel/qobject_p.h src/network/access/qhttpnetworkconnection.cpp
Diffstat (limited to 'tests/auto/qnetworkreply')
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 6c622f7..23a6025 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -237,6 +237,8 @@ private Q_SLOTS:
void httpProxyCommands_data();
void httpProxyCommands();
void proxyChange();
+ void authorizationError_data();
+ void authorizationError();
};
QT_BEGIN_NAMESPACE
@@ -3512,5 +3514,55 @@ void tst_QNetworkReply::proxyChange()
QVERIFY(int(reply3->error()) > 0);
}
+void tst_QNetworkReply::authorizationError_data()
+{
+
+ QTest::addColumn<QString>("url");
+ QTest::addColumn<int>("errorSignalCount");
+ QTest::addColumn<int>("finishedSignalCount");
+ QTest::addColumn<int>("error");
+ QTest::addColumn<int>("httpStatusCode");
+ QTest::addColumn<QString>("httpBody");
+
+ QTest::newRow("unknown-authorization-method") << "http://" + QtNetworkSettings::serverName() +
+ "/cgi-bin/http-unknown-authentication-method.cgi?401-authorization-required" << 1 << 1
+ << int(QNetworkReply::AuthenticationRequiredError) << 401 << "authorization required";
+ QTest::newRow("unknown-proxy-authorization-method") << "http://" + QtNetworkSettings::serverName() +
+ "/cgi-bin/http-unknown-authentication-method.cgi?407-proxy-authorization-required" << 1 << 1
+ << int(QNetworkReply::ProxyAuthenticationRequiredError) << 407
+ << "authorization required";
+}
+
+void tst_QNetworkReply::authorizationError()
+{
+ QFETCH(QString, url);
+ QNetworkRequest request(url);
+ QNetworkReplyPtr reply = manager.get(request);
+
+ QCOMPARE(reply->error(), QNetworkReply::NoError);
+
+ qRegisterMetaType<QNetworkReply::NetworkError>("QNetworkReply::NetworkError");
+ QSignalSpy errorSpy(reply, SIGNAL(error(QNetworkReply::NetworkError)));
+ QSignalSpy finishedSpy(reply, SIGNAL(finished()));
+ // now run the request:
+ connect(reply, SIGNAL(finished()),
+ &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QFETCH(int, errorSignalCount);
+ QCOMPARE(errorSpy.count(), errorSignalCount);
+ QFETCH(int, finishedSignalCount);
+ QCOMPARE(finishedSpy.count(), finishedSignalCount);
+ QFETCH(int, error);
+ QCOMPARE(reply->error(), QNetworkReply::NetworkError(error));
+
+ QFETCH(int, httpStatusCode);
+ QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), httpStatusCode);
+
+ QFETCH(QString, httpBody);
+ QCOMPARE(QString(reply->readAll()), httpBody);
+}
+
QTEST_MAIN(tst_QNetworkReply)
#include "tst_qnetworkreply.moc"