summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/network/kernel')
-rw-r--r--tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp25
-rw-r--r--tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp9
-rw-r--r--tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp114
3 files changed, 28 insertions, 120 deletions
diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
index 2671c253cb..cb7e66bad4 100644
--- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
+++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp
@@ -86,6 +86,8 @@ class tst_QHostInfo : public QObject
private slots:
void init();
void initTestCase();
+ void swapFunction();
+ void moveOperator();
void getSetCheck();
void staticInformation();
void lookupIPv4_data();
@@ -129,6 +131,29 @@ private:
#endif
};
+void tst_QHostInfo::swapFunction()
+{
+ QHostInfo obj1, obj2;
+ obj1.setError(QHostInfo::HostInfoError(0));
+ obj2.setError(QHostInfo::HostInfoError(1));
+ obj1.swap(obj2);
+ QCOMPARE(QHostInfo::HostInfoError(0), obj2.error());
+ QCOMPARE(QHostInfo::HostInfoError(1), obj1.error());
+}
+
+void tst_QHostInfo::moveOperator()
+{
+ QHostInfo obj1, obj2, obj3(1);
+ obj1.setError(QHostInfo::HostInfoError(0));
+ obj2.setError(QHostInfo::HostInfoError(1));
+ obj1 = std::move(obj2);
+ obj2 = obj3;
+ QCOMPARE(QHostInfo::HostInfoError(1), obj1.error());
+ QCOMPARE(obj3.lookupId(), obj2.lookupId());
+}
+
+
+
// Testing get/set functions
void tst_QHostInfo::getSetCheck()
{
diff --git a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
index 5695f90c53..e9034deff7 100644
--- a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
+++ b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
@@ -32,7 +32,7 @@
#include <qcoreapplication.h>
#include <qnetworkinterface.h>
-#include <qtcpsocket.h>
+#include <qudpsocket.h>
#ifndef QT_NO_BEARERMANAGEMENT
#include <QNetworkConfigurationManager>
#include <QNetworkSession>
@@ -189,17 +189,12 @@ void tst_QNetworkInterface::loopbackIPv6()
void tst_QNetworkInterface::localAddress()
{
- QTcpSocket socket;
+ QUdpSocket socket;
socket.connectToHost(QtNetworkSettings::serverName(), 80);
QVERIFY(socket.waitForConnected(5000));
QHostAddress local = socket.localAddress();
- // make Apache happy on fluke
- socket.write("GET / HTTP/1.0\r\n\r\n");
- socket.waitForBytesWritten(1000);
- socket.close();
-
// test that we can find the address that QTcpSocket reported
QList<QHostAddress> all = QNetworkInterface::allAddresses();
QVERIFY(all.contains(local));
diff --git a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
index 01566d795d..f3a1ac84ff 100644
--- a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
+++ b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp
@@ -34,10 +34,8 @@
#include <qdebug.h>
#include <qnetworkproxy.h>
-#include <QNetworkConfiguration>
-#include <QNetworkConfigurationManager>
-#include <QNetworkSession>
#include <QNetworkAccessManager>
+#include <QNetworkInterface>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QList>
@@ -71,11 +69,6 @@ private slots:
void systemProxyForQuery_data();
void systemProxyForQuery() const;
void systemProxyForQuery_local();
-#ifndef QT_NO_BEARERMANAGEMENT
- void fromConfigurations();
- void inNetworkAccessManager_data();
- void inNetworkAccessManager();
-#endif
void genericSystemProxy();
void genericSystemProxy_data();
@@ -253,111 +246,6 @@ void tst_QNetworkProxyFactory::systemProxyForQuery_local()
QVERIFY(list.isEmpty() || (list[0].type() == QNetworkProxy::NoProxy));
}
-#ifndef QT_NO_BEARERMANAGEMENT
-
-//Purpose of this test is just to check systemProxyForQuery doesn't hang or crash
-//with any given configuration including no configuration.
-//We can't test it returns the right proxies without implementing the native proxy code
-//again here, which would be testing our implementation against itself.
-//Therefore it's just testing that something valid is returned (at least a NoProxy entry)
-void tst_QNetworkProxyFactory::fromConfigurations()
-{
- QNetworkConfigurationManager manager;
- QList<QNetworkProxy> proxies;
- QUrl url(QLatin1String("http://qt-project.org"));
- //get from known configurations
- foreach (QNetworkConfiguration config, manager.allConfigurations()) {
- QNetworkProxyQuery query(config, url, QNetworkProxyQuery::UrlRequest);
- proxies = QNetworkProxyFactory::systemProxyForQuery(query);
- QVERIFY(!proxies.isEmpty());
- foreach (QNetworkProxy proxy, proxies) {
- qDebug() << config.name() << " - " << config.identifier() << " - " << formatProxyName(proxy);
- }
- }
-
- //get from default configuration
- QNetworkProxyQuery defaultquery(url, QNetworkProxyQuery::UrlRequest);
- proxies = QNetworkProxyFactory::systemProxyForQuery(defaultquery);
- QVERIFY(!proxies.isEmpty());
- foreach (QNetworkProxy proxy, proxies) {
- qDebug() << "default - " << formatProxyName(proxy);
- }
-
- //get from active configuration
- QNetworkSession session(manager.defaultConfiguration());
- session.open();
- QVERIFY(session.waitForOpened(30000));
- proxies = QNetworkProxyFactory::systemProxyForQuery(defaultquery);
- QVERIFY(!proxies.isEmpty());
- foreach (QNetworkProxy proxy, proxies) {
- qDebug() << "active - " << formatProxyName(proxy);
- }
-
- //get from known configurations while there is one active
- foreach (QNetworkConfiguration config, manager.allConfigurations()) {
- QNetworkProxyQuery query(config, url, QNetworkProxyQuery::UrlRequest);
- proxies = QNetworkProxyFactory::systemProxyForQuery(query);
- QVERIFY(!proxies.isEmpty());
- foreach (QNetworkProxy proxy, proxies) {
- qDebug() << config.name() << " - " << config.identifier() << " - " << formatProxyName(proxy);
- }
- }
-}
-
-void tst_QNetworkProxyFactory::inNetworkAccessManager_data()
-{
- QTest::addColumn<QNetworkConfiguration>("config");
- QTest::addColumn<QList<QNetworkProxy> >("proxies");
- QNetworkConfigurationManager manager;
- //get from known configurations
- foreach (QNetworkConfiguration config, manager.allConfigurations()) {
- QNetworkProxyQuery query(config, QUrl(QString("http://qt-project.org")), QNetworkProxyQuery::UrlRequest);
- QList<QNetworkProxy> proxies = QNetworkProxyFactory::systemProxyForQuery(query);
- QTest::newRow(config.name().toUtf8()) << config << proxies;
- }
-}
-
-//Purpose of this test is to check that QNetworkAccessManager uses the proxy from the configuration it
-//has been given. Needs two or more working configurations to be a good test.
-void tst_QNetworkProxyFactory::inNetworkAccessManager()
-{
- QFETCH(QNetworkConfiguration, config);
- QFETCH(QList<QNetworkProxy>, proxies);
-
- int count = QDebugProxyFactory::requestCounter;
-
- QNetworkAccessManager manager;
- manager.setConfiguration(config);
-
- //using an internet server, because cellular APs won't have a route to the test server.
- QNetworkRequest req(QUrl(QString("http://qt-project.org")));
- QNetworkReply *reply = manager.get(req);
- connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
- QTestEventLoop::instance().enterLoop(30);
- delete reply;
-
- if (count == QDebugProxyFactory::requestCounter) {
- //RND phones are preconfigured with several test access points which won't work without a matching SIM
- //If the network fails to start, QNAM won't ask the factory for proxies so we can't test.
- QSKIP("network configuration didn't start");
- }
- QVERIFY(factory);
-
- qDebug() << "testing network configuration for" << config.name();
- foreach (QNetworkProxy proxy, factory->returnedList) {
- qDebug() << formatProxyName(proxy);
- }
- qDebug() << " <vs> ";
- foreach (QNetworkProxy proxy, proxies) {
- qDebug() << formatProxyName(proxy);
- }
- if (config.type() != QNetworkConfiguration::InternetAccessPoint)
- QEXPECT_FAIL("","QNetworkProxyFactory::systemProxyForQuery doesn't work for service networks yet", Continue);
- QCOMPARE(factory->returnedList, proxies);
-}
-
-#endif //QT_NO_BEARERMANAGEMENT
-
Q_DECLARE_METATYPE(QNetworkProxy::ProxyType)
void tst_QNetworkProxyFactory::genericSystemProxy()