wlanutilities/wlanwizard/t_wlanwizard/ut/testwlanwizardui.cpp
changeset 46 2fbd1d709fe7
parent 45 d9ec2b8c6bad
child 47 b3d8f88532b7
child 50 d4198dcb9983
equal deleted inserted replaced
45:d9ec2b8c6bad 46:2fbd1d709fe7
     1 /*
       
     2  * Copyright (c) 2009 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 <QGraphicsWidget>
       
    26 #include <QObjectList>
       
    27 #include <QtCore>
       
    28 #include <QTest>
       
    29 #include <QDebug>
       
    30 #include <QList>
       
    31 #include <cmmanagerdefines_shim.h>
       
    32 
       
    33 // User includes
       
    34 #include "testwlanwizardui.h"
       
    35 #include "testwlanwizardui_conf.h"
       
    36 #include "hbautotest.h"
       
    37 #include "wlanwizard.h"
       
    38 #include "wlanwizard_p.h"
       
    39 #include "wlanwizardpagessid.h"
       
    40 #include "context_wlanqtutils.h"
       
    41 #include "wlanqtutils.h"
       
    42 #include "wlanqtutilsap.h"
       
    43 
       
    44 // External function prototypes
       
    45 
       
    46 // Local constants
       
    47 
       
    48 class TestRadioButtonList: public HbRadioButtonList
       
    49 {
       
    50 public:
       
    51     void emitActivated(const QModelIndex &modelIndex)
       
    52     { HbRadioButtonList::emitActivated(modelIndex); }
       
    53 };
       
    54 
       
    55 // ======== LOCAL FUNCTIONS ========
       
    56 
       
    57 // ======== MEMBER FUNCTIONS ========
       
    58 
       
    59 // ---------------------------------------------------------
       
    60 // FRAMEWORK FUNCTIONS
       
    61 // ---------------------------------------------------------
       
    62 
       
    63 ContextWlanApList::ContextWlanApList()
       
    64 {
       
    65 
       
    66 }
       
    67 
       
    68 ContextWlanApList::~ContextWlanApList()
       
    69 {
       
    70     clear();
       
    71 }
       
    72 
       
    73 void ContextWlanApList::Add(QString name, int netMode, int secMode, bool wpaPskInUse,
       
    74     bool wpsSupported, int signalStrength)
       
    75 {
       
    76     QSharedPointer<WlanQtUtilsAp> temp = QSharedPointer<WlanQtUtilsAp>(new WlanQtUtilsAp());
       
    77     temp->setValue(WlanQtUtilsAp::ConfIdSsid, name);
       
    78     temp->setValue(WlanQtUtilsAp::ConfIdConnectionMode, netMode);
       
    79     temp->setValue(WlanQtUtilsAp::ConfIdSecurityMode, secMode);
       
    80     temp->setValue(WlanQtUtilsAp::ConfIdWpaPskUse, wpaPskInUse);
       
    81     temp->setValue(WlanQtUtilsAp::ConfIdWpsSupported, wpsSupported);
       
    82     temp->setValue(WlanQtUtilsAp::ConfIdSignalStrength, signalStrength);
       
    83 
       
    84     mList.append(temp);
       
    85 }
       
    86 
       
    87 void ContextWlanApList::clear()
       
    88 {
       
    89     mList.clear();
       
    90 }
       
    91 
       
    92 /**
       
    93  * This function will be called before the first test function is executed.
       
    94  */
       
    95 void TestWlanWizardUi::initTestCase()
       
    96 {
       
    97     qDebug("TestWlanWizardUi::initTestCase");
       
    98 
       
    99     mMainWindow = new HbAutoTestMainWindow;
       
   100 
       
   101     mView = new TestView();
       
   102 
       
   103     mMainWindow->addView(mView);
       
   104     mMainWindow->setCurrentView(mView);
       
   105     mMainWindow->installEventFilter(this);
       
   106     mMainWindow->show();
       
   107 
       
   108     QTest::qWait(1);
       
   109     while (!mEvent) {
       
   110         QTest::qWait(WaitTimeForUi);
       
   111     }
       
   112     mEvent = false;
       
   113 
       
   114     mApList = new ContextWlanApList();
       
   115 
       
   116 }
       
   117 
       
   118 /**
       
   119  * This function will be called after the last test function was executed.
       
   120  */
       
   121 void TestWlanWizardUi::cleanupTestCase()
       
   122 {
       
   123     qDebug("TestWlanWizardUi::cleanupTestCase");
       
   124 
       
   125     qDebug("delete mApList");
       
   126     delete mApList;
       
   127     mApList = NULL;
       
   128 
       
   129     qDebug("delete mMainWindow");
       
   130     mMainWindow->deleteLater();
       
   131 
       
   132     qDebug("TestWlanWizardUi::cleanupTestCase exit");
       
   133 }
       
   134 
       
   135 /**
       
   136  * This function will be called before each test function is executed.
       
   137  */
       
   138 void TestWlanWizardUi::init()
       
   139 {
       
   140     qDebug("TestWlanWizardUi::init()");
       
   141 
       
   142     mView->createWizard();
       
   143     mWlanQtUtilsContext = new WlanQtUtilsContext(mView->mWizard->d_ptr->mWlanQtUtils.data());
       
   144 }
       
   145 
       
   146 /**
       
   147  * This function will be called after each test function is executed.
       
   148  */
       
   149 void TestWlanWizardUi::cleanup()
       
   150 {
       
   151     qDebug("TestWlanWizardUi::cleanup()");
       
   152 
       
   153     delete mWlanQtUtilsContext;
       
   154     mView->deleteWizard();
       
   155     mApList->clear();
       
   156     QTest::qWait(1);
       
   157 }
       
   158 
       
   159 // ---------------------------------------------------------
       
   160 // TEST CASES
       
   161 // ---------------------------------------------------------
       
   162 
       
   163 
       
   164 void TestWlanWizardUi::tcStartWizard()
       
   165 {
       
   166     qDebug("Start mView");
       
   167 }
       
   168 
       
   169 /*!
       
   170  * 
       
   171  */
       
   172 void TestWlanWizardUi::tc01()
       
   173 {
       
   174 #ifdef tc01_enabled
       
   175     
       
   176     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false);
       
   177 
       
   178     mWlanQtUtilsContext->setScanWlanDirectResult("huuhaa3421", mApList->List());
       
   179     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   180     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   181     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   182     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   183     
       
   184     mView->showWizard();
       
   185     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   186     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   187     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   188     QTest::qWait(WaitTimeForUi);
       
   189     QCOMPARE( insertTextToObject("lineEditKey", ""), true );
       
   190     QTest::qWait(WaitTimeForUi);
       
   191     QCOMPARE( mouseClickObject("dialog"), true );
       
   192     QTest::qWait(WaitTimeForUi);
       
   193     QCOMPARE( mouseClickNext(), false );
       
   194 #endif
       
   195 }
       
   196 
       
   197 /*!
       
   198  * 
       
   199  */ 
       
   200 void TestWlanWizardUi::tc02()
       
   201 {
       
   202 #ifdef tc02_enabled
       
   203     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false);
       
   204 
       
   205     mWlanQtUtilsContext->setScanWlanDirectResult("12345678901234567890123456789012", mApList->List());
       
   206     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   207     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   208     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   209     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   210 
       
   211     mView->showWizard();
       
   212     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   213     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   214     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   215     QTest::qWait(WaitTimeForUi);
       
   216     QCOMPARE( insertTextToObject("lineEditKey", "1234567890123456789012345678901234567890"), true );
       
   217     QTest::qWait(WaitTimeForUi);
       
   218     QCOMPARE( mouseClickObject("dialog"), true );
       
   219     QTest::qWait(WaitTimeForUi);
       
   220     QCOMPARE( mouseClickNext(), true );
       
   221     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   222     QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true );  
       
   223     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
   224 #endif
       
   225 }
       
   226 
       
   227 /*!
       
   228  *  
       
   229  */
       
   230 void TestWlanWizardUi::tc03()
       
   231 {
       
   232 #ifdef tc03_enabled
       
   233     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false);
       
   234 
       
   235     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
   236     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   237     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   238     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   239     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   240 
       
   241     mView->showWizard();
       
   242     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   243     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   244     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   245     QTest::qWait(WaitTimeForUi);
       
   246     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   247     QTest::qWait(WaitTimeForUi);
       
   248     QCOMPARE( mouseClickObject("dialog"), true );
       
   249     QTest::qWait(WaitTimeForUi);
       
   250     QCOMPARE( mouseClickNext(), true );
       
   251 
       
   252     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   253     QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true );  
       
   254     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
   255     QCOMPARE( verifyActionButtons(ButtonDisabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   256     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
   257     // Currently against the spec in http://wikis.in.nokia.com/pub/UXD/101ConnectionManager/occ_logical_flows_and_wireframes.pdf
       
   258     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonHidden, ButtonEnabled), true );
       
   259 
       
   260     QCOMPARE( mouseClickCancel(), true );
       
   261 
       
   262     QTest::qWait(WaitTimeForUi);
       
   263 
       
   264 #endif
       
   265 }
       
   266 
       
   267 /*!
       
   268  * 
       
   269  */
       
   270 void TestWlanWizardUi::tc04()
       
   271 {
       
   272 #ifdef tc04_enabled
       
   273     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false);
       
   274 
       
   275     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
   276     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   277     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   278     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   279     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   280 
       
   281     mView->showWizard();
       
   282     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   283     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   284     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   285     QTest::qWait(WaitTimeForUi);
       
   286     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   287     QTest::qWait(WaitTimeForUi);
       
   288     QCOMPARE( mouseClickObject("dialog"), true );
       
   289     QTest::qWait(WaitTimeForUi);
       
   290     QCOMPARE( mouseClickNext(), true );
       
   291 
       
   292     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   293     QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true );  
       
   294 
       
   295     // Click previous button and next again
       
   296     QCOMPARE( mouseClickPrevious(), true );
       
   297     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   298     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonEnabled, ButtonHidden), true );
       
   299     QTest::qWait(WaitTimeForUi);
       
   300     QCOMPARE( mouseClickNext(), true );
       
   301 
       
   302     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   303     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
   304     QCOMPARE( verifyActionButtons(ButtonDisabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   305     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
   306     // Currently against the spec in http://wikis.in.nokia.com/pub/UXD/101ConnectionManager/occ_logical_flows_and_wireframes.pdf
       
   307     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonHidden, ButtonEnabled), true );
       
   308     QCOMPARE( mouseClickFinish(), true );
       
   309 #endif
       
   310 }
       
   311 
       
   312 /*!
       
   313  * 
       
   314  */
       
   315 void TestWlanWizardUi::tc05()
       
   316 {
       
   317 #ifdef tc05_enabled
       
   318     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false);
       
   319 
       
   320     mWlanQtUtilsContext->setScanWlanDirectResult("huuhaa3421", mApList->List());
       
   321     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   322     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   323     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   324     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   325 
       
   326     mView->showWizard();
       
   327     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   328     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   329     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   330     QTest::qWait(WaitTimeForUi);
       
   331     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   332     QTest::qWait(WaitTimeForUi);
       
   333     QCOMPARE( mouseClickObject("dialog"), true );
       
   334     QTest::qWait(WaitTimeForUi);
       
   335     QCOMPARE( mouseClickNext(), true );
       
   336 
       
   337     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   338     QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); 
       
   339     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
   340     QCOMPARE( verifyActionButtons(ButtonDisabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   341     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
   342     // Currently against the spec in http://wikis.in.nokia.com/pub/UXD/101ConnectionManager/occ_logical_flows_and_wireframes.pdf
       
   343     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonHidden, ButtonEnabled), true );
       
   344     QCOMPARE( mouseClickFinish(), true );
       
   345 #endif
       
   346 }
       
   347 
       
   348 /*!
       
   349  * 
       
   350  */
       
   351 void TestWlanWizardUi::tc06()
       
   352 {
       
   353 #ifdef tc06_enabled
       
   354     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false);
       
   355 
       
   356     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
   357     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   358     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   359     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   360     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   361 
       
   362     mView->showWizard();
       
   363     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   364     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   365     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   366     QTest::qWait(WaitTimeForUi);
       
   367     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   368     QTest::qWait(WaitTimeForUi);
       
   369     QCOMPARE( mouseClickObject("dialog"), true );
       
   370     QTest::qWait(WaitTimeForUi);
       
   371     QCOMPARE( mouseClickNext(), true );
       
   372 
       
   373     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   374     QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); 
       
   375     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
   376     QCOMPARE( verifyActionButtons(ButtonDisabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   377     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
   378     // Currently against the spec in http://wikis.in.nokia.com/pub/UXD/101ConnectionManager/occ_logical_flows_and_wireframes.pdf
       
   379     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonHidden, ButtonEnabled), true );
       
   380     QCOMPARE( mouseClickFinish(), true );
       
   381 #endif
       
   382 }
       
   383 
       
   384 /*!
       
   385  * Stop verifying buttons for views that have been already verified.
       
   386  */
       
   387 void TestWlanWizardUi::tc07()
       
   388 {
       
   389 #ifdef tc07_enabled
       
   390     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWep, false, false);
       
   391 
       
   392     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
   393     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   394     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   395     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   396     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   397 
       
   398     mView->showWizard();
       
   399     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   400     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   401     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   402     QTest::qWait(WaitTimeForUi);
       
   403     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   404     QTest::qWait(WaitTimeForUi);
       
   405     QCOMPARE( mouseClickObject("dialog"), true );
       
   406     QTest::qWait(WaitTimeForUi);
       
   407     QCOMPARE( mouseClickNext(), true );
       
   408 
       
   409     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   410     
       
   411     // Key query short pwd
       
   412     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true );
       
   413     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   414     QTest::qWait(WaitTimeForUi);
       
   415     QCOMPARE( insertTextToObject("lineEditKey", "password"), true );
       
   416     QTest::qWait(WaitTimeForUi);
       
   417     QCOMPARE( mouseClickNext(), true );
       
   418     QTest::qWait(WaitTimeForUi);
       
   419     QCOMPARE( verifyDialogText("labelErrorNote", hbTrId("txt_occ_dialog_key_is_of_incorrect_length_please")), true );
       
   420     QCOMPARE( mouseClickObject("dialog"), true );
       
   421     QTest::qWait(WaitTimeForUi);
       
   422 
       
   423     // Key query success
       
   424     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   425     QTest::qWait(WaitTimeForUi);
       
   426     QCOMPARE( verifyDialogText("labelErrorNote", ""), true );
       
   427     QCOMPARE( insertTextToObject("lineEditKey", "12345"), true );
       
   428     QTest::qWait(WaitTimeForUi);
       
   429     QCOMPARE( mouseClickNext(), true );
       
   430 
       
   431     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
   432     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
   433     QCOMPARE( mouseClickFinish(), true );
       
   434     
       
   435 #endif
       
   436 }
       
   437 
       
   438 /*!
       
   439  * 
       
   440  */
       
   441 void TestWlanWizardUi::tc08()
       
   442 {
       
   443 #ifdef tc08_enabled
       
   444     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWep, false, false);
       
   445 
       
   446     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
   447     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   448     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   449     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   450     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   451 
       
   452     mView->showWizard();
       
   453     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   454     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   455     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   456     QTest::qWait(WaitTimeForUi);
       
   457     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   458     QTest::qWait(WaitTimeForUi);
       
   459     QCOMPARE( mouseClickObject("dialog"), true );
       
   460     QTest::qWait(WaitTimeForUi);
       
   461     QCOMPARE( mouseClickNext(), true );
       
   462 
       
   463     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   464     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true );
       
   465     QCOMPARE( mouseClickPrevious(), true );
       
   466     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   467     QCOMPARE( mouseClickNext(), true );
       
   468 
       
   469     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true );
       
   470 
       
   471 #endif
       
   472 }
       
   473 
       
   474 /*!
       
   475  * 
       
   476  */
       
   477 void TestWlanWizardUi::tc09()
       
   478 {
       
   479 #ifdef tc09_enabled
       
   480 
       
   481     mWlanQtUtilsContext->setScanWlanDirectResult("huuhaa3421", mApList->List());
       
   482     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   483     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   484     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   485     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   486 
       
   487     mView->showWizard();
       
   488     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   489     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   490     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   491     QTest::qWait(WaitTimeForUi);
       
   492     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   493     QTest::qWait(WaitTimeForUi);
       
   494     QCOMPARE( mouseClickObject("dialog"), true );
       
   495     QTest::qWait(WaitTimeForUi);
       
   496     QCOMPARE( mouseClickNext(), true );
       
   497 
       
   498     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkMode), true );
       
   499     QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); 
       
   500     QCOMPARE( mouseClickPrevious(), true );
       
   501     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   502     QCOMPARE( mouseClickNext(), true );
       
   503     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkMode), true );
       
   504     QCOMPARE( selectRadioButton( "list", 0 ), true );
       
   505     QTest::qWait(WaitTimeForUi);
       
   506     QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonEnabled, ButtonHidden), true );
       
   507     QCOMPARE( mouseClickNext(), true );
       
   508 
       
   509     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkSecurity), true );
       
   510     QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true ); 
       
   511     QCOMPARE( mouseClickPrevious(), true );
       
   512     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkMode), true );
       
   513     QCOMPARE( mouseClickNext(), true );
       
   514     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkSecurity), true );
       
   515     QCOMPARE( selectRadioButton( "list", 0 ), true );
       
   516     QTest::qWait(WaitTimeForUi);
       
   517     QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonEnabled, ButtonHidden), true );
       
   518     QCOMPARE( mouseClickNext(), true );
       
   519     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
   520     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonHidden, ButtonEnabled), true );
       
   521     QCOMPARE( mouseClickFinish(), true );
       
   522 #endif    
       
   523 }
       
   524 
       
   525 /*!
       
   526  * 
       
   527  */
       
   528 void TestWlanWizardUi::tc10()
       
   529 {
       
   530 #ifdef tc10_enabled
       
   531     mMainWindow->setOrientation(Qt::Horizontal, false);
       
   532     QTest::qWait(WaitTimeForUi);
       
   533 
       
   534     mWlanQtUtilsContext->setScanWlanDirectResult("huuhaa3421", mApList->List());
       
   535     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   536     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   537     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   538     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   539 
       
   540     mView->showWizard();
       
   541     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   542     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   543     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   544     QTest::qWait(WaitTimeForUi);
       
   545     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   546     QTest::qWait(WaitTimeForUi);
       
   547     QCOMPARE( mouseClickObject("dialog"), true );
       
   548     QTest::qWait(WaitTimeForUi);
       
   549     QCOMPARE( mouseClickNext(), true );
       
   550 
       
   551     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkMode), true );
       
   552     QCOMPARE( mouseClickPrevious(), true );
       
   553     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   554     QCOMPARE( mouseClickNext(), true );
       
   555     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkMode), true ); 
       
   556     QCOMPARE( selectRadioButton( "list", 0 ), true );
       
   557     QTest::qWait(WaitTimeForUi);
       
   558     QCOMPARE( mouseClickNext(), true );
       
   559 
       
   560     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkSecurity), true );
       
   561     QCOMPARE( mouseClickPrevious(), true );
       
   562     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkMode), true );
       
   563     QCOMPARE( mouseClickNext(), true );
       
   564     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageNetworkSecurity), true );
       
   565     QCOMPARE( selectRadioButton( "list", 0 ), true );
       
   566     QTest::qWait(WaitTimeForUi);
       
   567     QCOMPARE( mouseClickNext(), true );
       
   568     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
   569     QCOMPARE( mouseClickFinish(), true );
       
   570 #endif    
       
   571 }
       
   572 
       
   573 /*!
       
   574  * 
       
   575  */
       
   576 void TestWlanWizardUi::tc11()
       
   577 {
       
   578 #ifdef tc11_enabled
       
   579     mMainWindow->setOrientation(Qt::Horizontal, false);
       
   580     QTest::qWait(WaitTimeForUi);
       
   581 
       
   582     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWep, false, false);
       
   583 
       
   584     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
   585     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   586     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   587     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   588     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   589 
       
   590     mView->showWizard();
       
   591     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   592     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   593     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   594     QTest::qWait(WaitTimeForUi);
       
   595     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   596     QTest::qWait(WaitTimeForUi);
       
   597     QCOMPARE( mouseClickObject("dialog"), true );
       
   598     QTest::qWait(WaitTimeForUi);
       
   599     QCOMPARE( mouseClickNext(), true );
       
   600 
       
   601     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   602     
       
   603     // Key query short pwd
       
   604     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true );
       
   605     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   606     QTest::qWait(WaitTimeForUi);
       
   607     QCOMPARE( insertTextToObject("lineEditKey", "password"), true );
       
   608     QTest::qWait(WaitTimeForUi);
       
   609     QCOMPARE( mouseClickNext(), true );
       
   610     QTest::qWait(WaitTimeForUi);
       
   611     QCOMPARE( verifyDialogText("labelErrorNote", hbTrId("txt_occ_dialog_key_is_of_incorrect_length_please")), true );
       
   612     QCOMPARE( mouseClickObject("dialog"), true );
       
   613     QTest::qWait(WaitTimeForUi);
       
   614 
       
   615     // Key query success
       
   616     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   617     QTest::qWait(WaitTimeForUi);
       
   618     QCOMPARE( insertTextToObject("lineEditKey", "12345"), true );
       
   619     QTest::qWait(WaitTimeForUi);
       
   620     QCOMPARE( mouseClickNext(), true );
       
   621 
       
   622     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
   623     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
   624     QCOMPARE( mouseClickFinish(), true );
       
   625 #endif    
       
   626 }
       
   627 
       
   628 /*!
       
   629  * 
       
   630  */
       
   631 void TestWlanWizardUi::tc12()
       
   632 {
       
   633 #ifdef tc12_enabled
       
   634 
       
   635     mView->mWizard->setParameters("huuhaa3421",
       
   636         CMManagerShim::Infra,
       
   637         CMManagerShim::WlanSecModeWep,
       
   638         false, false, false);
       
   639 
       
   640     mView->showWizard();
       
   641 
       
   642     mMainWindow->setOrientation(Qt::Horizontal, false);
       
   643     QTest::qWait(WaitTimeForUi);
       
   644 
       
   645     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   646     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   647     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   648     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   649 
       
   650     QTest::qWait(4000);
       
   651 
       
   652 #endif    
       
   653 }
       
   654 
       
   655 /*
       
   656  * 
       
   657  */
       
   658 void TestWlanWizardUi::tc13()
       
   659 {
       
   660 #ifdef tc13_enabled
       
   661     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWep, false, false);
       
   662 
       
   663     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
   664     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   665     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   666     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   667     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   668 
       
   669     mView->showWizard();
       
   670     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   671     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   672     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   673     QTest::qWait(WaitTimeForUi);
       
   674     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   675     QTest::qWait(WaitTimeForUi);
       
   676     QCOMPARE( mouseClickObject("dialog"), true );
       
   677     QTest::qWait(WaitTimeForUi);
       
   678     QCOMPARE( mouseClickNext(), true );
       
   679 
       
   680     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   681     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true );
       
   682     
       
   683     QCOMPARE( insertTextToObject("lineEditKey", "passworddd"), true );
       
   684     QTest::qWait(WaitTimeForUi);
       
   685     QCOMPARE( mouseClickNext(), true );
       
   686     QTest::qWait(WaitTimeForUi);
       
   687     QCOMPARE( verifyDialogText("labelErrorNote", hbTrId("txt_occ_dialog_illegal_characters_in_key_please_c")), true );
       
   688     QTest::qWait(WaitTimeForUi);
       
   689 
       
   690 #endif
       
   691 }
       
   692 
       
   693 void TestWlanWizardUi::tc14()
       
   694 {
       
   695 #ifdef tc14_enabled
       
   696     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa, true, false);
       
   697 
       
   698     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
   699     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   700     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   701     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   702     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   703 
       
   704     mView->showWizard();
       
   705     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   706     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   707     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   708     QTest::qWait(WaitTimeForUi);
       
   709     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   710     QTest::qWait(WaitTimeForUi);
       
   711     QCOMPARE( mouseClickObject("dialog"), true );
       
   712     QTest::qWait(WaitTimeForUi);
       
   713     QCOMPARE( mouseClickNext(), true );
       
   714 
       
   715     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   716     QTest::qWait(2000);
       
   717     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true );
       
   718     
       
   719     QCOMPARE( insertTextToObject("lineEditKey", "1234"), true );
       
   720     QTest::qWait(WaitTimeForUi);
       
   721     QCOMPARE( mouseClickNext(), true );
       
   722     QTest::qWait(WaitTimeForUi);
       
   723     QCOMPARE( verifyDialogText("labelErrorNote", hbTrId("txt_occ_dialog_preshared_key_too_short_at_least")), true );
       
   724     QTest::qWait(WaitTimeForUi);
       
   725 #endif
       
   726 }
       
   727 
       
   728 /*
       
   729  * wpa psk
       
   730  */
       
   731 void TestWlanWizardUi::tc15()
       
   732 {
       
   733 #ifdef tc15_enabled
       
   734     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa, true, false);
       
   735 
       
   736     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
   737     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   738     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   739     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   740     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   741 
       
   742     mView->showWizard();
       
   743     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   744     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   745     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   746     QTest::qWait(WaitTimeForUi);
       
   747     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   748     QTest::qWait(WaitTimeForUi);
       
   749     QCOMPARE( mouseClickObject("dialog"), true );
       
   750     QTest::qWait(WaitTimeForUi);
       
   751     QCOMPARE( mouseClickNext(), true );
       
   752 
       
   753     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   754     QTest::qWait(2000);
       
   755     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true );
       
   756 
       
   757     QCOMPARE( insertTextToObject("lineEditKey", "1234567890"), true );
       
   758     QTest::qWait(WaitTimeForUi);
       
   759     QCOMPARE( mouseClickNext(), true );
       
   760     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
   761     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
   762     QCOMPARE( mouseClickFinish(), true );
       
   763 #endif
       
   764 }
       
   765 
       
   766 /*
       
   767  * no wpa psk
       
   768  */
       
   769 void TestWlanWizardUi::tc16()
       
   770 {
       
   771 #ifdef tc16_enabled
       
   772     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa, false, false);
       
   773 
       
   774     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
   775     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   776     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   777     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   778     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   779 
       
   780     mView->showWizard();
       
   781     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   782     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   783     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   784     QTest::qWait(WaitTimeForUi);
       
   785     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   786     QTest::qWait(WaitTimeForUi);
       
   787     QCOMPARE( mouseClickObject("dialog"), true );
       
   788     QTest::qWait(WaitTimeForUi);
       
   789     QCOMPARE( mouseClickNext(), true );
       
   790 
       
   791     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   792     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
   793     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
   794     QCOMPARE( mouseClickFinish(), true );
       
   795 #endif
       
   796 }
       
   797 
       
   798 /*
       
   799  * wpa2 psk
       
   800  */
       
   801 void TestWlanWizardUi::tc17()
       
   802 {
       
   803 #ifdef tc17_enabled
       
   804     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa2, true, false);
       
   805 
       
   806     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
   807     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   808     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   809     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   810     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   811 
       
   812     mView->showWizard();
       
   813     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   814     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   815     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   816     QTest::qWait(WaitTimeForUi);
       
   817     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   818     QTest::qWait(WaitTimeForUi);
       
   819     QCOMPARE( mouseClickObject("dialog"), true );
       
   820     QTest::qWait(WaitTimeForUi);
       
   821     QCOMPARE( mouseClickNext(), true );
       
   822 
       
   823     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   824     QTest::qWait(2000);
       
   825     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true );
       
   826 
       
   827     QCOMPARE( insertTextToObject("lineEditKey", "1234567890"), true );
       
   828     QTest::qWait(WaitTimeForUi);
       
   829     QCOMPARE( mouseClickNext(), true );
       
   830     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
   831     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
   832     QCOMPARE( mouseClickFinish(), true );
       
   833 #endif
       
   834 }
       
   835 
       
   836 /*
       
   837  * wpa2 no psk
       
   838  */
       
   839 void TestWlanWizardUi::tc18()
       
   840 {
       
   841 #ifdef tc18_enabled
       
   842     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa2, false, false);
       
   843 
       
   844     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
   845     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   846     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   847     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   848     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   849 
       
   850     mView->showWizard();
       
   851     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   852     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   853     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   854     QTest::qWait(WaitTimeForUi);
       
   855     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   856     QTest::qWait(WaitTimeForUi);
       
   857     QCOMPARE( mouseClickObject("dialog"), true );
       
   858     QTest::qWait(WaitTimeForUi);
       
   859     QCOMPARE( mouseClickNext(), true );
       
   860 
       
   861     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   862     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
   863     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
   864     QCOMPARE( mouseClickFinish(), true );
       
   865 #endif
       
   866 }
       
   867 
       
   868 /*
       
   869  * wpa2 no psk
       
   870  */
       
   871 void TestWlanWizardUi::tc19()
       
   872 {
       
   873 #ifdef tc19_enabled
       
   874     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa2, false, false);
       
   875 
       
   876     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
   877     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   878     mWlanQtUtilsContext->setSignalIctResult(0, false);
       
   879     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   880     mWlanQtUtilsContext->setConnectionSuccessed(false);
       
   881 
       
   882     mView->showWizard();
       
   883     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   884     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   885     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   886     QTest::qWait(WaitTimeForUi);
       
   887     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   888     QTest::qWait(WaitTimeForUi);
       
   889     QCOMPARE( mouseClickObject("dialog"), true );
       
   890     QTest::qWait(WaitTimeForUi);
       
   891     QCOMPARE( mouseClickNext(), true );
       
   892 
       
   893     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   894     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
   895     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 20, 500), false );
       
   896 #endif
       
   897 }
       
   898 
       
   899 /*
       
   900  * Wlan network closed -> generic error
       
   901  */
       
   902 void TestWlanWizardUi::tc20()
       
   903 {
       
   904 #ifdef tc20_enabled
       
   905     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa2, false, false);
       
   906 
       
   907     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
   908     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   909     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   910     mWlanQtUtilsContext->setSignalWlanNetworkClosed(100, 1);
       
   911     mWlanQtUtilsContext->setConnectionSuccessed(false);
       
   912 
       
   913     mView->showWizard();
       
   914     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   915     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   916     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   917     QTest::qWait(WaitTimeForUi);
       
   918     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   919     QTest::qWait(WaitTimeForUi);
       
   920     QCOMPARE( mouseClickObject("dialog"), true );
       
   921     QTest::qWait(WaitTimeForUi);
       
   922     QCOMPARE( mouseClickNext(), true );
       
   923 
       
   924     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   925     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
   926     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageGenericError, 10, 500), true );
       
   927     
       
   928 #endif
       
   929 }
       
   930 
       
   931 /*
       
   932  * adhoc no psk
       
   933  */
       
   934 void TestWlanWizardUi::tc21()
       
   935 {
       
   936 #ifdef tc21_enabled
       
   937     mApList->Add("huuhaa3421", CMManagerShim::Adhoc, CMManagerShim::WlanSecModeOpen, false, false);
       
   938 
       
   939     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
   940     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   941     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   942     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   943     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   944 
       
   945     mView->showWizard();
       
   946     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   947     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   948     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   949     QTest::qWait(WaitTimeForUi);
       
   950     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   951     QTest::qWait(WaitTimeForUi);
       
   952     QCOMPARE( mouseClickObject("dialog"), true );
       
   953     QTest::qWait(WaitTimeForUi);
       
   954     QCOMPARE( mouseClickNext(), true );
       
   955 
       
   956     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   957     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
   958     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
   959     
       
   960 #endif
       
   961 }
       
   962 
       
   963 /*
       
   964  * 802_1x
       
   965  */
       
   966 void TestWlanWizardUi::tc22()
       
   967 {
       
   968 #ifdef tc22_enabled
       
   969     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecMode802_1x, false, false);
       
   970 
       
   971     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
   972     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
   973     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
   974     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
   975     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   976 
       
   977     mView->showWizard();
       
   978     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
   979     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   980     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   981     QTest::qWait(WaitTimeForUi);
       
   982     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
   983     QTest::qWait(WaitTimeForUi);
       
   984     QCOMPARE( mouseClickObject("dialog"), true );
       
   985     QTest::qWait(WaitTimeForUi);
       
   986     QCOMPARE( mouseClickNext(), true );
       
   987 
       
   988     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
   989     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
   990     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
   991 #endif
       
   992 }
       
   993 
       
   994 /*
       
   995  * Wapi
       
   996  */
       
   997 void TestWlanWizardUi::tc23()
       
   998 {
       
   999 #ifdef tc23_enabled
       
  1000     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWapi, false, false);
       
  1001 
       
  1002     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
  1003     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
  1004     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
  1005     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
  1006     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
  1007 
       
  1008     mView->showWizard();
       
  1009     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
  1010     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
  1011     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
  1012     QTest::qWait(WaitTimeForUi);
       
  1013     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
  1014     QTest::qWait(WaitTimeForUi);
       
  1015     QCOMPARE( mouseClickObject("dialog"), true );
       
  1016     QTest::qWait(WaitTimeForUi);
       
  1017     QCOMPARE( mouseClickNext(), true );
       
  1018 
       
  1019     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
  1020     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
  1021     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
  1022 #endif
       
  1023 }
       
  1024 
       
  1025 /*
       
  1026  * Multiple AP scan match results
       
  1027  */
       
  1028 void TestWlanWizardUi::tc24()
       
  1029 {
       
  1030 #ifdef tc24_enabled
       
  1031     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa, false, false, 100);
       
  1032     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false, 400);
       
  1033     mApList->Add("foobar", CMManagerShim::Infra, CMManagerShim::WlanSecModeWep, false, false, 300);
       
  1034     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false, 200);
       
  1035 
       
  1036     mWlanQtUtilsContext->setScanWlanApsResult(mApList->List());
       
  1037     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
  1038     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
  1039     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
  1040     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
  1041 
       
  1042     mView->showWizard();
       
  1043     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
  1044     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
  1045     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
  1046     QTest::qWait(WaitTimeForUi);
       
  1047     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
  1048     QTest::qWait(WaitTimeForUi);
       
  1049     QCOMPARE( mouseClickObject("dialog"), true );
       
  1050     QTest::qWait(WaitTimeForUi);
       
  1051     QCOMPARE( mouseClickNext(), true );
       
  1052 
       
  1053     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
  1054     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
  1055     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
  1056 #endif
       
  1057 }
       
  1058 
       
  1059 /*
       
  1060  * Multiple Direct scan match results
       
  1061  */
       
  1062 void TestWlanWizardUi::tc25()
       
  1063 {
       
  1064 #ifdef tc25_enabled
       
  1065     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa, false, false, 100);
       
  1066     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false, 400);
       
  1067     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWep, false, false, 300);
       
  1068     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false, 200);
       
  1069 
       
  1070     mWlanQtUtilsContext->setScanWlanDirectResult("huuhaa3421", mApList->List());
       
  1071     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
  1072     mWlanQtUtilsContext->setSignalIctResult(100, true);
       
  1073     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
  1074     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
  1075 
       
  1076     mView->showWizard();
       
  1077     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSsid), true );
       
  1078     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
  1079     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
  1080     QTest::qWait(WaitTimeForUi);
       
  1081     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
  1082     QTest::qWait(WaitTimeForUi);
       
  1083     QCOMPARE( mouseClickObject("dialog"), true );
       
  1084     QTest::qWait(WaitTimeForUi);
       
  1085     QCOMPARE( mouseClickNext(), true );
       
  1086 
       
  1087     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
  1088     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
  1089     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
  1090 #endif
       
  1091 }
       
  1092 
       
  1093 /*!
       
  1094  * Connect to open:
       
  1095  * - verifies IAP settings
       
  1096  * - ICT success
       
  1097  * - Finish button pressed
       
  1098  */
       
  1099 void TestWlanWizardUi::tc_connect_to_open_success()
       
  1100 {
       
  1101 #ifdef tc_connect_to_open_success_enabled
       
  1102     tc_connect_success(
       
  1103         "tc_connect_to_open_success",
       
  1104         CMManagerShim::Infra,
       
  1105         CMManagerShim::WlanSecModeOpen,
       
  1106         false,
       
  1107         "" );
       
  1108 #endif 
       
  1109 }
       
  1110 
       
  1111 /*!
       
  1112  * Connect to open
       
  1113  */
       
  1114 void TestWlanWizardUi::tc_connect_to_open_success_hidden()
       
  1115 {
       
  1116 #ifdef tc_connect_to_open_success_hidden_enabled
       
  1117     tc_connect_success(
       
  1118         "tc_connect_to_open_success_hidden",
       
  1119         CMManagerShim::Infra,
       
  1120         CMManagerShim::WlanSecModeOpen,
       
  1121         true,
       
  1122         "" );
       
  1123 #endif 
       
  1124 }
       
  1125 
       
  1126 /*!
       
  1127  * Connect to open
       
  1128  */
       
  1129 void TestWlanWizardUi::tc_connect_to_open_success_adhoc()
       
  1130 {
       
  1131 #ifdef tc_connect_to_open_success_adhoc_enabled
       
  1132     tc_connect_success(
       
  1133         "tc_connect_to_open_success_adhoc",
       
  1134         CMManagerShim::Adhoc,
       
  1135         CMManagerShim::WlanSecModeOpen,
       
  1136         true,
       
  1137         "" );
       
  1138 #endif 
       
  1139 }
       
  1140 
       
  1141 /*!
       
  1142  * Connect to open
       
  1143  */
       
  1144 void TestWlanWizardUi::tc_connect_to_wep_success()
       
  1145 {
       
  1146 #ifdef tc_connect_to_wep_success_enabled
       
  1147     tc_connect_success(
       
  1148         "tc_connect_to_wep_success",
       
  1149         CMManagerShim::Adhoc,
       
  1150         CMManagerShim::WlanSecModeWep,
       
  1151         true,
       
  1152         "abcde" );
       
  1153 #endif 
       
  1154 }
       
  1155 
       
  1156 
       
  1157 /*!
       
  1158  * Connect to open
       
  1159  */
       
  1160 void TestWlanWizardUi::tc_connect_to_wpa_psk_success()
       
  1161 {
       
  1162 #ifdef tc_connect_to_wpa_psk_success_enabled
       
  1163     tc_connect_success(
       
  1164         "tc_connect_to_wpa_psk_success",
       
  1165         CMManagerShim::Infra,
       
  1166         CMManagerShim::WlanSecModeWpa,
       
  1167         false,
       
  1168         "password" );
       
  1169 #endif 
       
  1170 }
       
  1171 /*!
       
  1172  * Connect to open
       
  1173  */
       
  1174 void TestWlanWizardUi::tc_connect_to_wpa2_psk_success()
       
  1175 {
       
  1176 #ifdef tc_connect_to_wpa2_psk_success_enabled
       
  1177     tc_connect_success(
       
  1178         "tc_connect_to_wpa2_psk_success",
       
  1179         CMManagerShim::Adhoc,
       
  1180         CMManagerShim::WlanSecModeWpa2,
       
  1181         false,
       
  1182         "password" );
       
  1183 #endif 
       
  1184 }
       
  1185 
       
  1186 
       
  1187 /*!
       
  1188  * Connect to open:
       
  1189  * - Opens
       
  1190  * - ICT success
       
  1191  * - Cancel pressed in summary page
       
  1192  */
       
  1193 void TestWlanWizardUi::tc_connect_to_open_success_cancel()
       
  1194 {
       
  1195 #ifdef tc_connect_to_open_success_cancel_enabled
       
  1196 
       
  1197     mWlanQtUtilsContext->setCreateWlanIapResult(3);
       
  1198     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
  1199     mWlanQtUtilsContext->setSignalWlanNetworkOpened(3);
       
  1200     mWlanQtUtilsContext->setSignalIctResult(3, true);
       
  1201     
       
  1202     mView->mWizard->setParameters(
       
  1203         "tc_connect_to_open_success_cancel",
       
  1204         CMManagerShim::Infra,
       
  1205         CMManagerShim::WlanSecModeOpen,
       
  1206         false, false, false);
       
  1207     
       
  1208     mView->showWizard();
       
  1209     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
  1210     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
  1211     QTest::qWait(WaitTimeForUi);
       
  1212     
       
  1213     // Ignore previous calls
       
  1214     mWlanQtUtilsContext->calledMethods();
       
  1215     
       
  1216     QCOMPARE( mouseClickCancel(), true );
       
  1217     
       
  1218     QStringList calledMethods;
       
  1219     calledMethods 
       
  1220         << "disconnectIap"
       
  1221         << "deleteIap";
       
  1222     
       
  1223     QCOMPARE(mWlanQtUtilsContext->calledMethods(), calledMethods);
       
  1224     QCOMPARE( mView->verifyStatus(TestView::WizardStatusSignalCancelled), true);
       
  1225 #endif 
       
  1226 }
       
  1227 
       
  1228 /*!
       
  1229  * Helpper test case for testing success case with compinations of provided
       
  1230  * parameters.
       
  1231  */
       
  1232 void TestWlanWizardUi::tc_connect_success(
       
  1233     const QString &ssid,
       
  1234     int networkMode,
       
  1235     int securityMode,
       
  1236     bool hidden,
       
  1237     QString key)
       
  1238 {
       
  1239     
       
  1240     mWlanQtUtilsContext->setCreateWlanIapResult(2);
       
  1241     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
  1242     mWlanQtUtilsContext->setSignalWlanNetworkOpened(2);
       
  1243     mWlanQtUtilsContext->setSignalIctResult(2, true);
       
  1244     
       
  1245     mView->mWizard->setParameters(
       
  1246         ssid,
       
  1247         networkMode,
       
  1248         securityMode,
       
  1249         true, 
       
  1250         hidden,
       
  1251         false);
       
  1252 
       
  1253     WlanQtUtilsAp ap;
       
  1254     ap.setValue(WlanQtUtilsAp::ConfIdConnectionMode, networkMode);
       
  1255     ap.setValue(WlanQtUtilsAp::ConfIdSecurityMode, securityMode);
       
  1256     ap.setValue(WlanQtUtilsAp::ConfIdSsid, ssid);
       
  1257     ap.setValue(WlanQtUtilsAp::ConfIdHidden, hidden);
       
  1258     
       
  1259     QStringList calledMethods;
       
  1260     calledMethods << "WlanQtUtils";
       
  1261     QCOMPARE(mWlanQtUtilsContext->calledMethods(), calledMethods);
       
  1262 
       
  1263     mView->showWizard();
       
  1264     if (securityMode == CMManagerShim::WlanSecModeWep ||
       
  1265         securityMode == CMManagerShim::WlanSecModeWpa ||
       
  1266         securityMode == CMManagerShim::WlanSecModeWpa2) {
       
  1267         // Key query short pwd
       
  1268         QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageKeyQuery), true );
       
  1269         QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonEnabled, ButtonHidden), true );
       
  1270         QTest::qWait(WaitTimeForUi);
       
  1271         
       
  1272         QCOMPARE( mouseClickObject("lineEditKey"), true );
       
  1273         QTest::qWait(WaitTimeForUi);
       
  1274         
       
  1275         if (securityMode == CMManagerShim::WlanSecModeWep) {
       
  1276             ap.setValue(WlanQtUtilsAp::ConfIdWepKey1, key );
       
  1277             ap.setValue(WlanQtUtilsAp::ConfIdWepKey2, key );
       
  1278             ap.setValue(WlanQtUtilsAp::ConfIdWepKey3, key );
       
  1279             ap.setValue(WlanQtUtilsAp::ConfIdWepKey4, key );
       
  1280             ap.setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex1);
       
  1281             QCOMPARE( insertTextToObject("lineEditKey", "abcde"), true );
       
  1282         } 
       
  1283         else {
       
  1284             QCOMPARE( insertTextToObject("lineEditKey", "password"), true );
       
  1285             ap.setValue(WlanQtUtilsAp::ConfIdWpaPsk, key );
       
  1286             ap.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true );
       
  1287         }
       
  1288         QCOMPARE( mouseClickObject("dialog"), true );
       
  1289         
       
  1290         QTest::qWait(WaitTimeForUi);
       
  1291         QCOMPARE( mouseClickNext(), true );
       
  1292 
       
  1293         QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
  1294         QCOMPARE( verifyActionButtons(ButtonDisabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
  1295         QTest::qWait(WaitTimeForUi);
       
  1296         
       
  1297         QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
  1298         QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonHidden, ButtonEnabled), true );
       
  1299         QTest::qWait(WaitTimeForUi);
       
  1300     }
       
  1301     else {
       
  1302         QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
  1303         QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
  1304         
       
  1305         QTest::qWait(WaitTimeForUi);
       
  1306         QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
  1307         QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonHidden, ButtonEnabled), true );
       
  1308         QTest::qWait(WaitTimeForUi);
       
  1309     }
       
  1310     
       
  1311     calledMethods.clear();
       
  1312     calledMethods 
       
  1313         << "createIap" 
       
  1314         << "activeIap"
       
  1315         << "connectIap";
       
  1316     QCOMPARE( mWlanQtUtilsContext->calledMethods(), calledMethods);
       
  1317     
       
  1318     QCOMPARE( mWlanQtUtilsContext->verifyWlanIapSettings(ap), true);
       
  1319     
       
  1320     QTest::qWait(WaitTimeForUi);
       
  1321     QCOMPARE( mouseClickFinish(), true );
       
  1322     QCOMPARE( mView->verifyStatus(TestView::WizardStatusSignalFinished, 2), true);
       
  1323 }
       
  1324 
       
  1325 /*
       
  1326  * Ict Result enumerator used. Hotspot.
       
  1327  */
       
  1328 void TestWlanWizardUi::tc26()
       
  1329 {
       
  1330 #ifdef tc26_enabled
       
  1331     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa, false, false, 100);
       
  1332     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false, 400);
       
  1333     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWep, false, false, 300);
       
  1334     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false, 200);
       
  1335 
       
  1336     mWlanQtUtilsContext->setScanWlanDirectResult("huuhaa3421", mApList->List());
       
  1337     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
  1338     mWlanQtUtilsContext->setSignalIctResult(100, IctsHotspotPassed);
       
  1339     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
  1340     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
  1341 
       
  1342     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
  1343     QTest::qWait(1000);
       
  1344     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
  1345     QTest::qWait(1000);
       
  1346     QCOMPARE( mouseClickObject("dialog"), true );
       
  1347     QTest::qWait(1000);
       
  1348     QCOMPARE( mouseClickNext(), true );
       
  1349 
       
  1350     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
  1351     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
  1352     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
  1353     QTest::qWait(5000);
       
  1354 #endif
       
  1355 }
       
  1356 
       
  1357 /*
       
  1358  * Ict Result enumerator used. Ict canceled.
       
  1359  */
       
  1360 void TestWlanWizardUi::tc27()
       
  1361 {
       
  1362 #ifdef tc27_enabled
       
  1363     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWpa, false, false, 100);
       
  1364     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false, 400);
       
  1365     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeWep, false, false, 300);
       
  1366     mApList->Add("huuhaa3421", CMManagerShim::Infra, CMManagerShim::WlanSecModeOpen, false, false, 200);
       
  1367 
       
  1368     mWlanQtUtilsContext->setScanWlanDirectResult("huuhaa3421", mApList->List());
       
  1369     mWlanQtUtilsContext->setCreateWlanIapResult(100);
       
  1370     mWlanQtUtilsContext->setSignalIctResult(100, IctsCanceled);
       
  1371     mWlanQtUtilsContext->setSignalWlanNetworkOpened(100);
       
  1372     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
  1373 
       
  1374     QCOMPARE( mouseClickObject("lineEditKey"), true );
       
  1375     QTest::qWait(1000);
       
  1376     QCOMPARE( insertTextToObject("lineEditKey", "huuhaa3421"), true );
       
  1377     QTest::qWait(1000);
       
  1378     QCOMPARE( mouseClickObject("dialog"), true );
       
  1379     QTest::qWait(1000);
       
  1380     QCOMPARE( mouseClickNext(), true );
       
  1381 
       
  1382     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageScanning), true );
       
  1383     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageProcessSettings), true );
       
  1384     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageGenericError, 10, 500), true );
       
  1385     QTest::qWait(5000);
       
  1386 #endif
       
  1387 }
       
  1388 
       
  1389 /*!
       
  1390  * Filter to catch focus event to the text editor widget.
       
  1391  */
       
  1392 bool TestWlanWizardUi::eventFilter(QObject *obj, QEvent *event)
       
  1393 {
       
  1394     if (obj == mMainWindow && event->type() == QEvent::Show) {
       
  1395         mMainWindow->removeEventFilter(this);
       
  1396         mEvent = true;
       
  1397     }
       
  1398     return false;
       
  1399 }
       
  1400 
       
  1401 QGraphicsWidget* TestWlanWizardUi::findChildItem(const QString &itemName, QGraphicsWidget *widget)
       
  1402 {
       
  1403     QList<QGraphicsItem*> list = widget->childItems();
       
  1404     for (int i = 0; i < list.size(); i++) {
       
  1405         QGraphicsWidget* item = (QGraphicsWidget*) list[i];
       
  1406         if (item->objectName() == itemName) {
       
  1407             return item;
       
  1408         }
       
  1409         else if ((item = findChildItem(itemName, item))) {
       
  1410             return item;
       
  1411         }
       
  1412     }
       
  1413     return 0;
       
  1414 }
       
  1415 
       
  1416 bool TestWlanWizardUi::verifyCurrentPage(int pageId, int retries, int wait_ms)
       
  1417 {
       
  1418     for (int i = 0; i < retries; i++) {
       
  1419         QTest::qWait(wait_ms);
       
  1420 
       
  1421         WlanWizardPrivate *pPrivate = mView->mWizard->d_ptr;
       
  1422         HbWidget* current = qobject_cast<HbWidget*> (pPrivate->mStackedWidget->currentWidget());
       
  1423         WlanWizardPage *page = pPrivate->mPageMapper[current];
       
  1424 
       
  1425         // TODO: verify title in this method
       
  1426         
       
  1427         if (page == pPrivate->mPages[pageId]) {
       
  1428             switch(pageId) {
       
  1429             case WlanWizardPageInternal::PageEapStart:
       
  1430                 return true;
       
  1431             case WlanWizardPageInternal::PageGenericError:
       
  1432                 return true;
       
  1433             case WlanWizardPageInternal::PageKeyQuery:
       
  1434                 // TODO: add parameter SSID, FAILS without it
       
  1435                 return true; // verifyDialogText("dialog", hbTrId("txt_occ_dialog_enter_key_for_1"));
       
  1436             case WlanWizardPageInternal::PageNetworkMode:
       
  1437                 return verifyDialogText("dialog_6", hbTrId("txt_occ_dialog_select_network_mode_and_status"));
       
  1438             case WlanWizardPageInternal::PageNetworkSecurity:
       
  1439                 return verifyDialogText("dialog_6", hbTrId("txt_occ_dialog_select_network_security_mode"));
       
  1440             case WlanWizardPageInternal::PageProcessSettings:
       
  1441                 // TODO: add parameter SSID, FAILS without it
       
  1442                 return true; // verifyDialogText("dialog", hbTrId("txt_occ_dialog_checking_connection_to_1"));
       
  1443             case WlanWizardPageInternal::PageScanning:
       
  1444                 return true; // verifyDialogText("dialog", hbTrId("TODO_1"));
       
  1445             case WlanWizardPageInternal::PageSsid:
       
  1446                 return verifyDialogText("dialog", hbTrId("txt_occ_dialog_insert_the_name_of_the_new_wlan_net"));
       
  1447             case WlanWizardPageInternal::PageSummary:
       
  1448                 if (pPrivate->mTitle->plainText() != hbTrId("txt_occ_title_wlan_setup_wizard_summary")){
       
  1449                     qWarning("TestWlanWizardUi::verifyCurrentPage: Invalid title");
       
  1450                     return false;
       
  1451                 }
       
  1452                 return true;
       
  1453             case WlanWizardPageInternal::PageWpsStart:
       
  1454                 return true;
       
  1455             default:
       
  1456                 return true;
       
  1457             }
       
  1458         }
       
  1459     }
       
  1460     qWarning("verifyCurrentPage: expected: %d", pageId);
       
  1461     return false;
       
  1462 }
       
  1463 
       
  1464 bool TestWlanWizardUi::verifyDialogText(const QString objName, const QString text)
       
  1465 {
       
  1466     HbWidget* current = qobject_cast<HbWidget*> (
       
  1467         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
  1468     HbLabel* widget = (HbLabel*) findChildItem(objName, current);
       
  1469 
       
  1470     if (widget) {
       
  1471         if(widget->plainText() == text) {
       
  1472             return true;
       
  1473         }
       
  1474         else {
       
  1475             qWarning("verifyDialogText: not match");
       
  1476             qDebug() << "expect: " << text;
       
  1477             qDebug() << "actual: " << widget->plainText();
       
  1478         }
       
  1479     } else {
       
  1480         qWarning("verifyDialogText: object not found");
       
  1481     }
       
  1482     
       
  1483     return false;
       
  1484 }
       
  1485 
       
  1486 bool TestWlanWizardUi::verifyActionButtons(ButtonStatus prevStatus,
       
  1487     ButtonStatus cancelStatus,
       
  1488     ButtonStatus nextStatus,
       
  1489     ButtonStatus finishStatus)
       
  1490 {
       
  1491     WlanWizardPrivate *pPrivate = mView->mWizard->d_ptr;
       
  1492     ButtonStatus prevReally = ButtonHidden;
       
  1493     ButtonStatus cancelReally = ButtonHidden;
       
  1494     ButtonStatus nextReally = ButtonHidden;
       
  1495     ButtonStatus finishReally = ButtonHidden;
       
  1496 
       
  1497     if(pPrivate->mActionPrevious->isVisible()) {
       
  1498         if(pPrivate->mActionPrevious->isEnabled()) {
       
  1499             prevReally = ButtonEnabled;
       
  1500         } else {
       
  1501             prevReally = ButtonDisabled;
       
  1502         }
       
  1503     }
       
  1504 
       
  1505     if(pPrivate->mActionCancel->isVisible()) {
       
  1506         if(pPrivate->mActionCancel->isEnabled()) {
       
  1507             cancelReally = ButtonEnabled;
       
  1508         } else {
       
  1509             cancelReally = ButtonDisabled;
       
  1510         }
       
  1511     }
       
  1512 
       
  1513     if(pPrivate->mActionNext->isVisible()) {
       
  1514         if(pPrivate->mActionNext->isEnabled()) {
       
  1515             nextReally = ButtonEnabled;
       
  1516         } else {
       
  1517             nextReally = ButtonDisabled;
       
  1518         }
       
  1519     }
       
  1520 
       
  1521     if(pPrivate->mActionFinish->isVisible()) {
       
  1522         if(pPrivate->mActionFinish->isEnabled()) {
       
  1523             finishReally = ButtonEnabled;
       
  1524         } else {
       
  1525             finishReally = ButtonDisabled;
       
  1526         }
       
  1527     }
       
  1528     bool ret = true;
       
  1529     if (prevReally != prevStatus){
       
  1530         qWarning("Previous Button: really: %d, status: %d", prevReally, prevStatus);
       
  1531         ret = false;
       
  1532     }
       
  1533     if (cancelReally != cancelStatus){
       
  1534         qWarning("Cancel Button: really: %d, status: %d", cancelReally, cancelStatus);
       
  1535         ret = false;
       
  1536     }
       
  1537     if (nextReally != nextStatus){
       
  1538         qWarning("Next Button: really: %d, status: %d", nextReally, nextStatus);
       
  1539         ret = false;
       
  1540     }
       
  1541     if (finishReally != finishStatus){
       
  1542         qWarning("Finish Button: really: %d, status: %d", finishReally, finishStatus);
       
  1543         ret = false;
       
  1544     }
       
  1545     
       
  1546     return ret;
       
  1547 }
       
  1548 
       
  1549 bool TestWlanWizardUi::mouseClickObject(const QString objName)
       
  1550 {
       
  1551     HbWidget* current = qobject_cast<HbWidget*> (
       
  1552         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
  1553     HbWidget* widget = (HbWidget*) findChildItem(objName, current);
       
  1554     
       
  1555     if (widget) {
       
  1556         HbAutoTest::mouseClick(mMainWindow, widget);
       
  1557         widget->clearFocus();
       
  1558         widget->setFocus();
       
  1559         return true;
       
  1560     }
       
  1561     qWarning("mouseClickObject: object not found");
       
  1562     
       
  1563     return false;
       
  1564 }
       
  1565 
       
  1566 bool TestWlanWizardUi::insertTextToObject(const QString objName, const QString text)
       
  1567 {
       
  1568     HbWidget* current = qobject_cast<HbWidget*> (
       
  1569         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
  1570     HbWidget* widget = (HbWidget*) findChildItem(objName, current);
       
  1571 
       
  1572     if (widget) {
       
  1573         for (int i = 0; i < text.size(); i++) {
       
  1574             HbAutoTest::keyPress(mMainWindow, text.at(i).toAscii(), 0, 10);
       
  1575             QTest::qWait(20);
       
  1576         }
       
  1577         return true;
       
  1578     }
       
  1579     qWarning("insertTextToObject: object not found");
       
  1580     return false;
       
  1581 }
       
  1582 
       
  1583 bool TestWlanWizardUi::selectRadioButton(const QString objName, int index)
       
  1584 {
       
  1585     HbWidget* current = qobject_cast<HbWidget*> (
       
  1586         mView->mWizard->d_ptr->mStackedWidget->currentWidget());
       
  1587     TestRadioButtonList* widget = (TestRadioButtonList*) findChildItem(objName, current);
       
  1588 
       
  1589     if (widget) {
       
  1590         widget->setSelected(index);
       
  1591         widget->emitActivated(widget->currentIndex());
       
  1592         return true;
       
  1593     }
       
  1594     return false;
       
  1595 }
       
  1596 
       
  1597 bool TestWlanWizardUi::mouseClickNext()
       
  1598 {
       
  1599     if (mView->mWizard->d_ptr->mActionNext->isEnabled()) {
       
  1600         mView->mWizard->d_ptr->mActionNext->activate(QAction::Trigger);
       
  1601         return true;
       
  1602     }
       
  1603     qWarning("Next button not enabled");
       
  1604     return false;
       
  1605 }
       
  1606 
       
  1607 bool TestWlanWizardUi::mouseClickPrevious()
       
  1608 {
       
  1609     if (mView->mWizard->d_ptr->mActionPrevious->isEnabled()) {
       
  1610         mView->mWizard->d_ptr->mActionPrevious->activate(QAction::Trigger);
       
  1611         return true;
       
  1612     }
       
  1613     qWarning("Previous button not enabled");
       
  1614     return false;
       
  1615 }
       
  1616 
       
  1617 bool TestWlanWizardUi::mouseClickCancel()
       
  1618 {
       
  1619     if (mView->mWizard->d_ptr->mActionCancel->isEnabled()) {
       
  1620         mView->mWizard->d_ptr->mActionCancel->activate(QAction::Trigger);
       
  1621         return true;
       
  1622     }
       
  1623     qWarning("Cancel button not enabled");
       
  1624     return false;
       
  1625 }
       
  1626 
       
  1627 bool TestWlanWizardUi::mouseClickFinish()
       
  1628 {
       
  1629     if (mView->mWizard->d_ptr->mActionFinish->isEnabled()) {
       
  1630         mView->mWizard->d_ptr->mActionFinish->activate(QAction::Trigger);
       
  1631         return true;
       
  1632     }
       
  1633     qWarning("Finish button not enabled");
       
  1634     return false;
       
  1635 }
       
  1636 
       
  1637 TestView::TestView() : mWizard(NULL)
       
  1638 {
       
  1639     qDebug("TestView::TestView()");
       
  1640 }
       
  1641 
       
  1642 TestView::~TestView()
       
  1643 {
       
  1644     qDebug("TestView::~TestView()");
       
  1645 }
       
  1646 
       
  1647 void TestView::createWizard()
       
  1648 {
       
  1649     qDebug("TestView::createWizard");
       
  1650     Q_ASSERT(mWizard == NULL);
       
  1651     mWizard = new WlanWizard(mainWindow());
       
  1652     bool ok;
       
  1653     ok = connect(
       
  1654         mWizard, SIGNAL(finished(int, bool)), 
       
  1655         this, SLOT(finished(int, bool)), 
       
  1656         Qt::QueuedConnection);
       
  1657     Q_ASSERT(ok);
       
  1658 
       
  1659     ok = connect(
       
  1660         mWizard, SIGNAL(cancelled()), 
       
  1661         this, SLOT(cancelled()),
       
  1662         Qt::QueuedConnection);
       
  1663     Q_ASSERT(ok);
       
  1664     
       
  1665     mWizardStatus = WizardStatusSignalNone;
       
  1666     mConnectedIapId = -100;
       
  1667 }
       
  1668 
       
  1669 void TestView::showWizard()
       
  1670 {
       
  1671     qDebug("TestView::showWizard()");
       
  1672     Q_ASSERT(mWizard);
       
  1673     mWizard->show();
       
  1674 }
       
  1675 
       
  1676 void TestView::deleteWizard()
       
  1677 {
       
  1678     qDebug("TestView::deleteWizard");
       
  1679 
       
  1680     Q_ASSERT(mWizard != NULL);
       
  1681     QTest::qWait(10);
       
  1682     QTest::qWait(10); 
       
  1683     QMetaObject::invokeMethod(mWizard, "deleteLater", Qt::QueuedConnection); 
       
  1684     QTest::qWait(10); 
       
  1685     mWizard = NULL; 
       
  1686 }
       
  1687 
       
  1688 void TestView::finished(int iapId, bool connected)
       
  1689 {
       
  1690     qDebug("TestView::complete(), iap id: %d, connected: %d", iapId, connected);
       
  1691     
       
  1692     if (mWizardStatus != WizardStatusSignalNone) {
       
  1693         qWarning("TestView::finished: multiple signals received");
       
  1694         mWizardStatus = WizardStatusSignalUndefined;
       
  1695     } else {
       
  1696         mWizardStatus = WizardStatusSignalFinished;
       
  1697         mConnectedIapId = iapId;
       
  1698     }
       
  1699 }
       
  1700 
       
  1701 void TestView::cancelled()
       
  1702 {
       
  1703     qDebug("TestView::cancelled()");
       
  1704     if (mWizardStatus != WizardStatusSignalNone) {
       
  1705         qWarning("TestView::cancelled: multiple signals received");
       
  1706         mWizardStatus = WizardStatusSignalUndefined;
       
  1707     } else {
       
  1708         mWizardStatus = WizardStatusSignalCancelled;
       
  1709     }
       
  1710 }
       
  1711 
       
  1712 bool TestView::verifyStatus(WizardStatusSignal status, int iapId )
       
  1713 {
       
  1714     // Since connections to cancelled and finished signals are queued
       
  1715     // we need to use qWait() here.
       
  1716     QTest::qWait(100);
       
  1717     bool ret = true;
       
  1718     if (status != mWizardStatus){
       
  1719         qWarning("TestView::verifyStatus, status: expected: %d, actual: %d", status, mWizardStatus);
       
  1720         ret = false;
       
  1721     }
       
  1722     if (status == WizardStatusSignalFinished) {
       
  1723         if (iapId != mConnectedIapId) {
       
  1724             qWarning("TestView::verifyStatus, iapid: expected: %d, actual: %d", iapId, mConnectedIapId);
       
  1725             ret = false;
       
  1726         }
       
  1727     }
       
  1728     return ret;
       
  1729 }