usbengines/usbremotepersonality/tsrc/USBRemotePersonalityTest/src/USBRemotePersonalityTestBlocks.cpp
changeset 34 7858bc6ead78
parent 31 dfdd8240f7c8
child 35 9d8b04ca6939
equal deleted inserted replaced
31:dfdd8240f7c8 34:7858bc6ead78
     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:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // [INCLUDE FILES] - do not remove
       
    22 #include <e32svr.h>
       
    23 #include <StifParser.h>
       
    24 #include <Stiftestinterface.h>
       
    25 #include "USBRemotePersonalityTest.h"
       
    26 
       
    27 // EXTERNAL DATA STRUCTURES
       
    28 //extern  ?external_data;
       
    29 
       
    30 // EXTERNAL FUNCTION PROTOTYPES  
       
    31 //extern ?external_function( ?arg_type,?arg_type );
       
    32 
       
    33 // CONSTANTS
       
    34 //const ?type ?constant_var = ?constant;
       
    35 
       
    36 // MACROS
       
    37 //#define ?macro ?macro_def
       
    38 
       
    39 // LOCAL CONSTANTS AND MACROS
       
    40 //const ?type ?constant_var = ?constant;
       
    41 //#define ?macro_name ?macro_def
       
    42 
       
    43 // MODULE DATA STRUCTURES
       
    44 //enum ?declaration
       
    45 //typedef ?declaration
       
    46 
       
    47 // LOCAL FUNCTION PROTOTYPES
       
    48 //?type ?function_name( ?arg_type, ?arg_type );
       
    49 
       
    50 // FORWARD DECLARATIONS
       
    51 //class ?FORWARD_CLASSNAME;
       
    52 
       
    53 // ============================= LOCAL FUNCTIONS ===============================
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // ?function_name ?description.
       
    57 // ?description
       
    58 // Returns: ?value_1: ?description
       
    59 //          ?value_n: ?description_line1
       
    60 //                    ?description_line2
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 /*
       
    64 ?type ?function_name(
       
    65     ?arg_type arg,  // ?description
       
    66     ?arg_type arg)  // ?description
       
    67     {
       
    68 
       
    69     ?code  // ?comment
       
    70 
       
    71     // ?comment
       
    72     ?code
       
    73     }
       
    74 */
       
    75 
       
    76 // ============================ MEMBER FUNCTIONS ===============================
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CUSBRemotePersonalityTest::Delete
       
    80 // Delete here all resources allocated and opened from test methods. 
       
    81 // Called from destructor. 
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 void CUSBRemotePersonalityTest::Delete() 
       
    85     {    
       
    86     REComSession::DestroyedImplementation( iPluginDtorIDKey );        
       
    87     if ( iPlugin )
       
    88         {
       
    89         delete iPlugin;
       
    90         iPlugin = NULL;
       
    91         }
       
    92     REComSession::FinalClose();
       
    93     
       
    94     iSetupBuff.Close();
       
    95     iDataBuff.Close();
       
    96     
       
    97     if ( iUsbMan )
       
    98         {
       
    99         iUsbMan -> Close();
       
   100         delete iUsbMan;
       
   101         iUsbMan = NULL;
       
   102         }
       
   103     
       
   104     if ( iUsbWatcher )
       
   105         {
       
   106         iUsbWatcher -> Close();
       
   107         delete iUsbWatcher;
       
   108         iUsbWatcher = NULL;
       
   109         }
       
   110     
       
   111     if ( iDevUsbClient )
       
   112         {
       
   113         iDevUsbClient -> Close();
       
   114         delete iDevUsbClient;
       
   115         iDevUsbClient = NULL;
       
   116         }
       
   117     }
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CUSBRemotePersonalityTest::RunMethodL
       
   121 // Run specified method. Contains also table of test mothods and their names.
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 TInt CUSBRemotePersonalityTest::RunMethodL( 
       
   125     CStifItemParser& aItem ) 
       
   126     {
       
   127 
       
   128     static TStifFunctionInfo const KFunctions[] =
       
   129         {  
       
   130         //ADD NEW ENTRY HERE
       
   131         // [test cases entries] - Do not remove
       
   132 		ENTRY( "ExecuteApiTest", CUSBRemotePersonalityTest::ExecuteApiTest ),
       
   133         ENTRY( "ExecuteModuleTest", CUSBRemotePersonalityTest::ExecuteModuleTest ),
       
   134         ENTRY( "ExecuteBranchTest", CUSBRemotePersonalityTest::ExecuteBranchTest ),
       
   135         };
       
   136 
       
   137     const TInt count = sizeof( KFunctions ) / 
       
   138                         sizeof( TStifFunctionInfo );
       
   139 
       
   140     return RunInternalL( KFunctions, count, aItem );
       
   141 
       
   142     }
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // CUSBRemotePersonalityTest::ExecuteApiTest
       
   146 // -----------------------------------------------------------------------------
       
   147 
       
   148 TInt CUSBRemotePersonalityTest::ExecuteApiTest( CStifItemParser& aItem )
       
   149     {
       
   150 	STIF_LOG( "[STIF_LOG] >>>ExecuteApiTest" );
       
   151 	
       
   152 	TInt res;
       
   153     TUSBRemotePersonalityTestResult testResult;
       
   154     TPtrC apiTestName( KNullDesC );
       
   155 	
       
   156 	res = aItem.GetString( _L( "ExecuteApiTest" ), apiTestName );   
       
   157     if ( res != KErrNone )
       
   158         {
       
   159         iLog -> Log( _L( "GetString failed with value: %d" ), res );
       
   160         return res;
       
   161         }
       
   162 		
       
   163 	TRAP( res, DoExecuteApiTestL( apiTestName, testResult ) );
       
   164     if ( res != KErrNone )
       
   165         {
       
   166         iLog -> Log( _L( "DoExecuteApiTestL error: %d"), res );
       
   167         return res;
       
   168         }
       
   169     
       
   170     STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
       
   171     STIF_LOG( "[STIF_LOG] Test case passed" );
       
   172 	STIF_LOG( "[STIF_LOG] <<<ExecuteApiTest" );
       
   173     return KErrNone;
       
   174     }
       
   175 	
       
   176 	
       
   177 void CUSBRemotePersonalityTest::DoExecuteApiTestL( TPtrC aApiTestName, TUSBRemotePersonalityTestResult& aTestResult )
       
   178     {
       
   179 	STIF_LOG( "[STIF_LOG] >>>DoExecuteApiTestL" );
       
   180     if ( !aApiTestName.Compare( _L( "CreatePluginImplementationL" ) ) )
       
   181         {
       
   182         STIF_LOG( "[STIF_LOG] Api test type: CreatePluginImplementationL" );
       
   183         CreatePluginImplementationTestL( aTestResult );
       
   184         }
       
   185     else if ( !aApiTestName.Compare( _L( "InitializeTestL" ) ) )
       
   186         {
       
   187         STIF_LOG( "[STIF_LOG] Api test type: InitializeTestL" );
       
   188         InitializeTestL( aTestResult );
       
   189         }
       
   190     else if ( !aApiTestName.Compare( _L( "CheckLastResultTestL" ) ) )
       
   191         {
       
   192         STIF_LOG( "[STIF_LOG] Api test type: CheckLastResultTestL" );
       
   193         CheckLastResultTestL( aTestResult );
       
   194         }
       
   195     else if ( !aApiTestName.Compare( _L( "GetAllPersonalitiesTestL" ) ) )
       
   196         {
       
   197         STIF_LOG( "[STIF_LOG] Api test type: GetAllPersonalitiesTestL" );
       
   198         GetAllPersonalitiesTestL( aTestResult );
       
   199         }
       
   200     else if ( !aApiTestName.Compare( _L( "SetPersonalityTestL" ) ) )
       
   201         {
       
   202         STIF_LOG( "[STIF_LOG] Api test type: SetPersonalityTestL" );
       
   203         SetPersonalityTestL( aTestResult );
       
   204         }
       
   205     else if ( !aApiTestName.Compare( _L( "GetPersonalityTestL" ) ) )
       
   206         {
       
   207         STIF_LOG( "[STIF_LOG] Api test type: GetPersonalityTestL" );
       
   208         GetPersonalityTestL( aTestResult );
       
   209         }
       
   210     else if ( !aApiTestName.Compare( _L( "GetPersonalityDesTestL" ) ) )
       
   211         {
       
   212         STIF_LOG( "[STIF_LOG] Api test type: GetPersonalityDesTestL" );
       
   213         GetPersonalityDesTestL( aTestResult );
       
   214         }
       
   215     else if ( !aApiTestName.Compare( _L( "GetLockStateTestL" ) ) )
       
   216         {
       
   217         STIF_LOG( "[STIF_LOG] Api test type: GetLockStateTestL" );
       
   218         GetLockStateTestL( aTestResult );
       
   219         }
       
   220     else if ( !aApiTestName.Compare( _L( "SetLockStateTestL" ) ) )
       
   221         {
       
   222         STIF_LOG( "[STIF_LOG] Api test type: SetLockStateTestL" );
       
   223         SetLockStateTestL( aTestResult );
       
   224         }
       
   225     else
       
   226         {
       
   227         STIF_LOG( "[STIF_LOG] Api test type: not found" );
       
   228         User::Leave( KErrNotFound );
       
   229         }
       
   230 	STIF_LOG( "[STIF_LOG] <<<DoExecuteApiTestL" );
       
   231     }
       
   232 
       
   233 
       
   234 void CUSBRemotePersonalityTest::CreatePluginImplementationTestL( TUSBRemotePersonalityTestResult& aTestResult )
       
   235     {
       
   236     STIF_LOG( "[STIF_LOG] >>>CreatePluginImplementationTestL" );
       
   237     
       
   238     if ( !iPlugin )
       
   239         {
       
   240         aTestResult = ETestCaseFailed;
       
   241         return;
       
   242         }
       
   243     
       
   244     aTestResult = ETestCasePassed;
       
   245     STIF_LOG( "[STIF_LOG] <<<CreatePluginImplementationTestL" );
       
   246     }
       
   247 
       
   248 
       
   249 void CUSBRemotePersonalityTest::InitializeTestL( TUSBRemotePersonalityTestResult& aTestResult )
       
   250     {
       
   251     STIF_LOG( "[STIF_LOG] >>>InitializeTestL" );
       
   252     
       
   253     iPlugin -> Initialize( *iDevUsbClient, *iUsbWatcher, *iUsbMan );
       
   254     if ( !iPlugin )
       
   255         {
       
   256         aTestResult = ETestCaseFailed;
       
   257         return;
       
   258         }
       
   259     
       
   260     aTestResult = ETestCasePassed;
       
   261     STIF_LOG( "[STIF_LOG] <<<InitializeTestL" );
       
   262     }
       
   263 
       
   264 
       
   265 void CUSBRemotePersonalityTest::CheckLastResultTestL( TUSBRemotePersonalityTestResult& aTestResult )
       
   266     {
       
   267     STIF_LOG( "[STIF_LOG] >>>CheckLastResultTestL" );
       
   268     TInt res;
       
   269     TUint8 getLastResult;
       
   270     TInt getLastResultLenght;
       
   271     CRemotePersonalityHandler::TLastResult lastResult;
       
   272     
       
   273     User::LeaveIfNull( iPlugin );
       
   274     iPlugin -> Initialize( *iDevUsbClient, *iUsbWatcher, *iUsbMan );
       
   275     STIF_LOG( "[STIF_LOG] CheckLastResultTestL::initialization completed" );
       
   276     
       
   277     getLastResult = CRemotePersonalityHandler::EGetLastResult;
       
   278     getLastResultLenght = sizeof( getLastResult );
       
   279     TPtrC8 const getLastResultString( &getLastResult, getLastResultLenght );
       
   280     
       
   281     iSetupBuff.FillZ( KSetupPacketLength );
       
   282     iSetupBuff.Replace( 1, 1, getLastResultString );
       
   283     
       
   284     res = iPlugin->Handle( iSetupBuff, iDataBuff );
       
   285     if ( res != KErrNone )
       
   286         {
       
   287         iLog -> Log( _L( "Handle failed with value: %d"), res );
       
   288         aTestResult = ETestCaseFailed;
       
   289         return;
       
   290         }    
       
   291     STIF_LOG( "[STIF_LOG] Handle request completed" );
       
   292     
       
   293     lastResult = static_cast< CRemotePersonalityHandler::TLastResult >( iDataBuff[0] );
       
   294     iLog -> Log( _L( "Last result value: %d, expected %d"), lastResult, CRemotePersonalityHandler::EUndefinedError );   
       
   295     if ( lastResult != CRemotePersonalityHandler::EUndefinedError )
       
   296         {
       
   297         aTestResult = ETestCaseFailed;
       
   298         return;
       
   299         }
       
   300 
       
   301     aTestResult = ETestCasePassed;
       
   302     STIF_LOG( "[STIF_LOG] <<<CheckLastResultTestL" );
       
   303     }
       
   304 	
       
   305 void CUSBRemotePersonalityTest::GetAllPersonalitiesTestL( TUSBRemotePersonalityTestResult& aTestResult )
       
   306     {
       
   307     STIF_LOG( "[STIF_LOG] >>>GetAllPersonalitiesTestL" );
       
   308     TInt res;
       
   309     TUint8 getAll;
       
   310     TInt getAllLenght;
       
   311     
       
   312     User::LeaveIfNull( iPlugin );
       
   313     iPlugin -> Initialize( *iDevUsbClient, *iUsbWatcher, *iUsbMan );
       
   314     STIF_LOG( "[STIF_LOG] CheckLastResultTestL::initialization completed" );
       
   315         
       
   316     getAll = CRemotePersonalityHandler::EGetAllPersonalities;
       
   317     getAllLenght = sizeof( getAll );
       
   318     TPtrC8 const getAllString( &getAll, getAllLenght );
       
   319     
       
   320     iSetupBuff.FillZ( KSetupPacketLength );
       
   321     iSetupBuff.Replace( 1, 1, getAllString );
       
   322   
       
   323     res = iPlugin->Handle( iSetupBuff, iDataBuff );
       
   324     if ( res != KErrNone )
       
   325         {
       
   326         iLog -> Log( _L( "Handle failed with value: %d"), res );
       
   327         aTestResult = ETestCaseFailed;
       
   328         return;
       
   329         }    
       
   330     STIF_LOG( "[STIF_LOG] Handle request completed" );
       
   331 
       
   332     iLog -> Log( _L( "Data length: %d, expected != 0"), iDataBuff.Length() ); 
       
   333     if ( !iDataBuff.Length() )
       
   334         {
       
   335         aTestResult = ETestCaseFailed;
       
   336         return;
       
   337         }
       
   338 
       
   339     aTestResult = ETestCasePassed;
       
   340     STIF_LOG( "[STIF_LOG] <<<GetAllPersonalitiesTestL" );
       
   341     }
       
   342 
       
   343 
       
   344 void CUSBRemotePersonalityTest::SetPersonalityTestL( TUSBRemotePersonalityTestResult& aTestResult )
       
   345     {
       
   346     STIF_LOG( "[STIF_LOG] >>>SetPersonalityTestL" );
       
   347     TInt res;
       
   348     TUint8 setPersonality;
       
   349     TInt setPersonalityLenght;
       
   350     TUint8 personalityType;
       
   351     TInt personalityTypeLenght;
       
   352     TUint8 getLastResult;
       
   353     TInt getLastResultLenght;
       
   354     CRemotePersonalityHandler::TLastResult lastResult;
       
   355     
       
   356     User::LeaveIfNull( iPlugin );
       
   357     iPlugin -> Initialize( *iDevUsbClient, *iUsbWatcher, *iUsbMan );
       
   358     STIF_LOG( "[STIF_LOG] CheckLastResultTestL::initialization completed" );
       
   359     
       
   360     // Request type should be set in second byte
       
   361     // Personality type should be set in third byte
       
   362     setPersonality = CRemotePersonalityHandler::ESetPersonality;
       
   363     setPersonalityLenght = sizeof( setPersonality );
       
   364     TPtrC8 const setPersonalityString( &setPersonality, setPersonalityLenght );
       
   365     personalityType = KUsbPersonalityIdMTP;
       
   366     personalityTypeLenght = sizeof( personalityType );
       
   367     TPtrC8 const personalityTypeString( &personalityType, personalityTypeLenght );
       
   368     
       
   369     iSetupBuff.FillZ( KSetupPacketLength );   
       
   370     iSetupBuff.Replace( 1, 1, setPersonalityString );
       
   371     iSetupBuff.Replace( 2, 1, personalityTypeString );
       
   372 
       
   373     res = iPlugin->Handle( iSetupBuff, iDataBuff );
       
   374     if ( res != KErrNone )
       
   375         {
       
   376         iLog -> Log( _L( "Handle failed with value: %d"), res );
       
   377         aTestResult = ETestCaseFailed;
       
   378         return;
       
   379         }    
       
   380     STIF_LOG( "[STIF_LOG] Handle request completed" );
       
   381 
       
   382     getLastResult = CRemotePersonalityHandler::EGetLastResult;
       
   383     getLastResultLenght = sizeof( getLastResult );
       
   384     TPtrC8 const getLastResultString( &getLastResult, getLastResultLenght );
       
   385     
       
   386     iSetupBuff.FillZ( KSetupPacketLength );
       
   387     iDataBuff.FillZ();
       
   388     iSetupBuff.Replace( 1, 1, getLastResultString );
       
   389 
       
   390     res = iPlugin -> Handle( iSetupBuff, iDataBuff );
       
   391     if ( res != KErrNone )
       
   392         {
       
   393         iLog -> Log( _L( "Handle failed with value: %d"), res );
       
   394         aTestResult = ETestCaseFailed;
       
   395         return;
       
   396         }    
       
   397     STIF_LOG( "[STIF_LOG] Handle request completed" );
       
   398     
       
   399     lastResult = static_cast< CRemotePersonalityHandler::TLastResult >( iDataBuff[0] );
       
   400     iLog -> Log( _L( "Last result value: %d, expected %d"), lastResult, CRemotePersonalityHandler::EDataTransferInProgress );   
       
   401     if ( lastResult != CRemotePersonalityHandler::EDataTransferInProgress )
       
   402         {
       
   403         aTestResult = ETestCaseFailed;
       
   404         return;
       
   405         }
       
   406 
       
   407     aTestResult = ETestCasePassed;
       
   408     STIF_LOG( "[STIF_LOG] <<<SetPersonalityTestL" );
       
   409     }
       
   410 
       
   411 
       
   412 void CUSBRemotePersonalityTest::GetPersonalityTestL( TUSBRemotePersonalityTestResult& aTestResult )
       
   413     {
       
   414     STIF_LOG( "[STIF_LOG] >>>GetPersonalityTestL" );
       
   415     TInt res;
       
   416     TUint8 getPersonality;
       
   417     TInt getPersonalityLenght;
       
   418     
       
   419     User::LeaveIfNull( iPlugin );
       
   420     iPlugin -> Initialize( *iDevUsbClient, *iUsbWatcher, *iUsbMan );
       
   421     STIF_LOG( "[STIF_LOG] CheckLastResultTestL::initialization completed" );
       
   422     
       
   423     // Request type should be set in second byte
       
   424     getPersonality = CRemotePersonalityHandler::EGetPersonality;
       
   425     getPersonalityLenght = sizeof( getPersonality );
       
   426     TPtrC8 const getPersonalityString( &getPersonality, getPersonalityLenght );
       
   427     
       
   428     iSetupBuff.FillZ( KSetupPacketLength );
       
   429     iSetupBuff.Replace( 1, 1, getPersonalityString );
       
   430 
       
   431     res = iPlugin->Handle( iSetupBuff, iDataBuff );
       
   432     if ( res != KErrNotSupported )
       
   433         {
       
   434         iLog -> Log( _L( "Handle completion value: %d"), res );
       
   435         aTestResult = ETestCaseFailed;
       
   436         return;
       
   437         }    
       
   438     STIF_LOG( "[STIF_LOG] Handle request completed" );
       
   439     
       
   440     aTestResult = ETestCasePassed;
       
   441     STIF_LOG( "[STIF_LOG] <<<GetPersonalityTestL" );
       
   442     }
       
   443 
       
   444 
       
   445 void CUSBRemotePersonalityTest::GetPersonalityDesTestL( TUSBRemotePersonalityTestResult& aTestResult )
       
   446     {
       
   447     STIF_LOG( "[STIF_LOG] >>>GetPersonalityDesTestL" );
       
   448     TInt res;
       
   449     TUint8 getPersonalityDes;
       
   450     TInt getPersonalityDesLenght;
       
   451     
       
   452     User::LeaveIfNull( iPlugin );
       
   453     iPlugin -> Initialize( *iDevUsbClient, *iUsbWatcher, *iUsbMan );
       
   454     STIF_LOG( "[STIF_LOG] CheckLastResultTestL::initialization completed" );
       
   455     
       
   456     // Request type should be set in second byte
       
   457     getPersonalityDes = CRemotePersonalityHandler::EGetPersonalityDescriptor;
       
   458     getPersonalityDesLenght = sizeof( getPersonalityDes );
       
   459     TPtrC8 const getPersonalityDesString( &getPersonalityDes, getPersonalityDesLenght );
       
   460     
       
   461     iSetupBuff.FillZ( KSetupPacketLength );
       
   462     iSetupBuff.Replace( 1, 1, getPersonalityDesString );
       
   463 
       
   464     res = iPlugin->Handle( iSetupBuff, iDataBuff );
       
   465     if ( res != KErrNotSupported )
       
   466         {
       
   467         iLog -> Log( _L( "Handle completion value: %d"), res );
       
   468         aTestResult = ETestCaseFailed;
       
   469         return;
       
   470         }    
       
   471     STIF_LOG( "[STIF_LOG] Handle request completed" );
       
   472     
       
   473     aTestResult = ETestCasePassed;
       
   474     STIF_LOG( "[STIF_LOG] <<<GetPersonalityDesTestL" );
       
   475     }
       
   476 
       
   477 
       
   478 void CUSBRemotePersonalityTest::GetLockStateTestL( TUSBRemotePersonalityTestResult& aTestResult )
       
   479     {
       
   480     STIF_LOG( "[STIF_LOG] >>>GetLockStateTestL" );
       
   481     TInt res;
       
   482     TUint8 getLockState;
       
   483     TInt getLockStateLenght;
       
   484     
       
   485     User::LeaveIfNull( iPlugin );
       
   486     iPlugin -> Initialize( *iDevUsbClient, *iUsbWatcher, *iUsbMan );
       
   487     STIF_LOG( "[STIF_LOG] CheckLastResultTestL::initialization completed" );
       
   488     
       
   489     // Request type should be set in second byte
       
   490     getLockState = CRemotePersonalityHandler::EGetLockState;
       
   491     getLockStateLenght = sizeof( getLockState );
       
   492     TPtrC8 const getLockStateString( &getLockState, getLockStateLenght );
       
   493     
       
   494     iSetupBuff.FillZ( KSetupPacketLength );
       
   495     iSetupBuff.Replace( 1, 1, getLockStateString );
       
   496 
       
   497     res = iPlugin->Handle( iSetupBuff, iDataBuff );
       
   498     if ( res != KErrNotSupported )
       
   499         {
       
   500         iLog -> Log( _L( "Handle completion value: %d"), res );
       
   501         aTestResult = ETestCaseFailed;
       
   502         return;
       
   503         }    
       
   504     STIF_LOG( "[STIF_LOG] Handle request completed" );
       
   505     
       
   506     aTestResult = ETestCasePassed;
       
   507     STIF_LOG( "[STIF_LOG] <<<GetLockStateTestL" );
       
   508     }
       
   509 
       
   510 
       
   511 void CUSBRemotePersonalityTest::SetLockStateTestL( TUSBRemotePersonalityTestResult& aTestResult )
       
   512     {
       
   513     STIF_LOG( "[STIF_LOG] >>>SetLockStateTestL" );
       
   514     TInt res;
       
   515     TUint8 setLockState;
       
   516     TInt setLockStateLenght;
       
   517     
       
   518     User::LeaveIfNull( iPlugin );
       
   519     iPlugin -> Initialize( *iDevUsbClient, *iUsbWatcher, *iUsbMan );
       
   520     STIF_LOG( "[STIF_LOG] CheckLastResultTestL::initialization completed" );
       
   521     
       
   522     // Request type should be set in second byte
       
   523     setLockState = CRemotePersonalityHandler::ESetLockState;
       
   524     setLockStateLenght = sizeof( setLockState );
       
   525     TPtrC8 const setLockStateString( &setLockState, setLockStateLenght );
       
   526     
       
   527     iSetupBuff.FillZ( KSetupPacketLength );
       
   528     iSetupBuff.Replace( 1, 1, setLockStateString );
       
   529 
       
   530     res = iPlugin->Handle( iSetupBuff, iDataBuff );
       
   531     if ( res != KErrNotSupported )
       
   532         {
       
   533         iLog -> Log( _L( "Handle completion value: %d"), res );
       
   534         aTestResult = ETestCaseFailed;
       
   535         return;
       
   536         }    
       
   537     STIF_LOG( "[STIF_LOG] Handle request completed" );
       
   538  
       
   539     aTestResult = ETestCasePassed;
       
   540     STIF_LOG( "[STIF_LOG] <<<SetLockStateTestL" );
       
   541     }
       
   542 
       
   543 
       
   544 // -----------------------------------------------------------------------------
       
   545 // CUSBRemotePersonalityTest::ExecuteModuleTest
       
   546 // -----------------------------------------------------------------------------	
       
   547 
       
   548 TInt CUSBRemotePersonalityTest::ExecuteModuleTest( CStifItemParser& aItem )
       
   549     {
       
   550 	STIF_LOG( "[STIF_LOG] >>>ExecuteModuleTest" );
       
   551 	
       
   552     TInt res;
       
   553     TUSBRemotePersonalityTestResult testResult;
       
   554     TPtrC moduleTestName( KNullDesC );
       
   555 
       
   556     res = aItem.GetString( _L( "ExecuteModuleTest" ), moduleTestName );   
       
   557     if ( res != KErrNone )
       
   558         {
       
   559         iLog -> Log( _L( "GetString failed with value: %d" ), res );
       
   560         return res;
       
   561         }
       
   562 
       
   563     TRAP( res, DoExecuteModuleTestL( moduleTestName, testResult ) );
       
   564     if ( res != KErrNone )
       
   565         {
       
   566         iLog -> Log( _L( "DoExecuteModuleTestL error: %d"), res );
       
   567         return res;
       
   568         }
       
   569     
       
   570     STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
       
   571     STIF_LOG( "[STIF_LOG] Test case passed" );
       
   572 	STIF_LOG( "[STIF_LOG] <<<ExecuteModuleTest" );
       
   573     return KErrNone;
       
   574     }	
       
   575 	
       
   576 	
       
   577 void CUSBRemotePersonalityTest::DoExecuteModuleTestL( TPtrC aModuleTestName, TUSBRemotePersonalityTestResult& aTestResult )
       
   578     {
       
   579 	STIF_LOG( "[STIF_LOG] >>>DoExecuteModuleTestL" );
       
   580     if ( !aModuleTestName.Compare( _L( "ExampleModuleTest" ) ) )
       
   581         {
       
   582         STIF_LOG( "[STIF_LOG] Module test type: ExampleModuleTest" );
       
   583         ExampleModuleTestL( aTestResult );
       
   584         }
       
   585     else
       
   586         {
       
   587         STIF_LOG( "[STIF_LOG] Module test type: not found" );
       
   588         User::Leave( KErrNotFound );
       
   589         }
       
   590 	STIF_LOG( "[STIF_LOG] <<<DoExecuteModuleTestL" );
       
   591     }
       
   592 	
       
   593 	
       
   594 void CUSBRemotePersonalityTest::ExampleModuleTestL( TUSBRemotePersonalityTestResult& aTestResult )
       
   595     {
       
   596 	STIF_LOG( "[STIF_LOG] >>>ExampleModuleTestL" );
       
   597 	
       
   598     aTestResult = ETestCasePassed;
       
   599 	
       
   600 	STIF_LOG( "[STIF_LOG] <<<ExampleModuleTestL" );
       
   601     }
       
   602 	
       
   603 // -----------------------------------------------------------------------------
       
   604 // CUSBRemotePersonalityTest::ExecuteBranchTest
       
   605 // -----------------------------------------------------------------------------
       
   606 	
       
   607 TInt CUSBRemotePersonalityTest::ExecuteBranchTest( CStifItemParser& aItem )
       
   608     {
       
   609 	STIF_LOG( "[STIF_LOG] >>>ExecuteBranchTest" );
       
   610 	
       
   611     TInt res;
       
   612     TUSBRemotePersonalityTestResult testResult;
       
   613     TPtrC branchTestName( KNullDesC );
       
   614 
       
   615     res = aItem.GetString( _L( "ExecuteBranchTest" ), branchTestName );   
       
   616     if ( res != KErrNone )
       
   617         {
       
   618         iLog -> Log( _L( "GetString failed with value: %d" ), res );
       
   619         return res;
       
   620         }
       
   621 
       
   622     TRAP( res, DoExecuteBranchTestL( branchTestName, testResult ) );
       
   623     if ( res != KErrNone )
       
   624         {
       
   625         iLog -> Log( _L( "DoExecuteBranchTestL error: %d"), res );
       
   626         return res;
       
   627         }
       
   628     
       
   629     STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
       
   630     STIF_LOG( "[STIF_LOG] Test case passed" );
       
   631 	STIF_LOG( "[STIF_LOG] <<<ExecuteBranchTest" );
       
   632     return KErrNone;
       
   633     }
       
   634 
       
   635 	
       
   636 void CUSBRemotePersonalityTest::DoExecuteBranchTestL( TPtrC aBranchTestName, TUSBRemotePersonalityTestResult& aTestResult )
       
   637     {
       
   638 	STIF_LOG( "[STIF_LOG] >>>DoExecuteBranchTestL" );
       
   639     if ( !aBranchTestName.Compare( _L( "ExampleBranchTest" ) ) )
       
   640         {
       
   641         STIF_LOG( "[STIF_LOG] Branch test type: ExampleBranchTest" );
       
   642         ExampleBranchTestL( aTestResult );
       
   643         }
       
   644     else
       
   645         {
       
   646         STIF_LOG( "[STIF_LOG] Branch test type: not found" );
       
   647         User::Leave( KErrNotFound );
       
   648         }
       
   649 	STIF_LOG( "[STIF_LOG] <<<DoExecuteBranchTestL" );
       
   650     }
       
   651 	
       
   652 	
       
   653 void CUSBRemotePersonalityTest::ExampleBranchTestL( TUSBRemotePersonalityTestResult& aTestResult )
       
   654     {
       
   655 	STIF_LOG( "[STIF_LOG] >>>ExampleBranchTestL" );
       
   656 	
       
   657     aTestResult = ETestCasePassed;
       
   658     
       
   659 	STIF_LOG( "[STIF_LOG] <<<ExampleBranchTestL" );
       
   660 	}
       
   661 	
       
   662 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   663 // None
       
   664 
       
   665 //  [End of File] - Do not remove