31
|
1 |
/*
|
|
2 |
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* This is the source file for testing Wlan Qt Utilities library.
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <QApplication>
|
|
19 |
#include <QtCore>
|
|
20 |
#include <QTest>
|
|
21 |
#include <QSignalSpy>
|
|
22 |
#include <QSharedPointer>
|
|
23 |
#include <rconnmon.h>
|
|
24 |
#include <nifvar.h>
|
|
25 |
#include <cmmanagerdefines_shim.h>
|
|
26 |
|
|
27 |
#include "wlanqtutilsap.h"
|
|
28 |
#include "wlanqtutils.h"
|
|
29 |
#include "wlanqtutils_p.h"
|
|
30 |
#include "wlanqtutilsconmonwrapper.h"
|
39
|
31 |
#include "wlanqtutilsconmonwrapperinfo_symbian.h"
|
31
|
32 |
#include "testwlanqtutils.h"
|
|
33 |
#include "wlanqtutilstestcontext.h"
|
|
34 |
|
|
35 |
WlanQtUtilsTestContext testContext;
|
|
36 |
|
|
37 |
const QString TestWlanQtUtils::commsDatDefault_ = "default.cre";
|
|
38 |
|
|
39 |
// ---------------------------------------------------------
|
|
40 |
// FRAMEWORK FUNCTIONS
|
|
41 |
// ---------------------------------------------------------
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Test main function. Runs all test cases.
|
|
45 |
*/
|
|
46 |
int main(int argc, char *argv[])
|
|
47 |
{
|
|
48 |
QApplication app(argc, argv);
|
|
49 |
|
|
50 |
char *pass[3];
|
|
51 |
pass[0] = argv[0];
|
|
52 |
pass[1] = "-o";
|
|
53 |
pass[2] = "c:\\data\\wlanqtutils_qtest_log.txt";
|
|
54 |
|
|
55 |
TestWlanQtUtils tc;
|
|
56 |
int res = QTest::qExec(&tc, 3, pass);
|
|
57 |
|
|
58 |
return res;
|
|
59 |
}
|
|
60 |
|
|
61 |
/**
|
|
62 |
* This function will be called before the first test function is executed.
|
|
63 |
*/
|
|
64 |
void TestWlanQtUtils::initTestCase()
|
|
65 |
{
|
|
66 |
wlanQtUtils_ = NULL;
|
39
|
67 |
mSignalScanReady = NULL;
|
|
68 |
mSignalScanApReady = NULL;
|
|
69 |
mSignalScanDirectReady = NULL;
|
31
|
70 |
signalWlanNetworkOpened_ = NULL;
|
|
71 |
signalWlanNetworkClosed_ = NULL;
|
|
72 |
signalIctResult_ = NULL;
|
|
73 |
|
|
74 |
//If Active scheduler exists then don't install a new one as it will cause panic
|
|
75 |
if (CActiveScheduler::Current() == NULL) {
|
|
76 |
CActiveScheduler *scheduler = new CActiveScheduler();
|
|
77 |
CActiveScheduler::Install(scheduler);
|
|
78 |
}
|
|
79 |
}
|
|
80 |
|
|
81 |
/**
|
|
82 |
* This function will be called after the last test function was executed.
|
|
83 |
*/
|
|
84 |
void TestWlanQtUtils::cleanupTestCase()
|
|
85 |
{
|
|
86 |
// CommsDat file is initialized.
|
|
87 |
subTestLoadCommsDatFile(commsDatDefault_);
|
|
88 |
}
|
|
89 |
|
|
90 |
/**
|
|
91 |
* This function will be called before each test function is executed.
|
|
92 |
*/
|
|
93 |
void TestWlanQtUtils::init()
|
|
94 |
{
|
|
95 |
// CommsDat file is initialized.
|
|
96 |
subTestLoadCommsDatFile(commsDatDefault_);
|
|
97 |
|
|
98 |
testContext.initialize();
|
|
99 |
|
|
100 |
QVERIFY(wlanQtUtils_ == NULL);
|
39
|
101 |
QVERIFY(mSignalScanReady == NULL);
|
|
102 |
QVERIFY(mSignalScanApReady == NULL);
|
|
103 |
QVERIFY(mSignalScanDirectReady == NULL);
|
31
|
104 |
QVERIFY(signalWlanNetworkOpened_ == NULL);
|
|
105 |
QVERIFY(signalWlanNetworkClosed_ == NULL);
|
|
106 |
QVERIFY(signalIctResult_ == NULL);
|
|
107 |
subTestNewWlanQtUtils();
|
|
108 |
}
|
|
109 |
|
|
110 |
/**
|
|
111 |
* This function will be called after each test function is executed.
|
|
112 |
*/
|
|
113 |
void TestWlanQtUtils::cleanup()
|
|
114 |
{
|
|
115 |
delete wlanQtUtils_;
|
|
116 |
wlanQtUtils_ = NULL;
|
|
117 |
|
39
|
118 |
QCOMPARE(mSignalScanReady->count(), 0);
|
|
119 |
delete mSignalScanReady;
|
|
120 |
mSignalScanReady = NULL;
|
|
121 |
|
|
122 |
QCOMPARE(mSignalScanApReady->count(), 0);
|
|
123 |
delete mSignalScanApReady;
|
|
124 |
mSignalScanApReady = NULL;
|
|
125 |
|
|
126 |
QCOMPARE(mSignalScanDirectReady->count(), 0);
|
|
127 |
delete mSignalScanDirectReady;
|
|
128 |
mSignalScanDirectReady = NULL;
|
31
|
129 |
|
|
130 |
QCOMPARE(signalWlanNetworkOpened_->count(), 0);
|
|
131 |
delete signalWlanNetworkOpened_;
|
|
132 |
signalWlanNetworkOpened_ = NULL;
|
|
133 |
|
|
134 |
QCOMPARE(signalWlanNetworkClosed_->count(), 0);
|
|
135 |
delete signalWlanNetworkClosed_;
|
|
136 |
signalWlanNetworkClosed_ = NULL;
|
|
137 |
|
|
138 |
QCOMPARE(signalIctResult_->count(), 0);
|
|
139 |
delete signalIctResult_;
|
|
140 |
signalIctResult_ = NULL;
|
|
141 |
}
|
|
142 |
|
|
143 |
// ---------------------------------------------------------
|
|
144 |
// TEST CASES
|
|
145 |
// ---------------------------------------------------------
|
|
146 |
|
|
147 |
/**
|
|
148 |
* Test available WLAN APs when scan is triggered by client.
|
|
149 |
*/
|
|
150 |
void TestWlanQtUtils::testAvailableWlan()
|
|
151 |
{
|
53
|
152 |
testContext.mScan.createDefaultWlanScanApResultList(4);
|
31
|
153 |
|
|
154 |
// Request a scan to get result signal
|
|
155 |
wlanQtUtils_->scanWlans();
|
|
156 |
|
|
157 |
// Let active object run and verify signal.
|
39
|
158 |
subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
|
31
|
159 |
|
|
160 |
// Get and verify the list of available WLAN APs.
|
60
|
161 |
QList< QSharedPointer<WlanQtUtilsAp> > iaps;
|
31
|
162 |
QList< QSharedPointer<WlanQtUtilsAp> > aps;
|
|
163 |
wlanQtUtils_->availableWlans(iaps, aps);
|
|
164 |
|
53
|
165 |
testContext.mScan.verifyWlanScanApResultList(aps);
|
31
|
166 |
QCOMPARE(iaps.count(), 0);
|
|
167 |
aps.clear();
|
|
168 |
}
|
|
169 |
|
|
170 |
/**
|
|
171 |
* Test available WLAN APs when scan is triggered by client.
|
|
172 |
* Two scan results have the same SSID and the latter one of those will be removed.
|
|
173 |
* Two scan results have the same SSID but different security mode
|
|
174 |
* Two scan results have the same SSID and security mode but different WpaPsk value
|
|
175 |
* and both are included in the results.
|
39
|
176 |
* Two scan results have the same SSID but different connection mode
|
31
|
177 |
*/
|
|
178 |
void TestWlanQtUtils::testAvailableWlanDuplicates()
|
|
179 |
{
|
53
|
180 |
testContext.mScan.createDefaultWlanScanApResultList(11);
|
|
181 |
testContext.mScan.mWlanScanApResultList[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID");
|
|
182 |
testContext.mScan.mWlanScanApResultList[2]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID");
|
|
183 |
testContext.mScan.mWlanScanApResultList[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID, different SecMode");
|
|
184 |
testContext.mScan.mWlanScanApResultList[5]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa);
|
|
185 |
testContext.mScan.mWlanScanApResultList[6]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID, different SecMode");
|
|
186 |
testContext.mScan.mWlanScanApResultList[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeOpen);
|
|
187 |
testContext.mScan.mWlanScanApResultList[7]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID & SecMode diff Psk");
|
|
188 |
testContext.mScan.mWlanScanApResultList[7]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2);
|
|
189 |
testContext.mScan.mWlanScanApResultList[9]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID & SecMode diff Psk");
|
|
190 |
testContext.mScan.mWlanScanApResultList[9]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2);
|
|
191 |
testContext.mScan.mWlanScanApResultList[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true);
|
|
192 |
testContext.mScan.mWlanScanApResultList[10]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID");
|
|
193 |
testContext.mScan.mWlanScanApResultList[10]->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Adhoc);
|
31
|
194 |
|
|
195 |
// Request a scan to get result signal
|
|
196 |
wlanQtUtils_->scanWlans();
|
|
197 |
|
|
198 |
// Let active object run and verify signal.
|
39
|
199 |
subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
|
31
|
200 |
|
|
201 |
// Get and verify the list of available WLAN APs.
|
60
|
202 |
QList< QSharedPointer<WlanQtUtilsAp> > iaps;
|
31
|
203 |
QList< QSharedPointer<WlanQtUtilsAp> > aps;
|
|
204 |
wlanQtUtils_->availableWlans(iaps, aps);
|
|
205 |
|
|
206 |
// First remove AP that has duplicate SSID.
|
53
|
207 |
testContext.mScan.mWlanScanApResultList.removeAt(2);
|
|
208 |
testContext.mScan.verifyWlanScanApResultList(aps);
|
31
|
209 |
QCOMPARE(iaps.count(), 0);
|
|
210 |
aps.clear();
|
|
211 |
}
|
|
212 |
|
|
213 |
/**
|
|
214 |
* Test available WLAN APs when scan is triggered by client.
|
|
215 |
* Include all supported security modes.
|
|
216 |
*/
|
|
217 |
void TestWlanQtUtils::testAvailableWlanSecModes()
|
|
218 |
{
|
53
|
219 |
testContext.mScan.createDefaultWlanScanApResultList(11);
|
|
220 |
testContext.mScan.mWlanScanApResultList[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen);
|
|
221 |
testContext.mScan.mWlanScanApResultList[0]->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Adhoc);
|
|
222 |
testContext.mScan.mWlanScanApResultList[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWep);
|
|
223 |
testContext.mScan.mWlanScanApResultList[2]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWep);
|
|
224 |
testContext.mScan.mWlanScanApResultList[3]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecMode802_1x);
|
|
225 |
testContext.mScan.mWlanScanApResultList[4]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
|
|
226 |
testContext.mScan.mWlanScanApResultList[5]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
|
|
227 |
testContext.mScan.mWlanScanApResultList[5]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true);
|
|
228 |
testContext.mScan.mWlanScanApResultList[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2);
|
|
229 |
testContext.mScan.mWlanScanApResultList[7]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2);
|
|
230 |
testContext.mScan.mWlanScanApResultList[7]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true);
|
|
231 |
testContext.mScan.mWlanScanApResultList[8]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWapi);
|
|
232 |
testContext.mScan.mWlanScanApResultList[9]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWapi);
|
31
|
233 |
// Let's trick the stub to return WapiPsk by putting WpaPskUse on *
|
53
|
234 |
testContext.mScan.mWlanScanApResultList[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true);
|
|
235 |
testContext.mScan.mWlanScanApResultList[10]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2);
|
|
236 |
testContext.mScan.mWlanScanApResultList[10]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true);
|
|
237 |
testContext.mScan.mWlanScanApResultList[10]->setValue(WlanQtUtilsAp::ConfIdWpsSupported, true);
|
31
|
238 |
|
|
239 |
// Request a scan to get result signal
|
|
240 |
wlanQtUtils_->scanWlans();
|
|
241 |
|
|
242 |
// Let active object run and verify signal.
|
39
|
243 |
subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
|
31
|
244 |
|
|
245 |
// Get and verify the list of available WLAN APs.
|
60
|
246 |
QList< QSharedPointer<WlanQtUtilsAp> > iaps;
|
31
|
247 |
QList< QSharedPointer<WlanQtUtilsAp> > aps;
|
|
248 |
wlanQtUtils_->availableWlans(iaps, aps);
|
|
249 |
|
|
250 |
// Remove the trick *. WapiPsk and Wapi both map to just Wapi
|
53
|
251 |
testContext.mScan.mWlanScanApResultList[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,false);
|
|
252 |
testContext.mScan.verifyWlanScanApResultList(aps);
|
31
|
253 |
QCOMPARE(iaps.count(), 0);
|
|
254 |
aps.clear();
|
|
255 |
}
|
|
256 |
|
|
257 |
/**
|
|
258 |
* Test available WLAN APs when scan is triggered by client.
|
|
259 |
* Include some exotic ssids.
|
|
260 |
*/
|
|
261 |
void TestWlanQtUtils::testAvailableWlanSsids()
|
|
262 |
{
|
53
|
263 |
testContext.mScan.createDefaultWlanScanApResultList(6);
|
|
264 |
testContext.mScan.mWlanScanApResultList[1]->setValue(WlanQtUtilsAp::ConfIdSsid, " ");
|
|
265 |
testContext.mScan.mWlanScanApResultList[2]->setValue(WlanQtUtilsAp::ConfIdSsid, " whitespace around ssid ");
|
|
266 |
testContext.mScan.mWlanScanApResultList[3]->setValue(WlanQtUtilsAp::ConfIdSsid, QString(QChar()));
|
|
267 |
testContext.mScan.mWlanScanApResultList[4]->setValue(WlanQtUtilsAp::ConfIdSsid, "maximum length ssid that is 32 c");
|
|
268 |
testContext.mScan.mWlanScanApResultList[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "A");
|
31
|
269 |
|
|
270 |
// Request a scan to get result signal
|
|
271 |
wlanQtUtils_->scanWlans();
|
|
272 |
|
|
273 |
// Let active object run and verify signal.
|
39
|
274 |
subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
|
31
|
275 |
|
|
276 |
// Get and verify the list of available WLAN APs.
|
60
|
277 |
QList< QSharedPointer<WlanQtUtilsAp> > iaps;
|
31
|
278 |
QList< QSharedPointer<WlanQtUtilsAp> > aps;
|
|
279 |
wlanQtUtils_->availableWlans(iaps, aps);
|
|
280 |
|
|
281 |
// Empty ssids are removed from results
|
53
|
282 |
testContext.mScan.mWlanScanApResultList.removeAt(3);
|
|
283 |
testContext.mScan.mWlanScanApResultList.removeAt(1);
|
|
284 |
testContext.mScan.verifyWlanScanApResultList(aps);
|
31
|
285 |
QCOMPARE(iaps.count(), 0);
|
|
286 |
}
|
|
287 |
|
|
288 |
/**
|
|
289 |
* Test available WLAN APs when there are also WLAN IAPs available.
|
|
290 |
*/
|
|
291 |
void TestWlanQtUtils::testAvailableWlanWithIaps()
|
|
292 |
{
|
53
|
293 |
// Form WLAN IAP scan result list
|
|
294 |
testContext.mScan.createDefaultWlanScanIapResultList(3);
|
|
295 |
testContext.mScan.mWlanScanIapResultList.removeAt(1);
|
60
|
296 |
testContext.mScan.mWlanScanIapResultList[0]->setValue(WlanQtUtilsAp::ConfIdIapId, 5);
|
|
297 |
testContext.mScan.mWlanScanIapResultList[1]->setValue(WlanQtUtilsAp::ConfIdIapId, 7);
|
53
|
298 |
|
|
299 |
// Form WLAN AP scan result list
|
|
300 |
testContext.mScan.createDefaultWlanScanApResultList(7);
|
|
301 |
testContext.mScan.mWlanScanApResultList[1]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 3");
|
|
302 |
testContext.mScan.mWlanScanApResultList[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa);
|
|
303 |
testContext.mScan.mWlanScanApResultList[1]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true);
|
|
304 |
testContext.mScan.mWlanScanApResultList[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 1");
|
31
|
305 |
// SSID is found in Internet Snap, but security mode does not match:
|
53
|
306 |
testContext.mScan.mWlanScanApResultList[6]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 2");
|
|
307 |
testContext.mScan.mWlanScanApResultList[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa);
|
|
308 |
|
31
|
309 |
// Request a scan to get result signal
|
|
310 |
wlanQtUtils_->scanWlans();
|
|
311 |
|
|
312 |
// Let active object run and verify signal.
|
39
|
313 |
subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
|
31
|
314 |
|
|
315 |
// Get and verify the list of available WLAN APs.
|
60
|
316 |
QList< QSharedPointer<WlanQtUtilsAp> > iaps;
|
31
|
317 |
QList< QSharedPointer<WlanQtUtilsAp> > aps;
|
|
318 |
wlanQtUtils_->availableWlans(iaps, aps);
|
|
319 |
|
53
|
320 |
// Verify WLAN IAP list
|
|
321 |
testContext.mScan.verifyWlanScanIapResultList(iaps);
|
|
322 |
|
31
|
323 |
// Verify WLAN AP list. First, remove scan results that will not appear
|
|
324 |
// because they are WLAN IAPs.
|
53
|
325 |
testContext.mScan.mWlanScanApResultList.removeAt(5);
|
|
326 |
testContext.mScan.mWlanScanApResultList.removeAt(1);
|
|
327 |
testContext.mScan.verifyWlanScanApResultList(aps);
|
|
328 |
|
31
|
329 |
iaps.clear();
|
|
330 |
aps.clear();
|
|
331 |
}
|
|
332 |
|
|
333 |
/**
|
|
334 |
* Test refereshing of WLAN APs when client requests sequential scans.
|
|
335 |
*/
|
|
336 |
void TestWlanQtUtils::testAvailableWlanSequence()
|
|
337 |
{
|
|
338 |
// **************** Before 1st scan ********************
|
60
|
339 |
QList< QSharedPointer<WlanQtUtilsAp> > iaps;
|
31
|
340 |
QList< QSharedPointer<WlanQtUtilsAp> > aps;
|
|
341 |
wlanQtUtils_->availableWlans(iaps, aps);
|
|
342 |
// Verify we have no results
|
|
343 |
QCOMPARE(aps.count(), 0);
|
|
344 |
QCOMPARE(iaps.count(), 0);
|
|
345 |
|
|
346 |
// **************** 1st scan ********************
|
|
347 |
// 6 APs are required for this scan
|
53
|
348 |
testContext.mScan.createDefaultWlanScanApResultList(6);
|
31
|
349 |
|
|
350 |
wlanQtUtils_->scanWlans();
|
39
|
351 |
subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
|
31
|
352 |
|
|
353 |
// Get the results for the 1st scan
|
|
354 |
wlanQtUtils_->availableWlans(iaps, aps);
|
|
355 |
// Verify the results for the scan
|
53
|
356 |
testContext.mScan.verifyWlanScanApResultList(aps);
|
31
|
357 |
QCOMPARE(iaps.count(), 0);
|
|
358 |
aps.clear();
|
|
359 |
|
|
360 |
// **************** 2nd scan ********************
|
|
361 |
// 2 APs are required for this scan
|
53
|
362 |
testContext.mScan.createDefaultWlanScanApResultList(2);
|
31
|
363 |
|
|
364 |
wlanQtUtils_->scanWlans();
|
39
|
365 |
subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
|
31
|
366 |
|
|
367 |
// Get the results for the 2nd scan
|
|
368 |
wlanQtUtils_->availableWlans(iaps, aps);
|
|
369 |
// Verify the results for the scan
|
53
|
370 |
testContext.mScan.verifyWlanScanApResultList(aps);
|
31
|
371 |
QCOMPARE(iaps.count(), 0);
|
|
372 |
aps.clear();
|
|
373 |
|
|
374 |
// **************** 3rd scan ********************
|
|
375 |
// 4 APs are required for the 3rd scan
|
53
|
376 |
testContext.mScan.createDefaultWlanScanApResultList(4);
|
31
|
377 |
|
|
378 |
wlanQtUtils_->scanWlans();
|
39
|
379 |
subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
|
31
|
380 |
|
|
381 |
// Get the results for the 3rd scan
|
|
382 |
wlanQtUtils_->availableWlans(iaps, aps);
|
|
383 |
// Verify the results for the scan
|
53
|
384 |
testContext.mScan.verifyWlanScanApResultList(aps);
|
31
|
385 |
QCOMPARE(iaps.count(), 0);
|
|
386 |
aps.clear();
|
|
387 |
}
|
|
388 |
|
|
389 |
/**
|
39
|
390 |
* Test availability scan that finds nothing.
|
|
391 |
*/
|
|
392 |
void TestWlanQtUtils::testAvailableWlanScanEmpty()
|
|
393 |
{
|
|
394 |
// Form result list
|
53
|
395 |
testContext.mScan.createDefaultWlanScanApResultList(0);
|
39
|
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.
|
60
|
404 |
QList< QSharedPointer<WlanQtUtilsAp> > iaps;
|
39
|
405 |
QList< QSharedPointer<WlanQtUtilsAp> > aps;
|
|
406 |
wlanQtUtils_->availableWlans(iaps, aps);
|
53
|
407 |
testContext.mScan.verifyWlanScanApResultList(aps);
|
39
|
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
|
53
|
417 |
testContext.mScan.mApScanRetValue = KErrGeneral;
|
39
|
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 |
{
|
53
|
431 |
testContext.mScan.createDefaultWlanScanApResultList(4);
|
39
|
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 |
|
53
|
443 |
testContext.mScan.verifyWlanScanApResultList(aps);
|
39
|
444 |
aps.clear();
|
|
445 |
}
|
|
446 |
|
|
447 |
/**
|
|
448 |
* Test a direct scan that finds nothing.
|
|
449 |
*/
|
|
450 |
void TestWlanQtUtils::testAvailableWlanApsScanEmpty()
|
|
451 |
{
|
|
452 |
// Form result list
|
53
|
453 |
testContext.mScan.createDefaultWlanScanApResultList(0);
|
39
|
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);
|
53
|
464 |
testContext.mScan.verifyWlanScanApResultList(aps);
|
39
|
465 |
}
|
|
466 |
|
|
467 |
/**
|
|
468 |
* Test cancellation of WLAN AP scan.
|
|
469 |
*/
|
|
470 |
void TestWlanQtUtils::testStopWlanApScan()
|
|
471 |
{
|
|
472 |
// Do not complete scan request immediately
|
53
|
473 |
testContext.mScan.mCompleteWlanApScan = false;
|
39
|
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
|
53
|
490 |
testContext.mScan.mApScanRetValue = KErrGeneral;
|
39
|
491 |
|
|
492 |
// Start the scan
|
|
493 |
wlanQtUtils_->scanWlanAps();
|
|
494 |
|
|
495 |
// Catch & check the scan result signal
|
|
496 |
subTestScanResultSignal(mSignalScanApReady, WlanQtUtils::ScanStatusError);
|
|
497 |
}
|
|
498 |
|
|
499 |
/**
|
53
|
500 |
* Test WLAN AP scan with special characters.
|
|
501 |
*/
|
|
502 |
void TestWlanQtUtils::testAvailableWlanApsSpecialChars()
|
|
503 |
{
|
|
504 |
testContext.mScan.createDefaultWlanScanApResultList(3);
|
|
505 |
// Set SSID's to include special characters
|
|
506 |
testContext.mScan.mWlanScanApResultList[0]->setValue(
|
|
507 |
WlanQtUtilsAp::ConfIdSsid,
|
|
508 |
"\x57\x41\x50\x49\xBD\xA7\xA4\xE4\xF6");
|
|
509 |
testContext.mScan.mWlanScanApResultList[1]->setValue(
|
|
510 |
WlanQtUtilsAp::ConfIdSsid,
|
|
511 |
"\x01\x02\x03\xAB\x43\x52\x41\x50\xBB\xA7\xA4\xFE\xFF");
|
|
512 |
testContext.mScan.mWlanScanApResultList[2]->setValue(
|
|
513 |
WlanQtUtilsAp::ConfIdSsid,
|
|
514 |
"12345678901234567890123456789012"); // Maximum SSID length of 32 bytes
|
|
515 |
|
|
516 |
// Request a scan to get result signal
|
|
517 |
wlanQtUtils_->scanWlanAps();
|
|
518 |
|
|
519 |
// Let active object run and verify signal.
|
|
520 |
subTestScanResultSignal(mSignalScanApReady, WlanQtUtils::ScanStatusOk);
|
|
521 |
|
|
522 |
// Get and verify the list of available WLAN APs.
|
|
523 |
QList< QSharedPointer<WlanQtUtilsAp> > aps;
|
|
524 |
wlanQtUtils_->availableWlanAps(aps);
|
|
525 |
|
|
526 |
testContext.mScan.verifyWlanScanApResultList(aps);
|
|
527 |
aps.clear();
|
|
528 |
}
|
|
529 |
|
|
530 |
/**
|
39
|
531 |
* Test a basic direct scan.
|
|
532 |
*/
|
|
533 |
void TestWlanQtUtils::testDirectScanBasic()
|
|
534 |
{
|
|
535 |
// Form result list
|
53
|
536 |
testContext.mScan.createDefaultWlanScanApResultList(2);
|
|
537 |
testContext.mScan.mWlanScanApResultList[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "testssid");
|
|
538 |
testContext.mScan.mWlanScanApResultList[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen);
|
|
539 |
testContext.mScan.mWlanScanApResultList[1]->setValue(WlanQtUtilsAp::ConfIdSsid, "testssid");
|
|
540 |
testContext.mScan.mWlanScanApResultList[1]->setValue(WlanQtUtilsAp::ConfIdBssid, "654321");
|
|
541 |
testContext.mScan.mWlanScanApResultList[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
|
39
|
542 |
|
|
543 |
// Request a direct scan to get result signal
|
|
544 |
wlanQtUtils_->scanWlanDirect(QString("testssid"));
|
|
545 |
|
|
546 |
// Let active object run and verify signal.
|
|
547 |
subTestScanResultSignal(mSignalScanDirectReady, WlanQtUtils::ScanStatusOk);
|
|
548 |
|
|
549 |
// Get and verify the list of available WLAN APs.
|
|
550 |
QList< QSharedPointer<WlanQtUtilsAp> > aps;
|
|
551 |
wlanQtUtils_->availableWlanAps(aps);
|
|
552 |
|
53
|
553 |
testContext.mScan.verifyWlanScanApResultList(aps);
|
39
|
554 |
aps.clear();
|
|
555 |
}
|
|
556 |
|
|
557 |
/**
|
|
558 |
* Test a direct scan that finds nothing.
|
|
559 |
*/
|
|
560 |
void TestWlanQtUtils::testDirectScanEmpty()
|
|
561 |
{
|
|
562 |
// Form result list
|
53
|
563 |
testContext.mScan.createDefaultWlanScanApResultList(0);
|
39
|
564 |
|
|
565 |
// Request a direct scan to get result signal
|
|
566 |
wlanQtUtils_->scanWlanDirect(QString("notavailable"));
|
|
567 |
|
|
568 |
// Let active object run and verify signal.
|
|
569 |
subTestScanResultSignal(mSignalScanDirectReady, WlanQtUtils::ScanStatusOk);
|
|
570 |
|
|
571 |
// Get and verify the list of available WLAN APs.
|
|
572 |
QList< QSharedPointer<WlanQtUtilsAp> > aps;
|
|
573 |
wlanQtUtils_->availableWlanAps(aps);
|
53
|
574 |
testContext.mScan.verifyWlanScanApResultList(aps);
|
39
|
575 |
}
|
|
576 |
|
|
577 |
/**
|
|
578 |
* Test cancellation of direct scan.
|
|
579 |
*/
|
|
580 |
void TestWlanQtUtils::testDirectScanStop()
|
|
581 |
{
|
|
582 |
// Do not complete scan request immediately
|
53
|
583 |
testContext.mScan.mCompleteWlanApScan = false;
|
39
|
584 |
|
|
585 |
// Start the scan
|
|
586 |
wlanQtUtils_->scanWlanDirect(QString("testssid"));
|
|
587 |
// Cancel the scan
|
|
588 |
wlanQtUtils_->stopWlanScan();
|
|
589 |
|
|
590 |
// Catch & check the scan result signal
|
|
591 |
subTestScanResultSignal(mSignalScanDirectReady, WlanQtUtils::ScanStatusCancelled);
|
|
592 |
}
|
|
593 |
|
|
594 |
/**
|
|
595 |
* Test direct scan failure.
|
|
596 |
*/
|
|
597 |
void TestWlanQtUtils::testDirectScanError()
|
|
598 |
{
|
|
599 |
// Set the scan to fail
|
53
|
600 |
testContext.mScan.mApScanRetValue = KErrGeneral;
|
39
|
601 |
|
|
602 |
// Start the scan
|
|
603 |
wlanQtUtils_->scanWlanDirect(QString("boundtofail"));
|
|
604 |
|
|
605 |
// Catch & check the scan result signal
|
|
606 |
subTestScanResultSignal(mSignalScanDirectReady, WlanQtUtils::ScanStatusError);
|
|
607 |
}
|
|
608 |
|
|
609 |
/**
|
31
|
610 |
* This function tests creation of WLAN IAP in a succesful manner.
|
|
611 |
* - WLAN scan is made because otherwise we cannot verify that IAP creation is successful.
|
|
612 |
* - Check that there are no available WLAN IAPs.
|
|
613 |
* - Fetch SNAP list.
|
|
614 |
* - Create WLAN IAP.
|
|
615 |
* - Check that WLAN IAP has been created and that this IAP is not in WLAN AP scan results.
|
|
616 |
*/
|
|
617 |
void TestWlanQtUtils::testCreateIapOk()
|
|
618 |
{
|
53
|
619 |
// Form WLAN AP scan result list
|
|
620 |
testContext.mScan.createDefaultWlanScanApResultList(1);
|
|
621 |
testContext.mScan.mWlanScanApResultList[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapOk");
|
|
622 |
testContext.mScan.mWlanScanApResultList[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa);
|
|
623 |
testContext.mScan.mWlanScanApResultList[0]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true);
|
|
624 |
|
|
625 |
// Form WLAN IAP scan result list
|
|
626 |
testContext.mScan.createDefaultWlanScanIapResultList(0);
|
31
|
627 |
|
|
628 |
// Request a scan to get result signal
|
|
629 |
wlanQtUtils_->scanWlans();
|
53
|
630 |
|
31
|
631 |
// Let active object run and verify signal.
|
39
|
632 |
subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
|
31
|
633 |
|
|
634 |
// Ensure there are no WLAN IAPs but there is one scan result.
|
60
|
635 |
QList< QSharedPointer<WlanQtUtilsAp> > iaps;
|
31
|
636 |
QList< QSharedPointer<WlanQtUtilsAp> > aps;
|
|
637 |
wlanQtUtils_->availableWlans(iaps, aps);
|
|
638 |
|
|
639 |
QCOMPARE(iaps.count(), 0);
|
53
|
640 |
testContext.mScan.verifyWlanScanApResultList(aps);
|
31
|
641 |
|
|
642 |
// Execute createIap() function
|
39
|
643 |
QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
|
60
|
644 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdName, "testCreateIapOk");
|
39
|
645 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapOk");
|
|
646 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
|
|
647 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true);
|
|
648 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWpaPsk, "100euronlounas");
|
|
649 |
int iapId = wlanQtUtils_->createIap(wlanAp.data());
|
31
|
650 |
QVERIFY(iapId != WlanQtUtils::IapIdNone);
|
|
651 |
|
53
|
652 |
// Form WLAN IAP scan result list
|
|
653 |
testContext.mScan.createDefaultWlanScanIapResultList(1);
|
60
|
654 |
testContext.mScan.mWlanScanIapResultList[0]->setValue(WlanQtUtilsAp::ConfIdIapId, iapId);
|
|
655 |
testContext.mScan.mWlanScanIapResultList[0]->setValue(WlanQtUtilsAp::ConfIdName, QString("testCreateIapOk"));
|
|
656 |
testContext.mScan.mWlanScanIapResultList[0]->setValue(WlanQtUtilsAp::ConfIdSsid, QString("testCreateIapOk"));
|
|
657 |
testContext.mScan.mWlanScanIapResultList[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, (int)(CMManagerShim::WlanSecModeWpa));
|
|
658 |
testContext.mScan.mWlanScanIapResultList[0]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true);
|
53
|
659 |
|
|
660 |
// Re-execute the scan so that scan lists get updated due to the IAP creation
|
|
661 |
wlanQtUtils_->scanWlans();
|
|
662 |
subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
|
|
663 |
|
31
|
664 |
// Verify that created IAP is in the IAP list and AP list is empty.
|
|
665 |
wlanQtUtils_->availableWlans(iaps, aps);
|
53
|
666 |
testContext.mScan.verifyWlanScanIapResultList(iaps);
|
31
|
667 |
QCOMPARE(aps.count(), 0);
|
|
668 |
}
|
|
669 |
|
|
670 |
/**
|
|
671 |
* This function tests creation of WLAN IAP in unsuccesful manner.
|
|
672 |
*/
|
|
673 |
void TestWlanQtUtils::testCreateIapErr()
|
|
674 |
{
|
|
675 |
// Execute createIap() function with invalid parameters
|
39
|
676 |
QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
|
60
|
677 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdName, "testCreateIapErr");
|
39
|
678 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapErr");
|
|
679 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
|
31
|
680 |
// Invalid security mode -> exception
|
39
|
681 |
wlanAp->setValue(
|
31
|
682 |
WlanQtUtilsAp::ConfIdSecurityMode,
|
|
683 |
CMManager::EWlanSecModeWAPI + 1111);
|
39
|
684 |
int iapId = wlanQtUtils_->createIap(wlanAp.data());
|
31
|
685 |
QVERIFY(iapId == WlanQtUtils::IapIdNone);
|
|
686 |
}
|
|
687 |
|
|
688 |
/**
|
|
689 |
* This function tests creation of WLAN IAPs with different WEP keys.
|
|
690 |
*/
|
|
691 |
void TestWlanQtUtils::testCreateIapWepKeys()
|
|
692 |
{
|
|
693 |
// Create the IAPs with different kind of WEP keys
|
39
|
694 |
QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
|
60
|
695 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdName, "testCreateIapWepKeys");
|
39
|
696 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapWepKeys");
|
|
697 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWep);
|
|
698 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex2);
|
31
|
699 |
// All keys in HEX format
|
39
|
700 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey1, "1234567891");
|
|
701 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey2, "1234567891");
|
|
702 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey3, "1234567891");
|
|
703 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey4, "1234567891");
|
31
|
704 |
|
39
|
705 |
int iapId = wlanQtUtils_->createIap(wlanAp.data());
|
31
|
706 |
QVERIFY(iapId != WlanQtUtils::IapIdNone);
|
|
707 |
|
39
|
708 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex3);
|
31
|
709 |
// All keys in ASCII format
|
39
|
710 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey1, "12345");
|
|
711 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey2, "12345");
|
|
712 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey3, "12345");
|
|
713 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey4, "12345");
|
31
|
714 |
|
39
|
715 |
iapId = wlanQtUtils_->createIap(wlanAp.data());
|
31
|
716 |
QVERIFY(iapId != WlanQtUtils::IapIdNone);
|
|
717 |
|
39
|
718 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex4);
|
31
|
719 |
// Different keys, including a missing one
|
39
|
720 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey1, "");
|
|
721 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey2, "12345678911234567892123456");
|
|
722 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey3, "12345");
|
|
723 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey4, "1234567891123");
|
31
|
724 |
|
39
|
725 |
iapId = wlanQtUtils_->createIap(wlanAp.data());
|
31
|
726 |
QVERIFY(iapId != WlanQtUtils::IapIdNone);
|
|
727 |
}
|
|
728 |
|
|
729 |
/**
|
|
730 |
* This function tests updating of WLAN IAP in a succesful manner.
|
|
731 |
*/
|
|
732 |
void TestWlanQtUtils::testUpdateIapOk()
|
|
733 |
{
|
|
734 |
// Create an IAP that can be updated
|
39
|
735 |
QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
|
60
|
736 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdName, "testUpdateIapOk");
|
39
|
737 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testUpdateIapOk");
|
|
738 |
int iapId = wlanQtUtils_->createIap(wlanAp.data());
|
31
|
739 |
|
|
740 |
// Update the name and verify it changed
|
60
|
741 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdName, "UPDATED_testUpdateIapOk");
|
39
|
742 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "UPDATED_testUpdateIapOk");
|
31
|
743 |
|
39
|
744 |
bool success = wlanQtUtils_->updateIap(iapId, wlanAp.data());
|
31
|
745 |
QVERIFY(success == true);
|
|
746 |
QString name = wlanQtUtils_->iapName(iapId);
|
|
747 |
QCOMPARE(name, QString("UPDATED_testUpdateIapOk"));
|
|
748 |
}
|
|
749 |
|
|
750 |
/**
|
|
751 |
* This function tests updating of WLAN IAP in unsuccesful manner.
|
|
752 |
*/
|
|
753 |
void TestWlanQtUtils::testUpdateIapErr()
|
|
754 |
{
|
|
755 |
// Try to update a non-existing IAP
|
|
756 |
WlanQtUtilsAp wlanAp;
|
|
757 |
bool success = wlanQtUtils_->updateIap(200, &wlanAp);
|
|
758 |
QVERIFY(success == false);
|
|
759 |
}
|
|
760 |
|
|
761 |
/**
|
|
762 |
* This function tests deletion of WLAN IAP in a succesful manner.
|
|
763 |
*/
|
|
764 |
void TestWlanQtUtils::testDeleteIapOk()
|
|
765 |
{
|
|
766 |
// Create an IAP that can be deleted
|
39
|
767 |
QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
|
60
|
768 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdName, "testDeleteIapOk");
|
39
|
769 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testDeleteIapOk");
|
|
770 |
int iapId = wlanQtUtils_->createIap(wlanAp.data());
|
31
|
771 |
|
|
772 |
// Check that IAP now exists
|
|
773 |
QString name = wlanQtUtils_->iapName(iapId);
|
|
774 |
QCOMPARE(name, QString("testDeleteIapOk"));
|
|
775 |
|
|
776 |
// Delete it and verify it does not exist anymore
|
|
777 |
wlanQtUtils_->deleteIap(iapId);
|
|
778 |
name = wlanQtUtils_->iapName(iapId);
|
|
779 |
QVERIFY(name.isEmpty());
|
|
780 |
}
|
|
781 |
|
|
782 |
/**
|
|
783 |
* This function tests deletion of WLAN IAP in unsuccesful manner.
|
|
784 |
*/
|
|
785 |
void TestWlanQtUtils::testDeleteIapErr()
|
|
786 |
{
|
|
787 |
// Try to delete a non-existing IAP
|
|
788 |
wlanQtUtils_->deleteIap(200);
|
|
789 |
|
|
790 |
// No signals or return values to verify
|
|
791 |
}
|
|
792 |
|
|
793 |
/**
|
|
794 |
* This function tests connecting to IAP in a succesful manner.
|
|
795 |
*/
|
|
796 |
void TestWlanQtUtils::testConnectIapOk()
|
|
797 |
{
|
|
798 |
testContext.esock_.startRetValue_ = KErrNone;
|
|
799 |
|
|
800 |
// Esock stub completes connection creation immediately
|
|
801 |
wlanQtUtils_->connectIap(5);
|
|
802 |
|
|
803 |
// Connection creation in ConnMon interface
|
|
804 |
testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, 5);
|
|
805 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
|
|
806 |
EConnMonCreateConnection,
|
|
807 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
|
|
808 |
|
|
809 |
// Connection status change in ConnMon interface
|
|
810 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
811 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
812 |
0,
|
|
813 |
KConnectionOpen));
|
|
814 |
|
|
815 |
// Receive signal for connection opening (caused by connectIap, which completed immediately)
|
|
816 |
QList<QVariant> arguments;
|
|
817 |
subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments);
|
|
818 |
QCOMPARE(arguments.at(0).toInt(), 5);
|
|
819 |
|
|
820 |
// Connection status change to opened in ConnMon interface. Sub test cases between test
|
|
821 |
// cases check that no extra signals are sent
|
|
822 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
823 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
824 |
0,
|
|
825 |
KLinkLayerOpen));
|
|
826 |
}
|
|
827 |
|
|
828 |
/**
|
|
829 |
* This function tests connecting to IAP in unsuccesful manner.
|
|
830 |
*/
|
|
831 |
void TestWlanQtUtils::testConnectIapErr()
|
|
832 |
{
|
|
833 |
testContext.esock_.startRetValue_ = KErrGeneral;
|
|
834 |
|
|
835 |
wlanQtUtils_->connectIap(7);
|
|
836 |
|
|
837 |
testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, 7);
|
|
838 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
|
|
839 |
EConnMonCreateConnection,
|
|
840 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
|
|
841 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
842 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
843 |
0,
|
|
844 |
KConnectionOpen));
|
|
845 |
|
|
846 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
|
|
847 |
EConnMonDeleteConnection,
|
|
848 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
|
|
849 |
|
|
850 |
QList<QVariant> arguments;
|
|
851 |
subTestSignalWaitAndTake(signalWlanNetworkClosed_, &arguments);
|
|
852 |
QCOMPARE(arguments.at(0).toInt(), 7);
|
|
853 |
QCOMPARE(arguments.at(1).toInt(), KErrGeneral);
|
|
854 |
}
|
|
855 |
|
|
856 |
// TODO: testDisconnectFail cases are needed when fail branches are
|
|
857 |
// implemented into the connmon wrapper
|
|
858 |
/**
|
|
859 |
* This function tests IAP disconnecting functionality.
|
|
860 |
*/
|
|
861 |
void TestWlanQtUtils::testDisconnectIapOk()
|
|
862 |
{
|
|
863 |
// Create and connect an IAP we can then disconnect
|
39
|
864 |
QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
|
60
|
865 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdName, "testDisconnectIapOk");
|
39
|
866 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testDisconnectIapOk");
|
|
867 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
|
31
|
868 |
|
39
|
869 |
int iapId = wlanQtUtils_->createIap(wlanAp.data());
|
31
|
870 |
testContext.esock_.startRetValue_ = KErrNone;
|
|
871 |
wlanQtUtils_->connectIap(iapId);
|
|
872 |
QList<QVariant> arguments;
|
|
873 |
subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments);
|
|
874 |
QCOMPARE(arguments.at(0).toInt(), iapId);
|
|
875 |
|
|
876 |
// Make sure there is the newly created connection active and also
|
|
877 |
// another one to gain coverage
|
|
878 |
testContext.connMon_.activeConnections_.createDefaultActiveConnList(2, iapId - 1);
|
|
879 |
// The disconnect function does not have any return values or
|
|
880 |
// signals related to the disconnection, thus plain
|
|
881 |
// function call is done for the test.
|
|
882 |
wlanQtUtils_->disconnectIap(iapId);
|
|
883 |
}
|
|
884 |
|
|
885 |
/**
|
|
886 |
* This function tests IAP disconnecting functionality when there is no
|
|
887 |
* IAP to disconnect.
|
|
888 |
*/
|
|
889 |
void TestWlanQtUtils::testDisconnectIapIgnored()
|
|
890 |
{
|
|
891 |
testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, 150);
|
|
892 |
wlanQtUtils_->disconnectIap(200);
|
|
893 |
wlanQtUtils_->disconnectIap(WlanQtUtils::IapIdNone);
|
|
894 |
}
|
|
895 |
|
|
896 |
/**
|
60
|
897 |
* This function tests moving of an IAP into Internet destination.
|
|
898 |
*/
|
|
899 |
void TestWlanQtUtils::testMoveIapToInternetOk()
|
|
900 |
{
|
|
901 |
// First create the IAP to move
|
|
902 |
QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
|
|
903 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdName, "testMoveIapToInternetOk");
|
|
904 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testMoveIapToInternetOk");
|
|
905 |
int iapId = wlanQtUtils_->createIap(wlanAp.data());
|
|
906 |
QVERIFY(iapId != WlanQtUtils::IapIdNone);
|
|
907 |
|
|
908 |
// Verify the name
|
|
909 |
QCOMPARE(wlanQtUtils_->iapName(iapId), QString("testMoveIapToInternetOk"));
|
|
910 |
|
|
911 |
// Now move the IAP to internet destination
|
|
912 |
wlanQtUtils_->moveIapToInternetSnap(iapId);
|
|
913 |
|
|
914 |
// No interface for checking the destination via WlanQtUtils, so skipping it
|
|
915 |
|
|
916 |
// Delete the IAP
|
|
917 |
wlanQtUtils_->deleteIap(iapId);
|
|
918 |
}
|
|
919 |
|
|
920 |
/**
|
31
|
921 |
* This function tests connection status getter.
|
|
922 |
*/
|
|
923 |
void TestWlanQtUtils::testConnectionStatus()
|
|
924 |
{
|
|
925 |
// Request status when there is no connection
|
|
926 |
WlanQtUtils::ConnStatus status = wlanQtUtils_->connectionStatus();
|
|
927 |
QCOMPARE(status, WlanQtUtils::ConnStatusDisconnected);
|
|
928 |
|
|
929 |
// Make a connection and request its status
|
|
930 |
testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, 5);
|
|
931 |
// Send event for connection creation.
|
|
932 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
|
|
933 |
EConnMonCreateConnection,
|
|
934 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
|
|
935 |
// Send events for connection status change -> connecting
|
|
936 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
937 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
938 |
0,
|
|
939 |
KStartingConnection));
|
|
940 |
|
|
941 |
// Request status when there is connection in connecting state
|
|
942 |
status = wlanQtUtils_->connectionStatus();
|
|
943 |
QCOMPARE(status, WlanQtUtils::ConnStatusConnecting);
|
|
944 |
|
|
945 |
// Send events for connection status change -> connected
|
|
946 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
947 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
948 |
0,
|
|
949 |
KLinkLayerOpen));
|
|
950 |
|
|
951 |
QList<QVariant> arguments;
|
|
952 |
subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments);
|
|
953 |
QCOMPARE(arguments.at(0).toInt(), 5);
|
|
954 |
|
|
955 |
// Request status when there is connection in connected state
|
|
956 |
status = wlanQtUtils_->connectionStatus();
|
|
957 |
QCOMPARE(status, WlanQtUtils::ConnStatusConnected);
|
|
958 |
}
|
|
959 |
|
|
960 |
/**
|
|
961 |
* This function tests IAP name getter with existing IAP ID.
|
|
962 |
*/
|
|
963 |
void TestWlanQtUtils::testIapNameFound()
|
|
964 |
{
|
|
965 |
// Create the IAP we want to find with the getter
|
39
|
966 |
QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
|
60
|
967 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdName, "testIapFound");
|
39
|
968 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testIapFound");
|
|
969 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2);
|
31
|
970 |
|
39
|
971 |
int iapId = wlanQtUtils_->createIap(wlanAp.data());
|
31
|
972 |
|
|
973 |
// Execute the function under test and check that we got the correct name
|
|
974 |
QString name = wlanQtUtils_->iapName(iapId);
|
|
975 |
QCOMPARE(name, QString("testIapFound"));
|
|
976 |
}
|
|
977 |
|
|
978 |
/**
|
|
979 |
* This function tests IAP name getter with non-existing IAP ID.
|
|
980 |
*/
|
|
981 |
void TestWlanQtUtils::testIapNameNotFound()
|
|
982 |
{
|
|
983 |
// Execute the function under test and check that we get no name as result
|
|
984 |
QString name = wlanQtUtils_->iapName(200); // id in valid range, but not found -> KErrNotFound
|
|
985 |
QVERIFY(name.isEmpty());
|
|
986 |
|
|
987 |
name = wlanQtUtils_->iapName(1000); // id not in valid range -> KErrArgument
|
|
988 |
QVERIFY(name.isEmpty());
|
|
989 |
|
|
990 |
name = wlanQtUtils_->iapName(3); // id of cellular IAP -> discarded
|
|
991 |
QVERIFY(name.isEmpty());
|
|
992 |
}
|
|
993 |
|
|
994 |
/**
|
|
995 |
* This function tests active WLAN IAP getter with existing connection.
|
|
996 |
*/
|
|
997 |
void TestWlanQtUtils::testActiveIapFound()
|
|
998 |
{
|
|
999 |
// Create the IAP we want to find with the getter
|
39
|
1000 |
QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
|
60
|
1001 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdName, "testConnectedWlanIdFound");
|
39
|
1002 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testConnectedWlanIdFound");
|
|
1003 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
|
31
|
1004 |
|
39
|
1005 |
int iapId = wlanQtUtils_->createIap(wlanAp.data());
|
31
|
1006 |
|
|
1007 |
testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, iapId);
|
|
1008 |
|
|
1009 |
// Send event for connection creation.
|
|
1010 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
|
39
|
1011 |
EConnMonCreateConnection,
|
|
1012 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
|
31
|
1013 |
|
|
1014 |
// Send events for connection status change -> opened.
|
|
1015 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1016 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1017 |
0,
|
|
1018 |
KStartingConnection));
|
|
1019 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1020 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1021 |
0,
|
|
1022 |
KLinkLayerOpen));
|
|
1023 |
|
|
1024 |
QList<QVariant> arguments;
|
|
1025 |
subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments);
|
|
1026 |
QCOMPARE(arguments.at(0).toInt(), iapId);
|
|
1027 |
|
|
1028 |
// Execute the function under test and check that we get valid ID as result
|
|
1029 |
int id = wlanQtUtils_->activeIap();
|
|
1030 |
QCOMPARE(id, iapId);
|
|
1031 |
}
|
|
1032 |
|
|
1033 |
/**
|
|
1034 |
* This function tests active WLAN IAP getter with connection existing already during dll construction.
|
|
1035 |
*/
|
|
1036 |
void TestWlanQtUtils::testActiveIapFoundConstructor()
|
|
1037 |
{
|
|
1038 |
// IAP IDs 4 and 5 exist in default commsdat file, 4 is GPRS, 5 is WLAN
|
|
1039 |
testContext.connMon_.activeConnections_.createDefaultActiveConnList(2, 4);
|
|
1040 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connMonBearerType_ = EBearerGPRS;
|
|
1041 |
|
|
1042 |
// Create a new instance in order to test functionality triggered in constructor.
|
|
1043 |
WlanQtUtils *utils = new WlanQtUtils();
|
|
1044 |
|
|
1045 |
// Execute the function under test and check that we get valid ID as result
|
|
1046 |
int id = utils->activeIap();
|
|
1047 |
QCOMPARE(id, 5);
|
|
1048 |
|
|
1049 |
delete utils;
|
|
1050 |
}
|
|
1051 |
|
|
1052 |
/**
|
|
1053 |
* This function tests active WLAN IAP getter without existing connection.
|
|
1054 |
*/
|
|
1055 |
void TestWlanQtUtils::testActiveIapNotFound()
|
|
1056 |
{
|
|
1057 |
// Execute the function under test and check that we get invalid ID as result
|
|
1058 |
int id = wlanQtUtils_->activeIap();
|
|
1059 |
QCOMPARE(id, WlanQtUtils::IapIdNone);
|
|
1060 |
}
|
|
1061 |
|
|
1062 |
/**
|
|
1063 |
* Test WLAN scan triggering interface.
|
|
1064 |
*/
|
|
1065 |
void TestWlanQtUtils::testScanWlans()
|
|
1066 |
{
|
|
1067 |
// Execute function under test
|
|
1068 |
wlanQtUtils_->scanWlans();
|
|
1069 |
|
|
1070 |
// No need to verify scan results here, testAvailableWlan* test cases
|
|
1071 |
// are for that. Just make sure the result signal is received.
|
39
|
1072 |
subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
|
31
|
1073 |
}
|
|
1074 |
|
|
1075 |
/**
|
39
|
1076 |
* Test WLAN scan result ignoring & deletion during an ongoing request.
|
31
|
1077 |
*/
|
|
1078 |
void TestWlanQtUtils::testScanWlansIgnored()
|
|
1079 |
{
|
|
1080 |
// Do not complete scan request immediately
|
53
|
1081 |
testContext.mScan.mCompleteWlanApScan = false;
|
31
|
1082 |
|
|
1083 |
// Execute function under test
|
|
1084 |
wlanQtUtils_->scanWlans();
|
|
1085 |
|
|
1086 |
// Ongoing scan is cancelled in destructors
|
|
1087 |
}
|
|
1088 |
|
|
1089 |
/**
|
|
1090 |
* Test WLAN scan stopping interface when scan is active.
|
|
1091 |
*/
|
|
1092 |
void TestWlanQtUtils::testStopWlanScanOk()
|
|
1093 |
{
|
|
1094 |
// Do not complete scan request immediately
|
53
|
1095 |
testContext.mScan.mCompleteWlanApScan = false;
|
31
|
1096 |
// Start a scan
|
|
1097 |
wlanQtUtils_->scanWlans();
|
|
1098 |
// Execute function under test
|
|
1099 |
wlanQtUtils_->stopWlanScan();
|
39
|
1100 |
|
|
1101 |
// Catch & check the scan result signal
|
|
1102 |
subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusCancelled);
|
60
|
1103 |
|
|
1104 |
// Restart scan to make sure previous is really finished
|
|
1105 |
testContext.mScan.mCompleteWlanApScan = true;
|
|
1106 |
wlanQtUtils_->scanWlans();
|
|
1107 |
|
|
1108 |
// No need to verify scan results here, testAvailableWlan* test cases
|
|
1109 |
// are for that. Just make sure the result signal is received.
|
|
1110 |
subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk);
|
31
|
1111 |
}
|
|
1112 |
|
|
1113 |
/**
|
|
1114 |
* Test WLAN scan stopping interface when no scan is ongoing.
|
|
1115 |
*/
|
|
1116 |
void TestWlanQtUtils::testStopWlanScanIgnored()
|
|
1117 |
{
|
39
|
1118 |
// Stop without having an active scan
|
31
|
1119 |
wlanQtUtils_->stopWlanScan();
|
|
1120 |
|
|
1121 |
// No return values or signals to verify
|
|
1122 |
}
|
|
1123 |
|
|
1124 |
/**
|
|
1125 |
* This function tests Wlan network opening signal when network is not opened by the dll.
|
|
1126 |
*/
|
|
1127 |
void TestWlanQtUtils::testWlanNetworkOpened()
|
|
1128 |
{
|
|
1129 |
testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, 5);
|
|
1130 |
|
|
1131 |
// Send event for connection creation.
|
|
1132 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
|
|
1133 |
EConnMonCreateConnection,
|
|
1134 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
|
|
1135 |
|
|
1136 |
// Send events for connection status change -> opened.
|
|
1137 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1138 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1139 |
0,
|
|
1140 |
KConnectionOpen));
|
|
1141 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1142 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1143 |
0,
|
|
1144 |
KConfigDaemonFinishedRegistration));
|
|
1145 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1146 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1147 |
0,
|
|
1148 |
KLinkLayerOpen));
|
|
1149 |
|
|
1150 |
QList<QVariant> arguments;
|
|
1151 |
subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments);
|
|
1152 |
QCOMPARE(arguments.at(0).toInt(), 5);
|
|
1153 |
|
|
1154 |
// Send uninteresting event to gain coverage
|
|
1155 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
|
|
1156 |
EConnMonNetworkStatusChange,
|
|
1157 |
10));
|
|
1158 |
}
|
|
1159 |
|
|
1160 |
/**
|
|
1161 |
* This function tests Wlan network closing signal when network is not closed by the dll.
|
|
1162 |
*/
|
|
1163 |
void TestWlanQtUtils::testWlanNetworkClosed()
|
|
1164 |
{
|
|
1165 |
// First create a connection
|
|
1166 |
testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, 5);
|
|
1167 |
|
|
1168 |
// Send event for connection creation.
|
|
1169 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
|
|
1170 |
EConnMonCreateConnection,
|
|
1171 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
|
|
1172 |
|
|
1173 |
// Send events for connection status change -> opened.
|
|
1174 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1175 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1176 |
0,
|
|
1177 |
KConnectionOpen));
|
|
1178 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1179 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1180 |
0,
|
|
1181 |
KLinkLayerOpen));
|
|
1182 |
|
|
1183 |
QList<QVariant> arguments;
|
|
1184 |
subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments);
|
|
1185 |
QCOMPARE(arguments.at(0).toInt(), 5);
|
|
1186 |
|
|
1187 |
// Send event for connection status change -> closed.
|
|
1188 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1189 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1190 |
0,
|
|
1191 |
KLinkLayerClosed));
|
|
1192 |
|
|
1193 |
// Send event for connection deletion.
|
|
1194 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
|
|
1195 |
EConnMonDeleteConnection,
|
|
1196 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
|
|
1197 |
|
|
1198 |
subTestSignalWaitAndTake(signalWlanNetworkClosed_, &arguments);
|
|
1199 |
QCOMPARE(arguments.at(0).toInt(), 5);
|
|
1200 |
QCOMPARE(arguments.at(1).toInt(), KErrNone);
|
|
1201 |
}
|
|
1202 |
|
|
1203 |
/**
|
|
1204 |
* This function tests WlanQtUtilsAp copy constructor.
|
|
1205 |
*/
|
|
1206 |
void TestWlanQtUtils::testApCopyConstructor()
|
|
1207 |
{
|
|
1208 |
WlanQtUtilsAp firstAp;
|
|
1209 |
firstAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testApCopyConstructor");
|
39
|
1210 |
firstAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90);
|
31
|
1211 |
firstAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
|
|
1212 |
firstAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
|
|
1213 |
firstAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true);
|
|
1214 |
firstAp.setValue(WlanQtUtilsAp::ConfIdWpaPsk, "100euronlounas");
|
|
1215 |
|
|
1216 |
// Create the copy AP
|
|
1217 |
WlanQtUtilsAp secondAp(firstAp);
|
|
1218 |
QCOMPARE(secondAp.value(WlanQtUtilsAp::ConfIdSsid).toString(), QString("testApCopyConstructor"));
|
|
1219 |
QCOMPARE(secondAp.value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(), (int)(CMManagerShim::WlanSecModeWpa));
|
|
1220 |
QCOMPARE(secondAp.value(WlanQtUtilsAp::ConfIdWpaPskUse).toBool(), true);
|
|
1221 |
QCOMPARE(secondAp.value(WlanQtUtilsAp::ConfIdSignalStrength).toInt(), 90);
|
|
1222 |
QCOMPARE(secondAp.value(WlanQtUtilsAp::ConfIdConnectionMode).toInt(), (int)(CMManagerShim::Infra));
|
|
1223 |
QCOMPARE(secondAp.value(WlanQtUtilsAp::ConfIdWpaPsk).toString(), QString("100euronlounas"));
|
|
1224 |
}
|
|
1225 |
|
|
1226 |
/**
|
|
1227 |
* This function tests ICT when connection test passes.
|
|
1228 |
*/
|
|
1229 |
void TestWlanQtUtils::testConnectionTestOk()
|
|
1230 |
{
|
|
1231 |
// Create new IAP to test
|
39
|
1232 |
QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
|
60
|
1233 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdName, "testConnectionTestOk");
|
39
|
1234 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testConnectionTestOk");
|
|
1235 |
int iapId = wlanQtUtils_->createIap(wlanAp.data());
|
31
|
1236 |
QVERIFY(iapId != WlanQtUtils::IapIdNone);
|
|
1237 |
|
|
1238 |
testContext.esock_.startRetValue_ = KErrNone;
|
|
1239 |
|
|
1240 |
// Esock stub completes connection creation immediately
|
|
1241 |
wlanQtUtils_->connectIap(iapId, true);
|
|
1242 |
|
|
1243 |
// Connection creation in ConnMon interface
|
|
1244 |
testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, iapId);
|
|
1245 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
|
|
1246 |
EConnMonCreateConnection,
|
|
1247 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
|
|
1248 |
|
|
1249 |
// Connection status change in ConnMon interface
|
|
1250 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1251 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1252 |
0,
|
|
1253 |
KConnectionOpen));
|
|
1254 |
|
|
1255 |
// Receive signal for connection opening (caused by connectIap, which completed immediately)
|
|
1256 |
QList<QVariant> arguments;
|
|
1257 |
subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments);
|
|
1258 |
QCOMPARE(arguments.at(0).toInt(), iapId);
|
|
1259 |
|
|
1260 |
// Connection status change to opened in ConnMon interface. Sub test cases between test
|
|
1261 |
// cases check that no extra signals are sent
|
|
1262 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1263 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1264 |
0,
|
|
1265 |
KLinkLayerOpen));
|
|
1266 |
|
|
1267 |
// Connection test automatically started at this point. Call result function explicitly
|
|
1268 |
// No interface exists that we could check that the IAP is moved to Internet SNAP correctly
|
43
|
1269 |
wlanQtUtils_->d_ptr->updateIctResult(IctsWlanLoginInterface::IctsPassed);
|
31
|
1270 |
|
43
|
1271 |
subTestSignalWaitAndTake(signalIctResult_, &arguments);
|
31
|
1272 |
QCOMPARE(arguments.at(0).toInt(), iapId);
|
43
|
1273 |
QCOMPARE(arguments.at(1).toInt(), (int)WlanQtUtils::IctPassed);
|
31
|
1274 |
}
|
|
1275 |
|
|
1276 |
/**
|
|
1277 |
* This function tests ICT when connection test fails.
|
|
1278 |
*/
|
|
1279 |
void TestWlanQtUtils::testConnectionTestErr()
|
|
1280 |
{
|
|
1281 |
// Create and connect an IAP and request ICT to be run
|
39
|
1282 |
QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
|
60
|
1283 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdName, "testConnectionTestErr1");
|
43
|
1284 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testConnectionTestErr1");
|
39
|
1285 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
|
31
|
1286 |
|
39
|
1287 |
int iapId = wlanQtUtils_->createIap(wlanAp.data());
|
31
|
1288 |
wlanQtUtils_->connectIap(iapId, true);
|
|
1289 |
|
|
1290 |
testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, iapId);
|
|
1291 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
|
|
1292 |
EConnMonCreateConnection,
|
|
1293 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
|
|
1294 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1295 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1296 |
0,
|
|
1297 |
KConnectionOpen));
|
|
1298 |
QList<QVariant> arguments;
|
|
1299 |
subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments);
|
|
1300 |
QCOMPARE(arguments.at(0).toInt(), iapId);
|
|
1301 |
|
|
1302 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1303 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1304 |
0,
|
|
1305 |
KLinkLayerOpen));
|
|
1306 |
|
|
1307 |
// Connection test automatically started at this point. Call result function explicitly
|
|
1308 |
// No interface exists that we could check that IAP is not moved to another SNAP
|
43
|
1309 |
wlanQtUtils_->d_ptr->updateIctResult(IctsWlanLoginInterface::IctsFailed);
|
|
1310 |
|
|
1311 |
subTestSignalWaitAndTake(signalIctResult_, &arguments);
|
|
1312 |
QCOMPARE(arguments.at(0).toInt(), iapId);
|
|
1313 |
QCOMPARE(arguments.at(1).toInt(), (int)WlanQtUtils::IctFailed);
|
|
1314 |
|
|
1315 |
// Repeat with cancel status
|
|
1316 |
// Send event for connection status change -> closed.
|
|
1317 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1318 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1319 |
0,
|
|
1320 |
KLinkLayerClosed));
|
|
1321 |
|
|
1322 |
// Send event for connection deletion.
|
|
1323 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
|
|
1324 |
EConnMonDeleteConnection,
|
|
1325 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
|
|
1326 |
|
|
1327 |
subTestSignalWaitAndTake(signalWlanNetworkClosed_, &arguments);
|
|
1328 |
QCOMPARE(arguments.at(0).toInt(), iapId);
|
|
1329 |
QCOMPARE(arguments.at(1).toInt(), KErrNone);
|
|
1330 |
|
60
|
1331 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdName, "testConnectionTestErr2");
|
43
|
1332 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testConnectionTestErr2");
|
|
1333 |
|
|
1334 |
iapId = wlanQtUtils_->createIap(wlanAp.data());
|
|
1335 |
wlanQtUtils_->connectIap(iapId, true);
|
|
1336 |
|
|
1337 |
testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, iapId);
|
|
1338 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
|
|
1339 |
EConnMonCreateConnection,
|
|
1340 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
|
|
1341 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1342 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1343 |
0,
|
|
1344 |
KConnectionOpen));
|
|
1345 |
subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments);
|
|
1346 |
QCOMPARE(arguments.at(0).toInt(), iapId);
|
|
1347 |
|
|
1348 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1349 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1350 |
0,
|
|
1351 |
KLinkLayerOpen));
|
|
1352 |
|
|
1353 |
// Connection test automatically started at this point. Call result function explicitly
|
|
1354 |
// No interface exists that we could check that IAP is not moved to another SNAP
|
|
1355 |
wlanQtUtils_->d_ptr->updateIctResult(IctsWlanLoginInterface::IctsCanceled);
|
|
1356 |
|
|
1357 |
subTestSignalWaitAndTake(signalIctResult_, &arguments);
|
|
1358 |
QCOMPARE(arguments.at(0).toInt(), iapId);
|
|
1359 |
QCOMPARE(arguments.at(1).toInt(), (int)WlanQtUtils::IctCancelled);
|
|
1360 |
}
|
31
|
1361 |
|
43
|
1362 |
/**
|
|
1363 |
* This function tests ICT when connection test passes in hotspot case.
|
|
1364 |
*/
|
|
1365 |
void TestWlanQtUtils::testConnectionTestHotspot()
|
|
1366 |
{
|
|
1367 |
// Create new IAP to test
|
|
1368 |
QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp());
|
60
|
1369 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdName, "testConnectionTestHotspot");
|
43
|
1370 |
wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testConnectionTestHotspot");
|
|
1371 |
int iapId = wlanQtUtils_->createIap(wlanAp.data());
|
|
1372 |
QVERIFY(iapId != WlanQtUtils::IapIdNone);
|
|
1373 |
|
|
1374 |
testContext.esock_.startRetValue_ = KErrNone;
|
|
1375 |
|
|
1376 |
// Esock stub completes connection creation immediately
|
|
1377 |
wlanQtUtils_->connectIap(iapId, true);
|
|
1378 |
|
|
1379 |
// Connection creation in ConnMon interface
|
|
1380 |
testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, iapId);
|
|
1381 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
|
|
1382 |
EConnMonCreateConnection,
|
|
1383 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
|
|
1384 |
|
|
1385 |
// Connection status change in ConnMon interface
|
|
1386 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1387 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1388 |
0,
|
|
1389 |
KConnectionOpen));
|
|
1390 |
|
|
1391 |
// Receive signal for connection opening (caused by connectIap, which completed immediately)
|
|
1392 |
QList<QVariant> arguments;
|
|
1393 |
subTestSignalWaitAndTake(signalWlanNetworkOpened_, &arguments);
|
31
|
1394 |
QCOMPARE(arguments.at(0).toInt(), iapId);
|
43
|
1395 |
|
|
1396 |
// Connection status change to opened in ConnMon interface. Sub test cases between test
|
|
1397 |
// cases check that no extra signals are sent
|
|
1398 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1399 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1400 |
0,
|
|
1401 |
KLinkLayerOpen));
|
|
1402 |
|
|
1403 |
// Connection test automatically started at this point.
|
|
1404 |
// Call hotspot case slot explicitly
|
|
1405 |
wlanQtUtils_->d_ptr->updateIctHotspotCase();
|
|
1406 |
|
|
1407 |
// Call result function explicitly
|
|
1408 |
// No interface exists that we could check that the IAP is not moved to another SNAP
|
|
1409 |
wlanQtUtils_->d_ptr->updateIctResult(IctsWlanLoginInterface::IctsHotspotPassed);
|
|
1410 |
|
|
1411 |
subTestSignalWaitAndTake(signalIctResult_, &arguments);
|
|
1412 |
QCOMPARE(arguments.at(0).toInt(), iapId);
|
|
1413 |
QCOMPARE(arguments.at(1).toInt(), (int)WlanQtUtils::IctHotspotPassed);
|
31
|
1414 |
}
|
|
1415 |
|
|
1416 |
/**
|
|
1417 |
* This function tests that Gprs connection events are ignored.
|
|
1418 |
*/
|
|
1419 |
void TestWlanQtUtils::testConnMonEventGprs()
|
|
1420 |
{
|
|
1421 |
// First create a connection
|
|
1422 |
testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, 4);
|
|
1423 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connMonBearerType_ = EBearerGPRS;
|
|
1424 |
|
|
1425 |
// Send event for connection creation.
|
|
1426 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
|
|
1427 |
EConnMonCreateConnection,
|
|
1428 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
|
|
1429 |
|
|
1430 |
// Send events for connection status change -> opened.
|
|
1431 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1432 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1433 |
0,
|
|
1434 |
KConnectionOpen));
|
|
1435 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1436 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1437 |
0,
|
|
1438 |
KLinkLayerOpen));
|
|
1439 |
|
|
1440 |
// Send event for connection status change -> closed.
|
|
1441 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1442 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1443 |
0,
|
|
1444 |
KLinkLayerClosed));
|
|
1445 |
|
|
1446 |
// Send event for connection deletion.
|
|
1447 |
wlanQtUtils_->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
|
|
1448 |
EConnMonDeleteConnection,
|
|
1449 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
|
|
1450 |
}
|
|
1451 |
|
|
1452 |
/**
|
|
1453 |
* This function tests ConnMon event handling with connection existing already during dll construction.
|
|
1454 |
*/
|
|
1455 |
void TestWlanQtUtils::testConnMonEventCreatedBeforeConstructor()
|
|
1456 |
{
|
|
1457 |
// IAP ID 5 exists in default commsdat file
|
|
1458 |
testContext.connMon_.activeConnections_.createDefaultActiveConnList(1, 5);
|
|
1459 |
|
|
1460 |
// Create a new instance in order to test functionality triggered in constructor.
|
|
1461 |
WlanQtUtils *utils = new WlanQtUtils();
|
|
1462 |
|
|
1463 |
QSignalSpy *signalWlanNetworkOpened = new QSignalSpy(utils, SIGNAL(wlanNetworkOpened(int)));
|
|
1464 |
QVERIFY(signalWlanNetworkOpened->isValid() == true);
|
|
1465 |
QSignalSpy *signalWlanNetworkClosed = new QSignalSpy(utils, SIGNAL(wlanNetworkClosed(int, int)));
|
|
1466 |
QVERIFY(signalWlanNetworkClosed->isValid() == true);
|
|
1467 |
|
|
1468 |
// Send events for connection status change -> opened.
|
|
1469 |
utils->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1470 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1471 |
0,
|
|
1472 |
KConnectionOpen));
|
|
1473 |
utils->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1474 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1475 |
0,
|
|
1476 |
KLinkLayerOpen));
|
|
1477 |
|
|
1478 |
QList<QVariant> arguments;
|
|
1479 |
subTestSignalWaitAndTake(signalWlanNetworkOpened, &arguments);
|
|
1480 |
QCOMPARE(arguments.at(0).toInt(), 5);
|
|
1481 |
|
|
1482 |
// Send event for connection status change -> closed.
|
|
1483 |
utils->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonConnectionStatusChange(
|
|
1484 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId(),
|
|
1485 |
0,
|
|
1486 |
KLinkLayerClosed));
|
|
1487 |
|
|
1488 |
// Send event for connection deletion.
|
|
1489 |
utils->d_ptr->mConMonWrapper->d_ptrInfo->EventL(CConnMonEventBase(
|
|
1490 |
EConnMonDeleteConnection,
|
|
1491 |
testContext.connMon_.activeConnections_.activeConnList_[0]->connectionId()));
|
|
1492 |
|
|
1493 |
subTestSignalWaitAndTake(signalWlanNetworkClosed, &arguments);
|
|
1494 |
QCOMPARE(arguments.at(0).toInt(), 5);
|
|
1495 |
QCOMPARE(arguments.at(1).toInt(), KErrNone);
|
|
1496 |
|
|
1497 |
delete signalWlanNetworkOpened;
|
|
1498 |
delete signalWlanNetworkClosed;
|
|
1499 |
delete utils;
|
|
1500 |
}
|
|
1501 |
|
|
1502 |
// ---------------------------------------------------------
|
|
1503 |
// SUB TEST CASES
|
|
1504 |
// ---------------------------------------------------------
|
|
1505 |
|
|
1506 |
/**
|
|
1507 |
* This function waits for active objects to get time to run, takes the arguments of the
|
|
1508 |
* first signal and returns them from the given signal spy.
|
|
1509 |
* This function also verifies that the number of signals is 1.
|
|
1510 |
*
|
|
1511 |
* @param[in] spy Signal spy.
|
|
1512 |
* @param[out] arguments Arguments of the first signal in the given signal spy. NULL if arguments not needed.
|
|
1513 |
*/
|
|
1514 |
void TestWlanQtUtils::subTestSignalWaitAndTake(QSignalSpy* spy, QList<QVariant>* arguments)
|
|
1515 |
{
|
|
1516 |
QTest::qWait(1);
|
|
1517 |
QCOMPARE(spy->count(), 1);
|
|
1518 |
QList<QVariant> arguments_tmp = spy->takeFirst();
|
|
1519 |
if (arguments != NULL) {
|
|
1520 |
*arguments = arguments_tmp;
|
|
1521 |
}
|
|
1522 |
}
|
|
1523 |
|
|
1524 |
/**
|
39
|
1525 |
* Test case for catching and verifying the scan result signal.
|
|
1526 |
*
|
|
1527 |
* @param [in] status Scan result status.
|
|
1528 |
*/
|
|
1529 |
void TestWlanQtUtils::subTestScanResultSignal(QSignalSpy* spy, int status)
|
|
1530 |
{
|
|
1531 |
QList<QVariant> arguments;
|
|
1532 |
subTestSignalWaitAndTake(spy, &arguments);
|
|
1533 |
QCOMPARE(arguments.length(), 1);
|
|
1534 |
QCOMPARE(arguments.at(0).toInt(), status);
|
|
1535 |
}
|
|
1536 |
|
|
1537 |
/**
|
31
|
1538 |
* This function loads given CommsDat file, replacing current one.
|
|
1539 |
* If CommsDat file doesn't exist, it can be re-created by commanding WST script.
|
|
1540 |
* Using help switch is a quick way:
|
|
1541 |
* run_wst HELP
|
|
1542 |
*
|
|
1543 |
* @param newCommsdatFilename Filename of the new CommsDat to be loaded.
|
|
1544 |
*/
|
|
1545 |
void TestWlanQtUtils::subTestLoadCommsDatFile(QString newCommsdatFilename)
|
|
1546 |
{
|
|
1547 |
// EPOC's CommsDat filename
|
|
1548 |
const QString epocCommsdatFilename("cccccc00.cre");
|
|
1549 |
// EPOC's directory for CommsDat file
|
|
1550 |
const QString commsdatDir("c:\\private\\10202be9\\persists\\");
|
|
1551 |
// Created backup directory under EPOC for CommsDat files
|
|
1552 |
const QString storeDir("c:\\private\\10202be9\\persists\\backup\\");
|
|
1553 |
QString nameOld = commsdatDir + epocCommsdatFilename;
|
|
1554 |
QString nameDefault = storeDir + newCommsdatFilename;
|
|
1555 |
|
|
1556 |
// First remove the old CommsDat file.
|
|
1557 |
Q_ASSERT(QFile::remove(nameOld) == TRUE);
|
|
1558 |
|
|
1559 |
// Copy the stored default CommsDat file.
|
|
1560 |
Q_ASSERT(QFile::copy(nameDefault, nameOld) == TRUE);
|
|
1561 |
}
|
|
1562 |
|
|
1563 |
/**
|
|
1564 |
*
|
|
1565 |
*/
|
|
1566 |
void TestWlanQtUtils::subTestNewWlanQtUtils()
|
|
1567 |
{
|
39
|
1568 |
delete wlanQtUtils_;
|
31
|
1569 |
wlanQtUtils_ = new WlanQtUtils();
|
|
1570 |
|
39
|
1571 |
delete mSignalScanReady;
|
|
1572 |
mSignalScanReady = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanScanReady(int)));
|
|
1573 |
QVERIFY(mSignalScanReady->isValid() == true);
|
31
|
1574 |
|
39
|
1575 |
delete mSignalScanApReady;
|
|
1576 |
mSignalScanApReady = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanScanApReady(int)));
|
|
1577 |
QVERIFY(mSignalScanApReady->isValid() == true);
|
|
1578 |
|
|
1579 |
delete mSignalScanDirectReady;
|
|
1580 |
mSignalScanDirectReady = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanScanDirectReady(int)));
|
|
1581 |
QVERIFY(mSignalScanDirectReady->isValid() == true);
|
|
1582 |
|
|
1583 |
delete signalWlanNetworkOpened_;
|
31
|
1584 |
signalWlanNetworkOpened_ = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanNetworkOpened(int)));
|
|
1585 |
QVERIFY(signalWlanNetworkOpened_->isValid() == true);
|
|
1586 |
|
39
|
1587 |
delete signalWlanNetworkClosed_;
|
31
|
1588 |
signalWlanNetworkClosed_ = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanNetworkClosed(int, int)));
|
|
1589 |
QVERIFY(signalWlanNetworkClosed_->isValid() == true);
|
|
1590 |
|
39
|
1591 |
delete signalIctResult_;
|
|
1592 |
signalIctResult_ = new QSignalSpy(wlanQtUtils_, SIGNAL(ictResult(int, int)));
|
31
|
1593 |
QVERIFY(signalIctResult_->isValid() == true);
|
|
1594 |
}
|
39
|
1595 |
|
|
1596 |
/**
|
|
1597 |
* Create a new AP and fill it with default values.
|
|
1598 |
*/
|
|
1599 |
WlanQtUtilsAp *TestWlanQtUtils::subTestNewAp()
|
|
1600 |
{
|
|
1601 |
WlanQtUtilsAp *ap = new WlanQtUtilsAp;
|
|
1602 |
|
|
1603 |
// Set default values
|
60
|
1604 |
ap->setValue(WlanQtUtilsAp::ConfIdName, QString());
|
|
1605 |
ap->setValue(WlanQtUtilsAp::ConfIdSsid, QByteArray());
|
39
|
1606 |
ap->setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90);
|
|
1607 |
ap->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
|
|
1608 |
ap->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen);
|
|
1609 |
ap->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
|
|
1610 |
ap->setValue(WlanQtUtilsAp::ConfIdWpaPsk, QString());
|
|
1611 |
ap->setValue(WlanQtUtilsAp::ConfIdWepKey1, QString());
|
|
1612 |
ap->setValue(WlanQtUtilsAp::ConfIdWepKey2, QString());
|
|
1613 |
ap->setValue(WlanQtUtilsAp::ConfIdWepKey3, QString());
|
|
1614 |
ap->setValue(WlanQtUtilsAp::ConfIdWepKey4, QString());
|
|
1615 |
ap->setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex1);
|
|
1616 |
ap->setValue(WlanQtUtilsAp::ConfIdHidden, false);
|
53
|
1617 |
ap->setValue(WlanQtUtilsAp::ConfIdWlanScanSSID, false);
|
39
|
1618 |
|
|
1619 |
return ap;
|
|
1620 |
}
|