1 /* |
|
2 * Copyright (c) 2009 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 Wizard library. |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <QtCore> |
|
20 #include <QTest> |
|
21 |
|
22 // User includes |
|
23 #include "testwlanwizard.h" |
|
24 #include "wlanwizardutils.h" |
|
25 |
|
26 // External function prototypes |
|
27 |
|
28 // Local constants |
|
29 |
|
30 // ======== LOCAL FUNCTIONS ======== |
|
31 |
|
32 // ======== MEMBER FUNCTIONS ======== |
|
33 |
|
34 // --------------------------------------------------------- |
|
35 // FRAMEWORK FUNCTIONS |
|
36 // --------------------------------------------------------- |
|
37 |
|
38 /** |
|
39 * This function will be called before the first test function is executed. |
|
40 */ |
|
41 void TestWlanWizard::initTestCase() |
|
42 { |
|
43 |
|
44 } |
|
45 |
|
46 /** |
|
47 * This function will be called after the last test function was executed. |
|
48 */ |
|
49 void TestWlanWizard::cleanupTestCase() |
|
50 { |
|
51 } |
|
52 |
|
53 /** |
|
54 * This function will be called before each test function is executed. |
|
55 */ |
|
56 void TestWlanWizard::init() |
|
57 { |
|
58 |
|
59 } |
|
60 |
|
61 /** |
|
62 * This function will be called after each test function is executed. |
|
63 */ |
|
64 void TestWlanWizard::cleanup() |
|
65 { |
|
66 |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // TEST CASES |
|
71 // --------------------------------------------------------- |
|
72 |
|
73 |
|
74 void TestWlanWizard::testWepHex64Valid() |
|
75 { |
|
76 QString key("a0cd9fACDF"); |
|
77 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); |
|
78 QCOMPARE(status, WlanWizardUtils::KeyStatusOk); |
|
79 } |
|
80 |
|
81 void TestWlanWizard::testWepHex128Valid() |
|
82 { |
|
83 QString key("ABCDEFabcdef0123456789AAAA"); |
|
84 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); |
|
85 QCOMPARE(status, WlanWizardUtils::KeyStatusOk); |
|
86 } |
|
87 |
|
88 void TestWlanWizard::testWepHexInvalidCharacters() |
|
89 { |
|
90 QString key("wlanwizard"); |
|
91 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); |
|
92 QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); |
|
93 } |
|
94 |
|
95 void TestWlanWizard::testWepAscii64Valid() |
|
96 { |
|
97 QString key("testi"); |
|
98 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); |
|
99 QCOMPARE(status, WlanWizardUtils::KeyStatusOk); |
|
100 } |
|
101 |
|
102 void TestWlanWizard::testWepAscii128Valid() |
|
103 { |
|
104 QString key("wlanwizardjee"); |
|
105 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); |
|
106 QCOMPARE(status, WlanWizardUtils::KeyStatusOk); |
|
107 } |
|
108 |
|
109 void TestWlanWizard::testWepAsciiInvalidCharacters() |
|
110 { |
|
111 QString key("wlanwizardje"); |
|
112 key.append(QChar(31)); |
|
113 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); |
|
114 QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); |
|
115 } |
|
116 |
|
117 void TestWlanWizard::testWepLength9Invalid() |
|
118 { |
|
119 QString key("123456789"); |
|
120 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); |
|
121 QCOMPARE(status, WlanWizardUtils::KeyStatusWepInvalidLength); |
|
122 } |
|
123 |
|
124 void TestWlanWizard::testWepLength11Invalid() |
|
125 { |
|
126 QString key("12345678901"); |
|
127 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); |
|
128 QCOMPARE(status, WlanWizardUtils::KeyStatusWepInvalidLength); |
|
129 } |
|
130 |
|
131 void TestWlanWizard::testWepLength25Invalid() |
|
132 { |
|
133 QString key("1234567890123456789012345"); |
|
134 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); |
|
135 QCOMPARE(status, WlanWizardUtils::KeyStatusWepInvalidLength); |
|
136 } |
|
137 |
|
138 void TestWlanWizard::testWepLength27Invalid() |
|
139 { |
|
140 QString key("123456789012345678901234567"); |
|
141 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); |
|
142 QCOMPARE(status, WlanWizardUtils::KeyStatusWepInvalidLength); |
|
143 } |
|
144 |
|
145 void TestWlanWizard::testWepLength4Invalid() |
|
146 { |
|
147 QString key("1234"); |
|
148 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); |
|
149 QCOMPARE(status, WlanWizardUtils::KeyStatusWepInvalidLength); |
|
150 } |
|
151 |
|
152 void TestWlanWizard::testWepLength6Invalid() |
|
153 { |
|
154 QString key("123456"); |
|
155 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); |
|
156 QCOMPARE(status, WlanWizardUtils::KeyStatusWepInvalidLength); |
|
157 } |
|
158 |
|
159 void TestWlanWizard::testWepLength12Invalid() |
|
160 { |
|
161 QString key("123456789012"); |
|
162 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); |
|
163 QCOMPARE(status, WlanWizardUtils::KeyStatusWepInvalidLength); |
|
164 } |
|
165 |
|
166 void TestWlanWizard::testWepLength14Invalid() |
|
167 { |
|
168 QString key("12345678901234"); |
|
169 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWepKey(key); |
|
170 QCOMPARE(status, WlanWizardUtils::KeyStatusWepInvalidLength); |
|
171 } |
|
172 |
|
173 // ---------------------------------------------------------------------------- |
|
174 // WPA test cases |
|
175 // ---------------------------------------------------------------------------- |
|
176 void TestWlanWizard::testWpaHexValid() |
|
177 { |
|
178 QString key("1234567890123456789012345678abcdefabcdefabcdefABCDEFABCDEFABCDEF"); |
|
179 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWpaKey(key); |
|
180 QCOMPARE(status, WlanWizardUtils::KeyStatusOk); |
|
181 } |
|
182 |
|
183 void TestWlanWizard::testWpaHexInvalidCharacters() |
|
184 { |
|
185 QString key("abcdefabcdefabcdefABCDEFABCDEFABCDEF123456789012345678901234567G"); |
|
186 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWpaKey(key); |
|
187 QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); |
|
188 } |
|
189 void TestWlanWizard::testWpaAsciiLength8Valid() |
|
190 { |
|
191 QString key("ictsucks"); |
|
192 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWpaKey(key); |
|
193 QCOMPARE(status, WlanWizardUtils::KeyStatusOk); |
|
194 } |
|
195 |
|
196 void TestWlanWizard::testWpaAsciiLength63Valid() |
|
197 { |
|
198 QString key("zxcvbnm,.-asdfghjkl'qwertyuiop1234567890qwertyuiopzxcvbnm,.-123"); |
|
199 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWpaKey(key); |
|
200 QCOMPARE(status, WlanWizardUtils::KeyStatusOk); |
|
201 } |
|
202 |
|
203 void TestWlanWizard::testWpaAsciiLength64Invalid() |
|
204 { |
|
205 QString key("zxcvbnm,.-asdfghjkl'qwertyuiop1234567890qwertyuiopzxcvbnm,.-1234"); |
|
206 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWpaKey(key); |
|
207 QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); |
|
208 } |
|
209 |
|
210 void TestWlanWizard::testWpaAsciiInvalidCharacters() |
|
211 { |
|
212 QString key("wizardrules"); |
|
213 key.append(QChar(127)); |
|
214 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWpaKey(key); |
|
215 QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); |
|
216 } |
|
217 |
|
218 void TestWlanWizard::testWpaLength7Invalid() |
|
219 { |
|
220 QString key("wizards"); |
|
221 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWpaKey(key); |
|
222 QCOMPARE(status, WlanWizardUtils::KeyStatusWpaTooShort); |
|
223 } |
|
224 |
|
225 void TestWlanWizard::testWpaLength65Invalid() |
|
226 { |
|
227 QString key("zxcvbnm,.-asdfghjkl'qwertyuiop1234567890qwertyuiopzxcvbnm,.-12345"); |
|
228 WlanWizardUtils::KeyStatus status = WlanWizardUtils::validateWpaKey(key); |
|
229 QCOMPARE(status, WlanWizardUtils::KeyStatusWpaTooLong); |
|
230 } |
|
231 |
|
232 |
|
233 // ---------------------------------------------------------------------------- |
|
234 // ASCII test cases |
|
235 // ---------------------------------------------------------------------------- |
|
236 void TestWlanWizard::testAsciiValidCharacters() |
|
237 { |
|
238 QString key; |
|
239 for (int i = 32 ; i <= 126 ; i++){ |
|
240 key.append(QChar(i)); |
|
241 } |
|
242 WlanWizardUtils::KeyStatus status = WlanWizardUtils::isAscii(key); |
|
243 QCOMPARE(status, WlanWizardUtils::KeyStatusOk); |
|
244 } |
|
245 |
|
246 void TestWlanWizard::testAsciiInvalidCharactersLower() |
|
247 { |
|
248 QString key("wizardrules"); |
|
249 key.append(QChar(31)); |
|
250 WlanWizardUtils::KeyStatus status = WlanWizardUtils::isAscii(key); |
|
251 QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); |
|
252 } |
|
253 |
|
254 void TestWlanWizard::testAsciiInvalidCharactersUpper() |
|
255 { |
|
256 QString key("wizardrules"); |
|
257 key.append(QChar(127)); |
|
258 WlanWizardUtils::KeyStatus status = WlanWizardUtils::isAscii(key); |
|
259 QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); |
|
260 } |
|
261 |
|
262 |
|
263 // ---------------------------------------------------------------------------- |
|
264 // HEX test cases |
|
265 // ---------------------------------------------------------------------------- |
|
266 void TestWlanWizard::testHexValidCharacters() |
|
267 { |
|
268 QString key("abcdefABCDEF1234567890"); |
|
269 WlanWizardUtils::KeyStatus status = WlanWizardUtils::isHex(key); |
|
270 QCOMPARE(status, WlanWizardUtils::KeyStatusOk); |
|
271 } |
|
272 |
|
273 void TestWlanWizard::testHexInvalidCharactersDigitLower() |
|
274 { |
|
275 QString key("afAF09"); |
|
276 key.append(QChar(47)); |
|
277 WlanWizardUtils::KeyStatus status = WlanWizardUtils::isHex(key); |
|
278 QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); |
|
279 } |
|
280 |
|
281 void TestWlanWizard::testHexInvalidCharactersDigitUpper() |
|
282 { |
|
283 QString key("abc"); |
|
284 key.append(QChar(58)); |
|
285 WlanWizardUtils::KeyStatus status = WlanWizardUtils::isHex(key); |
|
286 QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); |
|
287 } |
|
288 |
|
289 void TestWlanWizard::testHexInvalidCharacters_a_Lower() |
|
290 { |
|
291 QString key("abc"); |
|
292 key.append(QChar(96)); |
|
293 WlanWizardUtils::KeyStatus status = WlanWizardUtils::isHex(key); |
|
294 QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); |
|
295 } |
|
296 |
|
297 void TestWlanWizard::testHexInvalidCharacters_f_Upper() |
|
298 { |
|
299 QString key("abc"); |
|
300 key.append(QChar(103)); |
|
301 WlanWizardUtils::KeyStatus status = WlanWizardUtils::isHex(key); |
|
302 QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); |
|
303 } |
|
304 |
|
305 void TestWlanWizard::testHexInvalidCharacters_A_Lower() |
|
306 { |
|
307 QString key("abc"); |
|
308 key.append(QChar(64)); |
|
309 WlanWizardUtils::KeyStatus status = WlanWizardUtils::isHex(key); |
|
310 QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); |
|
311 } |
|
312 |
|
313 void TestWlanWizard::testHexInvalidCharacters_F_Upper() |
|
314 { |
|
315 QString key("abc"); |
|
316 key.append(QChar(71)); |
|
317 WlanWizardUtils::KeyStatus status = WlanWizardUtils::isHex(key); |
|
318 QCOMPARE(status, WlanWizardUtils::KeyStatusIllegalCharacters); |
|
319 } |
|
320 |
|
321 void TestWlanWizard::testSsidValidCharacters() |
|
322 { |
|
323 QString key("12345678901234567890123456789012"); |
|
324 WlanWizardUtils::SsidStatus status = WlanWizardUtils::validateSsid(key); |
|
325 QCOMPARE(status, WlanWizardUtils::SsidStatusOk); |
|
326 } |
|
327 |
|
328 void TestWlanWizard::testSsidValidCharacters2() |
|
329 { |
|
330 QString key("1"); |
|
331 WlanWizardUtils::SsidStatus status = WlanWizardUtils::validateSsid(key); |
|
332 QCOMPARE(status, WlanWizardUtils::SsidStatusOk); |
|
333 } |
|
334 |
|
335 void TestWlanWizard::testSsidInvalidTooShort() |
|
336 { |
|
337 QString key(""); |
|
338 WlanWizardUtils::SsidStatus status = WlanWizardUtils::validateSsid(key); |
|
339 QCOMPARE(status, WlanWizardUtils::SsidStatusInvalidLength); |
|
340 } |
|
341 |
|
342 void TestWlanWizard::testSsidInvalidTooLong() |
|
343 { |
|
344 QString key("123456789012345678901234567890123"); |
|
345 WlanWizardUtils::SsidStatus status = WlanWizardUtils::validateSsid(key); |
|
346 QCOMPARE(status, WlanWizardUtils::SsidStatusInvalidLength); |
|
347 } |
|