wlanutilities/wlanqtutilities/tsrc/testwlanqtutils.cpp
changeset 39 7b3e49e4608a
parent 31 e8f4211554fb
child 43 72ebcbb64834
equal deleted inserted replaced
36:682dd021f9be 39:7b3e49e4608a
    27 #include "wlanqtutilsap.h"
    27 #include "wlanqtutilsap.h"
    28 #include "wlanqtutilsiap.h"
    28 #include "wlanqtutilsiap.h"
    29 #include "wlanqtutils.h"
    29 #include "wlanqtutils.h"
    30 #include "wlanqtutils_p.h"
    30 #include "wlanqtutils_p.h"
    31 #include "wlanqtutilsconmonwrapper.h"
    31 #include "wlanqtutilsconmonwrapper.h"
    32 #include "wlanqtutilsconmonwrapperinfo_s60_p.h"
    32 #include "wlanqtutilsconmonwrapperinfo_symbian.h"
    33 #include "wlanqtutilsconntestwrapper.h"
       
    34 #include "wlanqtutilsconntestwrapper_s60_p.h"
       
    35 #include "testwlanqtutils.h"
    33 #include "testwlanqtutils.h"
    36 #include "wlanqtutilstestcontext.h"
    34 #include "wlanqtutilstestcontext.h"
    37 
    35 
    38 WlanQtUtilsTestContext testContext;
    36 WlanQtUtilsTestContext testContext;
    39 
    37 
    65  * This function will be called before the first test function is executed.
    63  * This function will be called before the first test function is executed.
    66  */
    64  */
    67 void TestWlanQtUtils::initTestCase()
    65 void TestWlanQtUtils::initTestCase()
    68 {
    66 {
    69     wlanQtUtils_ = NULL;
    67     wlanQtUtils_ = NULL;
    70     signalScanReady_ = NULL;
    68     mSignalScanReady = NULL;
       
    69     mSignalScanApReady = NULL;
       
    70     mSignalScanDirectReady = NULL;
    71     signalWlanNetworkOpened_ = NULL;
    71     signalWlanNetworkOpened_ = NULL;
    72     signalWlanNetworkClosed_ = NULL;
    72     signalWlanNetworkClosed_ = NULL;
    73     signalIctResult_ = NULL;
    73     signalIctResult_ = NULL;
    74 
    74 
    75     //If Active scheduler exists then don't install a new one as it will cause panic
    75     //If Active scheduler exists then don't install a new one as it will cause panic
    97     subTestLoadCommsDatFile(commsDatDefault_);
    97     subTestLoadCommsDatFile(commsDatDefault_);
    98 
    98 
    99     testContext.initialize();
    99     testContext.initialize();
   100 
   100 
   101     QVERIFY(wlanQtUtils_ == NULL);
   101     QVERIFY(wlanQtUtils_ == NULL);
   102     QVERIFY(signalScanReady_ == NULL);
   102     QVERIFY(mSignalScanReady == NULL);
       
   103     QVERIFY(mSignalScanApReady == NULL);
       
   104     QVERIFY(mSignalScanDirectReady == NULL);
   103     QVERIFY(signalWlanNetworkOpened_ == NULL);
   105     QVERIFY(signalWlanNetworkOpened_ == NULL);
   104     QVERIFY(signalWlanNetworkClosed_ == NULL);
   106     QVERIFY(signalWlanNetworkClosed_ == NULL);
   105     QVERIFY(signalIctResult_ == NULL);
   107     QVERIFY(signalIctResult_ == NULL);
   106     subTestNewWlanQtUtils();
   108     subTestNewWlanQtUtils();
   107 }
   109 }
   112 void TestWlanQtUtils::cleanup()
   114 void TestWlanQtUtils::cleanup()
   113 {
   115 {
   114     delete wlanQtUtils_;
   116     delete wlanQtUtils_;
   115     wlanQtUtils_ = NULL;
   117     wlanQtUtils_ = NULL;
   116 
   118 
   117     QCOMPARE(signalScanReady_->count(), 0);
   119     QCOMPARE(mSignalScanReady->count(), 0);
   118     delete signalScanReady_;
   120     delete mSignalScanReady;
   119     signalScanReady_ = NULL;
   121     mSignalScanReady = NULL;
       
   122 
       
   123     QCOMPARE(mSignalScanApReady->count(), 0);
       
   124     delete mSignalScanApReady;
       
   125     mSignalScanApReady = NULL;
       
   126 
       
   127     QCOMPARE(mSignalScanDirectReady->count(), 0);
       
   128     delete mSignalScanDirectReady;
       
   129     mSignalScanDirectReady = NULL;
   120 
   130 
   121     QCOMPARE(signalWlanNetworkOpened_->count(), 0);
   131     QCOMPARE(signalWlanNetworkOpened_->count(), 0);
   122     delete signalWlanNetworkOpened_;
   132     delete signalWlanNetworkOpened_;
   123     signalWlanNetworkOpened_ = NULL;
   133     signalWlanNetworkOpened_ = NULL;
   124 
   134 
   138 /**
   148 /**
   139  * Test available WLAN APs when scan is triggered by client.
   149  * Test available WLAN APs when scan is triggered by client.
   140  */
   150  */
   141 void TestWlanQtUtils::testAvailableWlan()
   151 void TestWlanQtUtils::testAvailableWlan()
   142 {
   152 {
   143     testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(4);
   153     testContext.mScan.createDefaultWlanScanResultList(4);
   144     
   154     
   145     // Request a scan to get result signal
   155     // Request a scan to get result signal
   146     wlanQtUtils_->scanWlans();
   156     wlanQtUtils_->scanWlans();
   147     
   157     
   148     // Let active object run and verify signal.
   158     // Let active object run and verify signal.
   149     subTestSignalWaitAndTake(signalScanReady_, NULL);
   159     subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
   150 
   160 
   151     // Get and verify the list of available WLAN APs.
   161     // Get and verify the list of available WLAN APs.
   152     QList< QSharedPointer<WlanQtUtilsIap> > iaps;
   162     QList< QSharedPointer<WlanQtUtilsIap> > iaps;
   153     QList< QSharedPointer<WlanQtUtilsAp> > aps;
   163     QList< QSharedPointer<WlanQtUtilsAp> > aps;
   154     wlanQtUtils_->availableWlans(iaps, aps);
   164     wlanQtUtils_->availableWlans(iaps, aps);
   155 
   165 
   156     testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps);
   166     testContext.mScan.verifyWlanScanResultList(aps);
   157     QCOMPARE(iaps.count(), 0);
   167     QCOMPARE(iaps.count(), 0);
   158     aps.clear();
   168     aps.clear();
   159 }
   169 }
   160 
   170 
   161 /**
   171 /**
   162  * Test available WLAN APs when scan is triggered by client.
   172  * Test available WLAN APs when scan is triggered by client.
   163  * Two scan results have the same SSID and the latter one of those will be removed.
   173  * Two scan results have the same SSID and the latter one of those will be removed.
   164  * Two scan results have the same SSID but different security mode
   174  * Two scan results have the same SSID but different security mode
   165  * Two scan results have the same SSID and security mode but different WpaPsk value
   175  * Two scan results have the same SSID and security mode but different WpaPsk value
   166  * and both are included in the results.
   176  * and both are included in the results.
       
   177  * Two scan results have the same SSID but different connection mode
   167  */
   178  */
   168 void TestWlanQtUtils::testAvailableWlanDuplicates()
   179 void TestWlanQtUtils::testAvailableWlanDuplicates()
   169 {
   180 {
   170     testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(10);
   181     testContext.mScan.createDefaultWlanScanResultList(11);
   171     testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID");
   182     testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID");
   172     testContext.connMon_.wlanScanResult_.wlanScanResultList_[2]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID");
   183     testContext.mScan.mWlanScanResultList[2]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID");
   173     testContext.connMon_.wlanScanResult_.wlanScanResultList_[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID, different SecMode");
   184     testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID, different SecMode");
   174     testContext.connMon_.wlanScanResult_.wlanScanResultList_[5]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa);
   185     testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa);
   175     testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID, different SecMode");
   186     testContext.mScan.mWlanScanResultList[6]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID, different SecMode");
   176     testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeOpen);
   187     testContext.mScan.mWlanScanResultList[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeOpen);
   177     testContext.connMon_.wlanScanResult_.wlanScanResultList_[7]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID & SecMode diff Psk");
   188     testContext.mScan.mWlanScanResultList[7]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID & SecMode diff Psk");
   178     testContext.connMon_.wlanScanResult_.wlanScanResultList_[7]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2);
   189     testContext.mScan.mWlanScanResultList[7]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2);
   179     testContext.connMon_.wlanScanResult_.wlanScanResultList_[9]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID & SecMode diff Psk");
   190     testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID & SecMode diff Psk");
   180     testContext.connMon_.wlanScanResult_.wlanScanResultList_[9]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2);
   191     testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2);
   181     testContext.connMon_.wlanScanResult_.wlanScanResultList_[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true);
   192     testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true);
       
   193     testContext.mScan.mWlanScanResultList[10]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID");
       
   194     testContext.mScan.mWlanScanResultList[10]->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Adhoc);
   182 
   195 
   183     // Request a scan to get result signal
   196     // Request a scan to get result signal
   184     wlanQtUtils_->scanWlans();
   197     wlanQtUtils_->scanWlans();
   185     
   198     
   186     // Let active object run and verify signal.
   199     // Let active object run and verify signal.
   187     subTestSignalWaitAndTake(signalScanReady_, NULL);
   200     subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
   188 
   201 
   189     // Get and verify the list of available WLAN APs.
   202     // Get and verify the list of available WLAN APs.
   190     QList< QSharedPointer<WlanQtUtilsIap> > iaps;
   203     QList< QSharedPointer<WlanQtUtilsIap> > iaps;
   191     QList< QSharedPointer<WlanQtUtilsAp> > aps;
   204     QList< QSharedPointer<WlanQtUtilsAp> > aps;
   192     wlanQtUtils_->availableWlans(iaps, aps);
   205     wlanQtUtils_->availableWlans(iaps, aps);
   193 
   206 
   194     // First remove AP that has duplicate SSID.
   207     // First remove AP that has duplicate SSID.
   195     testContext.connMon_.wlanScanResult_.wlanScanResultList_.removeAt(2);
   208     testContext.mScan.mWlanScanResultList.removeAt(2);
   196     testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps);
   209     testContext.mScan.verifyWlanScanResultList(aps);
   197     QCOMPARE(iaps.count(), 0);
   210     QCOMPARE(iaps.count(), 0);
   198     aps.clear();
   211     aps.clear();
   199 }
   212 }
   200 
   213 
   201 /**
   214 /**
   202  * Test available WLAN APs when scan is triggered by client.
   215  * Test available WLAN APs when scan is triggered by client.
   203  * Include all supported security modes.
   216  * Include all supported security modes.
   204  */
   217  */
   205 void TestWlanQtUtils::testAvailableWlanSecModes()
   218 void TestWlanQtUtils::testAvailableWlanSecModes()
   206 {
   219 {
   207     testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(9);
   220     testContext.mScan.createDefaultWlanScanResultList(11);
   208     testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeOpen);
   221     testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen);
   209     testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Adhoc);
   222     testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Adhoc);
   210     testContext.connMon_.wlanScanResult_.wlanScanResultList_[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWep);
   223     testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWep);
   211     testContext.connMon_.wlanScanResult_.wlanScanResultList_[2]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecMode802_1x);
   224     testContext.mScan.mWlanScanResultList[2]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWep);
   212     testContext.connMon_.wlanScanResult_.wlanScanResultList_[3]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa);
   225     testContext.mScan.mWlanScanResultList[3]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecMode802_1x);
   213     testContext.connMon_.wlanScanResult_.wlanScanResultList_[4]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa);
   226     testContext.mScan.mWlanScanResultList[4]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
   214     testContext.connMon_.wlanScanResult_.wlanScanResultList_[4]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true);
   227     testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
   215     testContext.connMon_.wlanScanResult_.wlanScanResultList_[5]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2);
   228     testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true);
   216     testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2);
   229     testContext.mScan.mWlanScanResultList[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2);
   217     testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true);
   230     testContext.mScan.mWlanScanResultList[7]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2);
   218     testContext.connMon_.wlanScanResult_.wlanScanResultList_[7]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWapi);
   231     testContext.mScan.mWlanScanResultList[7]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true);
   219     testContext.connMon_.wlanScanResult_.wlanScanResultList_[8]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWapi);
   232     testContext.mScan.mWlanScanResultList[8]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWapi);
       
   233     testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWapi);
   220     // Let's trick the stub to return WapiPsk by putting WpaPskUse on *
   234     // Let's trick the stub to return WapiPsk by putting WpaPskUse on *
   221     testContext.connMon_.wlanScanResult_.wlanScanResultList_[8]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true);
   235     testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true);
       
   236     testContext.mScan.mWlanScanResultList[10]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2);
       
   237     testContext.mScan.mWlanScanResultList[10]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true);
       
   238     testContext.mScan.mWlanScanResultList[10]->setValue(WlanQtUtilsAp::ConfIdWpsSupported, true);
   222 
   239 
   223     // Request a scan to get result signal
   240     // Request a scan to get result signal
   224     wlanQtUtils_->scanWlans();
   241     wlanQtUtils_->scanWlans();
   225     
   242     
   226     // Let active object run and verify signal.
   243     // Let active object run and verify signal.
   227     subTestSignalWaitAndTake(signalScanReady_, NULL);
   244     subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
   228 
   245 
   229     // Get and verify the list of available WLAN APs.
   246     // Get and verify the list of available WLAN APs.
   230     QList< QSharedPointer<WlanQtUtilsIap> > iaps;
   247     QList< QSharedPointer<WlanQtUtilsIap> > iaps;
   231     QList< QSharedPointer<WlanQtUtilsAp> > aps;
   248     QList< QSharedPointer<WlanQtUtilsAp> > aps;
   232     wlanQtUtils_->availableWlans(iaps, aps);
   249     wlanQtUtils_->availableWlans(iaps, aps);
   233 
   250 
   234     // Remove the trick *. WapiPsk and Wapi both map to just Wapi
   251     // Remove the trick *. WapiPsk and Wapi both map to just Wapi
   235     testContext.connMon_.wlanScanResult_.wlanScanResultList_[8]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,false);
   252     testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,false);
   236     testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps);
   253     testContext.mScan.verifyWlanScanResultList(aps);
   237     QCOMPARE(iaps.count(), 0);
   254     QCOMPARE(iaps.count(), 0);
   238     aps.clear();
   255     aps.clear();
   239 }
   256 }
   240 
   257 
   241 /**
   258 /**
   242  * Test available WLAN APs when scan is triggered by client.
   259  * Test available WLAN APs when scan is triggered by client.
   243  * Include some exotic ssids.
   260  * Include some exotic ssids.
   244  */
   261  */
   245 void TestWlanQtUtils::testAvailableWlanSsids()
   262 void TestWlanQtUtils::testAvailableWlanSsids()
   246 {
   263 {
   247     testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(6);
   264     testContext.mScan.createDefaultWlanScanResultList(6);
   248     testContext.connMon_.wlanScanResult_.wlanScanResultList_[1]->setValue(WlanQtUtilsAp::ConfIdSsid, "           ");
   265     testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSsid, "           ");
   249     testContext.connMon_.wlanScanResult_.wlanScanResultList_[2]->setValue(WlanQtUtilsAp::ConfIdSsid, "    whitespace around ssid  ");
   266     testContext.mScan.mWlanScanResultList[2]->setValue(WlanQtUtilsAp::ConfIdSsid, "    whitespace around ssid  ");
   250     testContext.connMon_.wlanScanResult_.wlanScanResultList_[3]->setValue(WlanQtUtilsAp::ConfIdSsid, QString(QChar()));
   267     testContext.mScan.mWlanScanResultList[3]->setValue(WlanQtUtilsAp::ConfIdSsid, QString(QChar()));
   251     testContext.connMon_.wlanScanResult_.wlanScanResultList_[4]->setValue(WlanQtUtilsAp::ConfIdSsid, "maximum length ssid that is 32 c");
   268     testContext.mScan.mWlanScanResultList[4]->setValue(WlanQtUtilsAp::ConfIdSsid, "maximum length ssid that is 32 c");
   252     testContext.connMon_.wlanScanResult_.wlanScanResultList_[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "A");
   269     testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "A");
   253 
   270 
   254     // Request a scan to get result signal
   271     // Request a scan to get result signal
   255     wlanQtUtils_->scanWlans();
   272     wlanQtUtils_->scanWlans();
   256     
   273     
   257     // Let active object run and verify signal.
   274     // Let active object run and verify signal.
   258     subTestSignalWaitAndTake(signalScanReady_, NULL);
   275     subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
   259 
   276 
   260     // Get and verify the list of available WLAN APs.
   277     // Get and verify the list of available WLAN APs.
   261     QList< QSharedPointer<WlanQtUtilsIap> > iaps;
   278     QList< QSharedPointer<WlanQtUtilsIap> > iaps;
   262     QList< QSharedPointer<WlanQtUtilsAp> > aps;
   279     QList< QSharedPointer<WlanQtUtilsAp> > aps;
   263     wlanQtUtils_->availableWlans(iaps, aps);
   280     wlanQtUtils_->availableWlans(iaps, aps);
   264 
   281 
   265     // Empty ssids are removed from results
   282     // Empty ssids are removed from results
   266     testContext.connMon_.wlanScanResult_.wlanScanResultList_.removeAt(3);
   283     testContext.mScan.mWlanScanResultList.removeAt(3);
   267     testContext.connMon_.wlanScanResult_.wlanScanResultList_.removeAt(1);
   284     testContext.mScan.mWlanScanResultList.removeAt(1);
   268     testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps);
   285     testContext.mScan.verifyWlanScanResultList(aps);
   269     QCOMPARE(iaps.count(), 0);
   286     QCOMPARE(iaps.count(), 0);
   270     aps.clear();
   287     aps.clear();
   271 }
   288 }
   272 
   289 
   273 /**
   290 /**
   274  * Test available WLAN APs when there are also WLAN IAPs available.
   291  * Test available WLAN APs when there are also WLAN IAPs available.
   275  */
   292  */
   276 void TestWlanQtUtils::testAvailableWlanWithIaps()
   293 void TestWlanQtUtils::testAvailableWlanWithIaps()
   277 {
   294 {
   278     testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(7);
   295     testContext.mScan.createDefaultWlanScanResultList(7);
   279     testContext.connMon_.wlanScanResult_.wlanScanResultList_[1]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 3");
   296     testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 3");
   280     testContext.connMon_.wlanScanResult_.wlanScanResultList_[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa);    
   297     testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa);    
   281     testContext.connMon_.wlanScanResult_.wlanScanResultList_[1]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true);    
   298     testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true);    
   282     testContext.connMon_.wlanScanResult_.wlanScanResultList_[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 1");
   299     testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 1");
   283     // SSID is found in Internet Snap, but security mode does not match:
   300     // SSID is found in Internet Snap, but security mode does not match:
   284     testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 2");
   301     testContext.mScan.mWlanScanResultList[6]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 2");
   285     testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa);
   302     testContext.mScan.mWlanScanResultList[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa);
   286     
   303     
   287     // Request a scan to get result signal
   304     // Request a scan to get result signal
   288     wlanQtUtils_->scanWlans();
   305     wlanQtUtils_->scanWlans();
   289     
   306     
   290     // Let active object run and verify signal.
   307     // Let active object run and verify signal.
   291     subTestSignalWaitAndTake(signalScanReady_, NULL);
   308     subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
   292 
   309 
   293     // Get and verify the list of available WLAN APs.
   310     // Get and verify the list of available WLAN APs.
   294     QList< QSharedPointer<WlanQtUtilsIap> > iaps;
   311     QList< QSharedPointer<WlanQtUtilsIap> > iaps;
   295     QList< QSharedPointer<WlanQtUtilsAp> > aps;
   312     QList< QSharedPointer<WlanQtUtilsAp> > aps;
   296     wlanQtUtils_->availableWlans(iaps, aps);
   313     wlanQtUtils_->availableWlans(iaps, aps);
   297 
   314 
   298     // Verify WLAN AP list. First, remove scan results that will not appear
   315     // Verify WLAN AP list. First, remove scan results that will not appear
   299     // because they are WLAN IAPs.
   316     // because they are WLAN IAPs.
   300     testContext.connMon_.wlanScanResult_.wlanScanResultList_.removeAt(5);
   317     testContext.mScan.mWlanScanResultList.removeAt(5);
   301     testContext.connMon_.wlanScanResult_.wlanScanResultList_.removeAt(1);
   318     testContext.mScan.mWlanScanResultList.removeAt(1);
   302     testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps);
   319     testContext.mScan.verifyWlanScanResultList(aps);
   303 
   320 
   304     // Verify WLAN IAP list
   321     // Verify WLAN IAP list
   305     QCOMPARE(iaps.count(), 2);
   322     QCOMPARE(iaps.count(), 2);
   306     QCOMPARE(iaps[0]->value(WlanQtUtilsIap::ConfIdIapId).toInt(), 5);
   323     QCOMPARE(iaps[0]->value(WlanQtUtilsIap::ConfIdIapId).toInt(), 5);
   307     QCOMPARE(iaps[0]->value(WlanQtUtilsIap::ConfIdName).toString(), QString("WLAN IAP 1"));
   324     QCOMPARE(iaps[0]->value(WlanQtUtilsIap::ConfIdName).toString(), QString("WLAN IAP 1"));
   326     QCOMPARE(aps.count(), 0);
   343     QCOMPARE(aps.count(), 0);
   327     QCOMPARE(iaps.count(), 0);
   344     QCOMPARE(iaps.count(), 0);
   328     
   345     
   329     // **************** 1st scan ********************
   346     // **************** 1st scan ********************
   330     // 6 APs are required for this scan
   347     // 6 APs are required for this scan
   331     testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(6);
   348     testContext.mScan.createDefaultWlanScanResultList(6);
   332 
   349 
   333     wlanQtUtils_->scanWlans();
   350     wlanQtUtils_->scanWlans();
   334     subTestSignalWaitAndTake(signalScanReady_, NULL);
   351     subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
   335 
   352 
   336     // Get the results for the 1st scan
   353     // Get the results for the 1st scan
   337     wlanQtUtils_->availableWlans(iaps, aps);
   354     wlanQtUtils_->availableWlans(iaps, aps);
   338     // Verify the results for the scan
   355     // Verify the results for the scan
   339     testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps);
   356     testContext.mScan.verifyWlanScanResultList(aps);
   340     QCOMPARE(iaps.count(), 0);
   357     QCOMPARE(iaps.count(), 0);
   341     aps.clear();
   358     aps.clear();
   342 
   359 
   343     // **************** 2nd scan ********************
   360     // **************** 2nd scan ********************
   344     // 2 APs are required for this scan
   361     // 2 APs are required for this scan
   345     testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(2);
   362     testContext.mScan.createDefaultWlanScanResultList(2);
   346 
   363 
   347     wlanQtUtils_->scanWlans();
   364     wlanQtUtils_->scanWlans();
   348     subTestSignalWaitAndTake(signalScanReady_, NULL);
   365     subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
   349 
   366 
   350     // Get the results for the 2nd scan
   367     // Get the results for the 2nd scan
   351     wlanQtUtils_->availableWlans(iaps, aps);
   368     wlanQtUtils_->availableWlans(iaps, aps);
   352     // Verify the results for the scan
   369     // Verify the results for the scan
   353     testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps);
   370     testContext.mScan.verifyWlanScanResultList(aps);
   354     QCOMPARE(iaps.count(), 0);
   371     QCOMPARE(iaps.count(), 0);
   355     aps.clear();
   372     aps.clear();
   356 
   373 
   357     // **************** 3rd scan ********************
   374     // **************** 3rd scan ********************
   358     // 4 APs are required for the 3rd scan
   375     // 4 APs are required for the 3rd scan
   359     testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(4);
   376     testContext.mScan.createDefaultWlanScanResultList(4);
   360 
   377 
   361     wlanQtUtils_->scanWlans();
   378     wlanQtUtils_->scanWlans();
   362     subTestSignalWaitAndTake(signalScanReady_, NULL);
   379     subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
   363     
   380     
   364     // Get the results for the 3rd scan
   381     // Get the results for the 3rd scan
   365     wlanQtUtils_->availableWlans(iaps, aps);
   382     wlanQtUtils_->availableWlans(iaps, aps);
   366     // Verify the results for the scan
   383     // Verify the results for the scan
   367     testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps);
   384     testContext.mScan.verifyWlanScanResultList(aps);
   368     QCOMPARE(iaps.count(), 0);
   385     QCOMPARE(iaps.count(), 0);
   369     aps.clear();
   386     aps.clear();
       
   387 }
       
   388 
       
   389 /**
       
   390  * Test availability scan that finds nothing.
       
   391  */
       
   392 void TestWlanQtUtils::testAvailableWlanScanEmpty()
       
   393 {
       
   394     // Form result list
       
   395     testContext.mScan.createDefaultWlanScanResultList(0);
       
   396 
       
   397     // Request a direct scan to get result signal
       
   398     wlanQtUtils_->scanWlans();
       
   399     
       
   400     // Let active object run and verify signal.
       
   401     subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
       
   402 
       
   403     // Get and verify the list of available WLAN APs.
       
   404     QList< QSharedPointer<WlanQtUtilsIap> > iaps;
       
   405     QList< QSharedPointer<WlanQtUtilsAp> > aps;
       
   406     wlanQtUtils_->availableWlans(iaps, aps);
       
   407     testContext.mScan.verifyWlanScanResultList(aps);
       
   408     QCOMPARE(iaps.count(), 0);
       
   409 }
       
   410 
       
   411 /**
       
   412  * Test WLAN availability scan failure.
       
   413  */
       
   414 void TestWlanQtUtils::testAvailableWlanScanError()
       
   415 {
       
   416     // Set the scan to fail
       
   417     testContext.mScan.mScanRetValue = KErrGeneral;
       
   418     
       
   419     // Start the scan
       
   420     wlanQtUtils_->scanWlans();
       
   421 
       
   422     // Catch & check the scan result signal
       
   423     subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusError);
       
   424 }
       
   425 
       
   426 /**
       
   427  * Test available WLAN APs when scan is triggered by client.
       
   428  */
       
   429 void TestWlanQtUtils::testAvailableWlanAps()
       
   430 {
       
   431     testContext.mScan.createDefaultWlanScanResultList(4);
       
   432     
       
   433     // Request a scan to get result signal
       
   434     wlanQtUtils_->scanWlanAps();
       
   435     
       
   436     // Let active object run and verify signal.
       
   437     subTestScanResultSignal(mSignalScanApReady, WlanQtUtils::ScanStatusOk);
       
   438 
       
   439     // Get and verify the list of available WLAN APs.
       
   440     QList< QSharedPointer<WlanQtUtilsAp> > aps;
       
   441     wlanQtUtils_->availableWlanAps(aps);
       
   442 
       
   443     testContext.mScan.verifyWlanScanResultList(aps);
       
   444     aps.clear();
       
   445 }
       
   446 
       
   447 /**
       
   448  * Test a direct scan that finds nothing.
       
   449  */
       
   450 void TestWlanQtUtils::testAvailableWlanApsScanEmpty()
       
   451 {
       
   452     // Form result list
       
   453     testContext.mScan.createDefaultWlanScanResultList(0);
       
   454 
       
   455     // Request a direct scan to get result signal
       
   456     wlanQtUtils_->scanWlanAps();
       
   457     
       
   458     // Let active object run and verify signal.
       
   459     subTestScanResultSignal(mSignalScanApReady, WlanQtUtils::ScanStatusOk);
       
   460 
       
   461     // Get and verify the list of available WLAN APs.
       
   462     QList< QSharedPointer<WlanQtUtilsAp> > aps;
       
   463     wlanQtUtils_->availableWlanAps(aps);
       
   464     testContext.mScan.verifyWlanScanResultList(aps);
       
   465 }
       
   466 
       
   467 /**
       
   468  * Test cancellation of WLAN AP scan.
       
   469  */
       
   470 void TestWlanQtUtils::testStopWlanApScan()
       
   471 {
       
   472     // Do not complete scan request immediately
       
   473     testContext.mScan.mCompleteWlanScan = false;
       
   474     
       
   475     // Start the scan
       
   476     wlanQtUtils_->scanWlanAps();
       
   477     // Cancel the scan
       
   478     wlanQtUtils_->stopWlanScan();
       
   479 
       
   480     // Catch & check the scan result signal
       
   481     subTestScanResultSignal(mSignalScanApReady, WlanQtUtils::ScanStatusCancelled);
       
   482 }
       
   483 
       
   484 /**
       
   485  * Test WLAN AP scan failure.
       
   486  */
       
   487 void TestWlanQtUtils::testWlanApScanError()
       
   488 {
       
   489     // Set the scan to fail
       
   490     testContext.mScan.mScanRetValue = KErrGeneral;
       
   491     
       
   492     // Start the scan
       
   493     wlanQtUtils_->scanWlanAps();
       
   494 
       
   495     // Catch & check the scan result signal
       
   496     subTestScanResultSignal(mSignalScanApReady, WlanQtUtils::ScanStatusError);
       
   497 }
       
   498 
       
   499 /**
       
   500  * Test a basic direct scan.
       
   501  */
       
   502 void TestWlanQtUtils::testDirectScanBasic()
       
   503 {
       
   504     // Form result list
       
   505     testContext.mScan.createDefaultWlanScanResultList(2);
       
   506     testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "testssid");
       
   507     testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen);
       
   508     testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSsid, "testssid");
       
   509     testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdBssid, "654321");
       
   510     testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
       
   511 
       
   512     // Request a direct scan to get result signal
       
   513     wlanQtUtils_->scanWlanDirect(QString("testssid"));
       
   514     
       
   515     // Let active object run and verify signal.
       
   516     subTestScanResultSignal(mSignalScanDirectReady, WlanQtUtils::ScanStatusOk);
       
   517 
       
   518     // Get and verify the list of available WLAN APs.
       
   519     QList< QSharedPointer<WlanQtUtilsAp> > aps;
       
   520     wlanQtUtils_->availableWlanAps(aps);
       
   521 
       
   522     testContext.mScan.verifyWlanScanResultList(aps);
       
   523     aps.clear();
       
   524 }
       
   525 
       
   526 /**
       
   527  * Test a direct scan that finds nothing.
       
   528  */
       
   529 void TestWlanQtUtils::testDirectScanEmpty()
       
   530 {
       
   531     // Form result list
       
   532     testContext.mScan.createDefaultWlanScanResultList(0);
       
   533 
       
   534     // Request a direct scan to get result signal
       
   535     wlanQtUtils_->scanWlanDirect(QString("notavailable"));
       
   536     
       
   537     // Let active object run and verify signal.
       
   538     subTestScanResultSignal(mSignalScanDirectReady, WlanQtUtils::ScanStatusOk);
       
   539 
       
   540     // Get and verify the list of available WLAN APs.
       
   541     QList< QSharedPointer<WlanQtUtilsAp> > aps;
       
   542     wlanQtUtils_->availableWlanAps(aps);
       
   543     testContext.mScan.verifyWlanScanResultList(aps);
       
   544 }
       
   545 
       
   546 /**
       
   547  * Test cancellation of direct scan.
       
   548  */
       
   549 void TestWlanQtUtils::testDirectScanStop()
       
   550 {
       
   551     // Do not complete scan request immediately
       
   552     testContext.mScan.mCompleteWlanScan = false;
       
   553     
       
   554     // Start the scan
       
   555     wlanQtUtils_->scanWlanDirect(QString("testssid"));
       
   556     // Cancel the scan
       
   557     wlanQtUtils_->stopWlanScan();
       
   558 
       
   559     // Catch & check the scan result signal
       
   560     subTestScanResultSignal(mSignalScanDirectReady, WlanQtUtils::ScanStatusCancelled);
       
   561 }
       
   562 
       
   563 /**
       
   564  * Test direct scan failure.
       
   565  */
       
   566 void TestWlanQtUtils::testDirectScanError()
       
   567 {
       
   568     // Set the scan to fail
       
   569     testContext.mScan.mScanRetValue = KErrGeneral;
       
   570     
       
   571     // Start the scan
       
   572     wlanQtUtils_->scanWlanDirect(QString("boundtofail"));
       
   573 
       
   574     // Catch & check the scan result signal
       
   575     subTestScanResultSignal(mSignalScanDirectReady, WlanQtUtils::ScanStatusError);
   370 }
   576 }
   371 
   577 
   372 /**
   578 /**
   373  * This function tests creation of WLAN IAP in a succesful manner.
   579  * This function tests creation of WLAN IAP in a succesful manner.
   374  * - WLAN scan is made because otherwise we cannot verify that IAP creation is successful.
   580  * - WLAN scan is made because otherwise we cannot verify that IAP creation is successful.
   377  * - Create WLAN IAP.
   583  * - Create WLAN IAP.
   378  * - Check that WLAN IAP has been created and that this IAP is not in WLAN AP scan results.
   584  * - Check that WLAN IAP has been created and that this IAP is not in WLAN AP scan results.
   379  */
   585  */
   380 void TestWlanQtUtils::testCreateIapOk()
   586 void TestWlanQtUtils::testCreateIapOk()
   381 {
   587 {
   382     testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(1);
   588     testContext.mScan.createDefaultWlanScanResultList(1);
   383     testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapOk");
   589     testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapOk");
   384     testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa);
   590     testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa);
   385     testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true);
   591     testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true);
   386 
   592 
   387     // Request a scan to get result signal
   593     // Request a scan to get result signal
   388     wlanQtUtils_->scanWlans();
   594     wlanQtUtils_->scanWlans();
   389     
   595     
   390     // Let active object run and verify signal.
   596     // Let active object run and verify signal.
   391     subTestSignalWaitAndTake(signalScanReady_, NULL);
   597     subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
   392 
   598 
   393     // Ensure there are no WLAN IAPs but there is one scan result.
   599     // Ensure there are no WLAN IAPs but there is one scan result.
   394     QList< QSharedPointer<WlanQtUtilsIap> > iaps;
   600     QList< QSharedPointer<WlanQtUtilsIap> > iaps;
   395     QList< QSharedPointer<WlanQtUtilsAp> > aps;
   601     QList< QSharedPointer<WlanQtUtilsAp> > aps;
   396     wlanQtUtils_->availableWlans(iaps, aps);
   602     wlanQtUtils_->availableWlans(iaps, aps);
   397 
   603 
   398     QCOMPARE(iaps.count(), 0);
   604     QCOMPARE(iaps.count(), 0);
   399     testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps);
   605     testContext.mScan.verifyWlanScanResultList(aps);
   400 
   606 
   401     // Execute createIap() function
   607     // Execute createIap() function
   402     WlanQtUtilsAp wlanAp;
   608     QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
   403     wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapOk");
   609     wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapOk");
   404     wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 );
   610     wlanAp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
   405     wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
   611     wlanAp->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true);
   406     wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
   612     wlanAp->setValue(WlanQtUtilsAp::ConfIdWpaPsk, "100euronlounas");
   407     wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true);
   613     int iapId = wlanQtUtils_->createIap(wlanAp.data());
   408     wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPsk, "100euronlounas");
       
   409     int iapId = wlanQtUtils_->createIap(&wlanAp);
       
   410     QVERIFY(iapId != WlanQtUtils::IapIdNone);
   614     QVERIFY(iapId != WlanQtUtils::IapIdNone);
   411 
   615 
   412     // Verify that created IAP is in the IAP list and AP list is empty.
   616     // Verify that created IAP is in the IAP list and AP list is empty.
   413     wlanQtUtils_->availableWlans(iaps, aps);
   617     wlanQtUtils_->availableWlans(iaps, aps);
   414     QCOMPARE(iaps.count(), 1);
   618     QCOMPARE(iaps.count(), 1);
   425  * This function tests creation of WLAN IAP in unsuccesful manner.
   629  * This function tests creation of WLAN IAP in unsuccesful manner.
   426  */
   630  */
   427 void TestWlanQtUtils::testCreateIapErr()
   631 void TestWlanQtUtils::testCreateIapErr()
   428 {
   632 {
   429     // Execute createIap() function with invalid parameters
   633     // Execute createIap() function with invalid parameters
   430     WlanQtUtilsAp wlanAp;
   634     QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
   431     wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapErr");
   635     wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapErr");
   432     wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 );
   636     wlanAp->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
   433     wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
       
   434     wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
       
   435     // Invalid security mode -> exception
   637     // Invalid security mode -> exception
   436     wlanAp.setValue(
   638     wlanAp->setValue(
   437         WlanQtUtilsAp::ConfIdSecurityMode,
   639         WlanQtUtilsAp::ConfIdSecurityMode,
   438         CMManager::EWlanSecModeWAPI + 1111);
   640         CMManager::EWlanSecModeWAPI + 1111);
   439     int iapId = wlanQtUtils_->createIap(&wlanAp);
   641     int iapId = wlanQtUtils_->createIap(wlanAp.data());
   440     QVERIFY(iapId == WlanQtUtils::IapIdNone);
   642     QVERIFY(iapId == WlanQtUtils::IapIdNone);
   441 }
   643 }
   442 
   644 
   443 /**
   645 /**
   444  * This function tests creation of WLAN IAPs with different WEP keys.
   646  * This function tests creation of WLAN IAPs with different WEP keys.
   445  */
   647  */
   446 void TestWlanQtUtils::testCreateIapWepKeys()
   648 void TestWlanQtUtils::testCreateIapWepKeys()
   447 {
   649 {
   448     // Create the IAPs with different kind of WEP keys
   650     // Create the IAPs with different kind of WEP keys
   449     WlanQtUtilsAp wlanAp;
   651     QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
   450     wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapWepKeys");
   652     wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapWepKeys");
   451     wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90);
   653     wlanAp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWep);
   452     wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
   654     wlanAp->setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex2);
   453     wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWep);
       
   454     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, 1);
       
   455     // All keys in HEX format
   655     // All keys in HEX format
   456     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey1, "1234567891");
   656     wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey1, "1234567891");
   457     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey2, "1234567891");
   657     wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey2, "1234567891");
   458     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey3, "1234567891");
   658     wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey3, "1234567891");
   459     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey4, "1234567891");
   659     wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey4, "1234567891");
   460     wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
   660 
   461 
   661     int iapId = wlanQtUtils_->createIap(wlanAp.data());
   462     int iapId = wlanQtUtils_->createIap(&wlanAp);
       
   463     QVERIFY(iapId != WlanQtUtils::IapIdNone);
   662     QVERIFY(iapId != WlanQtUtils::IapIdNone);
   464     
   663     
   465     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, 2);
   664     wlanAp->setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex3);
   466     // All keys in ASCII format
   665     // All keys in ASCII format
   467     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey1, "12345");
   666     wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey1, "12345");
   468     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey2, "12345");
   667     wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey2, "12345");
   469     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey3, "12345");
   668     wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey3, "12345");
   470     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey4, "12345");
   669     wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey4, "12345");
   471 
   670 
   472     iapId = wlanQtUtils_->createIap(&wlanAp);
   671     iapId = wlanQtUtils_->createIap(wlanAp.data());
   473     QVERIFY(iapId != WlanQtUtils::IapIdNone);
   672     QVERIFY(iapId != WlanQtUtils::IapIdNone);
   474 
   673 
   475     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, 3);
   674     wlanAp->setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex4);
   476     // Different keys, including a missing one
   675     // Different keys, including a missing one
   477     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey1, "");
   676     wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey1, "");
   478     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey2, "12345678911234567892123456");
   677     wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey2, "12345678911234567892123456");
   479     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey3, "12345");
   678     wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey3, "12345");
   480     wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey4, "1234567891123");
   679     wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey4, "1234567891123");
   481 
   680 
   482     iapId = wlanQtUtils_->createIap(&wlanAp);
   681     iapId = wlanQtUtils_->createIap(wlanAp.data());
   483     QVERIFY(iapId != WlanQtUtils::IapIdNone);
   682     QVERIFY(iapId != WlanQtUtils::IapIdNone);
   484 }
   683 }
   485 
   684 
   486 /**
   685 /**
   487  * This function tests updating of WLAN IAP in a succesful manner.
   686  * This function tests updating of WLAN IAP in a succesful manner.
   488  */
   687  */
   489 void TestWlanQtUtils::testUpdateIapOk()
   688 void TestWlanQtUtils::testUpdateIapOk()
   490 {
   689 {
   491     // Create an IAP that can be updated
   690     // Create an IAP that can be updated
   492     WlanQtUtilsAp wlanAp;
   691     QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
   493     wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testUpdateIapOk");
   692     wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testUpdateIapOk");
   494     wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90);
   693     int iapId = wlanQtUtils_->createIap(wlanAp.data());
   495     wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
       
   496     wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen);
       
   497     wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
       
   498     int iapId = wlanQtUtils_->createIap(&wlanAp);
       
   499 
   694 
   500     // Update the name and verify it changed
   695     // Update the name and verify it changed
   501     wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "UPDATED_testUpdateIapOk");
   696     wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "UPDATED_testUpdateIapOk");
   502 
   697 
   503     bool success = wlanQtUtils_->updateIap(iapId, &wlanAp);
   698     bool success = wlanQtUtils_->updateIap(iapId, wlanAp.data());
   504     QVERIFY(success == true);
   699     QVERIFY(success == true);
   505     QString name = wlanQtUtils_->iapName(iapId);
   700     QString name = wlanQtUtils_->iapName(iapId);
   506     QCOMPARE(name, QString("UPDATED_testUpdateIapOk"));
   701     QCOMPARE(name, QString("UPDATED_testUpdateIapOk"));
   507 }
   702 }
   508 
   703 
   521  * This function tests deletion of WLAN IAP in a succesful manner.
   716  * This function tests deletion of WLAN IAP in a succesful manner.
   522  */
   717  */
   523 void TestWlanQtUtils::testDeleteIapOk()
   718 void TestWlanQtUtils::testDeleteIapOk()
   524 {
   719 {
   525     // Create an IAP that can be deleted
   720     // Create an IAP that can be deleted
   526     WlanQtUtilsAp wlanAp;
   721     QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
   527     wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testDeleteIapOk");
   722     wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testDeleteIapOk");
   528     wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 );
   723     int iapId = wlanQtUtils_->createIap(wlanAp.data());
   529     wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
       
   530     wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen);
       
   531     wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
       
   532     int iapId = wlanQtUtils_->createIap(&wlanAp);
       
   533 
   724 
   534     // Check that IAP now exists
   725     // Check that IAP now exists
   535     QString name = wlanQtUtils_->iapName(iapId);
   726     QString name = wlanQtUtils_->iapName(iapId);
   536     QCOMPARE(name, QString("testDeleteIapOk"));
   727     QCOMPARE(name, QString("testDeleteIapOk"));
   537     
   728     
   621  * This function tests IAP disconnecting functionality.
   812  * This function tests IAP disconnecting functionality.
   622  */
   813  */
   623 void TestWlanQtUtils::testDisconnectIapOk()
   814 void TestWlanQtUtils::testDisconnectIapOk()
   624 {
   815 {
   625     // Create and connect an IAP we can then disconnect
   816     // Create and connect an IAP we can then disconnect
   626     WlanQtUtilsAp wlanAp;
   817     QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
   627     wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testDisconnectIapOk");
   818     wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testDisconnectIapOk");
   628     wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 );
   819     wlanAp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
   629     wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
   820 
   630     wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
   821     int iapId = wlanQtUtils_->createIap(wlanAp.data());
   631     wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
       
   632 
       
   633     int iapId = wlanQtUtils_->createIap(&wlanAp);
       
   634     testContext.esock_.startRetValue_ = KErrNone;
   822     testContext.esock_.startRetValue_ = KErrNone;
   635     wlanQtUtils_->connectIap(iapId);
   823     wlanQtUtils_->connectIap(iapId);
   636     QList<QVariant> arguments;
   824     QList<QVariant> arguments;
   637     subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments); 
   825     subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments); 
   638     QCOMPARE(arguments.at(0).toInt(), iapId); 
   826     QCOMPARE(arguments.at(0).toInt(), iapId); 
   701  * This function tests IAP name getter with existing IAP ID.
   889  * This function tests IAP name getter with existing IAP ID.
   702  */
   890  */
   703 void TestWlanQtUtils::testIapNameFound()
   891 void TestWlanQtUtils::testIapNameFound()
   704 {
   892 {
   705     // Create the IAP we want to find with the getter
   893     // Create the IAP we want to find with the getter
   706     WlanQtUtilsAp wlanAp;
   894     QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
   707     wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testIapFound");
   895     wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testIapFound");
   708     wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 );
   896     wlanAp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2);
   709     wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
   897 
   710     wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2);
   898     int iapId = wlanQtUtils_->createIap(wlanAp.data());
   711     wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
       
   712 
       
   713     int iapId = wlanQtUtils_->createIap(&wlanAp);
       
   714     
   899     
   715     // Execute the function under test and check that we got the correct name
   900     // Execute the function under test and check that we got the correct name
   716     QString name = wlanQtUtils_->iapName(iapId);
   901     QString name = wlanQtUtils_->iapName(iapId);
   717     QCOMPARE(name, QString("testIapFound"));
   902     QCOMPARE(name, QString("testIapFound"));
   718 }
   903 }
   737  * This function tests active WLAN IAP getter with existing connection.
   922  * This function tests active WLAN IAP getter with existing connection.
   738  */
   923  */
   739 void TestWlanQtUtils::testActiveIapFound()
   924 void TestWlanQtUtils::testActiveIapFound()
   740 {
   925 {
   741     // Create the IAP we want to find with the getter
   926     // Create the IAP we want to find with the getter
   742     WlanQtUtilsAp wlanAp;
   927     QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
   743     wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testConnectedWlanIdFound");
   928     wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testConnectedWlanIdFound");
   744     wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 );
   929     wlanAp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
   745     wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
   930 
   746     wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
   931     int iapId = wlanQtUtils_->createIap(wlanAp.data());
   747     wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
       
   748 
       
   749     int iapId = wlanQtUtils_->createIap(&wlanAp);
       
   750     
   932     
   751     testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, iapId);
   933     testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, iapId);
   752 
   934 
   753     // Send event for connection creation.
   935     // Send event for connection creation.
   754     wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
   936     wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
   755             EConnMonCreateConnection,
   937         EConnMonCreateConnection,
   756             testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
   938         testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
   757 
   939 
   758     // Send events for connection status change -> opened.
   940     // Send events for connection status change -> opened.
   759     wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
   941     wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
   760         testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
   942         testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
   761         0,
   943         0,
   811     // Execute function under test
   993     // Execute function under test
   812     wlanQtUtils_->scanWlans();
   994     wlanQtUtils_->scanWlans();
   813 
   995 
   814     // No need to verify scan results here, testAvailableWlan* test cases
   996     // No need to verify scan results here, testAvailableWlan* test cases
   815     // are for that. Just make sure the result signal is received.
   997     // are for that. Just make sure the result signal is received.
   816     subTestSignalWaitAndTake(signalScanReady_, NULL);
   998     subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
   817 }
   999 }
   818 
  1000 
   819 /**
  1001 /**
   820  * Test WLAN scan triggering interface with two consecutive requests.
  1002  * Test WLAN scan result ignoring & deletion during an ongoing request.
   821  */
  1003  */
   822 void TestWlanQtUtils::testScanWlansIgnored()
  1004 void TestWlanQtUtils::testScanWlansIgnored()
   823 {
  1005 {
   824     // Do not complete scan request immediately
  1006     // Do not complete scan request immediately
   825     testContext.connMon_.wlanScanResult_.completeWlanScan_ = false;
  1007     testContext.mScan.mCompleteWlanScan = false;
   826     
  1008     
   827     // Execute function under test
  1009     // Execute function under test
   828     wlanQtUtils_->scanWlans();
  1010     wlanQtUtils_->scanWlans();
   829 
  1011 
   830     // Execute function under test again -> this one is ignored
       
   831     wlanQtUtils_->scanWlans();
       
   832     
       
   833     // Ongoing scan is cancelled in destructors
  1012     // Ongoing scan is cancelled in destructors
   834 }
  1013 }
   835 
  1014 
   836 /**
  1015 /**
   837  * Test WLAN scan stopping interface when scan is active.
  1016  * Test WLAN scan stopping interface when scan is active.
   838  */
  1017  */
   839 void TestWlanQtUtils::testStopWlanScanOk()
  1018 void TestWlanQtUtils::testStopWlanScanOk()
   840 {
  1019 {
   841     // Do not complete scan request immediately
  1020     // Do not complete scan request immediately
   842     testContext.connMon_.wlanScanResult_.completeWlanScan_ = false;
  1021     testContext.mScan.mCompleteWlanScan = false;
   843     // Start a scan
  1022     // Start a scan
   844     wlanQtUtils_->scanWlans();
  1023     wlanQtUtils_->scanWlans();
   845     // Execute function under test
  1024     // Execute function under test
   846     wlanQtUtils_->stopWlanScan();
  1025     wlanQtUtils_->stopWlanScan();
   847     
  1026 
   848     // No return values or signals to verify
  1027     // Catch & check the scan result signal
       
  1028     subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusCancelled);
   849 }
  1029 }
   850 
  1030 
   851 /**
  1031 /**
   852  * Test WLAN scan stopping interface when no scan is ongoing.
  1032  * Test WLAN scan stopping interface when no scan is ongoing.
   853  */
  1033  */
   854 void TestWlanQtUtils::testStopWlanScanIgnored()
  1034 void TestWlanQtUtils::testStopWlanScanIgnored()
   855 {
  1035 {
   856     // Execute function under test
  1036     // Stop without having an active scan
   857     wlanQtUtils_->stopWlanScan();
  1037     wlanQtUtils_->stopWlanScan();
   858     
  1038     
   859     // No return values or signals to verify
  1039     // No return values or signals to verify
   860 }
  1040 }
   861 
  1041 
   943  */
  1123  */
   944 void TestWlanQtUtils::testApCopyConstructor()
  1124 void TestWlanQtUtils::testApCopyConstructor()
   945 {
  1125 {
   946     WlanQtUtilsAp firstAp;
  1126     WlanQtUtilsAp firstAp;
   947     firstAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testApCopyConstructor");
  1127     firstAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testApCopyConstructor");
   948     firstAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 );
  1128     firstAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90);
   949     firstAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
  1129     firstAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
   950     firstAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
  1130     firstAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
   951     firstAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true);    
  1131     firstAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true);    
   952     firstAp.setValue(WlanQtUtilsAp::ConfIdWpaPsk, "100euronlounas");
  1132     firstAp.setValue(WlanQtUtilsAp::ConfIdWpaPsk, "100euronlounas");
   953     
  1133     
   965  * This function tests ICT when connection test passes.
  1145  * This function tests ICT when connection test passes.
   966  */
  1146  */
   967 void TestWlanQtUtils::testConnectionTestOk()
  1147 void TestWlanQtUtils::testConnectionTestOk()
   968 {
  1148 {
   969     // Create new IAP to test
  1149     // Create new IAP to test
   970     WlanQtUtilsAp wlanAp;
  1150     QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
   971     wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testConnectionTestOk");
  1151     wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testConnectionTestOk");
   972     wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 );
  1152     int iapId = wlanQtUtils_->createIap(wlanAp.data());
   973     wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
       
   974     wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen);
       
   975     wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
       
   976     int iapId = wlanQtUtils_->createIap(&wlanAp);
       
   977     QVERIFY(iapId != WlanQtUtils::IapIdNone);
  1153     QVERIFY(iapId != WlanQtUtils::IapIdNone);
   978 
  1154 
   979     testContext.esock_.startRetValue_ = KErrNone;
  1155     testContext.esock_.startRetValue_ = KErrNone;
   980 
  1156 
   981     // Esock stub completes connection creation immediately
  1157     // Esock stub completes connection creation immediately
  1005         0,
  1181         0,
  1006         KLinkLayerOpen));
  1182         KLinkLayerOpen));
  1007 
  1183 
  1008     // Connection test automatically started at this point. Call result function explicitly
  1184     // Connection test automatically started at this point. Call result function explicitly
  1009     // No interface exists that we could check that the IAP is moved to Internet SNAP correctly
  1185     // No interface exists that we could check that the IAP is moved to Internet SNAP correctly
       
  1186 #if 0       // TODO: Make this work with the new WLAN login interface 
  1010     TBuf<5> string;
  1187     TBuf<5> string;
  1011     wlanQtUtils_->d_ptr->mConnTestWrapper->d_ptr_->ConnectivityObserver(EConnectionOk, string);
  1188     wlanQtUtils_->d_ptr->mConnTestWrapper->d_ptr_->ConnectivityObserver(EConnectionOk, string);
  1012 
  1189 
  1013     subTestSignalWaitAndTake(signalIctResult_, &arguments); 
  1190     subTestSignalWaitAndTake(signalIctResult_, &arguments); 
  1014     QCOMPARE(arguments.at(0).toInt(), iapId); 
  1191     QCOMPARE(arguments.at(0).toInt(), iapId); 
  1015     QCOMPARE(arguments.at(1).toBool(), true);
  1192     QCOMPARE(arguments.at(1).toBool(), true);
       
  1193 #endif    
  1016 }
  1194 }
  1017 
  1195 
  1018 /**
  1196 /**
  1019  * This function tests ICT when connection test fails.
  1197  * This function tests ICT when connection test fails.
  1020  */
  1198  */
  1021 void TestWlanQtUtils::testConnectionTestErr()
  1199 void TestWlanQtUtils::testConnectionTestErr()
  1022 {
  1200 {
  1023     // Create and connect an IAP and request ICT to be run
  1201     // Create and connect an IAP and request ICT to be run
  1024     WlanQtUtilsAp wlanAp;
  1202     QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
  1025     wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testConnectionTestErr");
  1203     wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testConnectionTestErr");
  1026     wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 );
  1204     wlanAp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
  1027     wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
  1205     
  1028     wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
  1206     int iapId = wlanQtUtils_->createIap(wlanAp.data());
  1029     wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
       
  1030     
       
  1031     int iapId = wlanQtUtils_->createIap(&wlanAp);
       
  1032     wlanQtUtils_->connectIap(iapId, true);
  1207     wlanQtUtils_->connectIap(iapId, true);
  1033 
  1208 
  1034     testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, iapId);
  1209     testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, iapId);
  1035     wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
  1210     wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
  1036             EConnMonCreateConnection,
  1211             EConnMonCreateConnection,
  1048         0,
  1223         0,
  1049         KLinkLayerOpen));
  1224         KLinkLayerOpen));
  1050 
  1225 
  1051     // Connection test automatically started at this point. Call result function explicitly
  1226     // Connection test automatically started at this point. Call result function explicitly
  1052     // No interface exists that we could check that IAP is not moved to another SNAP
  1227     // No interface exists that we could check that IAP is not moved to another SNAP
       
  1228 #if 0       // TODO: Make this work with the new WLAN login interface 
  1053     TBuf<5> string;
  1229     TBuf<5> string;
  1054     wlanQtUtils_->d_ptr->mConnTestWrapper->d_ptr_->ConnectivityObserver(EHttpAuthenticationNeeded, string);
  1230     wlanQtUtils_->d_ptr->mConnTestWrapper->d_ptr_->ConnectivityObserver(EHttpAuthenticationNeeded, string);
  1055 
  1231 
  1056     subTestSignalWaitAndTake(signalIctResult_, &arguments); 
  1232     subTestSignalWaitAndTake(signalIctResult_, &arguments); 
  1057     QCOMPARE(arguments.at(0).toInt(), iapId); 
  1233     QCOMPARE(arguments.at(0).toInt(), iapId); 
  1058     QCOMPARE(arguments.at(1).toBool(), false);
  1234     QCOMPARE(arguments.at(1).toBool(), false);
       
  1235 #endif
  1059 }
  1236 }
  1060 
  1237 
  1061 /**
  1238 /**
  1062  * This function tests that Gprs connection events are ignored.
  1239  * This function tests that Gprs connection events are ignored.
  1063  */
  1240  */
  1162     QCOMPARE(spy->count(), 1);
  1339     QCOMPARE(spy->count(), 1);
  1163     QList<QVariant> arguments_tmp = spy->takeFirst();
  1340     QList<QVariant> arguments_tmp = spy->takeFirst();
  1164     if (arguments != NULL) {
  1341     if (arguments != NULL) {
  1165         *arguments = arguments_tmp;
  1342         *arguments = arguments_tmp;
  1166     }
  1343     }
       
  1344 }
       
  1345 
       
  1346 /**
       
  1347  * Test case for catching and verifying the scan result signal.
       
  1348  * 
       
  1349  * @param [in] status Scan result status.
       
  1350  */
       
  1351 void TestWlanQtUtils::subTestScanResultSignal(QSignalSpy* spy, int status)
       
  1352 {
       
  1353     QList<QVariant> arguments;
       
  1354     subTestSignalWaitAndTake(spy, &arguments);
       
  1355     QCOMPARE(arguments.length(), 1);
       
  1356     QCOMPARE(arguments.at(0).toInt(), status);
  1167 }
  1357 }
  1168 
  1358 
  1169 /**
  1359 /**
  1170  * This function loads given CommsDat file, replacing current one.
  1360  * This function loads given CommsDat file, replacing current one.
  1171  * If CommsDat file doesn't exist, it can be re-created by commanding WST script.
  1361  * If CommsDat file doesn't exist, it can be re-created by commanding WST script.
  1195 /**
  1385 /**
  1196  * 
  1386  * 
  1197  */
  1387  */
  1198 void TestWlanQtUtils::subTestNewWlanQtUtils()
  1388 void TestWlanQtUtils::subTestNewWlanQtUtils()
  1199 {
  1389 {
  1200     if (wlanQtUtils_ != NULL) {
  1390     delete wlanQtUtils_;
  1201         delete wlanQtUtils_;
       
  1202     }
       
  1203     wlanQtUtils_ = new WlanQtUtils();
  1391     wlanQtUtils_ = new WlanQtUtils();
  1204 
  1392 
  1205     if (signalScanReady_ != NULL) {
  1393     delete mSignalScanReady;
  1206         delete signalScanReady_;
  1394     mSignalScanReady = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanScanReady(int)));
  1207     }
  1395     QVERIFY(mSignalScanReady->isValid() == true);
  1208     signalScanReady_ = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanScanReady()));
  1396 
  1209     QVERIFY(signalScanReady_->isValid() == true);
  1397     delete mSignalScanApReady;
  1210 
  1398     mSignalScanApReady = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanScanApReady(int)));
  1211     if (signalWlanNetworkOpened_ != NULL) {
  1399     QVERIFY(mSignalScanApReady->isValid() == true);
  1212         delete signalWlanNetworkOpened_;
  1400 
  1213     }
  1401     delete mSignalScanDirectReady;
       
  1402     mSignalScanDirectReady = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanScanDirectReady(int)));
       
  1403     QVERIFY(mSignalScanDirectReady->isValid() == true);
       
  1404 
       
  1405     delete signalWlanNetworkOpened_;
  1214     signalWlanNetworkOpened_ = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanNetworkOpened(int)));
  1406     signalWlanNetworkOpened_ = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanNetworkOpened(int)));
  1215     QVERIFY(signalWlanNetworkOpened_->isValid() == true);
  1407     QVERIFY(signalWlanNetworkOpened_->isValid() == true);
  1216     
  1408     
  1217     if (signalWlanNetworkClosed_ != NULL) {
  1409     delete signalWlanNetworkClosed_;
  1218         delete signalWlanNetworkClosed_;
       
  1219     }
       
  1220     signalWlanNetworkClosed_ = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanNetworkClosed(int, int)));
  1410     signalWlanNetworkClosed_ = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanNetworkClosed(int, int)));
  1221     QVERIFY(signalWlanNetworkClosed_->isValid() == true);
  1411     QVERIFY(signalWlanNetworkClosed_->isValid() == true);
  1222     
  1412     
  1223     if (signalIctResult_ != NULL) {
  1413     delete signalIctResult_;
  1224         delete signalIctResult_;
  1414     signalIctResult_ = new QSignalSpy(wlanQtUtils_, SIGNAL(ictResult(int, int)));
  1225     }
       
  1226     signalIctResult_ = new QSignalSpy(wlanQtUtils_, SIGNAL(ictResult(int, bool)));
       
  1227     QVERIFY(signalIctResult_->isValid() == true);
  1415     QVERIFY(signalIctResult_->isValid() == true);
  1228 }
  1416 }
       
  1417 
       
  1418 /**
       
  1419  * Create a new AP and fill it with default values. 
       
  1420  */
       
  1421 WlanQtUtilsAp *TestWlanQtUtils::subTestNewAp()
       
  1422 {
       
  1423     WlanQtUtilsAp *ap = new WlanQtUtilsAp;
       
  1424 
       
  1425     // Set default values
       
  1426     ap->setValue(WlanQtUtilsAp::ConfIdSsid, QString());
       
  1427     ap->setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90);
       
  1428     ap->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
       
  1429     ap->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen);
       
  1430     ap->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
       
  1431     ap->setValue(WlanQtUtilsAp::ConfIdWpaPsk, QString());
       
  1432     ap->setValue(WlanQtUtilsAp::ConfIdWepKey1, QString());
       
  1433     ap->setValue(WlanQtUtilsAp::ConfIdWepKey2, QString());
       
  1434     ap->setValue(WlanQtUtilsAp::ConfIdWepKey3, QString());
       
  1435     ap->setValue(WlanQtUtilsAp::ConfIdWepKey4, QString());
       
  1436     ap->setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex1);
       
  1437     ap->setValue(WlanQtUtilsAp::ConfIdHidden, false);
       
  1438 
       
  1439     return ap;
       
  1440 }