remotemgmt_plat/syncml_ds_customization_api/tsrc/operatorsettings/nsmldsoperatorsettings_test.cpp
changeset 60 eb6690d0d439
equal deleted inserted replaced
55:1c556dee8eb1 60:eb6690d0d439
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Operator settings unit tests
       
    15 *
       
    16 */
       
    17 
       
    18 // INTERNAL INCLUDES
       
    19 #include "nsmldsoperatorsettings_test.h"
       
    20 
       
    21 // EXTERNAL INCLUDES
       
    22 #include <NSmlDSOperatorSettings.h>
       
    23 #include <EUnitMacros.h>
       
    24 #include <centralrepository.h> //CRepository
       
    25 #include <nsmloperatordatacrkeys.h> // KCRUidOperatorDatasyncInternalKeys
       
    26 
       
    27 // CONSTANTS
       
    28 
       
    29 // - Construction -----------------------------------------------------------
       
    30 
       
    31 CNSmlDSOperatorSettings_Test* CNSmlDSOperatorSettings_Test::NewL()
       
    32     {
       
    33     CNSmlDSOperatorSettings_Test* self = CNSmlDSOperatorSettings_Test::NewLC();
       
    34     CleanupStack::Pop( self );
       
    35     return self;
       
    36     }
       
    37 
       
    38 CNSmlDSOperatorSettings_Test* CNSmlDSOperatorSettings_Test::NewLC()
       
    39     {
       
    40     CNSmlDSOperatorSettings_Test* self = new( ELeave ) CNSmlDSOperatorSettings_Test();
       
    41     CleanupStack::PushL( self );
       
    42     self->ConstructL();
       
    43     return self;
       
    44     }
       
    45 
       
    46 CNSmlDSOperatorSettings_Test::~CNSmlDSOperatorSettings_Test()
       
    47     {
       
    48 
       
    49     }
       
    50 
       
    51 CNSmlDSOperatorSettings_Test::CNSmlDSOperatorSettings_Test()
       
    52     {
       
    53     
       
    54     }
       
    55 
       
    56 void CNSmlDSOperatorSettings_Test::ConstructL()
       
    57     {
       
    58     CEUnitTestSuiteClass::ConstructL();
       
    59     CRepository* rep = CRepository::NewL( KCRUidOperatorDatasyncInternalKeys );
       
    60     rep->Reset();
       
    61     delete rep;
       
    62     }
       
    63 
       
    64 // - Setup & teardown ---------------------------------------------------------
       
    65 
       
    66 // ++++++++++++ SETUP METHODS ++++++++++++
       
    67 
       
    68 void CNSmlDSOperatorSettings_Test::SetupL()
       
    69     {
       
    70     iOperatorSettings = CNSmlDSOperatorSettings::NewL();
       
    71     }
       
    72 
       
    73 //// ++++++++++++ TEARDOWN METHODS ++++++++++++
       
    74 //
       
    75 void CNSmlDSOperatorSettings_Test::Teardown()
       
    76     {
       
    77     delete iOperatorSettings;
       
    78     iOperatorSettings = NULL;
       
    79     }
       
    80 
       
    81 // - Test methods -------------------------------------------------------------
       
    82 
       
    83 // MEMORY ALLOCATION FOR DATASTORE
       
    84 void CNSmlDSOperatorSettings_Test::NewLL()
       
    85     {
       
    86     CNSmlDSOperatorSettings* settings = NULL;
       
    87     EUNIT_ASSERT_NO_LEAVE( settings = CNSmlDSOperatorSettings::NewL() );
       
    88     EUNIT_ASSERT( settings );
       
    89     delete settings;
       
    90     }
       
    91 
       
    92 void CNSmlDSOperatorSettings_Test::IsOperatorProfileLL()
       
    93     {
       
    94     EUNIT_ASSERT( iOperatorSettings->IsOperatorProfileL( _L("www.test.com") ) )
       
    95     EUNIT_ASSERT( !iOperatorSettings->IsOperatorProfileL( _L("www.test2.com") ) )    
       
    96     }
       
    97 
       
    98 void CNSmlDSOperatorSettings_Test::CustomSwvValueLCL()
       
    99     {
       
   100     HBufC8* swv( NULL );
       
   101     swv = iOperatorSettings->CustomSwvValueLC();
       
   102     EUNIT_PRINT( *swv );
       
   103     if( swv->Compare( _L8("1.0") ) != 0 )
       
   104         {
       
   105         EUNIT_FAIL_TEST( "Wrong software value" );
       
   106         }
       
   107     CleanupStack::PopAndDestroy( swv );
       
   108     }
       
   109 
       
   110 void CNSmlDSOperatorSettings_Test::CustomModValueLCL()
       
   111     {
       
   112     HBufC8* model( NULL );
       
   113     model = iOperatorSettings->CustomModValueLC();
       
   114     EUNIT_PRINT( *model );
       
   115     if( model->Compare( _L8("Mod") ) != 0 )
       
   116         {
       
   117         EUNIT_FAIL_TEST( "Wrong model value" );
       
   118         }
       
   119     CleanupStack::PopAndDestroy( model );
       
   120     }
       
   121 
       
   122 void CNSmlDSOperatorSettings_Test::CustomManValueLCL()
       
   123     {
       
   124     HBufC8* manufacturer( NULL );
       
   125     manufacturer = iOperatorSettings->CustomManValueLC();
       
   126     EUNIT_PRINT( *manufacturer );
       
   127     if( manufacturer->Compare( _L8("Nokia") ) != 0 )
       
   128         {
       
   129         EUNIT_FAIL_TEST( "Wrong manufacturer value" );
       
   130         }
       
   131     CleanupStack::PopAndDestroy( manufacturer );
       
   132     }
       
   133 
       
   134 
       
   135 void CNSmlDSOperatorSettings_Test::PopulateStatusCodeListLL()
       
   136     {
       
   137     RArray< TInt > statusCodeArray;
       
   138     iOperatorSettings->PopulateStatusCodeListL( statusCodeArray );
       
   139     for( TInt i = 0; i < statusCodeArray.Count(); i++ )
       
   140         {
       
   141         TBuf<10> code;
       
   142         TInt j = statusCodeArray[ i ];
       
   143         code.AppendNum( j );
       
   144         EUNIT_PRINT( code );
       
   145         }
       
   146 
       
   147     EUNIT_ASSERT( statusCodeArray[ 0 ] == 211 );
       
   148     EUNIT_ASSERT( statusCodeArray[ 1 ] == 400 );
       
   149     EUNIT_ASSERT( statusCodeArray[ 2 ] == 401 );
       
   150     EUNIT_ASSERT( !( statusCodeArray[ 3 ] == 401 ) );
       
   151 
       
   152     statusCodeArray.Close();
       
   153     }
       
   154 
       
   155 // - EUnit test table -------------------------------------------------------
       
   156 
       
   157 EUNIT_BEGIN_TEST_TABLE(
       
   158     CNSmlDSOperatorSettings_Test,
       
   159     "Unit test for operator settings",
       
   160     "UNIT" )
       
   161 
       
   162 EUNIT_TEST(
       
   163     "Test to verify memory allocation for the object",
       
   164     "CNSmlDSOperatorSettings",
       
   165     "NewL",
       
   166     "FUNCTIONALITY",
       
   167     Empty, NewLL, Empty)
       
   168 
       
   169 EUNIT_TEST(
       
   170     "Test to if profile is operator profile",
       
   171     "CNSmlDSOperatorSettings",
       
   172     "IsOperatorProfileL",
       
   173     "FUNCTIONALITY",
       
   174     SetupL, IsOperatorProfileLL, Teardown )
       
   175 
       
   176 EUNIT_TEST(
       
   177     "Test to verify Swv value",
       
   178     "CNSmlDSOperatorSettings",
       
   179     "CustomSwvValueLC",
       
   180     "FUNCTIONALITY",
       
   181     SetupL, CustomSwvValueLCL, Teardown )
       
   182 
       
   183 EUNIT_TEST(
       
   184     "Test to verify Model value",
       
   185     "CNSmlDSOperatorSettings",
       
   186     "CustomModValueLC",
       
   187     "FUNCTIONALITY",
       
   188     SetupL, CustomModValueLCL, Teardown )
       
   189 
       
   190 EUNIT_TEST(
       
   191     "Test to verify Manufacture value",
       
   192     "CNSmlDSOperatorSettings",
       
   193     "CustomManValueLC",
       
   194     "FUNCTIONALITY",
       
   195     SetupL, CustomManValueLCL, Teardown )
       
   196 
       
   197 EUNIT_TEST(
       
   198     "Test to verify status code values",
       
   199     "CNSmlDSOperatorSettings",
       
   200     "PopulateStatusCodeListL",
       
   201     "FUNCTIONALITY",
       
   202     SetupL, PopulateStatusCodeListLL, Teardown )
       
   203 
       
   204 EUNIT_END_TEST_TABLE
       
   205 
       
   206 //  End of File