summaryrefslogtreecommitdiffstats
path: root/tests/auto/qnetworkproxy
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-05-06 12:30:21 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-05-07 08:58:44 (GMT)
commit03b29811a3a6eb34421c476d829075505aa42ada (patch)
tree211628a14c39cc91405bc02ea7c5f57857ba3288 /tests/auto/qnetworkproxy
parent2fddd3c9b7e45b58b56fec9b89c78af0a8f75731 (diff)
downloadQt-03b29811a3a6eb34421c476d829075505aa42ada.zip
Qt-03b29811a3a6eb34421c476d829075505aa42ada.tar.gz
Qt-03b29811a3a6eb34421c476d829075505aa42ada.tar.bz2
Make QNetworkProxy calculate the capabilities for a new proxy type
If you write: QNetworkProxy proxy; proxy.setType(QNetworkProxy::HttpProxy); Then now QNetworkProxy will set the capabilities to the default value for the new proxy type. Previously, it wouldn't do that: default values were set only for the type passed in the constructor. Reviewed-by: Peter Hartmann
Diffstat (limited to 'tests/auto/qnetworkproxy')
-rw-r--r--tests/auto/qnetworkproxy/tst_qnetworkproxy.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qnetworkproxy/tst_qnetworkproxy.cpp b/tests/auto/qnetworkproxy/tst_qnetworkproxy.cpp
index 31a5391..0760ce8 100644
--- a/tests/auto/qnetworkproxy/tst_qnetworkproxy.cpp
+++ b/tests/auto/qnetworkproxy/tst_qnetworkproxy.cpp
@@ -59,6 +59,7 @@ public:
private slots:
void getSetCheck();
+ void capabilitiesPerType();
};
tst_QNetworkProxy::tst_QNetworkProxy()
@@ -79,6 +80,38 @@ void tst_QNetworkProxy::getSetCheck()
QCOMPARE(quint16(0), obj1.port());
obj1.setPort(quint16(0xffff));
QCOMPARE(quint16(0xffff), obj1.port());
+
+ obj1.setType(QNetworkProxy::DefaultProxy);
+ QCOMPARE(obj1.type(), QNetworkProxy::DefaultProxy);
+ obj1.setType(QNetworkProxy::HttpProxy);
+ QCOMPARE(obj1.type(), QNetworkProxy::HttpProxy);
+ obj1.setType(QNetworkProxy::Socks5Proxy);
+ QCOMPARE(obj1.type(), QNetworkProxy::Socks5Proxy);
+}
+
+void tst_QNetworkProxy::capabilitiesPerType()
+{
+ QNetworkProxy proxy(QNetworkProxy::Socks5Proxy);
+ QVERIFY(proxy.capabilities() & QNetworkProxy::TunnelingCapability);
+ QVERIFY(proxy.capabilities() & QNetworkProxy::HostNameLookupCapability);
+ QVERIFY(proxy.capabilities() & QNetworkProxy::UdpTunnelingCapability);
+
+ proxy.setType(QNetworkProxy::NoProxy);
+ // verify that the capabilities changed
+ QVERIFY(!(proxy.capabilities() & QNetworkProxy::HostNameLookupCapability));
+ QVERIFY(proxy.capabilities() & QNetworkProxy::UdpTunnelingCapability);
+
+ proxy.setType(QNetworkProxy::HttpProxy);
+ QVERIFY(proxy.capabilities() & QNetworkProxy::HostNameLookupCapability);
+ QVERIFY(!(proxy.capabilities() & QNetworkProxy::UdpTunnelingCapability));
+
+ // now set the capabilities on stone:
+ proxy.setCapabilities(QNetworkProxy::TunnelingCapability | QNetworkProxy::UdpTunnelingCapability);
+ QCOMPARE(proxy.capabilities(), QNetworkProxy::TunnelingCapability | QNetworkProxy::UdpTunnelingCapability);
+
+ // changing the type shouldn't change the capabilities any more
+ proxy.setType(QNetworkProxy::Socks5Proxy);
+ QCOMPARE(proxy.capabilities(), QNetworkProxy::TunnelingCapability | QNetworkProxy::UdpTunnelingCapability);
}
QTEST_MAIN(tst_QNetworkProxy)