176 * and both are included in the results. |
176 * and both are included in the results. |
177 * Two scan results have the same SSID but different connection mode |
177 * Two scan results have the same SSID but different connection mode |
178 */ |
178 */ |
179 void TestWlanQtUtils::testAvailableWlanDuplicates() |
179 void TestWlanQtUtils::testAvailableWlanDuplicates() |
180 { |
180 { |
181 testContext.mScan.createDefaultWlanScanResultList(11); |
181 testContext.mScan.createDefaultWlanScanApResultList(11); |
182 testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID"); |
182 testContext.mScan.mWlanScanApResultList[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID"); |
183 testContext.mScan.mWlanScanResultList[2]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID"); |
183 testContext.mScan.mWlanScanApResultList[2]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID"); |
184 testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID, different SecMode"); |
184 testContext.mScan.mWlanScanApResultList[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID, different SecMode"); |
185 testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
185 testContext.mScan.mWlanScanApResultList[5]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
186 testContext.mScan.mWlanScanResultList[6]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID, different SecMode"); |
186 testContext.mScan.mWlanScanApResultList[6]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID, different SecMode"); |
187 testContext.mScan.mWlanScanResultList[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeOpen); |
187 testContext.mScan.mWlanScanApResultList[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeOpen); |
188 testContext.mScan.mWlanScanResultList[7]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID & SecMode diff Psk"); |
188 testContext.mScan.mWlanScanApResultList[7]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID & SecMode diff Psk"); |
189 testContext.mScan.mWlanScanResultList[7]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2); |
189 testContext.mScan.mWlanScanApResultList[7]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2); |
190 testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID & SecMode diff Psk"); |
190 testContext.mScan.mWlanScanApResultList[9]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID & SecMode diff Psk"); |
191 testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2); |
191 testContext.mScan.mWlanScanApResultList[9]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2); |
192 testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); |
192 testContext.mScan.mWlanScanApResultList[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); |
193 testContext.mScan.mWlanScanResultList[10]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID"); |
193 testContext.mScan.mWlanScanApResultList[10]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID"); |
194 testContext.mScan.mWlanScanResultList[10]->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Adhoc); |
194 testContext.mScan.mWlanScanApResultList[10]->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Adhoc); |
195 |
195 |
196 // Request a scan to get result signal |
196 // Request a scan to get result signal |
197 wlanQtUtils_->scanWlans(); |
197 wlanQtUtils_->scanWlans(); |
198 |
198 |
199 // Let active object run and verify signal. |
199 // Let active object run and verify signal. |
203 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
203 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
204 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
204 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
205 wlanQtUtils_->availableWlans(iaps, aps); |
205 wlanQtUtils_->availableWlans(iaps, aps); |
206 |
206 |
207 // First remove AP that has duplicate SSID. |
207 // First remove AP that has duplicate SSID. |
208 testContext.mScan.mWlanScanResultList.removeAt(2); |
208 testContext.mScan.mWlanScanApResultList.removeAt(2); |
209 testContext.mScan.verifyWlanScanResultList(aps); |
209 testContext.mScan.verifyWlanScanApResultList(aps); |
210 QCOMPARE(iaps.count(), 0); |
210 QCOMPARE(iaps.count(), 0); |
211 aps.clear(); |
211 aps.clear(); |
212 } |
212 } |
213 |
213 |
214 /** |
214 /** |
215 * Test available WLAN APs when scan is triggered by client. |
215 * Test available WLAN APs when scan is triggered by client. |
216 * Include all supported security modes. |
216 * Include all supported security modes. |
217 */ |
217 */ |
218 void TestWlanQtUtils::testAvailableWlanSecModes() |
218 void TestWlanQtUtils::testAvailableWlanSecModes() |
219 { |
219 { |
220 testContext.mScan.createDefaultWlanScanResultList(11); |
220 testContext.mScan.createDefaultWlanScanApResultList(11); |
221 testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen); |
221 testContext.mScan.mWlanScanApResultList[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen); |
222 testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Adhoc); |
222 testContext.mScan.mWlanScanApResultList[0]->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Adhoc); |
223 testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWep); |
223 testContext.mScan.mWlanScanApResultList[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWep); |
224 testContext.mScan.mWlanScanResultList[2]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWep); |
224 testContext.mScan.mWlanScanApResultList[2]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWep); |
225 testContext.mScan.mWlanScanResultList[3]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecMode802_1x); |
225 testContext.mScan.mWlanScanApResultList[3]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecMode802_1x); |
226 testContext.mScan.mWlanScanResultList[4]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); |
226 testContext.mScan.mWlanScanApResultList[4]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); |
227 testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); |
227 testContext.mScan.mWlanScanApResultList[5]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); |
228 testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); |
228 testContext.mScan.mWlanScanApResultList[5]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); |
229 testContext.mScan.mWlanScanResultList[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2); |
229 testContext.mScan.mWlanScanApResultList[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2); |
230 testContext.mScan.mWlanScanResultList[7]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2); |
230 testContext.mScan.mWlanScanApResultList[7]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2); |
231 testContext.mScan.mWlanScanResultList[7]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); |
231 testContext.mScan.mWlanScanApResultList[7]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); |
232 testContext.mScan.mWlanScanResultList[8]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWapi); |
232 testContext.mScan.mWlanScanApResultList[8]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWapi); |
233 testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWapi); |
233 testContext.mScan.mWlanScanApResultList[9]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWapi); |
234 // Let's trick the stub to return WapiPsk by putting WpaPskUse on * |
234 // Let's trick the stub to return WapiPsk by putting WpaPskUse on * |
235 testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); |
235 testContext.mScan.mWlanScanApResultList[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); |
236 testContext.mScan.mWlanScanResultList[10]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2); |
236 testContext.mScan.mWlanScanApResultList[10]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2); |
237 testContext.mScan.mWlanScanResultList[10]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); |
237 testContext.mScan.mWlanScanApResultList[10]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); |
238 testContext.mScan.mWlanScanResultList[10]->setValue(WlanQtUtilsAp::ConfIdWpsSupported, true); |
238 testContext.mScan.mWlanScanApResultList[10]->setValue(WlanQtUtilsAp::ConfIdWpsSupported, true); |
239 |
239 |
240 // Request a scan to get result signal |
240 // Request a scan to get result signal |
241 wlanQtUtils_->scanWlans(); |
241 wlanQtUtils_->scanWlans(); |
242 |
242 |
243 // Let active object run and verify signal. |
243 // Let active object run and verify signal. |
247 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
247 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
248 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
248 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
249 wlanQtUtils_->availableWlans(iaps, aps); |
249 wlanQtUtils_->availableWlans(iaps, aps); |
250 |
250 |
251 // Remove the trick *. WapiPsk and Wapi both map to just Wapi |
251 // Remove the trick *. WapiPsk and Wapi both map to just Wapi |
252 testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,false); |
252 testContext.mScan.mWlanScanApResultList[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,false); |
253 testContext.mScan.verifyWlanScanResultList(aps); |
253 testContext.mScan.verifyWlanScanApResultList(aps); |
254 QCOMPARE(iaps.count(), 0); |
254 QCOMPARE(iaps.count(), 0); |
255 aps.clear(); |
255 aps.clear(); |
256 } |
256 } |
257 |
257 |
258 /** |
258 /** |
259 * Test available WLAN APs when scan is triggered by client. |
259 * Test available WLAN APs when scan is triggered by client. |
260 * Include some exotic ssids. |
260 * Include some exotic ssids. |
261 */ |
261 */ |
262 void TestWlanQtUtils::testAvailableWlanSsids() |
262 void TestWlanQtUtils::testAvailableWlanSsids() |
263 { |
263 { |
264 testContext.mScan.createDefaultWlanScanResultList(6); |
264 testContext.mScan.createDefaultWlanScanApResultList(6); |
265 testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSsid, " "); |
265 testContext.mScan.mWlanScanApResultList[1]->setValue(WlanQtUtilsAp::ConfIdSsid, " "); |
266 testContext.mScan.mWlanScanResultList[2]->setValue(WlanQtUtilsAp::ConfIdSsid, " whitespace around ssid "); |
266 testContext.mScan.mWlanScanApResultList[2]->setValue(WlanQtUtilsAp::ConfIdSsid, " whitespace around ssid "); |
267 testContext.mScan.mWlanScanResultList[3]->setValue(WlanQtUtilsAp::ConfIdSsid, QString(QChar())); |
267 testContext.mScan.mWlanScanApResultList[3]->setValue(WlanQtUtilsAp::ConfIdSsid, QString(QChar())); |
268 testContext.mScan.mWlanScanResultList[4]->setValue(WlanQtUtilsAp::ConfIdSsid, "maximum length ssid that is 32 c"); |
268 testContext.mScan.mWlanScanApResultList[4]->setValue(WlanQtUtilsAp::ConfIdSsid, "maximum length ssid that is 32 c"); |
269 testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "A"); |
269 testContext.mScan.mWlanScanApResultList[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "A"); |
270 |
270 |
271 // Request a scan to get result signal |
271 // Request a scan to get result signal |
272 wlanQtUtils_->scanWlans(); |
272 wlanQtUtils_->scanWlans(); |
273 |
273 |
274 // Let active object run and verify signal. |
274 // Let active object run and verify signal. |
278 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
278 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
279 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
279 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
280 wlanQtUtils_->availableWlans(iaps, aps); |
280 wlanQtUtils_->availableWlans(iaps, aps); |
281 |
281 |
282 // Empty ssids are removed from results |
282 // Empty ssids are removed from results |
283 testContext.mScan.mWlanScanResultList.removeAt(3); |
283 testContext.mScan.mWlanScanApResultList.removeAt(3); |
284 testContext.mScan.mWlanScanResultList.removeAt(1); |
284 testContext.mScan.mWlanScanApResultList.removeAt(1); |
285 testContext.mScan.verifyWlanScanResultList(aps); |
285 testContext.mScan.verifyWlanScanApResultList(aps); |
286 QCOMPARE(iaps.count(), 0); |
286 QCOMPARE(iaps.count(), 0); |
287 aps.clear(); |
|
288 } |
287 } |
289 |
288 |
290 /** |
289 /** |
291 * Test available WLAN APs when there are also WLAN IAPs available. |
290 * Test available WLAN APs when there are also WLAN IAPs available. |
292 */ |
291 */ |
293 void TestWlanQtUtils::testAvailableWlanWithIaps() |
292 void TestWlanQtUtils::testAvailableWlanWithIaps() |
294 { |
293 { |
295 testContext.mScan.createDefaultWlanScanResultList(7); |
294 // Form WLAN IAP scan result list |
296 testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 3"); |
295 testContext.mScan.createDefaultWlanScanIapResultList(3); |
297 testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
296 testContext.mScan.mWlanScanIapResultList.removeAt(1); |
298 testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); |
297 testContext.mScan.mWlanScanIapResultList[0]->setValue(WlanQtUtilsIap::ConfIdIapId, 5); |
299 testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 1"); |
298 testContext.mScan.mWlanScanIapResultList[1]->setValue(WlanQtUtilsIap::ConfIdIapId, 7); |
|
299 |
|
300 // Form WLAN AP scan result list |
|
301 testContext.mScan.createDefaultWlanScanApResultList(7); |
|
302 testContext.mScan.mWlanScanApResultList[1]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 3"); |
|
303 testContext.mScan.mWlanScanApResultList[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
|
304 testContext.mScan.mWlanScanApResultList[1]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); |
|
305 testContext.mScan.mWlanScanApResultList[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 1"); |
300 // SSID is found in Internet Snap, but security mode does not match: |
306 // SSID is found in Internet Snap, but security mode does not match: |
301 testContext.mScan.mWlanScanResultList[6]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 2"); |
307 testContext.mScan.mWlanScanApResultList[6]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 2"); |
302 testContext.mScan.mWlanScanResultList[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
308 testContext.mScan.mWlanScanApResultList[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
303 |
309 |
304 // Request a scan to get result signal |
310 // Request a scan to get result signal |
305 wlanQtUtils_->scanWlans(); |
311 wlanQtUtils_->scanWlans(); |
306 |
312 |
307 // Let active object run and verify signal. |
313 // Let active object run and verify signal. |
308 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
314 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
310 // Get and verify the list of available WLAN APs. |
316 // Get and verify the list of available WLAN APs. |
311 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
317 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
312 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
318 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
313 wlanQtUtils_->availableWlans(iaps, aps); |
319 wlanQtUtils_->availableWlans(iaps, aps); |
314 |
320 |
|
321 // Verify WLAN IAP list |
|
322 testContext.mScan.verifyWlanScanIapResultList(iaps); |
|
323 |
315 // Verify WLAN AP list. First, remove scan results that will not appear |
324 // Verify WLAN AP list. First, remove scan results that will not appear |
316 // because they are WLAN IAPs. |
325 // because they are WLAN IAPs. |
317 testContext.mScan.mWlanScanResultList.removeAt(5); |
326 testContext.mScan.mWlanScanApResultList.removeAt(5); |
318 testContext.mScan.mWlanScanResultList.removeAt(1); |
327 testContext.mScan.mWlanScanApResultList.removeAt(1); |
319 testContext.mScan.verifyWlanScanResultList(aps); |
328 testContext.mScan.verifyWlanScanApResultList(aps); |
320 |
329 |
321 // Verify WLAN IAP list |
|
322 QCOMPARE(iaps.count(), 2); |
|
323 QCOMPARE(iaps[0]->value(WlanQtUtilsIap::ConfIdIapId).toInt(), 5); |
|
324 QCOMPARE(iaps[0]->value(WlanQtUtilsIap::ConfIdName).toString(), QString("WLAN IAP 1")); |
|
325 QCOMPARE(iaps[0]->value(WlanQtUtilsAp::ConfIdSsid).toString(), QString("WLAN IAP 1")); |
|
326 QCOMPARE(iaps[1]->value(WlanQtUtilsIap::ConfIdIapId).toInt(), 7); |
|
327 QCOMPARE(iaps[1]->value(WlanQtUtilsIap::ConfIdName).toString(), QString("WLAN IAP 3")); |
|
328 QCOMPARE(iaps[1]->value(WlanQtUtilsAp::ConfIdSsid).toString(), QString("WLAN IAP 3")); |
|
329 iaps.clear(); |
330 iaps.clear(); |
330 aps.clear(); |
331 aps.clear(); |
331 } |
332 } |
332 |
333 |
333 /** |
334 /** |
343 QCOMPARE(aps.count(), 0); |
344 QCOMPARE(aps.count(), 0); |
344 QCOMPARE(iaps.count(), 0); |
345 QCOMPARE(iaps.count(), 0); |
345 |
346 |
346 // **************** 1st scan ******************** |
347 // **************** 1st scan ******************** |
347 // 6 APs are required for this scan |
348 // 6 APs are required for this scan |
348 testContext.mScan.createDefaultWlanScanResultList(6); |
349 testContext.mScan.createDefaultWlanScanApResultList(6); |
349 |
350 |
350 wlanQtUtils_->scanWlans(); |
351 wlanQtUtils_->scanWlans(); |
351 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
352 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
352 |
353 |
353 // Get the results for the 1st scan |
354 // Get the results for the 1st scan |
354 wlanQtUtils_->availableWlans(iaps, aps); |
355 wlanQtUtils_->availableWlans(iaps, aps); |
355 // Verify the results for the scan |
356 // Verify the results for the scan |
356 testContext.mScan.verifyWlanScanResultList(aps); |
357 testContext.mScan.verifyWlanScanApResultList(aps); |
357 QCOMPARE(iaps.count(), 0); |
358 QCOMPARE(iaps.count(), 0); |
358 aps.clear(); |
359 aps.clear(); |
359 |
360 |
360 // **************** 2nd scan ******************** |
361 // **************** 2nd scan ******************** |
361 // 2 APs are required for this scan |
362 // 2 APs are required for this scan |
362 testContext.mScan.createDefaultWlanScanResultList(2); |
363 testContext.mScan.createDefaultWlanScanApResultList(2); |
363 |
364 |
364 wlanQtUtils_->scanWlans(); |
365 wlanQtUtils_->scanWlans(); |
365 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
366 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
366 |
367 |
367 // Get the results for the 2nd scan |
368 // Get the results for the 2nd scan |
368 wlanQtUtils_->availableWlans(iaps, aps); |
369 wlanQtUtils_->availableWlans(iaps, aps); |
369 // Verify the results for the scan |
370 // Verify the results for the scan |
370 testContext.mScan.verifyWlanScanResultList(aps); |
371 testContext.mScan.verifyWlanScanApResultList(aps); |
371 QCOMPARE(iaps.count(), 0); |
372 QCOMPARE(iaps.count(), 0); |
372 aps.clear(); |
373 aps.clear(); |
373 |
374 |
374 // **************** 3rd scan ******************** |
375 // **************** 3rd scan ******************** |
375 // 4 APs are required for the 3rd scan |
376 // 4 APs are required for the 3rd scan |
376 testContext.mScan.createDefaultWlanScanResultList(4); |
377 testContext.mScan.createDefaultWlanScanApResultList(4); |
377 |
378 |
378 wlanQtUtils_->scanWlans(); |
379 wlanQtUtils_->scanWlans(); |
379 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
380 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
380 |
381 |
381 // Get the results for the 3rd scan |
382 // Get the results for the 3rd scan |
382 wlanQtUtils_->availableWlans(iaps, aps); |
383 wlanQtUtils_->availableWlans(iaps, aps); |
383 // Verify the results for the scan |
384 // Verify the results for the scan |
384 testContext.mScan.verifyWlanScanResultList(aps); |
385 testContext.mScan.verifyWlanScanApResultList(aps); |
385 QCOMPARE(iaps.count(), 0); |
386 QCOMPARE(iaps.count(), 0); |
386 aps.clear(); |
387 aps.clear(); |
387 } |
388 } |
388 |
389 |
389 /** |
390 /** |
390 * Test availability scan that finds nothing. |
391 * Test availability scan that finds nothing. |
391 */ |
392 */ |
392 void TestWlanQtUtils::testAvailableWlanScanEmpty() |
393 void TestWlanQtUtils::testAvailableWlanScanEmpty() |
393 { |
394 { |
394 // Form result list |
395 // Form result list |
395 testContext.mScan.createDefaultWlanScanResultList(0); |
396 testContext.mScan.createDefaultWlanScanApResultList(0); |
396 |
397 |
397 // Request a direct scan to get result signal |
398 // Request a direct scan to get result signal |
398 wlanQtUtils_->scanWlans(); |
399 wlanQtUtils_->scanWlans(); |
399 |
400 |
400 // Let active object run and verify signal. |
401 // Let active object run and verify signal. |
402 |
403 |
403 // Get and verify the list of available WLAN APs. |
404 // Get and verify the list of available WLAN APs. |
404 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
405 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
405 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
406 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
406 wlanQtUtils_->availableWlans(iaps, aps); |
407 wlanQtUtils_->availableWlans(iaps, aps); |
407 testContext.mScan.verifyWlanScanResultList(aps); |
408 testContext.mScan.verifyWlanScanApResultList(aps); |
408 QCOMPARE(iaps.count(), 0); |
409 QCOMPARE(iaps.count(), 0); |
409 } |
410 } |
410 |
411 |
411 /** |
412 /** |
412 * Test WLAN availability scan failure. |
413 * Test WLAN availability scan failure. |
413 */ |
414 */ |
414 void TestWlanQtUtils::testAvailableWlanScanError() |
415 void TestWlanQtUtils::testAvailableWlanScanError() |
415 { |
416 { |
416 // Set the scan to fail |
417 // Set the scan to fail |
417 testContext.mScan.mScanRetValue = KErrGeneral; |
418 testContext.mScan.mApScanRetValue = KErrGeneral; |
418 |
419 |
419 // Start the scan |
420 // Start the scan |
420 wlanQtUtils_->scanWlans(); |
421 wlanQtUtils_->scanWlans(); |
421 |
422 |
422 // Catch & check the scan result signal |
423 // Catch & check the scan result signal |
438 |
439 |
439 // Get and verify the list of available WLAN APs. |
440 // Get and verify the list of available WLAN APs. |
440 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
441 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
441 wlanQtUtils_->availableWlanAps(aps); |
442 wlanQtUtils_->availableWlanAps(aps); |
442 |
443 |
443 testContext.mScan.verifyWlanScanResultList(aps); |
444 testContext.mScan.verifyWlanScanApResultList(aps); |
444 aps.clear(); |
445 aps.clear(); |
445 } |
446 } |
446 |
447 |
447 /** |
448 /** |
448 * Test a direct scan that finds nothing. |
449 * Test a direct scan that finds nothing. |
449 */ |
450 */ |
450 void TestWlanQtUtils::testAvailableWlanApsScanEmpty() |
451 void TestWlanQtUtils::testAvailableWlanApsScanEmpty() |
451 { |
452 { |
452 // Form result list |
453 // Form result list |
453 testContext.mScan.createDefaultWlanScanResultList(0); |
454 testContext.mScan.createDefaultWlanScanApResultList(0); |
454 |
455 |
455 // Request a direct scan to get result signal |
456 // Request a direct scan to get result signal |
456 wlanQtUtils_->scanWlanAps(); |
457 wlanQtUtils_->scanWlanAps(); |
457 |
458 |
458 // Let active object run and verify signal. |
459 // Let active object run and verify signal. |
459 subTestScanResultSignal(mSignalScanApReady, WlanQtUtils::ScanStatusOk); |
460 subTestScanResultSignal(mSignalScanApReady, WlanQtUtils::ScanStatusOk); |
460 |
461 |
461 // Get and verify the list of available WLAN APs. |
462 // Get and verify the list of available WLAN APs. |
462 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
463 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
463 wlanQtUtils_->availableWlanAps(aps); |
464 wlanQtUtils_->availableWlanAps(aps); |
464 testContext.mScan.verifyWlanScanResultList(aps); |
465 testContext.mScan.verifyWlanScanApResultList(aps); |
465 } |
466 } |
466 |
467 |
467 /** |
468 /** |
468 * Test cancellation of WLAN AP scan. |
469 * Test cancellation of WLAN AP scan. |
469 */ |
470 */ |
470 void TestWlanQtUtils::testStopWlanApScan() |
471 void TestWlanQtUtils::testStopWlanApScan() |
471 { |
472 { |
472 // Do not complete scan request immediately |
473 // Do not complete scan request immediately |
473 testContext.mScan.mCompleteWlanScan = false; |
474 testContext.mScan.mCompleteWlanApScan = false; |
474 |
475 |
475 // Start the scan |
476 // Start the scan |
476 wlanQtUtils_->scanWlanAps(); |
477 wlanQtUtils_->scanWlanAps(); |
477 // Cancel the scan |
478 // Cancel the scan |
478 wlanQtUtils_->stopWlanScan(); |
479 wlanQtUtils_->stopWlanScan(); |
485 * Test WLAN AP scan failure. |
486 * Test WLAN AP scan failure. |
486 */ |
487 */ |
487 void TestWlanQtUtils::testWlanApScanError() |
488 void TestWlanQtUtils::testWlanApScanError() |
488 { |
489 { |
489 // Set the scan to fail |
490 // Set the scan to fail |
490 testContext.mScan.mScanRetValue = KErrGeneral; |
491 testContext.mScan.mApScanRetValue = KErrGeneral; |
491 |
492 |
492 // Start the scan |
493 // Start the scan |
493 wlanQtUtils_->scanWlanAps(); |
494 wlanQtUtils_->scanWlanAps(); |
494 |
495 |
495 // Catch & check the scan result signal |
496 // Catch & check the scan result signal |
496 subTestScanResultSignal(mSignalScanApReady, WlanQtUtils::ScanStatusError); |
497 subTestScanResultSignal(mSignalScanApReady, WlanQtUtils::ScanStatusError); |
497 } |
498 } |
498 |
499 |
499 /** |
500 /** |
500 * Test a basic direct scan. |
501 * Test WLAN AP scan with special characters. |
501 */ |
502 */ |
502 void TestWlanQtUtils::testDirectScanBasic() |
503 void TestWlanQtUtils::testAvailableWlanApsSpecialChars() |
503 { |
504 { |
504 // Form result list |
505 testContext.mScan.createDefaultWlanScanApResultList(3); |
505 testContext.mScan.createDefaultWlanScanResultList(2); |
506 // Set SSID's to include special characters |
506 testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "testssid"); |
507 testContext.mScan.mWlanScanApResultList[0]->setValue( |
507 testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen); |
508 WlanQtUtilsAp::ConfIdSsid, |
508 testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSsid, "testssid"); |
509 "\x57\x41\x50\x49\xBD\xA7\xA4\xE4\xF6"); |
509 testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdBssid, "654321"); |
510 testContext.mScan.mWlanScanApResultList[1]->setValue( |
510 testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); |
511 WlanQtUtilsAp::ConfIdSsid, |
511 |
512 "\x01\x02\x03\xAB\x43\x52\x41\x50\xBB\xA7\xA4\xFE\xFF"); |
512 // Request a direct scan to get result signal |
513 testContext.mScan.mWlanScanApResultList[2]->setValue( |
513 wlanQtUtils_->scanWlanDirect(QString("testssid")); |
514 WlanQtUtilsAp::ConfIdSsid, |
|
515 "12345678901234567890123456789012"); // Maximum SSID length of 32 bytes |
|
516 |
|
517 // Request a scan to get result signal |
|
518 wlanQtUtils_->scanWlanAps(); |
514 |
519 |
515 // Let active object run and verify signal. |
520 // Let active object run and verify signal. |
516 subTestScanResultSignal(mSignalScanDirectReady, WlanQtUtils::ScanStatusOk); |
521 subTestScanResultSignal(mSignalScanApReady, WlanQtUtils::ScanStatusOk); |
517 |
522 |
518 // Get and verify the list of available WLAN APs. |
523 // Get and verify the list of available WLAN APs. |
519 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
524 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
520 wlanQtUtils_->availableWlanAps(aps); |
525 wlanQtUtils_->availableWlanAps(aps); |
521 |
526 |
522 testContext.mScan.verifyWlanScanResultList(aps); |
527 testContext.mScan.verifyWlanScanApResultList(aps); |
523 aps.clear(); |
528 aps.clear(); |
524 } |
529 } |
525 |
530 |
526 /** |
531 /** |
527 * Test a direct scan that finds nothing. |
532 * Test a basic direct scan. |
528 */ |
533 */ |
529 void TestWlanQtUtils::testDirectScanEmpty() |
534 void TestWlanQtUtils::testDirectScanBasic() |
530 { |
535 { |
531 // Form result list |
536 // Form result list |
532 testContext.mScan.createDefaultWlanScanResultList(0); |
537 testContext.mScan.createDefaultWlanScanApResultList(2); |
|
538 testContext.mScan.mWlanScanApResultList[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "testssid"); |
|
539 testContext.mScan.mWlanScanApResultList[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen); |
|
540 testContext.mScan.mWlanScanApResultList[1]->setValue(WlanQtUtilsAp::ConfIdSsid, "testssid"); |
|
541 testContext.mScan.mWlanScanApResultList[1]->setValue(WlanQtUtilsAp::ConfIdBssid, "654321"); |
|
542 testContext.mScan.mWlanScanApResultList[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); |
533 |
543 |
534 // Request a direct scan to get result signal |
544 // Request a direct scan to get result signal |
535 wlanQtUtils_->scanWlanDirect(QString("notavailable")); |
545 wlanQtUtils_->scanWlanDirect(QString("testssid")); |
536 |
546 |
537 // Let active object run and verify signal. |
547 // Let active object run and verify signal. |
538 subTestScanResultSignal(mSignalScanDirectReady, WlanQtUtils::ScanStatusOk); |
548 subTestScanResultSignal(mSignalScanDirectReady, WlanQtUtils::ScanStatusOk); |
539 |
549 |
540 // Get and verify the list of available WLAN APs. |
550 // Get and verify the list of available WLAN APs. |
541 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
551 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
542 wlanQtUtils_->availableWlanAps(aps); |
552 wlanQtUtils_->availableWlanAps(aps); |
543 testContext.mScan.verifyWlanScanResultList(aps); |
553 |
|
554 testContext.mScan.verifyWlanScanApResultList(aps); |
|
555 aps.clear(); |
|
556 } |
|
557 |
|
558 /** |
|
559 * Test a direct scan that finds nothing. |
|
560 */ |
|
561 void TestWlanQtUtils::testDirectScanEmpty() |
|
562 { |
|
563 // Form result list |
|
564 testContext.mScan.createDefaultWlanScanApResultList(0); |
|
565 |
|
566 // Request a direct scan to get result signal |
|
567 wlanQtUtils_->scanWlanDirect(QString("notavailable")); |
|
568 |
|
569 // Let active object run and verify signal. |
|
570 subTestScanResultSignal(mSignalScanDirectReady, WlanQtUtils::ScanStatusOk); |
|
571 |
|
572 // Get and verify the list of available WLAN APs. |
|
573 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
|
574 wlanQtUtils_->availableWlanAps(aps); |
|
575 testContext.mScan.verifyWlanScanApResultList(aps); |
544 } |
576 } |
545 |
577 |
546 /** |
578 /** |
547 * Test cancellation of direct scan. |
579 * Test cancellation of direct scan. |
548 */ |
580 */ |
549 void TestWlanQtUtils::testDirectScanStop() |
581 void TestWlanQtUtils::testDirectScanStop() |
550 { |
582 { |
551 // Do not complete scan request immediately |
583 // Do not complete scan request immediately |
552 testContext.mScan.mCompleteWlanScan = false; |
584 testContext.mScan.mCompleteWlanApScan = false; |
553 |
585 |
554 // Start the scan |
586 // Start the scan |
555 wlanQtUtils_->scanWlanDirect(QString("testssid")); |
587 wlanQtUtils_->scanWlanDirect(QString("testssid")); |
556 // Cancel the scan |
588 // Cancel the scan |
557 wlanQtUtils_->stopWlanScan(); |
589 wlanQtUtils_->stopWlanScan(); |
583 * - Create WLAN IAP. |
615 * - Create WLAN IAP. |
584 * - Check that WLAN IAP has been created and that this IAP is not in WLAN AP scan results. |
616 * - Check that WLAN IAP has been created and that this IAP is not in WLAN AP scan results. |
585 */ |
617 */ |
586 void TestWlanQtUtils::testCreateIapOk() |
618 void TestWlanQtUtils::testCreateIapOk() |
587 { |
619 { |
588 testContext.mScan.createDefaultWlanScanResultList(1); |
620 // Form WLAN AP scan result list |
589 testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapOk"); |
621 testContext.mScan.createDefaultWlanScanApResultList(1); |
590 testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
622 testContext.mScan.mWlanScanApResultList[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapOk"); |
591 testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); |
623 testContext.mScan.mWlanScanApResultList[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
|
624 testContext.mScan.mWlanScanApResultList[0]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); |
|
625 |
|
626 // Form WLAN IAP scan result list |
|
627 testContext.mScan.createDefaultWlanScanIapResultList(0); |
592 |
628 |
593 // Request a scan to get result signal |
629 // Request a scan to get result signal |
594 wlanQtUtils_->scanWlans(); |
630 wlanQtUtils_->scanWlans(); |
595 |
631 |
596 // Let active object run and verify signal. |
632 // Let active object run and verify signal. |
597 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
633 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
598 |
634 |
599 // Ensure there are no WLAN IAPs but there is one scan result. |
635 // Ensure there are no WLAN IAPs but there is one scan result. |
600 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
636 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
601 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
637 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
602 wlanQtUtils_->availableWlans(iaps, aps); |
638 wlanQtUtils_->availableWlans(iaps, aps); |
603 |
639 |
604 QCOMPARE(iaps.count(), 0); |
640 QCOMPARE(iaps.count(), 0); |
605 testContext.mScan.verifyWlanScanResultList(aps); |
641 testContext.mScan.verifyWlanScanApResultList(aps); |
606 |
642 |
607 // Execute createIap() function |
643 // Execute createIap() function |
608 QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp()); |
644 QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp()); |
609 wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapOk"); |
645 wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapOk"); |
610 wlanAp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); |
646 wlanAp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); |
611 wlanAp->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); |
647 wlanAp->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); |
612 wlanAp->setValue(WlanQtUtilsAp::ConfIdWpaPsk, "100euronlounas"); |
648 wlanAp->setValue(WlanQtUtilsAp::ConfIdWpaPsk, "100euronlounas"); |
613 int iapId = wlanQtUtils_->createIap(wlanAp.data()); |
649 int iapId = wlanQtUtils_->createIap(wlanAp.data()); |
614 QVERIFY(iapId != WlanQtUtils::IapIdNone); |
650 QVERIFY(iapId != WlanQtUtils::IapIdNone); |
615 |
651 |
|
652 // Form WLAN IAP scan result list |
|
653 testContext.mScan.createDefaultWlanScanIapResultList(1); |
|
654 testContext.mScan.mWlanScanIapResultList[0]->setValue(WlanQtUtilsIap::ConfIdIapId, iapId); |
|
655 testContext.mScan.mWlanScanIapResultList[0]->setValue(WlanQtUtilsIap::ConfIdName, QString("testCreateIapOk")); |
|
656 testContext.mScan.mWlanScanIapResultList[0]->setValue(WlanQtUtilsIap::ConfIdSsid, QString("testCreateIapOk")); |
|
657 testContext.mScan.mWlanScanIapResultList[0]->setValue(WlanQtUtilsIap::ConfIdSecurityMode, (int)(CMManagerShim::WlanSecModeWpa)); |
|
658 testContext.mScan.mWlanScanIapResultList[0]->setValue(WlanQtUtilsIap::ConfIdWpaPskUse, true); |
|
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 |
616 // Verify that created IAP is in the IAP list and AP list is empty. |
664 // Verify that created IAP is in the IAP list and AP list is empty. |
617 wlanQtUtils_->availableWlans(iaps, aps); |
665 wlanQtUtils_->availableWlans(iaps, aps); |
618 QCOMPARE(iaps.count(), 1); |
666 testContext.mScan.verifyWlanScanIapResultList(iaps); |
619 QCOMPARE(iaps[0]->value(WlanQtUtilsIap::ConfIdIapId).toInt(), iapId); |
|
620 QCOMPARE(iaps[0]->value(WlanQtUtilsIap::ConfIdName).toString(), QString("testCreateIapOk")); |
|
621 QCOMPARE(iaps[0]->value(WlanQtUtilsAp::ConfIdSsid).toString(), QString("testCreateIapOk")); |
|
622 QCOMPARE(iaps[0]->value(WlanQtUtilsAp::ConfIdSecurityMode).toInt(), (int)(CMManagerShim::WlanSecModeWpa)); |
|
623 QCOMPARE(iaps[0]->value(WlanQtUtilsAp::ConfIdWpaPskUse).toBool(), true); |
|
624 QCOMPARE(aps.count(), 0); |
667 QCOMPARE(aps.count(), 0); |
625 iaps.clear(); |
|
626 } |
668 } |
627 |
669 |
628 /** |
670 /** |
629 * This function tests creation of WLAN IAP in unsuccesful manner. |
671 * This function tests creation of WLAN IAP in unsuccesful manner. |
630 */ |
672 */ |