web_pub/favourites_engine_api/tsrc/src/FavouritesSessionTestCases.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: SessionVersionTest
       
    60 
       
    61     Description: Test the RFavouritesSession Version 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::SessionVersionTest( TTestResult& aResult )
       
    75     {
       
    76     /* Simple server connect */
       
    77     _LIT( KDefinition ,"State" );
       
    78     _LIT( KData ,"Test the RFavouritesSession Version method" );
       
    79     TestModuleIf().Printf( 0, KDefinition, KData );
       
    80 
       
    81     TVersion sessionVersion = iFavouritesSession.Version();
       
    82     
       
    83     _LIT( KData2 ,"Finished");
       
    84     TestModuleIf().Printf( 0, KDefinition, KData2 );
       
    85     
       
    86     if (sessionVersion.iMajor > 0)
       
    87 	    {
       
    88 	    _LIT( KDescription , "Test case passed");
       
    89 	    aResult.SetResult( KErrNone, KDescription );
       
    90 	    }
       
    91     else
       
    92 	    {
       
    93 	    _LIT( KDescription , "Test case failed");
       
    94 	    aResult.SetResult( KErrGeneral, KDescription );
       
    95 	    }
       
    96 
       
    97     // Case was executed
       
    98     return KErrNone;
       
    99     }
       
   100 
       
   101 /*
       
   102 -------------------------------------------------------------------------------
       
   103 
       
   104     Class: CFavouritesEngineTest
       
   105 
       
   106     Method: SessionConnectTest
       
   107 
       
   108     Description: Test the RFavouritesSession Connect method.
       
   109   
       
   110     Parameters:  TTestResult& aErrorDescription: out:   
       
   111                     Test result and on error case a short description of error
       
   112 
       
   113     Return Values: TInt: Always KErrNone to indicate that test was valid
       
   114 
       
   115     Errors/Exceptions: None
       
   116 
       
   117     Status: Approved
       
   118 
       
   119 -------------------------------------------------------------------------------
       
   120 */
       
   121 TInt CFavouritesEngineTest::SessionConnectTest( TTestResult& aResult )
       
   122     {
       
   123     /* Simple server connect */
       
   124     _LIT( KDefinition ,"State" );
       
   125     _LIT( KData ,"Test the RFavouritesSession Connect method" );
       
   126     TestModuleIf().Printf( 0, KDefinition, KData );
       
   127 
       
   128     RFavouritesSession session;
       
   129     
       
   130     TInt result = session.Connect();
       
   131 
       
   132     _LIT( KData2 ,"Finished" );
       
   133     TestModuleIf().Printf( 0, KDefinition, KData2 );
       
   134     
       
   135     session.Close();
       
   136 	
       
   137     if( result == KErrNone )
       
   138 	    {
       
   139 	    _LIT( KDescription , "Test case passed" );
       
   140 	    aResult.SetResult( KErrNone, KDescription );
       
   141 	    }
       
   142     else
       
   143 	    {
       
   144 	    _LIT( KDescription , "Test case failed" );
       
   145 	    aResult.SetResult( KErrGeneral, KDescription );
       
   146 	    }
       
   147 
       
   148     // Case was executed
       
   149     return KErrNone;
       
   150     }
       
   151 
       
   152 /*
       
   153 -------------------------------------------------------------------------------
       
   154 
       
   155     Class: CFavouritesEngineTest
       
   156 
       
   157     Method: SessionResourceMarkTest
       
   158 
       
   159     Description: Test the RFavouritesSession ResourceMark method.
       
   160   
       
   161     Parameters:  TTestResult& aErrorDescription: out:   
       
   162                     Test result and on error case a short description of error
       
   163 
       
   164     Return Values: TInt: Always KErrNone to indicate that test was valid
       
   165 
       
   166     Errors/Exceptions: None
       
   167 
       
   168     Status: Approved
       
   169 
       
   170 -------------------------------------------------------------------------------
       
   171 */
       
   172 TInt CFavouritesEngineTest::SessionResourceMarkTest( TTestResult& aResult )
       
   173     {
       
   174     /* Simple server connect */
       
   175     _LIT( KDefinition ,"State" );
       
   176     _LIT( KData ,"Test the RFavouritesSession ResourceMark method" );
       
   177     TestModuleIf().Printf( 0, KDefinition, KData );
       
   178 
       
   179     iFavouritesSession.ResourceMark();
       
   180 
       
   181     _LIT( KData2 ,"Finished" );
       
   182     TestModuleIf().Printf( 0, KDefinition, KData2 );
       
   183 	
       
   184 	// ResourceMark provides no results, so if we've gotten this far assume success
       
   185     _LIT( KDescription , "Test case passed" );
       
   186     aResult.SetResult( KErrNone, KDescription );
       
   187 
       
   188     // Case was executed
       
   189     return KErrNone;
       
   190     }
       
   191 
       
   192 /*
       
   193 -------------------------------------------------------------------------------
       
   194 
       
   195     Class: CFavouritesEngineTest
       
   196 
       
   197     Method: SessionResourceCheckTest
       
   198 
       
   199     Description: Test the RFavouritesSession ResourceCheck method.
       
   200   
       
   201     Parameters:  TTestResult& aErrorDescription: out:   
       
   202                     Test result and on error case a short description of error
       
   203 
       
   204     Return Values: TInt: Always KErrNone to indicate that test was valid
       
   205 
       
   206     Errors/Exceptions: None
       
   207 
       
   208     Status: Approved
       
   209 
       
   210 -------------------------------------------------------------------------------
       
   211 */
       
   212 TInt CFavouritesEngineTest::SessionResourceCheckTest( TTestResult& aResult )
       
   213     {
       
   214     /* Simple server connect */
       
   215     _LIT( KDefinition ,"State" );
       
   216     _LIT( KData ,"Test the RFavouritesSession ResourceCheck method" );
       
   217     TestModuleIf().Printf( 0, KDefinition, KData );
       
   218 
       
   219     iFavouritesSession.ResourceCheck();
       
   220 
       
   221     _LIT( KData2 ,"Finished" );
       
   222     TestModuleIf().Printf( 0, KDefinition, KData2 );
       
   223 	
       
   224 	// ResourceCheck provides no results, so if we've gotten this far assume success
       
   225     _LIT( KDescription , "Test case passed" );
       
   226     aResult.SetResult( KErrNone, KDescription );
       
   227 
       
   228     // Case was executed
       
   229     return KErrNone;
       
   230     }
       
   231 
       
   232 /*
       
   233 -------------------------------------------------------------------------------
       
   234 
       
   235     Class: CFavouritesEngineTest
       
   236 
       
   237     Method: SessionResourceCountTest
       
   238 
       
   239     Description: Test the RFavouritesSession ResourceCount method.
       
   240   
       
   241     Parameters:  TTestResult& aErrorDescription: out:   
       
   242                     Test result and on error case a short description of error
       
   243 
       
   244     Return Values: TInt: Always KErrNone to indicate that test was valid
       
   245 
       
   246     Errors/Exceptions: None
       
   247 
       
   248     Status: Approved
       
   249 
       
   250 -------------------------------------------------------------------------------
       
   251 */
       
   252 TInt CFavouritesEngineTest::SessionResourceCountTest( TTestResult& aResult )
       
   253     {
       
   254     /* Simple server connect */
       
   255     _LIT( KDefinition ,"State" );
       
   256     _LIT( KData ,"Test the RFavouritesSession ResourceCount method" );
       
   257     TestModuleIf().Printf( 0, KDefinition, KData );
       
   258 
       
   259     TInt count = iFavouritesSession.ResourceCount();
       
   260 
       
   261     _LIT( KData2 ,"Finished" );
       
   262     TestModuleIf().Printf( 0, KDefinition, KData2 );
       
   263 	
       
   264     if( count == 0 )
       
   265 	    {
       
   266 	    _LIT( KDescription , "Test case passed" );
       
   267 	    aResult.SetResult( KErrNone, KDescription );
       
   268 	    }
       
   269     else
       
   270 	    {
       
   271 	    _LIT( KDescription , "Test case failed" );
       
   272 	    aResult.SetResult( KErrGeneral, KDescription );
       
   273 	    }
       
   274 
       
   275     // Case was executed
       
   276     return KErrNone;
       
   277     }
       
   278 
       
   279 /*
       
   280 -------------------------------------------------------------------------------
       
   281 
       
   282     Class: CFavouritesEngineTest
       
   283 
       
   284     Method: SessionDeleteDatabaseTestL
       
   285 
       
   286     Description: Test the RFavouritesSession DeleteDatabase method.
       
   287   
       
   288     Parameters:  TTestResult& aErrorDescription: out:   
       
   289                     Test result and on error case a short description of error
       
   290 
       
   291     Return Values: TInt: Always KErrNone to indicate that test was valid
       
   292 
       
   293     Errors/Exceptions: None
       
   294 
       
   295     Status: Approved
       
   296 
       
   297 -------------------------------------------------------------------------------
       
   298 */
       
   299 TInt CFavouritesEngineTest::SessionDeleteDatabaseTestL( TTestResult& aResult )
       
   300     {
       
   301     /* Simple server connect */
       
   302     _LIT( KDefinition ,"State" );
       
   303     _LIT( KData ,"Test the RFavouritesSession DeleteDatabase method" );
       
   304     TestModuleIf().Printf( 0, KDefinition, KData );
       
   305 
       
   306     iFavouritesDb.Open( iFavouritesSession, KTestDbName );
       
   307     CleanupClosePushL<RFavouritesDb>( iFavouritesDb );
       
   308     
       
   309     CreatePopulatedDbL();
       
   310 
       
   311     CleanupStack::PopAndDestroy(); // iFavouritesDb
       
   312     TInt result = iFavouritesSession.DeleteDatabase( KTestDbName );
       
   313 
       
   314     _LIT( KData2 ,"Finished" );
       
   315     TestModuleIf().Printf( 0, KDefinition, KData2 );
       
   316 	
       
   317     if( result == KErrNone )
       
   318 	    {
       
   319 	    _LIT( KDescription , "Test case passed" );
       
   320 	    aResult.SetResult( KErrNone, KDescription );
       
   321 	    }
       
   322     else
       
   323 	    {
       
   324 	    _LIT( KDescription , "Test case failed" );
       
   325 	    aResult.SetResult( KErrGeneral, KDescription );
       
   326 	    }
       
   327 
       
   328     // Case was executed
       
   329     return KErrNone;
       
   330     }
       
   331 
       
   332 /*
       
   333 -------------------------------------------------------------------------------
       
   334 
       
   335     Class: CFavouritesEngineTest
       
   336 
       
   337     Method: SessionDbgSetAllocFailTest
       
   338 
       
   339     Description: Test the RFavouritesSession __DbgSetAllocFail method.
       
   340   
       
   341     Parameters:  TTestResult& aErrorDescription: out:   
       
   342                     Test result and on error case a short description of error
       
   343 
       
   344     Return Values: TInt: Always KErrNone to indicate that test was valid
       
   345 
       
   346     Errors/Exceptions: None
       
   347 
       
   348     Status: Approved
       
   349 
       
   350 -------------------------------------------------------------------------------
       
   351 */
       
   352 TInt CFavouritesEngineTest::SessionDbgSetAllocFailTest( TTestResult& aResult )
       
   353     {
       
   354     /* Simple server connect */
       
   355     _LIT( KDefinition ,"State" );
       
   356     _LIT( KData ,"Test the RFavouritesSession __DbgSetAllocFail method" );
       
   357     TestModuleIf().Printf( 0, KDefinition, KData );
       
   358 
       
   359     iFavouritesSession.__DbgSetAllocFail( RHeap::ENone, 1 );
       
   360     
       
   361     _LIT( KData2 ,"Finished" );
       
   362     TestModuleIf().Printf( 0, KDefinition, KData2 );
       
   363 	
       
   364 	// __DbgSetAllocFail provides no results, so if we've gotten this far assume success
       
   365     _LIT( KDescription , "Test case passed" );
       
   366     aResult.SetResult( KErrNone, KDescription );
       
   367 
       
   368     // Case was executed
       
   369     return KErrNone;
       
   370     }
       
   371 
       
   372 // ================= OTHER EXPORTED FUNCTIONS =================================
       
   373 
       
   374 // End of File