web_pub/favourites_engine_api/tsrc/src/FavouritesDbIncrementalTestCases.cpp
changeset 1 7c90e6132015
child 25 0ed94ceaa377
equal deleted inserted replaced
0:dd21522fd290 1:7c90e6132015
       
     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 the License "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 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <e32math.h>
       
    23 #include "FavouritesEngineTest.h"
       
    24 
       
    25 // EXTERNAL DATA STRUCTURES
       
    26 // None
       
    27 
       
    28 // EXTERNAL FUNCTION PROTOTYPES  
       
    29 // None
       
    30 
       
    31 // CONSTANTS
       
    32 // None
       
    33 
       
    34 // MACROS
       
    35 // None
       
    36 
       
    37 // LOCAL CONSTANTS AND MACROS
       
    38 // None
       
    39 
       
    40 // MODULE DATA STRUCTURES
       
    41 // None
       
    42 
       
    43 // LOCAL FUNCTION PROTOTYPES
       
    44 // None
       
    45 
       
    46 // FORWARD DECLARATIONS
       
    47 // None
       
    48 
       
    49 // ==================== LOCAL FUNCTIONS =======================================
       
    50 
       
    51 
       
    52 // ============================ MEMBER FUNCTIONS ===============================
       
    53 
       
    54 /*
       
    55 -------------------------------------------------------------------------------
       
    56 
       
    57     Class: CFavouritesEngineTest
       
    58 
       
    59     Method: DbIncRecoverTestL
       
    60 
       
    61     Description: Test the RFavouritesDbIncremental Recover method.
       
    62   
       
    63     Parameters:  TTestResult& aErrorDescription: out:   
       
    64                     Test result and on error case a short description of error
       
    65 
       
    66     Return Values: TInt: Always KErrNone to indicate that test was valid
       
    67 
       
    68     Errors/Exceptions: None
       
    69 
       
    70     Status: Approved
       
    71 
       
    72 -------------------------------------------------------------------------------
       
    73 */
       
    74 TInt CFavouritesEngineTest::DbIncRecoverTestL( TTestResult& aResult )
       
    75     {
       
    76     /* Simple server connect */
       
    77     _LIT( KDefinition ,"State" );
       
    78     _LIT( KData ,"Test the RFavouritesDbIncremental Recover method" );
       
    79     TestModuleIf().Printf( 0, KDefinition, KData );
       
    80 
       
    81     iFavouritesDb.Open( iFavouritesSession, KTestDbName );
       
    82     CleanupClosePushL<RFavouritesDb>( iFavouritesDb );
       
    83 
       
    84     CreatePopulatedDbL();
       
    85 
       
    86     TInt step;
       
    87     RFavouritesDbIncremental incremental;
       
    88     TInt result = incremental.Recover( iFavouritesDb, step );
       
    89     CleanupClosePushL<RFavouritesDbIncremental>( incremental );
       
    90 
       
    91     _LIT( KData2 ,"Finished" );
       
    92     TestModuleIf().Printf( 0, KDefinition, KData2 );
       
    93 
       
    94     if( result == KErrNone )
       
    95 	    {
       
    96 	    _LIT( KDescription , "Test case passed" );
       
    97 	    aResult.SetResult( KErrNone, KDescription );
       
    98 	    }
       
    99     else
       
   100 	    {
       
   101 	    _LIT( KDescription , "Test case failed" );
       
   102 	    aResult.SetResult( KErrGeneral, KDescription );
       
   103 	    }
       
   104 
       
   105     CleanupStack::PopAndDestroy(2); // iFavouritesDb, incremental
       
   106     iFavouritesSession.DeleteDatabase( KTestDbName );
       
   107 
       
   108     // Case was executed
       
   109     return KErrNone;
       
   110     }
       
   111 
       
   112 /*
       
   113 -------------------------------------------------------------------------------
       
   114 
       
   115     Class: CFavouritesEngineTest
       
   116 
       
   117     Method: DbIncCompactTestL
       
   118 
       
   119     Description: Test the RFavouritesDbIncremental Compact method.
       
   120   
       
   121     Parameters:  TTestResult& aErrorDescription: out:   
       
   122                     Test result and on error case a short description of error
       
   123 
       
   124     Return Values: TInt: Always KErrNone to indicate that test was valid
       
   125 
       
   126     Errors/Exceptions: None
       
   127 
       
   128     Status: Approved
       
   129 
       
   130 -------------------------------------------------------------------------------
       
   131 */
       
   132 TInt CFavouritesEngineTest::DbIncCompactTestL( TTestResult& aResult )
       
   133     {
       
   134     /* Simple server connect */
       
   135     _LIT( KDefinition ,"State" );
       
   136     _LIT( KData ,"Test the RFavouritesDbIncremental Compact method" );
       
   137     TestModuleIf().Printf( 0, KDefinition, KData );
       
   138 
       
   139     iFavouritesDb.Open( iFavouritesSession, KTestDbName );
       
   140     CleanupClosePushL<RFavouritesDb>( iFavouritesDb );
       
   141 
       
   142     CreatePopulatedDbL();
       
   143 
       
   144     TInt step;
       
   145     RFavouritesDbIncremental incremental;
       
   146     TInt result = incremental.Compact( iFavouritesDb, step );
       
   147     CleanupClosePushL<RFavouritesDbIncremental>( incremental );
       
   148 
       
   149     _LIT( KData2 ,"Finished" );
       
   150     TestModuleIf().Printf( 0, KDefinition, KData2 );
       
   151 
       
   152     if( result == KErrNone )
       
   153 	    {
       
   154 	    _LIT( KDescription , "Test case passed" );
       
   155 	    aResult.SetResult( KErrNone, KDescription );
       
   156 	    }
       
   157     else
       
   158 	    {
       
   159 	    _LIT( KDescription , "Test case failed" );
       
   160 	    aResult.SetResult( KErrGeneral, KDescription );
       
   161 	    }
       
   162 
       
   163     CleanupStack::PopAndDestroy(2); // iFavouritesDb, incremental
       
   164     iFavouritesSession.DeleteDatabase( KTestDbName );
       
   165 
       
   166     // Case was executed
       
   167     return KErrNone;
       
   168     }
       
   169 
       
   170 /*
       
   171 -------------------------------------------------------------------------------
       
   172 
       
   173     Class: CFavouritesEngineTest
       
   174 
       
   175     Method: DbIncNextTestL
       
   176 
       
   177     Description: Test the RFavouritesDbIncremental Next method.
       
   178   
       
   179     Parameters:  TTestResult& aErrorDescription: out:   
       
   180                     Test result and on error case a short description of error
       
   181 
       
   182     Return Values: TInt: Always KErrNone to indicate that test was valid
       
   183 
       
   184     Errors/Exceptions: None
       
   185 
       
   186     Status: Approved
       
   187 
       
   188 -------------------------------------------------------------------------------
       
   189 */
       
   190 TInt CFavouritesEngineTest::DbIncNextTestL( TTestResult& aResult )
       
   191     {
       
   192     /* Simple server connect */
       
   193     _LIT( KDefinition ,"State" );
       
   194     _LIT( KData ,"Test the RFavouritesDbIncremental Next method" );
       
   195     TestModuleIf().Printf( 0, KDefinition, KData );
       
   196 
       
   197     iFavouritesDb.Open( iFavouritesSession, KTestDbName );
       
   198     CleanupClosePushL<RFavouritesDb>( iFavouritesDb );
       
   199 
       
   200     CreatePopulatedDbL();
       
   201 
       
   202     TInt step;
       
   203     RFavouritesDbIncremental incremental;
       
   204     incremental.Compact( iFavouritesDb, step );
       
   205     CleanupClosePushL<RFavouritesDbIncremental>( incremental );
       
   206 
       
   207     TInt result = incremental.Next( step );
       
   208 
       
   209     _LIT( KData2 ,"Finished" );
       
   210     TestModuleIf().Printf( 0, KDefinition, KData2 );
       
   211 
       
   212     if( result == KErrNone )
       
   213 	    {
       
   214 	    _LIT( KDescription , "Test case passed" );
       
   215 	    aResult.SetResult( KErrNone, KDescription );
       
   216 	    }
       
   217     else
       
   218 	    {
       
   219 	    _LIT( KDescription , "Test case failed" );
       
   220 	    aResult.SetResult( KErrGeneral, KDescription );
       
   221 	    }
       
   222 
       
   223     CleanupStack::PopAndDestroy(2); // iFavouritesDb, incremental
       
   224     iFavouritesSession.DeleteDatabase( KTestDbName );
       
   225 
       
   226     // Case was executed
       
   227     return KErrNone;
       
   228     }
       
   229 
       
   230 // ================= OTHER EXPORTED FUNCTIONS =================================
       
   231 
       
   232 // End of File