summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2011-05-25 14:46:01 +0100
committerShane Kearns <shane.kearns@accenture.com>2011-05-25 15:36:30 +0100
commita7cf6e27c9e31833991d61685d4dc5b8b5f777b7 (patch)
tree5a8d3f41a27d8eaf1cb1f7176f75f10b06f5666f
parente0bc5834ce26f91e60d8ca839f8a80ffd6f11c90 (diff)
Update bearer startup code in network autotests
The bearer startup code I added to some of the network autotests to ensure the network was up before testing caused test failures on some linux configurations due to there being no default network defined. I've changed it to follow these steps: 1. update the configuration list & wait for update completed signal - due to the polling engines not having any config defined on the first run before the initial poll happens 2. check default configuration is valid before attempting to start it 3a. for valid configuration, start it and wait for started as before 3b. for invalid configuration, fail if bearer is mandatory, otherwise ignore - on symbian bearer use is "mandatory", on desktop platforms it is optional Reviewed-by: Markus Goetz
-rw-r--r--tests/auto/networkselftest/tst_networkselftest.cpp15
-rw-r--r--tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp15
-rw-r--r--tests/auto/qftp/tst_qftp.cpp21
-rw-r--r--tests/auto/qhostinfo/tst_qhostinfo.cpp16
-rw-r--r--tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp15
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp15
-rw-r--r--tests/auto/qtcpserver/tst_qtcpserver.cpp19
-rw-r--r--tests/auto/qudpsocket/tst_qudpsocket.cpp15
8 files changed, 98 insertions, 33 deletions
diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp
index c21fd03f86..b2ce5cad96 100644
--- a/tests/auto/networkselftest/tst_networkselftest.cpp
+++ b/tests/auto/networkselftest/tst_networkselftest.cpp
@@ -371,11 +371,18 @@ void tst_NetworkSelfTest::initTestCase()
{
#ifndef QT_NO_BEARERMANAGEMENT
netConfMan = new QNetworkConfigurationManager(this);
+ netConfMan->updateConfigurations();
+ connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
networkConfiguration = netConfMan->defaultConfiguration();
- networkSession.reset(new QNetworkSession(networkConfiguration));
- if (!networkSession->isOpen()) {
- networkSession->open();
- QVERIFY(networkSession->waitForOpened(30000));
+ if (networkConfiguration.isValid()) {
+ networkSession.reset(new QNetworkSession(networkConfiguration));
+ if (!networkSession->isOpen()) {
+ networkSession->open();
+ QVERIFY(networkSession->waitForOpened(30000));
+ }
+ } else {
+ QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired));
}
#endif
}
diff --git a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
index e4372c58c6..aefe0b96c3 100644
--- a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
+++ b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp
@@ -141,11 +141,18 @@ void tst_QAbstractNetworkCache::initTestCase()
{
#ifndef QT_NO_BEARERMANAGEMENT
netConfMan = new QNetworkConfigurationManager(this);
+ netConfMan->updateConfigurations();
+ connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
networkConfiguration = netConfMan->defaultConfiguration();
- networkSession.reset(new QNetworkSession(networkConfiguration));
- if (!networkSession->isOpen()) {
- networkSession->open();
- QVERIFY(networkSession->waitForOpened(30000));
+ if (networkConfiguration.isValid()) {
+ networkSession.reset(new QNetworkSession(networkConfiguration));
+ if (!networkSession->isOpen()) {
+ networkSession->open();
+ QVERIFY(networkSession->waitForOpened(30000));
+ }
+ } else {
+ QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired));
}
#endif
}
diff --git a/tests/auto/qftp/tst_qftp.cpp b/tests/auto/qftp/tst_qftp.cpp
index 1fa0787b61..7e431cf109 100644
--- a/tests/auto/qftp/tst_qftp.cpp
+++ b/tests/auto/qftp/tst_qftp.cpp
@@ -155,6 +155,7 @@ private:
QFtp *ftp;
#ifndef QT_NO_BEARERMANAGEMENT
+ QNetworkConfigurationManager *netConfMan;
QSharedPointer<QNetworkSession> networkSessionExplicit;
QSharedPointer<QNetworkSession> networkSessionImplicit;
#endif
@@ -225,10 +226,20 @@ void tst_QFtp::initTestCase_data()
void tst_QFtp::initTestCase()
{
#ifndef QT_NO_BEARERMANAGEMENT
- QNetworkConfigurationManager manager;
- networkSessionImplicit = QSharedPointer<QNetworkSession>(new QNetworkSession(manager.defaultConfiguration()));
- networkSessionImplicit->open();
- QVERIFY(networkSessionImplicit->waitForOpened(60000)); //there may be user prompt on 1st connect
+ netConfMan = new QNetworkConfigurationManager(this);
+ netConfMan->updateConfigurations();
+ connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ QNetworkConfiguration networkConfiguration = netConfMan->defaultConfiguration();
+ if (networkConfiguration.isValid()) {
+ networkSessionImplicit = QSharedPointer<QNetworkSession>(new QNetworkSession(networkConfiguration));
+ if (!networkSessionImplicit->isOpen()) {
+ networkSessionImplicit->open();
+ QVERIFY(networkSessionImplicit->waitForOpened(30000));
+ }
+ } else {
+ QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired));
+ }
#endif
}
@@ -254,6 +265,8 @@ void tst_QFtp::init()
}
#ifndef QT_NO_BEARERMANAGEMENT
if (setSession) {
+ if (!networkSessionImplicit)
+ QSKIP("test requires a valid default network configuration", SkipSingle);
networkSessionExplicit = networkSessionImplicit;
if (!networkSessionExplicit->isOpen()) {
networkSessionExplicit->open();
diff --git a/tests/auto/qhostinfo/tst_qhostinfo.cpp b/tests/auto/qhostinfo/tst_qhostinfo.cpp
index 93c08cdc6b..2fa5e76890 100644
--- a/tests/auto/qhostinfo/tst_qhostinfo.cpp
+++ b/tests/auto/qhostinfo/tst_qhostinfo.cpp
@@ -197,13 +197,19 @@ tst_QHostInfo::~tst_QHostInfo()
void tst_QHostInfo::initTestCase()
{
#ifndef QT_NO_BEARERMANAGEMENT
- //start the default network
netConfMan = new QNetworkConfigurationManager(this);
+ netConfMan->updateConfigurations();
+ connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
networkConfiguration = netConfMan->defaultConfiguration();
- networkSession.reset(new QNetworkSession(networkConfiguration));
- if (!networkSession->isOpen()) {
- networkSession->open();
- QVERIFY(networkSession->waitForOpened(30000));
+ if (networkConfiguration.isValid()) {
+ networkSession.reset(new QNetworkSession(networkConfiguration));
+ if (!networkSession->isOpen()) {
+ networkSession->open();
+ QVERIFY(networkSession->waitForOpened(30000));
+ }
+ } else {
+ QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired));
}
#endif
diff --git a/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp
index ae3436d2f6..2077717e62 100644
--- a/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp
+++ b/tests/auto/qnetworkinterface/tst_qnetworkinterface.cpp
@@ -89,11 +89,18 @@ void tst_QNetworkInterface::initTestCase()
{
#ifndef QT_NO_BEARERMANAGEMENT
netConfMan = new QNetworkConfigurationManager(this);
+ netConfMan->updateConfigurations();
+ connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
networkConfiguration = netConfMan->defaultConfiguration();
- networkSession.reset(new QNetworkSession(networkConfiguration));
- if (!networkSession->isOpen()) {
- networkSession->open();
- QVERIFY(networkSession->waitForOpened(30000));
+ if (networkConfiguration.isValid()) {
+ networkSession.reset(new QNetworkSession(networkConfiguration));
+ if (!networkSession->isOpen()) {
+ networkSession->open();
+ QVERIFY(networkSession->waitForOpened(30000));
+ }
+ } else {
+ QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired));
}
#endif
}
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index c70075f8db..97ffeadbca 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -1283,11 +1283,18 @@ void tst_QNetworkReply::initTestCase()
#endif
#ifndef QT_NO_BEARERMANAGEMENT
netConfMan = new QNetworkConfigurationManager(this);
+ netConfMan->updateConfigurations();
+ connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
networkConfiguration = netConfMan->defaultConfiguration();
- networkSession.reset(new QNetworkSession(networkConfiguration));
- if (!networkSession->isOpen()) {
- networkSession->open();
- QVERIFY(networkSession->waitForOpened(30000));
+ if (networkConfiguration.isValid()) {
+ networkSession.reset(new QNetworkSession(networkConfiguration));
+ if (!networkSession->isOpen()) {
+ networkSession->open();
+ QVERIFY(networkSession->waitForOpened(30000));
+ }
+ } else {
+ QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired));
}
#endif
}
diff --git a/tests/auto/qtcpserver/tst_qtcpserver.cpp b/tests/auto/qtcpserver/tst_qtcpserver.cpp
index 3416a7cb23..a7c2604e00 100644
--- a/tests/auto/qtcpserver/tst_qtcpserver.cpp
+++ b/tests/auto/qtcpserver/tst_qtcpserver.cpp
@@ -116,6 +116,7 @@ private slots:
private:
#ifndef QT_NO_BEARERMANAGEMENT
QNetworkSession *networkSession;
+ QNetworkConfigurationManager *netConfMan;
#endif
};
@@ -154,10 +155,20 @@ void tst_QTcpServer::initTestCase_data()
void tst_QTcpServer::initTestCase()
{
#ifndef QT_NO_BEARERMANAGEMENT
- QNetworkConfigurationManager man;
- networkSession = new QNetworkSession(man.defaultConfiguration(), this);
- networkSession->open();
- QVERIFY(networkSession->waitForOpened());
+ netConfMan = new QNetworkConfigurationManager(this);
+ netConfMan->updateConfigurations();
+ connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ QNetworkConfiguration networkConfiguration = netConfMan->defaultConfiguration();
+ if (networkConfiguration.isValid()) {
+ networkSession = new QNetworkSession(networkConfiguration);
+ if (!networkSession->isOpen()) {
+ networkSession->open();
+ QVERIFY(networkSession->waitForOpened(30000));
+ }
+ } else {
+ QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired));
+ }
#endif
}
diff --git a/tests/auto/qudpsocket/tst_qudpsocket.cpp b/tests/auto/qudpsocket/tst_qudpsocket.cpp
index 9ca049bccf..a38082e7a5 100644
--- a/tests/auto/qudpsocket/tst_qudpsocket.cpp
+++ b/tests/auto/qudpsocket/tst_qudpsocket.cpp
@@ -148,11 +148,18 @@ void tst_QUdpSocket::initTestCase_data()
#ifndef QT_NO_BEARERMANAGEMENT
netConfMan = new QNetworkConfigurationManager(this);
+ netConfMan->updateConfigurations();
+ connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
networkConfiguration = netConfMan->defaultConfiguration();
- networkSession = QSharedPointer<QNetworkSession>(new QNetworkSession(networkConfiguration));
- if (!networkSession->isOpen()) {
- networkSession->open();
- QVERIFY(networkSession->waitForOpened(30000));
+ if (networkConfiguration.isValid()) {
+ networkSession = QSharedPointer<QNetworkSession>(new QNetworkSession(networkConfiguration));
+ if (!networkSession->isOpen()) {
+ networkSession->open();
+ QVERIFY(networkSession->waitForOpened(30000));
+ }
+ } else {
+ QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired));
}
#endif
}