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