summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-02-03 04:52:45 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-02-03 04:52:45 (GMT)
commit29f24e41b91c05d551c7ac16625a2961744c8339 (patch)
treed31187fd2ad5c952c5e4deb9470a8265bab508ca
parent1e06b5e995c6df715da8db53c8375d458277144d (diff)
downloadQt-29f24e41b91c05d551c7ac16625a2961744c8339.zip
Qt-29f24e41b91c05d551c7ac16625a2961744c8339.tar.gz
Qt-29f24e41b91c05d551c7ac16625a2961744c8339.tar.bz2
Bearer Management Integration 5.
-rw-r--r--src/network/bearer/qnetworksession.cpp3
-rw-r--r--tests/auto/qnetworksession/lackey/lackey.pro5
-rw-r--r--tests/auto/qnetworksession/lackey/main.cpp19
-rw-r--r--tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp46
-rw-r--r--tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro2
5 files changed, 55 insertions, 20 deletions
diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp
index 28afcfe..0ea773a 100644
--- a/src/network/bearer/qnetworksession.cpp
+++ b/src/network/bearer/qnetworksession.cpp
@@ -408,6 +408,9 @@ QNetworkConfiguration QNetworkSession::configuration() const
This function only returns a valid QNetworkInterface when this session is \l Connected.
The returned interface may change as a result of a roaming process.
+
+ Note: this function does not work in Symbian emulator due to the way the
+ connectivity is emulated on Windows.
\sa state()
*/
diff --git a/tests/auto/qnetworksession/lackey/lackey.pro b/tests/auto/qnetworksession/lackey/lackey.pro
index b8a006b..96edf99f 100644
--- a/tests/auto/qnetworksession/lackey/lackey.pro
+++ b/tests/auto/qnetworksession/lackey/lackey.pro
@@ -9,5 +9,10 @@ CONFIG+= testcase
include(../../../../common.pri)
+symbian {
+ # Needed for interprocess communication and opening QNetworkSession
+ TARGET.CAPABILITY = NetworkControl NetworkServices
+}
+
CONFIG += mobility
MOBILITY = bearer
diff --git a/tests/auto/qnetworksession/lackey/main.cpp b/tests/auto/qnetworksession/lackey/main.cpp
index f3a7a07..cc155f2 100644
--- a/tests/auto/qnetworksession/lackey/main.cpp
+++ b/tests/auto/qnetworksession/lackey/main.cpp
@@ -54,16 +54,23 @@ QTM_USE_NAMESPACE
#define NO_DISCOVERED_CONFIGURATIONS_ERROR 1
#define SESSION_OPEN_ERROR 2
+
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
QNetworkConfigurationManager manager;
QList<QNetworkConfiguration> discovered =
+#if defined (Q_OS_SYMBIAN)
+ // On Symbian, on the first query (before updateConfigurations() call
+ // the discovered-states are not correct, so defined-state will do.
+ manager.allConfigurations(QNetworkConfiguration::Defined);
+#else
manager.allConfigurations(QNetworkConfiguration::Discovered);
-
- if (discovered.isEmpty())
+#endif
+ if (discovered.isEmpty()) {
return NO_DISCOVERED_CONFIGURATIONS_ERROR;
+ }
// Cannot read/write to processes on WinCE or Symbian.
// Easiest alternative is to use sockets for IPC.
@@ -85,15 +92,16 @@ int main(int argc, char** argv)
qDebug() << "Discovered configurations:" << discovered.count();
if (discovered.isEmpty()) {
- qDebug() << "No more configurations";
+ qDebug() << "No more discovered configurations";
break;
}
qDebug() << "Taking first configuration";
QNetworkConfiguration config = discovered.takeFirst();
+
if ((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- qDebug() << config.name() << "is active";
+ qDebug() << config.name() << " is active, therefore skipping it (looking for configs in 'discovered' state).";
continue;
}
@@ -104,12 +112,11 @@ int main(int argc, char** argv)
QString output = QString("Starting session for %1\n").arg(config.identifier());
oopSocket.write(output.toAscii());
oopSocket.waitForBytesWritten();
-
session->open();
session->waitForOpened();
} while (!(session && session->isOpen()));
- qDebug() << "loop done";
+ qDebug() << "lackey: loop done";
if (!session) {
qDebug() << "Could not start session";
diff --git a/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp b/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp
index 86b3e46..adb8edd 100644
--- a/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp
+++ b/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp
@@ -66,6 +66,8 @@ public slots:
void cleanupTestCase();
private slots:
+
+ void outOfProcessSession();
void invalidSession();
void sessionProperties_data();
@@ -77,8 +79,6 @@ private slots:
void sessionOpenCloseStop_data();
void sessionOpenCloseStop();
- void outOfProcessSession();
-
private:
QNetworkConfigurationManager manager;
@@ -264,7 +264,10 @@ void tst_QNetworkSession::sessionProperties()
// QNetworkSession::interface() should return an invalid interface unless
// session is in the connected state.
+#if !(defined(Q_OS_SYMBIAN) && defined(__WINS__))
+ // On Symbian emulator, the support for data bearers is limited
QCOMPARE(session.state() == QNetworkSession::Connected, session.interface().isValid());
+#endif
if (!configuration.isValid()) {
QVERIFY(configuration.state() == QNetworkConfiguration::Undefined &&
@@ -311,13 +314,14 @@ void tst_QNetworkSession::userChoiceSession()
QNetworkSession session(configuration);
+ // Check that configuration was really set
QVERIFY(session.configuration() == configuration);
QVERIFY(!session.isOpen());
+ // Check that session is not active
QVERIFY(session.sessionProperty("ActiveConfiguration").toString().isEmpty());
-
// The remaining tests require the session to be not NotAvailable.
if (session.state() == QNetworkSession::NotAvailable)
QSKIP("Network is not available.", SkipSingle);
@@ -367,7 +371,10 @@ void tst_QNetworkSession::userChoiceSession()
QTRY_VERIFY(!stateChangedSpy.isEmpty());
QVERIFY(session.state() == QNetworkSession::Connected);
+#if !(defined(Q_OS_SYMBIAN) && defined(__WINS__))
+ // On Symbian emulator, the support for data bearers is limited
QVERIFY(session.interface().isValid());
+#endif
const QString userChoiceIdentifier =
session.sessionProperty("UserChoiceConfiguration").toString();
@@ -507,7 +514,10 @@ void tst_QNetworkSession::sessionOpenCloseStop()
}
QVERIFY(session.state() == QNetworkSession::Connected);
+#if !(defined(Q_OS_SYMBIAN) && defined(__WINS__))
+ // On Symbian emulator, the support for data bearers is limited
QVERIFY(session.interface().isValid());
+#endif
} else {
QFAIL("Timeout waiting for session to open.");
}
@@ -540,7 +550,10 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QVERIFY(session2.isOpen());
QVERIFY(session.state() == QNetworkSession::Connected);
QVERIFY(session2.state() == QNetworkSession::Connected);
+#if !(defined(Q_OS_SYMBIAN) && defined(__WINS__))
+ // On Symbian emulator, the support for data bearers is limited
QVERIFY(session.interface().isValid());
+#endif
QCOMPARE(session.interface().hardwareAddress(), session2.interface().hardwareAddress());
QCOMPARE(session.interface().index(), session2.interface().index());
}
@@ -713,7 +726,10 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QVERIFY(!session2.isOpen());
QVERIFY(session.state() == QNetworkSession::Connected);
QVERIFY(session2.state() == QNetworkSession::Connected);
+#if !(defined(Q_OS_SYMBIAN) && defined(__WINS__))
+ // On Symbian emulator, the support for data bearers is limited
QVERIFY(session.interface().isValid());
+#endif
QCOMPARE(session.interface().hardwareAddress(), session2.interface().hardwareAddress());
QCOMPARE(session.interface().index(), session2.interface().index());
}
@@ -786,17 +802,23 @@ QDebug operator<<(QDebug debug, const QList<QNetworkConfiguration> &list)
return debug;
}
+// Note: outOfProcessSession requires that at least one configuration is
+// at Discovered -state (Defined is ok for symbian as well, as long as it is possible to open).
void tst_QNetworkSession::outOfProcessSession()
{
+#if defined(Q_OS_SYMBIAN) && defined(__WINS__)
+ QSKIP("Symbian emulator does not support two [QR]PRocesses linking a dll (QtBearer.dll) with global writeable static data.", SkipAll);
+#endif
QNetworkConfigurationManager manager;
-
+ // Create a QNetworkConfigurationManager to detect configuration changes made in Lackey. This
+ // is actually the essence of this testcase - to check that platform mediates/reflects changes
+ // regardless of process boundaries. The interprocess communication is more like a way to get
+ // this test-case act correctly and timely.
QList<QNetworkConfiguration> before = manager.allConfigurations(QNetworkConfiguration::Active);
+ QSignalSpy spy(&manager, SIGNAL(configurationChanged(QNetworkConfiguration)));
- QSignalSpy spy(&manager, SIGNAL(configurationChanged(QNetworkConfiguration)));
-
// Cannot read/write to processes on WinCE or Symbian.
// Easiest alternative is to use sockets for IPC.
-
QLocalServer oopServer;
// First remove possible earlier listening address which would cause listen to fail
// (e.g. previously abruptly ended unit test might cause this)
@@ -813,19 +835,17 @@ void tst_QNetworkSession::outOfProcessSession()
do {
QByteArray output;
- if(oopSocket->waitForReadyRead())
+ if(oopSocket->waitForReadyRead()) {
output = oopSocket->readLine().trimmed();
+ }
if (output.startsWith("Started session ")) {
- QString identifier = QString::fromLocal8Bit(output.mid(16).constData());
-
+ QString identifier = QString::fromLocal8Bit(output.mid(20).constData());
QNetworkConfiguration changed;
do {
QTRY_VERIFY(!spy.isEmpty());
-
changed = qvariant_cast<QNetworkConfiguration>(spy.takeFirst().at(0));
-
} while (changed.identifier() != identifier);
QVERIFY((changed.state() & QNetworkConfiguration::Active) ==
@@ -870,10 +890,10 @@ void tst_QNetworkSession::outOfProcessSession()
switch (lackey.exitCode()) {
case 0:
+ qDebug("Lackey returned exit success (0)");
break;
case 1:
QSKIP("No discovered configurations found.", SkipAll);
- break;
case 2:
QSKIP("Lackey could not start session.", SkipAll);
default:
diff --git a/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro b/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro
index 18b5c23..f04a8fb 100644
--- a/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro
+++ b/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro
@@ -18,7 +18,7 @@ wince* {
}
symbian {
- TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData
+ TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData PowerMgmt
}
maemo6 {