cmmanager/cppacketdataapplugin/tsrc/ut/testcppacketdataapplugin.cpp
changeset 20 9c97ad6591ae
child 32 5c4486441ae6
equal deleted inserted replaced
18:fcbbe021d614 20:9c97ad6591ae
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Control Panel packet data AP plugin unit testing.
       
    16 */
       
    17 
       
    18 #include <HbApplication>
       
    19 #include <HbMainWindow>
       
    20 #include <HbView>
       
    21 #include <HbDialog>
       
    22 #include <HbRadioButtonList>
       
    23 #include <HbAction>
       
    24 #include <HbDataForm>
       
    25 #include <HbDataFormModel>
       
    26 #include <HbDataFormModelItem>
       
    27 #include <QtTest/QtTest>
       
    28 #include <cpbearerapplugininterface.h>
       
    29 #include <cmmanager_shim.h>
       
    30 #include <cmconnectionmethod_shim.h>
       
    31 
       
    32 #include "cppacketdataapview.h"
       
    33 
       
    34 #include "hbautotest.h"
       
    35 #include "testcppacketdataapplugin.h"
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // STATIC TEST DATA
       
    39 // -----------------------------------------------------------------------------
       
    40 
       
    41 // Connection method (AP) ID used for testing
       
    42 static const uint testApId = 1;
       
    43 
       
    44 static const QString pluginDir =
       
    45     "\\resource\\qt\\plugins\\controlpanel\\bearerap";
       
    46 
       
    47 static const QString pluginName = "cppacketdataapplugin.dll";
       
    48 
       
    49 // Time to wait before continuing after an UI step
       
    50 static const int waitTime = 10;
       
    51 
       
    52 // UI coordinates
       
    53 static const QPoint sideTop(350, 60);
       
    54 static const QPoint scrollStart(350, 300);
       
    55 static const QPoint scrollStop(350, 240);
       
    56 
       
    57 static const QPoint messageBoxOkButton(170, 320);
       
    58 
       
    59 // These are measured when view is scrolled to top
       
    60 static const QPoint connectionNameLineEdit(330, 110);
       
    61 
       
    62 static const QPoint accessPointNameLineEdit(330, 190);
       
    63 
       
    64 static const QPoint userNameLineEdit(330, 265);
       
    65 
       
    66 // These are measured when view is scrolled to bottom
       
    67 static const QPoint passwordPromptCheckbox(50, 295);
       
    68 static const QPoint passwordLineEdit(330, 380);
       
    69 
       
    70 static const QPoint authenticationComboBox(175, 470);
       
    71 static const QPoint authenticationSecure(100, 420);
       
    72 static const QPoint authenticationNormal(100, 365);
       
    73 
       
    74 static const QPoint homepageLineEdit(330, 555);
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // FRAMEWORK FUNCTIONS
       
    78 // -----------------------------------------------------------------------------
       
    79 
       
    80 /**
       
    81  * Test main function. Runs all test cases.
       
    82  */
       
    83 #ifndef TESTCMAPPLSETTINGSUI_NO_OUTPUT_REDIRECT
       
    84 int main(int argc, char *argv[])
       
    85 {
       
    86     HbApplication app(argc, argv);
       
    87     app.setApplicationName("TestCpPacketDataApPlugin");
       
    88     
       
    89     char *pass[3];  
       
    90     pass[0] = argv[0];
       
    91     pass[1] = "-o"; 
       
    92     pass[2] = "c:\\data\\TestCpPacketDataApPlugin.txt";
       
    93  
       
    94     TestCpPacketDataApPlugin tc;
       
    95     int res = QTest::qExec(&tc, 3, pass);
       
    96  
       
    97     return res;
       
    98 }
       
    99 #else
       
   100 QTEST_MAIN(TestCpPacketDataApPlugin)
       
   101 #endif
       
   102 
       
   103 /**
       
   104  * This function is be called before the first test case is executed.
       
   105  */
       
   106 void TestCpPacketDataApPlugin::initTestCase()
       
   107 {
       
   108     mMainWindow = new HbAutoTestMainWindow;
       
   109     //mMainWindow = new HbMainWindow;
       
   110     mMainWindow->show();
       
   111     
       
   112     // Load plugin
       
   113     QDir dir(pluginDir);
       
   114     QPluginLoader loader(dir.absoluteFilePath(pluginName));
       
   115     mPlugin = qobject_cast<CpBearerApPluginInterface *>(loader.instance());
       
   116     QVERIFY(mPlugin != NULL);
       
   117     
       
   118     // Verify plugin bearer type
       
   119     QVERIFY(mPlugin->bearerType() == CMManagerShim::BearerTypePacketData);
       
   120     
       
   121     // Create packet data settings view (connection method ID given)
       
   122     subCreateSettingsView(testApId);
       
   123 }
       
   124 
       
   125 /**
       
   126  * This function is be called after the last test case was executed.
       
   127  */
       
   128 void TestCpPacketDataApPlugin::cleanupTestCase()
       
   129 {
       
   130     delete mMainWindow;
       
   131     mMainWindow = 0;
       
   132 }
       
   133 
       
   134 /**
       
   135  * This function is be called before each test case is executed.
       
   136  */
       
   137 void TestCpPacketDataApPlugin::init()
       
   138 {
       
   139     QTest::qWait(1000);
       
   140 }
       
   141 
       
   142 /**
       
   143  * This function is be called after each test case is executed.
       
   144  */
       
   145 void TestCpPacketDataApPlugin::cleanup()
       
   146 {
       
   147 }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // TEST CASES
       
   151 // -----------------------------------------------------------------------------
       
   152 
       
   153 /**
       
   154  * Tests changing of connection name.
       
   155  */
       
   156 void TestCpPacketDataApPlugin::tcChangeConnectionName()
       
   157 {
       
   158     QFETCH(QString, string);
       
   159     QFETCH(QString, result);
       
   160     
       
   161     HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLineEdit);
       
   162     
       
   163     // Erase old string
       
   164     subClearLineEdit(CMManagerShim::CmNameLength);
       
   165     
       
   166     // Enter new string
       
   167     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
       
   168 
       
   169     HbAutoTest::mouseClick(mMainWindow, mTestView, sideTop);
       
   170 
       
   171     // Verify both commsdat and UI widget
       
   172     subVerifyString(
       
   173         CMManagerShim::CmName,
       
   174         mTestView->mConnectionNameItem,
       
   175         result);
       
   176 }
       
   177 
       
   178 /**
       
   179  * Test data for connection name change test case.
       
   180  */
       
   181 void TestCpPacketDataApPlugin::tcChangeConnectionName_data()
       
   182 {
       
   183     QTest::addColumn<QString>("string");
       
   184     QTest::addColumn<QString>("result");
       
   185     
       
   186     QTest::newRow("maximum length")
       
   187         << "really long name 1234567890123"
       
   188         << "really long name 1234567890123";
       
   189     QTest::newRow("too long")
       
   190         << "too long name 123456789012345678901234567890"
       
   191         << "too long name 1234567890123456";
       
   192     QTest::newRow("basic") // last one must always fit on one line in UI
       
   193         << "test packet AP"
       
   194         << "test packet AP";
       
   195 }
       
   196 
       
   197 /**
       
   198  * Tests that empty connection name is not accepted.
       
   199  */
       
   200 void TestCpPacketDataApPlugin::tcConnectionNameEmpty()
       
   201 {
       
   202     QString previous = 
       
   203         mTestView->mConnectionNameItem->contentWidgetData("text").toString();
       
   204     
       
   205     HbAutoTest::mouseClick(mMainWindow, mTestView, connectionNameLineEdit);
       
   206     
       
   207     // Erase old string
       
   208     subClearLineEdit(CMManagerShim::CmNameLength);
       
   209     
       
   210     HbAutoTest::mouseClick(mMainWindow, mTestView, sideTop);
       
   211 
       
   212     QTest::qWait(100);
       
   213     // Dismiss messagebox
       
   214     HbAutoTest::mouseClick(mMainWindow, mTestView, messageBoxOkButton);
       
   215     
       
   216     // Verify both commsdat and UI widget
       
   217     subVerifyString(
       
   218         CMManagerShim::CmName,
       
   219         mTestView->mConnectionNameItem,
       
   220         previous);
       
   221 }
       
   222 
       
   223 /**
       
   224  * Tests changing of access point name.
       
   225  */
       
   226 void TestCpPacketDataApPlugin::tcChangeAccessPointName()
       
   227 {
       
   228     QFETCH(QString, string);
       
   229     QFETCH(QString, result);
       
   230     
       
   231     HbAutoTest::mouseClick(mMainWindow, mTestView, accessPointNameLineEdit);
       
   232     
       
   233     // Erase old string
       
   234     subClearLineEdit(CMManagerShim::PacketDataAPNameLength);
       
   235     
       
   236     // Enter new string
       
   237     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
       
   238 
       
   239     HbAutoTest::mouseClick(mMainWindow, mTestView, sideTop);
       
   240 
       
   241     // Verify both commsdat and UI widget
       
   242     subVerifyString(
       
   243         CMManagerShim::PacketDataAPName,
       
   244         mTestView->mAccessPointNameItem,
       
   245         result);
       
   246 }
       
   247 
       
   248 /**
       
   249  * Test data for access point name change test case.
       
   250  */
       
   251 void TestCpPacketDataApPlugin::tcChangeAccessPointName_data()
       
   252 {
       
   253     QTest::addColumn<QString>("string");
       
   254     QTest::addColumn<QString>("result");
       
   255     
       
   256     QTest::newRow("maximum length")
       
   257         << "really long name 12345678901234567890123456789012345678901234567890123456789012345678901234567890123"
       
   258         << "really long name 12345678901234567890123456789012345678901234567890123456789012345678901234567890123";
       
   259     QTest::newRow("too long")
       
   260         << "too long name 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345"
       
   261         << "too long name 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456";
       
   262     QTest::newRow("basic") // last one must always fit on one line in UI
       
   263         << "test AP name"
       
   264         << "test AP name";
       
   265 }
       
   266 
       
   267 /**
       
   268  * Tests that empty access point name is not accepted.
       
   269  */
       
   270 void TestCpPacketDataApPlugin::tcAccessPointNameEmpty()
       
   271 {
       
   272     QString previous = 
       
   273         mTestView->mAccessPointNameItem->contentWidgetData("text").toString();
       
   274     
       
   275     HbAutoTest::mouseClick(mMainWindow, mTestView, accessPointNameLineEdit);
       
   276     
       
   277     // Erase old string
       
   278     subClearLineEdit(CMManagerShim::PacketDataAPNameLength);
       
   279     
       
   280     HbAutoTest::mouseClick(mMainWindow, mTestView, sideTop);
       
   281 
       
   282     QTest::qWait(100);
       
   283     // Dismiss messagebox
       
   284     HbAutoTest::mouseClick(mMainWindow, mTestView, messageBoxOkButton);
       
   285     
       
   286     // Verify both commsdat and UI widget
       
   287     subVerifyString(
       
   288         CMManagerShim::PacketDataAPName,
       
   289         mTestView->mAccessPointNameItem,
       
   290         previous);
       
   291 }
       
   292 
       
   293 /**
       
   294  * Tests changing of user name.
       
   295  */
       
   296 void TestCpPacketDataApPlugin::tcChangeUserName()
       
   297 {
       
   298     QFETCH(QString, string);
       
   299     QFETCH(QString, result);
       
   300     
       
   301     HbAutoTest::mouseClick(mMainWindow, mTestView, userNameLineEdit);
       
   302     
       
   303     // Erase old string
       
   304     subClearLineEdit(CMManagerShim::PacketDataIFAuthNameLength);
       
   305     
       
   306     // Enter new string
       
   307     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
       
   308 
       
   309     HbAutoTest::mouseClick(mMainWindow, mTestView, sideTop);
       
   310 
       
   311     // Verify both commsdat and UI widget
       
   312     subVerifyString(
       
   313         CMManagerShim::PacketDataIFAuthName,
       
   314         mTestView->mUserNameItem,
       
   315         result);
       
   316 }
       
   317 
       
   318 /**
       
   319  * Test data for user name change test case.
       
   320  */
       
   321 void TestCpPacketDataApPlugin::tcChangeUserName_data()
       
   322 {
       
   323     QTest::addColumn<QString>("string");
       
   324     QTest::addColumn<QString>("result");
       
   325 
       
   326 // Long strings don't work, Orbit bug? Screen goes blank
       
   327 //    QTest::newRow("maximum length")
       
   328 //        << "really long name 123456789012345678901234567890123"
       
   329 //        << "really long name 123456789012345678901234567890123";
       
   330 //    QTest::newRow("too long")
       
   331 //        << "too long name 1234567890123456789012345678901234567890123"
       
   332 //        << "too long name 123456789012345678901234567890123456";
       
   333     QTest::newRow("basic")
       
   334         << "username"
       
   335         << "username";
       
   336     QTest::newRow("empty") // last one must always fit on one line in UI
       
   337         << ""
       
   338         << "";
       
   339 }
       
   340 
       
   341 /**
       
   342  * Scrolls the tested view to the bottom.
       
   343  */
       
   344 void TestCpPacketDataApPlugin::tcScrollToBottom()
       
   345 {
       
   346     // Scroll to the bottom of the view
       
   347     HbAutoTest::mousePress(mMainWindow, mTestView, scrollStart);
       
   348     QTest::qWait(500);
       
   349     HbAutoTest::mouseMove(mMainWindow, mTestView, scrollStop);
       
   350     HbAutoTest::mouseRelease(mMainWindow, mTestView, scrollStop);
       
   351 }
       
   352 
       
   353 /**
       
   354  * Tests "prompt" password checkbox.
       
   355  */
       
   356 void TestCpPacketDataApPlugin::tcChangePromptPassword()
       
   357 {
       
   358     // Ensure prompt for password is unchecked
       
   359     bool prompt = subGetBool(CMManagerShim::PacketDataIFPromptForAuth);
       
   360     if (prompt) {
       
   361         // Disable prompt for password
       
   362         HbAutoTest::mouseClick(
       
   363             mMainWindow,
       
   364             mTestView,
       
   365             passwordPromptCheckbox);
       
   366     }
       
   367     
       
   368     // Enable prompt for password and verify
       
   369     HbAutoTest::mouseClick(mMainWindow, mTestView, passwordPromptCheckbox);
       
   370     subVerifyBool(
       
   371         CMManagerShim::PacketDataIFPromptForAuth,
       
   372         true);
       
   373     
       
   374     // Verify that password lineedit is disabled, following steps will
       
   375     // fail if editing is allowed
       
   376     HbAutoTest::mouseClick(mMainWindow, mTestView, passwordLineEdit);
       
   377     QTest::qWait(waitTime);
       
   378 
       
   379     // Disable prompt for password and verify
       
   380     HbAutoTest::mouseClick(mMainWindow, mTestView, passwordPromptCheckbox);
       
   381     subVerifyBool(
       
   382         CMManagerShim::PacketDataIFPromptForAuth,
       
   383         false);
       
   384 }
       
   385 
       
   386 /**
       
   387  * Tests changing of password.
       
   388  */
       
   389 void TestCpPacketDataApPlugin::tcChangePassword()
       
   390 {
       
   391     QFETCH(QString, string);
       
   392     QFETCH(QString, result);
       
   393     
       
   394     HbAutoTest::mouseClick(mMainWindow, mTestView, passwordLineEdit);
       
   395     
       
   396     // Erase old string
       
   397     subClearLineEdit(CMManagerShim::PacketDataIFAuthPassLength);
       
   398     
       
   399     // Enter new string
       
   400     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
       
   401 
       
   402     HbAutoTest::mouseClick(mMainWindow, mTestView, sideTop);
       
   403 
       
   404     // Verify both commsdat and UI widget
       
   405     subVerifyString(
       
   406         CMManagerShim::PacketDataIFAuthPass,
       
   407         mTestView->mPasswordItem,
       
   408         result);
       
   409 }
       
   410 
       
   411 /**
       
   412  * Test data for password change test case.
       
   413  */
       
   414 void TestCpPacketDataApPlugin::tcChangePassword_data()
       
   415 {
       
   416     QTest::addColumn<QString>("string");
       
   417     QTest::addColumn<QString>("result");
       
   418 
       
   419 // Long strings don't work, Orbit bug? Screen goes blank
       
   420 //    QTest::newRow("maximum length")
       
   421 //        << "really long name 123456789012345678901234567890123"
       
   422 //        << "really long name 123456789012345678901234567890123";
       
   423 //    QTest::newRow("too long")
       
   424 //        << "too long name 1234567890123456789012345678901234567890123"
       
   425 //        << "too long name 123456789012345678901234567890123456";
       
   426     QTest::newRow("basic")
       
   427         << "password"
       
   428         << "password";
       
   429     QTest::newRow("empty") // last one must always fit on one line in UI
       
   430         << ""
       
   431         << "";
       
   432 }
       
   433 
       
   434 /**
       
   435  * Tests changing of authentication mode.
       
   436  */
       
   437 void TestCpPacketDataApPlugin::tcChangeAuthenticationMode()
       
   438 {
       
   439     // Set authentication mode to secure
       
   440     HbAutoTest::mouseClick(mMainWindow, mTestView, authenticationComboBox, 100);
       
   441     QTest::qWait(100);
       
   442     HbAutoTest::mouseClick(mMainWindow, mTestView, authenticationSecure, 100);
       
   443 
       
   444     subVerifyBool(
       
   445         CMManagerShim::PacketDataDisablePlainTextAuth,
       
   446         true);
       
   447     
       
   448     // Set authentication mode to normal
       
   449     HbAutoTest::mouseClick(mMainWindow, mTestView, authenticationComboBox, 100);
       
   450     QTest::qWait(100);
       
   451     HbAutoTest::mouseClick(mMainWindow, mTestView, authenticationNormal, 100);
       
   452 
       
   453     subVerifyBool(
       
   454         CMManagerShim::PacketDataDisablePlainTextAuth,
       
   455         false);
       
   456 }
       
   457 
       
   458 /**
       
   459  * Tests changing of homepage.
       
   460  */
       
   461 void TestCpPacketDataApPlugin::tcChangeHomepage()
       
   462 {
       
   463     QFETCH(QString, string);
       
   464     QFETCH(QString, result);
       
   465     
       
   466     HbAutoTest::mouseClick(mMainWindow, mTestView, homepageLineEdit);
       
   467     
       
   468     // Erase old string
       
   469     QString text = mTestView->mHomepageItem->contentWidgetData("text").toString();
       
   470     subClearLineEdit(text.size());
       
   471     
       
   472     // Enter new string
       
   473     HbAutoTest::keyClicks(mMainWindow, string, 0, waitTime);
       
   474 
       
   475     HbAutoTest::mouseClick(mMainWindow, mTestView, sideTop);
       
   476 
       
   477     // Verify both commsdat and UI widget
       
   478     subVerifyString(
       
   479         CMManagerShim::CmStartPage,
       
   480         mTestView->mHomepageItem,
       
   481         result);
       
   482 }
       
   483 
       
   484 /**
       
   485  * Test data for homepage change test case.
       
   486  */
       
   487 void TestCpPacketDataApPlugin::tcChangeHomepage_data()
       
   488 {
       
   489     QTest::addColumn<QString>("string");
       
   490     QTest::addColumn<QString>("result");
       
   491   
       
   492 // Doesn't work always, view goes blank sometimes, Orbit bug?
       
   493 //    QTest::newRow("long")
       
   494 //        << "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
       
   497         << "http://www.symbian.org/"
       
   498         << "http://www.symbian.org/";
       
   499     QTest::newRow("empty")
       
   500         << ""
       
   501         << "";
       
   502 }
       
   503 
       
   504 /**
       
   505  * Tests advanced settings view (which is currently empty).
       
   506  */
       
   507 void TestCpPacketDataApPlugin::tcAdvancedSettings()
       
   508 {
       
   509     // Launch advanced settings view
       
   510     bool status = connect(
       
   511         this,
       
   512         SIGNAL(menuActionTriggered(HbAction *)),
       
   513         mTestView,
       
   514         SLOT(menuActionTriggered(HbAction *)));
       
   515     Q_ASSERT(status);
       
   516     emit menuActionTriggered(mTestView->mAdvancedSettingsAction);
       
   517 
       
   518     QTest::qWait(2000);
       
   519     
       
   520     // Return from advanced settings view
       
   521     subClickWidget("HbNavigationButton");
       
   522 }
       
   523 
       
   524 // -----------------------------------------------------------------------------
       
   525 // SUB TEST CASES
       
   526 // -----------------------------------------------------------------------------
       
   527 
       
   528 /**
       
   529  * Creates the settings view and shows it.
       
   530  */
       
   531 void TestCpPacketDataApPlugin::subCreateSettingsView(uint connectionMethodId)
       
   532 {
       
   533     // Create settings view
       
   534     HbView *view = mPlugin->createSettingView(connectionMethodId);
       
   535     QVERIFY(view != NULL);
       
   536     
       
   537     // Display the view
       
   538     mMainWindow->addView(view);
       
   539     mMainWindow->setCurrentView(view);
       
   540     // Store pointer to settings view class
       
   541     mTestView = static_cast<CpPacketDataApView *>(view);    
       
   542 }
       
   543 
       
   544 /**
       
   545  * Verifies that given string is correctly stored in CommsDat and shown on UI. 
       
   546  */
       
   547 void TestCpPacketDataApPlugin::subVerifyString(
       
   548     CMManagerShim::ConnectionMethodAttribute attribute,
       
   549     HbDataFormModelItem *item,
       
   550     QString expected)
       
   551 {
       
   552     // Read attribute value from CommsDat
       
   553     QScopedPointer<CmManagerShim> cmManager(new CmManagerShim);
       
   554     QScopedPointer<CmConnectionMethodShim> connectionMethod( 
       
   555         cmManager->connectionMethod(testApId));
       
   556     QString commsdat = connectionMethod->getStringAttribute(attribute);
       
   557 
       
   558     QCOMPARE(commsdat, expected);
       
   559 
       
   560     // Get value from UI widget
       
   561     QString widget = item->contentWidgetData("text").toString();
       
   562 
       
   563     QCOMPARE(widget, expected);
       
   564 }
       
   565 
       
   566 /**
       
   567  * Clears a HbLineEdit.
       
   568  */
       
   569 void TestCpPacketDataApPlugin::subClearLineEdit(
       
   570     uint length)
       
   571 {
       
   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
       
   576     //HbAutoTest::keyClick(mMainWindow, Qt::Key_End, 0, waitTime); // doesn't seem to do anything? 
       
   577     HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime);
       
   578     HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime);
       
   579     HbAutoTest::keyClick(mMainWindow, Qt::Key_Down, 0, waitTime);
       
   580     for (int i=0; i<25; i++) {
       
   581         HbAutoTest::keyClick(mMainWindow, Qt::Key_Right, 0, waitTime);
       
   582     }
       
   583     for (int i=0; i<length; i++) {
       
   584         HbAutoTest::keyClick(mMainWindow, Qt::Key_Backspace, 0, waitTime);
       
   585     }
       
   586 }
       
   587 
       
   588 /**
       
   589  * Gets value of a boolean attribute from CommsDat.
       
   590  */
       
   591 bool TestCpPacketDataApPlugin::subGetBool(
       
   592     CMManagerShim::ConnectionMethodAttribute attribute)
       
   593 {
       
   594     QScopedPointer<CmManagerShim> cmManager(new CmManagerShim);
       
   595     QScopedPointer<CmConnectionMethodShim> connectionMethod( 
       
   596         cmManager->connectionMethod(testApId));
       
   597     return connectionMethod->getBoolAttribute(attribute);
       
   598 }
       
   599 
       
   600 /**
       
   601  * Verifies that given attribute contains expected boolean value in CommsDat. 
       
   602  */
       
   603 void TestCpPacketDataApPlugin::subVerifyBool(
       
   604     CMManagerShim::ConnectionMethodAttribute attribute,
       
   605     bool expected)
       
   606 {
       
   607     // Read attribute value from CommsDat
       
   608     QScopedPointer<CmManagerShim> cmManager(new CmManagerShim);
       
   609     QScopedPointer<CmConnectionMethodShim> connectionMethod( 
       
   610         cmManager->connectionMethod(testApId));
       
   611     bool commsdat = connectionMethod->getBoolAttribute(attribute);
       
   612     
       
   613     QCOMPARE(commsdat, expected);
       
   614 }
       
   615 
       
   616 /**
       
   617  * Clicks a widget currently on UI by class name.
       
   618  */
       
   619 void TestCpPacketDataApPlugin::subClickWidget(const QString &name)
       
   620 {
       
   621     QList<QGraphicsItem *> itemList = mMainWindow->scene()->items();
       
   622 
       
   623     QGraphicsItem *target = 0;
       
   624     foreach (QGraphicsItem* item, itemList) {
       
   625         if (item->isWidget()) {
       
   626             QString widgetClassName(static_cast<QGraphicsWidget*>(item)->metaObject()->className());
       
   627             //qDebug() << widgetClassName;
       
   628             
       
   629             if (widgetClassName == name) {
       
   630                 target = item;
       
   631                 break;
       
   632             }
       
   633         }
       
   634     }
       
   635 
       
   636     Q_ASSERT(target);
       
   637     HbAutoTest::mouseClick(mMainWindow, static_cast<HbWidget *>(target));
       
   638 }