diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-04-30 09:33:19 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-30 09:33:19 +0200 |
commit | c917579a15d60a7b70c5fc5f00f6451da7c4e608 (patch) | |
tree | 1c89cd1f66ff5147e494a6493e81239e4a644911 /tests/auto/network/kernel | |
parent | ac06bfdc76414c8d8c727ff5278b1baafe610860 (diff) | |
parent | 85e3c53e5c5e2de993c90ece324a68d0ff62f417 (diff) |
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'tests/auto/network/kernel')
-rw-r--r-- | tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp | 41 |
1 files changed, 41 insertions, 0 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 { |