wlanutilities/wlanwizard/t_wlanwizard/ut/testwlanwizardconnect.cpp
changeset 53 bdc64aa9b954
parent 49 fb81b597edf1
child 60 822a45792fdd
equal deleted inserted replaced
49:fb81b597edf1 53:bdc64aa9b954
     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 #include <wlanerrorcodes.h>
       
    33 
       
    34 // User includes
       
    35 #include "testwlanwizardconnect.h"
       
    36 #include "testwlanwizardconnect_conf.h"
       
    37 #include "hbautotest.h"
       
    38 #include "wlanwizard.h"
       
    39 #include "wlanwizard_p.h"
       
    40 #include "wlanwizardpagessid.h"
       
    41 #include "wlanqtutils_context.h"
       
    42 #include "wlanqtutils.h"
       
    43 #include "wlanqtutilsap.h"
       
    44 
       
    45 // External function prototypes
       
    46 
       
    47 // Local constants
       
    48 
       
    49 
       
    50 // ======== LOCAL FUNCTIONS ========
       
    51 
       
    52 // ======== MEMBER FUNCTIONS ========
       
    53 
       
    54 
       
    55 // ---------------------------------------------------------
       
    56 // TEST CASES
       
    57 // ---------------------------------------------------------
       
    58 
       
    59 /*!
       
    60  * Connect to open:
       
    61  * - verifies IAP settings
       
    62  * - ICT success
       
    63  * - Finish button pressed
       
    64  */
       
    65 void TestWlanWizardConnect::tc_connect_to_open_success()
       
    66 {
       
    67 #ifdef tc_connect_to_open_success_enabled
       
    68     tc_connect_success("tc_connect_to_open_success", CMManagerShim::Infra,
       
    69         CMManagerShim::WlanSecModeOpen, false, "");
       
    70 #endif 
       
    71 }
       
    72 
       
    73 /*!
       
    74  * Connect to open
       
    75  */
       
    76 void TestWlanWizardConnect::tc_connect_to_open_success_hidden()
       
    77 {
       
    78 #ifdef tc_connect_to_open_success_hidden_enabled
       
    79     tc_connect_success("tc_connect_to_open_success_hidden", CMManagerShim::Infra,
       
    80         CMManagerShim::WlanSecModeOpen, true, "");
       
    81 #endif 
       
    82 }
       
    83 
       
    84 /*!
       
    85  * Connect to open
       
    86  */
       
    87 void TestWlanWizardConnect::tc_connect_to_open_success_adhoc()
       
    88 {
       
    89 #ifdef tc_connect_to_open_success_adhoc_enabled
       
    90     tc_connect_success("tc_connect_to_open_success_adhoc", CMManagerShim::Adhoc,
       
    91         CMManagerShim::WlanSecModeOpen, true, "");
       
    92 #endif 
       
    93 }
       
    94 
       
    95 /*!
       
    96  * Connect to open
       
    97  */
       
    98 void TestWlanWizardConnect::tc_connect_to_wep_success()
       
    99 {
       
   100 #ifdef tc_connect_to_wep_success_enabled
       
   101     tc_connect_success("tc_connect_to_wep_success", CMManagerShim::Adhoc,
       
   102         CMManagerShim::WlanSecModeWep, true, "abcde");
       
   103 #endif 
       
   104 }
       
   105 
       
   106 /*!
       
   107  * Connect to open
       
   108  */
       
   109 void TestWlanWizardConnect::tc_connect_to_wpa_psk_success()
       
   110 {
       
   111 #ifdef tc_connect_to_wpa_psk_success_enabled
       
   112     tc_connect_success("tc_connect_to_wpa_psk_success", CMManagerShim::Infra,
       
   113         CMManagerShim::WlanSecModeWpa, false, "password");
       
   114 #endif 
       
   115 }
       
   116 /*!
       
   117  * Connect to open
       
   118  */
       
   119 void TestWlanWizardConnect::tc_connect_to_wpa2_psk_success()
       
   120 {
       
   121 #ifdef tc_connect_to_wpa2_psk_success_enabled
       
   122     tc_connect_success("tc_connect_to_wpa2_psk_success", CMManagerShim::Adhoc,
       
   123         CMManagerShim::WlanSecModeWpa2, false, "password");
       
   124 #endif 
       
   125 }
       
   126 
       
   127 /*!
       
   128  * Connect to open:
       
   129  * - Opens
       
   130  * - ICT success
       
   131  * - Cancel pressed in summary page
       
   132  */
       
   133 void TestWlanWizardConnect::tc_connect_to_open_success_cancel()
       
   134 {
       
   135 #ifdef tc_connect_to_open_success_cancel_enabled
       
   136 
       
   137     mWlanQtUtilsContext->setCreateWlanIapResult(3);
       
   138     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   139     mWlanQtUtilsContext->setSignalWlanNetworkOpened(3);
       
   140     mWlanQtUtilsContext->setSignalIctResult(3, WlanQtUtils::IctPassed);
       
   141 
       
   142     mView->mWizard->setParameters("tc_connect_to_open_success_cancel",
       
   143         CMManagerShim::Infra,
       
   144         CMManagerShim::WlanSecModeOpen, false, false, false);
       
   145 
       
   146     mView->showWizard();
       
   147     QCOMPARE( verifyCurrentPageWithInfo(WlanWizardPageInternal::PageProcessSettings, "tc_connect_to_open_success_cancel"), true );
       
   148     QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
   149     QTest::qWait(WaitTimeForUi);
       
   150 
       
   151     // Ignore previous calls
       
   152     mWlanQtUtilsContext->calledMethods();
       
   153 
       
   154     QCOMPARE( mouseClickCancel(), true );
       
   155 
       
   156     QStringList calledMethods;
       
   157     calledMethods << "disconnectIap" << "deleteIap";
       
   158 
       
   159     QCOMPARE(mWlanQtUtilsContext->calledMethods(), calledMethods);
       
   160     QCOMPARE(verifyStatus(WizardStatusSignalCancelled), true);
       
   161 #endif 
       
   162 }
       
   163 
       
   164 void TestWlanWizardConnect::tc_network_failure_OpenAuthFailed()
       
   165 {
       
   166 #ifdef tc_network_failure_OpenAuthFailed_enabled
       
   167     tc_network_error_codes(
       
   168         "tc_network_failure_OpenAuthFailed", 
       
   169         CMManagerShim::Adhoc,
       
   170         CMManagerShim::WlanSecModeOpen, 
       
   171         false, 
       
   172         "",
       
   173         hbTrId("txt_occ_dialog_authentication_unsuccessful"), 
       
   174         KErrWlanOpenAuthFailed );
       
   175 #endif
       
   176 }
       
   177 void TestWlanWizardConnect::tc_network_failure_SharedKeyAuthRequired()
       
   178 {
       
   179 #ifdef tc_network_failure_SharedKeyAuthRequired_enabled
       
   180     tc_network_error_codes(
       
   181         "tc_network_failure_SharedKeyAuthRequired", 
       
   182         CMManagerShim::Adhoc,
       
   183         CMManagerShim::WlanSecModeOpen, 
       
   184         false, 
       
   185         "",
       
   186         hbTrId("txt_occ_dialog_authentication_unsuccessful"), 
       
   187         KErrWlanSharedKeyAuthRequired );
       
   188 #endif
       
   189 }
       
   190 void TestWlanWizardConnect::tc_network_failure_WpaAuthRequired()
       
   191 {
       
   192 #ifdef tc_network_failure_WpaAuthRequired_enabled
       
   193     tc_network_error_codes(
       
   194         "tc_network_failure_WpaAuthRequired", 
       
   195         CMManagerShim::Adhoc,
       
   196         CMManagerShim::WlanSecModeOpen, 
       
   197         false, 
       
   198         "",
       
   199         hbTrId("txt_occ_dialog_authentication_unsuccessful"), 
       
   200         KErrWlanWpaAuthRequired );
       
   201 #endif
       
   202 }
       
   203 void TestWlanWizardConnect::tc_network_failure_WpaAuthFailed()
       
   204 {
       
   205 #ifdef tc_network_failure_WpaAuthFailed_enabled
       
   206     tc_network_error_codes(
       
   207         "tc_network_failure_WpaAuthFailed", 
       
   208         CMManagerShim::Adhoc,
       
   209         CMManagerShim::WlanSecModeWpa, 
       
   210         true, 
       
   211         "password",
       
   212         hbTrId("txt_occ_dialog_authentication_unsuccessful"), 
       
   213         KErrWlanWpaAuthFailed );
       
   214 #endif
       
   215 }
       
   216 void TestWlanWizardConnect::tc_network_failure_802dot1xAuthFailed()
       
   217 {
       
   218 #ifdef tc_network_failure_802dot1xAuthFailed_enabled
       
   219     tc_network_error_codes(
       
   220         "tc_network_failure_802dot1xAuthFailed", 
       
   221         CMManagerShim::Adhoc,
       
   222         CMManagerShim::WlanSecModeOpen, 
       
   223         false, 
       
   224         "",
       
   225         hbTrId("txt_occ_dialog_authentication_unsuccessful"), 
       
   226         KErrWlan802dot1xAuthFailed );
       
   227 #endif
       
   228 }
       
   229 void TestWlanWizardConnect::tc_network_failure_IllegalEncryptionKeys()
       
   230 {
       
   231 #ifdef tc_network_failure_IllegalEncryptionKeys_enabled
       
   232     tc_network_error_codes(
       
   233         "tc_network_failure_IllegalEncryptionKeys", 
       
   234         CMManagerShim::Adhoc,
       
   235         CMManagerShim::WlanSecModeOpen, 
       
   236         false, 
       
   237         "",
       
   238         hbTrId("txt_occ_dialog_authentication_unsuccessful"), 
       
   239         KErrWlanIllegalEncryptionKeys );
       
   240 #endif
       
   241 }
       
   242 void TestWlanWizardConnect::tc_network_failure_PskModeRequired()
       
   243 {
       
   244 #ifdef tc_network_failure_PskModeRequired_enabled
       
   245     tc_network_error_codes(
       
   246         "tc_network_failure_PskModeRequired", 
       
   247         CMManagerShim::Adhoc,
       
   248         CMManagerShim::WlanSecModeOpen, 
       
   249         false, 
       
   250         "",
       
   251         hbTrId("txt_occ_dialog_authentication_unsuccessful"), 
       
   252         KErrWlanPskModeRequired );
       
   253 #endif
       
   254 }
       
   255 void TestWlanWizardConnect::tc_network_failure_EapModeRequired()
       
   256 {
       
   257 #ifdef tc_network_failure_EapModeRequired_enabled
       
   258     tc_network_error_codes(
       
   259         "tc_network_failure_EapModeRequired", 
       
   260         CMManagerShim::Adhoc,
       
   261         CMManagerShim::WlanSecModeOpen, 
       
   262         false, 
       
   263         "",
       
   264         hbTrId("txt_occ_dialog_authentication_unsuccessful"), 
       
   265         KErrWlanEapModeRequired );
       
   266 #endif
       
   267 }
       
   268 void TestWlanWizardConnect::tc_network_failure_IllefalWpaPskKey()
       
   269 {
       
   270 #ifdef tc_network_failure_IllefalWpaPskKey_enabled
       
   271     tc_network_error_codes(
       
   272         "tc_network_failure_IllefalWpaPskKey", 
       
   273         CMManagerShim::Adhoc,
       
   274         CMManagerShim::WlanSecModeOpen, 
       
   275         false, 
       
   276         "",
       
   277         hbTrId("txt_occ_dialog_incorrect_wpa_preshared_key_pleas"), 
       
   278         KErrWlanIllegalWpaPskKey );
       
   279 #endif
       
   280 }
       
   281 void TestWlanWizardConnect::tc_network_failure_SharedKeyAuthFailed()
       
   282 {
       
   283 #ifdef tc_network_failure_SharedKeyAuthFailed_enabled
       
   284     tc_network_error_codes(
       
   285         "tc_network_failure_SharedKeyAuthFailed", 
       
   286         CMManagerShim::Adhoc,
       
   287         CMManagerShim::WlanSecModeOpen, 
       
   288         false, 
       
   289         "",
       
   290         hbTrId("txt_occ_dialog_incorrect_wep_key_please_check_the"), 
       
   291         KErrWlanSharedKeyAuthFailed );
       
   292 #endif
       
   293 }
       
   294 void TestWlanWizardConnect::tc_network_failure_ErrNone()
       
   295 {
       
   296 #ifdef tc_network_failure_ErrNone_enabled
       
   297     tc_network_error_codes(
       
   298         "tc_network_failure_ErrNone", 
       
   299         CMManagerShim::Adhoc,
       
   300         CMManagerShim::WlanSecModeOpen, 
       
   301         false, 
       
   302         "",
       
   303         hbTrId("txt_occ_dialog_incorrect_wep_key_please_check_the"), 
       
   304         KErrWlanSharedKeyAuthFailed );
       
   305 #endif
       
   306 }
       
   307 void TestWlanWizardConnect::tc_network_failure_30180()
       
   308 {
       
   309 #ifdef tc_network_failure_30180_enabled
       
   310     const QString ssid("tc_network_failure_30180");
       
   311     tc_network_error_codes(
       
   312         ssid, 
       
   313         CMManagerShim::Adhoc,
       
   314         CMManagerShim::WlanSecModeWep, 
       
   315         false, 
       
   316         "abcde",
       
   317         hbTrId("txt_occ_dialog_connection_failed"), 
       
   318         30180 );
       
   319     
       
   320     QCOMPARE( mouseClickPrevious(), true );
       
   321     QTest::qWait(WaitTimeForUi);
       
   322 
       
   323     QCOMPARE( verifyCurrentPageWithInfo(WlanWizardPageInternal::PageKeyQuery, ssid), true );
       
   324     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonEnabled, ButtonHidden), true );
       
   325     QTest::qWait(WaitTimeForUi);
       
   326     
       
   327     QCOMPARE( mouseClickNext(), true );
       
   328     
       
   329     QCOMPARE( verifyCurrentPageWithInfo(WlanWizardPageInternal::PageProcessSettings, ssid), true );
       
   330     QCOMPARE( verifyActionButtons(ButtonDisabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   331     QTest::qWait(WaitTimeForUi);
       
   332 
       
   333     QCOMPARE( verifyCurrentPageWithInfo(WlanWizardPageInternal::PageGenericError, hbTrId("txt_occ_dialog_connection_failed")), true );
       
   334     QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   335     QTest::qWait(WaitTimeForUi);
       
   336 
       
   337     QStringList calledMethods;
       
   338     calledMethods 
       
   339         << "updateIap" 
       
   340         << "activeIap" 
       
   341         << "disconnectIap"
       
   342         << "connectIap";
       
   343     
       
   344     QCOMPARE(mWlanQtUtilsContext->calledMethods(), calledMethods);
       
   345     
       
   346 #endif
       
   347 }
       
   348 
       
   349 void TestWlanWizardConnect::tc_iap_creation_fails()
       
   350 {
       
   351 #ifdef tc_iap_creation_fails_enabled
       
   352 
       
   353     const QString ssid("tc_iap_creation_fails");
       
   354     
       
   355     mWlanQtUtilsContext->setCreateWlanIapResult(-1);
       
   356 
       
   357     mView->mWizard->setParameters(
       
   358         ssid, 
       
   359         CMManagerShim::Infra,
       
   360         CMManagerShim::WlanSecModeOpen, 
       
   361         false, false, false);
       
   362 
       
   363     mView->showWizard();
       
   364     
       
   365     QCOMPARE( verifyCurrentPageWithInfo(WlanWizardPageInternal::PageProcessSettings, ssid), true );
       
   366     QCOMPARE( verifyCurrentPageWithInfo(
       
   367             WlanWizardPageInternal::PageGenericError,
       
   368             hbTrId("txt_occ_dialog_unable_to_save_settings_please_ret") ), true );
       
   369     
       
   370     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   371     QTest::qWait(WaitTimeForUi);
       
   372     
       
   373     QStringList calledMethods;
       
   374     calledMethods << "WlanQtUtils" << "createIap";
       
   375     QCOMPARE(mWlanQtUtilsContext->calledMethods(), calledMethods);
       
   376     
       
   377     QCOMPARE( mouseClickCancel(), true );
       
   378     QTest::qWait(WaitTimeForUi);
       
   379     QCOMPARE( verifyStatus(WizardStatusSignalCancelled, 2), true);
       
   380     QTest::qWait(WaitTimeForUi);
       
   381 #endif 
       
   382 }
       
   383 
       
   384 void TestWlanWizardConnect::tc_cancel_key_query()
       
   385 {
       
   386 #ifdef tc_cancel_key_query_enabled
       
   387       
       
   388     const QString ssid("tc_cancel_key_query");
       
   389     
       
   390     mView->mWizard->setParameters(
       
   391         ssid,
       
   392         CMManagerShim::Adhoc, 
       
   393         CMManagerShim::WlanSecModeWep,
       
   394         true, false, false);
       
   395     mView->showWizard();
       
   396 
       
   397     QCOMPARE( verifyCurrentPageWithInfo(WlanWizardPageInternal::PageKeyQuery, ssid), true );
       
   398     QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonEnabled, ButtonHidden), true );
       
   399     QTest::qWait(WaitTimeForUi);
       
   400 
       
   401     QCOMPARE( mouseClickCancel(), true );
       
   402     QTest::qWait(WaitTimeForUi);
       
   403     QCOMPARE( verifyStatus(WizardStatusSignalCancelled), true);    
       
   404     
       
   405     mWlanQtUtilsContext->emitWlanNetworkClosed(-1, KErrCancel);
       
   406     callWlanWizard_startPageOperation();
       
   407     
       
   408     QStringList calledMethods;
       
   409     calledMethods << "WlanQtUtils";
       
   410     QCOMPARE(mWlanQtUtilsContext->calledMethods(), calledMethods);
       
   411 #endif
       
   412 }
       
   413 
       
   414 /*!
       
   415  * Helpper test case for testing success case with compinations of provided
       
   416  * parameters.
       
   417  */
       
   418 void TestWlanWizardConnect::tc_connect_success(const QString &ssid, int networkMode,
       
   419     int securityMode, bool hidden, QString key)
       
   420 {
       
   421 
       
   422     mWlanQtUtilsContext->setCreateWlanIapResult(2);
       
   423     mWlanQtUtilsContext->setConnectionSuccessed(true);
       
   424     mWlanQtUtilsContext->setSignalWlanNetworkOpened(2);
       
   425     mWlanQtUtilsContext->setSignalIctResult(2, WlanQtUtils::IctPassed);
       
   426 
       
   427     mView->mWizard->setParameters(ssid, networkMode, securityMode, true, hidden, false);
       
   428 
       
   429     WlanQtUtilsAp ap;
       
   430     ap.setValue(WlanQtUtilsAp::ConfIdConnectionMode, networkMode);
       
   431     ap.setValue(WlanQtUtilsAp::ConfIdSecurityMode, securityMode);
       
   432     ap.setValue(WlanQtUtilsAp::ConfIdSsid, ssid);
       
   433     ap.setValue(WlanQtUtilsAp::ConfIdHidden, hidden);
       
   434 
       
   435     // Default values
       
   436     ap.setValue(WlanQtUtilsAp::ConfIdWpaPsk, QString());
       
   437     ap.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true );
       
   438     ap.setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex1 );
       
   439     ap.setValue(WlanQtUtilsAp::ConfIdWepKey1, QString());
       
   440     ap.setValue(WlanQtUtilsAp::ConfIdWepKey2, QString());
       
   441     ap.setValue(WlanQtUtilsAp::ConfIdWepKey3, QString());
       
   442     ap.setValue(WlanQtUtilsAp::ConfIdWepKey4, QString());
       
   443     
       
   444     QStringList calledMethods;
       
   445     calledMethods << "WlanQtUtils";
       
   446     QCOMPARE(mWlanQtUtilsContext->calledMethods(), calledMethods);
       
   447 
       
   448     mView->showWizard();
       
   449     if (securityMode == CMManagerShim::WlanSecModeWep || securityMode
       
   450         == CMManagerShim::WlanSecModeWpa || securityMode == CMManagerShim::WlanSecModeWpa2) {
       
   451         // Key query short pwd
       
   452         QCOMPARE( verifyCurrentPageWithInfo(WlanWizardPageInternal::PageKeyQuery, ssid), true );
       
   453         QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonEnabled, ButtonHidden), true );
       
   454         QTest::qWait(WaitTimeForUi);
       
   455 
       
   456         QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   457         QTest::qWait(WaitTimeForUi);
       
   458             
       
   459         if (securityMode == CMManagerShim::WlanSecModeWep) {
       
   460             ap.setValue(WlanQtUtilsAp::ConfIdWepKey1, key);
       
   461             ap.setValue(WlanQtUtilsAp::ConfIdWepKey2, key);
       
   462             ap.setValue(WlanQtUtilsAp::ConfIdWepKey3, key);
       
   463             ap.setValue(WlanQtUtilsAp::ConfIdWepKey4, key);
       
   464             ap.setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex1);
       
   465             QCOMPARE( insertTextToObject("lineEditKey", "abcde"), true );
       
   466         }
       
   467         else {
       
   468             QCOMPARE( insertTextToObject("lineEditKey", "password"), true );
       
   469             ap.setValue(WlanQtUtilsAp::ConfIdWpaPsk, key);
       
   470             ap.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true);
       
   471         }
       
   472         QCOMPARE( mouseClickObject("dialog"), true );
       
   473 
       
   474         QTest::qWait(WaitTimeForUi);
       
   475         QCOMPARE( mouseClickNext(), true );
       
   476 
       
   477         QCOMPARE( verifyCurrentPageWithInfo(WlanWizardPageInternal::PageProcessSettings, ssid), true );
       
   478         QCOMPARE( verifyActionButtons(ButtonDisabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   479         QTest::qWait(WaitTimeForUi);
       
   480 
       
   481         QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
   482         QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonHidden, ButtonEnabled), true );
       
   483         QTest::qWait(WaitTimeForUi);
       
   484     }
       
   485     else {
       
   486         QCOMPARE( verifyCurrentPageWithInfo(WlanWizardPageInternal::PageProcessSettings, ssid), true );
       
   487         QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   488 
       
   489         QTest::qWait(WaitTimeForUi);
       
   490         QCOMPARE( verifyCurrentPage(WlanWizardPageInternal::PageSummary, 10, 500), true );
       
   491         QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonHidden, ButtonEnabled), true );
       
   492         QTest::qWait(WaitTimeForUi);
       
   493     }
       
   494     
       
   495     QCOMPARE(verifySummaryPage(
       
   496         ssid,
       
   497         networkMode,
       
   498         hidden, 
       
   499         securityMode, 
       
   500         true,
       
   501         hbTrId("txt_occ_dblist_destination_val_internet")),true);
       
   502 
       
   503     calledMethods.clear();
       
   504     calledMethods << "createIap" << "activeIap" << "connectIap";
       
   505     QCOMPARE( mWlanQtUtilsContext->calledMethods(), calledMethods);
       
   506     QCOMPARE( mWlanQtUtilsContext->verifyWlanIapSettings(ap), true);
       
   507     QTest::qWait(WaitTimeForUi);
       
   508 
       
   509     QCOMPARE( mouseClickFinish(), true );
       
   510     QTest::qWait(WaitTimeForUi);
       
   511     QCOMPARE( verifyStatus(WizardStatusSignalFinished, 2), true);
       
   512 }
       
   513 
       
   514 /*!
       
   515  * Helpper test case for testing success case with compinations of provided
       
   516  * parameters.
       
   517  */
       
   518 void TestWlanWizardConnect::tc_network_error_codes(
       
   519     const QString &ssid, 
       
   520     int networkMode,
       
   521     int securityMode, 
       
   522     bool hidden, 
       
   523     QString key, 
       
   524     const QString &errorString, 
       
   525     int errorCode)
       
   526 {
       
   527     mWlanQtUtilsContext->setCreateWlanIapResult(2);
       
   528     mWlanQtUtilsContext->setConnectionSuccessed(false);
       
   529     mWlanQtUtilsContext->setSignalWlanNetworkClosed(2, errorCode);
       
   530     mWlanQtUtilsContext->setActiveWlanIapResult(1);
       
   531     mView->mWizard->setParameters(ssid, networkMode, securityMode, true, hidden, false);
       
   532 
       
   533     WlanQtUtilsAp ap;
       
   534     ap.setValue(WlanQtUtilsAp::ConfIdConnectionMode, networkMode);
       
   535     ap.setValue(WlanQtUtilsAp::ConfIdSecurityMode, securityMode);
       
   536     ap.setValue(WlanQtUtilsAp::ConfIdSsid, ssid);
       
   537     ap.setValue(WlanQtUtilsAp::ConfIdHidden, hidden);
       
   538 
       
   539     // Default values
       
   540     ap.setValue(WlanQtUtilsAp::ConfIdWpaPsk, QString());
       
   541     ap.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true );
       
   542     ap.setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex1 );
       
   543     ap.setValue(WlanQtUtilsAp::ConfIdWepKey1, QString());
       
   544     ap.setValue(WlanQtUtilsAp::ConfIdWepKey2, QString());
       
   545     ap.setValue(WlanQtUtilsAp::ConfIdWepKey3, QString());
       
   546     ap.setValue(WlanQtUtilsAp::ConfIdWepKey4, QString());
       
   547     
       
   548     QStringList calledMethods;
       
   549     calledMethods << "WlanQtUtils";
       
   550     QCOMPARE(mWlanQtUtilsContext->calledMethods(), calledMethods);
       
   551 
       
   552     mView->showWizard();
       
   553     if (securityMode == CMManagerShim::WlanSecModeWep || securityMode
       
   554         == CMManagerShim::WlanSecModeWpa || securityMode == CMManagerShim::WlanSecModeWpa2) {
       
   555         // Key query short pwd
       
   556         QCOMPARE( verifyCurrentPageWithInfo(WlanWizardPageInternal::PageKeyQuery, ssid), true );
       
   557         QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonEnabled, ButtonHidden), true );
       
   558         QTest::qWait(WaitTimeForUi);
       
   559 
       
   560         QCOMPARE( mouseClickObject("lineEditKey"), true );
       
   561         QTest::qWait(WaitTimeForUi);
       
   562 
       
   563         if (securityMode == CMManagerShim::WlanSecModeWep) {
       
   564             ap.setValue(WlanQtUtilsAp::ConfIdWepKey1, key);
       
   565             ap.setValue(WlanQtUtilsAp::ConfIdWepKey2, key);
       
   566             ap.setValue(WlanQtUtilsAp::ConfIdWepKey3, key);
       
   567             ap.setValue(WlanQtUtilsAp::ConfIdWepKey4, key);
       
   568             ap.setValue(WlanQtUtilsAp::ConfIdWepDefaultIndex, CMManagerShim::WepKeyIndex1);
       
   569             QCOMPARE( insertTextToObject("lineEditKey", "abcde"), true );
       
   570         }
       
   571         else {
       
   572             QCOMPARE( insertTextToObject("lineEditKey", "password"), true );
       
   573             ap.setValue(WlanQtUtilsAp::ConfIdWpaPsk, key);
       
   574             ap.setValue(WlanQtUtilsAp::ConfIdWpaPskUse, true);
       
   575         }
       
   576         QCOMPARE( mouseClickObject("dialog"), true );
       
   577 
       
   578         QTest::qWait(WaitTimeForUi);
       
   579         QCOMPARE( mouseClickNext(), true );
       
   580 
       
   581         QCOMPARE( verifyCurrentPageWithInfo(WlanWizardPageInternal::PageProcessSettings, ssid), true );
       
   582         QCOMPARE( verifyActionButtons(ButtonDisabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   583         QTest::qWait(WaitTimeForUi);
       
   584 
       
   585         QCOMPARE( verifyCurrentPageWithInfo(WlanWizardPageInternal::PageGenericError, errorString), true );
       
   586         QCOMPARE( verifyActionButtons(ButtonEnabled, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   587         QTest::qWait(WaitTimeForUi);
       
   588     }
       
   589     else {
       
   590         QCOMPARE( verifyCurrentPageWithInfo(WlanWizardPageInternal::PageProcessSettings, ssid), true );
       
   591         QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   592         QTest::qWait(WaitTimeForUi);
       
   593 
       
   594         QCOMPARE( verifyCurrentPageWithInfo(WlanWizardPageInternal::PageGenericError, errorString), true );
       
   595         QCOMPARE( verifyActionButtons(ButtonHidden, ButtonEnabled, ButtonDisabled, ButtonHidden), true );
       
   596         QTest::qWait(WaitTimeForUi);
       
   597     }
       
   598 
       
   599     calledMethods.clear();
       
   600     calledMethods 
       
   601         << "createIap" 
       
   602         << "activeIap" 
       
   603         << "disconnectIap" 
       
   604         << "connectIap";
       
   605     QCOMPARE( mWlanQtUtilsContext->calledMethods(), calledMethods);
       
   606     QCOMPARE( mWlanQtUtilsContext->verifyWlanIapSettings(ap), true);
       
   607     QTest::qWait(WaitTimeForUi);
       
   608 }