cmmanager/cpwlanapplugin/tsrc/ut/testcpwlanapplugin.cpp
changeset 27 489cf6208544
parent 20 9c97ad6591ae
child 32 5c4486441ae6
equal deleted inserted replaced
23:7ec726f93df1 27:489cf6208544
    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 <QSharedPointer>
    27 #include <QtTest/QtTest>
    30 #include <QtTest/QtTest>
    28 #include <cpbearerapplugininterface.h>
    31 #include <cpbearerapplugininterface.h>
    29 #include <cmmanager_shim.h>
    32 #include <cmmanager_shim.h>
    30 #include <cmconnectionmethod_shim.h>
    33 #include <cmconnectionmethod_shim.h>
    31 
    34 
    32 #include "cpwlanapview.h"
    35 #include "cpwlanapview.h"
       
    36 #include "cpwlanapadvancedview.h"
    33 
    37 
    34 #include "hbautotest.h"
    38 #include "hbautotest.h"
    35 #include "testcpwlanapplugin.h"
    39 #include "testcpwlanapplugin.h"
    36 
    40 
    37 // Following flag must be defined if WLAN security settings plugins
    41 // Following flag must be defined if WLAN security settings plugins
    53 
    57 
    54 // Time to wait before continuing after an UI step
    58 // Time to wait before continuing after an UI step
    55 static const int waitTime = 10;
    59 static const int waitTime = 10;
    56 
    60 
    57 // UI coordinates
    61 // UI coordinates
    58 static const QPoint connectionNameLabel(175, 70);
    62 static const QPoint scrollMiddle(350, 280);
    59 
    63 static const QPoint scrollTop(350, 50);
    60 static const QPoint connectionNameLineEdit(330, 110);
    64 static const QPoint scrollBottom(350, 520);
    61 
    65 
    62 static const QPoint wlanNetworkNameLineEdit(330, 190);
    66 // Use positive offset if dropdown opens under the combobox
    63 
    67 static const QPoint comboBoxItemOffset(0, 55);
    64 static const QPoint networkStatusComboBox(175, 270);
    68 // Use negative offset if dropdown opens above the combobox
    65 static const QPoint networkStatusPublic(175, 325);
    69 static const QPoint comboBoxItemNegativeOffset(0, -50);
    66 static const QPoint networkStatusHidden(175, 375);
    70 
    67 
    71 static const QPoint exitEditorOffset(-10, -20);
    68 static const QPoint networkModeComboBox(175, 365);
    72 
    69 static const QPoint networkModeIntrastructure(175, 415);
    73 static const QPoint messageBoxOkButtonOffset(160, 140);
    70 static const QPoint networkModeAdHoc(175, 465);
    74 
    71 
    75 // Advanced settings groups
    72 static const QPoint securityModeComboBox(175, 460);
    76 static const QPoint ipv4Group(160, 10);
    73 #ifndef WLAN_SECURITY_PLUGINS_AVAILABLE
    77 static const QPoint ipv6Group(160, 60);
    74 static const QPoint securityModeOpen(175, 510);
    78 static const QPoint proxyGroup(160, 110);
    75 #else
       
    76 static const QPoint securityModeOpen(175, 260);
       
    77 static const QPoint securityModeWep(175, 305);
       
    78 static const QPoint securityModeWpaWpa2(175, 355);
       
    79 static const QPoint securityModeWpa2(175, 405);
       
    80 #endif
       
    81 
       
    82 static const QPoint homepageLineEdit(330, 545);
       
    83 
       
    84 static const QPoint messageBoxOkButton(170, 320);
       
    85 
    79 
    86 // -----------------------------------------------------------------------------
    80 // -----------------------------------------------------------------------------
    87 // FRAMEWORK FUNCTIONS
    81 // FRAMEWORK FUNCTIONS
    88 // -----------------------------------------------------------------------------
    82 // -----------------------------------------------------------------------------
    89 
    83 
   119     //mMainWindow = new HbMainWindow;
   113     //mMainWindow = new HbMainWindow;
   120     mMainWindow->show();
   114     mMainWindow->show();
   121     
   115     
   122     // Load plugin
   116     // Load plugin
   123     QDir dir(pluginDir);
   117     QDir dir(pluginDir);
   124     QPluginLoader loader(dir.absoluteFilePath(pluginName));
   118     mPluginLoader = new QPluginLoader(dir.absoluteFilePath(pluginName));
   125     mPlugin = qobject_cast<CpBearerApPluginInterface *>(loader.instance());
   119     mPlugin = qobject_cast<CpBearerApPluginInterface *>(mPluginLoader->instance());
   126     QVERIFY(mPlugin != NULL);
   120     QVERIFY(mPlugin != NULL);
   127     
   121     
   128     // Verify plugin bearer type
   122     // Verify plugin bearer type
   129     QVERIFY(mPlugin->bearerType() == CMManagerShim::BearerTypeWlan);
   123     QVERIFY(mPlugin->bearerType() == CMManagerShim::BearerTypeWlan);
   130     
   124     
   131     // Create WLAN settings view (connection method ID given)
   125     // Create WLAN settings view (connection method ID given)
   132     subCreateSettingsView(testApId);
   126     subCreateSettingsView(testApId);
       
   127     
       
   128     subGetUiWidgets();
   133 }
   129 }
   134 
   130 
   135 /**
   131 /**
   136  * This function is be called after the last test case was executed.
   132  * This function is be called after the last test case was executed.
   137  */
   133  */
   138 void TestCpWlanApPlugin::cleanupTestCase()
   134 void TestCpWlanApPlugin::cleanupTestCase()
   139 {
   135 {
   140     delete mMainWindow;
   136     delete mMainWindow;
   141     mMainWindow = 0;
   137     mMainWindow = 0;
       
   138     
       
   139     // Force unloading of plugin
       
   140     mPluginLoader->unload();
       
   141     delete mPluginLoader;
       
   142     mPluginLoader = 0;
   142 }
   143 }
   143 
   144 
   144 /**
   145 /**
   145  * This function is be called before each test case is executed.
   146  * This function is be called before each test case is executed.
   146  */
   147  */
   166 void TestCpWlanApPlugin::tcChangeConnectionName()
   167 void TestCpWlanApPlugin::tcChangeConnectionName()
   167 {
   168 {
   168     QFETCH(QString, string);
   169     QFETCH(QString, string);
   169     QFETCH(QString, result);
   170     QFETCH(QString, result);
   170     
   171     
   171     HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLineEdit);
   172     HbAutoTest::mouseClick(mMainWindow, mConnectionNameWidget);
   172     
   173     
   173     // Erase old string
   174     // Erase old string
   174     subClearLineEdit(CMManagerShim::CmNameLength);
   175     QString text = mTestView->mConnectionNameItem->contentWidgetData("text").toString();
       
   176     subClearLineEdit(text.size());
   175     
   177     
   176     // Enter new string
   178     // Enter new string
   177     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
   179     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
   178 
   180 
   179     HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLabel);
   181     HbAutoTest::mouseClick(mMainWindow, mConnectionNameWidget, exitEditorOffset);
   180 
   182 
   181     // Verify both commsdat and UI widget
   183     // Verify both commsdat and UI widget
   182     subVerifyString(
   184     subVerifyString(
   183         CMManagerShim::CmName,
   185         CMManagerShim::CmName,
   184         mTestView->mConnectionNameItem,
   186         mTestView->mConnectionNameItem,
   210 void TestCpWlanApPlugin::tcConnectionNameEmpty()
   212 void TestCpWlanApPlugin::tcConnectionNameEmpty()
   211 {
   213 {
   212     QString previous = 
   214     QString previous = 
   213         mTestView->mConnectionNameItem->contentWidgetData("text").toString();
   215         mTestView->mConnectionNameItem->contentWidgetData("text").toString();
   214     
   216     
   215     HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLineEdit);    
   217     HbAutoTest::mouseClick(mMainWindow, mConnectionNameWidget);
   216     // Erase old string
   218 
   217     subClearLineEdit(CMManagerShim::CmNameLength);
   219     // Erase old string
   218     
   220     QString text = mTestView->mConnectionNameItem->contentWidgetData("text").toString();
   219     HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLabel);
   221     subClearLineEdit(text.size());
       
   222     
       
   223     HbAutoTest::mouseClick(mMainWindow, mConnectionNameWidget, exitEditorOffset);
   220 
   224 
   221     QTest::qWait(100);
   225     QTest::qWait(100);
   222     // Dismiss messagebox
   226     // Dismiss messagebox
   223     HbAutoTest::mouseClick(mMainWindow, mTestView, messageBoxOkButton);
   227     HbAutoTest::mouseClick(
       
   228         mMainWindow,
       
   229         mTestView->mMessageBox.data(),
       
   230         messageBoxOkButtonOffset);
   224     
   231     
   225     // Verify both commsdat and UI widget
   232     // Verify both commsdat and UI widget
   226     subVerifyString(
   233     subVerifyString(
   227         CMManagerShim::CmName,
   234         CMManagerShim::CmName,
   228         mTestView->mConnectionNameItem,
   235         mTestView->mConnectionNameItem,
   235 void TestCpWlanApPlugin::tcChangeWlanNetworkName()
   242 void TestCpWlanApPlugin::tcChangeWlanNetworkName()
   236 {
   243 {
   237     QFETCH(QString, string);
   244     QFETCH(QString, string);
   238     QFETCH(QString, result);
   245     QFETCH(QString, result);
   239     
   246     
   240     HbAutoTest::mouseClick(mMainWindow, mTestView, wlanNetworkNameLineEdit);
   247     HbAutoTest::mouseClick(mMainWindow, mWlanNetworkNameWidget);
   241     
   248     
   242     // Erase old string
   249     // Erase old string
   243     subClearLineEdit(CMManagerShim::WlanSSIDLength);
   250     QString text = mTestView->mWlanNetworkNameItem->contentWidgetData("text").toString();
       
   251     subClearLineEdit(text.size());
   244     
   252     
   245     // Enter new string
   253     // Enter new string
   246     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
   254     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
   247 
   255 
   248     HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLabel);
   256     HbAutoTest::mouseClick(mMainWindow, mWlanNetworkNameWidget, exitEditorOffset);
   249 
   257 
   250     // Verify both commsdat and UI widget
   258     // Verify both commsdat and UI widget
   251     subVerifyString(
   259     subVerifyString(
   252         CMManagerShim::WlanSSID,
   260         CMManagerShim::WlanSSID,
   253         mTestView->mWlanNetworkNameItem,
   261         mTestView->mWlanNetworkNameItem,
   279 void TestCpWlanApPlugin::tcWlanNetworkNameEmpty()
   287 void TestCpWlanApPlugin::tcWlanNetworkNameEmpty()
   280 {
   288 {
   281     QString previous = 
   289     QString previous = 
   282         mTestView->mWlanNetworkNameItem->contentWidgetData("text").toString();
   290         mTestView->mWlanNetworkNameItem->contentWidgetData("text").toString();
   283     
   291     
   284     HbAutoTest::mouseClick(mMainWindow, mTestView, wlanNetworkNameLineEdit);
   292     HbAutoTest::mouseClick(mMainWindow, mWlanNetworkNameWidget);
   285     
   293     
   286     // Erase old string
   294     // Erase old string
   287     subClearLineEdit(CMManagerShim::WlanSSIDLength);
   295     QString text = mTestView->mWlanNetworkNameItem->contentWidgetData("text").toString();
   288     
   296     subClearLineEdit(text.size());
   289     HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLabel);
   297     
       
   298     HbAutoTest::mouseClick(mMainWindow, mWlanNetworkNameWidget, exitEditorOffset);
   290 
   299 
   291     QTest::qWait(100);
   300     QTest::qWait(100);
   292     // Dismiss messagebox
   301     // Dismiss messagebox
   293     HbAutoTest::mouseClick(mMainWindow, mTestView, messageBoxOkButton);
   302     HbAutoTest::mouseClick(
       
   303         mMainWindow,
       
   304         mTestView->mMessageBox.data(),
       
   305         messageBoxOkButtonOffset);
   294     
   306     
   295     // Verify both commsdat and UI widget
   307     // Verify both commsdat and UI widget
   296     subVerifyString(
   308     subVerifyString(
   297         CMManagerShim::WlanSSID,
   309         CMManagerShim::WlanSSID,
   298         mTestView->mWlanNetworkNameItem,
   310         mTestView->mWlanNetworkNameItem,
   302 /**
   314 /**
   303  * Tests changing of WLAN network status.
   315  * Tests changing of WLAN network status.
   304  */
   316  */
   305 void TestCpWlanApPlugin::tcChangeNetworkStatus()
   317 void TestCpWlanApPlugin::tcChangeNetworkStatus()
   306 {
   318 {
       
   319     QPointF publicPointOffset = comboBoxItemOffset;
       
   320     QPointF hiddenPointOffset = comboBoxItemOffset * 2;
       
   321     
   307     // Set network status to hidden
   322     // Set network status to hidden
   308     HbAutoTest::mouseClick(mMainWindow, mTestView, networkStatusComboBox, 100);
   323     HbAutoTest::mouseClick(mMainWindow, mNetworkStatusWidget);
   309     HbAutoTest::mouseClick(mMainWindow, mTestView, networkStatusHidden, 100);
   324     HbAutoTest::mouseClick(mMainWindow, mNetworkStatusWidget, hiddenPointOffset, 100);
   310     subVerifyNetworkStatus(HiddenStatus);
   325     subVerifyNetworkStatus(HiddenStatus);
   311 
   326 
   312     // Set network status to public
   327     // Set network status to public
   313     HbAutoTest::mouseClick(mMainWindow, mTestView, networkStatusComboBox, 100);
   328     HbAutoTest::mouseClick(mMainWindow, mNetworkStatusWidget);
   314     HbAutoTest::mouseClick(mMainWindow, mTestView, networkStatusPublic, 100);
   329     HbAutoTest::mouseClick(mMainWindow, mNetworkStatusWidget, publicPointOffset, 100);
   315     subVerifyNetworkStatus(PublicStatus);
   330     subVerifyNetworkStatus(PublicStatus);
   316 }
   331 }
   317 
   332 
   318 /**
   333 /**
   319  * Tests changing of WLAN network mode.
   334  * Tests changing of WLAN network mode.
   320  */
   335  */
   321 void TestCpWlanApPlugin::tcChangeNetworkMode()
   336 void TestCpWlanApPlugin::tcChangeNetworkMode()
   322 {
   337 {
       
   338     QPointF infraPointOffset = comboBoxItemOffset;
       
   339     QPointF adHocPointOffset = comboBoxItemOffset * 2;
       
   340     
   323     // Set network mode to ad-hoc
   341     // Set network mode to ad-hoc
   324     HbAutoTest::mouseClick(mMainWindow, mTestView, networkModeComboBox, 100);
   342     HbAutoTest::mouseClick(mMainWindow, mNetworkModeWidget);
   325     HbAutoTest::mouseClick(mMainWindow, mTestView, networkModeAdHoc, 100);
   343     HbAutoTest::mouseClick(mMainWindow, mNetworkModeWidget, adHocPointOffset, 100);
   326     subVerifyUint(CMManagerShim::WlanConnectionMode, CMManagerShim::Adhoc);
   344     subVerifyUint(CMManagerShim::WlanConnectionMode, CMManagerShim::Adhoc);
   327 
   345 
   328     // Set network mode to infrastructure
   346     // Set network mode to infrastructure
   329     HbAutoTest::mouseClick(mMainWindow, mTestView, networkModeComboBox, 100);
   347     HbAutoTest::mouseClick(mMainWindow, mNetworkModeWidget);
   330     HbAutoTest::mouseClick(mMainWindow, mTestView, networkModeIntrastructure, 100);
   348     HbAutoTest::mouseClick(mMainWindow, mNetworkModeWidget, infraPointOffset, 100);
   331     subVerifyUint(CMManagerShim::WlanConnectionMode, CMManagerShim::Infra);
   349     subVerifyUint(CMManagerShim::WlanConnectionMode, CMManagerShim::Infra);
   332 }
   350 }
   333 
   351 
   334 /**
   352 /**
   335  * Tests changing of WLAN security mode.
   353  * Tests changing of WLAN security mode.
   336  */
   354  */
   337 void TestCpWlanApPlugin::tcChangeSecurityMode()
   355 void TestCpWlanApPlugin::tcChangeSecurityMode()
   338 {
   356 {
   339 #ifdef WLAN_SECURITY_PLUGINS_AVAILABLE
   357 #ifdef WLAN_SECURITY_PLUGINS_AVAILABLE
   340     // Ensure security mode is open
   358     QPointF openPointOffset = comboBoxItemNegativeOffset * 4;
   341     HbAutoTest::mouseClick(mMainWindow, mTestView, securityModeComboBox, 100);
   359     QPointF wepPointOffset = comboBoxItemNegativeOffset * 3;
   342     QTest::qWait(100);
   360     QPointF wpaPointOffset = comboBoxItemNegativeOffset * 2;
   343     HbAutoTest::mouseClick(mMainWindow, mTestView, securityModeOpen, 100);
   361     QPointF wpa2PointOffset = comboBoxItemNegativeOffset;
       
   362 #else
       
   363     QPointF openPointOffset = comboBoxItemNegativeOffset;
       
   364 #endif
       
   365     
       
   366 #ifdef WLAN_SECURITY_PLUGINS_AVAILABLE
       
   367     // Set security mode to WEP
       
   368     HbAutoTest::mouseClick(mMainWindow, mSecurityModeWidget);
       
   369     QTest::qWait(100);
       
   370     HbAutoTest::mouseClick(mMainWindow, mSecurityModeWidget, wepPointOffset, 100);
       
   371     subVerifyUint(
       
   372         CMManagerShim::WlanSecurityMode,
       
   373         CMManagerShim::WlanSecModeWep);
       
   374     
       
   375     QTest::qWait(1000);
       
   376 #endif
       
   377     // Set security mode to open
       
   378     HbAutoTest::mouseClick(mMainWindow, mSecurityModeWidget);
       
   379     QTest::qWait(100);
       
   380     HbAutoTest::mouseClick(mMainWindow, mSecurityModeWidget, openPointOffset, 100);
   344     subVerifyUint(
   381     subVerifyUint(
   345         CMManagerShim::WlanSecurityMode,
   382         CMManagerShim::WlanSecurityMode,
   346         CMManagerShim::WlanSecModeOpen);
   383         CMManagerShim::WlanSecModeOpen);
   347 
   384 }
   348     QTest::qWait(1000);
   385 
   349 
   386 /**
   350     // Set security mode to WEP
   387  * Scrolls the tested view to the bottom.
   351     HbAutoTest::mouseClick(mMainWindow, mTestView, securityModeComboBox, 100);
   388  */
   352     QTest::qWait(100);
   389 void TestCpWlanApPlugin::tcScrollToBottom()
   353     HbAutoTest::mouseClick(mMainWindow, mTestView, securityModeWep, 100);
   390 {
   354     subVerifyUint(
   391     subScrollToBottom();
   355         CMManagerShim::WlanSecurityMode,
   392 }
   356         CMManagerShim::WlanSecModeWep);
   393 
   357     
   394 /**
   358     QTest::qWait(1000);
   395  * Gets UI widget pointers because homepage view item may have been
   359 #endif
   396  * created before it was visible on the UI.
   360     
   397  */
   361     // Set security mode to open
   398 void TestCpWlanApPlugin::tcGetUiWidgets()
   362     HbAutoTest::mouseClick(mMainWindow, mTestView, securityModeComboBox, 100);
   399 {
   363     QTest::qWait(100);
   400     subGetUiWidgets();
   364     HbAutoTest::mouseClick(mMainWindow, mTestView, securityModeOpen, 100);
       
   365     subVerifyUint(
       
   366         CMManagerShim::WlanSecurityMode,
       
   367         CMManagerShim::WlanSecModeOpen);
       
   368 }
   401 }
   369 
   402 
   370 /**
   403 /**
   371  * Tests changing of homepage.
   404  * Tests changing of homepage.
   372  */
   405  */
   373 void TestCpWlanApPlugin::tcChangeHomepage()
   406 void TestCpWlanApPlugin::tcChangeHomepage()
   374 {
   407 {
   375     QFETCH(QString, string);
   408     QFETCH(QString, string);
   376     QFETCH(QString, result);
   409     QFETCH(QString, result);
   377     
   410     
   378     HbAutoTest::mouseClick(mMainWindow, mTestView, homepageLineEdit);
   411     HbAutoTest::mouseClick(mMainWindow, mHomepageWidget);
   379     
   412     
   380     // Erase old string
   413     // Erase old string
   381     QString text = mTestView->mHomepageItem->contentWidgetData("text").toString();
   414     QString text = mTestView->mHomepageItem->contentWidgetData("text").toString();
   382     subClearLineEdit(text.size());
   415     subClearLineEdit(text.size());
   383     
   416     
   384     // Enter new string
   417     // Enter new string
   385     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
   418     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
   386 
   419 
   387     HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLabel);
   420     HbAutoTest::mouseClick(mMainWindow, mHomepageWidget, exitEditorOffset);
   388 
   421 
   389     // Verify both commsdat and UI widget
   422     // Verify both commsdat and UI widget
   390     subVerifyString(
   423     subVerifyString(
   391         CMManagerShim::CmStartPage,
   424         CMManagerShim::CmStartPage,
   392         mTestView->mHomepageItem,
   425         mTestView->mHomepageItem,
   399 void TestCpWlanApPlugin::tcChangeHomepage_data()
   432 void TestCpWlanApPlugin::tcChangeHomepage_data()
   400 {
   433 {
   401     QTest::addColumn<QString>("string");
   434     QTest::addColumn<QString>("string");
   402     QTest::addColumn<QString>("result");
   435     QTest::addColumn<QString>("result");
   403   
   436   
   404 // Doesn't work always, view goes blank sometimes, Orbit bug?
   437     QTest::newRow("long")
   405 //    QTest::newRow("long")
   438         << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html"
   406 //        << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html"
   439         << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html";
   407 //        << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html";
       
   408     QTest::newRow("basic") // last one should always fit on one line in UI
   440     QTest::newRow("basic") // last one should always fit on one line in UI
   409         << "http://www.symbian.org/"
   441         << "http://www.symbian.org/"
   410         << "http://www.symbian.org/";
   442         << "http://www.symbian.org/";
   411     QTest::newRow("empty")
   443     QTest::newRow("empty")
   412         << ""
   444         << ""
   413         << "";
   445         << "";
   414 }
   446 }
   415 
   447 
   416 /**
   448 /**
   417  * Tests advanced settings view (which is currently empty).
   449  * Opens advanced settings view.
   418  */
   450  */
   419 void TestCpWlanApPlugin::tcAdvancedSettings()
   451 void TestCpWlanApPlugin::tcOpenAdvancedSettingsView()
   420 {
   452 {
   421     // Launch advanced settings view
   453     // Launch advanced settings view
   422     bool status = connect(
   454     bool status = connect(
   423         this,
   455         this,
   424         SIGNAL(menuActionTriggered(HbAction *)),
   456         SIGNAL(menuActionTriggered(HbAction *)),
   425         mTestView,
   457         mTestView,
   426         SLOT(menuActionTriggered(HbAction *)));
   458         SLOT(menuActionTriggered(HbAction *)));
   427     Q_ASSERT(status);
   459     Q_ASSERT(status);
   428     emit menuActionTriggered(mTestView->mAdvancedSettingsAction);
   460     emit menuActionTriggered(mTestView->mAdvancedSettingsAction);
   429 
   461     
   430     QTest::qWait(2000);
   462     QTest::qWait(1000);
   431     
   463     
       
   464     mTestViewAdvanced = static_cast<CpWlanApAdvancedView *>(mMainWindow->currentView());
       
   465 }
       
   466 
       
   467 /**
       
   468  * Expands the IPv4 settings group and gets UI widget pointers.
       
   469  */
       
   470 void TestCpWlanApPlugin::tcExpandIpv4SettingsAndGetUiWidgets()
       
   471 {
       
   472     HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, ipv4Group);
       
   473     
       
   474     QTest::qWait(500);
       
   475 
       
   476     subGetAdvancedUiWidgets(0);
       
   477 }
       
   478 
       
   479 /**
       
   480  * Tests enabling of automatic phone IP address.
       
   481  */
       
   482 void TestCpWlanApPlugin::tcEnableAutomaticIpv4Address()
       
   483 {
       
   484     Qt::CheckState state = static_cast<Qt::CheckState>
       
   485         (mTestViewAdvanced->mIpv4Automatic->contentWidgetData("checkState").toInt());
       
   486     if (state == Qt::Checked) {
       
   487         // Disable automatic IP address
       
   488         HbAutoTest::mouseClick(mMainWindow, mIpv4AddressAutomaticWidget);
       
   489     }
       
   490     // Enable automatic IP address
       
   491     HbAutoTest::mouseClick(mMainWindow, mIpv4AddressAutomaticWidget);
       
   492     subVerifyBool(
       
   493         CMManagerShim::CmIPAddrFromServer,
       
   494         true);
       
   495     
       
   496     // Ensure that editing the IP address is not allowed
       
   497     HbAutoTest::mouseClick(mMainWindow, mIpv4AddressWidget);
       
   498     HbAutoTest::mouseClick(mMainWindow, mIpv4SubnetMaskWidget);
       
   499     HbAutoTest::mouseClick(mMainWindow, mIpv4GatewayWidget);
       
   500 }
       
   501 
       
   502 /**
       
   503  * Tests disabling of automatic phone IP address.
       
   504  */
       
   505 void TestCpWlanApPlugin::tcEnableUserDefinedIpv4Address()
       
   506 {
       
   507     Qt::CheckState state = static_cast<Qt::CheckState>
       
   508         (mTestViewAdvanced->mIpv4Automatic->contentWidgetData("checkState").toInt());
       
   509     if (state == Qt::Checked) {
       
   510         // Disable automatic IP address
       
   511         HbAutoTest::mouseClick(mMainWindow, mIpv4AddressAutomaticWidget);
       
   512     }
       
   513     // Can't verify the setting from CommsDat here, because CMManager will
       
   514     // set it back to true if no valid IP address is yet defined. The flag
       
   515     // is verified in tcChangeIpAddress().
       
   516 }
       
   517 
       
   518 /**
       
   519  * Tests changing of IP address.
       
   520  */
       
   521 void TestCpWlanApPlugin::tcChangeIpAddress()
       
   522 {
       
   523     QFETCH(QString, string);
       
   524     QFETCH(QString, result);
       
   525     
       
   526     HbAutoTest::mouseClick(mMainWindow, mIpv4AddressWidget);
       
   527     
       
   528     // Erase old string
       
   529     QString text = mTestViewAdvanced->mIpv4Address->contentWidgetData("text").toString();
       
   530     subClearLineEdit(text.size());
       
   531     
       
   532     // Enter new string
       
   533     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
       
   534 
       
   535     HbAutoTest::mouseClick(mMainWindow, mIpv4AddressWidget, exitEditorOffset);
       
   536 
       
   537     // Verify both commsdat and UI widget
       
   538     subVerifyString(
       
   539         CMManagerShim::CmIPAddress,
       
   540         mTestViewAdvanced->mIpv4Address,
       
   541         result);
       
   542     subVerifyBool(
       
   543         CMManagerShim::CmIPAddrFromServer,
       
   544         false);
       
   545 }
       
   546 
       
   547 /**
       
   548  * Test data for IP address change test case.
       
   549  */
       
   550 void TestCpWlanApPlugin::tcChangeIpAddress_data()
       
   551 {
       
   552     QTest::addColumn<QString>("string");
       
   553     QTest::addColumn<QString>("result");
       
   554   
       
   555     QTest::newRow("too long")
       
   556         << "255.255.255.2551234"
       
   557         << "255.255.255.255";
       
   558     QTest::newRow("normal")
       
   559         << "192.168.0.1"
       
   560         << "192.168.0.1";
       
   561 }
       
   562 
       
   563 /**
       
   564  * Tests changing of subnet mask.
       
   565  */
       
   566 void TestCpWlanApPlugin::tcChangeSubnetMask()
       
   567 {
       
   568     QFETCH(QString, string);
       
   569     QFETCH(QString, result);
       
   570     
       
   571     HbAutoTest::mouseClick(mMainWindow, mIpv4SubnetMaskWidget);
       
   572     
       
   573     // Erase old string
       
   574     QString text = mTestViewAdvanced->mIpv4SubnetMask->contentWidgetData("text").toString();
       
   575     subClearLineEdit(text.size());
       
   576     
       
   577     // Enter new string
       
   578     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
       
   579 
       
   580     HbAutoTest::mouseClick(mMainWindow, mIpv4SubnetMaskWidget, exitEditorOffset);
       
   581 
       
   582     // Verify both commsdat and UI widget
       
   583     subVerifyString(
       
   584         CMManagerShim::CmIPNetmask,
       
   585         mTestViewAdvanced->mIpv4SubnetMask,
       
   586         result);
       
   587 }
       
   588 
       
   589 /**
       
   590  * Test data for subnet mask change test case.
       
   591  */
       
   592 void TestCpWlanApPlugin::tcChangeSubnetMask_data()
       
   593 {
       
   594     QTest::addColumn<QString>("string");
       
   595     QTest::addColumn<QString>("result");
       
   596   
       
   597     QTest::newRow("empty")
       
   598         << ""
       
   599         << "0.0.0.0";
       
   600     QTest::newRow("zero")
       
   601         << "0.0.0.0"
       
   602         << "0.0.0.0";
       
   603     QTest::newRow("too long")
       
   604         << "255.255.255.2551234"
       
   605         << "255.255.255.255";
       
   606     QTest::newRow("normal")
       
   607         << "192.168.0.1"
       
   608         << "192.168.0.1";
       
   609 }
       
   610 
       
   611 /**
       
   612  * Tests invalid subnet mask.
       
   613  */
       
   614 void TestCpWlanApPlugin::tcInvalidSubnetMask()
       
   615 {
       
   616     QString previous = 
       
   617         mTestViewAdvanced->mIpv4SubnetMask->contentWidgetData("text").toString();
       
   618     
       
   619     HbAutoTest::mouseClick(mMainWindow, mIpv4SubnetMaskWidget);
       
   620     
       
   621     // Erase old string
       
   622     QString text = mTestViewAdvanced->mIpv4SubnetMask->contentWidgetData("text").toString();
       
   623     subClearLineEdit(text.size());
       
   624     
       
   625     // Enter new string
       
   626     HbAutoTest::keyClicks(mMainWindow, "999.999.999.999", 0, waitTime);
       
   627 
       
   628     HbAutoTest::mouseClick(mMainWindow, mIpv4SubnetMaskWidget, exitEditorOffset);
       
   629 
       
   630     QTest::qWait(100);
       
   631     // Dismiss messagebox
       
   632     HbAutoTest::mouseClick(
       
   633         mMainWindow,
       
   634         mTestViewAdvanced->mMessageBox.data(),
       
   635         messageBoxOkButtonOffset);
       
   636     
       
   637     // Verify both commsdat and UI widget
       
   638     subVerifyString(
       
   639         CMManagerShim::CmIPNetmask,
       
   640         mTestViewAdvanced->mIpv4SubnetMask,
       
   641         previous);
       
   642 }
       
   643 
       
   644 /**
       
   645  * Tests changing of gateway.
       
   646  */
       
   647 void TestCpWlanApPlugin::tcChangeGateway()
       
   648 {
       
   649     QFETCH(QString, string);
       
   650     QFETCH(QString, result);
       
   651     
       
   652     HbAutoTest::mouseClick(mMainWindow, mIpv4GatewayWidget);
       
   653     
       
   654     // Erase old string
       
   655     QString text = mTestViewAdvanced->mIpv4Gateway->contentWidgetData("text").toString();
       
   656     subClearLineEdit(text.size());
       
   657     
       
   658     // Enter new string
       
   659     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
       
   660 
       
   661     HbAutoTest::mouseClick(mMainWindow, mIpv4GatewayWidget, exitEditorOffset);
       
   662 
       
   663     // Verify both commsdat and UI widget
       
   664     subVerifyString(
       
   665         CMManagerShim::CmIPGateway,
       
   666         mTestViewAdvanced->mIpv4Gateway,
       
   667         result);
       
   668 }
       
   669 
       
   670 /**
       
   671  * Test data for gateway change test case.
       
   672  */
       
   673 void TestCpWlanApPlugin::tcChangeGateway_data()
       
   674 {
       
   675     QTest::addColumn<QString>("string");
       
   676     QTest::addColumn<QString>("result");
       
   677   
       
   678     QTest::newRow("empty")
       
   679         << ""
       
   680         << "0.0.0.0";
       
   681     QTest::newRow("zero")
       
   682         << "0.0.0.0"
       
   683         << "0.0.0.0";
       
   684     QTest::newRow("too long")
       
   685         << "255.255.255.2551234"
       
   686         << "255.255.255.255";
       
   687     QTest::newRow("normal")
       
   688         << "192.168.0.1"
       
   689         << "192.168.0.1";
       
   690 }
       
   691 
       
   692 /**
       
   693  * Tests invalid gateway address.
       
   694  */
       
   695 void TestCpWlanApPlugin::tcInvalidGateway()
       
   696 {
       
   697     QString previous = 
       
   698         mTestViewAdvanced->mIpv4Gateway->contentWidgetData("text").toString();
       
   699     
       
   700     HbAutoTest::mouseClick(mMainWindow, mIpv4GatewayWidget);
       
   701     
       
   702     // Erase old string
       
   703     QString text = mTestViewAdvanced->mIpv4Gateway->contentWidgetData("text").toString();
       
   704     subClearLineEdit(text.size());
       
   705     
       
   706     // Enter new string
       
   707     HbAutoTest::keyClicks(mMainWindow, "999.999.999.999", 0, waitTime);
       
   708 
       
   709     HbAutoTest::mouseClick(mMainWindow, mIpv4GatewayWidget, exitEditorOffset);
       
   710 
       
   711     QTest::qWait(100);
       
   712     // Dismiss messagebox
       
   713     HbAutoTest::mouseClick(
       
   714         mMainWindow,
       
   715         mTestViewAdvanced->mMessageBox.data(),
       
   716         messageBoxOkButtonOffset);
       
   717     
       
   718     // Verify both commsdat and UI widget
       
   719     subVerifyString(
       
   720         CMManagerShim::CmIPGateway,
       
   721         mTestViewAdvanced->mIpv4Gateway,
       
   722         previous);
       
   723 }
       
   724 
       
   725 /**
       
   726  * Scrolls the tested view to the bottom.
       
   727  */
       
   728 void TestCpWlanApPlugin::tcScrollToBottom2()
       
   729 {
       
   730     subScrollToBottom();
       
   731 }
       
   732 
       
   733 /**
       
   734  * Tests enabling of automatic IPv4 DNS addresses.
       
   735  */
       
   736 void TestCpWlanApPlugin::tcEnableAutomaticIpv4DnsAddress()
       
   737 {
       
   738     Qt::CheckState state = static_cast<Qt::CheckState>
       
   739         (mTestViewAdvanced->mIpv4DnsAutomatic->contentWidgetData("checkState").toInt());
       
   740     if (state == Qt::Checked) {
       
   741         // Disable automatic IPv4 DNS address
       
   742         HbAutoTest::mouseClick(mMainWindow, mIpv4DnsAddressAutomaticWidget);
       
   743     }
       
   744     // Enable automatic IPv4 DNS address
       
   745     HbAutoTest::mouseClick(mMainWindow, mIpv4DnsAddressAutomaticWidget);
       
   746     subVerifyBool(
       
   747         CMManagerShim::CmIPDNSAddrFromServer,
       
   748         true);
       
   749     
       
   750     // Ensure that editing the IP address is not allowed
       
   751     HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget);
       
   752     HbAutoTest::mouseClick(mMainWindow, mIpv4SecondaryDnsAddressWidget);
       
   753 }
       
   754 
       
   755 /**
       
   756  * Tests disabling of automatic IPv4 DNS addresses.
       
   757  */
       
   758 void TestCpWlanApPlugin::tcEnableUserDefinedIpv4DnsAddress()
       
   759 {
       
   760     Qt::CheckState state = static_cast<Qt::CheckState>
       
   761         (mTestViewAdvanced->mIpv4DnsAutomatic->contentWidgetData("checkState").toInt());
       
   762     if (state == Qt::Checked) {
       
   763         // Disable automatic IPv4 DNS address
       
   764         HbAutoTest::mouseClick(mMainWindow, mIpv4DnsAddressAutomaticWidget);
       
   765     }
       
   766     // Can't verify the setting from CommsDat here, because CMManager will
       
   767     // set it back to true if no valid IP address is yet defined. The flag
       
   768     // is verified in tcChangeIpv4DnsAddress().
       
   769 }
       
   770 
       
   771 /**
       
   772  * Tests changing of IPv4 DNS addresses.
       
   773  */
       
   774 void TestCpWlanApPlugin::tcChangeIpv4DnsAddress()
       
   775 {
       
   776     QFETCH(QString, string);
       
   777     QFETCH(QString, result);
       
   778     
       
   779     // Primary DNS address
       
   780     HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget);
       
   781     
       
   782     // Erase old string
       
   783     QString text = mTestViewAdvanced->mIpv4DnsAddress1->contentWidgetData("text").toString();
       
   784     subClearLineEdit(text.size());
       
   785     
       
   786     // Enter new string
       
   787     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
       
   788 
       
   789     HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget, exitEditorOffset);
       
   790 
       
   791     // Verify both commsdat and UI widget
       
   792     subVerifyString(
       
   793         CMManagerShim::CmIPNameServer1,
       
   794         mTestViewAdvanced->mIpv4DnsAddress1,
       
   795         result);
       
   796     
       
   797     // Secondary DNS address
       
   798     HbAutoTest::mouseClick(mMainWindow, mIpv4SecondaryDnsAddressWidget);
       
   799     
       
   800     // Erase old string
       
   801     text = mTestViewAdvanced->mIpv4DnsAddress2->contentWidgetData("text").toString();
       
   802     subClearLineEdit(text.size());
       
   803     
       
   804     // Enter new string
       
   805     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
       
   806 
       
   807     HbAutoTest::mouseClick(mMainWindow, mIpv4SecondaryDnsAddressWidget, exitEditorOffset);
       
   808 
       
   809     // Verify both commsdat and UI widget
       
   810     subVerifyString(
       
   811         CMManagerShim::CmIPNameServer2,
       
   812         mTestViewAdvanced->mIpv4DnsAddress2,
       
   813         result);
       
   814     
       
   815     // Verify user defined address is in use
       
   816     subVerifyBool(
       
   817         CMManagerShim::CmIPDNSAddrFromServer,
       
   818         false);
       
   819 }
       
   820 
       
   821 /**
       
   822  * Test data for IPv4 DNS address change test case.
       
   823  */
       
   824 void TestCpWlanApPlugin::tcChangeIpv4DnsAddress_data()
       
   825 {
       
   826     QTest::addColumn<QString>("string");
       
   827     QTest::addColumn<QString>("result");
       
   828   
       
   829     QTest::newRow("too long")
       
   830         << "255.255.255.2551234"
       
   831         << "255.255.255.255";
       
   832     QTest::newRow("normal")
       
   833         << "192.168.0.1"
       
   834         << "192.168.0.1";
       
   835 }
       
   836 
       
   837 /**
       
   838  * Tests invalid IPv4 DNS address.
       
   839  */
       
   840 void TestCpWlanApPlugin::tcInvalidIpv4DnsAddress()
       
   841 {
       
   842     QString previous = 
       
   843         mTestViewAdvanced->mIpv4DnsAddress1->contentWidgetData("text").toString();
       
   844     
       
   845     HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget);
       
   846     
       
   847     // Erase old string
       
   848     QString text = mTestViewAdvanced->mIpv4DnsAddress1->contentWidgetData("text").toString();
       
   849     subClearLineEdit(text.size());
       
   850     
       
   851     // Enter new string
       
   852     HbAutoTest::keyClicks(mMainWindow, "999.999.999.999", 0, waitTime);
       
   853 
       
   854     HbAutoTest::mouseClick(mMainWindow, mIpv4PrimaryDnsAddressWidget, exitEditorOffset);
       
   855 
       
   856     QTest::qWait(100);
       
   857     // Dismiss messagebox
       
   858     HbAutoTest::mouseClick(
       
   859         mMainWindow,
       
   860         mTestViewAdvanced->mMessageBox.data(),
       
   861         messageBoxOkButtonOffset);
       
   862     
       
   863     // Verify both commsdat and UI widget
       
   864     subVerifyString(
       
   865         CMManagerShim::CmIPNameServer1,
       
   866         mTestViewAdvanced->mIpv4DnsAddress1,
       
   867         previous);
       
   868 }
       
   869 
       
   870 /**
       
   871  * Scrolls the tested view to the top.
       
   872  */
       
   873 void TestCpWlanApPlugin::tcScrollToTop()
       
   874 {
       
   875     subScrollToTop();
       
   876 }
       
   877 
       
   878 /**
       
   879  * Collapses the IPv4 settings group.
       
   880  */
       
   881 void TestCpWlanApPlugin::tcCollapseIpv4Settings()
       
   882 {
       
   883     HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, ipv4Group);
       
   884 }
       
   885 
       
   886 /**
       
   887  * Expands the IPv6 settings group and gets UI widget pointers.
       
   888  */
       
   889 void TestCpWlanApPlugin::tcExpandIpv6SettingsAndGetUiWidgets()
       
   890 {
       
   891     HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, ipv6Group);
       
   892 
       
   893     QTest::qWait(500);
       
   894     
       
   895     subGetAdvancedUiWidgets(1);
       
   896 }
       
   897 
       
   898 /**
       
   899  * Tests enabling of automatic IPv6 DNS addresses.
       
   900  */
       
   901 void TestCpWlanApPlugin::tcEnableAutomaticIpv6DnsAddress()
       
   902 {
       
   903     // Enable automatic IPv6 DNS address
       
   904     QPointF automaticPointOffset = comboBoxItemOffset;
       
   905     HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget);
       
   906     QTest::qWait(100);
       
   907     HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget, automaticPointOffset, 100);
       
   908     QTest::qWait(100);
       
   909     subVerifyBool(
       
   910         CMManagerShim::CmIP6DNSAddrFromServer,
       
   911         true);
       
   912     
       
   913     // Ensure that editing the IP address is not allowed
       
   914     HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget);
       
   915     HbAutoTest::mouseClick(mMainWindow, mIpv6SecondaryDnsAddressWidget);
       
   916 }
       
   917 
       
   918 /**
       
   919  * Tests enabling of well-known IPv6 DNS addresses.
       
   920  */
       
   921 void TestCpWlanApPlugin::tcEnableWellKnownIpv6DnsAddress()
       
   922 {
       
   923     // Enable well-known IPv6 DNS address
       
   924     QPointF wellKnownPointOffset = comboBoxItemOffset * 2;
       
   925     HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget);
       
   926     QTest::qWait(100);
       
   927     HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget, wellKnownPointOffset, 100);
       
   928     QTest::qWait(100);
       
   929     subVerifyBool(
       
   930         CMManagerShim::CmIP6DNSAddrFromServer,
       
   931         false);
       
   932     subVerifyString(
       
   933         CMManagerShim::CmIP6NameServer1,
       
   934         mTestViewAdvanced->mIpv6DnsAddress1,
       
   935         "fec0:000:0000:ffff::1");
       
   936     subVerifyString(
       
   937         CMManagerShim::CmIP6NameServer2,
       
   938         mTestViewAdvanced->mIpv6DnsAddress2,
       
   939         "fec0:000:0000:ffff::2");
       
   940     
       
   941     // Ensure that editing the IP address is not allowed
       
   942     HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget);
       
   943     HbAutoTest::mouseClick(mMainWindow, mIpv6SecondaryDnsAddressWidget);
       
   944 }
       
   945 
       
   946 /**
       
   947  * Tests enabling of user defined IPv6 DNS addresses.
       
   948  */
       
   949 void TestCpWlanApPlugin::tcEnableUserDefinedIpv6DnsAddress()
       
   950 {
       
   951     // Select user defined IPv6 DNS address
       
   952     QPointF userDefinedPointOffset = comboBoxItemOffset * 3;
       
   953     //QPointF userDefinedPointOffset(0, 160);
       
   954     HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget);
       
   955     QTest::qWait(100);
       
   956     HbAutoTest::mouseClick(mMainWindow, mIpv6DnsAddressAutomaticWidget, userDefinedPointOffset, 100);
       
   957     QTest::qWait(100);
       
   958     // Can't verify the setting from CommsDat here, because CMManager will
       
   959     // set it back to true if no valid IP address is yet defined. The flag
       
   960     // is verified in tcChangeIpv4DnsAddress().
       
   961 }
       
   962 
       
   963 /**
       
   964  * Tests changing of IPv6 DNS addresses.
       
   965  */
       
   966 void TestCpWlanApPlugin::tcChangeIpv6DnsAddress()
       
   967 {
       
   968     QFETCH(QString, string);
       
   969     QFETCH(QString, result);
       
   970     
       
   971     // Primary DNS address
       
   972     HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget);
       
   973     
       
   974     // Erase old string
       
   975     QString text = mTestViewAdvanced->mIpv6DnsAddress1->contentWidgetData("text").toString();
       
   976     subClearLineEdit(text.size());
       
   977     
       
   978     // Enter new string
       
   979     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
       
   980 
       
   981     HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget, exitEditorOffset);
       
   982 
       
   983     // Verify both commsdat and UI widget
       
   984     subVerifyString(
       
   985         CMManagerShim::CmIP6NameServer1,
       
   986         mTestViewAdvanced->mIpv6DnsAddress1,
       
   987         result);
       
   988     
       
   989     // Secondary DNS address
       
   990     HbAutoTest::mouseClick(mMainWindow, mIpv6SecondaryDnsAddressWidget);
       
   991     
       
   992     // Erase old string
       
   993     text = mTestViewAdvanced->mIpv6DnsAddress2->contentWidgetData("text").toString();
       
   994     subClearLineEdit(text.size());
       
   995     
       
   996     // Enter new string
       
   997     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
       
   998 
       
   999     HbAutoTest::mouseClick(mMainWindow, mIpv6SecondaryDnsAddressWidget, exitEditorOffset);
       
  1000 
       
  1001     // Verify both commsdat and UI widget
       
  1002     subVerifyString(
       
  1003         CMManagerShim::CmIP6NameServer2,
       
  1004         mTestViewAdvanced->mIpv6DnsAddress2,
       
  1005         result);
       
  1006     
       
  1007     // Verify user defined address is in use
       
  1008     subVerifyBool(
       
  1009         CMManagerShim::CmIP6DNSAddrFromServer,
       
  1010         false);
       
  1011 }
       
  1012 
       
  1013 /**
       
  1014  * Test data for IPv6 DNS address change test case.
       
  1015  */
       
  1016 void TestCpWlanApPlugin::tcChangeIpv6DnsAddress_data()
       
  1017 {
       
  1018     QTest::addColumn<QString>("string");
       
  1019     QTest::addColumn<QString>("result");
       
  1020   
       
  1021     QTest::newRow("normal")
       
  1022         << "2001:db8:85a3::8a2e:370:7334"
       
  1023         << "2001:db8:85a3:0:0:8a2e:370:7334";
       
  1024 }
       
  1025 
       
  1026 /**
       
  1027  * Tests invalid IPv6 DNS address.
       
  1028  */
       
  1029 void TestCpWlanApPlugin::tcInvalidIpv6DnsAddress()
       
  1030 {
       
  1031     QString previous = 
       
  1032         mTestViewAdvanced->mIpv6DnsAddress1->contentWidgetData("text").toString();
       
  1033     
       
  1034     HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget);
       
  1035     
       
  1036     // Erase old string
       
  1037     QString text = mTestViewAdvanced->mIpv6DnsAddress1->contentWidgetData("text").toString();
       
  1038     subClearLineEdit(text.size());
       
  1039     
       
  1040     // Enter new string
       
  1041     HbAutoTest::keyClicks(mMainWindow, "abcdef:fedcba", 0, waitTime);
       
  1042 
       
  1043     HbAutoTest::mouseClick(mMainWindow, mIpv6PrimaryDnsAddressWidget, exitEditorOffset);
       
  1044 
       
  1045     QTest::qWait(100);
       
  1046     // Dismiss messagebox
       
  1047     HbAutoTest::mouseClick(
       
  1048         mMainWindow,
       
  1049         mTestViewAdvanced->mMessageBox.data(),
       
  1050         messageBoxOkButtonOffset);
       
  1051     
       
  1052     // Verify both commsdat and UI widget
       
  1053     subVerifyString(
       
  1054         CMManagerShim::CmIP6NameServer1,
       
  1055         mTestViewAdvanced->mIpv6DnsAddress1,
       
  1056         previous);
       
  1057 }
       
  1058 
       
  1059 /**
       
  1060  * Collapses the IPv6 settings group.
       
  1061  */
       
  1062 void TestCpWlanApPlugin::tcCollapseIpv6Settings()
       
  1063 {
       
  1064     HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, ipv6Group);
       
  1065 }
       
  1066 
       
  1067 /**
       
  1068  * Expands the proxy settings group and gets UI widget pointers.
       
  1069  */
       
  1070 void TestCpWlanApPlugin::tcExpandProxySettingsAndGetUiWidgets()
       
  1071 {
       
  1072     HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, proxyGroup);
       
  1073 
       
  1074     QTest::qWait(500);
       
  1075     
       
  1076     subGetAdvancedUiWidgets(2);
       
  1077 }
       
  1078 
       
  1079 /**
       
  1080  * Tests changing of proxy server address.
       
  1081  */
       
  1082 void TestCpWlanApPlugin::tcChangeProxyServerAddress()
       
  1083 {
       
  1084     QFETCH(QString, string);
       
  1085     QFETCH(QString, result);
       
  1086     
       
  1087     HbAutoTest::mouseClick(mMainWindow, mProxyServerAddressWidget);
       
  1088     
       
  1089     // Erase old string
       
  1090     QString text = mTestViewAdvanced->mProxyServer->contentWidgetData("text").toString();
       
  1091     subClearLineEdit(text.size());
       
  1092     
       
  1093     // Enter new string
       
  1094     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
       
  1095 
       
  1096     HbAutoTest::mouseClick(mMainWindow, mProxyServerAddressWidget, exitEditorOffset);
       
  1097 
       
  1098     QTest::qWait(100);
       
  1099     
       
  1100     // Verify both commsdat and UI widget
       
  1101     subVerifyString(
       
  1102         CMManagerShim::CmProxyServerName,
       
  1103         mTestViewAdvanced->mProxyServer,
       
  1104         result);
       
  1105     // Verify user defined address flag is set correctly
       
  1106     if (result.isEmpty()) {
       
  1107         subVerifyBool(
       
  1108             CMManagerShim::CmProxyUsageEnabled,
       
  1109             false);
       
  1110     } else {
       
  1111         subVerifyBool(
       
  1112             CMManagerShim::CmProxyUsageEnabled,
       
  1113             true);
       
  1114     }
       
  1115 }
       
  1116 
       
  1117 /**
       
  1118  * Test data for proxy server address change test case.
       
  1119  */
       
  1120 void TestCpWlanApPlugin::tcChangeProxyServerAddress_data()
       
  1121 {
       
  1122     QTest::addColumn<QString>("string");
       
  1123     QTest::addColumn<QString>("result");
       
  1124   
       
  1125     QTest::newRow("long")
       
  1126         << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html"
       
  1127         << "http://developer.symbian.org/main/documentation/reference/s^3/doc_source/AboutSymbianOSLibrary9.6/index.html";
       
  1128     QTest::newRow("empty")
       
  1129         << ""
       
  1130         << "";
       
  1131     QTest::newRow("basic") // last one should always fit on one line in UI
       
  1132         << "http://www.symbian.org/"
       
  1133         << "http://www.symbian.org/";
       
  1134 }
       
  1135 
       
  1136 /**
       
  1137  * Tests changing of proxy port number.
       
  1138  */
       
  1139 void TestCpWlanApPlugin::tcChangeProxyPortNumber()
       
  1140 {
       
  1141     QFETCH(QString, string);
       
  1142     QFETCH(QString, result);
       
  1143     
       
  1144     HbAutoTest::mouseClick(mMainWindow, mProxyPortNumberWidget);
       
  1145     
       
  1146     // Erase old string
       
  1147     QString text = mTestViewAdvanced->mProxyPort->contentWidgetData("text").toString();
       
  1148     subClearLineEdit(text.size());
       
  1149     
       
  1150     // Enter new string
       
  1151     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
       
  1152 
       
  1153     HbAutoTest::mouseClick(mMainWindow, mProxyPortNumberWidget, exitEditorOffset);
       
  1154 
       
  1155     QTest::qWait(100);
       
  1156 
       
  1157     // Verify both commsdat and UI widget
       
  1158     subVerifyUint(
       
  1159         CMManagerShim::CmProxyPortNumber,
       
  1160         result.toInt());
       
  1161     QCOMPARE(
       
  1162         mTestViewAdvanced->mProxyPort->contentWidgetData("text").toInt(),
       
  1163         result.toInt());
       
  1164 }
       
  1165 
       
  1166 /**
       
  1167  * Test data for proxy port number change test case.
       
  1168  */
       
  1169 void TestCpWlanApPlugin::tcChangeProxyPortNumber_data()
       
  1170 {
       
  1171     QTest::addColumn<QString>("string");
       
  1172     QTest::addColumn<QString>("result");
       
  1173   
       
  1174     QTest::newRow("basic")
       
  1175         << "8080"
       
  1176         << "8080";
       
  1177     QTest::newRow("too long")
       
  1178         << "1234567890"
       
  1179         << "12345";
       
  1180     QTest::newRow("zero")
       
  1181         << "0"
       
  1182         << "";
       
  1183     QTest::newRow("empty")
       
  1184         << ""
       
  1185         << "";
       
  1186 }
       
  1187 
       
  1188 /**
       
  1189  * Tests invalid proxy port number.
       
  1190  */
       
  1191 void TestCpWlanApPlugin::tcInvalidProxyPortNumber()
       
  1192 {
       
  1193     int previous = 
       
  1194         mTestViewAdvanced->mProxyPort->contentWidgetData("text").toInt();
       
  1195     
       
  1196     HbAutoTest::mouseClick(mMainWindow, mProxyPortNumberWidget);
       
  1197     
       
  1198     // Erase old string
       
  1199     QString text = mTestViewAdvanced->mProxyPort->contentWidgetData("text").toString();
       
  1200     subClearLineEdit(text.size());
       
  1201     
       
  1202     // Enter new string
       
  1203     HbAutoTest::keyClicks(mMainWindow, "65536", 0, waitTime);
       
  1204 
       
  1205     HbAutoTest::mouseClick(mMainWindow, mProxyPortNumberWidget, exitEditorOffset);
       
  1206 
       
  1207     QTest::qWait(100);
       
  1208     // Dismiss messagebox
       
  1209     HbAutoTest::mouseClick(
       
  1210         mMainWindow,
       
  1211         mTestViewAdvanced->mMessageBox.data(),
       
  1212         messageBoxOkButtonOffset);
       
  1213     
       
  1214     // Verify both commsdat and UI widget
       
  1215     subVerifyUint(
       
  1216         CMManagerShim::CmProxyPortNumber,
       
  1217         previous);
       
  1218     QCOMPARE(
       
  1219         mTestViewAdvanced->mProxyPort->contentWidgetData("text").toInt(),
       
  1220         previous);
       
  1221 }
       
  1222 
       
  1223 /**
       
  1224  * Collapses the proxy settings group.
       
  1225  */
       
  1226 void TestCpWlanApPlugin::tcCollapseProxySettings()
       
  1227 {
       
  1228     HbAutoTest::mouseClick(mMainWindow, mTestViewAdvanced, proxyGroup);
       
  1229 }
       
  1230 
       
  1231 /**
       
  1232  * Returns from advanced settings view.
       
  1233  */
       
  1234 void TestCpWlanApPlugin::tcCloseAdvancedSettingsView()
       
  1235 {
   432     // Return from advanced settings view
  1236     // Return from advanced settings view
   433     subClickWidget("HbNavigationButton");
  1237     subClickWidget("HbNavigationButton");
   434 }
  1238 }
   435 
  1239 
   436 // -----------------------------------------------------------------------------
  1240 // -----------------------------------------------------------------------------
   437 // SUB TEST CASES
  1241 // SUB TEST CASES
   438 // -----------------------------------------------------------------------------
  1242 // -----------------------------------------------------------------------------
       
  1243 
       
  1244 /**
       
  1245  * Gets UI widget pointers.
       
  1246  */
       
  1247 void TestCpWlanApPlugin::subGetUiWidgets()
       
  1248 {
       
  1249     HbModelIterator iterator(mTestView->mModel);
       
  1250     
       
  1251     // Get "Access point settings" group item
       
  1252     QModelIndex apGroupIndex = iterator.index(0);
       
  1253     
       
  1254     // Get UI widgets
       
  1255     mConnectionNameWidget = subGetWidgetByIndex(
       
  1256         mTestView->mForm,
       
  1257         iterator.index(0, apGroupIndex));
       
  1258     mWlanNetworkNameWidget = subGetWidgetByIndex(
       
  1259         mTestView->mForm,
       
  1260         iterator.index(1, apGroupIndex));
       
  1261     mNetworkStatusWidget = subGetWidgetByIndex(
       
  1262         mTestView->mForm,
       
  1263         iterator.index(2, apGroupIndex));
       
  1264     mNetworkModeWidget = subGetWidgetByIndex(
       
  1265         mTestView->mForm,
       
  1266         iterator.index(3, apGroupIndex));
       
  1267     mSecurityModeWidget = subGetWidgetByIndex(
       
  1268         mTestView->mForm,
       
  1269         iterator.index(4, apGroupIndex));
       
  1270     mHomepageWidget = subGetWidgetByIndex(
       
  1271         mTestView->mForm,
       
  1272         iterator.index(5, apGroupIndex));
       
  1273 }
       
  1274 
       
  1275 /**
       
  1276  * Gets advanced settings view UI widget pointers by group index.
       
  1277  */
       
  1278 void TestCpWlanApPlugin::subGetAdvancedUiWidgets(
       
  1279     uint index)
       
  1280 {
       
  1281     // Get the group item
       
  1282     HbModelIterator iterator(mTestViewAdvanced->mModel);
       
  1283     QModelIndex groupIndex = iterator.index(index);
       
  1284     
       
  1285     // Get UI widgets
       
  1286     if (index == 0) {
       
  1287         // IPv4 settings group
       
  1288         mIpv4AddressAutomaticWidget = subGetWidgetByIndex(
       
  1289             mTestViewAdvanced->mForm,
       
  1290             iterator.index(0, groupIndex));
       
  1291         mIpv4AddressWidget = subGetWidgetByIndex(
       
  1292             mTestViewAdvanced->mForm,
       
  1293             iterator.index(1, groupIndex));
       
  1294         mIpv4SubnetMaskWidget = subGetWidgetByIndex(
       
  1295             mTestViewAdvanced->mForm,
       
  1296             iterator.index(2, groupIndex));
       
  1297         mIpv4GatewayWidget = subGetWidgetByIndex(
       
  1298             mTestViewAdvanced->mForm,
       
  1299             iterator.index(3, groupIndex));
       
  1300         mIpv4DnsAddressAutomaticWidget = subGetWidgetByIndex(
       
  1301             mTestViewAdvanced->mForm,
       
  1302             iterator.index(4, groupIndex));
       
  1303         mIpv4PrimaryDnsAddressWidget = subGetWidgetByIndex(
       
  1304             mTestViewAdvanced->mForm,
       
  1305             iterator.index(5, groupIndex));
       
  1306         mIpv4SecondaryDnsAddressWidget = subGetWidgetByIndex(
       
  1307             mTestViewAdvanced->mForm,
       
  1308             iterator.index(6, groupIndex));
       
  1309     } else if (index == 1) {
       
  1310         // IPv6 settings group
       
  1311         mIpv6DnsAddressAutomaticWidget = subGetWidgetByIndex(
       
  1312             mTestViewAdvanced->mForm,
       
  1313             iterator.index(0, groupIndex));
       
  1314         mIpv6PrimaryDnsAddressWidget = subGetWidgetByIndex(
       
  1315             mTestViewAdvanced->mForm,
       
  1316             iterator.index(1, groupIndex));
       
  1317         mIpv6SecondaryDnsAddressWidget = subGetWidgetByIndex(
       
  1318             mTestViewAdvanced->mForm,
       
  1319             iterator.index(2, groupIndex));    
       
  1320     } else {
       
  1321         // Proxy settings group
       
  1322         mProxyServerAddressWidget = subGetWidgetByIndex(
       
  1323             mTestViewAdvanced->mForm,
       
  1324             iterator.index(0, groupIndex));
       
  1325         mProxyPortNumberWidget = subGetWidgetByIndex(
       
  1326             mTestViewAdvanced->mForm,
       
  1327             iterator.index(1, groupIndex));
       
  1328     }
       
  1329 }
       
  1330 
       
  1331 /**
       
  1332  * Gets an UI widget from HbDataForm by index. 
       
  1333  */
       
  1334 HbWidget *TestCpWlanApPlugin::subGetWidgetByIndex(
       
  1335     HbDataForm *form,
       
  1336     const QModelIndex &index)
       
  1337 {
       
  1338     HbDataFormViewItem *viewItem = qobject_cast<HbDataFormViewItem *>
       
  1339         (form->itemByIndex(index));
       
  1340     HbWidget *widget = viewItem->dataItemContentWidget();
       
  1341     //QString widgetClassName(widget->metaObject()->className());
       
  1342     //qDebug() << widgetClassName;
       
  1343     return widget;
       
  1344 }
   439 
  1345 
   440 /**
  1346 /**
   441  * Verifies that given string is correctly stored in CommsDat and shown on UI. 
  1347  * Verifies that given string is correctly stored in CommsDat and shown on UI. 
   442  */
  1348  */
   443 void TestCpWlanApPlugin::subVerifyString(
  1349 void TestCpWlanApPlugin::subVerifyString(
   501  * Clears a HbLineEdit.
  1407  * Clears a HbLineEdit.
   502  */
  1408  */
   503 void TestCpWlanApPlugin::subClearLineEdit(
  1409 void TestCpWlanApPlugin::subClearLineEdit(
   504     uint length)
  1410     uint length)
   505 {
  1411 {
   506     // Erase old string
       
   507     QTest::qWait(5000); // TODO: Remove this when item specific menu doesn't pop up anymore
       
   508 
       
   509     // Move cursor to end of string
  1412     // Move cursor to end of string
   510     //HbAutoTest::keyClick(mMainWindow, Qt::Key_End, 0, waitTime); // doesn't seem to do anything? 
  1413     //HbAutoTest::keyClick(mMainWindow, Qt::Key_End, Qt::ControlModifier, waitTime); // doesn't seem to do anything? 
   511     HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime);
  1414     HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime);
   512     HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime);
  1415     HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime);
   513     HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime);
  1416     HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime);
   514     for (int i=0; i<25; i++) {
  1417     for (int i=0; i<25; i++) {
   515         HbAutoTest::keyClick(mMainWindow, Qt::Key_Right, 0, waitTime);
  1418         HbAutoTest::keyClick(mMainWindow, Qt::Key_Right, 0, waitTime);
   516     }
  1419     }
       
  1420     // Erase string
   517     for (int i=0; i<length; i++) {
  1421     for (int i=0; i<length; i++) {
   518         HbAutoTest::keyClick(mMainWindow, Qt::Key_Backspace, 0, waitTime);
  1422         HbAutoTest::keyClick(mMainWindow, Qt::Key_Backspace, 0, waitTime);
   519     }
  1423     }
   520 }
  1424 }
   521 
  1425 
   556     }
  1460     }
   557 
  1461 
   558     Q_ASSERT(target);
  1462     Q_ASSERT(target);
   559     HbAutoTest::mouseClick(mMainWindow, static_cast<HbWidget *>(target));
  1463     HbAutoTest::mouseClick(mMainWindow, static_cast<HbWidget *>(target));
   560 }
  1464 }
       
  1465 
       
  1466 /**
       
  1467  * Returns the middle point of a widget.
       
  1468  */
       
  1469 QPointF TestCpWlanApPlugin::subMiddlePointOfWidget(const HbWidget *widget)
       
  1470 {
       
  1471     QRectF widgetRect = widget->rect();
       
  1472     QRectF widgetSceneRect = widget->mapRectToScene(widgetRect);
       
  1473     qreal middleX = ((widgetSceneRect.right() - widgetSceneRect.left()) / 2) + widgetSceneRect.left();
       
  1474     qreal middleY = ((widgetSceneRect.bottom() - widgetSceneRect.top()) / 2) + widgetSceneRect.top();
       
  1475     
       
  1476     return QPointF(middleX, middleY);
       
  1477 }
       
  1478 
       
  1479 /**
       
  1480  * Verifies that given attribute contains expected boolean value in CommsDat. 
       
  1481  */
       
  1482 void TestCpWlanApPlugin::subVerifyBool(
       
  1483     CMManagerShim::ConnectionMethodAttribute attribute,
       
  1484     bool expected)
       
  1485 {
       
  1486     // Read attribute value from CommsDat
       
  1487     QScopedPointer<CmManagerShim> cmManager(new CmManagerShim);
       
  1488     QScopedPointer<CmConnectionMethodShim> connectionMethod( 
       
  1489         cmManager->connectionMethod(testApId));
       
  1490     bool commsdat = connectionMethod->getBoolAttribute(attribute);
       
  1491     
       
  1492     QCOMPARE(commsdat, expected);
       
  1493 }
       
  1494 
       
  1495 /**
       
  1496  * Scrolls the tested view to the bottom.
       
  1497  */
       
  1498 void TestCpWlanApPlugin::subScrollToBottom()
       
  1499 {
       
  1500     // Scroll to the bottom of the view
       
  1501     HbAutoTest::mousePress(mMainWindow, mTestView, scrollMiddle);
       
  1502     QTest::qWait(1000);
       
  1503     HbAutoTest::mouseMove(mMainWindow, mTestView, scrollTop);
       
  1504     HbAutoTest::mouseRelease(mMainWindow, mTestView, scrollTop);
       
  1505 }
       
  1506 
       
  1507 /**
       
  1508  * Scrolls the tested view to the top.
       
  1509  */
       
  1510 void TestCpWlanApPlugin::subScrollToTop()
       
  1511 {
       
  1512     // Scroll to the top of the view
       
  1513     HbAutoTest::mousePress(mMainWindow, mTestView, scrollMiddle);
       
  1514     QTest::qWait(1000);
       
  1515     HbAutoTest::mouseMove(mMainWindow, mTestView, scrollBottom);
       
  1516     HbAutoTest::mouseRelease(mMainWindow, mTestView, scrollBottom);
       
  1517 }