1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Control Panel packet data AP plugin unit testing. |
|
16 */ |
|
17 |
|
18 #include <HbApplication> |
|
19 #include <HbMainWindow> |
|
20 #include <HbView> |
|
21 #include <HbDialog> |
|
22 #include <HbRadioButtonList> |
|
23 #include <HbAction> |
|
24 #include <HbDataForm> |
|
25 #include <HbDataFormModel> |
|
26 #include <HbDataFormModelItem> |
|
27 #include <HbDataFormViewItem> |
|
28 #include <HbModelIterator> |
|
29 #include <HbComboBox> |
|
30 #include <QtTest/QtTest> |
|
31 #include <etelpckt.h> |
|
32 #include <cpbearerapplugininterface.h> |
|
33 #include <cmmanager_shim.h> |
|
34 #include <cmconnectionmethod_shim.h> |
|
35 |
|
36 #include "cppacketdataapview.h" |
|
37 #include "cppacketdataapadvancedview.h" |
|
38 |
|
39 #include "hbautotest.h" |
|
40 #include "testcppacketdataapplugin.h" |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // STATIC TEST DATA |
|
44 // ----------------------------------------------------------------------------- |
|
45 |
|
46 // Connection method (AP) ID used for testing |
|
47 static const uint testApId = 1; |
|
48 |
|
49 static const QString pluginDir = |
|
50 "\\resource\\qt\\plugins\\controlpanel\\bearerap"; |
|
51 |
|
52 static const QString pluginName = "cppacketdataapplugin.dll"; |
|
53 |
|
54 // Time to wait before continuing after an UI step |
|
55 static const int waitTime = 10; |
|
56 |
|
57 // UI coordinates |
|
58 static const QPoint scrollMiddle(350, 280); |
|
59 static const QPoint scrollTop(350, 30); |
|
60 static const QPoint scrollBottom(350, 540); |
|
61 |
|
62 // Use positive offset if dropdown opens under the combobox |
|
63 static const QPoint comboBoxFirstItemOffset(80, 75); |
|
64 static const QPoint comboBoxItemOffset(0, 51); |
|
65 // Use negative offset if dropdown opens above the combobox |
|
66 static const QPoint comboBoxFirstItemNegativeOffset(80, -29); |
|
67 static const QPoint comboBoxItemNegativeOffset(0, -51); |
|
68 |
|
69 static const QPoint exitEditorOffset(-10, -20); |
|
70 |
|
71 static const QPoint messageBoxOkButtonOffset(160, 140); |
|
72 |
|
73 // Advanced settings groups |
|
74 static const QPoint ipGroup(160, 10); |
|
75 static const QPoint proxyGroup(160, 60); |
|
76 |
|
77 // Test strings |
|
78 static const QString tooLongUserName = |
|
79 "too long name 123456789012345678901234567890123456THISISEXTRA"; |
|
80 static const QString truncatedUserName = |
|
81 "too long name 123456789012345678901234567890123456"; |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // FRAMEWORK FUNCTIONS |
|
85 // ----------------------------------------------------------------------------- |
|
86 |
|
87 /** |
|
88 * Test main function. Runs all test cases. |
|
89 */ |
|
90 #ifndef TESTCMAPPLSETTINGSUI_NO_OUTPUT_REDIRECT |
|
91 int main(int argc, char *argv[]) |
|
92 { |
|
93 HbApplication app(argc, argv); |
|
94 app.setApplicationName("TestCpPacketDataApPlugin"); |
|
95 |
|
96 char *pass[3]; |
|
97 pass[0] = argv[0]; |
|
98 pass[1] = "-o"; |
|
99 pass[2] = "c:\\data\\TestCpPacketDataApPlugin.txt"; |
|
100 |
|
101 TestCpPacketDataApPlugin tc; |
|
102 int res = QTest::qExec(&tc, 3, pass); |
|
103 |
|
104 return res; |
|
105 } |
|
106 #else |
|
107 QTEST_MAIN(TestCpPacketDataApPlugin) |
|
108 #endif |
|
109 |
|
110 /** |
|
111 * This function is be called before the first test case is executed. |
|
112 */ |
|
113 void TestCpPacketDataApPlugin::initTestCase() |
|
114 { |
|
115 mMainWindow = new HbAutoTestMainWindow; |
|
116 //mMainWindow = new HbMainWindow; |
|
117 mMainWindow->show(); |
|
118 |
|
119 // Load plugin |
|
120 QDir dir(pluginDir); |
|
121 mPluginLoader = new QPluginLoader(dir.absoluteFilePath(pluginName)); |
|
122 mPlugin = qobject_cast<CpBearerApPluginInterface *>(mPluginLoader->instance()); |
|
123 QVERIFY(mPlugin != NULL); |
|
124 |
|
125 // Verify plugin bearer type |
|
126 QVERIFY(mPlugin->bearerType() == CMManagerShim::BearerTypePacketData); |
|
127 |
|
128 // Write initial settings to CommsDat |
|
129 subInitializeCommsDat(); |
|
130 |
|
131 // Create packet data settings view (connection method ID given) |
|
132 subCreateSettingsView(testApId); |
|
133 |
|
134 subGetUiWidgets(); |
|
135 } |
|
136 |
|
137 /** |
|
138 * This function is be called after the last test case was executed. |
|
139 */ |
|
140 void TestCpPacketDataApPlugin::cleanupTestCase() |
|
141 { |
|
142 delete mMainWindow; |
|
143 mMainWindow = 0; |
|
144 |
|
145 // Force unloading of plugin |
|
146 mPluginLoader->unload(); |
|
147 delete mPluginLoader; |
|
148 mPluginLoader = 0; |
|
149 } |
|
150 |
|
151 /** |
|
152 * This function is be called before each test case is executed. |
|
153 */ |
|
154 void TestCpPacketDataApPlugin::init() |
|
155 { |
|
156 QTest::qWait(1000); |
|
157 } |
|
158 |
|
159 /** |
|
160 * This function is be called after each test case is executed. |
|
161 */ |
|
162 void TestCpPacketDataApPlugin::cleanup() |
|
163 { |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // TEST CASES |
|
168 // ----------------------------------------------------------------------------- |
|
169 |
|
170 /** |
|
171 * Tests changing of connection name. |
|
172 */ |
|
173 void TestCpPacketDataApPlugin::tcChangeConnectionName() |
|
174 { |
|
175 QFETCH(QString, string); |
|
176 QFETCH(QString, result); |
|
177 |
|
178 HbAutoTest::mouseClick(mMainWindow, mConnectionNameWidget); |
|
179 |
|
180 // Erase old string |
|
181 QString text = mTestView->mConnectionNameItem->contentWidgetData("text").toString(); |
|
182 subClearLineEdit(text.size()); |
|
183 |
|
184 // Enter new string |
|
185 HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime); |
|
186 |
|
187 HbAutoTest::mouseClick(mMainWindow, mConnectionNameWidget, exitEditorOffset); |
|
188 |
|
189 // Verify both commsdat and UI widget |
|
190 subVerifyString( |
|
191 CMManagerShim::CmName, |
|
192 mTestView->mConnectionNameItem, |
|
193 result); |
|
194 } |
|
195 |
|
196 /** |
|
197 * Test data for connection name change test case. |
|
198 */ |
|
199 void TestCpPacketDataApPlugin::tcChangeConnectionName_data() |
|
200 { |
|
201 QTest::addColumn<QString>("string"); |
|
202 QTest::addColumn<QString>("result"); |
|
203 |
|
204 QTest::newRow("maximum length") |
|
205 << "really long name 123456789012345678901234567890123" |
|
206 << "really long name 123456789012345678901234567890123"; |
|
207 QTest::newRow("too long") |
|
208 << "too long name 12345678901234567890123456789012345678901234" |
|
209 << "too long name 123456789012345678901234567890123456"; |
|
210 QTest::newRow("basic") // last one must always fit on one line in UI |
|
211 << "test packet AP" |
|
212 << "test packet AP"; |
|
213 } |
|
214 |
|
215 /** |
|
216 * Tests that empty connection name is not accepted. |
|
217 */ |
|
218 void TestCpPacketDataApPlugin::tcConnectionNameEmpty() |
|
219 { |
|
220 QString previous = |
|
221 mTestView->mConnectionNameItem->contentWidgetData("text").toString(); |
|
222 |
|
223 HbAutoTest::mouseClick(mMainWindow, mConnectionNameWidget); |
|
224 |
|
225 // Erase old string |
|
226 QString text = mTestView->mConnectionNameItem->contentWidgetData("text").toString(); |
|
227 subClearLineEdit(text.size()); |
|
228 |
|
229 HbAutoTest::mouseClick(mMainWindow, mConnectionNameWidget, exitEditorOffset); |
|
230 |
|
231 QTest::qWait(100); |
|
232 // Dismiss messagebox |
|
233 HbAutoTest::mouseClick( |
|
234 mMainWindow, |
|
235 mTestView->mMessageBox.data(), |
|
236 messageBoxOkButtonOffset); |
|
237 |
|
238 // Verify both commsdat and UI widget |
|
239 subVerifyString( |
|
240 CMManagerShim::CmName, |
|
241 mTestView->mConnectionNameItem, |
|
242 previous); |
|
243 } |
|
244 |
|
245 /** |
|
246 * Tests changing of access point name. |
|
247 */ |
|
248 void TestCpPacketDataApPlugin::tcChangeAccessPointName() |
|
249 { |
|
250 QFETCH(QString, string); |
|
251 QFETCH(QString, result); |
|
252 |
|
253 HbAutoTest::mouseClick(mMainWindow, mAccessPointNameWidget); |
|
254 |
|
255 // Erase old string |
|
256 QString text = mTestView->mAccessPointNameItem->contentWidgetData("text").toString(); |
|
257 subClearLineEdit(text.size()); |
|
258 |
|
259 // Enter new string |
|
260 HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime); |
|
261 |
|
262 HbAutoTest::mouseClick(mMainWindow, mAccessPointNameWidget, exitEditorOffset); |
|
263 |
|
264 // Verify both commsdat and UI widget |
|
265 subVerifyString( |
|
266 CMManagerShim::PacketDataAPName, |
|
267 mTestView->mAccessPointNameItem, |
|
268 result); |
|
269 } |
|
270 |
|
271 /** |
|
272 * Test data for access point name change test case. |
|
273 */ |
|
274 void TestCpPacketDataApPlugin::tcChangeAccessPointName_data() |
|
275 { |
|
276 QTest::addColumn<QString>("string"); |
|
277 QTest::addColumn<QString>("result"); |
|
278 |
|
279 QTest::newRow("maximum length") |
|
280 << "really long name 12345678901234567890123456789012345678901234567890123456789012345678901234567890123" |
|
281 << "really long name 12345678901234567890123456789012345678901234567890123456789012345678901234567890123"; |
|
282 QTest::newRow("too long") |
|
283 << "too long name 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345" |
|
284 << "too long name 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456"; |
|
285 QTest::newRow("basic") // last one must always fit on one line in UI |
|
286 << "test AP name" |
|
287 << "test AP name"; |
|
288 } |
|
289 |
|
290 /** |
|
291 * Tests that empty access point name is not accepted. |
|
292 */ |
|
293 void TestCpPacketDataApPlugin::tcAccessPointNameEmpty() |
|
294 { |
|
295 QString previous = |
|
296 mTestView->mAccessPointNameItem->contentWidgetData("text").toString(); |
|
297 |
|
298 HbAutoTest::mouseClick(mMainWindow, mAccessPointNameWidget); |
|
299 |
|
300 // Erase old string |
|
301 QString text = mTestView->mAccessPointNameItem->contentWidgetData("text").toString(); |
|
302 subClearLineEdit(text.size()); |
|
303 |
|
304 HbAutoTest::mouseClick(mMainWindow, mAccessPointNameWidget, exitEditorOffset); |
|
305 |
|
306 QTest::qWait(100); |
|
307 // Dismiss messagebox |
|
308 HbAutoTest::mouseClick( |
|
309 mMainWindow, |
|
310 mTestView->mMessageBox.data(), |
|
311 messageBoxOkButtonOffset); |
|
312 |
|
313 // Verify both commsdat and UI widget |
|
314 subVerifyString( |
|
315 CMManagerShim::PacketDataAPName, |
|
316 mTestView->mAccessPointNameItem, |
|
317 previous); |
|
318 } |
|
319 |
|
320 |
|
321 /** |
|
322 * Tests handling of too long string from CommsDat (longer than UI accepts). |
|
323 */ |
|
324 void TestCpPacketDataApPlugin::tcTooLongUserNameInCommsDat() |
|
325 { |
|
326 // Verify UI text, the widget contains the too long string, even though |
|
327 // it is not shown completely on UI |
|
328 QString text = mTestView->mUserNameItem->contentWidgetData("text").toString(); |
|
329 QCOMPARE(tooLongUserName, text); |
|
330 |
|
331 QTest::qWait(1000); |
|
332 |
|
333 // Visit editing state, truncated string should be saved to CommsDat |
|
334 HbAutoTest::mouseClick(mMainWindow, mUserNameWidget); |
|
335 |
|
336 QTest::qWait(1000); |
|
337 |
|
338 HbAutoTest::mouseClick(mMainWindow, mUserNameWidget, exitEditorOffset); |
|
339 |
|
340 // Verify both commsdat and UI widget |
|
341 subVerifyString( |
|
342 CMManagerShim::PacketDataIFAuthName, |
|
343 mTestView->mUserNameItem, |
|
344 truncatedUserName); |
|
345 } |
|
346 |
|
347 /** |
|
348 * Tests changing of user name. |
|
349 */ |
|
350 void TestCpPacketDataApPlugin::tcChangeUserName() |
|
351 { |
|
352 QFETCH(QString, string); |
|
353 QFETCH(QString, result); |
|
354 |
|
355 HbAutoTest::mouseClick(mMainWindow, mUserNameWidget); |
|
356 |
|
357 // Erase old string |
|
358 QString text = mTestView->mUserNameItem->contentWidgetData("text").toString(); |
|
359 subClearLineEdit(text.size()); |
|
360 |
|
361 // Enter new string |
|
362 HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime); |
|
363 |
|
364 HbAutoTest::mouseClick(mMainWindow, mUserNameWidget, exitEditorOffset); |
|
365 |
|
366 // Verify both commsdat and UI widget |
|
367 subVerifyString( |
|
368 CMManagerShim::PacketDataIFAuthName, |
|
369 mTestView->mUserNameItem, |
|
370 result); |
|
371 } |
|
372 |
|
373 /** |
|
374 * Test data for user name change test case. |
|
375 */ |
|
376 void TestCpPacketDataApPlugin::tcChangeUserName_data() |
|
377 { |
|
378 QTest::addColumn<QString>("string"); |
|
379 QTest::addColumn<QString>("result"); |
|
380 |
|
381 QTest::newRow("maximum length") |
|
382 << "really long name 123456789012345678901234567890123" |
|
383 << "really long name 123456789012345678901234567890123"; |
|
384 QTest::newRow("too long") |
|
385 << "too long name 1234567890123456789012345678901234567890123" |
|
386 << "too long name 123456789012345678901234567890123456"; |
|
387 QTest::newRow("basic") |
|
388 << "username" |
|
389 << "username"; |
|
390 QTest::newRow("empty") // last one must always fit on one line in UI |
|
391 << "" |
|
392 << ""; |
|
393 } |
|
394 |
|
395 /** |
|
396 * Scrolls the tested view to the bottom. |
|
397 */ |
|
398 void TestCpPacketDataApPlugin::tcScrollToBottom() |
|
399 { |
|
400 subScrollToBottom(); |
|
401 } |
|
402 |
|
403 /** |
|
404 * Tests changing of password. |
|
405 */ |
|
406 void TestCpPacketDataApPlugin::tcChangePassword() |
|
407 { |
|
408 QFETCH(QString, string); |
|
409 QFETCH(QString, result); |
|
410 |
|
411 HbAutoTest::mouseClick(mMainWindow, mPasswordWidget); |
|
412 |
|
413 // Erase old string |
|
414 QString text = mTestView->mPasswordItem->contentWidgetData("text").toString(); |
|
415 subClearLineEdit(text.size()); |
|
416 |
|
417 // Enter new string |
|
418 HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime); |
|
419 |
|
420 HbAutoTest::mouseClick(mMainWindow, mPasswordWidget, exitEditorOffset); |
|
421 |
|
422 // Verify both commsdat and UI widget |
|
423 subVerifyString( |
|
424 CMManagerShim::PacketDataIFAuthPass, |
|
425 mTestView->mPasswordItem, |
|
426 result); |
|
427 } |
|
428 |
|
429 /** |
|
430 * Test data for password change test case. |
|
431 */ |
|
432 void TestCpPacketDataApPlugin::tcChangePassword_data() |
|
433 { |
|
434 QTest::addColumn<QString>("string"); |
|
435 QTest::addColumn<QString>("result"); |
|
436 |
|
437 QTest::newRow("maximum length") |
|
438 << "really long name 123456789012345678901234567890123" |
|
439 << "really long name 123456789012345678901234567890123"; |
|
440 QTest::newRow("too long") |
|
441 << "too long name 1234567890123456789012345678901234567890123" |
|
442 << "too long name 123456789012345678901234567890123456"; |
|
443 QTest::newRow("basic") |
|
444 << "password" |
|
445 << "password"; |
|
446 QTest::newRow("empty") // last one must always fit on one line in UI |
|
447 << "" |
|
448 << ""; |
|
449 } |
|
450 |
|
451 /** |
|
452 * Tests changing of authentication mode. |
|
453 */ |
|
454 void TestCpPacketDataApPlugin::tcChangeAuthenticationMode() |
|
455 { |
|
456 QPointF normalPointOffset = comboBoxFirstItemOffset; |
|
457 QPointF securePointOffset = comboBoxFirstItemOffset + comboBoxItemOffset; |
|
458 |
|
459 // Set authentication mode to secure |
|
460 HbAutoTest::mouseClick(mMainWindow, mAuthenticationWidget); |
|
461 QTest::qWait(100); |
|
462 HbAutoTest::mouseClick(mMainWindow, mAuthenticationWidget, securePointOffset); |
|
463 |
|
464 subVerifyBool( |
|
465 CMManagerShim::PacketDataDisablePlainTextAuth, |
|
466 true); |
|
467 |
|
468 // Set authentication mode to normal |
|
469 HbAutoTest::mouseClick(mMainWindow, mAuthenticationWidget); |
|
470 QTest::qWait(100); |
|
471 HbAutoTest::mouseClick(mMainWindow, mAuthenticationWidget, normalPointOffset); |
|
472 |
|
473 subVerifyBool( |
|
474 CMManagerShim::PacketDataDisablePlainTextAuth, |
|
475 false); |
|
476 } |
|
477 |
|
478 /** |
|
479 * Tests changing of homepage. |
|
480 */ |
|
481 void TestCpPacketDataApPlugin::tcChangeHomepage() |
|
482 { |
|
483 QFETCH(QString, string); |
|
484 QFETCH(QString, result); |
|
485 |
|
486 HbAutoTest::mouseClick(mMainWindow, mHomepageWidget); |
|
487 |
|
488 // Erase old string |
|
489 QString text = mTestView->mHomepageItem->contentWidgetData("text").toString(); |
|
490 subClearLineEdit(text.size()); |
|
491 |
|
492 // Enter new string |
|
493 HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime); |
|
494 |
|
495 HbAutoTest::mouseClick(mMainWindow, mHomepageWidget, exitEditorOffset); |
|
496 |
|
497 // Verify both commsdat and UI widget |
|
498 subVerifyString( |
|
499 CMManagerShim::CmStartPage, |
|
500 mTestView->mHomepageItem, |
|
501 result); |
|
502 } |
|
503 |
|
504 /** |
|
505 * Test data for homepage change test case. |
|
506 */ |
|
507 void TestCpPacketDataApPlugin::tcChangeHomepage_data() |
|
508 { |
|
509 QTest::addColumn<QString>("string"); |
|
510 QTest::addColumn<QString>("result"); |
|
511 |
|
512 QTest::newRow("long") |
|
513 << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html" |
|
514 << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html"; |
|
515 QTest::newRow("basic") // last one should always fit on one line in UI |
|
516 << "http://www.symbian.org/" |
|
517 << "http://www.symbian.org/"; |
|
518 QTest::newRow("empty") |
|
519 << "" |
|
520 << ""; |
|
521 } |
|
522 |
|
523 /** |
|
524 * Opens advanced settings view. |
|
525 */ |
|
526 void TestCpPacketDataApPlugin::tcOpenAdvancedSettingsView() |
|
527 { |
|
528 // Launch advanced settings view |
|
529 bool status = connect( |
|
530 this, |
|
531 SIGNAL(menuActionTriggered(HbAction *)), |
|
532 mTestView, |
|
533 SLOT(menuActionTriggered(HbAction *))); |
|
534 Q_ASSERT(status); |
|
535 emit menuActionTriggered(mTestView->mAdvancedSettingsAction); |
|
536 |
|
537 QTest::qWait(1000); |
|
538 |
|
539 mTestViewAdvanced = static_cast<CpPacketDataApAdvancedView *>(mMainWindow->currentView()); |
|
540 } |
|
541 |
|
542 /** |
|
543 * Expands the IP settings group. |
|
544 */ |
|
545 void TestCpPacketDataApPlugin::tcExpandIpSettings() |
|
546 { |
|
547 HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, ipGroup); |
|
548 |
|
549 subGetAdvancedUiWidgets(0); |
|
550 } |
|
551 |
|
552 /** |
|
553 * Sets the network type to IPv4 and gets UI widget pointers. |
|
554 */ |
|
555 void TestCpPacketDataApPlugin::tcSetIpv4NetworkType() |
|
556 { |
|
557 QPointF ipv4PointOffset = comboBoxFirstItemOffset; |
|
558 |
|
559 // Set network type to IPv4 |
|
560 HbAutoTest::mouseClick(mMainWindow, mNetworkTypeWidget); |
|
561 HbAutoTest::mouseClick(mMainWindow, mNetworkTypeWidget, ipv4PointOffset, 100); |
|
562 subVerifyUint(CMManagerShim::PacketDataPDPType, RPacketContext::EPdpTypeIPv4); |
|
563 |
|
564 subGetAdvancedUiWidgets(0); |
|
565 } |
|
566 |
|
567 /** |
|
568 * Tests enabling of automatic phone IP address. |
|
569 */ |
|
570 void TestCpPacketDataApPlugin::tcEnableAutomaticIpv4Address() |
|
571 { |
|
572 Qt::CheckState state = static_cast<Qt::CheckState> |
|
573 (mTestViewAdvanced->mIpv4Automatic->contentWidgetData("checkState").toInt()); |
|
574 if (state == Qt::Checked) { |
|
575 // Disable automatic IP address |
|
576 HbAutoTest::mouseClick(mMainWindow, mIpv4AddressAutomaticWidget); |
|
577 } |
|
578 // Enable automatic IP address |
|
579 HbAutoTest::mouseClick(mMainWindow, mIpv4AddressAutomaticWidget); |
|
580 subVerifyBool( |
|
581 CMManagerShim::PacketDataIPAddrFromServer, |
|
582 true); |
|
583 |
|
584 // Ensure that editing the IP address is not allowed |
|
585 HbAutoTest::mouseClick(mMainWindow, mIpv4AddressWidget); |
|
586 } |
|
587 |
|
588 /** |
|
589 * Tests disabling of automatic phone IP address. |
|
590 */ |
|
591 void TestCpPacketDataApPlugin::tcEnableUserDefinedIpv4Address() |
|
592 { |
|
593 Qt::CheckState state = static_cast<Qt::CheckState> |
|
594 (mTestViewAdvanced->mIpv4Automatic->contentWidgetData("checkState").toInt()); |
|
595 if (state == Qt::Checked) { |
|
596 // Disable automatic IP address |
|
597 HbAutoTest::mouseClick(mMainWindow, mIpv4AddressAutomaticWidget); |
|
598 } |
|
599 // Can't verify the setting from CommsDat here, because CMManager will |
|
600 // set it back to true if no valid IP address is yet defined. The flag |
|
601 // is verified in tcChangeIpAddress(). |
|
602 } |
|
603 |
|
604 /** |
|
605 * Tests changing of IP address. |
|
606 */ |
|
607 void TestCpPacketDataApPlugin::tcChangeIpAddress() |
|
608 { |
|
609 QFETCH(QString, string); |
|
610 QFETCH(QString, result); |
|
611 |
|
612 HbAutoTest::mouseClick(mMainWindow, mIpv4AddressWidget); |
|
613 |
|
614 // Erase old string |
|
615 QString text = mTestViewAdvanced->mIpv4Address->contentWidgetData("text").toString(); |
|
616 subClearLineEdit(text.size()); |
|
617 |
|
618 // Enter new string |
|
619 HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime); |
|
620 |
|
621 HbAutoTest::mouseClick(mMainWindow, mIpv4AddressWidget, exitEditorOffset); |
|
622 |
|
623 // Verify both commsdat and UI widget |
|
624 subVerifyString( |
|
625 CMManagerShim::PacketDataIPAddr, |
|
626 mTestViewAdvanced->mIpv4Address, |
|
627 result); |
|
628 subVerifyBool( |
|
629 CMManagerShim::PacketDataIPAddrFromServer, |
|
630 false); |
|
631 } |
|
632 |
|
633 /** |
|
634 * Test data for IP address change test case. |
|
635 */ |
|
636 void TestCpPacketDataApPlugin::tcChangeIpAddress_data() |
|
637 { |
|
638 QTest::addColumn<QString>("string"); |
|
639 QTest::addColumn<QString>("result"); |
|
640 |
|
641 QTest::newRow("too long") |
|
642 << "255.255.255.2551234" |
|
643 << "255.255.255.255"; |
|
644 QTest::newRow("normal") |
|
645 << "192.168.0.1" |
|
646 << "192.168.0.1"; |
|
647 } |
|
648 |
|
649 /** |
|
650 * Scrolls the tested view to the bottom. |
|
651 */ |
|
652 void TestCpPacketDataApPlugin::tcScrollToBottom2() |
|
653 { |
|
654 subScrollToBottom(); |
|
655 |
|
656 subGetAdvancedUiWidgets(0); |
|
657 } |
|
658 |
|
659 /** |
|
660 * Tests enabling of automatic IPv4 DNS addresses. |
|
661 */ |
|
662 void TestCpPacketDataApPlugin::tcEnableAutomaticIpv4DnsAddress() |
|
663 { |
|
664 Qt::CheckState state = static_cast<Qt::CheckState> |
|
665 (mTestViewAdvanced->mIpv4DnsAutomatic->contentWidgetData("checkState").toInt()); |
|
666 if (state == Qt::Checked) { |
|
667 // Disable automatic IPv4 DNS address |
|
668 HbAutoTest::mouseClick(mMainWindow, mIpv4DnsAddressAutomaticWidget); |
|
669 } |
|
670 // Enable automatic IPv4 DNS address |
|
671 HbAutoTest::mouseClick(mMainWindow, mIpv4DnsAddressAutomaticWidget); |
|
672 subVerifyBool( |
|
673 CMManagerShim::PacketDataIPDNSAddrFromServer, |
|
674 true); |
|
675 |
|
676 // Ensure that editing the IP address is not allowed |
|
677 HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget); |
|
678 HbAutoTest::mouseClick(mMainWindow, mIpv4SecondaryDnsAddressWidget); |
|
679 } |
|
680 |
|
681 /** |
|
682 * Tests disabling of automatic IPv4 DNS addresses. |
|
683 */ |
|
684 void TestCpPacketDataApPlugin::tcEnableUserDefinedIpv4DnsAddress() |
|
685 { |
|
686 Qt::CheckState state = static_cast<Qt::CheckState> |
|
687 (mTestViewAdvanced->mIpv4DnsAutomatic->contentWidgetData("checkState").toInt()); |
|
688 if (state == Qt::Checked) { |
|
689 // Disable automatic IPv4 DNS address |
|
690 HbAutoTest::mouseClick(mMainWindow, mIpv4DnsAddressAutomaticWidget); |
|
691 } |
|
692 // Can't verify the setting from CommsDat here, because CMManager will |
|
693 // set it back to true if no valid IP address is yet defined. The flag |
|
694 // is verified in tcChangeIpv4DnsAddress(). |
|
695 } |
|
696 |
|
697 /** |
|
698 * Tests changing of IPv4 DNS addresses. |
|
699 */ |
|
700 void TestCpPacketDataApPlugin::tcChangeIpv4DnsAddress() |
|
701 { |
|
702 QFETCH(QString, string); |
|
703 QFETCH(QString, result); |
|
704 |
|
705 // Primary DNS address |
|
706 HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget); |
|
707 |
|
708 // Erase old string |
|
709 QString text = mTestViewAdvanced->mIpv4DnsAddress1->contentWidgetData("text").toString(); |
|
710 subClearLineEdit(text.size()); |
|
711 |
|
712 // Enter new string |
|
713 HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime); |
|
714 |
|
715 HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget, exitEditorOffset); |
|
716 |
|
717 // Verify both commsdat and UI widget |
|
718 subVerifyString( |
|
719 CMManagerShim::PacketDataIPNameServer1, |
|
720 mTestViewAdvanced->mIpv4DnsAddress1, |
|
721 result); |
|
722 |
|
723 // Secondary DNS address |
|
724 HbAutoTest::mouseClick(mMainWindow, mIpv4SecondaryDnsAddressWidget); |
|
725 |
|
726 // Erase old string |
|
727 text = mTestViewAdvanced->mIpv4DnsAddress2->contentWidgetData("text").toString(); |
|
728 subClearLineEdit(text.size()); |
|
729 |
|
730 // Enter new string |
|
731 HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime); |
|
732 |
|
733 HbAutoTest::mouseClick(mMainWindow, mIpv4SecondaryDnsAddressWidget, exitEditorOffset); |
|
734 |
|
735 // Verify both commsdat and UI widget |
|
736 subVerifyString( |
|
737 CMManagerShim::PacketDataIPNameServer2, |
|
738 mTestViewAdvanced->mIpv4DnsAddress2, |
|
739 result); |
|
740 |
|
741 // Verify user defined address is in use |
|
742 subVerifyBool( |
|
743 CMManagerShim::PacketDataIPDNSAddrFromServer, |
|
744 false); |
|
745 } |
|
746 |
|
747 /** |
|
748 * Test data for IPv4 DNS address change test case. |
|
749 */ |
|
750 void TestCpPacketDataApPlugin::tcChangeIpv4DnsAddress_data() |
|
751 { |
|
752 QTest::addColumn<QString>("string"); |
|
753 QTest::addColumn<QString>("result"); |
|
754 |
|
755 QTest::newRow("too long") |
|
756 << "255.255.255.2551234" |
|
757 << "255.255.255.255"; |
|
758 QTest::newRow("normal") |
|
759 << "192.168.0.1" |
|
760 << "192.168.0.1"; |
|
761 } |
|
762 |
|
763 /** |
|
764 * Tests invalid IPv4 DNS address. |
|
765 */ |
|
766 void TestCpPacketDataApPlugin::tcInvalidIpv4DnsAddress() |
|
767 { |
|
768 QString previous = |
|
769 mTestViewAdvanced->mIpv4DnsAddress1->contentWidgetData("text").toString(); |
|
770 |
|
771 HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget); |
|
772 |
|
773 // Erase old string |
|
774 QString text = mTestViewAdvanced->mIpv4DnsAddress1->contentWidgetData("text").toString(); |
|
775 subClearLineEdit(text.size()); |
|
776 |
|
777 // Enter new string |
|
778 HbAutoTest::keyClicks(mMainWindow, "999.999.999.999", 0, waitTime); |
|
779 |
|
780 HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget, exitEditorOffset); |
|
781 |
|
782 QTest::qWait(100); |
|
783 // Dismiss messagebox |
|
784 HbAutoTest::mouseClick( |
|
785 mMainWindow, |
|
786 mTestViewAdvanced->mMessageBox.data(), |
|
787 messageBoxOkButtonOffset); |
|
788 |
|
789 // Verify both commsdat and UI widget |
|
790 subVerifyString( |
|
791 CMManagerShim::PacketDataIPNameServer1, |
|
792 mTestViewAdvanced->mIpv4DnsAddress1, |
|
793 previous); |
|
794 } |
|
795 |
|
796 /** |
|
797 * Scrolls the tested view to the top. |
|
798 */ |
|
799 void TestCpPacketDataApPlugin::tcScrollToTop() |
|
800 { |
|
801 subScrollToTop(); |
|
802 } |
|
803 |
|
804 /** |
|
805 * Sets the network type to IPv6 and gets UI widget pointers. |
|
806 */ |
|
807 void TestCpPacketDataApPlugin::tcSetIpv6NetworkType() |
|
808 { |
|
809 QPointF ipv6PointOffset = comboBoxFirstItemOffset + comboBoxItemOffset; |
|
810 |
|
811 // Set network type to IPv6 |
|
812 HbAutoTest::mouseClick(mMainWindow, mNetworkTypeWidget); |
|
813 HbAutoTest::mouseClick(mMainWindow, mNetworkTypeWidget, ipv6PointOffset, 100); |
|
814 subVerifyUint(CMManagerShim::PacketDataPDPType, RPacketContext::EPdpTypeIPv6); |
|
815 |
|
816 subGetAdvancedUiWidgets(0); |
|
817 } |
|
818 |
|
819 /** |
|
820 * Tests enabling of automatic IPv6 DNS addresses. |
|
821 */ |
|
822 void TestCpPacketDataApPlugin::tcEnableAutomaticIpv6DnsAddress() |
|
823 { |
|
824 // Enable automatic IPv6 DNS address |
|
825 QPointF automaticPointOffset = comboBoxFirstItemOffset; |
|
826 HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget); |
|
827 QTest::qWait(100); |
|
828 HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget, automaticPointOffset, 100); |
|
829 QTest::qWait(100); |
|
830 subVerifyBool( |
|
831 CMManagerShim::PacketDataIPIP6DNSAddrFromServer, |
|
832 true); |
|
833 |
|
834 // Ensure that editing the IP address is not allowed |
|
835 HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget); |
|
836 HbAutoTest::mouseClick(mMainWindow, mIpv6SecondaryDnsAddressWidget); |
|
837 } |
|
838 |
|
839 /** |
|
840 * Tests enabling of well-known IPv6 DNS addresses. |
|
841 */ |
|
842 void TestCpPacketDataApPlugin::tcEnableWellKnownIpv6DnsAddress() |
|
843 { |
|
844 // Enable well-known IPv6 DNS address |
|
845 QPointF wellKnownPointOffset = comboBoxFirstItemOffset + comboBoxItemOffset; |
|
846 HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget); |
|
847 QTest::qWait(100); |
|
848 HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget, wellKnownPointOffset, 100); |
|
849 QTest::qWait(100); |
|
850 subVerifyBool( |
|
851 CMManagerShim::PacketDataIPIP6DNSAddrFromServer, |
|
852 false); |
|
853 subVerifyString( |
|
854 CMManagerShim::PacketDataIPIP6NameServer1, |
|
855 mTestViewAdvanced->mIpv6DnsAddress1, |
|
856 "fec0:000:0000:ffff::1"); |
|
857 subVerifyString( |
|
858 CMManagerShim::PacketDataIPIP6NameServer2, |
|
859 mTestViewAdvanced->mIpv6DnsAddress2, |
|
860 "fec0:000:0000:ffff::2"); |
|
861 |
|
862 // Ensure that editing the IP address is not allowed |
|
863 HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget); |
|
864 HbAutoTest::mouseClick(mMainWindow, mIpv6SecondaryDnsAddressWidget); |
|
865 } |
|
866 |
|
867 /** |
|
868 * Tests enabling of user defined IPv6 DNS addresses. |
|
869 */ |
|
870 void TestCpPacketDataApPlugin::tcEnableUserDefinedIpv6DnsAddress() |
|
871 { |
|
872 // Select user defined IPv6 DNS address |
|
873 QPointF userDefinedPointOffset = comboBoxFirstItemOffset + comboBoxItemOffset * 2; |
|
874 //QPointF userDefinedPointOffset(0, 160); |
|
875 HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget); |
|
876 QTest::qWait(100); |
|
877 HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget, userDefinedPointOffset, 100); |
|
878 QTest::qWait(100); |
|
879 // Can't verify the setting from CommsDat here, because CMManager will |
|
880 // set it back to true if no valid IP address is yet defined. The flag |
|
881 // is verified in tcChangeIpv4DnsAddress(). |
|
882 } |
|
883 |
|
884 /** |
|
885 * Tests changing of IPv6 DNS addresses. |
|
886 */ |
|
887 void TestCpPacketDataApPlugin::tcChangeIpv6DnsAddress() |
|
888 { |
|
889 QFETCH(QString, string); |
|
890 QFETCH(QString, result); |
|
891 |
|
892 // Primary DNS address |
|
893 HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget); |
|
894 |
|
895 // Erase old string |
|
896 QString text = mTestViewAdvanced->mIpv6DnsAddress1->contentWidgetData("text").toString(); |
|
897 subClearLineEdit(text.size()); |
|
898 |
|
899 // Enter new string |
|
900 HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime); |
|
901 |
|
902 HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget, exitEditorOffset); |
|
903 |
|
904 // Verify both commsdat and UI widget |
|
905 subVerifyString( |
|
906 CMManagerShim::PacketDataIPIP6NameServer1, |
|
907 mTestViewAdvanced->mIpv6DnsAddress1, |
|
908 result); |
|
909 |
|
910 // Secondary DNS address |
|
911 HbAutoTest::mouseClick(mMainWindow, mIpv6SecondaryDnsAddressWidget); |
|
912 |
|
913 // Erase old string |
|
914 text = mTestViewAdvanced->mIpv6DnsAddress2->contentWidgetData("text").toString(); |
|
915 subClearLineEdit(text.size()); |
|
916 |
|
917 // Enter new string |
|
918 HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime); |
|
919 |
|
920 HbAutoTest::mouseClick(mMainWindow, mIpv6SecondaryDnsAddressWidget, exitEditorOffset); |
|
921 |
|
922 // Verify both commsdat and UI widget |
|
923 subVerifyString( |
|
924 CMManagerShim::PacketDataIPIP6NameServer2, |
|
925 mTestViewAdvanced->mIpv6DnsAddress2, |
|
926 result); |
|
927 |
|
928 // Verify user defined address is in use |
|
929 subVerifyBool( |
|
930 CMManagerShim::PacketDataIPIP6DNSAddrFromServer, |
|
931 false); |
|
932 } |
|
933 |
|
934 /** |
|
935 * Test data for IPv6 DNS address change test case. |
|
936 */ |
|
937 void TestCpPacketDataApPlugin::tcChangeIpv6DnsAddress_data() |
|
938 { |
|
939 QTest::addColumn<QString>("string"); |
|
940 QTest::addColumn<QString>("result"); |
|
941 |
|
942 QTest::newRow("normal") |
|
943 << "2001:db8:85a3::8a2e:370:7334" |
|
944 << "2001:db8:85a3:0:0:8a2e:370:7334"; |
|
945 } |
|
946 |
|
947 /** |
|
948 * Tests invalid IPv6 DNS address. |
|
949 */ |
|
950 void TestCpPacketDataApPlugin::tcInvalidIpv6DnsAddress() |
|
951 { |
|
952 QString previous = |
|
953 mTestViewAdvanced->mIpv6DnsAddress1->contentWidgetData("text").toString(); |
|
954 |
|
955 HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget); |
|
956 |
|
957 // Erase old string |
|
958 QString text = mTestViewAdvanced->mIpv6DnsAddress1->contentWidgetData("text").toString(); |
|
959 subClearLineEdit(text.size()); |
|
960 |
|
961 // Enter new string |
|
962 HbAutoTest::keyClicks(mMainWindow, "abcdef:fedcba", 0, waitTime); |
|
963 |
|
964 HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget, exitEditorOffset); |
|
965 |
|
966 QTest::qWait(100); |
|
967 // Dismiss messagebox |
|
968 HbAutoTest::mouseClick( |
|
969 mMainWindow, |
|
970 mTestViewAdvanced->mMessageBox.data(), |
|
971 messageBoxOkButtonOffset); |
|
972 |
|
973 // Verify both commsdat and UI widget |
|
974 subVerifyString( |
|
975 CMManagerShim::PacketDataIPIP6NameServer1, |
|
976 mTestViewAdvanced->mIpv6DnsAddress1, |
|
977 previous); |
|
978 } |
|
979 |
|
980 /** |
|
981 * Collapses the IP settings group. |
|
982 */ |
|
983 void TestCpPacketDataApPlugin::tcCollapseIpSettings() |
|
984 { |
|
985 HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, ipGroup); |
|
986 } |
|
987 |
|
988 /** |
|
989 * Expands the proxy settings group and gets UI widget pointers. |
|
990 */ |
|
991 void TestCpPacketDataApPlugin::tcExpandProxySettingsAndGetUiWidgets() |
|
992 { |
|
993 HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, proxyGroup); |
|
994 |
|
995 QTest::qWait(500); |
|
996 |
|
997 subGetAdvancedUiWidgets(1); |
|
998 } |
|
999 |
|
1000 /** |
|
1001 * Tests changing of proxy server address. |
|
1002 */ |
|
1003 void TestCpPacketDataApPlugin::tcChangeProxyServerAddress() |
|
1004 { |
|
1005 QFETCH(QString, string); |
|
1006 QFETCH(QString, result); |
|
1007 |
|
1008 HbAutoTest::mouseClick(mMainWindow, mProxyServerAddressWidget); |
|
1009 |
|
1010 // Erase old string |
|
1011 QString text = mTestViewAdvanced->mProxyServer->contentWidgetData("text").toString(); |
|
1012 subClearLineEdit(text.size()); |
|
1013 |
|
1014 // Enter new string |
|
1015 HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime); |
|
1016 |
|
1017 HbAutoTest::mouseClick(mMainWindow, mProxyServerAddressWidget, exitEditorOffset); |
|
1018 |
|
1019 // Verify both commsdat and UI widget |
|
1020 subVerifyString( |
|
1021 CMManagerShim::CmProxyServerName, |
|
1022 mTestViewAdvanced->mProxyServer, |
|
1023 result); |
|
1024 // Verify user defined address flag is set correctly |
|
1025 if (result.isEmpty()) { |
|
1026 subVerifyBool( |
|
1027 CMManagerShim::CmProxyUsageEnabled, |
|
1028 false); |
|
1029 } else { |
|
1030 subVerifyBool( |
|
1031 CMManagerShim::CmProxyUsageEnabled, |
|
1032 true); |
|
1033 } |
|
1034 } |
|
1035 |
|
1036 /** |
|
1037 * Test data for proxy server address change test case. |
|
1038 */ |
|
1039 void TestCpPacketDataApPlugin::tcChangeProxyServerAddress_data() |
|
1040 { |
|
1041 QTest::addColumn<QString>("string"); |
|
1042 QTest::addColumn<QString>("result"); |
|
1043 |
|
1044 QTest::newRow("long") |
|
1045 << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html" |
|
1046 << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html"; |
|
1047 QTest::newRow("empty") |
|
1048 << "" |
|
1049 << ""; |
|
1050 QTest::newRow("basic") // last one should always fit on one line in UI |
|
1051 << "http://www.symbian.org/" |
|
1052 << "http://www.symbian.org/"; |
|
1053 } |
|
1054 |
|
1055 /** |
|
1056 * Tests changing of proxy port number. |
|
1057 */ |
|
1058 void TestCpPacketDataApPlugin::tcChangeProxyPortNumber() |
|
1059 { |
|
1060 QFETCH(QString, string); |
|
1061 QFETCH(QString, result); |
|
1062 |
|
1063 HbAutoTest::mouseClick(mMainWindow, mProxyPortNumberWidget); |
|
1064 |
|
1065 // Erase old string |
|
1066 QString text = mTestViewAdvanced->mProxyPort->contentWidgetData("text").toString(); |
|
1067 subClearLineEdit(text.size()); |
|
1068 |
|
1069 // Enter new string |
|
1070 HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime); |
|
1071 |
|
1072 HbAutoTest::mouseClick(mMainWindow, mProxyPortNumberWidget, exitEditorOffset); |
|
1073 |
|
1074 // Verify both commsdat and UI widget |
|
1075 subVerifyUint( |
|
1076 CMManagerShim::CmProxyPortNumber, |
|
1077 result.toInt()); |
|
1078 QCOMPARE( |
|
1079 mTestViewAdvanced->mProxyPort->contentWidgetData("text").toInt(), |
|
1080 result.toInt()); |
|
1081 } |
|
1082 |
|
1083 /** |
|
1084 * Test data for proxy port number change test case. |
|
1085 */ |
|
1086 void TestCpPacketDataApPlugin::tcChangeProxyPortNumber_data() |
|
1087 { |
|
1088 QTest::addColumn<QString>("string"); |
|
1089 QTest::addColumn<QString>("result"); |
|
1090 |
|
1091 QTest::newRow("basic") |
|
1092 << "8080" |
|
1093 << "8080"; |
|
1094 QTest::newRow("too long") |
|
1095 << "1234567890" |
|
1096 << "12345"; |
|
1097 QTest::newRow("zero") |
|
1098 << "0" |
|
1099 << ""; |
|
1100 QTest::newRow("empty") |
|
1101 << "" |
|
1102 << ""; |
|
1103 } |
|
1104 |
|
1105 /** |
|
1106 * Tests invalid proxy port number. |
|
1107 */ |
|
1108 void TestCpPacketDataApPlugin::tcInvalidProxyPortNumber() |
|
1109 { |
|
1110 int previous = |
|
1111 mTestViewAdvanced->mProxyPort->contentWidgetData("text").toInt(); |
|
1112 |
|
1113 HbAutoTest::mouseClick(mMainWindow, mProxyPortNumberWidget); |
|
1114 |
|
1115 // Erase old string |
|
1116 QString text = mTestViewAdvanced->mProxyPort->contentWidgetData("text").toString(); |
|
1117 subClearLineEdit(text.size()); |
|
1118 |
|
1119 // Enter new string |
|
1120 HbAutoTest::keyClicks(mMainWindow, "65536", 0, waitTime); |
|
1121 |
|
1122 HbAutoTest::mouseClick(mMainWindow, mProxyPortNumberWidget, exitEditorOffset); |
|
1123 |
|
1124 QTest::qWait(100); |
|
1125 // Dismiss messagebox |
|
1126 HbAutoTest::mouseClick( |
|
1127 mMainWindow, |
|
1128 mTestViewAdvanced->mMessageBox.data(), |
|
1129 messageBoxOkButtonOffset); |
|
1130 |
|
1131 // Verify both commsdat and UI widget |
|
1132 subVerifyUint( |
|
1133 CMManagerShim::CmProxyPortNumber, |
|
1134 previous); |
|
1135 QCOMPARE( |
|
1136 mTestViewAdvanced->mProxyPort->contentWidgetData("text").toInt(), |
|
1137 previous); |
|
1138 } |
|
1139 |
|
1140 /** |
|
1141 * Collapses the proxy settings group. |
|
1142 */ |
|
1143 void TestCpPacketDataApPlugin::tcCollapseProxySettings() |
|
1144 { |
|
1145 HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, proxyGroup); |
|
1146 } |
|
1147 |
|
1148 /** |
|
1149 * Returns from advanced settings view. |
|
1150 */ |
|
1151 void TestCpPacketDataApPlugin::tcCloseAdvancedSettingsView() |
|
1152 { |
|
1153 // Return from advanced settings view |
|
1154 subClickWidget("HbNavigationButton"); |
|
1155 } |
|
1156 |
|
1157 // ----------------------------------------------------------------------------- |
|
1158 // SUB TEST CASES |
|
1159 // ----------------------------------------------------------------------------- |
|
1160 |
|
1161 /** |
|
1162 * Gets UI widget pointers. |
|
1163 */ |
|
1164 void TestCpPacketDataApPlugin::subGetUiWidgets() |
|
1165 { |
|
1166 HbModelIterator iterator(mTestView->mModel); |
|
1167 |
|
1168 // Get "Access point settings" group item |
|
1169 QModelIndex apGroupIndex = iterator.index(0); |
|
1170 |
|
1171 // Get UI widgets |
|
1172 mConnectionNameWidget = subGetWidgetByIndex( |
|
1173 mTestView->mForm, |
|
1174 iterator.index(0, apGroupIndex)); |
|
1175 mAccessPointNameWidget = subGetWidgetByIndex( |
|
1176 mTestView->mForm, |
|
1177 iterator.index(1, apGroupIndex)); |
|
1178 mUserNameWidget = subGetWidgetByIndex( |
|
1179 mTestView->mForm, |
|
1180 iterator.index(2, apGroupIndex)); |
|
1181 mPasswordWidget = subGetWidgetByIndex( |
|
1182 mTestView->mForm, |
|
1183 iterator.index(4, apGroupIndex)); |
|
1184 mAuthenticationWidget = subGetWidgetByIndex( |
|
1185 mTestView->mForm, |
|
1186 iterator.index(5, apGroupIndex)); |
|
1187 mHomepageWidget = subGetWidgetByIndex( |
|
1188 mTestView->mForm, |
|
1189 iterator.index(6, apGroupIndex)); |
|
1190 } |
|
1191 |
|
1192 /** |
|
1193 * Gets advanced settings view UI widget pointers by group index. |
|
1194 */ |
|
1195 void TestCpPacketDataApPlugin::subGetAdvancedUiWidgets( |
|
1196 uint index) |
|
1197 { |
|
1198 // Get the group item |
|
1199 HbModelIterator iterator(mTestViewAdvanced->mModel); |
|
1200 QModelIndex groupIndex = iterator.index(index); |
|
1201 |
|
1202 // Get UI widgets |
|
1203 if (index == 0) { |
|
1204 // IP settings group |
|
1205 mNetworkTypeWidget = subGetWidgetByIndex( |
|
1206 mTestViewAdvanced->mForm, |
|
1207 iterator.index(0, groupIndex)); |
|
1208 if (qobject_cast<HbComboBox *>(mNetworkTypeWidget)->currentIndex() == 0) { |
|
1209 // IPv4 |
|
1210 mIpv4AddressAutomaticWidget = subGetWidgetByIndex( |
|
1211 mTestViewAdvanced->mForm, |
|
1212 iterator.index(1, groupIndex)); |
|
1213 mIpv4AddressWidget = subGetWidgetByIndex( |
|
1214 mTestViewAdvanced->mForm, |
|
1215 iterator.index(2, groupIndex)); |
|
1216 mIpv4DnsAddressAutomaticWidget = subGetWidgetByIndex( |
|
1217 mTestViewAdvanced->mForm, |
|
1218 iterator.index(3, groupIndex)); |
|
1219 mIpv4PrimaryDnsAddressWidget = subGetWidgetByIndex( |
|
1220 mTestViewAdvanced->mForm, |
|
1221 iterator.index(4, groupIndex)); |
|
1222 mIpv4SecondaryDnsAddressWidget = subGetWidgetByIndex( |
|
1223 mTestViewAdvanced->mForm, |
|
1224 iterator.index(5, groupIndex)); |
|
1225 } else { |
|
1226 // IPv6 |
|
1227 mIpv6DnsAddressAutomaticWidget = subGetWidgetByIndex( |
|
1228 mTestViewAdvanced->mForm, |
|
1229 iterator.index(1, groupIndex)); |
|
1230 mIpv6PrimaryDnsAddressWidget = subGetWidgetByIndex( |
|
1231 mTestViewAdvanced->mForm, |
|
1232 iterator.index(2, groupIndex)); |
|
1233 mIpv6SecondaryDnsAddressWidget = subGetWidgetByIndex( |
|
1234 mTestViewAdvanced->mForm, |
|
1235 iterator.index(3, groupIndex)); |
|
1236 } |
|
1237 } else { |
|
1238 // Proxy settings group |
|
1239 mProxyServerAddressWidget = subGetWidgetByIndex( |
|
1240 mTestViewAdvanced->mForm, |
|
1241 iterator.index(0, groupIndex)); |
|
1242 mProxyPortNumberWidget = subGetWidgetByIndex( |
|
1243 mTestViewAdvanced->mForm, |
|
1244 iterator.index(1, groupIndex)); |
|
1245 } |
|
1246 } |
|
1247 |
|
1248 /** |
|
1249 * Gets an UI widget from HbDataForm by index. |
|
1250 */ |
|
1251 HbWidget *TestCpPacketDataApPlugin::subGetWidgetByIndex( |
|
1252 HbDataForm *form, |
|
1253 const QModelIndex &index) |
|
1254 { |
|
1255 HbDataFormViewItem *viewItem = qobject_cast<HbDataFormViewItem *> |
|
1256 (form->itemByIndex(index)); |
|
1257 HbWidget *widget = viewItem->dataItemContentWidget(); |
|
1258 //QString widgetClassName(widget->metaObject()->className()); |
|
1259 //qDebug() << widgetClassName; |
|
1260 return widget; |
|
1261 } |
|
1262 |
|
1263 /** |
|
1264 * Writes initial settings to CommsDat needed by some test cases. |
|
1265 */ |
|
1266 void TestCpPacketDataApPlugin::subInitializeCommsDat() |
|
1267 { |
|
1268 QScopedPointer<CmManagerShim> cmManager(new CmManagerShim); |
|
1269 QScopedPointer<CmConnectionMethodShim> connectionMethod( |
|
1270 cmManager->connectionMethod(testApId)); |
|
1271 |
|
1272 // Initial settings |
|
1273 connectionMethod->setStringAttribute( |
|
1274 CMManagerShim::PacketDataIFAuthName, |
|
1275 tooLongUserName); |
|
1276 |
|
1277 connectionMethod->update(); |
|
1278 } |
|
1279 |
|
1280 /** |
|
1281 * Creates the settings view and shows it. |
|
1282 */ |
|
1283 void TestCpPacketDataApPlugin::subCreateSettingsView(uint connectionMethodId) |
|
1284 { |
|
1285 // Create settings view |
|
1286 HbView *view = mPlugin->createSettingView(connectionMethodId); |
|
1287 QVERIFY(view != NULL); |
|
1288 |
|
1289 // Display the view |
|
1290 mMainWindow->addView(view); |
|
1291 mMainWindow->setCurrentView(view); |
|
1292 // Store pointer to settings view class |
|
1293 mTestView = static_cast<CpPacketDataApView *>(view); |
|
1294 } |
|
1295 |
|
1296 /** |
|
1297 * Verifies that given string is correctly stored in CommsDat and shown on UI. |
|
1298 */ |
|
1299 void TestCpPacketDataApPlugin::subVerifyString( |
|
1300 CMManagerShim::ConnectionMethodAttribute attribute, |
|
1301 HbDataFormModelItem *item, |
|
1302 QString expected) |
|
1303 { |
|
1304 QTest::qWait(waitTime); |
|
1305 |
|
1306 // Read attribute value from CommsDat |
|
1307 QScopedPointer<CmManagerShim> cmManager(new CmManagerShim); |
|
1308 QScopedPointer<CmConnectionMethodShim> connectionMethod( |
|
1309 cmManager->connectionMethod(testApId)); |
|
1310 QString commsdat = connectionMethod->getStringAttribute(attribute); |
|
1311 |
|
1312 QCOMPARE(commsdat, expected); |
|
1313 |
|
1314 // Get value from UI widget |
|
1315 QString widget = item->contentWidgetData("text").toString(); |
|
1316 |
|
1317 QCOMPARE(widget, expected); |
|
1318 } |
|
1319 |
|
1320 /** |
|
1321 * Clears a HbLineEdit. |
|
1322 */ |
|
1323 void TestCpPacketDataApPlugin::subClearLineEdit( |
|
1324 uint length) |
|
1325 { |
|
1326 // Move cursor to end of string |
|
1327 //HbAutoTest::keyClick(mMainWindow, Qt::Key_End, Qt::ControlModifier, waitTime); // doesn't seem to do anything? |
|
1328 HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime); |
|
1329 HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime); |
|
1330 HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime); |
|
1331 for (int i=0; i<25; i++) { |
|
1332 HbAutoTest::keyClick(mMainWindow, Qt::Key_Right, 0, waitTime); |
|
1333 } |
|
1334 // Erase string |
|
1335 for (int i=0; i<length; i++) { |
|
1336 HbAutoTest::keyClick(mMainWindow, Qt::Key_Backspace, 0, waitTime); |
|
1337 } |
|
1338 } |
|
1339 |
|
1340 /** |
|
1341 * Gets value of a boolean attribute from CommsDat. |
|
1342 */ |
|
1343 bool TestCpPacketDataApPlugin::subGetBool( |
|
1344 CMManagerShim::ConnectionMethodAttribute attribute) |
|
1345 { |
|
1346 QScopedPointer<CmManagerShim> cmManager(new CmManagerShim); |
|
1347 QScopedPointer<CmConnectionMethodShim> connectionMethod( |
|
1348 cmManager->connectionMethod(testApId)); |
|
1349 return connectionMethod->getBoolAttribute(attribute); |
|
1350 } |
|
1351 |
|
1352 /** |
|
1353 * Verifies that given attribute contains expected boolean value in CommsDat. |
|
1354 */ |
|
1355 void TestCpPacketDataApPlugin::subVerifyBool( |
|
1356 CMManagerShim::ConnectionMethodAttribute attribute, |
|
1357 bool expected) |
|
1358 { |
|
1359 QTest::qWait(waitTime); |
|
1360 |
|
1361 // Read attribute value from CommsDat |
|
1362 QScopedPointer<CmManagerShim> cmManager(new CmManagerShim); |
|
1363 QScopedPointer<CmConnectionMethodShim> connectionMethod( |
|
1364 cmManager->connectionMethod(testApId)); |
|
1365 bool commsdat = connectionMethod->getBoolAttribute(attribute); |
|
1366 |
|
1367 QCOMPARE(commsdat, expected); |
|
1368 } |
|
1369 |
|
1370 /** |
|
1371 * Verifies that given attribute contains expected integer value in CommsDat. |
|
1372 */ |
|
1373 void TestCpPacketDataApPlugin::subVerifyUint( |
|
1374 CMManagerShim::ConnectionMethodAttribute attribute, |
|
1375 uint expected) |
|
1376 { |
|
1377 QTest::qWait(waitTime); |
|
1378 |
|
1379 // Read attribute value from CommsDat |
|
1380 QScopedPointer<CmManagerShim> cmManager(new CmManagerShim); |
|
1381 QScopedPointer<CmConnectionMethodShim> connectionMethod( |
|
1382 cmManager->connectionMethod(testApId)); |
|
1383 uint commsdat = connectionMethod->getIntAttribute(attribute); |
|
1384 |
|
1385 QCOMPARE(commsdat, expected); |
|
1386 } |
|
1387 |
|
1388 /** |
|
1389 * Clicks a widget currently on UI by class name. |
|
1390 */ |
|
1391 void TestCpPacketDataApPlugin::subClickWidget(const QString &name) |
|
1392 { |
|
1393 QList<QGraphicsItem *> itemList = mMainWindow->scene()->items(); |
|
1394 |
|
1395 QGraphicsItem *target = 0; |
|
1396 foreach (QGraphicsItem* item, itemList) { |
|
1397 if (item->isWidget()) { |
|
1398 QString widgetClassName(static_cast<QGraphicsWidget*>(item)->metaObject()->className()); |
|
1399 //qDebug() << widgetClassName; |
|
1400 |
|
1401 if (widgetClassName == name) { |
|
1402 target = item; |
|
1403 break; |
|
1404 } |
|
1405 } |
|
1406 } |
|
1407 |
|
1408 Q_ASSERT(target); |
|
1409 HbAutoTest::mouseClick(mMainWindow, static_cast<HbWidget *>(target)); |
|
1410 } |
|
1411 |
|
1412 /** |
|
1413 * Scrolls the tested view to the bottom. |
|
1414 */ |
|
1415 void TestCpPacketDataApPlugin::subScrollToBottom() |
|
1416 { |
|
1417 // Scroll to the bottom of the view |
|
1418 HbAutoTest::mousePress(mMainWindow, mTestView, scrollMiddle); |
|
1419 QTest::qWait(1000); |
|
1420 HbAutoTest::mouseMove(mMainWindow, mTestView, scrollTop); |
|
1421 HbAutoTest::mouseRelease(mMainWindow, mTestView, scrollTop); |
|
1422 } |
|
1423 |
|
1424 /** |
|
1425 * Scrolls the tested view to the top. |
|
1426 */ |
|
1427 void TestCpPacketDataApPlugin::subScrollToTop() |
|
1428 { |
|
1429 // Scroll to the top of the view |
|
1430 HbAutoTest::mousePress(mMainWindow, mTestView, scrollMiddle); |
|
1431 QTest::qWait(1000); |
|
1432 HbAutoTest::mouseMove(mMainWindow, mTestView, scrollBottom); |
|
1433 HbAutoTest::mouseRelease(mMainWindow, mTestView, scrollBottom); |
|
1434 } |
|