gsprofilesrv_plat/settings_plugin_api/tsrc/SettingsPluginApiTest/src/SettingsPluginApiTestblocks.cpp
branchRCL_3
changeset 24 8ee96d21d9bf
parent 23 8bda91a87a00
child 25 7e0eff37aedb
equal deleted inserted replaced
23:8bda91a87a00 24:8ee96d21d9bf
     1 /*
       
     2 * Copyright (c) 2002 - 2007 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:  This cpp file has the functions to test SettingsPluginApi.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // [INCLUDE FILES]
       
    20 #include <e32svr.h>
       
    21 #include <StifParser.h>
       
    22 #include <Stiftestinterface.h>
       
    23 #include "SettingsPluginApiTest.h"
       
    24 
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CSettingsPluginApiTest::Delete
       
    30 // Delete here all resources allocated and opened from test methods. 
       
    31 // Called from destructor. 
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 void CSettingsPluginApiTest::Delete() 
       
    35     { 
       
    36     if ( iGSPluginInterface )
       
    37     	{
       
    38     	delete iGSPluginInterface;
       
    39     	iGSPluginInterface = NULL;
       
    40     	}
       
    41 
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CSettingsPluginApiTest::RunMethodL
       
    46 // Run specified method. Contains also table of test mothods and their names.
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 TInt CSettingsPluginApiTest::RunMethodL( 
       
    50     CStifItemParser& aItem ) 
       
    51     {
       
    52 
       
    53     static TStifFunctionInfo const KFunctions[] =
       
    54         {  
       
    55         // First string is the function name used in TestScripter script file.
       
    56         // Second is the actual implementation member function. 
       
    57         ENTRY( "CallGetValueL", CSettingsPluginApiTest::CallGetValueL ),
       
    58         ENTRY( "CallMenuActivationItemL", CSettingsPluginApiTest::CallMenuActivationItemL ),
       
    59         ENTRY( "CallVisibleL", CSettingsPluginApiTest::CallVisibleL ),
       
    60         ENTRY( "CallResetSelectedItemIndexL", CSettingsPluginApiTest::CallResetSelectedItemIndexL ),
       
    61         // [test cases entries]
       
    62         };
       
    63 
       
    64     const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo );
       
    65 
       
    66     return RunInternalL( KFunctions, count, aItem );
       
    67 
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CSettingsPluginApiTest::RunMethodL
       
    72 // Run specified method. Contains also table of test mothods and their names.
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 TInt CSettingsPluginApiTest::SetupCGSParentPluginL()
       
    76 	{  
       
    77 	TRAPD( error, iTestGsPlugin = CTestGSPlugin::NewL() );
       
    78 	
       
    79 	if ( KErrNone == error )
       
    80 		{
       
    81         iGSPluginInterface = static_cast<CGSPluginInterface*> ( iTestGsPlugin );
       
    82 		}
       
    83     
       
    84     return error;
       
    85 	}
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CServicesDbApiTest::CallGetValueL
       
    89 // Is used to test CGSPluginInterface::GetValue
       
    90 // -----------------------------------------------------------------------------
       
    91 TInt CSettingsPluginApiTest::CallGetValueL( CStifItemParser& /*aItem*/ )
       
    92     {
       
    93     //
       
    94     TInt result = 0;
       
    95     TRAPD( error, result = SetupCGSParentPluginL() );
       
    96     if( KErrNone != error )
       
    97         {
       
    98         iLog->Log( _L( "Initial GSPluginInterface failed,the failed code is %d" ), error );
       
    99         return error;
       
   100         }
       
   101     else
       
   102         {
       
   103         if( KErrNone != result )
       
   104             {            
       
   105             return result;
       
   106             }
       
   107         };
       
   108     TBuf<256> value;
       
   109     TRAPD( errorCall, iGSPluginInterface->GetValue( EGSPluginKeySettingsItemValueString, value ) );
       
   110     if( errorCall != KErrNone )
       
   111         {
       
   112         iLog->Log( _L( "Function GetValue is called failed. The failed code is %d" ), errorCall );
       
   113         return errorCall;
       
   114         }
       
   115     else
       
   116         {
       
   117         iLog->Log( _L( "Function GetValue called successfully." ) );
       
   118         }
       
   119     
       
   120     return KErrNone;
       
   121     }
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // CServicesDbApiTest::CallMenuActivationItemL
       
   125 // Is used to test CGSPluginInterface::MenuActivationItem
       
   126 // -----------------------------------------------------------------------------
       
   127 TInt CSettingsPluginApiTest::CallMenuActivationItemL( CStifItemParser& /*aItem*/ )
       
   128     {
       
   129     //
       
   130     TInt result = 0;
       
   131     TRAPD( error, result = SetupCGSParentPluginL() );
       
   132     if(KErrNone != error)
       
   133         {
       
   134         iLog->Log( _L( "Initial GSPluginInterface failed,the failed code is %d" ), error );
       
   135         return error;
       
   136         }
       
   137     else
       
   138         {
       
   139         if( KErrNone != result )
       
   140             {            
       
   141             return result;
       
   142             }
       
   143         };
       
   144     TGSMenuActivationItems GsMenuActivationItems;
       
   145     TRAPD( errorCall, GsMenuActivationItems = iGSPluginInterface->MenuActivationItem() );
       
   146     if( errorCall != KErrNone )
       
   147         {
       
   148         iLog->Log( _L( "Function MenuActivationItem is called failed. The failed code is %d" ), errorCall );
       
   149         return errorCall;
       
   150         }
       
   151     else
       
   152         {
       
   153         iLog->Log( _L( "Function MenuActivationItem is called successfully." ) );
       
   154         }
       
   155     
       
   156     return KErrNone;
       
   157     }
       
   158 
       
   159 // -----------------------------------------------------------------------------
       
   160 // CServicesDbApiTest::CallVisibleL
       
   161 // Is used to test CGSPluginInterface::Visible
       
   162 // -----------------------------------------------------------------------------
       
   163 TInt CSettingsPluginApiTest::CallVisibleL( CStifItemParser& /*aItem*/ )
       
   164     {
       
   165     //
       
   166     TInt result = 0;
       
   167     TRAPD( error, result = SetupCGSParentPluginL() );
       
   168     if(KErrNone != error)
       
   169         {
       
   170         iLog->Log( _L( "Initial GSPluginInterface failed,the failed code is %d" ), error );
       
   171         return error;
       
   172         }
       
   173     else
       
   174         {
       
   175         if( KErrNone != result )
       
   176             {            
       
   177             return result;
       
   178             }
       
   179         };
       
   180     TBool IsVisible;
       
   181     TRAPD( errorCall, IsVisible = iGSPluginInterface->Visible() );
       
   182     if( errorCall != KErrNone )
       
   183         {
       
   184         iLog->Log( _L( "Function Visible is called failed. The failed code is %d" ), errorCall );
       
   185         return errorCall;
       
   186         }
       
   187     else
       
   188         {
       
   189         iLog->Log( _L( "Function Visible is called successfully." ) );
       
   190         }
       
   191     
       
   192     return KErrNone;
       
   193     }
       
   194 
       
   195 // -----------------------------------------------------------------------------
       
   196 // CServicesDbApiTest::CallResetSelectedItemIndexL
       
   197 // Is used to test CGSPluginInterface::ResetSelectedItemIndex
       
   198 // -----------------------------------------------------------------------------
       
   199 TInt CSettingsPluginApiTest::CallResetSelectedItemIndexL( CStifItemParser& /*aItem*/ )
       
   200     {
       
   201     //
       
   202     TInt result = 0 ;
       
   203     TRAPD( error, result = SetupCGSParentPluginL() );
       
   204     if(KErrNone != error)
       
   205         {
       
   206         iLog->Log( _L( "Initial GSPluginInterface failed,the failed code is %d" ), error );
       
   207         return error;
       
   208         }
       
   209     else
       
   210         {
       
   211         if( KErrNone != result )
       
   212             {            
       
   213             return result;
       
   214             }
       
   215         };
       
   216     TRAPD( errorCall, iGSPluginInterface->ResetSelectedItemIndex() );
       
   217     if( errorCall != KErrNone )
       
   218         {
       
   219         iLog->Log( _L( "Function ResetSelectedItemIndex is called failed. The failed code is %d" ), errorCall );
       
   220         return errorCall;
       
   221         }
       
   222     else
       
   223         {
       
   224         iLog->Log( _L( "Function ResetSelectedItemIndex is called successfully." ) );
       
   225         }
       
   226     
       
   227     return KErrNone;
       
   228     }
       
   229 
       
   230 //
       
   231 //  [End of File]