wlanutilities/wlanwizard/tsrc/ut/testwlanwizardcontext.cpp
changeset 56 de27cc8389dd
child 58 301aeb18ae47
equal deleted inserted replaced
50:d4198dcb9983 56:de27cc8389dd
       
     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  */
       
    16 
       
    17 // System includes
       
    18 #include <HbApplication>
       
    19 #include <HbDocumentLoader>
       
    20 #include <HbStackedWidget>
       
    21 #include <HbRadioButtonList>
       
    22 #include <HbAction>
       
    23 #include <HbLineEdit>
       
    24 #include <HbLabel>
       
    25 #include <HbCheckBox>
       
    26 #include <QGraphicsWidget>
       
    27 #include <QObjectList>
       
    28 #include <QtCore>
       
    29 #include <QTest>
       
    30 #include <QDebug>
       
    31 #include <QList>
       
    32 #include <HbListWidget>
       
    33 #include <HbListWidgetItem>
       
    34 #include <HbParameterLengthLimiter>
       
    35 
       
    36 // User includes
       
    37 #include "testwlanwizardcontext.h"
       
    38 #include "hbautotest.h"
       
    39 #include "wlanwizard.h"
       
    40 #include "wlanwizard_p.h"
       
    41 #include "wlanwizardpageinternal.h"
       
    42 #include "wlanwizardhelper.h"
       
    43 #include "wlanqtutils_context.h"
       
    44 #include "wlanqtutils.h"
       
    45 #include "wlanqtutilsap.h"
       
    46 #include "eapqtconfiginterface_context.h"
       
    47 #include "eapwizard.h"
       
    48 #include "eapwizard_p.h"
       
    49 #include "eapwizardpage.h"
       
    50 #include "wpswizardpage.h"
       
    51 #include "wlanmgmtclient_context.h"
       
    52 #include "wpswizardstepfour.h"
       
    53 #include "wpswizardstepfour_p.h"
       
    54 #include "cwpsactiverunner.h"
       
    55 
       
    56 // External function prototypes
       
    57 
       
    58 // Local constants
       
    59 class TestRadioButtonList: public HbRadioButtonList
       
    60 {
       
    61 public:
       
    62     void emitActivated(const QModelIndex &modelIndex)
       
    63     { HbRadioButtonList::emitActivated(modelIndex); }
       
    64 };
       
    65 
       
    66 
       
    67 // ---------------------------------------------------------
       
    68 // FRAMEWORK FUNCTIONS
       
    69 // ---------------------------------------------------------
       
    70 
       
    71 ContextWlanApList::ContextWlanApList()
       
    72 {
       
    73 
       
    74 }
       
    75 
       
    76 ContextWlanApList::~ContextWlanApList()
       
    77 {
       
    78     clear();
       
    79 }
       
    80 
       
    81 void ContextWlanApList::Add(QString name, int netMode, int secMode, bool wpaPskInUse,
       
    82     bool wpsSupported, int signalStrength)
       
    83 {
       
    84     QSharedPointer<WlanQtUtilsAp> temp = QSharedPointer<WlanQtUtilsAp>(new WlanQtUtilsAp());
       
    85     temp->setValue(WlanQtUtilsAp::ConfIdSsid, name);
       
    86     temp->setValue(WlanQtUtilsAp::ConfIdConnectionMode, netMode);
       
    87     temp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, secMode);
       
    88     temp->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, wpaPskInUse);
       
    89     temp->setValue(WlanQtUtilsAp::ConfIdWpsSupported, wpsSupported);
       
    90     temp->setValue(WlanQtUtilsAp::ConfIdSignalStrength, signalStrength);
       
    91 
       
    92     mList.append(temp);
       
    93 }
       
    94 
       
    95 void ContextWlanApList::clear()
       
    96 {
       
    97     mList.clear();
       
    98 }
       
    99 
       
   100 
       
   101 TestWlanWizardContext::TestWlanWizardContext() :
       
   102     mView(NULL),
       
   103     mMainWindow(NULL),
       
   104     mWlanQtUtilsContext(NULL),
       
   105     mEapQtUtilsContext(NULL),
       
   106     mWlanMgmtClientContext(NULL),
       
   107     mApList(NULL),
       
   108     mApOpenList(NULL)   
       
   109 {
       
   110     
       
   111 }
       
   112 TestWlanWizardContext::~TestWlanWizardContext()
       
   113 {
       
   114     
       
   115 }
       
   116 
       
   117 /**
       
   118  * This function will be called before the first test function is executed.
       
   119  */
       
   120 void TestWlanWizardContext::initTestCase()
       
   121 {
       
   122     qDebug("TestWlanWizardContext::initTestCase");
       
   123 
       
   124     mMainWindow = new HbAutoTestMainWindow;
       
   125 
       
   126     mView = new TestView();
       
   127 
       
   128     mMainWindow->addView(mView);
       
   129     mMainWindow->setCurrentView(mView);
       
   130     mMainWindow->installEventFilter(this);
       
   131     mMainWindow->show();
       
   132 
       
   133     QTest::qWait(1);
       
   134     while (!mEvent) {
       
   135         QTest::qWait(WaitTimeForUi);
       
   136     }
       
   137     mEvent = false;
       
   138     mApList = new ContextWlanApList();
       
   139     mApOpenList = new ContextWlanApList();
       
   140 
       
   141 }
       
   142 
       
   143 /**
       
   144  * This function will be called after the last test function was executed.
       
   145  */
       
   146 void TestWlanWizardContext::cleanupTestCase()
       
   147 {
       
   148     qDebug("TestWlanWizardContext::cleanupTestCase");
       
   149 
       
   150     qDebug("delete mApList");
       
   151     delete mApList;
       
   152     mApList = NULL;
       
   153     delete mApOpenList;
       
   154     mApOpenList = NULL;
       
   155 
       
   156     qDebug("delete mMainWindow");
       
   157     mMainWindow->setAttribute( Qt::WA_DeleteOnClose, true );
       
   158     mMainWindow->close();
       
   159     mMainWindow = NULL;
       
   160     QTest::qWait(WaitTimeForUi);
       
   161     qDebug("TestWlanWizardContext::cleanupTestCase exit");
       
   162 }
       
   163 
       
   164 /**
       
   165  * This function will be called before each test function is executed.
       
   166  */
       
   167 void TestWlanWizardContext::init()
       
   168 {
       
   169     qDebug("TestWlanWizardContext::init()");
       
   170 
       
   171     mView->createWizard();
       
   172     mWlanQtUtilsContext = new WlanQtUtilsContext(mView->mWizard->d_ptr->mWlanQtUtils.data());
       
   173 
       
   174     mEapQtUtilsContext = new EapQtConfigInterfaceContext();
       
   175     mEapQtUtilsContext->setObject(getEapQtConfig());
       
   176     
       
   177     mWlanMgmtClientContext = new WlanMgmtClientContext();
       
   178     //mWlanMgmtClientContext->setObject(mWlanMgmtClient);
       
   179     
       
   180     WpsPageStepFour* wps = (WpsPageStepFour*)(mView->mWizard->d_ptr->mPages[WpsWizardPage::PageWpsWizardStep4]);
       
   181     Q_ASSERT(wps);
       
   182     mWlanMgmtClientContext->setObject(wps->d_ptr->mWpsActiveRunner->iWLANMgmtClient);
       
   183 }
       
   184 
       
   185 /**
       
   186  * This function will be called after each test function is executed.
       
   187  */
       
   188 void TestWlanWizardContext::cleanup()
       
   189 {
       
   190     qDebug("TestWlanWizardContext::cleanup()");
       
   191 
       
   192     delete mWlanQtUtilsContext;
       
   193     delete mEapQtUtilsContext;
       
   194     delete mWlanMgmtClientContext;
       
   195     
       
   196     mView->deleteWizard();
       
   197     mApList->clear();
       
   198     mApOpenList->clear();
       
   199     QTest::qWait(1);
       
   200 }
       
   201 
       
   202 
       
   203 /*!
       
   204  * Filter to catch focus event to the text editor widget.
       
   205  */
       
   206 bool TestWlanWizardContext::eventFilter(QObject *obj, QEvent *event)
       
   207 {
       
   208     if (obj == mMainWindow && event->type() == QEvent::Show) {
       
   209         mMainWindow->removeEventFilter(this);
       
   210         mEvent = true;
       
   211     }
       
   212     return false;
       
   213 }
       
   214 
       
   215 QGraphicsWidget* TestWlanWizardContext::findChildItem(const QString &itemName, QGraphicsItem *widget)
       
   216 {
       
   217     QList<QGraphicsItem*> list = widget->childItems();
       
   218     for (int i = 0; i < list.size(); i++) {
       
   219         QGraphicsItem* item = list[i];
       
   220         
       
   221         QGraphicsWidget* widget = NULL;
       
   222         if (item->isWidget()) {
       
   223             widget = (QGraphicsWidget*)item;
       
   224         }
       
   225         if (widget && widget->objectName() == itemName) {
       
   226             return widget;
       
   227         }
       
   228         else if ((item = findChildItem(itemName, item))) {
       
   229             return (QGraphicsWidget*)item;
       
   230         }
       
   231     }
       
   232     return 0;
       
   233 }
       
   234 
       
   235 bool TestWlanWizardContext::verifyStatus(WizardStatusSignal status, int iapId)
       
   236 {
       
   237     return mView->verifyStatus(status, iapId);
       
   238 }
       
   239 
       
   240 bool TestWlanWizardContext::verifyCurrentPage(int pageId, int retries, int wait_ms)
       
   241 {
       
   242     bool ret = true;
       
   243     for (int i = 0; i < retries; i++) {
       
   244         QTest::qWait(wait_ms);
       
   245         WlanWizardPrivate *pPrivate = mView->mWizard->d_ptr;
       
   246         HbWidget* current = qobject_cast<HbWidget*> (pPrivate->mStackedWidget->currentWidget());
       
   247         WlanWizardPage *page = pPrivate->mPageMapper[current];
       
   248         
       
   249         // TODO: verify title in this method
       
   250         
       
   251         if (page == pPrivate->mPages[pageId]) {
       
   252             switch(pageId) {
       
   253             case WlanWizardPageInternal::PageNetworkMode:
       
   254                 return verifyDialogText("dialog_6", hbTrId("txt_occ_dialog_select_network_mode_and_status"));
       
   255             
       
   256             case WlanWizardPageInternal::PageNetworkSecurity:
       
   257                 return verifyDialogText("dialog_6", hbTrId("txt_occ_dialog_select_network_security_mode"));
       
   258             
       
   259             case WlanWizardPageInternal::PageSsid:
       
   260                 return verifyDialogText("dialog", hbTrId("txt_occ_dialog_insert_the_name_of_the_new_wlan_net"));
       
   261             
       
   262             case WlanWizardPageInternal::PageSummary:
       
   263                 if (pPrivate->mTitle->plainText() != hbTrId("txt_occ_title_wlan_setup_wizard_summary")){
       
   264                     qWarning("TestWlanWizardContext::verifyCurrentPage: Invalid title");
       
   265                     return false;
       
   266                 }
       
   267                 return true;
       
   268                
       
   269             case EapWizardPage::PageOuterType:
       
   270                 return verifyDialogText("title", hbTrId("txt_occ_title_select_eap_type"));
       
   271 
       
   272             case EapWizardPage::PageCertificateCa:
       
   273                 return verifyDialogText("title", hbTrId("txt_occ_title_select_authority_certificate"));
       
   274                 
       
   275             case EapWizardPage::PageCertificateUser:
       
   276                 return verifyDialogText("title", hbTrId("txt_occ_title_select_user_certificate"));
       
   277                 
       
   278             case EapWizardPage::PageNewPacStorePassword:
       
   279                 ret &= verifyDialogText("setlabel_55", hbTrId("txt_occ_setlabel_new_pac_store_password"));
       
   280                 ret &= verifyDialogText("setlabel_56", hbTrId("txt_occ_setlabel_confirm_password"));
       
   281                 return ret;
       
   282 
       
   283             case EapWizardPage::PagePromptPacStorePassword:
       
   284                 return verifyDialogText("setlabel_59", hbTrId("txt_occ_setlabel_eap_pac_store_password"));
       
   285 
       
   286             case WpsWizardPage::PageWpsWizardStep2:
       
   287                 return verifyDialogText("label", hbTrId("txt_occ_dialog_selected_network_supports_wifi_pro"));
       
   288                 break;
       
   289 
       
   290             case WpsWizardPage::PageWpsWizardStep3_Button:
       
   291                 return verifyDialogText("label_heading", hbTrId("txt_occ_dialog_first_press_button_on_the_wireless"));
       
   292                 break;
       
   293 
       
   294             case WpsWizardPage::PageWpsWizardStep3_Number:
       
   295                 // TODO: something better here??
       
   296                 return true;
       
   297                 
       
   298             case WpsWizardPage::PageWpsWizardStep4:
       
   299                 return verifyDialogText("label_heading", hbTrId("txt_occ_dialog_negotiating"));
       
   300                 
       
   301             case WpsWizardPage::PageWpsWizardStep5:
       
   302                 return verifyDialogText("label", hbTrId("txt_occ_dialog_settings_received_for_multiple_wlan"));
       
   303                 
       
   304             default:
       
   305                 return false;
       
   306             }
       
   307         }
       
   308     }
       
   309     qWarning("verifyCurrentPage: expected: %d", pageId);
       
   310     return false;
       
   311 }
       
   312 
       
   313 bool TestWlanWizardContext::verifyCurrentPageWithInfo(
       
   314     int pageId, const QString &info, int retries, int wait_ms)
       
   315 {
       
   316     bool ret = true;
       
   317     for (int i = 0; i < retries; i++) {
       
   318         QTest::qWait(wait_ms);
       
   319 
       
   320         WlanWizardPrivate *pPrivate = mView->mWizard->d_ptr;
       
   321         HbWidget* current = qobject_cast<HbWidget*> (pPrivate->mStackedWidget->currentWidget());
       
   322         WlanWizardPage *page = pPrivate->mPageMapper[current];
       
   323 
       
   324         // TODO: verify title in this method
       
   325         
       
   326         if (page == pPrivate->mPages[pageId]) {
       
   327             switch(pageId) {
       
   328             case WlanWizardPageInternal::PageGenericError:
       
   329                 return verifyDialogText("dialog", info);
       
   330 
       
   331             case WlanWizardPageInternal::PageKeyQuery:
       
   332                 return verifyDialogText("dialog", HbParameterLengthLimiter("txt_occ_dialog_enter_key_for_1").arg(info));
       
   333 
       
   334             case WlanWizardPageInternal::PageProcessSettings:
       
   335                 return verifyDialogText("dialog", HbParameterLengthLimiter("txt_occ_dialog_checking_connection_to_1").arg(info));
       
   336 
       
   337             case WlanWizardPageInternal::PageScanning:
       
   338                 return verifyDialogText("dialog", HbParameterLengthLimiter("txt_occ_dialog_searching").arg(info));
       
   339                
       
   340             case EapWizardPage::PageUsernamePassword:
       
   341                 ret &= verifyDialogText(
       
   342                     "setlabel_55",
       
   343                     HbParameterLengthLimiter("txt_occ_setlabel_user_name_for_1").arg(info));
       
   344                 ret &= verifyDialogText("setlabel_56", hbTrId("txt_occ_setlabel_eap_password"));
       
   345                 return ret;
       
   346                 
       
   347             case EapWizardPage::PageIdentity:
       
   348                 ret &= verifyDialogText("setlabel_53", HbParameterLengthLimiter("txt_occ_setlabel_user_name_for_1").arg(info));
       
   349                 ret &= verifyDialogText("setlabel_53_val", hbTrId("txt_occ_setlabel_user_name_val_generate_automatic"));
       
   350                 ret &= verifyDialogText("setlabel_54", hbTrId("txt_occ_setlabel_eap_realm"));
       
   351                 ret &= verifyDialogText("setlabel_54_val", hbTrId("txt_occ_setlabel_eap_realm_val_generate_automatically"));
       
   352                 return ret;
       
   353                 
       
   354             case EapWizardPage::PageInnerTypePeap:
       
   355             case EapWizardPage::PageInnerTypeEapTtls:
       
   356                 return verifyDialogText("title", HbParameterLengthLimiter("txt_occ_title_select_innear_eap_type_for_1").arg(info));
       
   357             
       
   358             default:
       
   359                 return verifyCurrentPage(pageId, retries, wait_ms);
       
   360             }
       
   361         }
       
   362     }
       
   363     qWarning("verifyCurrentPage: expected: %d", pageId);
       
   364     return false;
       
   365 }
       
   366 
       
   367 
       
   368 bool TestWlanWizardContext::verifyDialogText(const QString objName, const QString text)
       
   369 {
       
   370     HbWidget* current = qobject_cast<HbWidget*> (
       
   371         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   372     HbWidget* widget = qobject_cast<HbWidget*> (
       
   373         findChildItem(objName, current));
       
   374     
       
   375     if (widget) {
       
   376         HbLabel *label = qobject_cast<HbLabel*>(widget);
       
   377         if (label) {
       
   378             if(label->plainText() == text) {
       
   379                 if (!label->isVisible()){
       
   380                     qWarning("verifyDialogText: not visible");
       
   381                     return false;
       
   382                 }
       
   383                 return true;
       
   384                 
       
   385             } else {
       
   386                 qWarning("verifyDialogText: not match");
       
   387                 qDebug() << "expect: " << text;
       
   388                 qDebug() << "actual: " << label->plainText();
       
   389                 return false;
       
   390             }
       
   391         }
       
   392         HbCheckBox *checkBox = qobject_cast<HbCheckBox*>(widget);
       
   393         
       
   394         if (checkBox) {
       
   395             if(checkBox->text() == text) {
       
   396                 if (!checkBox->isVisible()){
       
   397                     qWarning("verifyDialogText: not visible");
       
   398                     return false;
       
   399                 }
       
   400                 return true;
       
   401                 
       
   402             } else {
       
   403                 qWarning("verifyDialogText: not match");
       
   404                 qDebug() << "expect: " << text;
       
   405                 qDebug() << "actual: " << checkBox->text();
       
   406                 return false;
       
   407             }
       
   408         }
       
   409     }
       
   410     
       
   411     qWarning("verifyDialogText: object not found");
       
   412     
       
   413     return false;
       
   414 }
       
   415 
       
   416 bool TestWlanWizardContext::verifyActionButtons(ButtonStatus prevStatus,
       
   417     ButtonStatus cancelStatus,
       
   418     ButtonStatus nextStatus,
       
   419     ButtonStatus finishStatus)
       
   420 {
       
   421     WlanWizardPrivate *pPrivate = mView->mWizard->d_ptr;
       
   422     ButtonStatus prevReally = ButtonHidden;
       
   423     ButtonStatus cancelReally = ButtonHidden;
       
   424     ButtonStatus nextReally = ButtonHidden;
       
   425     ButtonStatus finishReally = ButtonHidden;
       
   426 
       
   427     if(pPrivate->mActionPrevious->isVisible()) {
       
   428         if(pPrivate->mActionPrevious->isEnabled()) {
       
   429             prevReally = ButtonEnabled;
       
   430         } else {
       
   431             prevReally = ButtonDisabled;
       
   432         }
       
   433     }
       
   434 
       
   435     if(pPrivate->mActionCancel->isVisible()) {
       
   436         if(pPrivate->mActionCancel->isEnabled()) {
       
   437             cancelReally = ButtonEnabled;
       
   438         } else {
       
   439             cancelReally = ButtonDisabled;
       
   440         }
       
   441     }
       
   442 
       
   443     if(pPrivate->mActionNext->isVisible()) {
       
   444         if(pPrivate->mActionNext->isEnabled()) {
       
   445             nextReally = ButtonEnabled;
       
   446         } else {
       
   447             nextReally = ButtonDisabled;
       
   448         }
       
   449     }
       
   450 
       
   451     if(pPrivate->mActionFinish->isVisible()) {
       
   452         if(pPrivate->mActionFinish->isEnabled()) {
       
   453             finishReally = ButtonEnabled;
       
   454         } else {
       
   455             finishReally = ButtonDisabled;
       
   456         }
       
   457     }
       
   458     bool ret = true;
       
   459     if (prevReally != prevStatus){
       
   460         qWarning("Previous Button: really: %d, status: %d", prevReally, prevStatus);
       
   461         ret = false;
       
   462     }
       
   463     if (cancelReally != cancelStatus){
       
   464         qWarning("Cancel Button: really: %d, status: %d", cancelReally, cancelStatus);
       
   465         ret = false;
       
   466     }
       
   467     if (nextReally != nextStatus){
       
   468         qWarning("Next Button: really: %d, status: %d", nextReally, nextStatus);
       
   469         ret = false;
       
   470     }
       
   471     if (finishReally != finishStatus){
       
   472         qWarning("Finish Button: really: %d, status: %d", finishReally, finishStatus);
       
   473         ret = false;
       
   474     }
       
   475     
       
   476     return ret;
       
   477 }
       
   478 
       
   479 bool TestWlanWizardContext::verifySummaryPage(
       
   480     const QString &ssid, 
       
   481     int netMode, 
       
   482     bool hidden,
       
   483     int secMode, 
       
   484     bool useWpaPsk,
       
   485     const QString &destination, 
       
   486     int outerType,
       
   487     int innerType,
       
   488     bool eapFastProvMode)
       
   489 {
       
   490     bool ret = true;
       
   491     int i = 0;
       
   492     HbListWidget* listWidget = qobject_cast<HbListWidget*> (
       
   493         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   494     
       
   495     if (!listWidget){
       
   496         qWarning("verifySummaryPage: ListWidget not found");
       
   497         return false;
       
   498     }
       
   499     
       
   500     // VERIFY: NETWORK NAME
       
   501     HbListWidgetItem *item = listWidget->item(i++);
       
   502     if (item->text() != hbTrId("txt_occ_dblist_network_name")) {
       
   503         qWarning("verifySummaryPage: no match network name");
       
   504         ret = false;
       
   505     }
       
   506     
       
   507     if (item->secondaryText() != ssid){
       
   508         qWarning("verifySummaryPage: no match ssid");
       
   509         ret = false;
       
   510     }
       
   511     
       
   512     // VERIFY: NETWORK MODE
       
   513     item = listWidget->item(i++);
       
   514     if (item->text() != hbTrId("txt_occ_dblist_network_mode")) {
       
   515         qWarning("verifySummaryPage: no match network mode");
       
   516         ret = false;
       
   517     }
       
   518     QString netModeString(toNetworkModeString(netMode, hidden));
       
   519     if (item->secondaryText() != netModeString){
       
   520         qWarning("verifySummaryPage: no match network mode value");
       
   521         qDebug() << "Actual: " << item->secondaryText();
       
   522         qDebug() << "Expected: " << netModeString;
       
   523         ret = false;
       
   524     }
       
   525     
       
   526     // VERIFY: SECURITY MODE
       
   527     item = listWidget->item(i++);
       
   528     if (item->text() != hbTrId("txt_occ_dblist_security_mode")) {
       
   529         qWarning("verifySummaryPage: no match security mode");
       
   530         ret = false;
       
   531     }
       
   532     
       
   533     if (item->secondaryText() != toSecurityModeString(secMode, useWpaPsk)){
       
   534         qWarning("verifySummaryPage: no match security mode value");
       
   535         ret = false;
       
   536     }
       
   537     
       
   538     // VERIFY: EAP OUTER TYPE
       
   539     if (outerType != -1) {
       
   540         item = listWidget->item(i++);
       
   541         if (item->text() != hbTrId("txt_occ_dblist_outer_eap")) {
       
   542             qWarning("verifySummaryPage: no match eap outer type");
       
   543             ret = false;
       
   544         }
       
   545         if (item->secondaryText() != eapTypeToString(outerType)){
       
   546             qWarning("verifySummaryPage: no match eap outer type value");
       
   547             ret = false;
       
   548         }
       
   549     }
       
   550     
       
   551     // VERIFY: EAP INNER TYPE
       
   552     if (innerType != -1) {
       
   553         item = listWidget->item(i++);
       
   554         if (item->text() != hbTrId("txt_occ_dblist_inner_eap")) {
       
   555             qWarning("verifySummaryPage: no match eap inner type");
       
   556             ret = false;
       
   557         }
       
   558         if (item->secondaryText() != eapTypeToString(innerType)){
       
   559             qWarning("verifySummaryPage: no match eap inner type value");
       
   560             ret = false;
       
   561         }
       
   562     }
       
   563     
       
   564     // VERIFY: EAP FAST PROVISIONING MODE
       
   565     if (eapFastProvMode) {
       
   566         item = listWidget->item(i++);
       
   567         if (item->text() != hbTrId("txt_occ_dblist_provisioning_mode_for_eapfast")) {
       
   568             qWarning("verifySummaryPage: no match eap prov mode");
       
   569             ret = false;
       
   570         }
       
   571         if (item->secondaryText() != hbTrId("txt_occ_dblist_provisioning_mode_for_val_unauthent")){
       
   572             qWarning("verifySummaryPage: no match eap prov mode value");
       
   573             ret = false;
       
   574         }
       
   575     }
       
   576 
       
   577     // VERIFY: DESTINATION
       
   578     if (destination.length() > 0) {
       
   579         item = listWidget->item(i++);
       
   580         if (item->text() != hbTrId("txt_occ_dblist_destination")) {
       
   581             qWarning("verifySummaryPage: no match destination");
       
   582             ret = false;
       
   583         }
       
   584         if (item->secondaryText() != destination){
       
   585             qWarning("verifySummaryPage: no match destination value");
       
   586             ret = false;
       
   587         }
       
   588     }
       
   589 
       
   590     
       
   591     return ret;
       
   592 }
       
   593 
       
   594 bool TestWlanWizardContext::mouseClickObject(const QString objName)
       
   595 {
       
   596     HbWidget* current = qobject_cast<HbWidget*> (
       
   597         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   598     HbWidget* widget = (HbWidget*) findChildItem(objName, current);
       
   599     
       
   600     if (widget) {
       
   601         HbAutoTest::mouseClick(mMainWindow, widget);
       
   602         widget->clearFocus();
       
   603         widget->setFocus();
       
   604         return true;
       
   605     }
       
   606     qWarning("mouseClickObject: object not found");
       
   607     
       
   608     return false;
       
   609 }
       
   610 
       
   611 bool TestWlanWizardContext::insertTextToObject(const QString objName, const QString text)
       
   612 {
       
   613     HbWidget* current = qobject_cast<HbWidget*> (
       
   614         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   615     HbWidget* widget = (HbWidget*) findChildItem(objName, current);
       
   616 
       
   617     if (widget) {
       
   618         for (int i = 0; i < text.size(); i++) {
       
   619             HbAutoTest::keyPress(mMainWindow, text.at(i).toAscii(), 0, 10);
       
   620             QTest::qWait(20);
       
   621         }
       
   622         return true;
       
   623     }
       
   624     qWarning("insertTextToObject: object not found");
       
   625     return false;
       
   626 }
       
   627 
       
   628 bool TestWlanWizardContext::selectRadioButton(const QString objName, int index)
       
   629 {
       
   630     HbWidget* current = qobject_cast<HbWidget*> (
       
   631         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   632     TestRadioButtonList* widget = (TestRadioButtonList*) findChildItem(objName, current);
       
   633 
       
   634     if (widget) {
       
   635         if (widget->items().length() <= index) {
       
   636             qWarning("selectRadioButton: index out of range");
       
   637             return false;
       
   638         }
       
   639         widget->setSelected(index);
       
   640         widget->emitActivated(widget->currentIndex());
       
   641         return true;
       
   642     }
       
   643     qWarning("selectRadioButton: object not found");
       
   644     
       
   645     return false;
       
   646 }
       
   647 
       
   648 bool TestWlanWizardContext::verifyRadioButtonState(
       
   649     const QString objName, 
       
   650     int index, 
       
   651     const QString &text)
       
   652 {
       
   653     HbWidget* current = qobject_cast<HbWidget*> (
       
   654         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   655     
       
   656     HbRadioButtonList* widget = qobject_cast<HbRadioButtonList*>( 
       
   657         findChildItem(objName, current));
       
   658 
       
   659     if (widget) {
       
   660         if (widget->selected() != index) {
       
   661             qWarning("verifyRadioButtonState: invalid index");
       
   662             return false;
       
   663         }
       
   664         
       
   665         if (widget->items().at(index) != text) {
       
   666             qWarning("verifyRadioButtonState: text does not match");
       
   667             return false;
       
   668         }
       
   669         
       
   670         return true;
       
   671     }
       
   672     qWarning("verifyRadioButtonState: object not found");
       
   673     
       
   674     return false;
       
   675 }
       
   676 
       
   677 QStringList TestWlanWizardContext::verifyRadioButtons(const QString objName)
       
   678 {
       
   679     HbWidget* current = qobject_cast<HbWidget*> (
       
   680         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   681 
       
   682     HbRadioButtonList* widget = qobject_cast<HbRadioButtonList*>( 
       
   683         findChildItem(objName, current));
       
   684     
       
   685     QStringList ret;
       
   686 
       
   687     if (widget) {
       
   688         ret = widget->items();
       
   689     }
       
   690     else {
       
   691         qWarning("verifyRadioButtons: object not found");
       
   692     }
       
   693 
       
   694     return ret;
       
   695 }
       
   696 
       
   697 int TestWlanWizardContext::verifySelectedRadioButton(const QString objName)
       
   698 {
       
   699     HbWidget* current = qobject_cast<HbWidget*> (
       
   700         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   701 
       
   702     HbRadioButtonList* widget = qobject_cast<HbRadioButtonList*>( 
       
   703         findChildItem(objName, current));
       
   704 
       
   705     int ret = ListNotFound;
       
   706 
       
   707     if (widget) {
       
   708         ret = widget->selected();
       
   709     }
       
   710     else {
       
   711         qWarning("verifySelectedRadioButton: object not found");
       
   712     }
       
   713 
       
   714     return ret;
       
   715 }
       
   716 
       
   717 bool TestWlanWizardContext::verifyCheckBoxState(const QString &objName, bool checked)
       
   718 {
       
   719     HbWidget* current = qobject_cast<HbWidget*> (
       
   720         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   721     HbCheckBox* widget = qobject_cast<HbCheckBox*>(
       
   722         findChildItem(objName, current));
       
   723 
       
   724     if (widget) {
       
   725         if (widget->isChecked() != checked) {
       
   726             qWarning("Checkbox in wrong state");
       
   727             return false;
       
   728         }
       
   729         return true;
       
   730     } 
       
   731     qWarning("verifyCheckBoxState: object not found");
       
   732     return false;
       
   733 }
       
   734 
       
   735 bool TestWlanWizardContext::selectCheckBoxState(const QString &objName, bool check)
       
   736 {
       
   737     HbWidget* current = qobject_cast<HbWidget*> (
       
   738         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   739     HbCheckBox* widget = qobject_cast<HbCheckBox*>(
       
   740         findChildItem(objName, current));
       
   741 
       
   742     if (widget) {
       
   743         if (check) {
       
   744             widget->setCheckState(Qt::Checked);
       
   745         } else {
       
   746             widget->setCheckState(Qt::Unchecked);
       
   747         }
       
   748         return true;
       
   749         
       
   750     } 
       
   751     qWarning("selectCheckBoxState: object not found");
       
   752     return false; 
       
   753 }
       
   754 
       
   755 bool TestWlanWizardContext::mouseClickNext()
       
   756 {
       
   757     if (mView->mWizard->d_ptr->mActionNext->isEnabled()) {
       
   758         mView->mWizard->d_ptr->mActionNext->activate(QAction::Trigger);
       
   759         return true;
       
   760     }
       
   761     qWarning("Next button not enabled");
       
   762     return false;
       
   763 }
       
   764 
       
   765 bool TestWlanWizardContext::mouseClickPrevious()
       
   766 {
       
   767     if (mView->mWizard->d_ptr->mActionPrevious->isEnabled()) {
       
   768         mView->mWizard->d_ptr->mActionPrevious->activate(QAction::Trigger);
       
   769         return true;
       
   770     }
       
   771     qWarning("mouseClickPrevious: Previous button not enabled");
       
   772     
       
   773     return false;
       
   774 }
       
   775 
       
   776 bool TestWlanWizardContext::mouseClickCancel()
       
   777 {
       
   778     if (mView->mWizard->d_ptr->mActionCancel->isEnabled()) {
       
   779         mView->mWizard->d_ptr->mActionCancel->activate(QAction::Trigger);
       
   780         return true;
       
   781     }
       
   782     qWarning("mouseClickCancel: Cancel button not enabled");
       
   783     
       
   784     return false;
       
   785 }
       
   786 
       
   787 bool TestWlanWizardContext::mouseClickFinish()
       
   788 {
       
   789     if (mView->mWizard->d_ptr->mActionFinish->isEnabled()) {
       
   790         mView->mWizard->d_ptr->mActionFinish->activate(QAction::Trigger);
       
   791         return true;
       
   792     }
       
   793     qWarning("mouseClickFinish: Finish button not enabled");
       
   794     
       
   795     return false;
       
   796 }
       
   797 
       
   798 QString TestWlanWizardContext::toNetworkModeString(int netMode, bool isHidden)
       
   799 {
       
   800     QString ret;
       
   801     switch (netMode) {
       
   802     case CMManagerShim::Adhoc:
       
   803         ret = hbTrId("txt_occ_dblist_network_mode_val_adhoc");
       
   804         break;
       
   805 
       
   806      default:
       
   807          if (isHidden) {
       
   808              ret = hbTrId("txt_occ_dblist_network_mode_val_infrastructure_hi");
       
   809          } else {
       
   810              ret = hbTrId("txt_occ_dblist_network_mode_val_infrastructure_pu");
       
   811          }
       
   812          break;
       
   813      }
       
   814     return ret;
       
   815 } 
       
   816 
       
   817 QString TestWlanWizardContext::toSecurityModeString(int secMode, int useWpaPsk)
       
   818 {
       
   819     QString ret;
       
   820     switch (secMode) {
       
   821     case CMManagerShim::WlanSecMode802_1x:
       
   822         ret = hbTrId("txt_occ_dblist_security_mode_val_8021x");
       
   823         break;
       
   824         
       
   825     case CMManagerShim::WlanSecModeWep:
       
   826         ret = hbTrId("txt_occ_dblist_security_mode_val_wep");
       
   827         break;
       
   828         
       
   829     case CMManagerShim::WlanSecModeWpa:
       
   830         if (useWpaPsk) {
       
   831             ret = hbTrId("txt_occ_dblist_security_mode_val_wpawpa2psk");
       
   832         } else {
       
   833             ret = hbTrId("txt_occ_dblist_security_mode_val_wpawpa2_with_eap");
       
   834         }
       
   835         break;
       
   836         
       
   837     case CMManagerShim::WlanSecModeWpa2:
       
   838         if (useWpaPsk) {
       
   839             ret = hbTrId("txt_occ_dblist_security_mode_val_wpa2_with_passwor");
       
   840         } else {
       
   841             ret = hbTrId("txt_occ_dblist_security_mode_val_wpa2_with_eap");
       
   842         }
       
   843         break;
       
   844         
       
   845     default:
       
   846         Q_ASSERT(secMode == CMManagerShim::WlanSecModeOpen);
       
   847         ret = hbTrId("txt_occ_dblist_security_mode_val_open");
       
   848         break;
       
   849     }
       
   850     return ret;
       
   851 }
       
   852 
       
   853 
       
   854 EapQtConfigInterface *TestWlanWizardContext::getEapQtConfig()
       
   855 {
       
   856     return mView->mWizard->d_ptr->mEapWizard->d_ptr->mEapConfIf.data();
       
   857 }
       
   858 
       
   859 QString TestWlanWizardContext::eapTypeToString(int type)
       
   860 {
       
   861     QCOMPARE(mView->mWizard->d_ptr->mEapWizard != NULL, true);
       
   862     return mView->mWizard->d_ptr->mEapWizard->d_ptr->eapTypeToString(type);
       
   863 }
       
   864 
       
   865 void TestWlanWizardContext::callWlanWizard_startPageOperation()
       
   866 {
       
   867     mView->mWizard->d_ptr->startPageOperation();
       
   868 }
       
   869 
       
   870 
       
   871 void TestWlanWizardContext::setWlanMgmtClientObject(CWlanMgmtClient* object)
       
   872 {
       
   873     // TODO: mWlanMgmtClient = object;
       
   874 }
       
   875 
       
   876 TestView::TestView() : mWizard(NULL)
       
   877 {
       
   878     qDebug("TestView::TestView()");
       
   879 }
       
   880 
       
   881 TestView::~TestView()
       
   882 {
       
   883     qDebug("TestView::~TestView()");
       
   884 }
       
   885 
       
   886 void TestView::createWizard()
       
   887 {
       
   888     qDebug("TestView::createWizard");
       
   889     Q_ASSERT(mWizard == NULL);
       
   890     mWizard = new WlanWizard(mainWindow());
       
   891     bool ok;
       
   892     ok = connect(
       
   893         mWizard, SIGNAL(finished(int, bool)), 
       
   894         this, SLOT(finished(int, bool)), 
       
   895         Qt::QueuedConnection);
       
   896     Q_ASSERT(ok);
       
   897 
       
   898     ok = connect(
       
   899         mWizard, SIGNAL(cancelled()), 
       
   900         this, SLOT(cancelled()),
       
   901         Qt::QueuedConnection);
       
   902     Q_ASSERT(ok);
       
   903     
       
   904     mWizardStatus = WizardStatusSignalNone;
       
   905     mConnectedIapId = -100;
       
   906 }
       
   907 
       
   908 void TestView::showWizard()
       
   909 {
       
   910     qDebug("TestView::showWizard()");
       
   911     Q_ASSERT(mWizard);
       
   912     mWizard->show();
       
   913 }
       
   914 
       
   915 void TestView::deleteWizard()
       
   916 {
       
   917     qDebug("TestView::deleteWizard");
       
   918 
       
   919     Q_ASSERT(mWizard != NULL);
       
   920     QMetaObject::invokeMethod(mWizard, "deleteLater", Qt::QueuedConnection);
       
   921     QTest::qWait(100); 
       
   922     mWizard = NULL; 
       
   923 }
       
   924 
       
   925 void TestView::finished(int iapId, bool connected)
       
   926 {
       
   927     qDebug("TestView::complete(), iap id: %d, connected: %d", iapId, connected);
       
   928     
       
   929     if (mWizardStatus != WizardStatusSignalNone) {
       
   930         qWarning("TestView::finished: multiple signals received");
       
   931         mWizardStatus = WizardStatusSignalUndefined;
       
   932     } else {
       
   933         mWizardStatus = WizardStatusSignalFinished;
       
   934         mConnectedIapId = iapId;
       
   935     }
       
   936 }
       
   937 
       
   938 void TestView::cancelled()
       
   939 {
       
   940     qDebug("TestView::cancelled()");
       
   941     if (mWizardStatus != WizardStatusSignalNone) {
       
   942         qWarning("TestView::cancelled: multiple signals received");
       
   943         mWizardStatus = WizardStatusSignalUndefined;
       
   944     } else {
       
   945         mWizardStatus = WizardStatusSignalCancelled;
       
   946     }
       
   947 }
       
   948 
       
   949 bool TestView::verifyStatus(WizardStatusSignal status, int iapId )
       
   950 {
       
   951     // Since connections to cancelled and finished signals are queued
       
   952     // we need to use qWait() here.
       
   953     QTest::qWait(100);
       
   954     bool ret = true;
       
   955     if (status != mWizardStatus){
       
   956         qWarning("TestView::verifyStatus, status: expected: %d, actual: %d", status, mWizardStatus);
       
   957         ret = false;
       
   958     }
       
   959     if (status == WizardStatusSignalFinished) {
       
   960         if (iapId != mConnectedIapId) {
       
   961             qWarning("TestView::verifyStatus, iapid: expected: %d, actual: %d", iapId, mConnectedIapId);
       
   962             ret = false;
       
   963         }
       
   964     }
       
   965     return ret;
       
   966 }
       
   967 
       
   968