summaryrefslogtreecommitdiffstats
path: root/tests/auto/qhttpnetworkconnection
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-10-29 16:06:48 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-10-29 16:06:48 (GMT)
commit7db218d6860a04df238735ff692010f0910d0c92 (patch)
treead8033623855b3afb17752552ca56b096c1b9159 /tests/auto/qhttpnetworkconnection
parent8943b44c38ee6244c4a5b190c2b35879b1921843 (diff)
parentc02ef9eb331f03dbd59d2fd938c53b54f5c65cea (diff)
downloadQt-7db218d6860a04df238735ff692010f0910d0c92.zip
Qt-7db218d6860a04df238735ff692010f0910d0c92.tar.gz
Qt-7db218d6860a04df238735ff692010f0910d0c92.tar.bz2
Merge branch 4.7 into qt-master-from-4.7
Diffstat (limited to 'tests/auto/qhttpnetworkconnection')
-rw-r--r--tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp54
1 files changed, 19 insertions, 35 deletions
diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
index 188ed29..a9b501c 100644
--- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
+++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp
@@ -57,7 +57,7 @@ public:
public Q_SLOTS:
void finishedReply();
void finishedWithError(QNetworkReply::NetworkError errorCode, const QString &detail);
- void challenge401(const QHttpNetworkRequest &request, QAuthenticator *authenticator, const QHttpNetworkConnection *connection);
+ void challenge401(const QHttpNetworkRequest &request, QAuthenticator *authenticator);
#ifndef QT_NO_OPENSSL
void sslErrors(const QList<QSslError> &errors);
#endif
@@ -177,11 +177,9 @@ void tst_QHttpNetworkConnection::head()
QFETCH(QString, statusString);
QFETCH(int, contentLength);
- QHttpNetworkConnection connection(host);
+ QHttpNetworkConnection connection(host, port, encrypt);
QCOMPARE(connection.port(), port);
QCOMPARE(connection.hostName(), host);
- if (encrypt)
- connection.enableEncryption();
QCOMPARE(connection.isEncrypted(), encrypt);
QHttpNetworkRequest request(protocol + host + path, QHttpNetworkRequest::Head);
@@ -237,11 +235,9 @@ void tst_QHttpNetworkConnection::get()
QFETCH(int, contentLength);
QFETCH(int, downloadSize);
- QHttpNetworkConnection connection(host);
+ QHttpNetworkConnection connection(host, port, encrypt);
QCOMPARE(connection.port(), port);
QCOMPARE(connection.hostName(), host);
- if (encrypt)
- connection.enableEncryption();
QCOMPARE(connection.isEncrypted(), encrypt);
QHttpNetworkRequest request(protocol + host + path);
@@ -317,11 +313,9 @@ void tst_QHttpNetworkConnection::put()
QFETCH(QString, data);
QFETCH(bool, succeed);
- QHttpNetworkConnection connection(host);
+ QHttpNetworkConnection connection(host, port, encrypt);
QCOMPARE(connection.port(), port);
QCOMPARE(connection.hostName(), host);
- if (encrypt)
- connection.enableEncryption();
QCOMPARE(connection.isEncrypted(), encrypt);
QHttpNetworkRequest request(protocol + host + path, QHttpNetworkRequest::Put);
@@ -338,8 +332,6 @@ void tst_QHttpNetworkConnection::put()
connect(reply, SIGNAL(finished()), SLOT(finishedReply()));
connect(reply, SIGNAL(finishedWithError(QNetworkReply::NetworkError, const QString &)),
SLOT(finishedWithError(QNetworkReply::NetworkError, const QString &)));
- connect(&connection, SIGNAL(error(QNetworkReply::NetworkError, const QString &)),
- SLOT(finishedWithError(QNetworkReply::NetworkError, const QString &)));
QTime stopWatch;
stopWatch.start();
@@ -409,11 +401,9 @@ void tst_QHttpNetworkConnection::post()
QFETCH(int, contentLength);
QFETCH(int, downloadSize);
- QHttpNetworkConnection connection(host);
+ QHttpNetworkConnection connection(host, port, encrypt);
QCOMPARE(connection.port(), port);
QCOMPARE(connection.hostName(), host);
- if (encrypt)
- connection.enableEncryption();
QCOMPARE(connection.isEncrypted(), encrypt);
QHttpNetworkRequest request(protocol + host + path, QHttpNetworkRequest::Post);
@@ -498,14 +488,14 @@ void tst_QHttpNetworkConnection::_connect()
}
void tst_QHttpNetworkConnection::challenge401(const QHttpNetworkRequest &request,
- QAuthenticator *authenticator,
- const QHttpNetworkConnection *connection)
+ QAuthenticator *authenticator)
{
Q_UNUSED(request)
- Q_UNUSED(connection)
- QHttpNetworkConnection *c = qobject_cast<QHttpNetworkConnection*>(sender());
- if (connection) {
+ QHttpNetworkReply *reply = qobject_cast<QHttpNetworkReply*>(sender());
+ if (reply) {
+ QHttpNetworkConnection *c = reply->connection();
+
QVariant val = c->property("setCredentials");
if (val.toBool()) {
QVariant user = c->property("username");
@@ -551,17 +541,15 @@ void tst_QHttpNetworkConnection::get401()
QHttpNetworkConnection connection(host, port, encrypt);
QCOMPARE(connection.port(), port);
QCOMPARE(connection.hostName(), host);
- if (encrypt)
- connection.enableEncryption();
QCOMPARE(connection.isEncrypted(), encrypt);
- connect(&connection, SIGNAL(authenticationRequired(const QHttpNetworkRequest&, QAuthenticator *, const QHttpNetworkConnection*)),
- SLOT(challenge401(const QHttpNetworkRequest&, QAuthenticator *, const QHttpNetworkConnection*)));
connection.setProperty("setCredentials", setCredentials);
connection.setProperty("username", username);
connection.setProperty("password", password);
QHttpNetworkRequest request(protocol + host + path);
QHttpNetworkReply *reply = connection.sendRequest(request);
+ connect(reply, SIGNAL(authenticationRequired(const QHttpNetworkRequest&, QAuthenticator *)),
+ SLOT(challenge401(const QHttpNetworkRequest&, QAuthenticator *)));
finishedCalled = false;
finishedWithErrorCalled = false;
@@ -620,11 +608,9 @@ void tst_QHttpNetworkConnection::compression()
QFETCH(bool, autoCompress);
QFETCH(QString, contentCoding);
- QHttpNetworkConnection connection(host);
+ QHttpNetworkConnection connection(host, port, encrypt);
QCOMPARE(connection.port(), port);
QCOMPARE(connection.hostName(), host);
- if (encrypt)
- connection.enableEncryption();
QCOMPARE(connection.isEncrypted(), encrypt);
QHttpNetworkRequest request(protocol + host + path);
@@ -670,8 +656,10 @@ void tst_QHttpNetworkConnection::sslErrors(const QList<QSslError> &errors)
{
Q_UNUSED(errors)
- QHttpNetworkConnection *connection = qobject_cast<QHttpNetworkConnection*>(sender());
- if (connection) {
+ QHttpNetworkReply *reply = qobject_cast<QHttpNetworkReply*>(sender());
+ if (reply) {
+ QHttpNetworkConnection *connection = reply->connection();
+
QVariant val = connection->property("ignoreFromSignal");
if (val.toBool())
connection->ignoreSslErrors();
@@ -713,17 +701,15 @@ void tst_QHttpNetworkConnection::ignoresslerror()
QHttpNetworkConnection connection(host, port, encrypt);
QCOMPARE(connection.port(), port);
QCOMPARE(connection.hostName(), host);
- if (encrypt)
- connection.enableEncryption();
if (ignoreInit)
connection.ignoreSslErrors();
QCOMPARE(connection.isEncrypted(), encrypt);
- connect(&connection, SIGNAL(sslErrors(const QList<QSslError>&)),
- SLOT(sslErrors(const QList<QSslError>&)));
connection.setProperty("ignoreFromSignal", ignoreFromSignal);
QHttpNetworkRequest request(protocol + host + path);
QHttpNetworkReply *reply = connection.sendRequest(request);
+ connect(reply, SIGNAL(sslErrors(const QList<QSslError>&)),
+ SLOT(sslErrors(const QList<QSslError>&)));
finishedWithErrorCalled = false;
@@ -771,8 +757,6 @@ void tst_QHttpNetworkConnection::nossl()
QHttpNetworkConnection connection(host, port, encrypt);
QCOMPARE(connection.port(), port);
QCOMPARE(connection.hostName(), host);
- if (encrypt)
- connection.enableEncryption();
QHttpNetworkRequest request(protocol + host + path);
QHttpNetworkReply *reply = connection.sendRequest(request);