summaryrefslogtreecommitdiffstats
path: root/tests/auto/qnetworksession
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-02-03 06:41:07 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-02-03 06:41:07 (GMT)
commite80295fff0836268d357488feaefb874b458e8ab (patch)
treee7c283b015fe520654c50c4fb10a62982077bd4f /tests/auto/qnetworksession
parentba7fdc51a2cc0792ceeaf51edce7863c94d96249 (diff)
parent29f24e41b91c05d551c7ac16625a2961744c8339 (diff)
downloadQt-e80295fff0836268d357488feaefb874b458e8ab.zip
Qt-e80295fff0836268d357488feaefb874b458e8ab.tar.gz
Qt-e80295fff0836268d357488feaefb874b458e8ab.tar.bz2
Merge commit 'BearerIntegration-5' into remove-manual-test
Conflicts: tests/auto/qnetworksession/lackey/lackey.pro tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp
Diffstat (limited to 'tests/auto/qnetworksession')
-rw-r--r--tests/auto/qnetworksession/lackey/lackey.pro6
-rw-r--r--tests/auto/qnetworksession/lackey/main.cpp21
-rw-r--r--tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp44
-rw-r--r--tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro2
4 files changed, 53 insertions, 20 deletions
diff --git a/tests/auto/qnetworksession/lackey/lackey.pro b/tests/auto/qnetworksession/lackey/lackey.pro
index 6cc1b43..3ed9850 100644
--- a/tests/auto/qnetworksession/lackey/lackey.pro
+++ b/tests/auto/qnetworksession/lackey/lackey.pro
@@ -2,3 +2,9 @@ SOURCES += main.cpp
TARGET = qnetworksessionlackey
QT = core network
+
+symbian {
+ # Needed for interprocess communication and opening QNetworkSession
+ TARGET.CAPABILITY = NetworkControl NetworkServices
+}
+
diff --git a/tests/auto/qnetworksession/lackey/main.cpp b/tests/auto/qnetworksession/lackey/main.cpp
index a84021d..1e40485 100644
--- a/tests/auto/qnetworksession/lackey/main.cpp
+++ b/tests/auto/qnetworksession/lackey/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -54,16 +54,23 @@ QT_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 d3923e9..48db6cb 100644
--- a/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp
+++ b/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -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;
@@ -269,7 +269,10 @@ void tst_QNetworkSession::sessionProperties()
// session is in the connected state.
qDebug() << "Session state:" << session.state();
qDebug() << "Session iface:" << session.interface().isValid() << session.interface().name();
+#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 &&
@@ -316,13 +319,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);
@@ -372,7 +376,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();
@@ -514,7 +521,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.");
}
@@ -547,7 +557,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());
}
@@ -720,7 +733,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());
}
@@ -793,19 +809,25 @@ 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()
{
qDebug() << "START";
+#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)
@@ -825,19 +847,16 @@ 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(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) ==
@@ -882,6 +901,7 @@ void tst_QNetworkSession::outOfProcessSession()
switch (lackey.exitCode()) {
case 0:
+ qDebug("Lackey returned exit success (0)");
break;
case 1:
QSKIP("No discovered configurations found.", SkipAll);
diff --git a/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro b/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro
index ffa3b25..cad388c 100644
--- a/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro
+++ b/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro
@@ -5,7 +5,7 @@ HEADERS += ../../qbearertestcommon.h
QT = core network
symbian {
- TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData
+ TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData PowerMgmt
}
maemo6 {