kerneltest/e32test/usbho/t_usbdi/src/PBASE-T_USBDI-0486.cpp
changeset 253 d37db4dcc88d
parent 0 a41df078684a
child 257 3e88ff8f41d5
equal deleted inserted replaced
252:0a40b8675b23 253:d37db4dcc88d
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    18 
    18 
    19 #include "PBASE-T_USBDI-0486.h"
    19 #include "PBASE-T_USBDI-0486.h"
    20 #include "testpolicy.h"
    20 #include "testpolicy.h"
    21 #include "testdebug.h"
    21 #include "testdebug.h"
    22 #include "modelleddevices.h"
    22 #include "modelleddevices.h"
       
    23 #include "OstTraceDefinitions.h"
       
    24 #ifdef OST_TRACE_COMPILER_IN_USE
       
    25 #include "PBASE-T_USBDI-0486Traces.h"
       
    26 #endif
    23 
    27 
    24 namespace NUnitTesting_USBDI
    28 namespace NUnitTesting_USBDI
    25 	{
    29 	{
    26 	
    30 	
    27 _LIT(KTestCaseId,"PBASE-T_USBDI-0486");
    31 _LIT(KTestCaseId,"PBASE-T_USBDI-0486");
    29 const TInt KBulkTranferId = 2;
    33 const TInt KBulkTranferId = 2;
    30 const TInt KExpectedDataSize = 26;
    34 const TInt KExpectedDataSize = 26;
    31 
    35 
    32 CUT_PBASE_T_USBDI_0486* CUT_PBASE_T_USBDI_0486::NewL(TBool aHostRole)
    36 CUT_PBASE_T_USBDI_0486* CUT_PBASE_T_USBDI_0486::NewL(TBool aHostRole)
    33 	{
    37 	{
       
    38 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_NEWL_ENTRY, aHostRole );
    34 	CUT_PBASE_T_USBDI_0486* self = new (ELeave) CUT_PBASE_T_USBDI_0486(aHostRole);
    39 	CUT_PBASE_T_USBDI_0486* self = new (ELeave) CUT_PBASE_T_USBDI_0486(aHostRole);
    35 	CleanupStack::PushL(self);
    40 	CleanupStack::PushL(self);
    36 	self->ConstructL();
    41 	self->ConstructL();
    37 	CleanupStack::Pop(self);
    42 	CleanupStack::Pop(self);
       
    43 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_NEWL_EXIT, ( TUint )( self ) );
    38 	return self;  
    44 	return self;  
    39 	} 
    45 	} 
    40 	
    46 	
    41 
    47 
    42 CUT_PBASE_T_USBDI_0486::CUT_PBASE_T_USBDI_0486(TBool aHostRole)
    48 CUT_PBASE_T_USBDI_0486::CUT_PBASE_T_USBDI_0486(TBool aHostRole)
    43 :	CBaseBulkTestCase(KTestCaseId,aHostRole),
    49 :	CBaseBulkTestCase(KTestCaseId,aHostRole),
    44 	iCaseStep(EWaitForDeviceCConnection)
    50 	iCaseStep(EWaitForDeviceCConnection)
    45 	{
    51 	{
       
    52 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0486_CUT_PBASE_T_USBDI_0486_ENTRY, this );
       
    53 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_CUT_PBASE_T_USBDI_0486_EXIT, this );
    46 	} 
    54 	} 
    47 
    55 
    48 
    56 
    49 void CUT_PBASE_T_USBDI_0486::ConstructL()
    57 void CUT_PBASE_T_USBDI_0486::ConstructL()
    50 	{
    58 	{
       
    59 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_CONSTRUCTL_ENTRY, this );
    51 	BaseBulkConstructL();
    60 	BaseBulkConstructL();
    52 	iTestDeviceC = new RUsbDeviceC(this);  // TODO check tree for device C, once inserted
    61 	iTestDeviceC = new RUsbDeviceC(this);  // TODO check tree for device C, once inserted
       
    62 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_CONSTRUCTL_EXIT, this );
    53 	}
    63 	}
    54 
    64 
    55 CUT_PBASE_T_USBDI_0486::~CUT_PBASE_T_USBDI_0486()
    65 CUT_PBASE_T_USBDI_0486::~CUT_PBASE_T_USBDI_0486()
    56 	{
    66 	{
    57 	LOG_FUNC
    67 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_CUT_PBASE_T_USBDI_0486_ENTRY_DUP01, this );
    58 	
    68 	
    59 	delete iTestDeviceC;
    69 	delete iTestDeviceC;
       
    70 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_CUT_PBASE_T_USBDI_0486_EXIT_DUP01, this );
    60 	}
    71 	}
    61 	
    72 	
    62 /**
    73 /**
    63 Called when the device has reported any kind of error in its operation
    74 Called when the device has reported any kind of error in its operation
    64 or when the device has been informed by the host to report success
    75 or when the device has been informed by the host to report success
    65 */
    76 */
    66 void CUT_PBASE_T_USBDI_0486::DeviceRunL()
    77 void CUT_PBASE_T_USBDI_0486::DeviceRunL()
    67 	{
    78 	{
    68 	LOG_FUNC	
    79 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_DEVICERUNL_ENTRY, this );
    69 	// Complete the test case request	
    80 	// Complete the test case request	
    70 	TestPolicy().SignalTestComplete(iStatus.Int());
    81 	TestPolicy().SignalTestComplete(iStatus.Int());
       
    82 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_DEVICERUNL_EXIT, this );
    71 	}
    83 	}
    72 
    84 
    73 void CUT_PBASE_T_USBDI_0486::DeviceDoCancel()
    85 void CUT_PBASE_T_USBDI_0486::DeviceDoCancel()
    74 	{
    86 	{
    75 	LOG_FUNC
    87 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_DEVICEDOCANCEL_ENTRY, this );
    76 	iTestDeviceC->CancelSubscriptionToReports();
    88 	iTestDeviceC->CancelSubscriptionToReports();
       
    89 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_DEVICEDOCANCEL_EXIT, this );
    77 	}
    90 	}
    78 	
    91 	
    79 TBool CUT_PBASE_T_USBDI_0486::CheckSN(const TDesC16& aSerialNumberGot, const TDesC& aExpectedSerialNumber)
    92 TBool CUT_PBASE_T_USBDI_0486::CheckSN(const TDesC16& aSerialNumberGot, const TDesC& aExpectedSerialNumber)
    80 	{
    93 	{
       
    94 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0486_CHECKSN_ENTRY, this );
    81 	TBool areSNsIdenticals = (aSerialNumberGot.Compare(aExpectedSerialNumber) == 0);	
    95 	TBool areSNsIdenticals = (aSerialNumberGot.Compare(aExpectedSerialNumber) == 0);	
    82 	 
    96 	 
    83 	if(!areSNsIdenticals)
    97 	if(!areSNsIdenticals)
    84 		{
    98 		{
    85 		// Incorrect device for this test case	
    99 		// Incorrect device for this test case	
    86 		RDebug::Printf("<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)",
   100 		OstTraceExt3(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_CHECKSN, "<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)",
    87 			KErrNotFound,&aSerialNumberGot, &aExpectedSerialNumber);
   101 			KErrNotFound,aSerialNumberGot, aExpectedSerialNumber);
    88 		}
   102 		}
       
   103 	OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0486_CHECKSN_EXIT, this, areSNsIdenticals );
    89 	return areSNsIdenticals;
   104 	return areSNsIdenticals;
    90 	}
   105 	}
    91 	
   106 	
    92 	
   107 	
    93 void CUT_PBASE_T_USBDI_0486::Ep0TransferCompleteL(TInt aCompletionCode)
   108 void CUT_PBASE_T_USBDI_0486::Ep0TransferCompleteL(TInt aCompletionCode)
    94 	{
   109 	{
    95 	LOG_FUNC
   110     OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0486_EP0TRANSFERCOMPLETEL_ENTRY, this );
    96 
   111 
    97 	RDebug::Printf("Ep0TransferCompleteL with aCompletionCode = %d",aCompletionCode);
   112 	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_EP0TRANSFERCOMPLETEL, "Ep0TransferCompleteL with aCompletionCode = %d",aCompletionCode);
    98 	RDebug::Printf("--->Ep0TransferCompleteL, case step = %d", iCaseStep);
   113 	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_EP0TRANSFERCOMPLETEL_DUP01, "--->Ep0TransferCompleteL, case step = %d", iCaseStep);
    99 
   114 
   100 	switch(iCaseStep)
   115 	switch(iCaseStep)
   101 		{
   116 		{
   102 		case EDeviceCConnected:
   117 		case EDeviceCConnected:
   103 			{
   118 			{
   104 			if(aCompletionCode != KErrNone)
   119 			if(aCompletionCode != KErrNone)
   105 				{
   120 				{
   106 				RDebug::Printf("<Error %d> aCompletionCode != KErrNone",aCompletionCode);
   121 				OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_EP0TRANSFERCOMPLETEL_DUP02, "<Error %d> aCompletionCode != KErrNone",aCompletionCode);
   107 				return TestFailed(aCompletionCode);
   122 				return TestFailed(aCompletionCode);
   108 				}
   123 				}
   109 			// close interface 0			
   124 			// close interface 0			
   110 			iUsbInterface0.Close();			
   125 			iUsbInterface0.Close();			
   111 			iCaseStep = EWaitForDeviceCDisconnection;
   126 			iCaseStep = EWaitForDeviceCDisconnection;
   118 	
   133 	
   119 		default:
   134 		default:
   120 			TestFailed(KErrCompletion);
   135 			TestFailed(KErrCompletion);
   121 			break;
   136 			break;
   122 		}
   137 		}
       
   138 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_EP0TRANSFERCOMPLETEL_EXIT, this );
   123 	}
   139 	}
   124 	
   140 	
   125 void CUT_PBASE_T_USBDI_0486::TransferCompleteL(TInt aTransferId,TInt aCompletionCode)
   141 void CUT_PBASE_T_USBDI_0486::TransferCompleteL(TInt aTransferId,TInt aCompletionCode)
   126 	{
   142 	{
   127 	LOG_FUNC
   143 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0486_TRANSFERCOMPLETEL_ENTRY, this );
   128 	Cancel();
   144 	Cancel();
   129 	RDebug::Printf("--->TransferCompleteL, case step = %d", iCaseStep);
   145 	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_TRANSFERCOMPLETEL, "--->TransferCompleteL, case step = %d", iCaseStep);
   130 
   146 
   131 	if(aTransferId == KBulkTranferId)
   147 	if(aTransferId == KBulkTranferId)
   132 		{							
   148 		{							
   133 		if(aCompletionCode != KErrCancel && aCompletionCode != KErrUsbIOError)
   149 		if(aCompletionCode != KErrCancel && aCompletionCode != KErrUsbIOError)
   134 			{
   150 			{
   135 			TBuf<256> msg;
   151 			TBuf<256> msg;
   136 			msg.Format(_L("<Error %d> The transfer completed with no errors but should have done so"),aCompletionCode);
   152 			msg.Format(_L("<Error %d> The transfer completed with no errors but should have done so"),aCompletionCode);
   137 			RDebug::Print(msg);
   153 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_TRANSFERCOMPLETEL_DUP01, msg);
   138 			TTestCaseFailed request(KErrCorrupt,msg);
   154 			TTestCaseFailed request(KErrCorrupt,msg);
   139 			return iControlEp0->SendRequest(request,this);
   155 			return iControlEp0->SendRequest(request,this);
   140 			} 					
   156 			} 					
   141 		}
   157 		}
   142 	else
   158 	else
   143 		{
   159 		{
   144 		RDebug::Printf("<Error> a transfer completed (id=%d) that was not expected",aTransferId);
   160 		OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_TRANSFERCOMPLETEL_DUP02, "<Error> a transfer completed (id=%d) that was not expected",aTransferId);
   145 		return TestFailed(KErrCorrupt);
   161 		return TestFailed(KErrCorrupt);
   146 		}	
   162 		}	
       
   163 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_TRANSFERCOMPLETEL_EXIT, this );
   147 	}	
   164 	}	
   148 	
   165 	
   149 	
   166 	
   150 void CUT_PBASE_T_USBDI_0486::DeviceInsertedL(TUint aDeviceHandle)
   167 void CUT_PBASE_T_USBDI_0486::DeviceInsertedL(TUint aDeviceHandle)
   151 	{
   168 	{
   152 	LOG_FUNC
   169 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_ENTRY, this );
   153 	RDebug::Printf("--->DeviceInsertedL, case step = %d", iCaseStep);
   170 	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL, "--->DeviceInsertedL, case step = %d", iCaseStep);
   154 
   171 
   155 	// Cancel the timeout timer	
   172 	// Cancel the timeout timer	
   156 	Cancel();	
   173 	Cancel();	
   157 	TInt err(KErrNone);
   174 	TInt err(KErrNone);
   158 	
   175 	
   171 			iCaseStep = EDeviceCConnected;
   188 			iCaseStep = EDeviceCConnected;
   172 			
   189 			
   173 			err = testDevice.Device().GetTokenForInterface(0,iToken0DeviceC);
   190 			err = testDevice.Device().GetTokenForInterface(0,iToken0DeviceC);
   174 			if(err != KErrNone)
   191 			if(err != KErrNone)
   175 				{
   192 				{
   176 				RDebug::Printf("<Error %d> Unable to retrieve token for interface 0",err);
   193 				OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP01, "<Error %d> Unable to retrieve token for interface 0",err);
   177 				TestFailed(err);
   194 				TestFailed(err);
   178 				} 
   195 				} 
   179 			// Open the interface	
   196 			// Open the interface	
   180 			err = iUsbInterface0.Open(iToken0DeviceC);
   197 			err = iUsbInterface0.Open(iToken0DeviceC);
   181 			if(err != KErrNone)
   198 			if(err != KErrNone)
   182 				{
   199 				{
   183 				RDebug::Printf("<Error %d> Unable to open interface 0");
   200 				OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP02, "<Error %d> Unable to open interface 0", err);
   184 				TestFailed(err);
   201 				TestFailed(err);
   185 				}
   202 				}
   186 				
   203 				
   187 			TUint32 token1;
   204 			TUint32 token1;
   188 			err = testDevice.Device().GetTokenForInterface(1,token1);
   205 			err = testDevice.Device().GetTokenForInterface(1,token1);
   189 			if(err != KErrNone)
   206 			if(err != KErrNone)
   190 				{
   207 				{
   191 				TBuf<256> msg;
   208 				TBuf<256> msg;
   192 				msg.Format(_L("<Error %d> Token for interface 1 could not be retrieved"),err);
   209 				msg.Format(_L("<Error %d> Token for interface 1 could not be retrieved"),err);
   193 				RDebug::Print(msg);
   210 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP03, msg);
   194 				iCaseStep = EFailed;
   211 				iCaseStep = EFailed;
   195 				TTestCaseFailed request(err,msg);
   212 				TTestCaseFailed request(err,msg);
   196 				return iControlEp0->SendRequest(request,this);
   213 				return iControlEp0->SendRequest(request,this);
   197 				}
   214 				}
   198 				
   215 				
   200 			err = iUsbInterface1.Open(token1); // Default interface setting 0
   217 			err = iUsbInterface1.Open(token1); // Default interface setting 0
   201 			if(err != KErrNone)
   218 			if(err != KErrNone)
   202 				{
   219 				{
   203 				TBuf<256> msg;
   220 				TBuf<256> msg;
   204 				msg.Format(_L("<Error %d> Unable to open interface 1 using token %d"),err,token1);
   221 				msg.Format(_L("<Error %d> Unable to open interface 1 using token %d"),err,token1);
   205 				RDebug::Print(msg);
   222 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP04, msg);
   206 				iCaseStep = EFailed;
   223 				iCaseStep = EFailed;
   207 				TTestCaseFailed request(err,msg);
   224 				TTestCaseFailed request(err,msg);
   208 				return iControlEp0->SendRequest(request,this);
   225 				return iControlEp0->SendRequest(request,this);
   209 				}
   226 				}
   210 				
   227 				
   213 			err = GetEndpointAddress(iUsbInterface1,0,KTransferTypeBulk,KEpDirectionIn,endpointAddress);
   230 			err = GetEndpointAddress(iUsbInterface1,0,KTransferTypeBulk,KEpDirectionIn,endpointAddress);
   214 			if(err != KErrNone)
   231 			if(err != KErrNone)
   215 				{
   232 				{
   216 				TBuf<256> msg;
   233 				TBuf<256> msg;
   217 				msg.Format(_L("<Error %d> Address for bulk in endpoint could not be obtained"),err);
   234 				msg.Format(_L("<Error %d> Address for bulk in endpoint could not be obtained"),err);
   218 				RDebug::Print(msg);
   235 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP05, msg);
   219 				iCaseStep = EFailed;
   236 				iCaseStep = EFailed;
   220 				TTestCaseFailed request(err,msg);
   237 				TTestCaseFailed request(err,msg);
   221 				return iControlEp0->SendRequest(request,this);
   238 				return iControlEp0->SendRequest(request,this);
   222 				}
   239 				}
   223 			RDebug::Printf("Endpoint adress %08x",endpointAddress);
   240 			OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP06, "Endpoint adress %08x",endpointAddress);
   224 	
   241 	
   225 			err = iUsbInterface1.OpenPipeForEndpoint(iTestPipeInterface1BulkIn,endpointAddress,ETrue);
   242 			err = iUsbInterface1.OpenPipeForEndpoint(iTestPipeInterface1BulkIn,endpointAddress,ETrue);
   226 			if(err != KErrNone)
   243 			if(err != KErrNone)
   227 				{
   244 				{
   228 				TBuf<256> msg;
   245 				TBuf<256> msg;
   229 				msg.Format(_L("<Error %d> Unable to open pipe for endpoint %08x"),err,endpointAddress);
   246 				msg.Format(_L("<Error %d> Unable to open pipe for endpoint %08x"),err,endpointAddress);
   230 				RDebug::Print(msg);
   247 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP07, msg);
   231 				iCaseStep = EFailed;
   248 				iCaseStep = EFailed;
   232 				TTestCaseFailed request(err,msg);
   249 				TTestCaseFailed request(err,msg);
   233 				return iControlEp0->SendRequest(request,this);
   250 				return iControlEp0->SendRequest(request,this);
   234 				}
   251 				}
   235 			
   252 			
   236 			// Create the bulk transfers	
   253 			// Create the bulk transfers	
   237 			iInTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,256,*this, KBulkTranferId);
   254 			iInTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,256,*this, KBulkTranferId);
   238 		
   255 		
   239 			// Initialise the descriptors for transfer		
   256 			// Initialise the descriptors for transfer		
   240 			RDebug::Printf("Initialising the transfer descriptors");
   257 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP08, "Initialising the transfer descriptors");
   241 			err = iUsbInterface1.InitialiseTransferDescriptors();
   258 			err = iUsbInterface1.InitialiseTransferDescriptors();
   242 			if(err != KErrNone)
   259 			if(err != KErrNone)
   243 				{
   260 				{
   244 				TBuf<256> msg;
   261 				TBuf<256> msg;
   245 				msg.Format(_L("<Error %d> Unable to initialise transfer descriptors"),err);
   262 				msg.Format(_L("<Error %d> Unable to initialise transfer descriptors"),err);
   246 				RDebug::Print(msg);
   263 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP09, msg);
   247 				iCaseStep = EFailed;
   264 				iCaseStep = EFailed;
   248 				TTestCaseFailed request(err,msg);
   265 				TTestCaseFailed request(err,msg);
   249 				return iControlEp0->SendRequest(request,this);
   266 				return iControlEp0->SendRequest(request,this);
   250 				}				
   267 				}				
   251 			iInTransfer[0]->TransferIn(KExpectedDataSize);
   268 			iInTransfer[0]->TransferIn(KExpectedDataSize);
   269 			    }
   286 			    }
   270 			// try to open interface 0			
   287 			// try to open interface 0			
   271 			err = iUsbInterface0.Open(iToken0DeviceC);
   288 			err = iUsbInterface0.Open(iToken0DeviceC);
   272 			if(err != KErrNotFound) // invalid token
   289 			if(err != KErrNotFound) // invalid token
   273 				{
   290 				{
   274 				RDebug::Printf("iUsbInterface0.Open(iToken0DeviceC) === %d", err);
   291 				OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP10, "iUsbInterface0.Open(iToken0DeviceC) === %d", err);
   275 				TestFailed(err);
   292 				TestFailed(err);
   276 				}
   293 				}
   277 			
   294 			
   278 			// get token now 
   295 			// get token now 
   279 			TUint32 token0DeviceA; 
   296 			TUint32 token0DeviceA; 
   280 			err = testDevice.Device().GetTokenForInterface(0,token0DeviceA);
   297 			err = testDevice.Device().GetTokenForInterface(0,token0DeviceA);
   281 			if(err != KErrNone)
   298 			if(err != KErrNone)
   282 				{
   299 				{
   283 				RDebug::Printf("<Error %d> Unable to retrieve token(device A) for interface 0",err);
   300 				OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP11, "<Error %d> Unable to retrieve token(device A) for interface 0",err);
   284 				TestFailed(err);
   301 				TestFailed(err);
   285 				} 
   302 				} 
   286 			// Open the interface	
   303 			// Open the interface	
   287 			err = iUsbInterface0.Open(token0DeviceA);
   304 			err = iUsbInterface0.Open(token0DeviceA);
   288 			if(err != KErrNone)
   305 			if(err != KErrNone)
   289 				{
   306 				{
   290 				RDebug::Printf("<Error %d> Unable to open interface 0(device A)");
   307 				OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP12, "<Error %d> Unable to open interface 0(device A)", err);
   291 				TestFailed(err);
   308 				TestFailed(err);
   292 				}
   309 				}
   293 			
   310 			
   294 			// ok, send EPassed request			
   311 			// ok, send EPassed request			
   295 			iCaseStep = EPassed;
   312 			iCaseStep = EPassed;
   300 			} 
   317 			} 
   301 			break;
   318 			break;
   302 			
   319 			
   303 		default:
   320 		default:
   304 			{
   321 			{
   305 			RDebug::Printf("<Error> Test case actions out of sync");
   322 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP13, "<Error> Test case actions out of sync");
   306 			TestFailed(KErrCorrupt);
   323 			TestFailed(KErrCorrupt);
   307 			}	
   324 			}	
   308 			break;
   325 			break;
   309 		}	
   326 		}	
       
   327 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_EXIT, this );
   310 	}
   328 	}
   311 	
   329 	
   312 void CUT_PBASE_T_USBDI_0486::DeviceRemovedL(TUint aDeviceHandle)
   330 void CUT_PBASE_T_USBDI_0486::DeviceRemovedL(TUint aDeviceHandle)
   313 	{
   331 	{
   314 	LOG_FUNC
   332 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0486_DEVICEREMOVEDL_ENTRY, this );
   315 	Cancel();	
   333 	Cancel();	
   316 	RDebug::Printf("--->DeviceRemovedL, case step = %d", iCaseStep);
   334 	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEREMOVEDL, "--->DeviceRemovedL, case step = %d", iCaseStep);
   317 
   335 
   318 	switch(iCaseStep)
   336 	switch(iCaseStep)
   319 		{
   337 		{
   320 		case EWaitForDeviceCDisconnection: // device C is disconnected now, interface 0 has been closed before
   338 		case EWaitForDeviceCDisconnection: // device C is disconnected now, interface 0 has been closed before
   321 			{
   339 			{
   323 			iActorFDF->Monitor();
   341 			iActorFDF->Monitor();
   324 			}
   342 			}
   325 			break;		
   343 			break;		
   326 	
   344 	
   327 		default:
   345 		default:
   328 			RDebug::Printf("<Error> Test case actions out of sync");
   346 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEREMOVEDL_DUP01, "<Error> Test case actions out of sync");
   329 			TestFailed(KErrCorrupt);
   347 			TestFailed(KErrCorrupt);
   330 			break;
   348 			break;
   331 			}
   349 			}
       
   350 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_DEVICEREMOVEDL_EXIT, this );
   332 	}
   351 	}
   333 	
   352 	
   334 void CUT_PBASE_T_USBDI_0486::HandleDeviceDConnection()
   353 void CUT_PBASE_T_USBDI_0486::HandleDeviceDConnection()
   335 	{
   354 	{
   336 	LOG_FUNC
   355 		OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_HANDLEDEVICEDCONNECTION_ENTRY, this );
   337 		
   356 		
   338 	iTestDevice->SubscribeToReports(iStatus);
   357 	iTestDevice->SubscribeToReports(iStatus);
   339 	SetActive();
   358 	SetActive();
       
   359 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_HANDLEDEVICEDCONNECTION_EXIT, this );
   340 	}
   360 	}
   341 
   361 
   342 void CUT_PBASE_T_USBDI_0486::ExecuteDeviceTestCaseL()	
   362 void CUT_PBASE_T_USBDI_0486::ExecuteDeviceTestCaseL()	
   343 	{ 
   363 	{ 
   344 	LOG_FUNC
   364 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_EXECUTEDEVICETESTCASEL_ENTRY, this );
   345 	
   365 	
   346 	// Create the test device	
   366 	// Create the test device	
   347 	iTestDeviceC->OpenL(KTestDeviceC_SN());
   367 	iTestDeviceC->OpenL(KTestDeviceC_SN());
   348 	iTestDeviceC->SubscribeToReports(iStatus);
   368 	iTestDeviceC->SubscribeToReports(iStatus);
   349 	SetActive();
   369 	SetActive();
   350 	
   370 	
   351 	// Connect the device to the host	
   371 	// Connect the device to the host	
   352 	iTestDeviceC->SoftwareConnect();
   372 	iTestDeviceC->SoftwareConnect();
       
   373 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_EXECUTEDEVICETESTCASEL_EXIT, this );
   353 	}
   374 	}
   354 
   375 
   355 RUsbDeviceC* CUT_PBASE_T_USBDI_0486::TestDeviceC()
   376 RUsbDeviceC* CUT_PBASE_T_USBDI_0486::TestDeviceC()
   356 	{
   377 	{
       
   378 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_TESTDEVICEC_ENTRY, this );
       
   379 	OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0486_TESTDEVICEC_EXIT, this, ( TUint )( iTestDeviceC ) );
   357 	return iTestDeviceC;
   380 	return iTestDeviceC;
   358 	}
   381 	}
   359 
   382 
   360 RUsbDeviceD* CUT_PBASE_T_USBDI_0486::TestDeviceD()
   383 RUsbDeviceD* CUT_PBASE_T_USBDI_0486::TestDeviceD()
   361 	{
   384 	{
       
   385 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0486_TESTDEVICED_ENTRY, this );
       
   386 	OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0486_TESTDEVICED_EXIT, this, ( TUint )( iTestDevice ) );
   362 	return iTestDevice; //from CBaseBulkTestCase
   387 	return iTestDevice; //from CBaseBulkTestCase
   363 	}
   388 	}
   364 	
   389 	
   365 	}
   390 	}