wlanutilities/wlanwizard/t_wlanwizard/ut/testwlanwizardcontext.cpp
changeset 39 7b3e49e4608a
child 49 fb81b597edf1
equal deleted inserted replaced
36:682dd021f9be 39:7b3e49e4608a
       
     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, QGraphicsWidget *widget)
       
   216 {
       
   217     QList<QGraphicsItem*> list = widget->childItems();
       
   218     for (int i = 0; i < list.size(); i++) {
       
   219         QGraphicsWidget* item = (QGraphicsWidget*) list[i];
       
   220         if (item->objectName() == itemName) {
       
   221             return item;
       
   222         }
       
   223         else if ((item = findChildItem(itemName, item))) {
       
   224             return item;
       
   225         }
       
   226     }
       
   227     return 0;
       
   228 }
       
   229 
       
   230 bool TestWlanWizardContext::verifyStatus(WizardStatusSignal status, int iapId)
       
   231 {
       
   232     return mView->verifyStatus(status, iapId);
       
   233 }
       
   234 
       
   235 bool TestWlanWizardContext::verifyCurrentPage(int pageId, int retries, int wait_ms)
       
   236 {
       
   237     bool ret = true;
       
   238     
       
   239     for (int i = 0; i < retries; i++) {
       
   240         QTest::qWait(wait_ms);
       
   241 
       
   242         WlanWizardPrivate *pPrivate = mView->mWizard->d_ptr;
       
   243         HbWidget* current = qobject_cast<HbWidget*> (pPrivate->mStackedWidget->currentWidget());
       
   244         WlanWizardPage *page = pPrivate->mPageMapper[current];
       
   245 
       
   246         // TODO: verify title in this method
       
   247         
       
   248         if (page == pPrivate->mPages[pageId]) {
       
   249             switch(pageId) {
       
   250             case WlanWizardPageInternal::PageNetworkMode:
       
   251                 return verifyDialogText("dialog_6", hbTrId("txt_occ_dialog_select_network_mode_and_status"));
       
   252             
       
   253             case WlanWizardPageInternal::PageNetworkSecurity:
       
   254                 return verifyDialogText("dialog_6", hbTrId("txt_occ_dialog_select_network_security_mode"));
       
   255             
       
   256             case WlanWizardPageInternal::PageSsid:
       
   257                 return verifyDialogText("dialog", hbTrId("txt_occ_dialog_insert_the_name_of_the_new_wlan_net"));
       
   258             
       
   259             case WlanWizardPageInternal::PageSummary:
       
   260                 if (pPrivate->mTitle->plainText() != hbTrId("txt_occ_title_wlan_setup_wizard_summary")){
       
   261                     qWarning("TestWlanWizardContext::verifyCurrentPage: Invalid title");
       
   262                     return false;
       
   263                 }
       
   264                 return true;
       
   265                
       
   266             case EapWizardPage::PageOuterType:
       
   267                 return verifyDialogText("title", hbTrId("txt_occ_title_select_eap_type"));
       
   268 
       
   269             case EapWizardPage::PageCertificateCa:
       
   270                 return verifyDialogText("title", hbTrId("txt_occ_title_select_authority_certificate"));
       
   271                 
       
   272             case EapWizardPage::PageCertificateUser:
       
   273                 return verifyDialogText("title", hbTrId("txt_occ_title_select_user_certificate"));
       
   274                 
       
   275             case EapWizardPage::PageNewPacStorePassword:
       
   276                 ret &= verifyDialogText("setlabel_55", hbTrId("txt_occ_setlabel_new_pac_store_password"));
       
   277                 ret &= verifyDialogText("setlabel_56", hbTrId("txt_occ_setlabel_confirm_password"));
       
   278                 return ret;
       
   279 
       
   280             case EapWizardPage::PagePromptPacStorePassword:
       
   281                 return verifyDialogText("setlabel_59", hbTrId("txt_occ_setlabel_eap_pac_store_password"));
       
   282 
       
   283             case WpsWizardPage::PageWpsWizardStep2:
       
   284                 return verifyDialogText("label", hbTrId("txt_occ_dialog_selected_network_supports_wifi_pro"));
       
   285                 break;
       
   286 
       
   287             case WpsWizardPage::PageWpsWizardStep3_Button:
       
   288                 return verifyDialogText("label_heading", hbTrId("txt_occ_dialog_first_press_button_on_the_wireless"));
       
   289                 break;
       
   290 
       
   291             case WpsWizardPage::PageWpsWizardStep3_Number:
       
   292                 // TODO: something better here??
       
   293                 return true;
       
   294                 
       
   295             case WpsWizardPage::PageWpsWizardStep4:
       
   296                 return verifyDialogText("label_heading", hbTrId("txt_occ_dialog_negotiating"));
       
   297                 
       
   298             case WpsWizardPage::PageWpsWizardStep5:
       
   299                 return verifyDialogText("label", hbTrId("txt_occ_dialog_settings_received_for_multiple_wlan"));
       
   300                 
       
   301             default:
       
   302                 return false;
       
   303             }
       
   304         }
       
   305     }
       
   306     qWarning("verifyCurrentPage: expected: %d", pageId);
       
   307     return false;
       
   308 }
       
   309 
       
   310 bool TestWlanWizardContext::verifyCurrentPageWithInfo(
       
   311     int pageId, const QString &info, int retries, int wait_ms)
       
   312 {
       
   313     bool ret = true;
       
   314     for (int i = 0; i < retries; i++) {
       
   315         QTest::qWait(wait_ms);
       
   316 
       
   317         WlanWizardPrivate *pPrivate = mView->mWizard->d_ptr;
       
   318         HbWidget* current = qobject_cast<HbWidget*> (pPrivate->mStackedWidget->currentWidget());
       
   319         WlanWizardPage *page = pPrivate->mPageMapper[current];
       
   320 
       
   321         // TODO: verify title in this method
       
   322         
       
   323         if (page == pPrivate->mPages[pageId]) {
       
   324             switch(pageId) {
       
   325             case WlanWizardPageInternal::PageGenericError:
       
   326                 return verifyDialogText("dialog", info);
       
   327 
       
   328             case WlanWizardPageInternal::PageKeyQuery:
       
   329                 return verifyDialogText("dialog", HbParameterLengthLimiter(hbTrId("txt_occ_dialog_enter_key_for_1")).arg(info));
       
   330 
       
   331             case WlanWizardPageInternal::PageProcessSettings:
       
   332                 return verifyDialogText("dialog", HbParameterLengthLimiter(hbTrId("txt_occ_dialog_checking_connection_to_1")).arg(info));
       
   333 
       
   334             case WlanWizardPageInternal::PageScanning:
       
   335                 return verifyDialogText("dialog", HbParameterLengthLimiter(hbTrId("txt_occ_dialog_searching")).arg(info));
       
   336                
       
   337             case EapWizardPage::PageUsernamePassword:
       
   338                 ret &= verifyDialogText(
       
   339                     "setlabel_55",
       
   340                     HbParameterLengthLimiter(hbTrId("txt_occ_setlabel_user_name_for_1")).arg(info));
       
   341                 ret &= verifyDialogText("setlabel_56", hbTrId("txt_occ_setlabel_eap_password"));
       
   342                 return ret;
       
   343                 
       
   344             case EapWizardPage::PageIdentity:
       
   345                 ret &= verifyDialogText("setlabel_53", HbParameterLengthLimiter(hbTrId("txt_occ_setlabel_user_name_for_1")).arg(info));
       
   346                 ret &= verifyDialogText("setlabel_53_val", hbTrId("txt_occ_setlabel_user_name_val_generate_automatic"));
       
   347                 ret &= verifyDialogText("setlabel_54", hbTrId("txt_occ_setlabel_eap_realm"));
       
   348                 ret &= verifyDialogText("setlabel_54_val", hbTrId("txt_occ_setlabel_eap_realm_val_generate_automatically"));
       
   349                 return ret;
       
   350                 
       
   351             case EapWizardPage::PageInnerTypePeap:
       
   352             case EapWizardPage::PageInnerTypeEapTtls:
       
   353                 return verifyDialogText("title", HbParameterLengthLimiter(hbTrId("txt_occ_title_select_innear_eap_type_for_1")).arg(info));
       
   354             
       
   355             default:
       
   356                 return verifyCurrentPage(pageId, retries, wait_ms);
       
   357             }
       
   358         }
       
   359     }
       
   360     qWarning("verifyCurrentPage: expected: %d", pageId);
       
   361     return false;
       
   362 }
       
   363 
       
   364 
       
   365 bool TestWlanWizardContext::verifyDialogText(const QString objName, const QString text)
       
   366 {
       
   367     HbWidget* current = qobject_cast<HbWidget*> (
       
   368         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   369     HbWidget* widget = qobject_cast<HbWidget*> (
       
   370         findChildItem(objName, current));
       
   371     
       
   372     if (widget) {
       
   373         HbLabel *label = qobject_cast<HbLabel*>(widget);
       
   374         if (label) {
       
   375             if(label->plainText() == text) {
       
   376                 if (!label->isVisible()){
       
   377                     qWarning("verifyDialogText: not visible");
       
   378                     return false;
       
   379                 }
       
   380                 return true;
       
   381                 
       
   382             } else {
       
   383                 qWarning("verifyDialogText: not match");
       
   384                 qDebug() << "expect: " << text;
       
   385                 qDebug() << "actual: " << label->plainText();
       
   386                 return false;
       
   387             }
       
   388         }
       
   389         HbCheckBox *checkBox = qobject_cast<HbCheckBox*>(widget);
       
   390         if (checkBox) {
       
   391             if(checkBox->text() == text) {
       
   392                 if (!checkBox->isVisible()){
       
   393                     qWarning("verifyDialogText: not visible");
       
   394                     return false;
       
   395                 }
       
   396                 return true;
       
   397                 
       
   398             } else {
       
   399                 qWarning("verifyDialogText: not match");
       
   400                 qDebug() << "expect: " << text;
       
   401                 qDebug() << "actual: " << checkBox->text();
       
   402                 return false;
       
   403             }
       
   404         }
       
   405     }
       
   406     
       
   407     qWarning("verifyDialogText: object not found");
       
   408     
       
   409     return false;
       
   410 }
       
   411 
       
   412 bool TestWlanWizardContext::verifyActionButtons(ButtonStatus prevStatus,
       
   413     ButtonStatus cancelStatus,
       
   414     ButtonStatus nextStatus,
       
   415     ButtonStatus finishStatus)
       
   416 {
       
   417     WlanWizardPrivate *pPrivate = mView->mWizard->d_ptr;
       
   418     ButtonStatus prevReally = ButtonHidden;
       
   419     ButtonStatus cancelReally = ButtonHidden;
       
   420     ButtonStatus nextReally = ButtonHidden;
       
   421     ButtonStatus finishReally = ButtonHidden;
       
   422 
       
   423     if(pPrivate->mActionPrevious->isVisible()) {
       
   424         if(pPrivate->mActionPrevious->isEnabled()) {
       
   425             prevReally = ButtonEnabled;
       
   426         } else {
       
   427             prevReally = ButtonDisabled;
       
   428         }
       
   429     }
       
   430 
       
   431     if(pPrivate->mActionCancel->isVisible()) {
       
   432         if(pPrivate->mActionCancel->isEnabled()) {
       
   433             cancelReally = ButtonEnabled;
       
   434         } else {
       
   435             cancelReally = ButtonDisabled;
       
   436         }
       
   437     }
       
   438 
       
   439     if(pPrivate->mActionNext->isVisible()) {
       
   440         if(pPrivate->mActionNext->isEnabled()) {
       
   441             nextReally = ButtonEnabled;
       
   442         } else {
       
   443             nextReally = ButtonDisabled;
       
   444         }
       
   445     }
       
   446 
       
   447     if(pPrivate->mActionFinish->isVisible()) {
       
   448         if(pPrivate->mActionFinish->isEnabled()) {
       
   449             finishReally = ButtonEnabled;
       
   450         } else {
       
   451             finishReally = ButtonDisabled;
       
   452         }
       
   453     }
       
   454     bool ret = true;
       
   455     if (prevReally != prevStatus){
       
   456         qWarning("Previous Button: really: %d, status: %d", prevReally, prevStatus);
       
   457         ret = false;
       
   458     }
       
   459     if (cancelReally != cancelStatus){
       
   460         qWarning("Cancel Button: really: %d, status: %d", cancelReally, cancelStatus);
       
   461         ret = false;
       
   462     }
       
   463     if (nextReally != nextStatus){
       
   464         qWarning("Next Button: really: %d, status: %d", nextReally, nextStatus);
       
   465         ret = false;
       
   466     }
       
   467     if (finishReally != finishStatus){
       
   468         qWarning("Finish Button: really: %d, status: %d", finishReally, finishStatus);
       
   469         ret = false;
       
   470     }
       
   471     
       
   472     return ret;
       
   473 }
       
   474 
       
   475 bool TestWlanWizardContext::verifySummaryPage(
       
   476     const QString &ssid, 
       
   477     int netMode, 
       
   478     bool hidden,
       
   479     int secMode, 
       
   480     bool useWpaPsk,
       
   481     const QString &destination, 
       
   482     int outerType,
       
   483     int innerType,
       
   484     bool eapFastProvMode)
       
   485 {
       
   486     bool ret = true;
       
   487     int i = 0;
       
   488     HbListWidget* listWidget = qobject_cast<HbListWidget*> (
       
   489         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   490     
       
   491     if (!listWidget){
       
   492         qWarning("verifySummaryPage: ListWidget not found");
       
   493         return false;
       
   494     }
       
   495     
       
   496     // VERIFY: NETWORK NAME
       
   497     HbListWidgetItem *item = listWidget->item(i++);
       
   498     if (item->text() != hbTrId("txt_occ_dblist_network_name")) {
       
   499         qWarning("verifySummaryPage: no match network name");
       
   500         ret = false;
       
   501     }
       
   502     
       
   503     if (item->secondaryText() != ssid){
       
   504         qWarning("verifySummaryPage: no match ssid");
       
   505         ret = false;
       
   506     }
       
   507     
       
   508     // VERIFY: NETWORK MODE
       
   509     item = listWidget->item(i++);
       
   510     if (item->text() != hbTrId("txt_occ_dblist_network_mode")) {
       
   511         qWarning("verifySummaryPage: no match network mode");
       
   512         ret = false;
       
   513     }
       
   514     
       
   515     if (item->secondaryText() != toNetworkModeString(netMode, hidden)){
       
   516         qWarning("verifySummaryPage: no match network mode value");
       
   517         ret = false;
       
   518     }
       
   519     
       
   520     // VERIFY: SECURITY MODE
       
   521     item = listWidget->item(i++);
       
   522     if (item->text() != hbTrId("txt_occ_dblist_security_mode")) {
       
   523         qWarning("verifySummaryPage: no match security mode");
       
   524         ret = false;
       
   525     }
       
   526     
       
   527     if (item->secondaryText() != toSecurityModeString(secMode, useWpaPsk)){
       
   528         qWarning("verifySummaryPage: no match security mode value");
       
   529         ret = false;
       
   530     }
       
   531     
       
   532     // VERIFY: EAP OUTER TYPE
       
   533     if (outerType != -1) {
       
   534         item = listWidget->item(i++);
       
   535         if (item->text() != hbTrId("txt_occ_dblist_outer_eap")) {
       
   536             qWarning("verifySummaryPage: no match eap outer type");
       
   537             ret = false;
       
   538         }
       
   539         if (item->secondaryText() != eapTypeToString(outerType)){
       
   540             qWarning("verifySummaryPage: no match eap outer type value");
       
   541             ret = false;
       
   542         }
       
   543     }
       
   544     
       
   545     // VERIFY: EAP INNER TYPE
       
   546     if (innerType != -1) {
       
   547         item = listWidget->item(i++);
       
   548         if (item->text() != hbTrId("txt_occ_dblist_inner_eap")) {
       
   549             qWarning("verifySummaryPage: no match eap inner type");
       
   550             ret = false;
       
   551         }
       
   552         if (item->secondaryText() != eapTypeToString(innerType)){
       
   553             qWarning("verifySummaryPage: no match eap inner type value");
       
   554             ret = false;
       
   555         }
       
   556     }
       
   557     
       
   558     // VERIFY: EAP FAST PROVISIONING MODE
       
   559     if (eapFastProvMode) {
       
   560         item = listWidget->item(i++);
       
   561         if (item->text() != hbTrId("txt_occ_dblist_provisioning_mode_for_eapfast")) {
       
   562             qWarning("verifySummaryPage: no match eap prov mode");
       
   563             ret = false;
       
   564         }
       
   565         if (item->secondaryText() != hbTrId("txt_occ_dblist_provisioning_mode_for_val_unauthent")){
       
   566             qWarning("verifySummaryPage: no match eap prov mode value");
       
   567             ret = false;
       
   568         }
       
   569     }
       
   570 
       
   571     // VERIFY: DESTINATION
       
   572     if (destination.length() > 0) {
       
   573         item = listWidget->item(i++);
       
   574         if (item->text() != hbTrId("txt_occ_dblist_destination")) {
       
   575             qWarning("verifySummaryPage: no match destination");
       
   576             ret = false;
       
   577         }
       
   578         if (item->secondaryText() != destination){
       
   579             qWarning("verifySummaryPage: no match destination value");
       
   580             ret = false;
       
   581         }
       
   582     }
       
   583 
       
   584     
       
   585     return ret;
       
   586 }
       
   587 
       
   588 bool TestWlanWizardContext::mouseClickObject(const QString objName)
       
   589 {
       
   590     HbWidget* current = qobject_cast<HbWidget*> (
       
   591         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   592     HbWidget* widget = (HbWidget*) findChildItem(objName, current);
       
   593     
       
   594     if (widget) {
       
   595         HbAutoTest::mouseClick(mMainWindow, widget);
       
   596         widget->clearFocus();
       
   597         widget->setFocus();
       
   598         return true;
       
   599     }
       
   600     qWarning("mouseClickObject: object not found");
       
   601     
       
   602     return false;
       
   603 }
       
   604 
       
   605 bool TestWlanWizardContext::insertTextToObject(const QString objName, const QString text)
       
   606 {
       
   607     HbWidget* current = qobject_cast<HbWidget*> (
       
   608         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   609     HbWidget* widget = (HbWidget*) findChildItem(objName, current);
       
   610 
       
   611     if (widget) {
       
   612         for (int i = 0; i < text.size(); i++) {
       
   613             HbAutoTest::keyPress(mMainWindow, text.at(i).toAscii(), 0, 10);
       
   614             QTest::qWait(20);
       
   615         }
       
   616         return true;
       
   617     }
       
   618     qWarning("insertTextToObject: object not found");
       
   619     return false;
       
   620 }
       
   621 
       
   622 bool TestWlanWizardContext::selectRadioButton(const QString objName, int index)
       
   623 {
       
   624     HbWidget* current = qobject_cast<HbWidget*> (
       
   625         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   626     TestRadioButtonList* widget = (TestRadioButtonList*) findChildItem(objName, current);
       
   627 
       
   628     if (widget) {
       
   629         if (widget->items().length() <= index) {
       
   630             qWarning("selectRadioButton: index out of range");
       
   631             return false;
       
   632         }
       
   633         widget->setSelected(index);
       
   634         widget->emitActivated(widget->currentIndex());
       
   635         return true;
       
   636     }
       
   637     qWarning("selectRadioButton: object not found");
       
   638     
       
   639     return false;
       
   640 }
       
   641 
       
   642 bool TestWlanWizardContext::verifyRadioButtonState(
       
   643     const QString objName, 
       
   644     int index, 
       
   645     const QString &text)
       
   646 {
       
   647     HbWidget* current = qobject_cast<HbWidget*> (
       
   648         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   649     
       
   650     HbRadioButtonList* widget = qobject_cast<HbRadioButtonList*>( 
       
   651         findChildItem(objName, current));
       
   652 
       
   653     if (widget) {
       
   654         if (widget->selected() != index) {
       
   655             qWarning("verifyRadioButtonState: invalid index");
       
   656             return false;
       
   657         }
       
   658         
       
   659         if (widget->items().at(index) != text) {
       
   660             qWarning("verifyRadioButtonState: text does not match");
       
   661             return false;
       
   662         }
       
   663         
       
   664         return true;
       
   665     }
       
   666     qWarning("verifyRadioButtonState: object not found");
       
   667     
       
   668     return false;
       
   669 }
       
   670 
       
   671 QStringList TestWlanWizardContext::verifyRadioButtons(const QString objName)
       
   672 {
       
   673     HbWidget* current = qobject_cast<HbWidget*> (
       
   674         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   675 
       
   676     HbRadioButtonList* widget = qobject_cast<HbRadioButtonList*>( 
       
   677         findChildItem(objName, current));
       
   678     
       
   679     QStringList ret;
       
   680 
       
   681     if (widget) {
       
   682         ret = widget->items();
       
   683     }
       
   684     else {
       
   685         qWarning("verifyRadioButtons: object not found");
       
   686     }
       
   687 
       
   688     return ret;
       
   689 }
       
   690 
       
   691 int TestWlanWizardContext::verifySelectedRadioButton(const QString objName)
       
   692 {
       
   693     HbWidget* current = qobject_cast<HbWidget*> (
       
   694         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   695 
       
   696     HbRadioButtonList* widget = qobject_cast<HbRadioButtonList*>( 
       
   697         findChildItem(objName, current));
       
   698 
       
   699     int ret = ListNotFound;
       
   700 
       
   701     if (widget) {
       
   702         ret = widget->selected();
       
   703     }
       
   704     else {
       
   705         qWarning("verifySelectedRadioButton: object not found");
       
   706     }
       
   707 
       
   708     return ret;
       
   709 }
       
   710 
       
   711 bool TestWlanWizardContext::verifyCheckBoxState(const QString &objName, bool checked)
       
   712 {
       
   713     HbWidget* current = qobject_cast<HbWidget*> (
       
   714         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   715     HbCheckBox* widget = qobject_cast<HbCheckBox*>(
       
   716         findChildItem(objName, current));
       
   717 
       
   718     if (widget) {
       
   719         if (widget->isChecked() != checked) {
       
   720             qWarning("Checkbox in wrong state");
       
   721             return false;
       
   722         }
       
   723         return true;
       
   724     } 
       
   725     qWarning("verifyCheckBoxState: object not found");
       
   726     return false;
       
   727 }
       
   728 
       
   729 bool TestWlanWizardContext::selectCheckBoxState(const QString &objName, bool check)
       
   730 {
       
   731     HbWidget* current = qobject_cast<HbWidget*> (
       
   732         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
   733     HbCheckBox* widget = qobject_cast<HbCheckBox*>(
       
   734         findChildItem(objName, current));
       
   735 
       
   736     if (widget) {
       
   737         if (check) {
       
   738             widget->setCheckState(Qt::Checked);
       
   739         } else {
       
   740             widget->setCheckState(Qt::Unchecked);
       
   741         }
       
   742         return true;
       
   743         
       
   744     } 
       
   745     qWarning("selectCheckBoxState: object not found");
       
   746     return false; 
       
   747 }
       
   748 
       
   749 bool TestWlanWizardContext::mouseClickNext()
       
   750 {
       
   751     if (mView->mWizard->d_ptr->mActionNext->isEnabled()) {
       
   752         mView->mWizard->d_ptr->mActionNext->activate(QAction::Trigger);
       
   753         return true;
       
   754     }
       
   755     qWarning("Next button not enabled");
       
   756     return false;
       
   757 }
       
   758 
       
   759 bool TestWlanWizardContext::mouseClickPrevious()
       
   760 {
       
   761     if (mView->mWizard->d_ptr->mActionPrevious->isEnabled()) {
       
   762         mView->mWizard->d_ptr->mActionPrevious->activate(QAction::Trigger);
       
   763         return true;
       
   764     }
       
   765     qWarning("mouseClickPrevious: Previous button not enabled");
       
   766     
       
   767     return false;
       
   768 }
       
   769 
       
   770 bool TestWlanWizardContext::mouseClickCancel()
       
   771 {
       
   772     if (mView->mWizard->d_ptr->mActionCancel->isEnabled()) {
       
   773         mView->mWizard->d_ptr->mActionCancel->activate(QAction::Trigger);
       
   774         return true;
       
   775     }
       
   776     qWarning("mouseClickCancel: Cancel button not enabled");
       
   777     
       
   778     return false;
       
   779 }
       
   780 
       
   781 bool TestWlanWizardContext::mouseClickFinish()
       
   782 {
       
   783     if (mView->mWizard->d_ptr->mActionFinish->isEnabled()) {
       
   784         mView->mWizard->d_ptr->mActionFinish->activate(QAction::Trigger);
       
   785         return true;
       
   786     }
       
   787     qWarning("mouseClickFinish: Finish button not enabled");
       
   788     
       
   789     return false;
       
   790 }
       
   791 
       
   792 QString TestWlanWizardContext::toNetworkModeString(int netMode, bool isHidden)
       
   793 {
       
   794     QString ret;
       
   795     switch (netMode) {
       
   796     case CMManagerShim::Adhoc:
       
   797         ret = hbTrId("txt_occ_dblist_network_mode_val_adhoc");
       
   798         break;
       
   799 
       
   800      default:
       
   801          if (isHidden) {
       
   802              ret = hbTrId("txt_occ_dblist_network_mode_val_infrastructure_hi");
       
   803          } else {
       
   804              ret = hbTrId("txt_occ_dblist_network_mode_val_infrastructure_pu");
       
   805          }
       
   806          break;
       
   807      }
       
   808     return ret;
       
   809 } 
       
   810 
       
   811 QString TestWlanWizardContext::toSecurityModeString(int secMode, int useWpaPsk)
       
   812 {
       
   813     QString ret;
       
   814     switch (secMode) {
       
   815     case CMManagerShim::WlanSecMode802_1x:
       
   816         ret = hbTrId("txt_occ_dblist_security_mode_val_8021x");
       
   817         break;
       
   818         
       
   819     case CMManagerShim::WlanSecModeWep:
       
   820         ret = hbTrId("txt_occ_dblist_security_mode_val_wep");
       
   821         break;
       
   822         
       
   823     case CMManagerShim::WlanSecModeWpa:
       
   824         if (useWpaPsk) {
       
   825             ret = hbTrId("txt_occ_dblist_security_mode_val_wpawpa2psk");
       
   826         } else {
       
   827             ret = hbTrId("txt_occ_dblist_security_mode_val_wpawpa2_with_eap");
       
   828         }
       
   829         break;
       
   830         
       
   831     case CMManagerShim::WlanSecModeWpa2:
       
   832         if (useWpaPsk) {
       
   833             ret = hbTrId("txt_occ_dblist_security_mode_val_wpa2_with_passwor");
       
   834         } else {
       
   835             ret = hbTrId("txt_occ_dblist_security_mode_val_wpa2_with_eap");
       
   836         }
       
   837         break;
       
   838         
       
   839     default:
       
   840         Q_ASSERT(secMode == CMManagerShim::WlanSecModeOpen);
       
   841         ret = hbTrId("txt_occ_dblist_security_mode_val_open");
       
   842         break;
       
   843     }
       
   844     return ret;
       
   845 }
       
   846 
       
   847 
       
   848 EapQtConfigInterface *TestWlanWizardContext::getEapQtConfig()
       
   849 {
       
   850     return mView->mWizard->d_ptr->mEapWizard->d_ptr->mEapConfIf.data();
       
   851 }
       
   852 
       
   853 QString TestWlanWizardContext::eapTypeToString(int type)
       
   854 {
       
   855     QCOMPARE(mView->mWizard->d_ptr->mEapWizard != NULL, true);
       
   856     return mView->mWizard->d_ptr->mEapWizard->d_ptr->eapTypeToString(type);
       
   857 }
       
   858 
       
   859 void TestWlanWizardContext::callWlanWizard_startPageOperation()
       
   860 {
       
   861     mView->mWizard->d_ptr->startPageOperation();
       
   862 }
       
   863 
       
   864 
       
   865 void TestWlanWizardContext::setWlanMgmtClientObject(CWlanMgmtClient* object)
       
   866 {
       
   867     // TODO: mWlanMgmtClient = object;
       
   868 }
       
   869 
       
   870 TestView::TestView() : mWizard(NULL)
       
   871 {
       
   872     qDebug("TestView::TestView()");
       
   873 }
       
   874 
       
   875 TestView::~TestView()
       
   876 {
       
   877     qDebug("TestView::~TestView()");
       
   878 }
       
   879 
       
   880 void TestView::createWizard()
       
   881 {
       
   882     qDebug("TestView::createWizard");
       
   883     Q_ASSERT(mWizard == NULL);
       
   884     mWizard = new WlanWizard(mainWindow());
       
   885     bool ok;
       
   886     ok = connect(
       
   887         mWizard, SIGNAL(finished(int, bool)), 
       
   888         this, SLOT(finished(int, bool)), 
       
   889         Qt::QueuedConnection);
       
   890     Q_ASSERT(ok);
       
   891 
       
   892     ok = connect(
       
   893         mWizard, SIGNAL(cancelled()), 
       
   894         this, SLOT(cancelled()),
       
   895         Qt::QueuedConnection);
       
   896     Q_ASSERT(ok);
       
   897     
       
   898     mWizardStatus = WizardStatusSignalNone;
       
   899     mConnectedIapId = -100;
       
   900 }
       
   901 
       
   902 void TestView::showWizard()
       
   903 {
       
   904     qDebug("TestView::showWizard()");
       
   905     Q_ASSERT(mWizard);
       
   906     mWizard->show();
       
   907 }
       
   908 
       
   909 void TestView::deleteWizard()
       
   910 {
       
   911     qDebug("TestView::deleteWizard");
       
   912 
       
   913     Q_ASSERT(mWizard != NULL);
       
   914     QMetaObject::invokeMethod(mWizard, "deleteLater", Qt::QueuedConnection);
       
   915     QTest::qWait(100); 
       
   916     mWizard = NULL; 
       
   917 }
       
   918 
       
   919 void TestView::finished(int iapId, bool connected)
       
   920 {
       
   921     qDebug("TestView::complete(), iap id: %d, connected: %d", iapId, connected);
       
   922     
       
   923     if (mWizardStatus != WizardStatusSignalNone) {
       
   924         qWarning("TestView::finished: multiple signals received");
       
   925         mWizardStatus = WizardStatusSignalUndefined;
       
   926     } else {
       
   927         mWizardStatus = WizardStatusSignalFinished;
       
   928         mConnectedIapId = iapId;
       
   929     }
       
   930 }
       
   931 
       
   932 void TestView::cancelled()
       
   933 {
       
   934     qDebug("TestView::cancelled()");
       
   935     if (mWizardStatus != WizardStatusSignalNone) {
       
   936         qWarning("TestView::cancelled: multiple signals received");
       
   937         mWizardStatus = WizardStatusSignalUndefined;
       
   938     } else {
       
   939         mWizardStatus = WizardStatusSignalCancelled;
       
   940     }
       
   941 }
       
   942 
       
   943 bool TestView::verifyStatus(WizardStatusSignal status, int iapId )
       
   944 {
       
   945     // Since connections to cancelled and finished signals are queued
       
   946     // we need to use qWait() here.
       
   947     QTest::qWait(100);
       
   948     bool ret = true;
       
   949     if (status != mWizardStatus){
       
   950         qWarning("TestView::verifyStatus, status: expected: %d, actual: %d", status, mWizardStatus);
       
   951         ret = false;
       
   952     }
       
   953     if (status == WizardStatusSignalFinished) {
       
   954         if (iapId != mConnectedIapId) {
       
   955             qWarning("TestView::verifyStatus, iapid: expected: %d, actual: %d", iapId, mConnectedIapId);
       
   956             ret = false;
       
   957         }
       
   958     }
       
   959     return ret;
       
   960 }
       
   961 
       
   962