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