wvsettings20/tsrc/basic/private/src/wvsapsettingstestCases.cpp
branchRCL_3
changeset 13 a941bc465d9f
parent 0 094583676ce7
equal deleted inserted replaced
12:6ca72c0fe49a 13:a941bc465d9f
       
     1 /*
       
     2 * Copyright (c) 2002 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: SAP settings test cases
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <e32math.h>
       
    22 #include <e32debug.h>
       
    23 
       
    24 // Classes under test include
       
    25 #include "IMPSSAPSettingsStoreTestUtils.h"
       
    26 
       
    27 #include "wvsapsettingstest.h"
       
    28 
       
    29 #include <S32strm.h>
       
    30 #include <S32mem.h>
       
    31 
       
    32 #include <CImpssapsettingsstore.h>
       
    33 
       
    34 #include <CImpssapsettings.h>
       
    35 
       
    36 #include <CIMPSSAPSettingsList.h>
       
    37 
       
    38 #include <IMPSSAPSettingsStoreDefinitions.h>
       
    39 #include <IMPSSAPSettingsStoreCenRepUids.h>
       
    40 #include <IMPSSAPSettingsStorePanics.h>
       
    41 
       
    42 //Obersever class
       
    43 
       
    44 #include "WVSAPSettingsObserverTestCases.h"
       
    45 
       
    46 #define STIF_TRAP( err, operation ) \
       
    47     TRAP( err, operation ); \
       
    48     if( err == KErrNoMemory ) \
       
    49         { \
       
    50         User::Leave( KErrNoMemory ); \
       
    51         } \
       
    52      
       
    53 
       
    54 //FORWARD DECLARATIONS
       
    55 
       
    56 class CIMPSSAPSettingsStore;
       
    57 class CIMPSSAPSettings;
       
    58 class cimpssapsettingsstoretestobserver;
       
    59 
       
    60 // ============================= LOCAL FUNCTIONS ===============================
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // ?function_name ?description.
       
    64 // ?description
       
    65 // Returns: ?value_1: ?description
       
    66 //          ?value_n: ?description_line1
       
    67 //                    ?description_line2
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 /*
       
    71 ?type ?function_name(
       
    72     ?arg_type arg,  // ?description
       
    73     ?arg_type arg)  // ?description
       
    74     {
       
    75 
       
    76     ?code  // ?comment
       
    77 
       
    78     // ?comment
       
    79     ?code
       
    80     }
       
    81 */
       
    82 
       
    83 // ============================ MEMBER FUNCTIONS ===============================
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // Cwvsapsettingstest::Case
       
    87 // Returns a test case by number.
       
    88 //
       
    89 // This function contains an array of all available test cases
       
    90 // i.e pair of case name and test function. If case specified by parameter
       
    91 // aCaseNumber is found from array, then that item is returned.
       
    92 //
       
    93 // The reason for this rather complicated function is to specify all the
       
    94 // test cases only in one place. It is not necessary to understand how
       
    95 // function pointers to class member functions works when adding new test
       
    96 // cases. See function body for instructions how to add new test case.
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 const TCaseInfo Cwvsapsettingstest::Case (
       
   100     const TInt aCaseNumber ) const
       
   101     {
       
   102 
       
   103     /**
       
   104     * To add new test cases, implement new test case function and add new
       
   105     * line to KCases array specify the name of the case and the function
       
   106     * doing the test case
       
   107     * In practice, do following
       
   108     * 1) Make copy of existing test case function and change its name
       
   109     *    and functionality. Note that the function must be added to
       
   110     *    wvsapsettingstest.cpp file and to wvsapsettingstest.h
       
   111     *    header file.
       
   112     *
       
   113     * 2) Add entry to following KCases array either by using:
       
   114     *
       
   115     * 2.1: FUNCENTRY or ENTRY macro
       
   116     * ENTRY macro takes two parameters: test case name and test case
       
   117     * function name.
       
   118     *
       
   119     * FUNCENTRY macro takes only test case function name as a parameter and
       
   120     * uses that as a test case name and test case function name.
       
   121     *
       
   122     * Or
       
   123     *
       
   124     * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
       
   125     * only with OOM (Out-Of-Memory) testing!
       
   126     *
       
   127     * OOM_ENTRY macro takes five parameters: test case name, test case
       
   128     * function name, TBool which specifies is method supposed to be run using
       
   129     * OOM conditions, TInt value for first heap memory allocation failure and
       
   130     * TInt value for last heap memory allocation failure.
       
   131     *
       
   132     * OOM_FUNCENTRY macro takes test case function name as a parameter and uses
       
   133     * that as a test case name, TBool which specifies is method supposed to be
       
   134     * run using OOM conditions, TInt value for first heap memory allocation
       
   135     * failure and TInt value for last heap memory allocation failure.
       
   136     */
       
   137 
       
   138     static TCaseInfoInternal const KCases[] =
       
   139         {
       
   140         // To add new test cases, add new items to this array
       
   141 
       
   142         // NOTE: When compiled to GCCE, there must be Classname::
       
   143         // declaration in front of the method name, e.g.
       
   144         // Cwvsapsettingstest::PrintTest. Otherwise the compiler
       
   145         // gives errors.
       
   146 
       
   147         //FUNCENTRY( Cwvsapsettingstest::PrintTest ),
       
   148         //ENTRY( "Loop test", Cwvsapsettingstest::LoopTest ),
       
   149         // Example how to use OOM functionality
       
   150         //OOM_ENTRY( "Loop test with OOM", Cwvsapsettingstest::LoopTest, ETrue, 2, 3),
       
   151         //OOM_FUNCENTRY( Cwvsapsettingstest::PrintTest, ETrue, 1, 3 ),
       
   152 
       
   153         ENTRY( "SetupEmpty SAP", Cwvsapsettingstest::SetupEmptySAPL ),
       
   154         ENTRY( "Setup Partially Filled SAP", Cwvsapsettingstest::SetupPartiallyFilledSAPL ),
       
   155         ENTRY( "Setup Complete SAP", Cwvsapsettingstest::SetupFullSAPL ),
       
   156         ENTRY( "Test Data Set and Get APIs", Cwvsapsettingstest::Test_DataSetAndGetL ),
       
   157         ENTRY( "TestBrand Protection Store", Cwvsapsettingstest::TestBrandProtection_StoreL ),
       
   158         ENTRY( "TestBrand Protection Update", Cwvsapsettingstest::TestBrandProtection_UpdateL ),
       
   159         ENTRY( "TestBrand Protection Delete", Cwvsapsettingstest::TestBrandProtection_DeleteL ),
       
   160         ENTRY( "Test Login Count", Cwvsapsettingstest::TestLoginCountHandlingL ),
       
   161         ENTRY( "Test Login Count Storage", Cwvsapsettingstest::TestLoginCountStorageL ),
       
   162         ENTRY( "Test Externalize and Internalize", Cwvsapsettingstest::TestSAPContainerExternalizeInternalizeL ),
       
   163         ENTRY( "Test Pack-Unpack", Cwvsapsettingstest::TestSAPContainerPackUnpackL ),
       
   164         ENTRY( "Test Key Value pair", Cwvsapsettingstest::TestSAPContainerKeyValuePairsL ),
       
   165         ENTRY( "Test SAP Container Copy", Cwvsapsettingstest::TestSAPContainerCopyL ),
       
   166         ENTRY( "Test PopulateSettingsList", Cwvsapsettingstest::TestPopulateSettingsListL ),
       
   167         ENTRY( "Test SettingsList Ascend", Cwvsapsettingstest::TestIterateTroughSettingsListAscendL ),
       
   168         ENTRY( "Test SettingsList Descend", Cwvsapsettingstest::TestIterateTroughSettingsListDescendL ),
       
   169         ENTRY( "Test Obs for Adding SAP", Cwvsapsettingstest::TestObsForAddingSAP ),
       
   170         ENTRY( "Test Obs for Remove SAP", Cwvsapsettingstest::TestObsForRemoveSAP ),
       
   171 
       
   172         };
       
   173 
       
   174     // Verify that case number is valid
       
   175     if ( ( TUint ) aCaseNumber >= sizeof( KCases ) /
       
   176          sizeof( TCaseInfoInternal ) )
       
   177         {
       
   178         // Invalid case, construct empty object
       
   179         TCaseInfo null( ( const TText* ) L"" );
       
   180         null.iMethod = NULL;
       
   181         null.iIsOOMTest = EFalse;
       
   182         null.iFirstMemoryAllocation = 0;
       
   183         null.iLastMemoryAllocation = 0;
       
   184         return null;
       
   185         }
       
   186 
       
   187     // Construct TCaseInfo object and return it
       
   188     TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
       
   189     tmp.iMethod = KCases[ aCaseNumber ].iMethod;
       
   190     tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
       
   191     tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
       
   192     tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
       
   193     return tmp;
       
   194 
       
   195     }
       
   196 
       
   197 // -----------------------------------------------------------------------------
       
   198 // Cwvsapsettingstest::PrintTest
       
   199 // Simple printing to UI test.
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 TInt Cwvsapsettingstest::PrintTest(
       
   203     TTestResult& aResult )
       
   204     {
       
   205     /* Simple print test */
       
   206     _LIT( KPrintTest, "PrintTest" );
       
   207     _LIT( KEnter, "Enter" );
       
   208     _LIT( KOnGoing, "On-going" );
       
   209     _LIT( KExit, "Exit" );
       
   210 
       
   211     TestModuleIf().Printf( 0, KPrintTest, KEnter );
       
   212 
       
   213     TestModuleIf().Printf( 1, KPrintTest, KOnGoing );
       
   214 
       
   215     TestModuleIf().Printf( 0, KPrintTest, KExit );
       
   216 
       
   217     // Test case passed
       
   218 
       
   219     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   220     _LIT( KDescription, "PrintTest passed" );
       
   221     aResult.SetResult( KErrNone, KDescription );
       
   222 
       
   223     // Case was executed
       
   224     return KErrNone;
       
   225 
       
   226     }
       
   227 
       
   228 // -----------------------------------------------------------------------------
       
   229 // Cwvsapsettingstest::LoopTest
       
   230 // Another printing to UI test.
       
   231 // -----------------------------------------------------------------------------
       
   232 //
       
   233 TInt Cwvsapsettingstest::LoopTest( TTestResult& aResult )
       
   234     {
       
   235 
       
   236     /* Simple print and wait loop */
       
   237     _LIT( KState, "State" );
       
   238     _LIT( KLooping, "Looping" );
       
   239 
       
   240     TestModuleIf().Printf( 0, KState, KLooping );
       
   241 
       
   242     _LIT( KRunning, "Running" );
       
   243     _LIT( KLoop, "%d" );
       
   244     for ( TInt i = 0; i < 10; i++ )
       
   245         {
       
   246         TestModuleIf().Printf( 1, KRunning, KLoop, i );
       
   247         User::After( 1000000 );
       
   248         }
       
   249 
       
   250     _LIT( KFinished, "Finished" );
       
   251     TestModuleIf().Printf( 0, KState, KFinished );
       
   252 
       
   253     // Test case passed
       
   254 
       
   255     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   256     _LIT( KDescription, "LoopTest passed" );
       
   257     aResult.SetResult( KErrNone, KDescription );
       
   258 
       
   259     // Case was executed
       
   260     return KErrNone;
       
   261 
       
   262     }
       
   263 
       
   264 TInt Cwvsapsettingstest::SetupEmptySAPL( TTestResult& aResult )
       
   265     {
       
   266 
       
   267     //Create and initialize iSAP and iTempSAP.
       
   268     iSAP = CIMPSSAPSettings::NewL();
       
   269     iTempSAP = CIMPSSAPSettings::NewL();
       
   270 
       
   271     _LIT ( KNullValue , "" );
       
   272     //This is the test case for empty SAP,
       
   273     //verify the values with empty strings and empty values.
       
   274     //This will also test the Get methods on null and empty values.
       
   275 
       
   276     if ( ( iSAP->SAPName() != KNullValue ) ||
       
   277          ( iSAP->SAPUserPassword() != KNullValue ) ||
       
   278          ( iSAP->HTTPProxyAddress() != KNullValue ) ||
       
   279          ( iSAP->HTTPProxyUserPassword() != KNullValue ) ||
       
   280          ( iSAP->AccessPoint() != 0 ) || //Check the default value of AccessPoint
       
   281          ( iSAP->AccessGroup() != EIMPSNoAccessGroup )
       
   282 
       
   283        )
       
   284 
       
   285         {
       
   286         return KErrArgument;
       
   287         }
       
   288     else
       
   289         {
       
   290         return KErrNone;
       
   291         }
       
   292 
       
   293     }
       
   294 
       
   295 
       
   296 TInt Cwvsapsettingstest::SetupPartiallyFilledSAPL( TTestResult& aResult )
       
   297     {
       
   298 
       
   299     iSAP = CIMPSSAPSettings::NewL();
       
   300     iTempSAP = CIMPSSAPSettings::NewL();
       
   301 
       
   302     iSAP->SetSAPNameL( _L( "name" ) );
       
   303     iSAP->SetSAPUserPasswordL( _L( "pass" ) );
       
   304     iSAP->SetHTTPProxyAddressL( KNullDesC );
       
   305     iSAP->SetHTTPProxyUserPasswordL( KNullDesC );
       
   306     iSAP->SetAccessPoint( 123 );
       
   307     iSAP->SetAccessGroup( EIMPSIMAccessGroup );
       
   308 
       
   309 
       
   310     //Use the getter methods and check if iSAP is set to
       
   311     //the values that are passed.
       
   312     _LIT( KName , "name" );
       
   313     _LIT( KPassword, "pass" );
       
   314 
       
   315     if ( ( iSAP->SAPName() != KName ) ||
       
   316          ( iSAP->SAPUserPassword() != KPassword ) ||
       
   317          ( iSAP->HTTPProxyAddress() != KNullDesC ) ||
       
   318          ( iSAP->HTTPProxyUserPassword() != KNullDesC ) ||
       
   319          ( iSAP->AccessPoint() != 123 ) || //Check the default value of AccessPoint
       
   320          ( iSAP->AccessGroup() != EIMPSIMAccessGroup )
       
   321 
       
   322        )
       
   323 
       
   324         {
       
   325         return KErrArgument;
       
   326         }
       
   327     else
       
   328         {
       
   329         return KErrNone;
       
   330         }
       
   331 
       
   332     }
       
   333 
       
   334 TInt Cwvsapsettingstest::SetupFullSAPL( TTestResult& aResult )
       
   335     {
       
   336 
       
   337     iSAP = CIMPSSAPSettings::NewL();
       
   338     iTempSAP = CIMPSSAPSettings::NewL();
       
   339 
       
   340     IMPSSAPSettingsStoreTestUtils::FillContainerLongDataL( *iSAP );
       
   341     iSAP->ProtectL( ESAPBrandProtection );
       
   342 
       
   343     return 0;
       
   344     }
       
   345 
       
   346 
       
   347 
       
   348 // TEST METHODS
       
   349 TInt Cwvsapsettingstest::Test_DataSetAndGetL( TTestResult& aResult )
       
   350     {
       
   351 
       
   352     SetupSchedulerL();
       
   353 
       
   354     CIMPSSAPSettings* sap = CIMPSSAPSettings::NewL();
       
   355     CIMPSSAPSettings* sap1 = CIMPSSAPSettings::NewL();
       
   356 
       
   357 
       
   358     TInt err = KErrNone;
       
   359 
       
   360     _LIT( KDummy, "strng" );
       
   361 
       
   362     sap->ProtectL( ESAPNoProtection );
       
   363     sap->SetSAPNameL( _L( "strng" ) );
       
   364     sap->SetSAPAddressL( _L( "strng" ) ) ;
       
   365     sap->SetSAPPort( 1 );
       
   366     sap->SetSAPUserIdL( _L( "strng" ) );
       
   367     sap->SetSAPUserPasswordL( _L( "strng" ) );
       
   368     sap->SetHTTPProxyAddressL( _L( "strng" ) );
       
   369     sap->SetHTTPProxyUserIdL( _L( "strng" ) );
       
   370     sap->SetHTTPProxyUserPasswordL( _L( "strng" ) );
       
   371     sap->SetHTTPProxyPort( 1 );
       
   372 
       
   373     sap->SetAccessPoint( 1 );
       
   374     sap->SetClientIdL( _L( "strng" ) );
       
   375     sap->ProtectL( ESAPBrandProtection );
       
   376 
       
   377     iStore = CIMPSSAPSettingsStore::NewL();
       
   378     IMPSSAPSettingsStoreTestUtils::DeleteAllSAPSettingsL( *iStore );
       
   379 
       
   380     TUint32 uid = 0;
       
   381     uid = iStore->StoreNewSAPL( sap, EIMPSIMAccessGroup ) ;
       
   382 
       
   383     iStore->GetSAPL( uid, sap1 );
       
   384 
       
   385     // Set APIs are alreday tested in test cases (1) and (2).
       
   386     //Use the get APIs for testing.
       
   387 
       
   388     if (	( sap1->SAPName() != KDummy ) ||
       
   389          ( sap1->SAPAddress() != KDummy ) ||
       
   390          ( sap1->SAPPort() != 1 ) ||
       
   391          ( sap1->SAPUserId() != KDummy ) ||
       
   392          ( sap1->SAPUserPassword() != KDummy ) ||
       
   393          ( sap1->SAPUserPassword() != KDummy ) ||
       
   394          ( sap1->HTTPProxyAddress() != KDummy ) ||
       
   395          ( sap1->HTTPProxyUserId() != KDummy ) ||
       
   396          ( sap1->HTTPProxyUserPassword() != KDummy ) ||
       
   397          ( sap1->HTTPProxyPort() != 1 ) ||
       
   398          ( sap1->AccessPoint() != 1 ) ||
       
   399          ( sap1->ClientId() != KDummy )
       
   400        )
       
   401         {
       
   402         err = KErrArgument;
       
   403         }
       
   404 
       
   405     CloseScheduler();
       
   406 
       
   407     return err;
       
   408     }
       
   409 
       
   410 
       
   411 TInt Cwvsapsettingstest::TestBrandProtection_StoreL( TTestResult& aResult )
       
   412     {
       
   413 
       
   414     SetupSchedulerL();
       
   415 
       
   416     CIMPSSAPSettings* sap1 = CIMPSSAPSettings::NewLC();
       
   417 
       
   418     //Create the SettingsStore and delete any existing Settings
       
   419     iStore = CIMPSSAPSettingsStore::NewL();
       
   420     IMPSSAPSettingsStoreTestUtils::DeleteAllSAPSettingsL( *iStore );
       
   421 
       
   422     IMPSSAPSettingsStoreTestUtils::FillContainerLongDataL( *sap1 );
       
   423 
       
   424     //Fill the SAPContainer
       
   425     ///IMPSSAPSettingsStoreTestUtils::FillContainerL(*sap1, _L("SettingsFilled") );
       
   426     sap1->ProtectL( ESAPBrandProtection );
       
   427 
       
   428     //TUint32 uid = iStore->StoreNewSAPL( sap1, EIMPSIMAccessGroup );
       
   429 
       
   430 
       
   431     //_LIT(Kname, "newsap1");
       
   432     //sap1->SetSAPNameL(Kname);
       
   433 
       
   434     TUint32 uid = 0;
       
   435     TRAPD( err, uid = iStore->StoreNewSAPL( sap1, EIMPSIMAccessGroup ) );
       
   436 
       
   437 
       
   438     //Null SAP settings in sap2.
       
   439     CIMPSSAPSettings* sap2 = CIMPSSAPSettings::NewLC();
       
   440 
       
   441     if ( err == KErrNone )
       
   442         {
       
   443         //See whether sap1 is correctly stored or not using Get method.
       
   444         iStore->GetSAPL( uid, sap2 );
       
   445         }
       
   446 
       
   447     if ( IMPSSAPSettingsStoreTestUtils::Equals( *sap1, *sap2 ) )
       
   448         {
       
   449         err = KErrNone;
       
   450         }
       
   451     else
       
   452         {
       
   453         err = KErrArgument;
       
   454         }
       
   455 
       
   456     CleanupStack::PopAndDestroy( 2 ); //sap1 , sap2
       
   457     CloseScheduler();
       
   458 
       
   459     return err;
       
   460     }
       
   461 
       
   462 
       
   463 TInt Cwvsapsettingstest::TestBrandProtection_UpdateL( TTestResult& aResult )
       
   464     {
       
   465 
       
   466     SetupSchedulerL();
       
   467 
       
   468     CIMPSSAPSettings* sap1 = CIMPSSAPSettings::NewLC();
       
   469     IMPSSAPSettingsStoreTestUtils::FillContainerLongDataL( *sap1 );
       
   470     sap1->ProtectL( ESAPBrandProtection );
       
   471 
       
   472     iStore = CIMPSSAPSettingsStore::NewL();
       
   473     IMPSSAPSettingsStoreTestUtils::DeleteAllSAPSettingsL( *iStore );
       
   474 
       
   475     TUint32 uid = iStore->StoreNewSAPL( sap1, EIMPSIMAccessGroup );
       
   476 
       
   477     sap1->SetAccessPoint( 1234 );
       
   478     iStore->UpdateOldSAPL( sap1, uid );
       
   479 
       
   480     CIMPSSAPSettings* sap2 = CIMPSSAPSettings::NewLC();
       
   481     iStore->GetSAPL( uid, sap2 );
       
   482 
       
   483     TInt err;
       
   484 
       
   485     //Test whether the update happened correctly.
       
   486     if ( IMPSSAPSettingsStoreTestUtils::Equals( *sap1, *sap2 ) )
       
   487         {
       
   488         err = KErrNone;
       
   489         }
       
   490     else
       
   491         {
       
   492         err = KErrArgument;
       
   493         }
       
   494 
       
   495     CleanupStack::PopAndDestroy( 2 ); //sap1 , sap2, istore
       
   496     CloseScheduler();
       
   497 
       
   498     return err;
       
   499 
       
   500     }
       
   501 
       
   502 
       
   503 TInt Cwvsapsettingstest::TestBrandProtection_DeleteL( TTestResult& aResult )
       
   504     {
       
   505 
       
   506     SetupSchedulerL();
       
   507 
       
   508     CIMPSSAPSettings* sap1 = CIMPSSAPSettings::NewLC();
       
   509     IMPSSAPSettingsStoreTestUtils::FillContainerLongDataL( *sap1 );
       
   510     sap1->ProtectL( ESAPBrandProtection );
       
   511 
       
   512     iStore = CIMPSSAPSettingsStore::NewL();
       
   513     IMPSSAPSettingsStoreTestUtils::DeleteAllSAPSettingsL( *iStore );
       
   514 
       
   515     TUint32 uid = iStore->StoreNewSAPL( sap1, EIMPSIMAccessGroup );
       
   516 
       
   517     TInt err = KErrNone;
       
   518 
       
   519     iStore->DeleteSAPL( uid );
       
   520 
       
   521     //We stored one new SAP, deleted the same sap1.
       
   522     //After deletion, the SAP count on the store must be 0.
       
   523     //If not 0, return error.
       
   524 
       
   525     if ( iStore->SAPCountL( EIMPSIMAccessGroup ) != 0 )
       
   526         {
       
   527         err = KErrGeneral;
       
   528         }
       
   529 
       
   530     CleanupStack::PopAndDestroy( 1 ); //sap1
       
   531 
       
   532     CloseScheduler();
       
   533 
       
   534     return err;
       
   535 
       
   536 
       
   537     }
       
   538 
       
   539 
       
   540 TInt Cwvsapsettingstest::TestLoginCountHandlingL( TTestResult& aResult )
       
   541     {
       
   542     CIMPSSAPSettings* sap = CIMPSSAPSettings::NewLC();
       
   543 
       
   544     TInt err = KErrNone;
       
   545     TInt err1 = KErrNone;
       
   546 
       
   547     //Initially LoginCount should be 0.
       
   548     if ( sap->LoginCount() != 0 )
       
   549         {
       
   550         err1 = KErrArgument;
       
   551         };
       
   552 
       
   553     sap->IncreaseLoginCount();
       
   554     if ( sap->LoginCount() != 1 )
       
   555         {
       
   556         err1 = KErrArgument;
       
   557         }
       
   558     err &= err1;
       
   559 
       
   560     sap->SetSAPNameL( _L( "strng" ) );
       
   561     if ( sap->LoginCount() != 1 )
       
   562         {
       
   563         err1 = KErrArgument;
       
   564         }
       
   565     err &= err1;
       
   566 
       
   567 
       
   568     sap->IncreaseLoginCount();
       
   569     sap->SetSAPAddressL( _L( "strng" ) );
       
   570     if ( sap->LoginCount() != 0 )
       
   571         {
       
   572         err1 = KErrArgument;
       
   573         }
       
   574     err &= err1;
       
   575 
       
   576 
       
   577     sap->IncreaseLoginCount();
       
   578     sap->SetSAPPort( 1 );
       
   579     if ( sap->LoginCount() != 0 )
       
   580         {
       
   581         err1 = KErrArgument;
       
   582         }
       
   583     err &= err1;
       
   584 
       
   585     sap->IncreaseLoginCount();
       
   586     sap->SetSAPUserIdL( _L( "strng" ) );
       
   587     if ( sap->LoginCount() != 0 )
       
   588         {
       
   589         err1 = KErrArgument;
       
   590         }
       
   591     err &= err1;
       
   592 
       
   593 
       
   594     sap->IncreaseLoginCount();
       
   595     sap->SetSAPUserPasswordL( _L( "strng" ) );
       
   596     if ( sap->LoginCount() != 0 )
       
   597         {
       
   598         err1 = KErrArgument;
       
   599         }
       
   600     err &= err1;
       
   601 
       
   602     sap->IncreaseLoginCount();
       
   603     sap->SetHTTPProxyAddressL( _L( "strng" ) );
       
   604     if ( sap->LoginCount() != 0 )
       
   605         {
       
   606         err1 = KErrArgument;
       
   607         }
       
   608     err &= err1;
       
   609 
       
   610 
       
   611     sap->IncreaseLoginCount();
       
   612     sap->SetHTTPProxyUserIdL( _L( "strng" ) );
       
   613     if ( sap->LoginCount() != 0 )
       
   614         {
       
   615         err1 = KErrArgument;
       
   616         }
       
   617     err &= err1;
       
   618 
       
   619     sap->IncreaseLoginCount();
       
   620     sap->SetHTTPProxyUserPasswordL( _L( "strng" ) );
       
   621     if ( sap->LoginCount() != 0 )
       
   622         {
       
   623         err1 = KErrArgument;
       
   624         }
       
   625     err &= err1;
       
   626 
       
   627 
       
   628     sap->IncreaseLoginCount();
       
   629     sap->SetHTTPProxyPort( 1 );
       
   630     if ( sap->LoginCount() != 0 )
       
   631         {
       
   632         err1 = KErrArgument;
       
   633         }
       
   634     err &= err1;
       
   635 
       
   636     sap->IncreaseLoginCount();
       
   637     sap->SetAccessPoint( 1 );
       
   638     if ( sap->LoginCount() != 0 )
       
   639         {
       
   640         err1 = KErrArgument;
       
   641         }
       
   642     err &= err1;
       
   643 
       
   644     sap->IncreaseLoginCount();
       
   645     sap->SetClientIdL( _L( "strng" ) );
       
   646     if ( sap->LoginCount() != 0 )
       
   647         {
       
   648         err1 = KErrArgument;
       
   649         }
       
   650     err &= err1;
       
   651 
       
   652 
       
   653     CleanupStack::PopAndDestroy(); //sap
       
   654 
       
   655     if ( err == KErrNone )
       
   656         {
       
   657         return err;
       
   658         }
       
   659     else
       
   660         {
       
   661         return KErrArgument;
       
   662         }
       
   663 
       
   664     }
       
   665 
       
   666 
       
   667 TInt Cwvsapsettingstest::TestLoginCountStorageL( TTestResult& aResult )
       
   668     {
       
   669 
       
   670     SetupSchedulerL();
       
   671 
       
   672     TInt err = KErrGeneral;
       
   673 
       
   674     CIMPSSAPSettings* sap1 = CIMPSSAPSettings::NewLC();
       
   675 
       
   676     iStore = CIMPSSAPSettingsStore::NewL();
       
   677     IMPSSAPSettingsStoreTestUtils::DeleteAllSAPSettingsL( *iStore );
       
   678 
       
   679     IMPSSAPSettingsStoreTestUtils::FillContainerLongDataL( *sap1 );
       
   680 
       
   681     //make the login count in sap1 as 2.
       
   682     sap1->IncreaseLoginCount();
       
   683     sap1->IncreaseLoginCount();
       
   684 
       
   685     //Login count has become 2.
       
   686     if ( sap1->LoginCount() == 2 )
       
   687         {
       
   688         err = KErrNone;
       
   689         }
       
   690 
       
   691     //store sap1 and get the uid of the transaction
       
   692     TUint32 uid = iStore->StoreNewSAPL( sap1, EIMPSIMAccessGroup );
       
   693 
       
   694     CIMPSSAPSettings* sap2 = CIMPSSAPSettings::NewLC();
       
   695 
       
   696     //Get the sap stored in iStore in sap2.
       
   697     iStore->GetSAPL( uid, sap2 );
       
   698 
       
   699 
       
   700     //Check the previous error code and login count of sap2 which has
       
   701     //just been read from the iStore
       
   702 
       
   703     if ( ( sap2->LoginCount() == 2 ) && ( err == KErrNone ) )
       
   704         {
       
   705         err = KErrNone;
       
   706         }
       
   707 
       
   708     CleanupStack::PopAndDestroy( 2 ); //sap1 , sap2
       
   709     CloseScheduler();
       
   710 
       
   711     return err;
       
   712     }
       
   713 
       
   714 
       
   715 TInt Cwvsapsettingstest::TestSAPContainerExternalizeInternalizeL( TTestResult& aResult )
       
   716     {
       
   717     CBufSeg* buffer = CBufSeg::NewL( 50000 );
       
   718     CleanupStack::PushL( buffer );
       
   719 
       
   720     RBufWriteStream wstream;
       
   721     wstream.Open( *buffer );
       
   722     CleanupClosePushL( wstream );
       
   723 
       
   724     CIMPSSAPSettings* iSAP = CIMPSSAPSettings::NewLC();
       
   725 
       
   726 
       
   727     iSAP->ExternalizeL( wstream );
       
   728     CleanupStack::PopAndDestroy(); //wstream
       
   729 
       
   730     RBufReadStream rstream;
       
   731     rstream.Open( *buffer );
       
   732     CleanupClosePushL( rstream );
       
   733 
       
   734     CIMPSSAPSettings* iTempSAP = CIMPSSAPSettings::NewLC();
       
   735     iTempSAP->InternalizeL( rstream );
       
   736 
       
   737     TInt err = KErrNone;
       
   738 
       
   739     if ( IMPSSAPSettingsStoreTestUtils::Equals( *iTempSAP, *iSAP ) )
       
   740         {
       
   741         //Internalized and Externalized strings are equal,
       
   742         //Just as a check also match Connection Settings and User Settings
       
   743         if ( iTempSAP->EqualConnectionSettings( *iSAP )  &&
       
   744              iTempSAP->EqualUserSettings( *iSAP ) )
       
   745             {
       
   746             err = KErrNone;
       
   747             }
       
   748 
       
   749         }
       
   750     else
       
   751         {
       
   752         err = KErrGeneral;
       
   753         }
       
   754 
       
   755 
       
   756     CleanupStack::PopAndDestroy(); //rstream
       
   757     CleanupStack::PopAndDestroy(); //buffer
       
   758 
       
   759     CleanupStack::PopAndDestroy( 2 );//iSAP,iTempSAP
       
   760 
       
   761     return err;
       
   762     }
       
   763 
       
   764 TInt Cwvsapsettingstest::TestSAPContainerPackUnpackL( TTestResult& aResult )
       
   765     {
       
   766 
       
   767     CIMPSSAPSettings* iSAP = CIMPSSAPSettings::NewLC();
       
   768 
       
   769 
       
   770     // Pack the SAP
       
   771     HBufC8* buff = iSAP->PackLC();
       
   772 
       
   773     CIMPSSAPSettings* iTempSAP = CIMPSSAPSettings::NewLC();
       
   774 
       
   775     // Unpack the SAP
       
   776     TPtrC8 buffPtr( buff->Des() );
       
   777     iTempSAP->UnPackL( buffPtr );
       
   778 
       
   779     TInt err;
       
   780 
       
   781     if ( IMPSSAPSettingsStoreTestUtils::Equals( *iTempSAP, *iSAP ) )
       
   782         {
       
   783         //Internalized and Externalized strings are equal,
       
   784         //Just as a check also match Connection Settings and User Settings
       
   785         if ( iTempSAP->EqualConnectionSettings( *iSAP )  &&
       
   786              iTempSAP->EqualUserSettings( *iSAP ) )
       
   787             {
       
   788             err = KErrNone;
       
   789             }
       
   790         else
       
   791             {
       
   792             err = KErrArgument;
       
   793             }
       
   794         }
       
   795     else
       
   796         {
       
   797         err = KErrGeneral;
       
   798         }
       
   799 
       
   800     CleanupStack::PopAndDestroy(); // buff
       
   801     CleanupStack::PopAndDestroy( 2 );//iSAP,iTempSAP
       
   802 
       
   803     return err;
       
   804     }
       
   805 
       
   806 TInt Cwvsapsettingstest::TestSAPContainerKeyValuePairsL( TTestResult& aResult )
       
   807     {
       
   808 
       
   809     CIMPSSAPSettings* iSAP = CIMPSSAPSettings::NewLC();
       
   810     CIMPSSAPSettings* iTempSAP = CIMPSSAPSettings::NewLC();
       
   811 
       
   812     //Test case for SetOpaqueInt , GetOpaqueInt and DeleteOpaque
       
   813     _LIT( KKey16, "key16" );
       
   814     _LIT( KKey8, "key8" );
       
   815     _LIT( KKeyInt, "keyint" );
       
   816 
       
   817     _LIT( KValue16, "value16" );
       
   818     _LIT8( KValue8, "value8" );
       
   819     const TInt KValueInt = 500;
       
   820 
       
   821     iSAP->SetOpaqueDesC16( KKey16, KValue16 );
       
   822     iSAP->SetOpaqueDesC8( KKey8, KValue8 );
       
   823     iSAP->SetOpaqueInt( KKeyInt, KValueInt );
       
   824 
       
   825     TPtrC16 stored16;
       
   826     TPtrC8 stored8;
       
   827     TInt storedInt;
       
   828 
       
   829     iSAP->GetOpaqueDesC16( KKey16, stored16 );
       
   830     iSAP->GetOpaqueDesC8( KKey8, stored8 );
       
   831     iSAP->GetOpaqueInt( KKeyInt, storedInt );
       
   832 
       
   833     TInt err, err1, err2;
       
   834     if ( ( stored16.Compare( KValue16 ) == 0 ) || ( stored8.Compare( KValue8 ) == 0 )
       
   835          || ( storedInt == KValueInt ) )
       
   836         {
       
   837         err1 = KErrNone;
       
   838 
       
   839         }
       
   840     else
       
   841         {
       
   842         err1 = KErrArgument;
       
   843         }
       
   844     if ( ( iSAP->DeleteOpaque( KKey16 ) == KErrNone ) || ( iSAP->DeleteOpaque( KKey8 ) == KErrNone )
       
   845          || ( iSAP->DeleteOpaque( KKeyInt ) == KErrNone ) )
       
   846         {
       
   847         err2 = KErrNone;
       
   848         }
       
   849     else
       
   850         {
       
   851         err2 = KErrArgument;
       
   852         }
       
   853 
       
   854     err = err1 & err2;
       
   855 
       
   856     CleanupStack::PopAndDestroy( 2 );//iSAP,iTempSAP
       
   857 
       
   858     return err;
       
   859 
       
   860     }
       
   861 
       
   862 TInt Cwvsapsettingstest::TestSAPContainerCopyL( TTestResult& aResult )
       
   863     {
       
   864 
       
   865     TInt err;
       
   866 
       
   867     CIMPSSAPSettings* iSAP = CIMPSSAPSettings::NewLC();
       
   868     CIMPSSAPSettings* destination = CIMPSSAPSettings::NewLC();
       
   869     destination->CopyL( *iSAP );
       
   870 
       
   871     if ( IMPSSAPSettingsStoreTestUtils::Equals( *destination, *iSAP ) )
       
   872         {
       
   873         if ( destination->AccessGroup() == iSAP->AccessGroup() )
       
   874             {
       
   875             err = KErrNone;
       
   876             }
       
   877         else
       
   878             {
       
   879             err = KErrArgument;
       
   880             }
       
   881         }
       
   882     else
       
   883         {
       
   884         err = KErrArgument;
       
   885         }
       
   886 
       
   887     CleanupStack::PopAndDestroy( 2 ); // destination , iSAP
       
   888 
       
   889     return err;
       
   890     }
       
   891 
       
   892 
       
   893 TInt Cwvsapsettingstest::TestPopulateSettingsListL( TTestResult& aResult )
       
   894     {
       
   895     //test:
       
   896     // 1. no SAPs defined
       
   897     // 2. 1 SAP defined
       
   898     // 3. 2 SAPs defined
       
   899     // 4. 10 SAPs defined
       
   900     // 5. 30 SAPs defined
       
   901 
       
   902     //Install the scheduler
       
   903     SetupSchedulerL();
       
   904 
       
   905     CIMPSSAPSettingsList* list = CIMPSSAPSettingsList::NewLC();
       
   906 
       
   907     //Instantiate SettingsStore with 1 entry
       
   908     iStore = CIMPSSAPSettingsStore::NewL();
       
   909     IMPSSAPSettingsStoreTestUtils::DeleteAllSAPSettingsL( *iStore );
       
   910 
       
   911     CIMPSSAPSettings* settings = CIMPSSAPSettings::NewL();
       
   912     CleanupStack::PushL( settings );
       
   913 
       
   914     IMPSSAPSettingsStoreTestUtils::FillContainerPartiallyL( *settings, _L( "PartiallyFilled" ) );
       
   915     iStore->StoreNewSAPL( settings, EIMPSIMAccessGroup );
       
   916 
       
   917     iStoredCount = 1;
       
   918 
       
   919     iStore->PopulateSAPSettingsListL( *list, EIMPSIMAccessGroup );
       
   920     //verify list count
       
   921     TUint32 count( 0 );
       
   922     count = list->MdcaCount();
       
   923 
       
   924     TInt err1 = KErrNone;
       
   925 
       
   926     if ( count == iStoredCount )
       
   927         {
       
   928         err1 = KErrNone;
       
   929         }
       
   930     else err1 = KErrArgument ;
       
   931 
       
   932     //verify direct store count
       
   933 
       
   934     TInt err2 = KErrNone;
       
   935 
       
   936     //istore must be equal to the number of elements on the SettingsList,
       
   937     //else there is some problem.
       
   938     if ( iStore->SAPCountL( EIMPSIMAccessGroup ) == iStoredCount )
       
   939         {
       
   940         err2 = KErrNone;
       
   941         }
       
   942     else err2 = KErrArgument;
       
   943 
       
   944     if ( err1 || err2 != KErrNone )
       
   945         {
       
   946         //return with a failure code since there was an error
       
   947         //since we are returning at this point itself,
       
   948         //PopandDestroy the list on the cleanupstack.
       
   949 
       
   950         CleanupStack::PopAndDestroy( 3 ); //list(CIMPSSAPSettingsList) ,iStore, settings
       
   951 
       
   952         iStoredCount = 0;
       
   953 
       
   954         CloseScheduler();
       
   955         return KErrArgument;
       
   956         }
       
   957 
       
   958 
       
   959     TUint32 uid;
       
   960     for ( TInt ii( 0 ); ii < iStoredCount; ii++  )
       
   961         {
       
   962         list->MdcaPoint( ii );
       
   963         uid = list->UidForIndex( ii );
       
   964 
       
   965         //From the uid, try to access the listitem.
       
   966         const CIMPSSAPSettingsListItem* item = list->ListItemForUid( uid  );
       
   967         item->Name();
       
   968         item->Uid();
       
   969         }
       
   970 
       
   971     CleanupStack::PopAndDestroy( 2 ); //list(CIMPSSAPSettingsList), settings
       
   972     CloseScheduler();
       
   973 
       
   974     iStoredCount = 0;
       
   975 
       
   976     return KErrNone;
       
   977     }
       
   978 
       
   979 TInt Cwvsapsettingstest::TestIterateTroughSettingsListAscendL( TTestResult& aResult )
       
   980     {
       
   981     //test:
       
   982     // 1. no SAPs defined
       
   983     // 2. 1 SAP defined
       
   984     // 3. 2 SAPs defined
       
   985     // 4. 10 SAPs defined
       
   986 
       
   987     CIMPSSAPSettingsList* list = CIMPSSAPSettingsList::NewLC();
       
   988 
       
   989     SetupSchedulerL();
       
   990 
       
   991     //Instantiate SettingsStore.
       
   992 
       
   993     iStore = CIMPSSAPSettingsStore::NewL();
       
   994     IMPSSAPSettingsStoreTestUtils::DeleteAllSAPSettingsL( *iStore );
       
   995 
       
   996     TUint32 dummy1, dummy2;
       
   997     iStoredCount = 10;
       
   998     IMPSSAPSettingsStoreTestUtils::AddSAPSettingsL( *iStore,
       
   999                                                     iStoredCount,
       
  1000                                                     dummy1,
       
  1001                                                     dummy2,
       
  1002                                                     EIMPSIMAccessGroup );
       
  1003 
       
  1004     iStore->PopulateSAPSettingsListL( *list, EIMPSIMAccessGroup );
       
  1005 
       
  1006     TInt err = KErrNone;
       
  1007 
       
  1008     if ( list->MdcaCount() == iStoredCount )
       
  1009         {
       
  1010         err = KErrNone;
       
  1011         }
       
  1012     else err = KErrArgument;
       
  1013 
       
  1014     if ( err == KErrArgument )
       
  1015         {
       
  1016 
       
  1017         //return from the test case with an error code.
       
  1018         CleanupStack::PopAndDestroy( 1 ); //list
       
  1019 
       
  1020         CloseScheduler();
       
  1021         return err;
       
  1022         }
       
  1023 
       
  1024     RDebug::Print( _L( "Pos:  name   [uid]" ) );
       
  1025     for ( TInt ii( 0 ); ii < iStoredCount; ii++  )
       
  1026         {
       
  1027         const TPtrC name = list->MdcaPoint( ii );
       
  1028         RDebug::Print( _L( "%d: %S [%u]" ), ii, &name, list->UidForIndex( ii ) );
       
  1029         }
       
  1030 
       
  1031     CleanupStack::PopAndDestroy( 1 ); //list
       
  1032     CloseScheduler();
       
  1033     return KErrNone;
       
  1034 
       
  1035     }
       
  1036 
       
  1037 
       
  1038 TInt Cwvsapsettingstest::TestIterateTroughSettingsListDescendL( TTestResult& aResult )
       
  1039     {
       
  1040     //test:
       
  1041     // 1. no SAPs defined
       
  1042     // 2. 1 SAP defined
       
  1043     // 3. 2 SAPs defined
       
  1044     // 4. 10 SAPs defined
       
  1045 
       
  1046     CIMPSSAPSettingsList* list = CIMPSSAPSettingsList::NewL();
       
  1047     CleanupStack::PushL( list );
       
  1048 
       
  1049 
       
  1050     SetupSchedulerL();
       
  1051 
       
  1052     //Instantiate SettingsStore.
       
  1053 
       
  1054     iStore = CIMPSSAPSettingsStore::NewL();
       
  1055     IMPSSAPSettingsStoreTestUtils::DeleteAllSAPSettingsL( *iStore );
       
  1056 
       
  1057     TUint32 dummy1, dummy2;
       
  1058     iStoredCount = 10;
       
  1059     IMPSSAPSettingsStoreTestUtils::AddSAPSettingsL( *iStore,
       
  1060                                                     iStoredCount,
       
  1061                                                     dummy1,
       
  1062                                                     dummy2,
       
  1063                                                     EIMPSIMAccessGroup );
       
  1064 
       
  1065     iStore->PopulateSAPSettingsListL( *list, EIMPSIMAccessGroup, EFalse );
       
  1066 
       
  1067     TInt err = KErrNone;
       
  1068     if ( list->MdcaCount() == iStoredCount )
       
  1069         {
       
  1070         err = KErrNone;
       
  1071         }
       
  1072     else err = KErrArgument;
       
  1073 
       
  1074     RDebug::Print( _L( "Pos:  name   [uid]" ) );
       
  1075     for ( TInt ii( 0 ); ii < iStoredCount; ii++  )
       
  1076         {
       
  1077         const TPtrC name = list->MdcaPoint( ii );
       
  1078         RDebug::Print( _L( "%d: %S [%u]" ), ii, &name, list->UidForIndex( ii ) );
       
  1079         }
       
  1080 
       
  1081 
       
  1082     CleanupStack::PopAndDestroy( 1 ); //list
       
  1083 
       
  1084     CloseScheduler();
       
  1085     return err;
       
  1086     }
       
  1087 
       
  1088 
       
  1089 /* TInt Cwvsapsettingstest::TestDeleteSettingsListL(TTestResult& aResult)
       
  1090     {
       
  1091 
       
  1092     //First setup the Store with 3 lists say.
       
  1093 
       
  1094     CIMPSSAPSettingsList* list = CIMPSSAPSettingsList::NewLC();
       
  1095 
       
  1096     SetupSchedulerL();
       
  1097 
       
  1098     //Instantiate SettingsStore.
       
  1099 
       
  1100     iStore = CIMPSSAPSettingsStore::NewLC();
       
  1101 	IMPSSAPSettingsStoreTestUtils::DeleteAllSAPSettingsL( *iStore );
       
  1102 
       
  1103     TUint32 dummy1, dummy2;
       
  1104     iStoredCount = 3;
       
  1105     IMPSSAPSettingsStoreTestUtils::AddSAPSettingsL( *iStore,
       
  1106                                                   iStoredCount,
       
  1107                                                   dummy1,
       
  1108                                                   dummy2,
       
  1109                                                   EIMPSIMAccessGroup );
       
  1110 
       
  1111     iStore->PopulateSAPSettingsListL( *list, EIMPSIMAccessGroup );
       
  1112 
       
  1113     TInt err = KErrNone;
       
  1114 
       
  1115     if( list->MdcaCount() == iStoredCount )
       
  1116     {
       
  1117     	err = KErrNone;
       
  1118     }
       
  1119     else err = KErrArgument;
       
  1120 
       
  1121     if (err == KErrArgument)
       
  1122     {
       
  1123 
       
  1124     	//return from the test case with an error code.
       
  1125     	CleanupStack::PopAndDestroy(2); //list, iStore
       
  1126 
       
  1127     	CloseScheduler();
       
  1128     	return err;
       
  1129     }
       
  1130 
       
  1131     RDebug::Print( _L("Pos:  name   [uid]") );
       
  1132     for( TInt ii(0); ii<iStoredCount; ii++  )
       
  1133         {
       
  1134         const TPtrC name = list->MdcaPoint( ii );
       
  1135         RDebug::Print( _L("%d: %S [%u]"), ii, &name, list->UidForIndex( ii ) );
       
  1136         }
       
  1137 
       
  1138 
       
  1139   	//test:
       
  1140     // 1. delete one of the lists from the store.
       
  1141 
       
  1142     TInt startCount( list->Count() );
       
  1143     iList->Delete( 3 );
       
  1144     EUNIT_ASSERT( startCount == list->Count() + 1 );
       
  1145 
       
  1146 
       
  1147     //test:
       
  1148     // 1. delete many
       
  1149 
       
  1150     TInt startCount( list->Count() );
       
  1151     iList->Delete( 1, 3 );
       
  1152     EUNIT_ASSERT( startCount == list->Count() + 3 );
       
  1153 
       
  1154     //test:
       
  1155     // 1. delete one - out of bounds
       
  1156 
       
  1157     TInt startCount( list->Count() );
       
  1158     EUNIT_ASSERT_PANIC( list->Delete( startCount + 2 ), "E32USER-CBase", 21 );
       
  1159 
       
  1160     //test:
       
  1161     // 1. delete one out of bounds
       
  1162 
       
  1163     TInt startCount( list->Count() );
       
  1164     EUNIT_ASSERT_PANIC( list->Delete( startCount - 1, 5 ), "E32USER-CBase", 21 );
       
  1165 
       
  1166     CleanupStack::PopAndDestroy(2); //list, iStore
       
  1167     CloseScheduler();
       
  1168     return KErrNone;
       
  1169 
       
  1170     } */
       
  1171 
       
  1172 //Utility functions for adding items to store.
       
  1173 
       
  1174 /* void Cwvsapsettingstest::SetupOpenFilledStore1L()
       
  1175     {
       
  1176 
       
  1177     SetupSchedulerL();
       
  1178 
       
  1179     iStore = CIMPSSAPSettingsStore::NewLC();
       
  1180 	IMPSSAPSettingsStoreTestUtils::DeleteAllSAPSettingsL( *iStore );
       
  1181 
       
  1182     CIMPSSAPSettings* settings = CIMPSSAPSettings::NewL();
       
  1183     CleanupStack::PushL( settings );
       
  1184 
       
  1185     IMPSSAPSettingsStoreTestUtils::FillContainerPartiallyL( *settings, _L("PartiallyFilled") );
       
  1186     iStore->StoreNewSAPL( settings, EIMPSIMAccessGroup );
       
  1187 
       
  1188     CleanupStack::PopAndDestroy(); //Settings
       
  1189     CloseScheduler();
       
  1190 
       
  1191     iStoredCount = 1;
       
  1192     } */
       
  1193 
       
  1194 
       
  1195 /* void Cwvsapsettingstest::SetupOpenFilledStore10L()
       
  1196     {
       
  1197 
       
  1198     SetupSchedulerL();
       
  1199 
       
  1200     iStore = CIMPSSAPSettingsStore::NewL();
       
  1201 	IMPSSAPSettingsStoreTestUtils::DeleteAllSAPSettingsL( *iStore );
       
  1202 
       
  1203     TUint32 dummy1, dummy2;
       
  1204     iStoredCount = 10;
       
  1205     IMPSSAPSettingsStoreTestUtils::AddSAPSettingsL( *iStore,
       
  1206                                                   iStoredCount,
       
  1207                                                   dummy1,
       
  1208                                                   dummy2,
       
  1209                                                   EIMPSIMAccessGroup );
       
  1210 
       
  1211 	CloseScheduler();
       
  1212     } */
       
  1213 
       
  1214 TInt Cwvsapsettingstest::TestObsForAddingSAP( TTestResult& aResult )
       
  1215     {
       
  1216     SetupSchedulerL();
       
  1217 
       
  1218     WVSAPSettingsObserverTestCases *obstestitnf = WVSAPSettingsObserverTestCases::NewL();
       
  1219     //Call the FilledStoreL function that will register the observer
       
  1220 
       
  1221     TInt err = ( obstestitnf->TestNotify_AddSapL() );
       
  1222 
       
  1223     CloseScheduler();
       
  1224 
       
  1225     return err;
       
  1226 
       
  1227     }
       
  1228 
       
  1229 TInt Cwvsapsettingstest::TestObsForRemoveSAP( TTestResult& aResult )
       
  1230     {
       
  1231 
       
  1232     SetupSchedulerL();
       
  1233 
       
  1234     WVSAPSettingsObserverTestCases *obstestitnf = WVSAPSettingsObserverTestCases::NewL();
       
  1235     //Call the RemoveSAPL APIs
       
  1236     TInt err;
       
  1237 
       
  1238     err = obstestitnf->TestNotify_RemoveSapL();
       
  1239 
       
  1240     CloseScheduler();
       
  1241 
       
  1242     return err;
       
  1243 
       
  1244     }
       
  1245 
       
  1246 //Utility functions for installing and uninstalling the scheduler
       
  1247 
       
  1248 void Cwvsapsettingstest::SetupSchedulerL()
       
  1249     {
       
  1250     // Create a scheduler
       
  1251     CActiveScheduler* scheduler = new( ELeave )CActiveScheduler;
       
  1252     CleanupStack::PushL( scheduler );
       
  1253     CActiveScheduler::Install( scheduler );
       
  1254     CleanupStack::Pop(); // scheduler
       
  1255 
       
  1256     }
       
  1257 
       
  1258 void Cwvsapsettingstest::CloseScheduler()
       
  1259     {
       
  1260     delete CActiveScheduler::Current();
       
  1261     }