cellular/telephonysettings/xqbindings/psetwrapper/tsrc/ut_psetnetworkinfoconverter/ut_psetnetworkinfoconverter.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_psetnetworkinfoconverter.h"
       
    19 #include "psetnetworkinfoconverter.h"
       
    20 #include "qtestmains60.h"
       
    21 
       
    22 
       
    23 /*!
       
    24   UT_PSetNetworkInfoConverter::UT_PSetNetworkInfoConverter
       
    25  */
       
    26 UT_PSetNetworkInfoConverter::UT_PSetNetworkInfoConverter() 
       
    27 {
       
    28 }
       
    29 
       
    30 /*!
       
    31   UT_PSetNetworkInfoConverter::~UT_PSetNetworkInfoConverter
       
    32  */
       
    33 UT_PSetNetworkInfoConverter::~UT_PSetNetworkInfoConverter()
       
    34 {
       
    35 
       
    36 }
       
    37 
       
    38 /*!
       
    39   UT_PSetNetworkInfoConverter::init
       
    40  */
       
    41 void UT_PSetNetworkInfoConverter::init()
       
    42 {
       
    43     initialize();
       
    44 }
       
    45 
       
    46 /*!
       
    47   UT_PSetNetworkInfoConverter::cleanup
       
    48  */
       
    49 void UT_PSetNetworkInfoConverter::cleanup()
       
    50 {
       
    51     reset();
       
    52 }
       
    53 
       
    54 /*!
       
    55   UT_PSetNetworkInfoConverter::t_convertToSymbianTypeNetworkInfo
       
    56  */
       
    57 void UT_PSetNetworkInfoConverter::t_convertToSymbianTypeNetworkInfo()
       
    58 {
       
    59     _LIT(KCountryCode, "1234");         // country code max length is 4
       
    60     _LIT(KNetworkCode, "12345678");     // network code max length is 8
       
    61     PSetNetworkWrapper::NetworkId networkId = 
       
    62         { 
       
    63             QString::fromUtf16(KCountryCode().Ptr(), KCountryCode().Length()),
       
    64             QString::fromUtf16(KNetworkCode().Ptr(), KNetworkCode().Length()),
       
    65         };
       
    66     
       
    67     _LIT(KShortName, "shortNameMaxLength20");
       
    68     _LIT(KLongName, "longNameMaxLengthIs30LikeThis_");
       
    69     PSetNetworkWrapper::NetworkInfo info =
       
    70         {
       
    71             networkId,
       
    72             PSetNetworkWrapper::StatusUnknown,
       
    73             PSetNetworkWrapper::SelectionModeManual,
       
    74             PSetNetworkWrapper::AccessTypeGsm,
       
    75             QString::fromUtf16(KShortName().Ptr(), KShortName().Length()),
       
    76             QString::fromUtf16(KLongName().Ptr(), KLongName().Length()),
       
    77         };
       
    78     
       
    79     MPsetNetworkSelect::TNetworkInfo convertedInfo =
       
    80         NetworkInfoConverter::ConvertToSymbianType(info);
       
    81     
       
    82     QVERIFY(convertedInfo.iId.iCountryCode == KCountryCode());
       
    83     QVERIFY(convertedInfo.iId.iNetworkCode == KNetworkCode());
       
    84     QVERIFY(convertedInfo.iStatus == MPsetNetworkSelect::ENetStatUnknown);
       
    85     QVERIFY(convertedInfo.iMode == MPsetNetworkSelect::ENetSelectModeManual);
       
    86     QVERIFY(convertedInfo.iAccess == MPsetNetworkSelect::ENetNetworkGSM);
       
    87     QVERIFY(convertedInfo.iShortName == KShortName());
       
    88     QVERIFY(convertedInfo.iLongName == KLongName());
       
    89 }
       
    90 
       
    91 /*!
       
    92   UT_PSetNetworkInfoConverter::t_convertToSymbianTypeNetworkId
       
    93  */
       
    94 void UT_PSetNetworkInfoConverter::t_convertToSymbianTypeNetworkId()
       
    95 {
       
    96     _LIT(KCountryCode, "1234");
       
    97     _LIT(KNetworkCode, "12345678");
       
    98     PSetNetworkWrapper::NetworkId networkId = 
       
    99         { 
       
   100             QString::fromUtf16(KCountryCode().Ptr(), KCountryCode().Length()),
       
   101             QString::fromUtf16(KNetworkCode().Ptr(), KNetworkCode().Length()),
       
   102         };
       
   103     
       
   104     MPsetNetworkSelect::TNetworkId  convertedType =
       
   105         NetworkInfoConverter::ConvertToSymbianType(networkId);
       
   106     QVERIFY(convertedType.iCountryCode == KCountryCode());
       
   107     QVERIFY(convertedType.iNetworkCode == KNetworkCode());
       
   108 }
       
   109 
       
   110 /*!
       
   111   UT_PSetNetworkInfoConverter::t_convertToSymbianTypeNetworkStatus
       
   112  */
       
   113 void UT_PSetNetworkInfoConverter::t_convertToSymbianTypeNetworkStatus()
       
   114 {
       
   115     MPsetNetworkSelect::TNetworkStatus convertedType =
       
   116         NetworkInfoConverter::ConvertToSymbianType(
       
   117             PSetNetworkWrapper::StatusUnknown);
       
   118     QVERIFY(MPsetNetworkSelect::ENetStatUnknown == convertedType);
       
   119     
       
   120     convertedType = NetworkInfoConverter::ConvertToSymbianType(
       
   121         PSetNetworkWrapper::StatusAvailable);
       
   122     QVERIFY(MPsetNetworkSelect::ENetStatAvailable == convertedType);
       
   123     
       
   124     convertedType = NetworkInfoConverter::ConvertToSymbianType(
       
   125         PSetNetworkWrapper::StatusCurrent);
       
   126     QVERIFY(MPsetNetworkSelect::ENetStatCurrent == convertedType);
       
   127     
       
   128     convertedType = NetworkInfoConverter::ConvertToSymbianType(
       
   129         PSetNetworkWrapper::StatusForbidden);
       
   130     QVERIFY(MPsetNetworkSelect::ENetStatForbidden == convertedType);
       
   131 }
       
   132 
       
   133 /*!
       
   134   UT_PSetNetworkInfoConverter::t_convertToSymbianTypeNetworkSelectionMode
       
   135  */
       
   136 void UT_PSetNetworkInfoConverter::t_convertToSymbianTypeNetworkSelectionMode()
       
   137 {
       
   138     MPsetNetworkSelect::TSelectMode convertedType =
       
   139         NetworkInfoConverter::ConvertToSymbianType(
       
   140             PSetNetworkWrapper::SelectionModeAutomatic);
       
   141     QVERIFY(MPsetNetworkSelect::ENetSelectModeAutomatic == convertedType);
       
   142     
       
   143     convertedType = NetworkInfoConverter::ConvertToSymbianType(
       
   144         PSetNetworkWrapper::SelectionModeManual);
       
   145     QVERIFY(MPsetNetworkSelect::ENetSelectModeManual == convertedType);
       
   146 }
       
   147 
       
   148 /*!
       
   149   UT_PSetNetworkInfoConverter::t_convertToSymbianTypeNetworkAccessType
       
   150  */
       
   151 void UT_PSetNetworkInfoConverter::t_convertToSymbianTypeNetworkAccessType()
       
   152 {
       
   153     MPsetNetworkSelect::TNetworkAccess convertedType =
       
   154         NetworkInfoConverter::ConvertToSymbianType(
       
   155             PSetNetworkWrapper::AccessTypeGsm);
       
   156     QVERIFY(MPsetNetworkSelect::ENetNetworkGSM == convertedType);
       
   157     
       
   158     convertedType = NetworkInfoConverter::ConvertToSymbianType(
       
   159         PSetNetworkWrapper::AccessTypeWcdma);
       
   160     QVERIFY(MPsetNetworkSelect::ENetNetworkWCDMA == convertedType);
       
   161 }
       
   162 
       
   163 /*!
       
   164   UT_PSetNetworkInfoConverter::t_convertToQtTypeNetworkSelectionMode
       
   165  */
       
   166 void UT_PSetNetworkInfoConverter::t_convertToQtTypeNetworkSelectionMode()
       
   167 {
       
   168     PSetNetworkWrapper::NetworkSelectionMode convertedType =
       
   169         NetworkInfoConverter::ConvertToQtType(
       
   170             MPsetNetworkSelect::ENetSelectModeAutomatic);
       
   171     QVERIFY(PSetNetworkWrapper::SelectionModeAutomatic == convertedType);
       
   172     
       
   173     convertedType = NetworkInfoConverter::ConvertToQtType(
       
   174         MPsetNetworkSelect::ENetSelectModeManual);
       
   175     QVERIFY(PSetNetworkWrapper::SelectionModeManual == convertedType);
       
   176 }
       
   177 
       
   178 QTEST_MAIN_S60(UT_PSetNetworkInfoConverter)