138 /** |
148 /** |
139 * Test available WLAN APs when scan is triggered by client. |
149 * Test available WLAN APs when scan is triggered by client. |
140 */ |
150 */ |
141 void TestWlanQtUtils::testAvailableWlan() |
151 void TestWlanQtUtils::testAvailableWlan() |
142 { |
152 { |
143 testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(4); |
153 testContext.mScan.createDefaultWlanScanResultList(4); |
144 |
154 |
145 // Request a scan to get result signal |
155 // Request a scan to get result signal |
146 wlanQtUtils_->scanWlans(); |
156 wlanQtUtils_->scanWlans(); |
147 |
157 |
148 // Let active object run and verify signal. |
158 // Let active object run and verify signal. |
149 subTestSignalWaitAndTake(signalScanReady_, NULL); |
159 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
150 |
160 |
151 // Get and verify the list of available WLAN APs. |
161 // Get and verify the list of available WLAN APs. |
152 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
162 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
153 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
163 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
154 wlanQtUtils_->availableWlans(iaps, aps); |
164 wlanQtUtils_->availableWlans(iaps, aps); |
155 |
165 |
156 testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); |
166 testContext.mScan.verifyWlanScanResultList(aps); |
157 QCOMPARE(iaps.count(), 0); |
167 QCOMPARE(iaps.count(), 0); |
158 aps.clear(); |
168 aps.clear(); |
159 } |
169 } |
160 |
170 |
161 /** |
171 /** |
162 * Test available WLAN APs when scan is triggered by client. |
172 * Test available WLAN APs when scan is triggered by client. |
163 * Two scan results have the same SSID and the latter one of those will be removed. |
173 * Two scan results have the same SSID and the latter one of those will be removed. |
164 * Two scan results have the same SSID but different security mode |
174 * Two scan results have the same SSID but different security mode |
165 * Two scan results have the same SSID and security mode but different WpaPsk value |
175 * Two scan results have the same SSID and security mode but different WpaPsk value |
166 * and both are included in the results. |
176 * and both are included in the results. |
|
177 * Two scan results have the same SSID but different connection mode |
167 */ |
178 */ |
168 void TestWlanQtUtils::testAvailableWlanDuplicates() |
179 void TestWlanQtUtils::testAvailableWlanDuplicates() |
169 { |
180 { |
170 testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(10); |
181 testContext.mScan.createDefaultWlanScanResultList(11); |
171 testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID"); |
182 testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID"); |
172 testContext.connMon_.wlanScanResult_.wlanScanResultList_[2]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID"); |
183 testContext.mScan.mWlanScanResultList[2]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID"); |
173 testContext.connMon_.wlanScanResult_.wlanScanResultList_[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID, different SecMode"); |
184 testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID, different SecMode"); |
174 testContext.connMon_.wlanScanResult_.wlanScanResultList_[5]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
185 testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
175 testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID, different SecMode"); |
186 testContext.mScan.mWlanScanResultList[6]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID, different SecMode"); |
176 testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeOpen); |
187 testContext.mScan.mWlanScanResultList[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeOpen); |
177 testContext.connMon_.wlanScanResult_.wlanScanResultList_[7]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID & SecMode diff Psk"); |
188 testContext.mScan.mWlanScanResultList[7]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID & SecMode diff Psk"); |
178 testContext.connMon_.wlanScanResult_.wlanScanResultList_[7]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2); |
189 testContext.mScan.mWlanScanResultList[7]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2); |
179 testContext.connMon_.wlanScanResult_.wlanScanResultList_[9]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID & SecMode diff Psk"); |
190 testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID & SecMode diff Psk"); |
180 testContext.connMon_.wlanScanResult_.wlanScanResultList_[9]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2); |
191 testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2); |
181 testContext.connMon_.wlanScanResult_.wlanScanResultList_[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); |
192 testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); |
|
193 testContext.mScan.mWlanScanResultList[10]->setValue(WlanQtUtilsAp::ConfIdSsid, "Same SSID"); |
|
194 testContext.mScan.mWlanScanResultList[10]->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Adhoc); |
182 |
195 |
183 // Request a scan to get result signal |
196 // Request a scan to get result signal |
184 wlanQtUtils_->scanWlans(); |
197 wlanQtUtils_->scanWlans(); |
185 |
198 |
186 // Let active object run and verify signal. |
199 // Let active object run and verify signal. |
187 subTestSignalWaitAndTake(signalScanReady_, NULL); |
200 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
188 |
201 |
189 // Get and verify the list of available WLAN APs. |
202 // Get and verify the list of available WLAN APs. |
190 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
203 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
191 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
204 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
192 wlanQtUtils_->availableWlans(iaps, aps); |
205 wlanQtUtils_->availableWlans(iaps, aps); |
193 |
206 |
194 // First remove AP that has duplicate SSID. |
207 // First remove AP that has duplicate SSID. |
195 testContext.connMon_.wlanScanResult_.wlanScanResultList_.removeAt(2); |
208 testContext.mScan.mWlanScanResultList.removeAt(2); |
196 testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); |
209 testContext.mScan.verifyWlanScanResultList(aps); |
197 QCOMPARE(iaps.count(), 0); |
210 QCOMPARE(iaps.count(), 0); |
198 aps.clear(); |
211 aps.clear(); |
199 } |
212 } |
200 |
213 |
201 /** |
214 /** |
202 * Test available WLAN APs when scan is triggered by client. |
215 * Test available WLAN APs when scan is triggered by client. |
203 * Include all supported security modes. |
216 * Include all supported security modes. |
204 */ |
217 */ |
205 void TestWlanQtUtils::testAvailableWlanSecModes() |
218 void TestWlanQtUtils::testAvailableWlanSecModes() |
206 { |
219 { |
207 testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(9); |
220 testContext.mScan.createDefaultWlanScanResultList(11); |
208 testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeOpen); |
221 testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen); |
209 testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Adhoc); |
222 testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Adhoc); |
210 testContext.connMon_.wlanScanResult_.wlanScanResultList_[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWep); |
223 testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWep); |
211 testContext.connMon_.wlanScanResult_.wlanScanResultList_[2]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecMode802_1x); |
224 testContext.mScan.mWlanScanResultList[2]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWep); |
212 testContext.connMon_.wlanScanResult_.wlanScanResultList_[3]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
225 testContext.mScan.mWlanScanResultList[3]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecMode802_1x); |
213 testContext.connMon_.wlanScanResult_.wlanScanResultList_[4]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
226 testContext.mScan.mWlanScanResultList[4]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); |
214 testContext.connMon_.wlanScanResult_.wlanScanResultList_[4]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); |
227 testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); |
215 testContext.connMon_.wlanScanResult_.wlanScanResultList_[5]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2); |
228 testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); |
216 testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa2); |
229 testContext.mScan.mWlanScanResultList[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2); |
217 testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); |
230 testContext.mScan.mWlanScanResultList[7]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2); |
218 testContext.connMon_.wlanScanResult_.wlanScanResultList_[7]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWapi); |
231 testContext.mScan.mWlanScanResultList[7]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); |
219 testContext.connMon_.wlanScanResult_.wlanScanResultList_[8]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWapi); |
232 testContext.mScan.mWlanScanResultList[8]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWapi); |
|
233 testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWapi); |
220 // Let's trick the stub to return WapiPsk by putting WpaPskUse on * |
234 // Let's trick the stub to return WapiPsk by putting WpaPskUse on * |
221 testContext.connMon_.wlanScanResult_.wlanScanResultList_[8]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); |
235 testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); |
|
236 testContext.mScan.mWlanScanResultList[10]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa2); |
|
237 testContext.mScan.mWlanScanResultList[10]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); |
|
238 testContext.mScan.mWlanScanResultList[10]->setValue(WlanQtUtilsAp::ConfIdWpsSupported, true); |
222 |
239 |
223 // Request a scan to get result signal |
240 // Request a scan to get result signal |
224 wlanQtUtils_->scanWlans(); |
241 wlanQtUtils_->scanWlans(); |
225 |
242 |
226 // Let active object run and verify signal. |
243 // Let active object run and verify signal. |
227 subTestSignalWaitAndTake(signalScanReady_, NULL); |
244 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
228 |
245 |
229 // Get and verify the list of available WLAN APs. |
246 // Get and verify the list of available WLAN APs. |
230 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
247 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
231 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
248 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
232 wlanQtUtils_->availableWlans(iaps, aps); |
249 wlanQtUtils_->availableWlans(iaps, aps); |
233 |
250 |
234 // Remove the trick *. WapiPsk and Wapi both map to just Wapi |
251 // Remove the trick *. WapiPsk and Wapi both map to just Wapi |
235 testContext.connMon_.wlanScanResult_.wlanScanResultList_[8]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,false); |
252 testContext.mScan.mWlanScanResultList[9]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,false); |
236 testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); |
253 testContext.mScan.verifyWlanScanResultList(aps); |
237 QCOMPARE(iaps.count(), 0); |
254 QCOMPARE(iaps.count(), 0); |
238 aps.clear(); |
255 aps.clear(); |
239 } |
256 } |
240 |
257 |
241 /** |
258 /** |
242 * Test available WLAN APs when scan is triggered by client. |
259 * Test available WLAN APs when scan is triggered by client. |
243 * Include some exotic ssids. |
260 * Include some exotic ssids. |
244 */ |
261 */ |
245 void TestWlanQtUtils::testAvailableWlanSsids() |
262 void TestWlanQtUtils::testAvailableWlanSsids() |
246 { |
263 { |
247 testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(6); |
264 testContext.mScan.createDefaultWlanScanResultList(6); |
248 testContext.connMon_.wlanScanResult_.wlanScanResultList_[1]->setValue(WlanQtUtilsAp::ConfIdSsid, " "); |
265 testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSsid, " "); |
249 testContext.connMon_.wlanScanResult_.wlanScanResultList_[2]->setValue(WlanQtUtilsAp::ConfIdSsid, " whitespace around ssid "); |
266 testContext.mScan.mWlanScanResultList[2]->setValue(WlanQtUtilsAp::ConfIdSsid, " whitespace around ssid "); |
250 testContext.connMon_.wlanScanResult_.wlanScanResultList_[3]->setValue(WlanQtUtilsAp::ConfIdSsid, QString(QChar())); |
267 testContext.mScan.mWlanScanResultList[3]->setValue(WlanQtUtilsAp::ConfIdSsid, QString(QChar())); |
251 testContext.connMon_.wlanScanResult_.wlanScanResultList_[4]->setValue(WlanQtUtilsAp::ConfIdSsid, "maximum length ssid that is 32 c"); |
268 testContext.mScan.mWlanScanResultList[4]->setValue(WlanQtUtilsAp::ConfIdSsid, "maximum length ssid that is 32 c"); |
252 testContext.connMon_.wlanScanResult_.wlanScanResultList_[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "A"); |
269 testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "A"); |
253 |
270 |
254 // Request a scan to get result signal |
271 // Request a scan to get result signal |
255 wlanQtUtils_->scanWlans(); |
272 wlanQtUtils_->scanWlans(); |
256 |
273 |
257 // Let active object run and verify signal. |
274 // Let active object run and verify signal. |
258 subTestSignalWaitAndTake(signalScanReady_, NULL); |
275 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
259 |
276 |
260 // Get and verify the list of available WLAN APs. |
277 // Get and verify the list of available WLAN APs. |
261 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
278 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
262 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
279 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
263 wlanQtUtils_->availableWlans(iaps, aps); |
280 wlanQtUtils_->availableWlans(iaps, aps); |
264 |
281 |
265 // Empty ssids are removed from results |
282 // Empty ssids are removed from results |
266 testContext.connMon_.wlanScanResult_.wlanScanResultList_.removeAt(3); |
283 testContext.mScan.mWlanScanResultList.removeAt(3); |
267 testContext.connMon_.wlanScanResult_.wlanScanResultList_.removeAt(1); |
284 testContext.mScan.mWlanScanResultList.removeAt(1); |
268 testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); |
285 testContext.mScan.verifyWlanScanResultList(aps); |
269 QCOMPARE(iaps.count(), 0); |
286 QCOMPARE(iaps.count(), 0); |
270 aps.clear(); |
287 aps.clear(); |
271 } |
288 } |
272 |
289 |
273 /** |
290 /** |
274 * Test available WLAN APs when there are also WLAN IAPs available. |
291 * Test available WLAN APs when there are also WLAN IAPs available. |
275 */ |
292 */ |
276 void TestWlanQtUtils::testAvailableWlanWithIaps() |
293 void TestWlanQtUtils::testAvailableWlanWithIaps() |
277 { |
294 { |
278 testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(7); |
295 testContext.mScan.createDefaultWlanScanResultList(7); |
279 testContext.connMon_.wlanScanResult_.wlanScanResultList_[1]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 3"); |
296 testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 3"); |
280 testContext.connMon_.wlanScanResult_.wlanScanResultList_[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
297 testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
281 testContext.connMon_.wlanScanResult_.wlanScanResultList_[1]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); |
298 testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); |
282 testContext.connMon_.wlanScanResult_.wlanScanResultList_[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 1"); |
299 testContext.mScan.mWlanScanResultList[5]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 1"); |
283 // SSID is found in Internet Snap, but security mode does not match: |
300 // SSID is found in Internet Snap, but security mode does not match: |
284 testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 2"); |
301 testContext.mScan.mWlanScanResultList[6]->setValue(WlanQtUtilsAp::ConfIdSsid, "WLAN IAP 2"); |
285 testContext.connMon_.wlanScanResult_.wlanScanResultList_[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
302 testContext.mScan.mWlanScanResultList[6]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
286 |
303 |
287 // Request a scan to get result signal |
304 // Request a scan to get result signal |
288 wlanQtUtils_->scanWlans(); |
305 wlanQtUtils_->scanWlans(); |
289 |
306 |
290 // Let active object run and verify signal. |
307 // Let active object run and verify signal. |
291 subTestSignalWaitAndTake(signalScanReady_, NULL); |
308 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
292 |
309 |
293 // Get and verify the list of available WLAN APs. |
310 // Get and verify the list of available WLAN APs. |
294 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
311 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
295 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
312 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
296 wlanQtUtils_->availableWlans(iaps, aps); |
313 wlanQtUtils_->availableWlans(iaps, aps); |
297 |
314 |
298 // Verify WLAN AP list. First, remove scan results that will not appear |
315 // Verify WLAN AP list. First, remove scan results that will not appear |
299 // because they are WLAN IAPs. |
316 // because they are WLAN IAPs. |
300 testContext.connMon_.wlanScanResult_.wlanScanResultList_.removeAt(5); |
317 testContext.mScan.mWlanScanResultList.removeAt(5); |
301 testContext.connMon_.wlanScanResult_.wlanScanResultList_.removeAt(1); |
318 testContext.mScan.mWlanScanResultList.removeAt(1); |
302 testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); |
319 testContext.mScan.verifyWlanScanResultList(aps); |
303 |
320 |
304 // Verify WLAN IAP list |
321 // Verify WLAN IAP list |
305 QCOMPARE(iaps.count(), 2); |
322 QCOMPARE(iaps.count(), 2); |
306 QCOMPARE(iaps[0]->value(WlanQtUtilsIap::ConfIdIapId).toInt(), 5); |
323 QCOMPARE(iaps[0]->value(WlanQtUtilsIap::ConfIdIapId).toInt(), 5); |
307 QCOMPARE(iaps[0]->value(WlanQtUtilsIap::ConfIdName).toString(), QString("WLAN IAP 1")); |
324 QCOMPARE(iaps[0]->value(WlanQtUtilsIap::ConfIdName).toString(), QString("WLAN IAP 1")); |
326 QCOMPARE(aps.count(), 0); |
343 QCOMPARE(aps.count(), 0); |
327 QCOMPARE(iaps.count(), 0); |
344 QCOMPARE(iaps.count(), 0); |
328 |
345 |
329 // **************** 1st scan ******************** |
346 // **************** 1st scan ******************** |
330 // 6 APs are required for this scan |
347 // 6 APs are required for this scan |
331 testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(6); |
348 testContext.mScan.createDefaultWlanScanResultList(6); |
332 |
349 |
333 wlanQtUtils_->scanWlans(); |
350 wlanQtUtils_->scanWlans(); |
334 subTestSignalWaitAndTake(signalScanReady_, NULL); |
351 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
335 |
352 |
336 // Get the results for the 1st scan |
353 // Get the results for the 1st scan |
337 wlanQtUtils_->availableWlans(iaps, aps); |
354 wlanQtUtils_->availableWlans(iaps, aps); |
338 // Verify the results for the scan |
355 // Verify the results for the scan |
339 testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); |
356 testContext.mScan.verifyWlanScanResultList(aps); |
340 QCOMPARE(iaps.count(), 0); |
357 QCOMPARE(iaps.count(), 0); |
341 aps.clear(); |
358 aps.clear(); |
342 |
359 |
343 // **************** 2nd scan ******************** |
360 // **************** 2nd scan ******************** |
344 // 2 APs are required for this scan |
361 // 2 APs are required for this scan |
345 testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(2); |
362 testContext.mScan.createDefaultWlanScanResultList(2); |
346 |
363 |
347 wlanQtUtils_->scanWlans(); |
364 wlanQtUtils_->scanWlans(); |
348 subTestSignalWaitAndTake(signalScanReady_, NULL); |
365 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
349 |
366 |
350 // Get the results for the 2nd scan |
367 // Get the results for the 2nd scan |
351 wlanQtUtils_->availableWlans(iaps, aps); |
368 wlanQtUtils_->availableWlans(iaps, aps); |
352 // Verify the results for the scan |
369 // Verify the results for the scan |
353 testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); |
370 testContext.mScan.verifyWlanScanResultList(aps); |
354 QCOMPARE(iaps.count(), 0); |
371 QCOMPARE(iaps.count(), 0); |
355 aps.clear(); |
372 aps.clear(); |
356 |
373 |
357 // **************** 3rd scan ******************** |
374 // **************** 3rd scan ******************** |
358 // 4 APs are required for the 3rd scan |
375 // 4 APs are required for the 3rd scan |
359 testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(4); |
376 testContext.mScan.createDefaultWlanScanResultList(4); |
360 |
377 |
361 wlanQtUtils_->scanWlans(); |
378 wlanQtUtils_->scanWlans(); |
362 subTestSignalWaitAndTake(signalScanReady_, NULL); |
379 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
363 |
380 |
364 // Get the results for the 3rd scan |
381 // Get the results for the 3rd scan |
365 wlanQtUtils_->availableWlans(iaps, aps); |
382 wlanQtUtils_->availableWlans(iaps, aps); |
366 // Verify the results for the scan |
383 // Verify the results for the scan |
367 testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); |
384 testContext.mScan.verifyWlanScanResultList(aps); |
368 QCOMPARE(iaps.count(), 0); |
385 QCOMPARE(iaps.count(), 0); |
369 aps.clear(); |
386 aps.clear(); |
|
387 } |
|
388 |
|
389 /** |
|
390 * Test availability scan that finds nothing. |
|
391 */ |
|
392 void TestWlanQtUtils::testAvailableWlanScanEmpty() |
|
393 { |
|
394 // Form result list |
|
395 testContext.mScan.createDefaultWlanScanResultList(0); |
|
396 |
|
397 // Request a direct scan to get result signal |
|
398 wlanQtUtils_->scanWlans(); |
|
399 |
|
400 // Let active object run and verify signal. |
|
401 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
|
402 |
|
403 // Get and verify the list of available WLAN APs. |
|
404 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
|
405 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
|
406 wlanQtUtils_->availableWlans(iaps, aps); |
|
407 testContext.mScan.verifyWlanScanResultList(aps); |
|
408 QCOMPARE(iaps.count(), 0); |
|
409 } |
|
410 |
|
411 /** |
|
412 * Test WLAN availability scan failure. |
|
413 */ |
|
414 void TestWlanQtUtils::testAvailableWlanScanError() |
|
415 { |
|
416 // Set the scan to fail |
|
417 testContext.mScan.mScanRetValue = KErrGeneral; |
|
418 |
|
419 // Start the scan |
|
420 wlanQtUtils_->scanWlans(); |
|
421 |
|
422 // Catch & check the scan result signal |
|
423 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusError); |
|
424 } |
|
425 |
|
426 /** |
|
427 * Test available WLAN APs when scan is triggered by client. |
|
428 */ |
|
429 void TestWlanQtUtils::testAvailableWlanAps() |
|
430 { |
|
431 testContext.mScan.createDefaultWlanScanResultList(4); |
|
432 |
|
433 // Request a scan to get result signal |
|
434 wlanQtUtils_->scanWlanAps(); |
|
435 |
|
436 // Let active object run and verify signal. |
|
437 subTestScanResultSignal(mSignalScanApReady, WlanQtUtils::ScanStatusOk); |
|
438 |
|
439 // Get and verify the list of available WLAN APs. |
|
440 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
|
441 wlanQtUtils_->availableWlanAps(aps); |
|
442 |
|
443 testContext.mScan.verifyWlanScanResultList(aps); |
|
444 aps.clear(); |
|
445 } |
|
446 |
|
447 /** |
|
448 * Test a direct scan that finds nothing. |
|
449 */ |
|
450 void TestWlanQtUtils::testAvailableWlanApsScanEmpty() |
|
451 { |
|
452 // Form result list |
|
453 testContext.mScan.createDefaultWlanScanResultList(0); |
|
454 |
|
455 // Request a direct scan to get result signal |
|
456 wlanQtUtils_->scanWlanAps(); |
|
457 |
|
458 // Let active object run and verify signal. |
|
459 subTestScanResultSignal(mSignalScanApReady, WlanQtUtils::ScanStatusOk); |
|
460 |
|
461 // Get and verify the list of available WLAN APs. |
|
462 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
|
463 wlanQtUtils_->availableWlanAps(aps); |
|
464 testContext.mScan.verifyWlanScanResultList(aps); |
|
465 } |
|
466 |
|
467 /** |
|
468 * Test cancellation of WLAN AP scan. |
|
469 */ |
|
470 void TestWlanQtUtils::testStopWlanApScan() |
|
471 { |
|
472 // Do not complete scan request immediately |
|
473 testContext.mScan.mCompleteWlanScan = false; |
|
474 |
|
475 // Start the scan |
|
476 wlanQtUtils_->scanWlanAps(); |
|
477 // Cancel the scan |
|
478 wlanQtUtils_->stopWlanScan(); |
|
479 |
|
480 // Catch & check the scan result signal |
|
481 subTestScanResultSignal(mSignalScanApReady, WlanQtUtils::ScanStatusCancelled); |
|
482 } |
|
483 |
|
484 /** |
|
485 * Test WLAN AP scan failure. |
|
486 */ |
|
487 void TestWlanQtUtils::testWlanApScanError() |
|
488 { |
|
489 // Set the scan to fail |
|
490 testContext.mScan.mScanRetValue = KErrGeneral; |
|
491 |
|
492 // Start the scan |
|
493 wlanQtUtils_->scanWlanAps(); |
|
494 |
|
495 // Catch & check the scan result signal |
|
496 subTestScanResultSignal(mSignalScanApReady, WlanQtUtils::ScanStatusError); |
|
497 } |
|
498 |
|
499 /** |
|
500 * Test a basic direct scan. |
|
501 */ |
|
502 void TestWlanQtUtils::testDirectScanBasic() |
|
503 { |
|
504 // Form result list |
|
505 testContext.mScan.createDefaultWlanScanResultList(2); |
|
506 testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "testssid"); |
|
507 testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen); |
|
508 testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSsid, "testssid"); |
|
509 testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdBssid, "654321"); |
|
510 testContext.mScan.mWlanScanResultList[1]->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); |
|
511 |
|
512 // Request a direct scan to get result signal |
|
513 wlanQtUtils_->scanWlanDirect(QString("testssid")); |
|
514 |
|
515 // Let active object run and verify signal. |
|
516 subTestScanResultSignal(mSignalScanDirectReady, WlanQtUtils::ScanStatusOk); |
|
517 |
|
518 // Get and verify the list of available WLAN APs. |
|
519 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
|
520 wlanQtUtils_->availableWlanAps(aps); |
|
521 |
|
522 testContext.mScan.verifyWlanScanResultList(aps); |
|
523 aps.clear(); |
|
524 } |
|
525 |
|
526 /** |
|
527 * Test a direct scan that finds nothing. |
|
528 */ |
|
529 void TestWlanQtUtils::testDirectScanEmpty() |
|
530 { |
|
531 // Form result list |
|
532 testContext.mScan.createDefaultWlanScanResultList(0); |
|
533 |
|
534 // Request a direct scan to get result signal |
|
535 wlanQtUtils_->scanWlanDirect(QString("notavailable")); |
|
536 |
|
537 // Let active object run and verify signal. |
|
538 subTestScanResultSignal(mSignalScanDirectReady, WlanQtUtils::ScanStatusOk); |
|
539 |
|
540 // Get and verify the list of available WLAN APs. |
|
541 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
|
542 wlanQtUtils_->availableWlanAps(aps); |
|
543 testContext.mScan.verifyWlanScanResultList(aps); |
|
544 } |
|
545 |
|
546 /** |
|
547 * Test cancellation of direct scan. |
|
548 */ |
|
549 void TestWlanQtUtils::testDirectScanStop() |
|
550 { |
|
551 // Do not complete scan request immediately |
|
552 testContext.mScan.mCompleteWlanScan = false; |
|
553 |
|
554 // Start the scan |
|
555 wlanQtUtils_->scanWlanDirect(QString("testssid")); |
|
556 // Cancel the scan |
|
557 wlanQtUtils_->stopWlanScan(); |
|
558 |
|
559 // Catch & check the scan result signal |
|
560 subTestScanResultSignal(mSignalScanDirectReady, WlanQtUtils::ScanStatusCancelled); |
|
561 } |
|
562 |
|
563 /** |
|
564 * Test direct scan failure. |
|
565 */ |
|
566 void TestWlanQtUtils::testDirectScanError() |
|
567 { |
|
568 // Set the scan to fail |
|
569 testContext.mScan.mScanRetValue = KErrGeneral; |
|
570 |
|
571 // Start the scan |
|
572 wlanQtUtils_->scanWlanDirect(QString("boundtofail")); |
|
573 |
|
574 // Catch & check the scan result signal |
|
575 subTestScanResultSignal(mSignalScanDirectReady, WlanQtUtils::ScanStatusError); |
370 } |
576 } |
371 |
577 |
372 /** |
578 /** |
373 * This function tests creation of WLAN IAP in a succesful manner. |
579 * This function tests creation of WLAN IAP in a succesful manner. |
374 * - WLAN scan is made because otherwise we cannot verify that IAP creation is successful. |
580 * - WLAN scan is made because otherwise we cannot verify that IAP creation is successful. |
377 * - Create WLAN IAP. |
583 * - Create WLAN IAP. |
378 * - Check that WLAN IAP has been created and that this IAP is not in WLAN AP scan results. |
584 * - Check that WLAN IAP has been created and that this IAP is not in WLAN AP scan results. |
379 */ |
585 */ |
380 void TestWlanQtUtils::testCreateIapOk() |
586 void TestWlanQtUtils::testCreateIapOk() |
381 { |
587 { |
382 testContext.connMon_.wlanScanResult_.createDefaultWlanScanResultList(1); |
588 testContext.mScan.createDefaultWlanScanResultList(1); |
383 testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapOk"); |
589 testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapOk"); |
384 testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
590 testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdSecurityMode,CMManagerShim::WlanSecModeWpa); |
385 testContext.connMon_.wlanScanResult_.wlanScanResultList_[0]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); |
591 testContext.mScan.mWlanScanResultList[0]->setValue(WlanQtUtilsAp::ConfIdWpaPskUse,true); |
386 |
592 |
387 // Request a scan to get result signal |
593 // Request a scan to get result signal |
388 wlanQtUtils_->scanWlans(); |
594 wlanQtUtils_->scanWlans(); |
389 |
595 |
390 // Let active object run and verify signal. |
596 // Let active object run and verify signal. |
391 subTestSignalWaitAndTake(signalScanReady_, NULL); |
597 subTestScanResultSignal(mSignalScanReady, WlanQtUtils::ScanStatusOk); |
392 |
598 |
393 // Ensure there are no WLAN IAPs but there is one scan result. |
599 // Ensure there are no WLAN IAPs but there is one scan result. |
394 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
600 QList< QSharedPointer<WlanQtUtilsIap> > iaps; |
395 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
601 QList< QSharedPointer<WlanQtUtilsAp> > aps; |
396 wlanQtUtils_->availableWlans(iaps, aps); |
602 wlanQtUtils_->availableWlans(iaps, aps); |
397 |
603 |
398 QCOMPARE(iaps.count(), 0); |
604 QCOMPARE(iaps.count(), 0); |
399 testContext.connMon_.wlanScanResult_.verifyWlanScanResultList(aps); |
605 testContext.mScan.verifyWlanScanResultList(aps); |
400 |
606 |
401 // Execute createIap() function |
607 // Execute createIap() function |
402 WlanQtUtilsAp wlanAp; |
608 QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp()); |
403 wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapOk"); |
609 wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapOk"); |
404 wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 ); |
610 wlanAp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); |
405 wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra); |
611 wlanAp->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); |
406 wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWpa); |
612 wlanAp->setValue(WlanQtUtilsAp::ConfIdWpaPsk, "100euronlounas"); |
407 wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true); |
613 int iapId = wlanQtUtils_->createIap(wlanAp.data()); |
408 wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPsk, "100euronlounas"); |
|
409 int iapId = wlanQtUtils_->createIap(&wlanAp); |
|
410 QVERIFY(iapId != WlanQtUtils::IapIdNone); |
614 QVERIFY(iapId != WlanQtUtils::IapIdNone); |
411 |
615 |
412 // Verify that created IAP is in the IAP list and AP list is empty. |
616 // Verify that created IAP is in the IAP list and AP list is empty. |
413 wlanQtUtils_->availableWlans(iaps, aps); |
617 wlanQtUtils_->availableWlans(iaps, aps); |
414 QCOMPARE(iaps.count(), 1); |
618 QCOMPARE(iaps.count(), 1); |
425 * This function tests creation of WLAN IAP in unsuccesful manner. |
629 * This function tests creation of WLAN IAP in unsuccesful manner. |
426 */ |
630 */ |
427 void TestWlanQtUtils::testCreateIapErr() |
631 void TestWlanQtUtils::testCreateIapErr() |
428 { |
632 { |
429 // Execute createIap() function with invalid parameters |
633 // Execute createIap() function with invalid parameters |
430 WlanQtUtilsAp wlanAp; |
634 QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp()); |
431 wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapErr"); |
635 wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapErr"); |
432 wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90 ); |
636 wlanAp->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false); |
433 wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra); |
|
434 wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false); |
|
435 // Invalid security mode -> exception |
637 // Invalid security mode -> exception |
436 wlanAp.setValue( |
638 wlanAp->setValue( |
437 WlanQtUtilsAp::ConfIdSecurityMode, |
639 WlanQtUtilsAp::ConfIdSecurityMode, |
438 CMManager::EWlanSecModeWAPI + 1111); |
640 CMManager::EWlanSecModeWAPI + 1111); |
439 int iapId = wlanQtUtils_->createIap(&wlanAp); |
641 int iapId = wlanQtUtils_->createIap(wlanAp.data()); |
440 QVERIFY(iapId == WlanQtUtils::IapIdNone); |
642 QVERIFY(iapId == WlanQtUtils::IapIdNone); |
441 } |
643 } |
442 |
644 |
443 /** |
645 /** |
444 * This function tests creation of WLAN IAPs with different WEP keys. |
646 * This function tests creation of WLAN IAPs with different WEP keys. |
445 */ |
647 */ |
446 void TestWlanQtUtils::testCreateIapWepKeys() |
648 void TestWlanQtUtils::testCreateIapWepKeys() |
447 { |
649 { |
448 // Create the IAPs with different kind of WEP keys |
650 // Create the IAPs with different kind of WEP keys |
449 WlanQtUtilsAp wlanAp; |
651 QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp()); |
450 wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapWepKeys"); |
652 wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testCreateIapWepKeys"); |
451 wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90); |
653 wlanAp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWep); |
452 wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra); |
654 wlanAp->setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex2); |
453 wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeWep); |
|
454 wlanAp.setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, 1); |
|
455 // All keys in HEX format |
655 // All keys in HEX format |
456 wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey1, "1234567891"); |
656 wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey1, "1234567891"); |
457 wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey2, "1234567891"); |
657 wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey2, "1234567891"); |
458 wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey3, "1234567891"); |
658 wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey3, "1234567891"); |
459 wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey4, "1234567891"); |
659 wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey4, "1234567891"); |
460 wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false); |
660 |
461 |
661 int iapId = wlanQtUtils_->createIap(wlanAp.data()); |
462 int iapId = wlanQtUtils_->createIap(&wlanAp); |
|
463 QVERIFY(iapId != WlanQtUtils::IapIdNone); |
662 QVERIFY(iapId != WlanQtUtils::IapIdNone); |
464 |
663 |
465 wlanAp.setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, 2); |
664 wlanAp->setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex3); |
466 // All keys in ASCII format |
665 // All keys in ASCII format |
467 wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey1, "12345"); |
666 wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey1, "12345"); |
468 wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey2, "12345"); |
667 wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey2, "12345"); |
469 wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey3, "12345"); |
668 wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey3, "12345"); |
470 wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey4, "12345"); |
669 wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey4, "12345"); |
471 |
670 |
472 iapId = wlanQtUtils_->createIap(&wlanAp); |
671 iapId = wlanQtUtils_->createIap(wlanAp.data()); |
473 QVERIFY(iapId != WlanQtUtils::IapIdNone); |
672 QVERIFY(iapId != WlanQtUtils::IapIdNone); |
474 |
673 |
475 wlanAp.setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, 3); |
674 wlanAp->setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex4); |
476 // Different keys, including a missing one |
675 // Different keys, including a missing one |
477 wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey1, ""); |
676 wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey1, ""); |
478 wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey2, "12345678911234567892123456"); |
677 wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey2, "12345678911234567892123456"); |
479 wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey3, "12345"); |
678 wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey3, "12345"); |
480 wlanAp.setValue(WlanQtUtilsAp::ConfIdWepKey4, "1234567891123"); |
679 wlanAp->setValue(WlanQtUtilsAp::ConfIdWepKey4, "1234567891123"); |
481 |
680 |
482 iapId = wlanQtUtils_->createIap(&wlanAp); |
681 iapId = wlanQtUtils_->createIap(wlanAp.data()); |
483 QVERIFY(iapId != WlanQtUtils::IapIdNone); |
682 QVERIFY(iapId != WlanQtUtils::IapIdNone); |
484 } |
683 } |
485 |
684 |
486 /** |
685 /** |
487 * This function tests updating of WLAN IAP in a succesful manner. |
686 * This function tests updating of WLAN IAP in a succesful manner. |
488 */ |
687 */ |
489 void TestWlanQtUtils::testUpdateIapOk() |
688 void TestWlanQtUtils::testUpdateIapOk() |
490 { |
689 { |
491 // Create an IAP that can be updated |
690 // Create an IAP that can be updated |
492 WlanQtUtilsAp wlanAp; |
691 QScopedPointer<WlanQtUtilsAp> wlanAp(subTestNewAp()); |
493 wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "testUpdateIapOk"); |
692 wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "testUpdateIapOk"); |
494 wlanAp.setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90); |
693 int iapId = wlanQtUtils_->createIap(wlanAp.data()); |
495 wlanAp.setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra); |
|
496 wlanAp.setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen); |
|
497 wlanAp.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false); |
|
498 int iapId = wlanQtUtils_->createIap(&wlanAp); |
|
499 |
694 |
500 // Update the name and verify it changed |
695 // Update the name and verify it changed |
501 wlanAp.setValue(WlanQtUtilsAp::ConfIdSsid, "UPDATED_testUpdateIapOk"); |
696 wlanAp->setValue(WlanQtUtilsAp::ConfIdSsid, "UPDATED_testUpdateIapOk"); |
502 |
697 |
503 bool success = wlanQtUtils_->updateIap(iapId, &wlanAp); |
698 bool success = wlanQtUtils_->updateIap(iapId, wlanAp.data()); |
504 QVERIFY(success == true); |
699 QVERIFY(success == true); |
505 QString name = wlanQtUtils_->iapName(iapId); |
700 QString name = wlanQtUtils_->iapName(iapId); |
506 QCOMPARE(name, QString("UPDATED_testUpdateIapOk")); |
701 QCOMPARE(name, QString("UPDATED_testUpdateIapOk")); |
507 } |
702 } |
508 |
703 |
1195 /** |
1385 /** |
1196 * |
1386 * |
1197 */ |
1387 */ |
1198 void TestWlanQtUtils::subTestNewWlanQtUtils() |
1388 void TestWlanQtUtils::subTestNewWlanQtUtils() |
1199 { |
1389 { |
1200 if (wlanQtUtils_ != NULL) { |
1390 delete wlanQtUtils_; |
1201 delete wlanQtUtils_; |
|
1202 } |
|
1203 wlanQtUtils_ = new WlanQtUtils(); |
1391 wlanQtUtils_ = new WlanQtUtils(); |
1204 |
1392 |
1205 if (signalScanReady_ != NULL) { |
1393 delete mSignalScanReady; |
1206 delete signalScanReady_; |
1394 mSignalScanReady = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanScanReady(int))); |
1207 } |
1395 QVERIFY(mSignalScanReady->isValid() == true); |
1208 signalScanReady_ = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanScanReady())); |
1396 |
1209 QVERIFY(signalScanReady_->isValid() == true); |
1397 delete mSignalScanApReady; |
1210 |
1398 mSignalScanApReady = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanScanApReady(int))); |
1211 if (signalWlanNetworkOpened_ != NULL) { |
1399 QVERIFY(mSignalScanApReady->isValid() == true); |
1212 delete signalWlanNetworkOpened_; |
1400 |
1213 } |
1401 delete mSignalScanDirectReady; |
|
1402 mSignalScanDirectReady = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanScanDirectReady(int))); |
|
1403 QVERIFY(mSignalScanDirectReady->isValid() == true); |
|
1404 |
|
1405 delete signalWlanNetworkOpened_; |
1214 signalWlanNetworkOpened_ = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanNetworkOpened(int))); |
1406 signalWlanNetworkOpened_ = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanNetworkOpened(int))); |
1215 QVERIFY(signalWlanNetworkOpened_->isValid() == true); |
1407 QVERIFY(signalWlanNetworkOpened_->isValid() == true); |
1216 |
1408 |
1217 if (signalWlanNetworkClosed_ != NULL) { |
1409 delete signalWlanNetworkClosed_; |
1218 delete signalWlanNetworkClosed_; |
|
1219 } |
|
1220 signalWlanNetworkClosed_ = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanNetworkClosed(int, int))); |
1410 signalWlanNetworkClosed_ = new QSignalSpy(wlanQtUtils_, SIGNAL(wlanNetworkClosed(int, int))); |
1221 QVERIFY(signalWlanNetworkClosed_->isValid() == true); |
1411 QVERIFY(signalWlanNetworkClosed_->isValid() == true); |
1222 |
1412 |
1223 if (signalIctResult_ != NULL) { |
1413 delete signalIctResult_; |
1224 delete signalIctResult_; |
1414 signalIctResult_ = new QSignalSpy(wlanQtUtils_, SIGNAL(ictResult(int, int))); |
1225 } |
|
1226 signalIctResult_ = new QSignalSpy(wlanQtUtils_, SIGNAL(ictResult(int, bool))); |
|
1227 QVERIFY(signalIctResult_->isValid() == true); |
1415 QVERIFY(signalIctResult_->isValid() == true); |
1228 } |
1416 } |
|
1417 |
|
1418 /** |
|
1419 * Create a new AP and fill it with default values. |
|
1420 */ |
|
1421 WlanQtUtilsAp *TestWlanQtUtils::subTestNewAp() |
|
1422 { |
|
1423 WlanQtUtilsAp *ap = new WlanQtUtilsAp; |
|
1424 |
|
1425 // Set default values |
|
1426 ap->setValue(WlanQtUtilsAp::ConfIdSsid, QString()); |
|
1427 ap->setValue(WlanQtUtilsAp::ConfIdSignalStrength, 90); |
|
1428 ap->setValue(WlanQtUtilsAp::ConfIdConnectionMode, CMManagerShim::Infra); |
|
1429 ap->setValue(WlanQtUtilsAp::ConfIdSecurityMode, CMManagerShim::WlanSecModeOpen); |
|
1430 ap->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, false); |
|
1431 ap->setValue(WlanQtUtilsAp::ConfIdWpaPsk, QString()); |
|
1432 ap->setValue(WlanQtUtilsAp::ConfIdWepKey1, QString()); |
|
1433 ap->setValue(WlanQtUtilsAp::ConfIdWepKey2, QString()); |
|
1434 ap->setValue(WlanQtUtilsAp::ConfIdWepKey3, QString()); |
|
1435 ap->setValue(WlanQtUtilsAp::ConfIdWepKey4, QString()); |
|
1436 ap->setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex1); |
|
1437 ap->setValue(WlanQtUtilsAp::ConfIdHidden, false); |
|
1438 |
|
1439 return ap; |
|
1440 } |