31
|
1 |
/*
|
|
2 |
* Copyright (c) 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 Sniffer application.
|
|
16 |
*/
|
|
17 |
|
|
18 |
// System includes
|
|
19 |
|
|
20 |
#include <QTest>
|
|
21 |
#include <QSharedPointer>
|
|
22 |
#include <HbApplication>
|
|
23 |
#include <HbListWidget>
|
|
24 |
#include <HbListWidgetItem>
|
|
25 |
#include <cmmanagerdefines_shim.h>
|
|
26 |
|
|
27 |
// User includes
|
|
28 |
|
|
29 |
#include "wlanqtutilsiap.h"
|
|
30 |
#include "wlanqtutilsap.h"
|
|
31 |
|
|
32 |
#include "wlansnifferlistwidget.h"
|
|
33 |
#include "t_wlansniffer.h"
|
|
34 |
|
|
35 |
// External function prototypes
|
|
36 |
|
|
37 |
// Local constants
|
|
38 |
|
|
39 |
// ======== LOCAL FUNCTIONS ========
|
|
40 |
|
|
41 |
/*!
|
|
42 |
Test main function. Runs all test cases.
|
|
43 |
*/
|
|
44 |
|
|
45 |
int main(int argc, char *argv[])
|
|
46 |
{
|
|
47 |
HbApplication app(argc, argv);
|
|
48 |
|
|
49 |
char *pass[3];
|
|
50 |
pass[0] = argv[0];
|
|
51 |
pass[1] = "-o";
|
|
52 |
pass[2] = "c:\\data\\TestWlanSniffer.txt";
|
|
53 |
|
|
54 |
TestWlanSniffer tc;
|
|
55 |
int res = QTest::qExec(&tc, 3, pass);
|
|
56 |
|
|
57 |
return res;
|
|
58 |
}
|
|
59 |
|
|
60 |
// ======== MEMBER FUNCTIONS ========
|
|
61 |
|
|
62 |
/*!
|
|
63 |
This function will be called before the first test function is executed.
|
|
64 |
*/
|
|
65 |
|
|
66 |
void TestWlanSniffer::initTestCase()
|
|
67 |
{
|
|
68 |
mWidget = NULL;
|
|
69 |
}
|
|
70 |
|
|
71 |
/*!
|
|
72 |
This function will be called after the last test function was executed.
|
|
73 |
*/
|
|
74 |
|
|
75 |
void TestWlanSniffer::cleanupTestCase()
|
|
76 |
{
|
|
77 |
}
|
|
78 |
|
|
79 |
/*!
|
|
80 |
This function will be called before each test function is executed.
|
|
81 |
*/
|
|
82 |
|
|
83 |
void TestWlanSniffer::init()
|
|
84 |
{
|
|
85 |
mListWidget = new HbListWidget();
|
|
86 |
mWidget = new WlanSnifferListWidget(mListWidget);
|
|
87 |
|
|
88 |
mIaps.clear();
|
|
89 |
mAps.clear();
|
|
90 |
}
|
|
91 |
|
|
92 |
/*!
|
|
93 |
This function will be called after each test function is executed.
|
|
94 |
*/
|
|
95 |
|
|
96 |
void TestWlanSniffer::cleanup()
|
|
97 |
{
|
|
98 |
delete mWidget;
|
|
99 |
mWidget = NULL;
|
|
100 |
|
|
101 |
mListWidget->clear();
|
|
102 |
delete mListWidget;
|
|
103 |
mListWidget = NULL;
|
|
104 |
}
|
|
105 |
|
|
106 |
/*!
|
|
107 |
This function tests Wlan list widget content updating.
|
|
108 |
*/
|
|
109 |
|
|
110 |
void TestWlanSniffer::testUpdateContentIapAdded()
|
|
111 |
{
|
|
112 |
appendWlanAp("SSID 1", 20, 0, CMManagerShim::WlanSecModeOpen);
|
|
113 |
appendWlanAp("SSID 2", 90, 0, CMManagerShim::WlanSecModeWpa);
|
|
114 |
|
|
115 |
mWidget->updateContent(mIaps, mAps, 0);
|
|
116 |
|
|
117 |
QCOMPARE(mListWidget->count(), 2);
|
|
118 |
verifyAp(0, QString("SSID 1"), CMManagerShim::WlanSecModeOpen);
|
|
119 |
verifyAp(1, QString("SSID 2"), CMManagerShim::WlanSecModeWpa);
|
|
120 |
|
|
121 |
appendWlanIap(1, 0, "SSID 3", "SSID 3", 20, CMManagerShim::WlanSecModeWpa);
|
|
122 |
|
|
123 |
mWidget->updateContent(mIaps, mAps, 0);
|
|
124 |
|
|
125 |
QCOMPARE(mListWidget->count(), 3);
|
|
126 |
verifyIap(0, 1);
|
|
127 |
verifyAp(1, QString("SSID 1"), CMManagerShim::WlanSecModeOpen);
|
|
128 |
verifyAp(2, QString("SSID 2"), CMManagerShim::WlanSecModeWpa);
|
|
129 |
}
|
|
130 |
|
|
131 |
/*!
|
|
132 |
This function tests Wlan list widget content updating.
|
|
133 |
*/
|
|
134 |
|
|
135 |
void TestWlanSniffer::testUpdateContentApAdded()
|
|
136 |
{
|
|
137 |
appendWlanAp("SSID 1", 20, 0, CMManagerShim::WlanSecModeOpen);
|
|
138 |
|
|
139 |
mWidget->updateContent(mIaps, mAps, 0);
|
|
140 |
|
|
141 |
QCOMPARE(mListWidget->count(), 1);
|
|
142 |
verifyAp(0, QString("SSID 1"), CMManagerShim::WlanSecModeOpen);
|
|
143 |
|
|
144 |
appendWlanAp("SSID 2", 90, 0, CMManagerShim::WlanSecModeWpa);
|
|
145 |
|
|
146 |
mWidget->updateContent(mIaps, mAps, 0);
|
|
147 |
|
|
148 |
QCOMPARE(mListWidget->count(), 2);
|
|
149 |
verifyAp(0, QString("SSID 1"), CMManagerShim::WlanSecModeOpen);
|
|
150 |
verifyAp(1, QString("SSID 2"), CMManagerShim::WlanSecModeWpa);
|
|
151 |
}
|
|
152 |
|
|
153 |
/*!
|
|
154 |
This function tests Wlan list widget content updating.
|
|
155 |
*/
|
|
156 |
|
|
157 |
void TestWlanSniffer::testUpdateContentIapRemoved()
|
|
158 |
{
|
|
159 |
appendWlanIap(1, 0, "SSID 1", "SSID 1", 20, CMManagerShim::WlanSecModeWpa);
|
|
160 |
appendWlanIap(2, 0, "SSID 2", "SSID 2", 90, CMManagerShim::WlanSecModeWpa);
|
|
161 |
appendWlanAp("SSID 3", 90, 0, CMManagerShim::WlanSecModeWep);
|
|
162 |
|
|
163 |
mWidget->updateContent(mIaps, mAps, 0);
|
|
164 |
|
|
165 |
QCOMPARE(mListWidget->count(), 3);
|
|
166 |
verifyIap(0, 1);
|
|
167 |
verifyIap(1, 2);
|
|
168 |
verifyAp(2, QString("SSID 3"), CMManagerShim::WlanSecModeWep);
|
|
169 |
|
|
170 |
mIaps.takeAt(0);
|
|
171 |
|
|
172 |
mWidget->updateContent(mIaps, mAps, 0);
|
|
173 |
|
|
174 |
QCOMPARE(mListWidget->count(), 2);
|
|
175 |
verifyIap(0, 2);
|
|
176 |
verifyAp(1, QString("SSID 3"), CMManagerShim::WlanSecModeWep);
|
|
177 |
}
|
|
178 |
|
|
179 |
/*!
|
|
180 |
This function tests Wlan list widget content updating.
|
|
181 |
*/
|
|
182 |
|
|
183 |
void TestWlanSniffer::testUpdateContentApRemoved()
|
|
184 |
{
|
|
185 |
appendWlanAp("SSID 1", 20, 0, CMManagerShim::WlanSecModeOpen);
|
|
186 |
|
|
187 |
mWidget->updateContent(mIaps, mAps, 0);
|
|
188 |
|
|
189 |
QCOMPARE(mListWidget->count(), 1);
|
|
190 |
verifyAp(0, QString("SSID 1"), CMManagerShim::WlanSecModeOpen);
|
|
191 |
|
|
192 |
mAps.takeAt(0);
|
|
193 |
|
|
194 |
mWidget->updateContent(mIaps, mAps, 0);
|
|
195 |
|
|
196 |
QCOMPARE(mListWidget->count(), 0);
|
|
197 |
}
|
|
198 |
|
|
199 |
/*!
|
|
200 |
This function tests Wlan list widget content updating.
|
|
201 |
*/
|
|
202 |
|
|
203 |
void TestWlanSniffer::testUpdateContentIapConnected()
|
|
204 |
{
|
|
205 |
appendWlanIap(1, 0, "SSID 1", "SSID 1", 95, CMManagerShim::WlanSecModeWpa);
|
|
206 |
appendWlanIap(2, 0, "SSID 2", "SSID 2", 15, CMManagerShim::WlanSecModeWpa);
|
|
207 |
appendWlanAp("SSID 3", 20, 0, CMManagerShim::WlanSecModeOpen);
|
|
208 |
|
|
209 |
mWidget->updateContent(mIaps, mAps, 0);
|
|
210 |
|
|
211 |
QCOMPARE(mListWidget->count(), 3);
|
|
212 |
verifyIap(0, 1);
|
|
213 |
verifyIap(1, 2);
|
|
214 |
verifyAp(2, QString("SSID 3"), CMManagerShim::WlanSecModeOpen);
|
|
215 |
|
|
216 |
// IAP order changed because one is connected
|
|
217 |
mIaps.clear();
|
|
218 |
appendWlanIap(2, 0, "SSID 2", "SSID 2", 20, CMManagerShim::WlanSecModeWpa);
|
|
219 |
appendWlanIap(1, 0, "SSID 1", "SSID 1", 20, CMManagerShim::WlanSecModeWpa);
|
|
220 |
|
|
221 |
mWidget->updateContent(mIaps, mAps, 2);
|
|
222 |
|
|
223 |
QCOMPARE(mListWidget->count(), 3);
|
|
224 |
verifyIap(0, 2);
|
|
225 |
verifyIap(1, 1);
|
|
226 |
verifyAp(2, QString("SSID 3"), CMManagerShim::WlanSecModeOpen);
|
|
227 |
}
|
|
228 |
|
|
229 |
/*!
|
|
230 |
This function tests Wlan list widget content updating.
|
|
231 |
*/
|
|
232 |
|
|
233 |
void TestWlanSniffer::testUpdateContentIapDisconnected()
|
|
234 |
{
|
|
235 |
appendWlanIap(2, 0, "SSID 2", "SSID 2", 20, CMManagerShim::WlanSecModeWpa);
|
|
236 |
appendWlanIap(1, 0, "SSID 1", "SSID 1", 20, CMManagerShim::WlanSecModeWpa);
|
|
237 |
appendWlanAp("SSID 3", 20, 0, CMManagerShim::WlanSecModeOpen);
|
|
238 |
|
|
239 |
mWidget->updateContent(mIaps, mAps, 2);
|
|
240 |
|
|
241 |
QCOMPARE(mListWidget->count(), 3);
|
|
242 |
verifyIap(0, 2);
|
|
243 |
verifyIap(1, 1);
|
|
244 |
verifyAp(2, QString("SSID 3"), CMManagerShim::WlanSecModeOpen);
|
|
245 |
|
|
246 |
// IAP order changed because not connected anymore
|
|
247 |
mIaps.clear();
|
|
248 |
appendWlanIap(1, 0, "SSID 1", "SSID 1", 20, CMManagerShim::WlanSecModeWpa);
|
|
249 |
appendWlanIap(2, 0, "SSID 2", "SSID 2", 60, CMManagerShim::WlanSecModeWpa);
|
|
250 |
|
|
251 |
mWidget->updateContent(mIaps, mAps, 0);
|
|
252 |
|
|
253 |
QCOMPARE(mListWidget->count(), 3);
|
|
254 |
verifyIap(0, 1);
|
|
255 |
verifyIap(1, 2);
|
|
256 |
verifyAp(2, QString("SSID 3"), CMManagerShim::WlanSecModeOpen);
|
|
257 |
}
|
|
258 |
|
|
259 |
/*!
|
|
260 |
This function tests Wlan list widget content updating.
|
|
261 |
*/
|
|
262 |
|
|
263 |
void TestWlanSniffer::testUpdateContentRobustness1()
|
|
264 |
{
|
|
265 |
appendWlanIap(1, 0, "SSID 1", "SSID 1", 15, CMManagerShim::WlanSecModeWpa);
|
|
266 |
appendWlanIap(2, 0, "SSID 2", "SSID 2", 95, CMManagerShim::WlanSecModeWpa);
|
|
267 |
appendWlanAp("SSID 3", 20, 0, CMManagerShim::WlanSecModeOpen);
|
|
268 |
appendWlanAp("SSID 4", 30, 0, CMManagerShim::WlanSecModeWep);
|
|
269 |
appendWlanAp("SSID 5", 40, 0, CMManagerShim::WlanSecModeOpen);
|
|
270 |
|
|
271 |
mWidget->updateContent(mIaps, mAps, 0);
|
|
272 |
|
|
273 |
QCOMPARE(mListWidget->count(), 5);
|
|
274 |
verifyIap(0, 1);
|
|
275 |
verifyIap(1, 2);
|
|
276 |
verifyAp(2, QString("SSID 3"), CMManagerShim::WlanSecModeOpen);
|
|
277 |
verifyAp(3, QString("SSID 4"), CMManagerShim::WlanSecModeWep);
|
|
278 |
verifyAp(4, QString("SSID 5"), CMManagerShim::WlanSecModeOpen);
|
|
279 |
|
|
280 |
mIaps.clear();
|
|
281 |
appendWlanIap(3, 0, "SSID 3", "SSID 3", 10, CMManagerShim::WlanSecModeOpen);
|
|
282 |
appendWlanIap(1, 0, "SSID 1", "SSID 1", 20, CMManagerShim::WlanSecModeWpa);
|
|
283 |
appendWlanIap(2, 0, "SSID 2", "SSID 2", 30, CMManagerShim::WlanSecModeWpa);
|
|
284 |
mAps.clear();
|
|
285 |
appendWlanAp("SSID 4", 30, 0, CMManagerShim::WlanSecModeWep);
|
|
286 |
appendWlanAp("SSID 5", 40, 0, CMManagerShim::WlanSecModeOpen);
|
|
287 |
appendWlanAp("SSID 6", 30, 0, CMManagerShim::WlanSecModeWep);
|
|
288 |
appendWlanAp("SSID 7", 40, 0, CMManagerShim::WlanSecModeOpen);
|
|
289 |
|
|
290 |
mWidget->updateContent(mIaps, mAps, 3);
|
|
291 |
|
|
292 |
QCOMPARE(mListWidget->count(), 7);
|
|
293 |
verifyIap(0, 3);
|
|
294 |
verifyIap(1, 1);
|
|
295 |
verifyIap(2, 2);
|
|
296 |
verifyAp(3, QString("SSID 4"), CMManagerShim::WlanSecModeWep);
|
|
297 |
verifyAp(4, QString("SSID 5"), CMManagerShim::WlanSecModeOpen);
|
|
298 |
verifyAp(5, QString("SSID 6"), CMManagerShim::WlanSecModeWep);
|
|
299 |
verifyAp(6, QString("SSID 7"), CMManagerShim::WlanSecModeOpen);
|
|
300 |
|
|
301 |
mIaps.clear();
|
|
302 |
appendWlanIap(4, 0, "SSID X", "SSID X", 10, CMManagerShim::WlanSecModeWpa);
|
|
303 |
appendWlanIap(2, 0, "SSID 2", "SSID 2", 20, CMManagerShim::WlanSecModeWpa);
|
|
304 |
appendWlanIap(3, 0, "SSID 3", "SSID 3", 10, CMManagerShim::WlanSecModeOpen);
|
|
305 |
appendWlanIap(5, 0, "SSID 3", "SSID 3", 50, CMManagerShim::WlanSecModeWapi);
|
|
306 |
mAps.clear();
|
|
307 |
appendWlanAp("SSID 4", 30, 0, CMManagerShim::WlanSecModeOpen);
|
|
308 |
appendWlanAp("SSID 4a", 40, 0, CMManagerShim::WlanSecModeOpen);
|
|
309 |
appendWlanAp("SSID 7", 76, 0, CMManagerShim::WlanSecModeOpen);
|
|
310 |
appendWlanAp("SSID 7", 90, 0, CMManagerShim::WlanSecModeWep);
|
|
311 |
appendWlanAp("SSID 8", 30, 0, CMManagerShim::WlanSecModeWpa);
|
|
312 |
appendWlanAp("SSID 9", 30, 0, CMManagerShim::WlanSecModeWpa);
|
|
313 |
|
|
314 |
mWidget->updateContent(mIaps, mAps, 4);
|
|
315 |
|
|
316 |
QCOMPARE(mListWidget->count(), 10);
|
|
317 |
verifyIap(0, 4);
|
|
318 |
verifyIap(1, 2);
|
|
319 |
verifyIap(2, 3);
|
|
320 |
verifyIap(3, 5);
|
|
321 |
verifyAp(4, QString("SSID 4"), CMManagerShim::WlanSecModeOpen);
|
|
322 |
verifyAp(5, QString("SSID 4a"), CMManagerShim::WlanSecModeOpen);
|
|
323 |
verifyAp(6, QString("SSID 7"), CMManagerShim::WlanSecModeOpen);
|
|
324 |
verifyAp(7, QString("SSID 7"), CMManagerShim::WlanSecModeWep);
|
|
325 |
verifyAp(8, QString("SSID 8"), CMManagerShim::WlanSecModeWpa);
|
|
326 |
verifyAp(9, QString("SSID 9"), CMManagerShim::WlanSecModeWpa);
|
|
327 |
|
|
328 |
mIaps.clear();
|
|
329 |
appendWlanIap(3, 0, "SSID 3", "SSID 3", 50, CMManagerShim::WlanSecModeOpen);
|
|
330 |
mAps.clear();
|
|
331 |
|
|
332 |
mWidget->updateContent(mIaps, mAps, 0);
|
|
333 |
|
|
334 |
QCOMPARE(mListWidget->count(), 1);
|
|
335 |
verifyIap(0, 3);
|
|
336 |
|
|
337 |
mIaps.clear();
|
|
338 |
mAps.clear();
|
|
339 |
|
|
340 |
mWidget->updateContent(mIaps, mAps, 0);
|
|
341 |
|
|
342 |
QCOMPARE(mListWidget->count(), 0);
|
|
343 |
}
|
|
344 |
|
|
345 |
/*!
|
|
346 |
This function tests Wlan list widget content updating.
|
|
347 |
*/
|
|
348 |
|
|
349 |
void TestWlanSniffer::testUpdateContentRobustness2()
|
|
350 |
{
|
|
351 |
QSharedPointer<WlanQtUtilsIap> iap2(new WlanQtUtilsIap());
|
|
352 |
iap2->setValue(WlanQtUtilsIap::ConfIdIapId, 2);
|
|
353 |
iap2->setValue(WlanQtUtilsIap::ConfIdNetworkId, 0);
|
|
354 |
iap2->setValue(WlanQtUtilsIap::ConfIdName, "SSID 2");
|
|
355 |
iap2->setValue(WlanQtUtilsAp::ConfIdSsid, "SSID 2");
|
|
356 |
iap2->setValue(WlanQtUtilsAp::ConfIdSignalStrength, 10);
|
39
|
357 |
iap2->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
|
31
|
358 |
iap2->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
|
|
359 |
QSharedPointer<WlanQtUtilsIap> iap4(new WlanQtUtilsIap());
|
|
360 |
iap4->setValue(WlanQtUtilsIap::ConfIdIapId, 4);
|
|
361 |
iap4->setValue(WlanQtUtilsIap::ConfIdNetworkId, 0);
|
|
362 |
iap4->setValue(WlanQtUtilsIap::ConfIdName, "SSID 4");
|
|
363 |
iap4->setValue(WlanQtUtilsAp::ConfIdSsid, "SSID 4");
|
|
364 |
iap4->setValue(WlanQtUtilsAp::ConfIdSignalStrength, 20);
|
39
|
365 |
iap4->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
|
31
|
366 |
iap4->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa);
|
|
367 |
|
|
368 |
appendWlanAp("SSID 1", 20, 0, CMManagerShim::WlanSecModeOpen);
|
|
369 |
appendWlanAp("SSID 3", 20, 0, CMManagerShim::WlanSecModeWpa);
|
|
370 |
appendWlanAp("SSID 5", 20, 0, CMManagerShim::WlanSecModeWpa);
|
|
371 |
appendWlanAp("SSID 6", 20, 0, CMManagerShim::WlanSecModeWpa);
|
|
372 |
|
|
373 |
mIaps.append(iap2);
|
|
374 |
mIaps.append(iap4);
|
|
375 |
|
|
376 |
mWidget->updateContent(mIaps, mAps, 0);
|
|
377 |
|
|
378 |
QCOMPARE(mListWidget->count(), 6);
|
|
379 |
verifyIap(0, 2);
|
|
380 |
verifyIap(1, 4);
|
|
381 |
verifyAp(2, QString("SSID 1"), CMManagerShim::WlanSecModeOpen);
|
|
382 |
verifyAp(3, QString("SSID 3"), CMManagerShim::WlanSecModeWpa);
|
|
383 |
verifyAp(4, QString("SSID 5"), CMManagerShim::WlanSecModeWpa);
|
|
384 |
verifyAp(5, QString("SSID 6"), CMManagerShim::WlanSecModeWpa);
|
|
385 |
|
|
386 |
mIaps.clear();
|
|
387 |
mAps.clear();
|
|
388 |
mIaps.append(iap2);
|
|
389 |
appendWlanAp("SSID 1", 20, 0, CMManagerShim::WlanSecModeOpen);
|
|
390 |
|
|
391 |
mWidget->updateContent(mIaps, mAps, 0);
|
|
392 |
|
|
393 |
QCOMPARE(mListWidget->count(), 2);
|
|
394 |
verifyIap(0, 2);
|
|
395 |
verifyAp(1, QString("SSID 1"), CMManagerShim::WlanSecModeOpen);
|
|
396 |
|
|
397 |
mIaps.clear();
|
|
398 |
mAps.clear();
|
|
399 |
mIaps.append(iap2);
|
|
400 |
mIaps.append(iap4);
|
|
401 |
appendWlanAp("SSID 1", 20, 0, CMManagerShim::WlanSecModeOpen);
|
|
402 |
appendWlanAp("SSID 3", 20, 0, CMManagerShim::WlanSecModeWpa);
|
|
403 |
appendWlanAp("SSID 5", 20, 0, CMManagerShim::WlanSecModeWpa);
|
|
404 |
appendWlanAp("SSID 6", 20, 0, CMManagerShim::WlanSecModeWpa);
|
|
405 |
|
|
406 |
mWidget->updateContent(mIaps, mAps, 0);
|
|
407 |
|
|
408 |
QCOMPARE(mListWidget->count(), 6);
|
|
409 |
verifyIap(0, 2);
|
|
410 |
verifyIap(1, 4);
|
|
411 |
verifyAp(2, QString("SSID 1"), CMManagerShim::WlanSecModeOpen);
|
|
412 |
verifyAp(3, QString("SSID 3"), CMManagerShim::WlanSecModeWpa);
|
|
413 |
verifyAp(4, QString("SSID 5"), CMManagerShim::WlanSecModeWpa);
|
|
414 |
verifyAp(5, QString("SSID 6"), CMManagerShim::WlanSecModeWpa);
|
|
415 |
}
|
|
416 |
|
|
417 |
/*!
|
|
418 |
This function tests list sorting. The list content comes in "random" order,
|
|
419 |
and the list widget should sort the list alphabetically.
|
|
420 |
*/
|
|
421 |
|
|
422 |
void TestWlanSniffer::testUpdateContentSort()
|
|
423 |
{
|
|
424 |
appendWlanIap(1, 0, "Dada", "dada", 20, CMManagerShim::WlanSecModeOpen);
|
|
425 |
appendWlanIap(2, 0, "salakka", "salakka", 30, CMManagerShim::WlanSecModeWpa);
|
|
426 |
appendWlanIap(3, 0, "lahna", "lahna", 40, CMManagerShim::WlanSecModeOpen);
|
|
427 |
appendWlanIap(4, 0, "Labiili", "labiili", 50, CMManagerShim::WlanSecModeOpen);
|
|
428 |
appendWlanIap(5, 0, "ABCD", "ABCD", 60, CMManagerShim::WlanSecModeWpa);
|
|
429 |
appendWlanIap(6, 0, "connected", "connected", 60, CMManagerShim::WlanSecModeOpen);
|
|
430 |
appendWlanIap(7, 0, "IAP 1", "IAP 1", 10, CMManagerShim::WlanSecModeOpen);
|
|
431 |
appendWlanIap(8, 0, "IAP 10", "IAP 10", 10, CMManagerShim::WlanSecModeOpen);
|
|
432 |
appendWlanIap(9, 0, "IAP 2", "IAP 2", 10, CMManagerShim::WlanSecModeOpen);
|
|
433 |
appendWlanIap(10, 0, "IAP 11", "IAP 11", 10, CMManagerShim::WlanSecModeOpen);
|
|
434 |
|
|
435 |
appendWlanAp("jokuap", 20, 0, CMManagerShim::WlanSecModeWpa);
|
|
436 |
appendWlanAp("Jippii", 30, 0, CMManagerShim::WlanSecModeOpen);
|
|
437 |
appendWlanAp("jalava", 40, 0, CMManagerShim::WlanSecModeWpa);
|
|
438 |
appendWlanAp("abba", 50, 0, CMManagerShim::WlanSecModeOpen);
|
|
439 |
appendWlanAp("hippokampus", 60, 0, CMManagerShim::WlanSecModeOpen);
|
|
440 |
|
|
441 |
mWidget->updateContent(mIaps, mAps, 6);
|
|
442 |
|
|
443 |
QCOMPARE(mListWidget->count(), 15);
|
|
444 |
verifyIap(0, 6);
|
|
445 |
verifyIap(1, 5);
|
|
446 |
verifyIap(2, 1);
|
|
447 |
verifyIap(3, 7);
|
|
448 |
verifyIap(4, 8);
|
|
449 |
verifyIap(5, 10);
|
|
450 |
verifyIap(6, 9);
|
|
451 |
verifyIap(7, 4);
|
|
452 |
verifyIap(8, 3);
|
|
453 |
verifyIap(9, 2);
|
|
454 |
verifyAp(10, QString("abba"), CMManagerShim::WlanSecModeOpen);
|
|
455 |
verifyAp(11, QString("hippokampus"), CMManagerShim::WlanSecModeOpen);
|
|
456 |
verifyAp(12, QString("jalava"), CMManagerShim::WlanSecModeWpa);
|
|
457 |
verifyAp(13, QString("Jippii"), CMManagerShim::WlanSecModeOpen);
|
|
458 |
verifyAp(14, QString("jokuap"), CMManagerShim::WlanSecModeWpa);
|
|
459 |
}
|
|
460 |
|
|
461 |
/*!
|
|
462 |
This function tests list scrolling. There's no way to verify in this test
|
|
463 |
that the scrolling actually works, but let's execute the code at least.
|
|
464 |
*/
|
|
465 |
|
|
466 |
void TestWlanSniffer::testScrollTo()
|
|
467 |
{
|
|
468 |
appendWlanIap(1, 0, "SSID 1", "SSID 1", 15, CMManagerShim::WlanSecModeWpa);
|
|
469 |
appendWlanIap(2, 0, "SSID 2", "SSID 2", 95, CMManagerShim::WlanSecModeWpa);
|
|
470 |
appendWlanAp("SSID 3", 20, 0, CMManagerShim::WlanSecModeOpen);
|
|
471 |
appendWlanAp("SSID 4", 30, 0, CMManagerShim::WlanSecModeWep);
|
|
472 |
appendWlanAp("SSID 5", 40, 0, CMManagerShim::WlanSecModeOpen);
|
|
473 |
appendWlanAp("SSID 6", 20, 0, CMManagerShim::WlanSecModeOpen);
|
|
474 |
appendWlanAp("SSID 7", 30, 0, CMManagerShim::WlanSecModeWep);
|
|
475 |
appendWlanAp("SSID 8", 40, 0, CMManagerShim::WlanSecModeOpen);
|
|
476 |
appendWlanAp("SSID 9", 20, 0, CMManagerShim::WlanSecModeOpen);
|
|
477 |
appendWlanAp("SSID 10", 30, 0, CMManagerShim::WlanSecModeWep);
|
|
478 |
appendWlanAp("SSID 11", 40, 0, CMManagerShim::WlanSecModeOpen);
|
|
479 |
appendWlanAp("SSID 12", 20, 0, CMManagerShim::WlanSecModeOpen);
|
|
480 |
appendWlanAp("SSID 13", 30, 0, CMManagerShim::WlanSecModeWep);
|
|
481 |
appendWlanAp("SSID 14", 40, 0, CMManagerShim::WlanSecModeOpen);
|
|
482 |
|
|
483 |
mWidget->updateContent(mIaps, mAps, 0);
|
|
484 |
|
|
485 |
QCOMPARE(mListWidget->count(), 14);
|
|
486 |
|
|
487 |
// Scroll to last row
|
|
488 |
mWidget->scrollTo(13);
|
|
489 |
// Scroll to non-existing row -> ignored
|
|
490 |
mWidget->scrollTo(20);
|
|
491 |
// Scroll to first row
|
|
492 |
mWidget->scrollTo(0);
|
|
493 |
|
|
494 |
QCOMPARE(mListWidget->count(), 14);
|
|
495 |
}
|
|
496 |
|
|
497 |
/*!
|
|
498 |
This function verifies that the item on "row" is an IAP matching the given parameters.
|
|
499 |
*/
|
|
500 |
|
|
501 |
void TestWlanSniffer::verifyIap(int row, int iapId)
|
|
502 |
{
|
|
503 |
QVERIFY(mListWidget->item(row)->data().canConvert<int>());
|
|
504 |
int id = mListWidget->item(row)->data().value<int>();
|
|
505 |
QCOMPARE(id, iapId);
|
|
506 |
}
|
|
507 |
|
|
508 |
/*!
|
|
509 |
This function verifies that the item on "row" is an AP matching the given parameters.
|
|
510 |
*/
|
|
511 |
|
|
512 |
void TestWlanSniffer::verifyAp(int row, QString ssid, int securityMode)
|
|
513 |
{
|
|
514 |
QVERIFY(mListWidget->item(row)->data().canConvert<WlanQtUtilsAp>());
|
|
515 |
WlanQtUtilsAp ap = mListWidget->item(row)->data().value<WlanQtUtilsAp>();
|
|
516 |
QCOMPARE(ap.value(WlanQtUtilsAp::ConfIdSsid).toString(), ssid);
|
|
517 |
QCOMPARE(ap.value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(), securityMode);
|
|
518 |
}
|
|
519 |
|
|
520 |
/*!
|
|
521 |
Sub test case for appending an AP to AP list.
|
|
522 |
*/
|
|
523 |
|
|
524 |
void TestWlanSniffer::appendWlanAp(
|
|
525 |
QString ssId,
|
|
526 |
int signalStrength,
|
|
527 |
int networkMode,
|
|
528 |
int securityMode)
|
|
529 |
{
|
|
530 |
QSharedPointer<WlanQtUtilsAp> ap(new WlanQtUtilsAp());
|
|
531 |
ap->setValue(WlanQtUtilsAp::ConfIdSsid, ssId);
|
|
532 |
ap->setValue(WlanQtUtilsAp::ConfIdSignalStrength, signalStrength);
|
|
533 |
ap->setValue(WlanQtUtilsAp::ConfIdConnectionMode, networkMode);
|
|
534 |
ap->setValue(WlanQtUtilsAp::ConfIdSecurityMode, securityMode);
|
|
535 |
ap->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
|
39
|
536 |
ap->setValue(WlanQtUtilsAp::ConfIdWpsSupported, false);
|
31
|
537 |
mAps.append(ap);
|
|
538 |
}
|
|
539 |
|
|
540 |
/*!
|
|
541 |
Sub test case for appending an IAP to IAP list.
|
|
542 |
*/
|
|
543 |
|
|
544 |
void TestWlanSniffer::appendWlanIap(
|
|
545 |
int iapId,
|
|
546 |
int netId,
|
|
547 |
QString name,
|
|
548 |
QString ssId,
|
|
549 |
int signalStrength,
|
|
550 |
int securityMode)
|
|
551 |
{
|
|
552 |
WlanQtUtilsIap *iap = new WlanQtUtilsIap();
|
|
553 |
iap->setValue(WlanQtUtilsIap::ConfIdIapId, iapId);
|
|
554 |
iap->setValue(WlanQtUtilsIap::ConfIdNetworkId, netId);
|
|
555 |
iap->setValue(WlanQtUtilsIap::ConfIdName, name);
|
|
556 |
iap->setValue(WlanQtUtilsAp::ConfIdSsid, ssId);
|
|
557 |
iap->setValue(WlanQtUtilsAp::ConfIdSignalStrength, signalStrength);
|
39
|
558 |
iap->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra);
|
31
|
559 |
iap->setValue(WlanQtUtilsAp::ConfIdSecurityMode, securityMode);
|
39
|
560 |
iap->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false);
|
|
561 |
iap->setValue(WlanQtUtilsAp::ConfIdWpsSupported, false);
|
31
|
562 |
mIaps.append(QSharedPointer<WlanQtUtilsIap>(iap));
|
|
563 |
}
|