usbuis/usbuinotif/tsrc/usbuinotifapitest/src/usbuinotifapitestblocks.cpp
branchRCL_3
changeset 23 25fce757be94
parent 6 a15c582fbf97
child 24 e02eb84a14d2
equal deleted inserted replaced
22:5b2a402e96ac 23:25fce757be94
     1 /*
     1 /*
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    13 *
    13 *
    14 * Description:  
    14 * Description:  
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
       
    19 
       
    20 
       
    21 // [INCLUDE FILES] - do not remove
    18 // [INCLUDE FILES] - do not remove
    22 #include <e32svr.h>
    19 #include <e32svr.h>
    23 #include <StifParser.h>
    20 #include <StifParser.h>
    24 #include <ecom/ecom.h>
    21 #include <ecom/ecom.h>
    25 #include <Stiftestinterface.h>
    22 #include <Stiftestinterface.h>
    26 #include "UsbUiNotifApiTest.h"
    23 #include "usbuinotifapitest.h"
    27 
    24 
    28 // EXTERNAL DATA STRUCTURES
    25 // EXTERNAL DATA STRUCTURES
    29 //extern  ?external_data;
       
    30 
    26 
    31 // EXTERNAL FUNCTION PROTOTYPES  
    27 // EXTERNAL FUNCTION PROTOTYPES  
    32 //extern ?external_function( ?arg_type,?arg_type );
       
    33 
    28 
    34 // CONSTANTS
    29 // CONSTANTS
    35 //const ?type ?constant_var = ?constant;
    30 #ifdef __WINS__
       
    31 _LIT( KUsbAppProcPattern, "usb[*" );
       
    32 #else
       
    33 _LIT( KUsbAppProcPattern, "#USBSettingsApp*" );
       
    34 #endif
    36 
    35 
    37 // MACROS
    36 // MACROS
    38 //#define ?macro ?macro_def
       
    39 
    37 
    40 // LOCAL CONSTANTS AND MACROS
    38 // LOCAL CONSTANTS AND MACROS
    41 //const ?type ?constant_var = ?constant;
       
    42 //#define ?macro_name ?macro_def
       
    43 
    39 
    44 // MODULE DATA STRUCTURES
    40 // MODULE DATA STRUCTURES
    45 //enum ?declaration
       
    46 //typedef ?declaration
       
    47 
    41 
    48 // LOCAL FUNCTION PROTOTYPES
    42 // LOCAL FUNCTION PROTOTYPES
    49 //?type ?function_name( ?arg_type, ?arg_type );
       
    50 
    43 
    51 // FORWARD DECLARATIONS
    44 // FORWARD DECLARATIONS
    52 //class ?FORWARD_CLASSNAME;
       
    53 
    45 
    54 // ============================= LOCAL FUNCTIONS ===============================
    46 // ============================= LOCAL FUNCTIONS ===============================
    55 
    47 
    56 // -----------------------------------------------------------------------------
       
    57 // ?function_name ?description.
       
    58 // ?description
       
    59 // Returns: ?value_1: ?description
       
    60 //          ?value_n: ?description_line1
       
    61 //                    ?description_line2
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 /*
       
    65 ?type ?function_name(
       
    66     ?arg_type arg,  // ?description
       
    67     ?arg_type arg)  // ?description
       
    68     {
       
    69 
       
    70     ?code  // ?comment
       
    71 
       
    72     // ?comment
       
    73     ?code
       
    74     }
       
    75 */
       
    76 
       
    77 // ============================ MEMBER FUNCTIONS ===============================
    48 // ============================ MEMBER FUNCTIONS ===============================
    78 
    49 
    79 // -----------------------------------------------------------------------------
    50 // -----------------------------------------------------------------------------
    80 // CUsbUiNotifApiTest::Delete
    51 // CUSBUiNotifApiTest::Delete
    81 // Delete here all resources allocated and opened from test methods. 
    52 // Delete here all resources allocated and opened from test methods. 
    82 // Called from destructor. 
    53 // Called from destructor. 
    83 // -----------------------------------------------------------------------------
    54 // -----------------------------------------------------------------------------
    84 //
    55 //
    85 void CUsbUiNotifApiTest::Delete() 
    56 void CUSBUiNotifApiTest::Delete() 
    86 	{
    57     {
    87     iNotifier -> Close();
    58     iNotifier -> Close();
    88     delete iNotifier;
    59     delete iNotifier;
    89     iNotifier = NULL;
    60     iNotifier = NULL;
    90     iUsbWatcher -> Close();
    61     }
    91     delete iUsbWatcher;
    62 
    92     iUsbWatcher = NULL;
    63 // -----------------------------------------------------------------------------
    93     delete iRepository;
    64 // CUSBUiNotifApiTest::RunMethodL
    94     iRepository = NULL;
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CUsbUiNotifApiTest::RunMethodL
       
    99 // Run specified method. Contains also table of test mothods and their names.
    65 // Run specified method. Contains also table of test mothods and their names.
   100 // -----------------------------------------------------------------------------
    66 // -----------------------------------------------------------------------------
   101 //
    67 //
   102 TInt CUsbUiNotifApiTest::RunMethodL( 
    68 TInt CUSBUiNotifApiTest::RunMethodL( 
   103     CStifItemParser& aItem ) 
    69     CStifItemParser& aItem ) 
   104     {
    70     {
   105 
    71 
   106     static TStifFunctionInfo const KFunctions[] =
    72     static TStifFunctionInfo const KFunctions[] =
   107         {  
    73         {  
       
    74         // Copy this line for every implemented function.
       
    75         // First string is the function name used in TestScripter script file.
       
    76         // Second is the actual implementation member function. 
       
    77         ENTRY( "CableConnectedNotifierTest", CUSBUiNotifApiTest::CableConnectedNotifierTest ),
       
    78         ENTRY( "FinishCableConnectedQuery", CUSBUiNotifApiTest::FinishCableConnectedQuery ),        
       
    79         ENTRY( "UsbQueriesNotifierTest", CUSBUiNotifApiTest::UsbQueriesNotifierTest ),
       
    80         ENTRY( "FinishQuery", CUSBUiNotifApiTest::FinishQuery ),
       
    81         ENTRY( "UsbOTGErrorNotifierTests", CUSBUiNotifApiTest::UsbOTGErrorNotifierTests ), 
       
    82         ENTRY( "UsbOTGWarningNotifierTests", CUSBUiNotifApiTest::UsbOTGWarningNotifierTests ),
       
    83         ENTRY( "LoadNotifiers", CUSBUiNotifApiTest::LoadNotifiersL ),
       
    84         ENTRY( "UnLoadNotifiers", CUSBUiNotifApiTest::UnLoadNotifiers ),
       
    85         ENTRY( "UsbMSMMNotifierTests", CUSBUiNotifApiTest::UsbMSMMNotifierTests ),
       
    86         ENTRY( "CancelMsmmNotifier", CUSBUiNotifApiTest::CancelMsmmNotifier ),
       
    87         ENTRY( "CancelQueryNotifier", CUSBUiNotifApiTest::CancelQueryNotifier ),
       
    88         ENTRY( "CancelOtgErrorNotifier", CUSBUiNotifApiTest::CancelOtgErrorNotifier ),
       
    89         ENTRY( "CancelOtgWarningNotifier", CUSBUiNotifApiTest::CancelOtgWarningNotifier ),
       
    90         ENTRY( "CancelCableConnectedNotifier", CUSBUiNotifApiTest::CancelCableConnectedNotifier ),
       
    91         ENTRY( "WaitForRequest", CUSBUiNotifApiTest::WaitForRequest ),
       
    92         ENTRY( "SynchStart", CUSBUiNotifApiTest::SynchStart ),	
       
    93         ENTRY( "Update", CUSBUiNotifApiTest::Update )
   108         //ADD NEW ENTRY HERE
    94         //ADD NEW ENTRY HERE
   109         // [test cases entries] - Do not remove
    95         // [test cases entries] - Do not remove
   110 		ENTRY( "ExecuteApiTestBlock", CUsbUiNotifApiTest::ExecuteApiTestBlock ),
    96 
   111         ENTRY( "ExecuteModuleTestBlock", CUsbUiNotifApiTest::ExecuteModuleTestBlock ),
       
   112         ENTRY( "ExecuteBranchTestBlock", CUsbUiNotifApiTest::ExecuteBranchTestBlock ),
       
   113         };
    97         };
   114 
    98 
   115     const TInt count = sizeof( KFunctions ) / 
    99     const TInt count = sizeof( KFunctions ) / 
   116                         sizeof( TStifFunctionInfo );
   100                         sizeof( TStifFunctionInfo );
   117 
   101 
   118     return RunInternalL( KFunctions, count, aItem );
   102     return RunInternalL( KFunctions, count, aItem );
   119 
   103 
   120     }
   104     }
   121 
   105 
   122 // -----------------------------------------------------------------------------
   106 // -----------------------------------------------------------------------------
   123 // CUsbUiNotifApiTest::GetTestBlockParamsL
   107 // CUSBUiNotifApiTest::CableConnectedNotifierTests
   124 // -----------------------------------------------------------------------------
   108 // -----------------------------------------------------------------------------
   125 
   109 
   126 void CUsbUiNotifApiTest::GetTestBlockParamsL( CStifItemParser& aItem )
   110 TInt CUSBUiNotifApiTest::CableConnectedNotifierTest( CStifItemParser& /*aItem*/ )
   127     {
   111     {
   128     TRACE_INFO( _L(">>> GetTestBlockParamsL") );
       
   129     
       
   130     // Add new test block branches below, get all required test parameters    
       
   131     if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) )
       
   132         {              
       
   133         User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) );        
       
   134         User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );
       
   135         User::LeaveIfError( aItem.GetNextInt( iTestBlockParams.iTestIntOption1 ) );        
       
   136         User::LeaveIfError( aItem.GetNextChar( iTestBlockParams.iTestCharOption1 ) );        
       
   137         }
       
   138     else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CableConnectedNotifierTest" ) ) )
       
   139 		{                      
       
   140 		User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
       
   141 		}
       
   142 	else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) )
       
   143 		{                      
       
   144 		User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
       
   145 		}
       
   146 	else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FinishQuery" ) ) )
       
   147 		{                      
       
   148 		User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
       
   149 		}
       
   150 	else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbOTGErrorNotifierTests" ) ) )
       
   151 		{                      
       
   152 		User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
       
   153 		}
       
   154 	else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbOTGWarningNotifierTests" ) ) )
       
   155 		{                      
       
   156 		User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
       
   157 		}
       
   158 	else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "LoadNotifiers" ) ) )
       
   159 		{                           
       
   160 		}
       
   161 	else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UnLoadNotifiers" ) ) )
       
   162 		{                      
       
   163 		}
       
   164 	else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbMSMMNotifierTests" ) ) )
       
   165 		{                      
       
   166 		User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) );       
       
   167 		}
       
   168     else
       
   169         {
       
   170         TRACE_INFO( _L("GetTestBlockParamsL() Test type: not found") );
       
   171         User::Leave( KErrNotFound );
       
   172         }
       
   173     TRACE_INFO( _L("<<< GetTestBlockParamsL") );
       
   174     }
       
   175 
       
   176 // -----------------------------------------------------------------------------
       
   177 // CUsbUiNotifApiTest::ExecuteApiTestBlock
       
   178 // -----------------------------------------------------------------------------
       
   179 
       
   180 TInt CUsbUiNotifApiTest::ExecuteApiTestBlock( CStifItemParser& aItem )
       
   181     {
       
   182     TRACE_INFO( _L(">>> ExecuteApiTestBlock") );
       
   183 	
       
   184 	TInt res;
       
   185     TUsbUiNotifApiTestResult testResult = ETestCaseFailed;
       
   186 	
       
   187     TRAP( res, DoExecuteApiTestBlockL( aItem, testResult ) );
       
   188     if ( res != KErrNone )
       
   189         {
       
   190         TRACE_INFO( (_L("DoExecuteApiTestBlockL error: %d"), res) );
       
   191         return res;
       
   192         }
       
   193     
       
   194     STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
       
   195     TRACE_INFO( _L("Test case passed") );
       
   196     
       
   197     TRACE_INFO( _L("<<< ExecuteApiTestBlock") );
       
   198 	
       
   199     return KErrNone;
       
   200     }
       
   201 	
       
   202 	
       
   203 void CUsbUiNotifApiTest::DoExecuteApiTestBlockL( CStifItemParser& aItem, TUsbUiNotifApiTestResult& aTestResult )
       
   204     {
       
   205     TRACE_INFO( _L(">>>DoExecuteApiTestBlockL") );
       
   206 
       
   207 	User::LeaveIfError( aItem.GetString( _L( "ExecuteApiTestBlock" ), iTestBlockParams.iTestBlockName ) );
       
   208         TRACE_INFO( (_L("Api test type: %S"), &iTestBlockParams.iTestBlockName) );
       
   209 	
       
   210 	GetTestBlockParamsL( aItem );
       
   211 	
       
   212 	// Add new API test block branches with optional test parameters here	
       
   213     if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) )
       
   214         {      
       
   215         ExampleTestL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, 
       
   216                 iTestBlockParams.iTestIntOption1, iTestBlockParams.iTestCharOption1, aTestResult );
       
   217         }	
       
   218     else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CableConnectedNotifierTest" ) ) )
       
   219         {      
       
   220         CableConnectedNotifierTest( iTestBlockParams.iTestOption2, aTestResult );
       
   221         }
       
   222     else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) )
       
   223         {      
       
   224         UsbQueriesNotifierTest( iTestBlockParams.iTestOption2, aTestResult );
       
   225         }
       
   226     else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FinishQuery" ) ) )
       
   227         {      
       
   228         FinishQuery( iTestBlockParams.iTestOption2, aTestResult );
       
   229         }
       
   230     else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) )
       
   231         {      
       
   232         UsbQueriesNotifierTest( iTestBlockParams.iTestOption2, aTestResult );
       
   233         }
       
   234     else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) )
       
   235         {      
       
   236         UsbQueriesNotifierTest( iTestBlockParams.iTestOption2, aTestResult );
       
   237         }
       
   238     else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) )
       
   239         {      
       
   240         UsbQueriesNotifierTest( iTestBlockParams.iTestOption2, aTestResult );
       
   241         }
       
   242     else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbOTGErrorNotifierTests" ) ) )
       
   243         {      
       
   244         UsbOTGErrorNotifierTests( iTestBlockParams.iTestOption2, aTestResult );
       
   245         }
       
   246     else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbOTGWarningNotifierTests" ) ) )
       
   247         {      
       
   248         UsbOTGWarningNotifierTests( iTestBlockParams.iTestOption2, aTestResult );
       
   249         }
       
   250     else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "LoadNotifiers" ) ) )
       
   251         {      
       
   252         LoadNotifiersL( aTestResult );
       
   253         }
       
   254     else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UnLoadNotifiers" ) ) )
       
   255         {      
       
   256         UnLoadNotifiers( aTestResult );
       
   257         }
       
   258     else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbMSMMNotifierTests" ) ) )
       
   259         {      
       
   260         UsbMSMMNotifierTests( iTestBlockParams.iTestOption2, aTestResult );
       
   261         }
       
   262     else
       
   263         {
       
   264     TRACE_INFO( _L("DoExecuteApiTestBlockL() Test type: not found") );
       
   265         User::Leave( KErrNotFound );
       
   266         }
       
   267 	
       
   268     TRACE_INFO( _L("<<<DoExecuteApiTestBlockL") );
       
   269     }
       
   270 	
       
   271 // -----------------------------------------------------------------------------
       
   272 // CUsbUiNotifApiTest::ExecuteModuleTestBlock
       
   273 // -----------------------------------------------------------------------------	
       
   274 
       
   275 TInt CUsbUiNotifApiTest::ExecuteModuleTestBlock( CStifItemParser& aItem )
       
   276     {
       
   277     TRACE_INFO( _L(">>>ExecuteModuleTestBlock") );
       
   278 	
       
   279     TInt res;
   112     TInt res;
   280     TUsbUiNotifApiTestResult testResult;
   113     TPtrC8 dummyPckg; //no parameters used
   281     
   114     
   282     TRAP( res, DoExecuteModuleTestBlockL( aItem, testResult ) );
   115     res = iNotifier -> Connect();
   283     if ( res != KErrNone )
   116     if ( res != KErrNone )
   284         {
   117         {
   285         TRACE_INFO( (_L("DoExecuteModuleTestBlockL error: %d"), res) );
   118         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
   286         return res;
   119         return res;
   287         }
   120         }   
   288     
   121     iLog -> Log( _L("RNotifier connected") );
   289     STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
   122 
   290     TRACE_INFO( _L("Test case passed") );
   123     //kill the possibly running usb application
   291     TRACE_INFO( _L("<<<ExecuteModuleTestBlock") );
   124     FindAndKillProcess(KUsbAppProcPattern);
   292     return KErrNone;
   125     
   293     }	
   126     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KCableConnectedNotifierUid, 
   294 	
   127             dummyPckg, iConnectionNotifierResponseParamsPckg );    
   295 	
   128     
   296 void CUsbUiNotifApiTest::DoExecuteModuleTestBlockL( CStifItemParser& aItem, TUsbUiNotifApiTestResult& aTestResult )
   129     return KErrNone;
   297     {
   130     
   298     TRACE_INFO( _L(">>>DoExecuteModuleTestBlockL") );
   131     }
   299 	
   132 
   300     User::LeaveIfError( aItem.GetString( _L( "ExecuteModuleTestBlock" ), iTestBlockParams.iTestBlockName ) );
   133 
   301     TRACE_INFO( (_L("Module test type: %S"), &iTestBlockParams.iTestBlockName) );
   134 TInt CUSBUiNotifApiTest::FinishCableConnectedQuery( CStifItemParser& aItem )
   302     
   135     {
   303     GetTestBlockParamsL( aItem );
   136     //give time for application to start, in microseconds
   304     
   137     const TInt KAppLaunchDelay = 5000000; 
   305     // Add new module test block branches with optional test parameters here   
       
   306     if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) )
       
   307         {      
       
   308         ExampleTestL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, 
       
   309                 iTestBlockParams.iTestIntOption1, iTestBlockParams.iTestCharOption1, aTestResult );
       
   310         }
       
   311     else
       
   312         {
       
   313     TRACE_INFO( _L("DoExecuteModuleTestBlockL() Test type: not found") );
       
   314         User::Leave( KErrNotFound );
       
   315         }
       
   316     
       
   317     TRACE_INFO( _L("<<<DoExecuteModuleTestBlockL") );
       
   318     }
       
   319 	
       
   320 // -----------------------------------------------------------------------------
       
   321 // CUsbUiNotifApiTest::ExecuteBranchTestBlock
       
   322 // -----------------------------------------------------------------------------
       
   323 	
       
   324 TInt CUsbUiNotifApiTest::ExecuteBranchTestBlock( CStifItemParser& aItem )
       
   325     {
       
   326     TRACE_INFO( _L(">>>ExecuteBranchTestBlock") );
       
   327 	
       
   328     TInt res;
   138     TInt res;
   329     TUsbUiNotifApiTestResult testResult;
   139     TPtrC optionName( KNullDesC );
   330     
   140     TTestOption option;
   331     TRAP( res, DoExecuteBranchTestBlockL( aItem, testResult ) );
   141     TPtrC expectedUsbPersonalityName( KNullDesC );
   332     if ( res != KErrNone )
   142     TInt expectedErrorCode;
   333         {
   143 
   334         TRACE_INFO( (_L("DoExecuteBranchTestBlockL error: %d"), res) );
   144     iLog -> Log( _L("FinishCableConnectedQuery") );
   335         return res;
   145     
   336         }   
   146     res = aItem.GetString( _L( "FinishCableConnectedQuery" ), optionName );
   337     
       
   338     STIF_ASSERT_EQUALS( ETestCasePassed, testResult );
       
   339     TRACE_INFO( _L("Test case passed") );
       
   340     TRACE_INFO( _L("<<<ExecuteBranchTestBlock") );
       
   341     return KErrNone;
       
   342     }
       
   343 
       
   344 	
       
   345 void CUsbUiNotifApiTest::DoExecuteBranchTestBlockL( CStifItemParser& aItem, TUsbUiNotifApiTestResult& aTestResult )
       
   346     {
       
   347     TRACE_INFO( _L(">>>DoExecuteBranchTestBlockL") );
       
   348 	
       
   349     User::LeaveIfError( aItem.GetString( _L( "ExecuteBranchTestBlock" ), iTestBlockParams.iTestBlockName ) );
       
   350     TRACE_INFO( (_L("Branch test type: %S"), &iTestBlockParams.iTestBlockName) );
       
   351     
       
   352     GetTestBlockParamsL( aItem );
       
   353     
       
   354     // Add new branch test block branches with optional test parameters here   
       
   355     if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) )
       
   356         {      
       
   357         ExampleTestL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, 
       
   358                 iTestBlockParams.iTestIntOption1, iTestBlockParams.iTestCharOption1, aTestResult );
       
   359         }
       
   360     else
       
   361         {
       
   362     TRACE_INFO( _L("DoExecuteBranchTestBlockL() Test type: not found") );
       
   363         User::Leave( KErrNotFound );
       
   364         }
       
   365     
       
   366     TRACE_INFO( _L("<<<DoExecuteBranchTestBlockL") );
       
   367     }
       
   368 
       
   369 // Add test block methods implementation here
       
   370 // -----------------------------------------------------------------------------
       
   371 // CUsbUiNotifApiTest::ExampleTestL
       
   372 // -----------------------------------------------------------------------------
       
   373 
       
   374 void CUsbUiNotifApiTest::ExampleTestL( TPtrC aTestOption, TPtrC aTestSubOption, 
       
   375         TInt aTestIntOption, TInt aTestCharOption, TUsbUiNotifApiTestResult& aTestResult )
       
   376     {
       
   377     TRACE_INFO( _L(">>>ExampleTestL") );
       
   378     
       
   379     if ( !aTestOption.Compare( _L( "API" ) ) )
       
   380         {
       
   381     TRACE_INFO( (_L("Api test option: %S"), &aTestOption) );
       
   382     TRACE_INFO( (_L("Api test sub-option: %S"), &aTestSubOption) );
       
   383     TRACE_INFO( (_L("Api test int option: %d"), aTestIntOption) );
       
   384     TRACE_INFO( (_L("Api test char option: %c"), aTestCharOption) );
       
   385         }
       
   386     else if ( !aTestOption.Compare( _L( "MODULE" ) ) )
       
   387         {
       
   388     TRACE_INFO( (_L("Module test option: %S"), &aTestOption) );
       
   389     TRACE_INFO( (_L("Module test sub-option: %S"), &aTestSubOption) );
       
   390     TRACE_INFO( (_L("Module test int option: %d"), aTestIntOption) );
       
   391     TRACE_INFO( (_L("Module test char option: %c"), aTestCharOption) );
       
   392         }
       
   393     else if ( !aTestOption.Compare( _L( "BRANCH" ) ) )
       
   394         {
       
   395     TRACE_INFO( (_L("Branch test option: %S"), &aTestOption) );
       
   396     TRACE_INFO( (_L("Branch test sub-option: %S"), &aTestSubOption) );
       
   397     TRACE_INFO( (_L("Branch test int option: %d"), aTestIntOption) );
       
   398     TRACE_INFO( (_L("Branch test char option: %c"), aTestCharOption) );
       
   399         }
       
   400     else
       
   401         {
       
   402         TRACE_INFO( _L("Invalid test parameter") );
       
   403         User::Leave( KErrNotFound );
       
   404         }
       
   405     
       
   406     aTestResult = ETestCasePassed;
       
   407     
       
   408     TRACE_INFO( _L("<<<ExampleTestL") );
       
   409     }
       
   410 
       
   411 // -----------------------------------------------------------------------------
       
   412 // CUsbUiNotifApiTest::CableConnectedNotifierTest
       
   413 // -----------------------------------------------------------------------------
       
   414 
       
   415 void CUsbUiNotifApiTest::CableConnectedNotifierTest( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult )
       
   416     {
       
   417     TRACE_INFO(  _L(">>>CableConnectedNotifierTest") );
       
   418     
       
   419     TInt res;
       
   420     TUSBConnectionNotifierParamsPckg emptyNotifierInputPckg;
       
   421     TPtrC displayedUsbPersonalityName( KNullDesC );
       
   422     TInt displayedUsbPersonalityId;
       
   423     
       
   424     res = GetPersonalityIdFromString( aTestSubOption, displayedUsbPersonalityId );
       
   425     if ( res != KErrNone )
       
   426         {
       
   427         TRACE_INFO(  (_L("GetPersonalityIdFromString failed with value: %d"), res) );
       
   428         return;
       
   429         }
       
   430     
       
   431     res = iRepository -> Get( KUsbWatcherPersonality, iPersonalityIdBackup );
       
   432     if ( res != KErrNone )
       
   433         {
       
   434         TRACE_INFO(  (_L("Personality backup failed with value (cenrep): %d"), res) );
       
   435         return;
       
   436         }
       
   437     
       
   438     res = iUsbWatcher -> Connect();
       
   439     if ( res != KErrNone )
       
   440         {
       
   441         TRACE_INFO(  (_L("Failed to connect UsbWatcher with value: %d"), res) );
       
   442         return;
       
   443         }   
       
   444     TRACE_INFO(  _L("UsbWatcher connected") );
       
   445         
   147         
   446     iUsbWatcher -> SetPersonality( iReqStatus, displayedUsbPersonalityId, ETrue, ETrue );
   148     if ( res != KErrNone )
       
   149         {
       
   150         iLog -> Log( _L("GetString failed with value: %d"), res );
       
   151         iNotifier -> Close();
       
   152         return res;
       
   153         }
       
   154     
       
   155     iLog -> Log( _L("FinishCableConnectedQuery getting option") );
       
   156     res = GetTestOption( optionName, option );
       
   157     if ( res != KErrNone )
       
   158         {
       
   159         iLog -> Log( _L("GetTestOption failed with value: %d"), res );
       
   160         iUsbWatcher -> Close();
       
   161         iNotifier -> Close();
       
   162         return res;
       
   163         }
       
   164  
       
   165     iLog -> Log( _L("FinishCableConnectedQuery wait for request") );
   447     User::WaitForRequest( iReqStatus );
   166     User::WaitForRequest( iReqStatus );
   448     if ( iReqStatus.Int() != KErrNone )
   167     expectedErrorCode = iReqStatus.Int();
   449         {
   168 
   450         TRACE_INFO(  (_L("Failed to set usb personality with value: %d"), iReqStatus.Int()) );
   169     iLog -> Log( _L("FinishCableConnectedQuery request complete") );
   451         iUsbWatcher -> Close();
   170     
   452         return;
   171     iNotifier -> Close();  
   453         }   
   172 
   454     
   173     iLog -> Log( _L("FinishCableConnectedQuery close") );
   455     res = iNotifier -> Connect();
   174     
   456     if ( res != KErrNone )
   175     TInt ret = KErrNone;
   457         {
   176     switch( option )
   458         TRACE_INFO(  (_L("Failed to connect RNotifier with value: %d"), res) );
   177         {
   459         iUsbWatcher -> Close();
   178         case EQueryAccepted:
   460         return;
   179             iLog -> Log( _L("EQueryAccepted"));
   461         }   
   180             User::After(KAppLaunchDelay); //let the app start and let the tester person to see that
   462     TRACE_INFO(  _L("RNotifier connected") );
   181             ret = FindAndKillProcess(KUsbAppProcPattern);
   463 
   182             if (ret != KErrNone)
   464     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KCableConnectedNotifierUid, emptyNotifierInputPckg, iConnectionNotifierResponseParamsPckg );    
   183                 {
   465     User::WaitForRequest( iReqStatus );
   184                 iLog -> Log( _L("Process start failed: %d"), ret );
   466     
   185                 return ret;
   467     TRACE_INFO((_L("StartNotifierAndGetResponse Status: %d, expected: %d"), iReqStatus.Int(), KErrCancel));
   186                 }
   468     if(iReqStatus.Int() == KErrCancel)
   187             iLog -> Log( _L("Request status value: %d, expected: %d"), expectedErrorCode, KErrCancel );
   469     	aTestResult = ETestCasePassed;
   188             //the notifier returns KErrCancel when clicked
   470     
   189             STIF_ASSERT_EQUALS( KErrCancel, expectedErrorCode );
   471     TRACE_INFO(  _L("<<<CableConnectedNotifierTest") );
   190             break;
   472     }
   191         case EQueryCanceled:
   473 
   192             iLog -> Log( _L("FinishCableConnectedQuery canceled") );
   474 
   193             iLog -> Log( _L("Request status value: %d, expected: %d"), expectedErrorCode, KErrCancel );
   475 // -----------------------------------------------------------------------------
   194             STIF_ASSERT_EQUALS( KErrCancel, expectedErrorCode );
   476 // CUsbUiNotifApiTest::UsbQueriesNotifierTest
   195             break;
   477 // -----------------------------------------------------------------------------
   196         default:
   478 
   197             iLog -> Log( _L("FinishCableConnectedQuery default - not found") );
   479 void CUsbUiNotifApiTest::UsbQueriesNotifierTest( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult )
   198             return KErrNotFound;
   480     {
   199         }
   481     TRACE_INFO(  _L(">>>UsbQueriesNotifierTest") );
   200 
       
   201     iLog -> Log( _L("Test case passed!") );
       
   202     return KErrNone;
       
   203     }
       
   204 
       
   205 
       
   206 // -----------------------------------------------------------------------------
       
   207 // CBtNotifApiTest::UsbQueriesNotifierTests
       
   208 // -----------------------------------------------------------------------------
       
   209 
       
   210 TInt CUSBUiNotifApiTest::UsbQueriesNotifierTest( CStifItemParser& aItem )
       
   211     {
   482     TInt res;    
   212     TInt res;    
       
   213     TPtrC usbQueryName( KNullDesC );
   483     TUSBUIQueries usbQueryType;
   214     TUSBUIQueries usbQueryType;
   484     
   215     
   485     
   216     res = aItem.GetString( _L( "UsbQueriesNotifierTest" ), usbQueryName );   
   486     res = GetQueryType( aTestSubOption, usbQueryType );
   217     if ( res != KErrNone )
   487     if ( res != KErrNone )
   218         {
   488         {
   219         iLog -> Log( _L("GetString failed with value: %d"), res );
   489         TRACE_INFO(  (_L("GetQueryType failed with value: %d"), res) );
   220         iNotifier -> Close();
   490         return;
   221         return res;
       
   222         }
       
   223     
       
   224     res = GetQueryType( usbQueryName, usbQueryType );
       
   225     if ( res != KErrNone )
       
   226         {
       
   227         iLog -> Log( _L("GetQueryType failed with value: %d"), res );
       
   228         return res;
   491         }
   229         }
   492     
   230     
   493     TUSBQueriesNotiferParams notifierParams;
   231     TUSBQueriesNotiferParams notifierParams;
   494     notifierParams.iDrive = 'c';
   232     notifierParams.iDrive = 'c';
   495     notifierParams.iQuery = usbQueryType;
   233     notifierParams.iQuery = usbQueryType;
   496     TUSBQueriesNotifierParamsPckg notifierParamsPckg( notifierParams );
   234     TUSBQueriesNotifierParamsPckg notifierParamsPckg( notifierParams );
   497     TPckgBuf<TBool> output;
   235     TPckgBuf<TBool> output;
   498     
   236     
   499     res = iNotifier -> Connect();
   237     if (!iNotifierConnected)
   500     if ( res != KErrNone )
   238         {
   501         {
   239         res = iNotifier -> Connect();
   502         TRACE_INFO(  (_L("Failed to connect RNotifier with value: %d"), res) );
   240         iNotifierConnected = ETrue;
   503         return;
   241         }
       
   242     if ( res != KErrNone )
       
   243         {
       
   244         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
       
   245         return res;
   504         }   
   246         }   
   505     TRACE_INFO(  _L("RNotifier connected") );
   247     iLog -> Log( _L("RNotifier connected") );
   506     
   248     
   507     switch( usbQueryType )
   249     switch( usbQueryType )
   508         {
   250         {
   509         case EUSBNoMemoryCard:
   251         case EUSBNoMemoryCard:
   510             iCompleteQuery = ETrue;
   252             iCompleteQuery = ETrue;
   515             break;
   257             break;
   516         default:
   258         default:
   517             break; 
   259             break; 
   518         }
   260         }
   519     
   261     
   520     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KQueriesNotifier, notifierParamsPckg, output ); 
   262     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KQueriesNotifier, 
   521 
   263             notifierParamsPckg, output ); 
   522     aTestResult = ETestCasePassed;
   264     iLog -> Log( _L("StartNotifierAndGetResponse ready") );
   523     
   265     
   524     TRACE_INFO(  _L("<<<UsbQueriesNotifierTest") );
   266     return KErrNone;
   525     }
   267     }
   526 
   268     
   527 // -----------------------------------------------------------------------------
   269 // -----------------------------------------------------------------------------
   528 // CUsbUiNotifApiTest::UsbOTGErrorNotifierTests
   270 // CBtNotifApiTest::UsbOTGErrorNotifierTests
   529 // -----------------------------------------------------------------------------
   271 // -----------------------------------------------------------------------------
   530 
   272 
   531 void CUsbUiNotifApiTest::UsbOTGErrorNotifierTests( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult )
   273 TInt CUSBUiNotifApiTest::UsbOTGErrorNotifierTests( CStifItemParser& aItem )
   532     {
   274     {
   533     TRACE_INFO(  _L(">>>UsbOTGErrorNotifierTests") );
       
   534     
       
   535     TInt res;    
   275     TInt res;    
       
   276     TPtrC usbQueryName( KNullDesC );
   536     TUsbUiNotifOtgError usbOTGErrorType;
   277     TUsbUiNotifOtgError usbOTGErrorType;
   537         
   278     
   538     res = GetOTGErrorType( aTestSubOption, usbOTGErrorType );
   279     res = aItem.GetString( _L( "UsbOTGErrorNotifierTests" ), usbQueryName );   
   539     if ( res != KErrNone )
   280     if ( res != KErrNone )
   540         {
   281         {
   541         TRACE_INFO(  (_L("usbOTGErrorType failed with value: %d"), res) );
   282         iLog -> Log( _L("GetString failed with value: %d"), res );
   542         return;
   283         iNotifier -> Close();
   543         }    
   284         return res;
   544     
   285         }
   545     res = iNotifier -> Connect();
   286     
   546     if ( res != KErrNone )
   287     res = GetOTGErrorType( usbQueryName, usbOTGErrorType );
   547         {
   288     if ( res != KErrNone )
   548         TRACE_INFO(  (_L("Failed to connect RNotifier with value: %d"), res) );
   289         {
   549         return;
   290         iLog -> Log( _L("usbOTGErrorType failed with value: %d"), res );
       
   291         return res;
       
   292         }    
       
   293     
       
   294     if (!iNotifierConnected)
       
   295         {
       
   296         res = iNotifier -> Connect();
       
   297         iNotifierConnected = ETrue;
       
   298         }
       
   299     if ( res != KErrNone )
       
   300         {
       
   301         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
       
   302         return res;
   550         }   
   303         }   
   551     TRACE_INFO(  _L("RNotifier connected") );
   304     iLog -> Log( _L("RNotifier connected") );
   552     
   305     
   553     TPckgBuf<TInt> notifierParamsPckg;
   306     TPckgBuf<TInt> notifierParamsPckg;
   554     notifierParamsPckg() = usbOTGErrorType;
   307     notifierParamsPckg() = usbOTGErrorType;
   555     iCompleteQuery = EFalse;
   308     iCompleteQuery = EFalse;
   556 
   309 
   557     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifOtgError, notifierParamsPckg, iRes ); 
   310     iNotifier -> StartNotifierAndGetResponse( iReqStatus, 
   558 
   311             KUsbUiNotifOtgError, notifierParamsPckg, iRes ); 
   559     aTestResult = ETestCasePassed;
   312     
   560     
   313     return KErrNone;
   561     TRACE_INFO(  _L("<<<UsbOTGErrorNotifierTests") );
   314     }
   562     }
   315 
   563 
   316 // -----------------------------------------------------------------------------
   564 // -----------------------------------------------------------------------------
   317 // CBtNotifApiTest::UsbOTGErrorNotifierTests
   565 // CUsbUiNotifApiTest::UsbOTGWarningNotifierTests
   318 // -----------------------------------------------------------------------------
   566 // -----------------------------------------------------------------------------
   319 
   567 
   320 TInt CUSBUiNotifApiTest::UsbOTGWarningNotifierTests( CStifItemParser& aItem )
   568 void CUsbUiNotifApiTest::UsbOTGWarningNotifierTests( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult )
       
   569     {        
   321     {        
   570     TRACE_INFO(  _L(">>>UsbOTGWarningNotifierTests") );
       
   571     
       
   572     TInt res;    
   322     TInt res;    
       
   323     TPtrC usbQueryName( KNullDesC );
   573     TUsbUiNotifOtgWarning usbOTGWarningType;
   324     TUsbUiNotifOtgWarning usbOTGWarningType;
   574     
   325     
   575     
   326     res = aItem.GetString( _L( "UsbOTGWarningNotifierTests" ), usbQueryName );   
   576     res = GetOTGWarningType( aTestSubOption, usbOTGWarningType );
   327     if ( res != KErrNone )
   577     if ( res != KErrNone )
   328         {
   578         {
   329         iLog -> Log( _L("GetString failed with value: %d"), res );
   579         TRACE_INFO(  (_L("usbOTGErrorType failed with value: %d"), res) );
   330         iNotifier -> Close();
   580         return;
   331         return res;
   581         }    
   332         }
   582     
   333     
   583     res = iNotifier -> Connect();
   334     res = GetOTGWarningType( usbQueryName, usbOTGWarningType );
   584     if ( res != KErrNone )
   335     if ( res != KErrNone )
   585         {
   336         {
   586         TRACE_INFO(  (_L("Failed to connect RNotifier with value: %d"), res) );
   337         iLog -> Log( _L("usbOTGErrorType failed with value: %d"), res );
   587         return;
   338         return res;
       
   339         }    
       
   340     
       
   341     if (!iNotifierConnected)
       
   342         {
       
   343         res = iNotifier -> Connect();
       
   344         iNotifierConnected = ETrue;
       
   345         }
       
   346     if ( res != KErrNone )
       
   347         {
       
   348         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
       
   349         return res;
   588         }   
   350         }   
   589     TRACE_INFO(  _L("RNotifier connected") );
   351     iLog -> Log( _L("RNotifier connected") );
   590     
   352     
   591     TPckgBuf<TInt> notifierParamsPckg;
   353     TPckgBuf<TInt> notifierParamsPckg;
   592     notifierParamsPckg() = usbOTGWarningType;
   354     notifierParamsPckg() = usbOTGWarningType;
   593     iCompleteQuery = EFalse;
   355     iCompleteQuery = EFalse;
   594 
   356 
   595     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifOtgWarning, notifierParamsPckg, iRes ); 
   357     iNotifier -> StartNotifierAndGetResponse( iReqStatus, 
   596 
   358             KUsbUiNotifOtgWarning, notifierParamsPckg, iRes ); 
   597     aTestResult = ETestCasePassed;
   359     
   598     
   360     return KErrNone;    
   599     TRACE_INFO(  _L("<<<UsbOTGWarningNotifierTests") ); 
   361     }
   600     }
   362 
   601 
   363 // -----------------------------------------------------------------------------
   602 // -----------------------------------------------------------------------------
   364 // CBtNotifApiTest::UsbMSMMNotifierTests
   603 // CUsbUiNotifApiTest::UsbMSMMNotifierTests
   365 // -----------------------------------------------------------------------------
   604 // -----------------------------------------------------------------------------
   366 
   605 
   367 TInt CUSBUiNotifApiTest::UsbMSMMNotifierTests( CStifItemParser& aItem )
   606 void CUsbUiNotifApiTest::UsbMSMMNotifierTests( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult )
       
   607     {        
   368     {        
   608     TRACE_INFO(  _L(">>>UsbMSMMNotifierTests") );
       
   609     
       
   610     TInt res;    
   369     TInt res;    
       
   370     TPtrC usbQueryName( KNullDesC );
   611     THostMsErrCode usbMSMMNErrorType;
   371     THostMsErrCode usbMSMMNErrorType;
   612     
   372     
   613     res = GetMSMMrrorType( aTestSubOption, usbMSMMNErrorType );
   373     iLog -> Log( _L("------msmm------") );
   614     if ( res != KErrNone )
   374     
   615         {
   375     res = aItem.GetString( _L( "UsbMSMMNotifierTests" ), usbQueryName );   
   616         TRACE_INFO(  (_L("MSMMrrorType failed with value: %d"), res) );
   376     if ( res != KErrNone )
   617         return;
   377         {
       
   378         iLog -> Log( _L("GetString failed with value: %d"), res );
       
   379         iNotifier -> Close();
       
   380         return res;
       
   381         }
       
   382     
       
   383     res = GetMSMMrrorType( usbQueryName, usbMSMMNErrorType );
       
   384     if ( res != KErrNone )
       
   385         {
       
   386         iLog -> Log( _L("MSMMrrorType failed with value: %d"), res );
       
   387         return res;
   618         }    
   388         }    
   619     iErrData.iError=usbMSMMNErrorType;
   389     iErrData.iError=usbMSMMNErrorType;
   620     iErrPckg = iErrData;
   390     iErrPckg = iErrData;
   621     res = iNotifier -> Connect();
   391     if (!iNotifierConnected)
   622     if ( res != KErrNone )
   392         {
   623         {
   393         res = iNotifier -> Connect();
   624         TRACE_INFO(  (_L("Failed to connect RNotifier with value: %d"), res) );
   394         iNotifierConnected = ETrue;
   625         return;
   395         }
       
   396     if ( res != KErrNone )
       
   397         {
       
   398         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
       
   399         return res;
   626         }   
   400         }   
   627     TRACE_INFO(  _L("RNotifier connected") );
   401     iLog -> Log( _L("RNotifier connected") );
   628     
   402     
   629     TPckgBuf<TInt> notifierParamsPckg;
   403     TPckgBuf<TInt> notifierParamsPckg;
   630     notifierParamsPckg() = usbMSMMNErrorType;
   404     notifierParamsPckg() = usbMSMMNErrorType;
   631     iCompleteQuery = EFalse;
   405     iCompleteQuery = EFalse;
   632 
   406 
   633     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifMsmmError, iErrPckg, iRes ); 
   407     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifMsmmError, iErrPckg, iRes ); 
   634 
   408     
   635     aTestResult = ETestCasePassed;
   409     return KErrNone;    
   636     
   410     }
   637     TRACE_INFO(  _L("<<<UsbMSMMNotifierTests") ); 
   411 
   638     }
   412 
   639 
   413 TInt CUSBUiNotifApiTest::CancelMsmmNotifier( CStifItemParser& /*aItem*/ ) 
   640 
   414     {
   641 // -----------------------------------------------------------------------------
   415     return ( iNotifier->CancelNotifier(KUsbUiNotifMsmmError) );
   642 // CUsbUiNotifApiTest::FinishQuery
   416     }
   643 // -----------------------------------------------------------------------------
   417 
   644 
   418 
   645 TInt CUsbUiNotifApiTest::FinishQuery( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult )
   419 TInt CUSBUiNotifApiTest::CancelQueryNotifier( CStifItemParser& /*aItem*/ ) 
   646     {
   420     {
   647     TRACE_INFO(  _L(">>>FinishQuery") ); 
   421     iLog -> Log( _L("CancelQueryNotifier") );
   648     
   422     return ( iNotifier->CancelNotifier(KQueriesNotifier) );
       
   423     }
       
   424 
       
   425 
       
   426 TInt CUSBUiNotifApiTest::CancelOtgErrorNotifier( CStifItemParser& /*aItem*/ ) 
       
   427     {
       
   428     return ( iNotifier->CancelNotifier(KUsbUiNotifOtgError) );
       
   429     }
       
   430 
       
   431 TInt CUSBUiNotifApiTest::CancelOtgWarningNotifier( CStifItemParser& /*aItem*/ ) 
       
   432     {
       
   433     return ( iNotifier->CancelNotifier(KUsbUiNotifOtgWarning) );
       
   434     }
       
   435 
       
   436 TInt CUSBUiNotifApiTest::CancelCableConnectedNotifier( CStifItemParser& /*aItem*/ ) 
       
   437     {
       
   438     return ( iNotifier->CancelNotifier(KCableConnectedNotifierUid) );
       
   439     }
       
   440 
       
   441 TInt CUSBUiNotifApiTest::WaitForRequest( CStifItemParser& /*aItem*/ ) 
       
   442     {
       
   443     User::WaitForRequest( iReqStatus );
       
   444     return KErrNone;
       
   445     }
       
   446 
       
   447 TInt CUSBUiNotifApiTest::SynchStart(CStifItemParser& aItem )
       
   448 {
       
   449     TInt res;    
       
   450     TPtrC usbQueryName( KNullDesC );
       
   451     TUsbUiNotifOtgWarning usbOTGWarningType;
       
   452     
       
   453     res = aItem.GetString( _L( "SynchStart" ), usbQueryName );   
       
   454     if ( res != KErrNone )
       
   455         {
       
   456         iLog -> Log( _L("GetString failed with value: %d"), res );
       
   457         iNotifier -> Close();
       
   458         return res;
       
   459         }
       
   460     
       
   461     res = GetOTGWarningType( usbQueryName, usbOTGWarningType );
       
   462     if ( res != KErrNone )
       
   463         {
       
   464         iLog -> Log( _L("usbOTGErrorType failed with value: %d"), res );
       
   465         return res;
       
   466         }    
       
   467  
       
   468  
       
   469     res = iNotifier -> Connect();
       
   470     if ( res != KErrNone )
       
   471         {
       
   472         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
       
   473         return res;
       
   474         }   
       
   475     iLog -> Log( _L("RNotifier connected") );
       
   476  
       
   477     TPckgBuf<TInt> notifierParamsPckg;
       
   478     notifierParamsPckg() = usbOTGWarningType;
       
   479     iCompleteQuery = EFalse;
       
   480 
       
   481     TInt retVal = iNotifier -> StartNotifier( KUsbUiNotifOtgWarning, notifierParamsPckg );
       
   482     iLog -> Log( _L("StartNotifier returned with value: %d"), retVal );
       
   483     
       
   484     iNotifier->Close();
       
   485     return retVal;    
       
   486 }
       
   487 
       
   488 TInt CUSBUiNotifApiTest::Update(CStifItemParser& /*aItem*/ )
       
   489 {
       
   490     //delay in microseconds before updating the notifier
       
   491     const TInt KUpdateDelay = 2000000;
       
   492     TInt res;    
       
   493     TPtrC usbQueryName( KNullDesC );
       
   494     
       
   495     res = iNotifier -> Connect();
       
   496     if ( res != KErrNone )
       
   497         {
       
   498         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
       
   499         return res;
       
   500         }   
       
   501     iLog -> Log( _L("RNotifier connected") );
       
   502  
       
   503     TPckgBuf<TInt> notifierParamsPckg;
       
   504     notifierParamsPckg() = EUsbOtgUnsupportedDevice;
       
   505     iCompleteQuery = EFalse;
       
   506     TPckgBuf<TInt> response ;
       
   507     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifOtgError, 
       
   508             notifierParamsPckg, iRes );
       
   509 		
       
   510     User::After(KUpdateDelay); //simulate update after a delay
       
   511     TPckgBuf<TInt> notifierParamsPckgUpdate;
       
   512     notifierParamsPckgUpdate() = EUsbOtgErrorNoMemory;    
       
   513   	TInt retVal = iNotifier -> UpdateNotifier( KUsbUiNotifOtgError, 
       
   514   	        notifierParamsPckgUpdate, response);
       
   515   	
       
   516     iNotifier->Close();  	
       
   517     return retVal;    
       
   518 }
       
   519 
       
   520 
       
   521 TInt CUSBUiNotifApiTest::FinishQuery( CStifItemParser& aItem )
       
   522     {
       
   523     iLog -> Log( _L("FinishQuery") );
   649     TInt res;
   524     TInt res;
       
   525     TPtrC optionName( KNullDesC );
   650     TTestOption option;
   526     TTestOption option;
   651     
   527     
   652     if ( iCompleteQuery )
   528     if ( iCompleteQuery )
   653         {
   529         {
       
   530         iLog -> Log( _L("FinishQuery completing request") );
   654         TRequestStatus* statPtr = &iReqStatus;
   531         TRequestStatus* statPtr = &iReqStatus;
   655         User::RequestComplete( statPtr, KErrNone );
   532         User::RequestComplete( statPtr, KErrNone );
   656         }    
   533         }
   657     
   534     
   658     res = GetTestOption( aTestSubOption, option );
   535     iLog -> Log( _L("FinishQuery getting options") );
   659     if ( res != KErrNone )
   536     res = aItem.GetString( _L( "FinishQuery" ), optionName );   
   660         {
   537     if ( res != KErrNone )
   661         TRACE_INFO(  (_L("GetTestOption failed with value: %d"), res) );
   538         {
       
   539         iLog -> Log( _L("GetString failed with value: %d"), res );
   662         iNotifier -> Close();
   540         iNotifier -> Close();
   663         return res;
   541         return res;
   664         }
   542         }
   665     
   543     
   666     User::WaitForRequest( iReqStatus );   
   544     res = GetTestOption( optionName, option );
       
   545     if ( res != KErrNone )
       
   546         {
       
   547         iLog -> Log( _L("GetTestOption failed with value: %d"), res );
       
   548         iNotifier -> Close();
       
   549         return res;
       
   550         }
       
   551     
       
   552     iLog -> Log( _L("FinishQuery waiting for request") );
       
   553     User::WaitForRequest( iReqStatus );
       
   554     iLog -> Log( _L("FinishQuery closing notifier") );
   667     iNotifier -> Close();
   555     iNotifier -> Close();
       
   556     iNotifierConnected = EFalse;
   668     
   557     
   669     switch( option )
   558     switch( option )
   670         {
   559         {
   671         case EQueryAccepted:
   560         case EQueryAccepted:
   672             TRACE_INFO(  (_L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone) );
   561             iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone );
   673             STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() );
   562             STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() );
   674             break;
   563             break;
   675         case EQueryCanceled:
   564         case EQueryCanceled:
   676             TRACE_INFO(  (_L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel) );
   565             iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel );
   677             STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() );
   566             STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() );
   678             break;
   567             break;
   679         default:
   568         default:
   680             return KErrNotFound;
   569             return KErrNotFound;
   681         }
   570         }
   682     
   571     
   683     aTestResult = ETestCasePassed;
   572     iLog -> Log( _L("Test case passed!") );
   684     
   573     return KErrNone;
   685     TRACE_INFO(  _L("<<<FinishQuery") ); 
   574     }
   686     
   575 
   687     return KErrNone;
   576 TInt CUSBUiNotifApiTest::LoadNotifiersL( CStifItemParser& /*aItem*/ )
   688     }
   577     {
   689 
       
   690 // -----------------------------------------------------------------------------
       
   691 // CUsbUiNotifApiTest::LoadNotifiersL
       
   692 // -----------------------------------------------------------------------------
       
   693 
       
   694 void CUsbUiNotifApiTest::LoadNotifiersL( TUsbUiNotifApiTestResult& aTestResult )
       
   695     {
       
   696     TRACE_INFO(  _L(">>>LoadNotifiersL") );
       
   697     
       
   698     iNotifierArray = reinterpret_cast<CArrayPtr<MEikSrvNotifierBase2>*>(
   578     iNotifierArray = reinterpret_cast<CArrayPtr<MEikSrvNotifierBase2>*>(
   699 												REComSession::CreateImplementationL(TUid::Uid(0x10281F23), iInstanceUid));
   579 												REComSession::CreateImplementationL(TUid::Uid(0x10281F23), iInstanceUid));
   700 
   580 	return KErrNone;	
   701     aTestResult = ETestCasePassed;
   581     }
   702     
   582     
   703     TRACE_INFO(  _L("<<<LoadNotifiersL") ); 	
   583 TInt CUSBUiNotifApiTest::UnLoadNotifiers ( CStifItemParser& /*aItem*/ )
   704     }
   584     {
   705 
       
   706 // -----------------------------------------------------------------------------
       
   707 // CUsbUiNotifApiTest::UnLoadNotifiers
       
   708 // -----------------------------------------------------------------------------
       
   709 
       
   710 void CUsbUiNotifApiTest::UnLoadNotifiers ( TUsbUiNotifApiTestResult& aTestResult )
       
   711     {
       
   712     TRACE_INFO(  _L(">>>UnLoadNotifiers") );
       
   713     
       
   714     TInt count = iNotifierArray->Count();
   585     TInt count = iNotifierArray->Count();
   715     TInt i=0;
   586     TInt i=0;
   716     for (i=0; i<count; i++)
   587     for (i=0; i<count; i++)
   717         {
   588         {
   718         iNotifierArray->At(i)->Release();        
   589         iNotifierArray->At(i)->Release();        
   719         }
   590         }
   720     iNotifierArray->Reset();    
   591     iNotifierArray->Reset();    
   721     delete iNotifierArray;
   592     delete iNotifierArray;
       
   593     iNotifierArray = NULL;
   722     REComSession::DestroyedImplementation(iInstanceUid);    
   594     REComSession::DestroyedImplementation(iInstanceUid);    
   723 
   595     return KErrNone;
   724     aTestResult = ETestCasePassed;
   596     }
   725     
   597                        
   726     TRACE_INFO(  _L("<<<UnLoadNotifiers") ); 
   598 TInt CUSBUiNotifApiTest::GetQueryType( TPtrC aTypeString, TUSBUIQueries& aQueryType )
   727     }
   599     {
   728 
       
   729 // -----------------------------------------------------------------------------
       
   730 // CUsbUiNotifApiTest::Update
       
   731 // -----------------------------------------------------------------------------
       
   732 
       
   733 void CUsbUiNotifApiTest::Update( TUsbUiNotifApiTestResult& aTestResult  )
       
   734     {
       
   735     TRACE_INFO(  _L(">>>Update") );
       
   736     TInt count = iNotifierArray->Count();
       
   737     TInt i=0;    
       
   738     _LIT8(test, "test");
       
   739     TBuf8<32> buf(test);
       
   740     for (i=0; i<count; i++)
       
   741         {
       
   742         iNotifierArray->At(i)->UpdateL(buf);        
       
   743         }    
       
   744     
       
   745     aTestResult = ETestCasePassed;
       
   746     
       
   747     TRACE_INFO(  _L("<<<Update") );
       
   748     }
       
   749 
       
   750 // -----------------------------------------------------------------------------
       
   751 // CUsbUiNotifApiTest::Notifierstart
       
   752 // -----------------------------------------------------------------------------
       
   753 
       
   754 void CUsbUiNotifApiTest::Notifierstart( TUsbUiNotifApiTestResult& aTestResult )
       
   755     {
       
   756     TRACE_INFO(  _L(">>>Notifierstart") );
       
   757     TInt count = iNotifierArray->Count();
       
   758     TInt i=0;    
       
   759     _LIT8(test, "test");
       
   760     TBuf8<32> buf(test);
       
   761     for (i=0; i<count; i++)
       
   762         {
       
   763         iNotifierArray->At(i)->StartL(buf);        
       
   764         }
       
   765     
       
   766     aTestResult = ETestCasePassed;
       
   767     
       
   768     TRACE_INFO(  _L("<<<Notifierstart") );
       
   769     }
       
   770 
       
   771 
       
   772 // -----------------------------------------------------------------------------
       
   773 // CUsbUiNotifApiTest::GetQueryType
       
   774 // -----------------------------------------------------------------------------
       
   775 
       
   776 TInt CUsbUiNotifApiTest::GetQueryType( TPtrC aTypeString, TUSBUIQueries& aQueryType )
       
   777     {
       
   778     TRACE_INFO(  _L(">>>GetQueryType") );
       
   779     if ( !aTypeString.Compare( _L( "EUSBNoMemoryCard" ) ) )
   600     if ( !aTypeString.Compare( _L( "EUSBNoMemoryCard" ) ) )
   780         {
   601         {
   781         aQueryType = EUSBNoMemoryCard;
   602         aQueryType = EUSBNoMemoryCard;
   782         TRACE_INFO(  _L("Query type: EUSBNoMemoryCard") );
   603         iLog -> Log( _L("Query type: EUSBNoMemoryCard") );
   783         }
   604         }
   784     else if ( !aTypeString.Compare( _L( "EUSBStorageMediaFailure" ) ) )
   605     else if ( !aTypeString.Compare( _L( "EUSBStorageMediaFailure" ) ) )
   785         {
   606         {
   786         aQueryType = EUSBStorageMediaFailure;
   607         aQueryType = EUSBStorageMediaFailure;
   787         TRACE_INFO(  _L("Query type: EUSBStorageMediaFailure") );
   608         iLog -> Log( _L("Query type: EUSBStorageMediaFailure") );
   788         }
   609         }
   789     else if ( !aTypeString.Compare( _L( "EUSBChangeFromMassStorage" ) ) )
   610     else if ( !aTypeString.Compare( _L( "EUSBDiskFull" ) ) )
   790         {
   611         {
   791         aQueryType = EUSBChangeFromMassStorage;
   612         aQueryType = EUSBDiskFull;
   792         TRACE_INFO(  _L("Query type: EUSBChangeFromMassStorage") );
   613         iLog -> Log( _L("Query type: EUSBDiskFull") );
       
   614         }    
       
   615     else if ( !aTypeString.Compare( _L( "EUSBNotEnoughRam" ) ) )
       
   616         {
       
   617         aQueryType = EUSBNotEnoughRam;
       
   618         iLog -> Log( _L("Query type: EUSBNotEnoughRam") );
   793         }    
   619         }    
   794     else
   620     else
   795         {
   621         {
   796         TRACE_INFO(  _L("Query type: not supported") );
   622         iLog -> Log( _L("Query type: not supported") );
   797         return KErrNotFound;
   623         return KErrNotFound;
   798         }
   624         }
   799     TRACE_INFO(  _L("<<<GetQueryType") );
   625  
   800     return KErrNone;
   626     return KErrNone;
   801     }
   627     }
   802 
   628 
   803 // -----------------------------------------------------------------------------
   629 TInt CUSBUiNotifApiTest::GetOTGErrorType( TPtrC aTypeString, TUsbUiNotifOtgError& aQueryType )
   804 // CUsbUiNotifApiTest::GetOTGErrorType
   630     {
   805 // -----------------------------------------------------------------------------
       
   806 
       
   807 TInt CUsbUiNotifApiTest::GetOTGErrorType( TPtrC aTypeString, TUsbUiNotifOtgError& aQueryType )
       
   808     {
       
   809     TRACE_INFO(  _L(">>>GetOTGErrorType") );
       
   810     
       
   811     if ( !aTypeString.Compare( _L( "EUsbOtgTooMuchPower" ) ) )
   631     if ( !aTypeString.Compare( _L( "EUsbOtgTooMuchPower" ) ) )
   812         {
   632         {
   813         aQueryType = EUsbOtgTooMuchPower;
   633         aQueryType = EUsbOtgTooMuchPower;
   814         TRACE_INFO(  _L("Query type: EUsbOtgTooMuchPower") );
   634         iLog -> Log( _L("Query type: EUsbOtgTooMuchPower") );
   815         }    
   635         }    
   816     else if ( !aTypeString.Compare( _L( "EUsbOtgTooMuchPowerRequired" ) ) )
   636     else if ( !aTypeString.Compare( _L( "EUsbOtgTooMuchPowerRequired" ) ) )
   817         {
   637         {
   818         aQueryType = EUsbOtgTooMuchPowerRequired;
   638         aQueryType = EUsbOtgTooMuchPowerRequired;
   819         TRACE_INFO(  _L("Query type: EUsbOtgTooMuchPowerRequired") );
   639         iLog -> Log( _L("Query type: EUsbOtgTooMuchPowerRequired") );
   820         }    
   640         }    
   821     else if ( !aTypeString.Compare( _L( "EUsbOtgUnsupportedDevice" ) ) )
   641     else if ( !aTypeString.Compare( _L( "EUsbOtgUnsupportedDevice" ) ) )
   822         {
   642         {
   823         aQueryType = EUsbOtgUnsupportedDevice;
   643         aQueryType = EUsbOtgUnsupportedDevice;
   824         TRACE_INFO(  _L("Query type: EUsbOtgUnsupportedDevice") );
   644         iLog -> Log( _L("Query type: EUsbOtgUnsupportedDevice") );
   825         }        
   645         }        
   826     else if ( !aTypeString.Compare( _L( "EUsbOtgHubUnsupported" ) ) )
   646     else if ( !aTypeString.Compare( _L( "EUsbOtgHubUnsupported" ) ) )
   827         {
   647         {
   828         aQueryType = EUsbOtgHubUnsupported;
   648         aQueryType = EUsbOtgHubUnsupported;
   829         TRACE_INFO(  _L("Query type: EUsbOtgHubUnsupported") );
   649         iLog -> Log( _L("Query type: EUsbOtgHubUnsupported") );
   830         }            
   650         }            
   831     else if ( !aTypeString.Compare( _L( "EUsbOtgErrorInConnection" ) ) )
   651     else if ( !aTypeString.Compare( _L( "EUsbOtgErrorInConnection" ) ) )
   832         {
   652         {
   833         aQueryType = EUsbOtgErrorInConnection;
   653         aQueryType = EUsbOtgErrorInConnection;
   834         TRACE_INFO(  _L("Query type: EUsbOtgErrorInConnection") );
   654         iLog -> Log( _L("Query type: EUsbOtgErrorInConnection") );
   835         }                
   655         }                
   836     else if ( !aTypeString.Compare( _L( "EUsbOtgErrorAttachTimedOut" ) ) )
   656     else if ( !aTypeString.Compare( _L( "EUsbOtgErrorAttachTimedOut" ) ) )
   837         {
   657         {
   838         aQueryType = EUsbOtgErrorAttachTimedOut;
   658         aQueryType = EUsbOtgErrorAttachTimedOut;
   839         TRACE_INFO(  _L("Query type: EUsbOtgErrorAttachTimedOut") );
   659         iLog -> Log( _L("Query type: EUsbOtgErrorAttachTimedOut") );
       
   660         }                    
       
   661     else if ( !aTypeString.Compare( _L( "EUsbOtgErrorNoMemory" ) ) )
       
   662         {
       
   663         aQueryType = EUsbOtgErrorNoMemory;
       
   664         iLog -> Log( _L("Query type: EUsbOtgErrorNoMemory") );
   840         }                    
   665         }                    
   841     else
   666     else
   842         {
   667         {
   843         TRACE_INFO(  _L("Query type: not supported") );
   668         iLog -> Log( _L("Query type: not supported") );
   844         return KErrNotFound;
   669         return KErrNotFound;
   845         } 
   670         } 
   846     
       
   847     TRACE_INFO(  _L("<<<GetOTGErrorType") );
       
   848     return KErrNone;    
   671     return KErrNone;    
   849     }
   672     }
   850 
   673 
   851 
   674 
   852 // -----------------------------------------------------------------------------
   675 TInt CUSBUiNotifApiTest::GetOTGWarningType( TPtrC aTypeString, TUsbUiNotifOtgWarning& aQueryType )
   853 // CUsbUiNotifApiTest::GetOTGWarningType
       
   854 // -----------------------------------------------------------------------------
       
   855 
       
   856 TInt CUsbUiNotifApiTest::GetOTGWarningType( TPtrC aTypeString, TUsbUiNotifOtgWarning& aQueryType )
       
   857     {        
   676     {        
   858     TRACE_INFO(  _L(">>>GetOTGWarningType") );
       
   859     
       
   860     if ( !aTypeString.Compare( _L( "EUsbOtgPartiallySupportedDevice" ) ) )
   677     if ( !aTypeString.Compare( _L( "EUsbOtgPartiallySupportedDevice" ) ) )
   861         {            
   678         {            
   862         aQueryType = EUsbOtgPartiallySupportedDevice;
   679         aQueryType = EUsbOtgPartiallySupportedDevice;
   863         TRACE_INFO(  _L("Query type: EUsbOtgPartiallySupportedDevice;") );
   680         iLog -> Log( _L("Query type: EUsbOtgPartiallySupportedDevice;") );
   864         }    
   681         }    
   865     else
   682     else
   866         {
   683         {
   867         TRACE_INFO(  _L("Query type: not supported") );
   684         iLog -> Log( _L("Query type: not supported") );
   868         return KErrNotFound;
   685         return KErrNotFound;
   869         }
   686         }
   870 
   687  
   871     TRACE_INFO(  _L("<<<GetOTGWarningType") );
   688     return KErrNone;
   872     
   689     }
   873     return KErrNone;
   690 
   874     }
   691 TInt CUSBUiNotifApiTest::GetMSMMrrorType( TPtrC aTypeString, THostMsErrCode& aQueryType )
   875 
       
   876 // -----------------------------------------------------------------------------
       
   877 // CUsbUiNotifApiTest::GetMSMMrrorType
       
   878 // -----------------------------------------------------------------------------
       
   879 
       
   880 TInt CUsbUiNotifApiTest::GetMSMMrrorType( TPtrC aTypeString, THostMsErrCode& aQueryType )
       
   881     {        
   692     {        
   882     TRACE_INFO(  _L(">>>GetMSMMrrorType") );
       
   883     if ( !aTypeString.Compare( _L( "EUsbMSMMGeneralError" ) ) )
   693     if ( !aTypeString.Compare( _L( "EUsbMSMMGeneralError" ) ) )
   884         {            
   694         {            
   885         aQueryType = EHostMsErrGeneral;
   695         aQueryType = EHostMsErrGeneral;
   886         TRACE_INFO(  _L("Query type: EUsbOtgPartiallySupportedDevice;") );
   696         iLog -> Log( _L("Query type: EUsbOtgPartiallySupportedDevice;") );
   887         }    
   697         }    
   888     else if ( !aTypeString.Compare( _L( "EUsbMSMMUnknownFileSystem" ) ) )
   698     else if ( !aTypeString.Compare( _L( "EUsbMSMMUnknownFileSystem" ) ) )
   889         {
   699         {
   890         aQueryType = EHostMsErrUnknownFileSystem;
   700         aQueryType = EHostMsErrUnknownFileSystem;
   891         TRACE_INFO(  _L("Query type: EUsbMSMMUnknownFileSystem") );
   701         iLog -> Log( _L("Query type: EUsbMSMMUnknownFileSystem") );
   892         }         
   702         }         
   893     else if ( !aTypeString.Compare( _L( "EUsbMSMMOutOfMemory" ) ) )
   703     else if ( !aTypeString.Compare( _L( "EUsbMSMMOutOfMemory" ) ) )
   894         {
   704         {
   895         aQueryType = EHostMsErrOutOfMemory;
   705         aQueryType = EHostMsErrOutOfMemory;
   896         TRACE_INFO(  _L("Query type: EUsbMSMMOutOfMemory") );
   706         iLog -> Log( _L("Query type: EUsbMSMMOutOfMemory") );
       
   707         }     
       
   708     else if ( !aTypeString.Compare( _L( "EUsbMSMMSafeToRemove" ) ) )
       
   709         {
       
   710         aQueryType = EHostMsErrNone;
       
   711         iLog -> Log( _L("Query type: EUsbMSMMSafeToRemove") );
       
   712         }     
       
   713     else if ( !aTypeString.Compare( _L( "EUsbMSMMUnableToEject" ) ) )
       
   714         {
       
   715         aQueryType = EHostMsErrInUse;
       
   716         iLog -> Log( _L("Query type: EUsbMSMMUnableToEject") );
   897         }     
   717         }     
   898     else
   718     else
   899         {
   719         {
   900         TRACE_INFO(  _L("Query type: not supported") );
   720         iLog -> Log( _L("Query type: not supported") );
   901         return KErrNotFound;
   721         return KErrNotFound;
   902         }
   722         }
   903 
   723  
   904     TRACE_INFO(  _L("<<<GetMSMMrrorType") );
   724     return KErrNone;
   905     return KErrNone;
   725     }
   906     }
   726     
   907 
   727 // -----------------------------------------------------------------------------
   908 // -----------------------------------------------------------------------------
   728 // CBtNotifApiTest::GetTestOption
   909 // CUsbUiNotifApiTest::GetTestOption
   729 // -----------------------------------------------------------------------------
   910 // -----------------------------------------------------------------------------
   730 
   911 
   731 TInt CUSBUiNotifApiTest::GetTestOption( TPtrC aOptionString, TTestOption& aOption )
   912 TInt CUsbUiNotifApiTest::GetTestOption( TPtrC aOptionString, TTestOption& aOption )
       
   913     {    
   732     {    
   914     if ( !aOptionString.Compare( _L( "DISCARD" ) ) )
   733     if ( !aOptionString.Compare( _L( "DISCARD" ) ) )
   915         {
   734         {
   916         aOption = EQueryDiscarded;
   735         aOption = EQueryDiscarded;
   917         TRACE_INFO(  _L("Test type: EQueryDiscarded") );
   736         iLog -> Log( _L("Test type: EQueryDiscarded") );
   918         }
   737         }
   919     else if ( !aOptionString.Compare( _L( "ACCEPT" ) ) )
   738     else if ( !aOptionString.Compare( _L( "ACCEPT" ) ) )
   920         {
   739         {
   921         aOption = EQueryAccepted;
   740         aOption = EQueryAccepted;
   922         TRACE_INFO(  _L("Test type: EQueryAccepted") );
   741         iLog -> Log( _L("Test type: EQueryAccepted") );
   923         }
   742         }
   924     else if ( !aOptionString.Compare( _L( "CANCEL" ) ) )
   743     else if ( !aOptionString.Compare( _L( "CANCEL" ) ) )
   925         {
   744         {
   926         aOption = EQueryCanceled;
   745         aOption = EQueryCanceled;
   927         TRACE_INFO(  _L("Test type: EQueryCanceled") );
   746         iLog -> Log( _L("Test type: EQueryCanceled") );
   928         }
   747         }
   929     else
   748     else
   930         {
   749         {
   931         TRACE_INFO(  _L("Test type: not supported") );
   750         iLog -> Log( _L("Test type: not supported") );
   932         return KErrNotFound;
   751         return KErrNotFound;
   933         }
   752         }
   934  
   753  
   935     return KErrNone;
   754     return KErrNone;
   936     }
   755     }
   937 
   756 
   938 // -----------------------------------------------------------------------------
   757 // -----------------------------------------------------------------------------
   939 // CUsbUiNotifApiTest::GetPersonalityIdFromString
   758 // CBtNotifApiTest::GetPersonalityIdFromString
   940 // -----------------------------------------------------------------------------
   759 // -----------------------------------------------------------------------------
   941 
   760 
   942 TInt CUsbUiNotifApiTest::GetPersonalityIdFromString( TPtrC aOptionString, TInt& aPersonalityId )
   761 TInt CUSBUiNotifApiTest::GetPersonalityIdFromString( TPtrC aOptionString, TInt& aPersonalityId )
   943     {    
   762     {    
   944     if ( !aOptionString.Compare( _L( "MS" ) ) )
   763     if ( !aOptionString.Compare( _L( "MS" ) ) )
   945         {
   764         {
   946         aPersonalityId = KUsbPersonalityIdMS;
   765         aPersonalityId = KUsbPersonalityIdMS;
   947         TRACE_INFO(  _L("Usb personality type: KUsbPersonalityIdMS") );
   766         iLog -> Log( _L("Usb personality type: KUsbPersonalityIdMS") );
   948         }
   767         }
   949     else if ( !aOptionString.Compare( _L( "PCSUITE" ) ) )
   768     else if ( !aOptionString.Compare( _L( "PTP" ) ) )
   950         {
   769         {
   951         aPersonalityId = KUsbPersonalityIdPCSuite;
   770         aPersonalityId = KUsbPersonalityIdPTP;
   952         TRACE_INFO(  _L("Usb personality type: KUsbPersonalityIdPCSuite") );
   771         iLog -> Log( _L("Usb personality type: KUsbPersonalityIdPTP") );
   953         }
   772         }
   954     else if ( !aOptionString.Compare( _L( "MTP" ) ) )
   773     else if ( !aOptionString.Compare( _L( "MTP" ) ) )
   955         {
   774         {
   956         aPersonalityId = KUsbPersonalityIdMTP;
   775         aPersonalityId = KUsbPersonalityIdMTP;
   957         TRACE_INFO(  _L("Usb personality type: KUsbPersonalityIdMTP") );
   776         iLog -> Log( _L("Usb personality type: KUsbPersonalityIdMTP") );
   958         }
   777         }
   959     else if ( !aOptionString.Compare( _L( "PCSUITEMTP" ) ) )
   778     else if ( !aOptionString.Compare( _L( "PCSUITEMTP" ) ) )
   960         {
   779         {
   961         aPersonalityId = KUsbPersonalityIdPCSuiteMTP;
   780         aPersonalityId = KUsbPersonalityIdPCSuiteMTP;
   962         TRACE_INFO(  _L("Usb personality type: KUsbPersonalityIdPCSuiteMTP") );
   781         iLog -> Log( _L("Usb personality type: KUsbPersonalityIdPCSuiteMTP") );
   963         }
   782         }
   964     else
   783     else
   965         {
   784         {
   966         TRACE_INFO(  _L("Usb personality type: not found") );
   785         iLog -> Log( _L("Usb personality type: not found") );
   967         return KErrNotFound;  
   786         return KErrNotFound;  
   968         }
   787         }
   969  
   788  
   970     return KErrNone;
   789     return KErrNone;
       
   790     }
       
   791 
       
   792 
       
   793 TInt CUSBUiNotifApiTest::FindAndKillProcess(const TDesC& aProcessName)
       
   794     {
       
   795     iLog -> Log( _L("FindAndKillProcess") );
       
   796     TInt ret = KErrNotFound;
       
   797     RProcess process;            
       
   798     TFindProcess findProc;
       
   799     findProc.Find(aProcessName);
       
   800     TFullName procName;
       
   801     ret = findProc.Next(procName);
       
   802     iLog -> Log( _L("FindAndKillProcess findProc returned: %d"), ret );
       
   803     if (ret == KErrNone)
       
   804         {
       
   805         ret = process.Open(procName, EOwnerThread);
       
   806         iLog -> Log( _L("FindAndKillProcess process open returned: %d"), ret );
       
   807         if (ret == KErrNone)
       
   808             {
       
   809             process.Terminate(KErrNone);
       
   810             process.Close();
       
   811             }
       
   812         }
       
   813     return ret;
   971     }
   814     }
   972 
   815 
   973 // ========================== OTHER EXPORTED FUNCTIONS =========================
   816 // ========================== OTHER EXPORTED FUNCTIONS =========================
   974 // None
   817 // None
   975 
   818