summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp')
-rw-r--r--tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp144
1 files changed, 11 insertions, 133 deletions
diff --git a/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
index 6b299ac459..c801534a50 100644
--- a/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
+++ b/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -42,12 +42,9 @@
#include <QtTest/QtTest>
#include "../qbearertestcommon.h"
+#ifndef QT_NO_BEARERMANAGEMENT
#include <QtNetwork/qnetworkconfiguration.h>
#include <QtNetwork/qnetworkconfigmanager.h>
-
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
-#include <stdio.h>
-#include <iapconf.h>
#endif
QT_USE_NAMESPACE
@@ -55,136 +52,16 @@ class tst_QNetworkConfigurationManager : public QObject
{
Q_OBJECT
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
private slots:
+#ifndef QT_NO_BEARERMANAGEMENT
void usedInThread(); // this test must be first, or it will falsely pass
void allConfigurations();
void defaultConfiguration();
void configurationFromIdentifier();
-
-private:
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
- Maemo::IAPConf *iapconf;
- Maemo::IAPConf *iapconf2;
- Maemo::IAPConf *gprsiap;
-#define MAX_IAPS 50
- Maemo::IAPConf *iaps[MAX_IAPS];
- QProcess *icd_stub;
#endif
};
-void tst_QNetworkConfigurationManager::initTestCase()
-{
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
- iapconf = new Maemo::IAPConf("007");
- iapconf->setValue("ipv4_type", "AUTO");
- iapconf->setValue("wlan_wepkey1", "connt");
- iapconf->setValue("wlan_wepdefkey", 1);
- iapconf->setValue("wlan_ssid", QByteArray("JamesBond"));
- iapconf->setValue("name", "James Bond");
- iapconf->setValue("type", "WLAN_INFRA");
-
- gprsiap = new Maemo::IAPConf("This-is-GPRS-IAP");
- gprsiap->setValue("ask_password", false);
- gprsiap->setValue("gprs_accesspointname", "internet");
- gprsiap->setValue("gprs_password", "");
- gprsiap->setValue("gprs_username", "");
- gprsiap->setValue("ipv4_autodns", true);
- gprsiap->setValue("ipv4_type", "AUTO");
- gprsiap->setValue("sim_imsi", "244070123456789");
- gprsiap->setValue("name", "MI6");
- gprsiap->setValue("type", "GPRS");
-
- iapconf2 = new Maemo::IAPConf("osso.net");
- iapconf2->setValue("ipv4_type", "AUTO");
- iapconf2->setValue("wlan_wepkey1", "osso.net");
- iapconf2->setValue("wlan_wepdefkey", 1);
- iapconf2->setValue("wlan_ssid", QByteArray("osso.net"));
- iapconf2->setValue("name", "osso.net");
- iapconf2->setValue("type", "WLAN_INFRA");
- iapconf2->setValue("wlan_security", "WEP");
-
- /* Create large number of IAPs in the gconf and see what happens */
- fflush(stdout);
- printf("Creating %d IAPS: ", MAX_IAPS);
- for (int i=0; i<MAX_IAPS; i++) {
- QString num = QString().sprintf("%d", i);
- QString iap = "iap-" + num;
- iaps[i] = new Maemo::IAPConf(iap);
- iaps[i]->setValue("name", QString("test-iap-")+num);
- iaps[i]->setValue("type", "WLAN_INFRA");
- iaps[i]->setValue("wlan_ssid", QString(QString("test-ssid-")+num).toAscii());
- iaps[i]->setValue("wlan_security", "WPA_PSK");
- iaps[i]->setValue("EAP_wpa_preshared_passphrase", QString("test-passphrase-")+num);
- printf(".");
- fflush(stdout);
- }
- printf("\n");
- fflush(stdout);
-
- icd_stub = new QProcess(this);
- icd_stub->start("/usr/bin/icd2_stub.py");
- QTest::qWait(1000);
-
- // Add a known network to scan list that icd2 stub returns
- QProcess dbus_send;
- // 007 network
- dbus_send.start("dbus-send --type=method_call --system "
- "--dest=com.nokia.icd2 /com/nokia/icd2 "
- "com.nokia.icd2.testing.add_available_network "
- "string:'' uint32:0 string:'' "
- "string:WLAN_INFRA uint32:5000011 array:byte:48,48,55");
- dbus_send.waitForFinished();
-
- // osso.net network
- dbus_send.start("dbus-send --type=method_call --system "
- "--dest=com.nokia.icd2 /com/nokia/icd2 "
- "com.nokia.icd2.testing.add_available_network "
- "string:'' uint32:0 string:'' "
- "string:WLAN_INFRA uint32:83886097 array:byte:111,115,115,111,46,110,101,116");
- dbus_send.waitForFinished();
-#endif
-}
-
-
-void tst_QNetworkConfigurationManager::cleanupTestCase()
-{
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICD)
- iapconf->clear();
- delete iapconf;
- iapconf2->clear();
- delete iapconf2;
- gprsiap->clear();
- delete gprsiap;
-
- printf("Deleting %d IAPS : ", MAX_IAPS);
- for (int i=0; i<MAX_IAPS; i++) {
- iaps[i]->clear();
- delete iaps[i];
- printf(".");
- fflush(stdout);
- }
- printf("\n");
- qDebug() << "Deleted" << MAX_IAPS << "IAPs";
-
- icd_stub->terminate();
- icd_stub->waitForFinished();
-#endif
-}
-
-void tst_QNetworkConfigurationManager::init()
-{
-}
-
-void tst_QNetworkConfigurationManager::cleanup()
-{
-}
-
+#ifndef QT_NO_BEARERMANAGEMENT
void printConfigurationDetails(const QNetworkConfiguration& p)
{
qDebug() << p.name() <<": isvalid->" <<p.isValid() << " type->"<< p.type() <<
@@ -204,7 +81,7 @@ void tst_QNetworkConfigurationManager::allConfigurations()
QSignalSpy spy(&manager, SIGNAL(updateCompleted()));
manager.updateConfigurations(); //initiate scans
- QTRY_VERIFY(spy.count() == 1); //wait for scan to complete
+ QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete
QList<QNetworkConfiguration> configs = manager.allConfigurations();
@@ -281,7 +158,7 @@ void tst_QNetworkConfigurationManager::defaultConfiguration()
QNetworkConfigurationManager manager;
QSignalSpy spy(&manager, SIGNAL(updateCompleted()));
manager.updateConfigurations(); //initiate scans
- QTRY_VERIFY(spy.count() == 1); //wait for scan to complete
+ QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete
QList<QNetworkConfiguration> configs = manager.allConfigurations();
QNetworkConfiguration defaultConfig = manager.defaultConfiguration();
@@ -311,7 +188,7 @@ void tst_QNetworkConfigurationManager::configurationFromIdentifier()
//force an update to get maximum number of configs
QSignalSpy spy(&manager, SIGNAL(updateCompleted()));
manager.updateConfigurations(); //initiate scans
- QTRY_VERIFY(spy.count() == 1); //wait for scan to complete
+ QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete
QList<QNetworkConfiguration> configs = manager.allConfigurations();
@@ -339,7 +216,7 @@ protected:
preScanConfigs = manager.allConfigurations();
QSignalSpy spy(&manager, SIGNAL(updateCompleted()));
manager.updateConfigurations(); //initiate scans
- QTRY_VERIFY(spy.count() == 1); //wait for scan to complete
+ QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete
configs = manager.allConfigurations();
}
public:
@@ -356,7 +233,7 @@ void tst_QNetworkConfigurationManager::usedInThread()
QNCMTestThread thread;
connect(&thread, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
thread.start();
- QTestEventLoop::instance().enterLoop(100); //QTRY_VERIFY could take ~90 seconds to time out in the thread
+ QTestEventLoop::instance().enterLoop(100); //QTRY_VERIFY_WITH_TIMEOUT could take ~90 seconds to time out in the thread
QVERIFY(!QTestEventLoop::instance().timeout());
qDebug() << "prescan:" << thread.preScanConfigs.count();
qDebug() << "postscan:" << thread.configs.count();
@@ -365,7 +242,7 @@ void tst_QNetworkConfigurationManager::usedInThread()
QList<QNetworkConfiguration> preScanConfigs = manager.allConfigurations();
QSignalSpy spy(&manager, SIGNAL(updateCompleted()));
manager.updateConfigurations(); //initiate scans
- QTRY_VERIFY(spy.count() == 1); //wait for scan to complete
+ QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete
QList<QNetworkConfiguration> configs = manager.allConfigurations();
QCOMPARE(thread.configs, configs);
//Don't compare pre scan configs, because these may be cached and therefore give different results
@@ -373,6 +250,7 @@ void tst_QNetworkConfigurationManager::usedInThread()
//QCOMPARE(thread.preScanConfigs, preScanConfigs);
#endif
}
+#endif
QTEST_MAIN(tst_QNetworkConfigurationManager)
#include "tst_qnetworkconfigurationmanager.moc"