cellular/psuinotes/tsrc/ut_psuiutils/ut_psuiutils.cpp
branchRCL_3
changeset 20 987c9837762f
parent 19 7d48bed6ce0c
child 21 0a6dd2dc9970
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
     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 
       
    18 #include "ut_psuiutils.h"
       
    19 #include "qtestmains60.h"
       
    20 #include <gsmerror.h>
       
    21 #include <exterror.h>
       
    22 #include <etelmm.h>
       
    23 #include <btsapdomainpskeys.h>
       
    24 #define private public
       
    25 #include "psuiutils.h"
       
    26 
       
    27 /*!
       
    28   UT_PsUiUtils::UT_PsUiUtils
       
    29  */
       
    30 UT_PsUiUtils::UT_PsUiUtils() :
       
    31     mWrapper(NULL)
       
    32 {
       
    33 }
       
    34 
       
    35 /*!
       
    36   UT_PsUiUtils::~UT_PsUiUtils
       
    37  */
       
    38 UT_PsUiUtils::~UT_PsUiUtils()
       
    39 {
       
    40     delete mWrapper;
       
    41 }
       
    42 
       
    43 /*!
       
    44   UT_PsUiUtils::init
       
    45  */
       
    46 void UT_PsUiUtils::init()
       
    47 {
       
    48     initialize();
       
    49     
       
    50     mWrapper = new PsUiSettingsWrapper();
       
    51 }
       
    52 
       
    53 /*!
       
    54   UT_PsUiUtils::cleanup
       
    55  */
       
    56 void UT_PsUiUtils::cleanup()
       
    57 {
       
    58     reset();
       
    59 }
       
    60 
       
    61 /*!
       
    62   UT_PsUiUtils::t_memleak
       
    63  */
       
    64 void UT_PsUiUtils::t_memleak()
       
    65 {
       
    66     
       
    67 }
       
    68 
       
    69 /*!
       
    70   UT_PsUiUtils::t_errorCodeTextMapping
       
    71  */
       
    72 void UT_PsUiUtils::t_errorCodeTextMapping()
       
    73 {
       
    74     QString text = "";
       
    75     PsUiUtils::errorCodeTextMapping(KErrGsmSSSubscriptionViolation, text);
       
    76     QCOMPARE( text, QString(
       
    77             "txt_phone_info_barring_operation_not_successful"));
       
    78     PsUiUtils::errorCodeTextMapping(KErrGsmSSUnknownSubscriber, text);
       
    79     QCOMPARE( text, QString(
       
    80             "txt_phone_info_not_allowed"));
       
    81     PsUiUtils::errorCodeTextMapping(KErrGsmSSAbsentSubscriber, text);
       
    82     QCOMPARE( text, QString(
       
    83             "txt_phone_info_not_allowed"));
       
    84     PsUiUtils::errorCodeTextMapping(KErrGsmSSIllegalOperation, text);
       
    85     QCOMPARE( text, QString(
       
    86             "txt_phone_info_not_allowed"));
       
    87     PsUiUtils::errorCodeTextMapping(KErrGsmSSIllegalSubscriber, text);
       
    88     QCOMPARE( text, QString(
       
    89             "txt_phone_info_not_allowed"));
       
    90     PsUiUtils::errorCodeTextMapping(KErrGsmSSIllegalEquipment, text);
       
    91     QCOMPARE( text, QString(
       
    92             "txt_phone_info_not_allowed"));
       
    93     PsUiUtils::errorCodeTextMapping(KErrGsmSSCallBarred, text);
       
    94     QCOMPARE( text, QString(
       
    95             "txt_phone_info_not_allowed"));
       
    96     PsUiUtils::errorCodeTextMapping(KErrGsmSSDataMissing, text);
       
    97     QCOMPARE( text, QString(
       
    98             "txt_phone_info_not_allowed"));
       
    99     PsUiUtils::errorCodeTextMapping(KErrGsmSSIncompatibility, text);
       
   100     QCOMPARE( text, QString(
       
   101             "txt_phone_info_conflict_error"));
       
   102     PsUiUtils::errorCodeTextMapping(KErrGsmSSSystemFailure, text);
       
   103     QCOMPARE( text, QString(
       
   104             "txt_phone_info_result_unknown"));
       
   105     PsUiUtils::errorCodeTextMapping(KErrGsmSSUnexpectedDataValue, text);
       
   106     QCOMPARE( text, QString(
       
   107             "txt_phone_info_request_rejected"));
       
   108     PsUiUtils::errorCodeTextMapping(KErrGsmSSResourcesUnavailable, text);
       
   109     QCOMPARE( text, QString(
       
   110             "txt_phone_info_request_rejected"));
       
   111     PsUiUtils::errorCodeTextMapping(KErrGsmSSNegativePasswordCheck, text);
       
   112     QCOMPARE( text, QString(
       
   113             "Password error"));
       
   114     PsUiUtils::errorCodeTextMapping(KErrGsmSSPasswordRegistrationFailure, text);
       
   115     QCOMPARE( text, QString(
       
   116             "Password error"));
       
   117     PsUiUtils::errorCodeTextMapping(KErrGsmSSPasswordAttemptsViolation, text);
       
   118     QCOMPARE( text, QString(
       
   119             "txt_phone_info_barring_password_blocked"));
       
   120     PsUiUtils::errorCodeTextMapping(KErrGsmSMSNoNetworkService, text);
       
   121     QCOMPARE( text, QString(
       
   122             "No network coverage"));
       
   123     PsUiUtils::errorCodeTextMapping(KErrGsmNoService, text);
       
   124     QCOMPARE( text, QString(
       
   125             "No network coverage"));
       
   126     PsUiUtils::errorCodeTextMapping(KErrSsActivationDataLost, text);
       
   127     QCOMPARE( text, QString(
       
   128             "Check network services"));
       
   129     PsUiUtils::errorCodeTextMapping(KErrGsmSSUnknownAlphabet, text);
       
   130     QCOMPARE( text, QString("txt_phone_info_invalid_phone_number"));
       
   131     
       
   132     expect("XQSysInfo::isSupported").returns(false);
       
   133     PsUiUtils::errorCodeTextMapping(KErrGsmOfflineOpNotAllowed, text);
       
   134     QCOMPARE( text, QString(
       
   135             "txt_phone_info_request_not_completed"));
       
   136     QVERIFY( verify() );
       
   137     
       
   138     expect("XQSysInfo::isSupported").returns(true);
       
   139     expect("XQSettingsManager::readItemValue").returns(QVariant(EBTSapConnected));
       
   140     PsUiUtils::errorCodeTextMapping(KErrGsmOfflineOpNotAllowed, text);
       
   141     QCOMPARE( text, QString(
       
   142             "Operation not possible in SIM access profile mode"));
       
   143     QVERIFY( verify() );
       
   144     
       
   145     expect("XQSysInfo::isSupported").returns(true);
       
   146     expect("XQSettingsManager::readItemValue").returns(QVariant(EBTSapNotConnected));
       
   147     PsUiUtils::errorCodeTextMapping(KErrGsmOfflineOpNotAllowed, text);
       
   148     QCOMPARE( text, QString(
       
   149             "Operation not possible in Off-line mode"));
       
   150     
       
   151     PsUiUtils::errorCodeTextMapping(-1, text);
       
   152     QCOMPARE( text, QString(
       
   153             "txt_phone_info_request_not_completed"));
       
   154     
       
   155     QVERIFY( verify() );
       
   156         
       
   157 }
       
   158 
       
   159 /*!
       
   160   UT_PsUiUtils::::t_isFeatureCallWaitingDistiquishNotProvisionedEnabled
       
   161  */
       
   162 void UT_PsUiUtils::t_isFeatureCallWaitingDistiquishNotProvisionedEnabled()
       
   163 {
       
   164     expect("XQSettingsManager::readItemValue").
       
   165                 returns(QVariant(1));
       
   166     mWrapper->isFeatureCallWaitingDistiquishNotProvisionedEnabled();
       
   167     QVERIFY( verify() );
       
   168 }
       
   169 
       
   170 /*!
       
   171   UT_PsUiUtils::::t_isPhoneOffline
       
   172  */
       
   173 void UT_PsUiUtils::t_isPhoneOffline()
       
   174 {
       
   175     expect("XQSysInfo::isSupported");
       
   176     mWrapper->isPhoneOffline();
       
   177     QVERIFY( verify() );
       
   178 }
       
   179 
       
   180 QTEST_MAIN_S60(UT_PsUiUtils)