diff options
Diffstat (limited to 'tests/auto/network')
-rw-r--r-- | tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp | 41 | ||||
-rw-r--r-- | tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 3 |
2 files changed, 43 insertions, 1 deletions
diff --git a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp index d57a99a758..e06285dc67 100644 --- a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp +++ b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp @@ -87,6 +87,8 @@ private slots: void inNetworkAccessManager_data(); void inNetworkAccessManager(); #endif + void genericSystemProxy(); + void genericSystemProxy_data(); private: QString formatProxyName(const QNetworkProxy & proxy) const; @@ -367,6 +369,45 @@ void tst_QNetworkProxyFactory::inNetworkAccessManager() #endif //QT_NO_BEARERMANAGEMENT +Q_DECLARE_METATYPE(QNetworkProxy::ProxyType) + +void tst_QNetworkProxyFactory::genericSystemProxy() +{ + QFETCH(QByteArray, envVar); + QFETCH(QByteArray, url); + QFETCH(QNetworkProxy::ProxyType, proxyType); + QFETCH(QString, hostName); + QFETCH(int, port); + +// The generic system proxy is only available on the following platforms +#if (!defined Q_OS_BLACKBERRY) && (!defined Q_OS_WIN) && ((!defined Q_OS_MAC) || defined Q_OS_IOS) + qputenv(envVar, url); + const QList<QNetworkProxy> systemProxy = QNetworkProxyFactory::systemProxyForQuery(); + QCOMPARE(systemProxy.size(), 1); + QCOMPARE(systemProxy.first().type(), proxyType); + QCOMPARE(systemProxy.first().hostName(), hostName); + QCOMPARE(systemProxy.first().port(), static_cast<quint16>(port)); + qunsetenv(envVar); +#else + QSKIP("Generic system proxy not available on this platform."); +#endif +} + +void tst_QNetworkProxyFactory::genericSystemProxy_data() +{ + QTest::addColumn<QByteArray>("envVar"); + QTest::addColumn<QByteArray>("url"); + QTest::addColumn<QNetworkProxy::ProxyType>("proxyType"); + QTest::addColumn<QString>("hostName"); + QTest::addColumn<int>("port"); + + QTest::newRow("no proxy") << QByteArray("http_proxy") << QByteArray() << QNetworkProxy::NoProxy + << QString() << 0; + QTest::newRow("socks5") << QByteArray("http_proxy") << QByteArray("socks5://127.0.0.1:4242") + << QNetworkProxy::Socks5Proxy << QString("127.0.0.1") << 4242; + QTest::newRow("http") << QByteArray("http_proxy") << QByteArray("http://example.com:666") + << QNetworkProxy::HttpProxy << QString("example.com") << 666; +} class QSPFQThread : public QThread { diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index feb6978690..f3adb2b52f 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -2135,7 +2135,8 @@ void tst_QSslSocket::writeBigChunk() QFAIL("Error while writing! Check if the OpenSSL BIO size is limited?!"); } // also check the error string. If another error (than UnknownError) occurred, it should be different than before - QVERIFY(errorBefore == errorAfter); + QVERIFY2(errorBefore == errorAfter || socket->error() == QAbstractSocket::RemoteHostClosedError, + QByteArray("unexpected error: ").append(qPrintable(errorAfter))); // check that everything has been written to OpenSSL QVERIFY(socket->bytesToWrite() == 0); |