kerneltest/e32test/usbho/t_usbdi/src/PBASE-T_USBDI-0477.cpp
changeset 259 57b9594f5772
parent 0 a41df078684a
child 257 3e88ff8f41d5
child 271 dc268b18d709
equal deleted inserted replaced
247:d8d70de2bd36 259:57b9594f5772
     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".
    17 //
    17 //
    18 
    18 
    19 #include "PBASE-T_USBDI-0477.h"
    19 #include "PBASE-T_USBDI-0477.h"
    20 #include "testpolicy.h"
    20 #include "testpolicy.h"
    21 #include "modelleddevices.h"
    21 #include "modelleddevices.h"
       
    22 #include "OstTraceDefinitions.h"
       
    23 #ifdef OST_TRACE_COMPILER_IN_USE
       
    24 #include "PBASE-T_USBDI-0477Traces.h"
       
    25 #endif
    22 
    26 
    23 
    27 
    24 namespace NUnitTesting_USBDI
    28 namespace NUnitTesting_USBDI
    25 	{
    29 	{
    26 	
    30 	
    27 _LIT(KTestCaseId,"PBASE-T_USBDI-0477");
    31 _LIT(KTestCaseId,"PBASE-T_USBDI-0477");
    28 const TFunctorTestCase<CUT_PBASE_T_USBDI_0477,TBool> CUT_PBASE_T_USBDI_0477::iFunctor(KTestCaseId);	
    32 const TFunctorTestCase<CUT_PBASE_T_USBDI_0477,TBool> CUT_PBASE_T_USBDI_0477::iFunctor(KTestCaseId);	
    29 
    33 
    30 CUT_PBASE_T_USBDI_0477* CUT_PBASE_T_USBDI_0477::NewL(TBool aHostRole)
    34 CUT_PBASE_T_USBDI_0477* CUT_PBASE_T_USBDI_0477::NewL(TBool aHostRole)
    31 	{
    35 	{
       
    36 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_NEWL_ENTRY, aHostRole );
    32 	CUT_PBASE_T_USBDI_0477* self = new (ELeave) CUT_PBASE_T_USBDI_0477(aHostRole);
    37 	CUT_PBASE_T_USBDI_0477* self = new (ELeave) CUT_PBASE_T_USBDI_0477(aHostRole);
    33 	CleanupStack::PushL(self);
    38 	CleanupStack::PushL(self);
    34 	self->ConstructL();
    39 	self->ConstructL();
    35 	CleanupStack::Pop(self);
    40 	CleanupStack::Pop(self);
       
    41 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_NEWL_EXIT, ( TUint )( self ) );
    36 	return self;
    42 	return self;
    37 	}
    43 	}
    38 	
    44 	
    39 
    45 
    40 CUT_PBASE_T_USBDI_0477::CUT_PBASE_T_USBDI_0477(TBool aHostRole)
    46 CUT_PBASE_T_USBDI_0477::CUT_PBASE_T_USBDI_0477(TBool aHostRole)
    41 :	CBaseTestCase(KTestCaseId,aHostRole),
    47 :	CBaseTestCase(KTestCaseId,aHostRole),
    42 	iCaseStep(EInProgress)
    48 	iCaseStep(EInProgress)
    43 	{
    49 	{
       
    50 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0477_CUT_PBASE_T_USBDI_0477_ENTRY, this );
       
    51 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_CUT_PBASE_T_USBDI_0477_EXIT, this );
    44 	} 
    52 	} 
    45 
    53 
    46  
    54  
    47 void CUT_PBASE_T_USBDI_0477::ConstructL()
    55 void CUT_PBASE_T_USBDI_0477::ConstructL()
    48 	{
    56 	{
       
    57 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_CONSTRUCTL_ENTRY, this );
    49 	iTestDevice = new RUsbDeviceA(this);
    58 	iTestDevice = new RUsbDeviceA(this);
    50 	BaseConstructL();
    59 	BaseConstructL();
       
    60 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_CONSTRUCTL_EXIT, this );
    51 	}
    61 	}
    52 
    62 
    53 
    63 
    54 CUT_PBASE_T_USBDI_0477::~CUT_PBASE_T_USBDI_0477()
    64 CUT_PBASE_T_USBDI_0477::~CUT_PBASE_T_USBDI_0477()
    55 	{
    65 	{
    56 	LOG_FUNC
    66 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_CUT_PBASE_T_USBDI_0477_ENTRY_DUP01, this );
    57 	Cancel();
    67 	Cancel();
    58 
    68 
    59 	iTestPipe.Close();
    69 	iTestPipe.Close();
    60 	iUsbInterface1.Close();
    70 	iUsbInterface1.Close();
    61 	iUsbInterface0.Close();
    71 	iUsbInterface0.Close();
    65 	if(!IsHost() && iTestDevice)
    75 	if(!IsHost() && iTestDevice)
    66 		{
    76 		{
    67 		iTestDevice->Close();
    77 		iTestDevice->Close();
    68 		}		
    78 		}		
    69 	delete iTestDevice;
    79 	delete iTestDevice;
       
    80 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_CUT_PBASE_T_USBDI_0477_EXIT_DUP01, this );
    70 	}
    81 	}
    71 	
    82 	
    72 	
    83 	
    73 void CUT_PBASE_T_USBDI_0477::ExecuteHostTestCaseL()
    84 void CUT_PBASE_T_USBDI_0477::ExecuteHostTestCaseL()
    74 	{
    85 	{
    75 	LOG_FUNC
    86 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_EXECUTEHOSTTESTCASEL_ENTRY, this );
    76 	
    87 	
    77 	iActorFDF = CActorFDF::NewL(*this);
    88 	iActorFDF = CActorFDF::NewL(*this);
    78 	iClientAction = new (ELeave) CEp0Transfer(iUsbInterface0);
    89 	iClientAction = new (ELeave) CEp0Transfer(iUsbInterface0);
    79 	iActorFDF->Monitor();
    90 	iActorFDF->Monitor();
    80 	TimeoutIn(30);
    91 	TimeoutIn(30);
       
    92 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_EXECUTEHOSTTESTCASEL_EXIT, this );
    81 	}
    93 	}
    82 
    94 
    83 	
    95 	
    84 void CUT_PBASE_T_USBDI_0477::ExecuteDeviceTestCaseL()
    96 void CUT_PBASE_T_USBDI_0477::ExecuteDeviceTestCaseL()
    85 	{
    97 	{
    86 	LOG_FUNC
    98 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_EXECUTEDEVICETESTCASEL_ENTRY, this );
    87 	
    99 	
    88 	iTestDevice->OpenL(TestCaseId());
   100 	iTestDevice->OpenL(TestCaseId());
    89 	iTestDevice->SubscribeToReports(iStatus);
   101 	iTestDevice->SubscribeToReports(iStatus);
    90 	SetActive();
   102 	SetActive();
    91 	iTestDevice->SoftwareConnect();
   103 	iTestDevice->SoftwareConnect();
       
   104 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_EXECUTEDEVICETESTCASEL_EXIT, this );
    92 	}
   105 	}
    93 	
   106 	
    94 	
   107 	
    95 void CUT_PBASE_T_USBDI_0477::HostDoCancel()
   108 void CUT_PBASE_T_USBDI_0477::HostDoCancel()
    96 	{
   109 	{
    97 	LOG_FUNC
   110 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_HOSTDOCANCEL_ENTRY, this );
    98 	
   111 	
    99 	// Cancel the test step timeout
   112 	// Cancel the test step timeout
   100 	
   113 	
   101 	CancelTimeout();
   114 	CancelTimeout();
       
   115 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_HOSTDOCANCEL_EXIT, this );
   102 	}
   116 	}
   103 
   117 
   104 
   118 
   105 void CUT_PBASE_T_USBDI_0477::DeviceDoCancel()
   119 void CUT_PBASE_T_USBDI_0477::DeviceDoCancel()
   106 	{
   120 	{
   107 	LOG_FUNC
   121 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_DEVICEDOCANCEL_ENTRY, this );
   108 	
   122 	
   109 	// Cancel the device
   123 	// Cancel the device
   110 	
   124 	
   111 	iTestDevice->CancelSubscriptionToReports();
   125 	iTestDevice->CancelSubscriptionToReports();
       
   126 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEDOCANCEL_EXIT, this );
   112 	}
   127 	}
   113 	
   128 	
   114 TBool CUT_PBASE_T_USBDI_0477::CheckFirstInterfaceDescriptorDeviceA(TUsbInterfaceDescriptor& aIfDescriptor)
   129 TBool CUT_PBASE_T_USBDI_0477::CheckFirstInterfaceDescriptorDeviceA(TUsbInterfaceDescriptor& aIfDescriptor)
   115 	{
   130 	{
   116 	LOG_FUNC	
   131 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0477_CHECKFIRSTINTERFACEDESCRIPTORDEVICEA_ENTRY, this );
   117 	/*	Interface0	[setting0]
   132 	/*	Interface0	[setting0]
   118 		Interface1	[setting0]
   133 		Interface1	[setting0]
   119 						[endpoint1] Bulk out
   134 						[endpoint1] Bulk out
   120 						[endpoint2] Bulk in
   135 						[endpoint2] Bulk in
   121 					[setting1]			
   136 					[setting1]			
   159 		TUsbEndpointDescriptor::Cast(desc);
   174 		TUsbEndpointDescriptor::Cast(desc);
   160 		CHECK_RET_BOOL(desc != 0);			
   175 		CHECK_RET_BOOL(desc != 0);			
   161 		desc = desc->iNextPeer; // no peer
   176 		desc = desc->iNextPeer; // no peer
   162 		CHECK_RET_BOOL(desc == 0); 
   177 		CHECK_RET_BOOL(desc == 0); 
   163 		
   178 		
   164 		RDebug::Printf("CheckFirstInterfaceDescriptorDeviceA successfull!");
   179 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_CHECKFIRSTINTERFACEDESCRIPTORDEVICEA, "CheckFirstInterfaceDescriptorDeviceA successfull!");
       
   180 		OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0477_CHECKFIRSTINTERFACEDESCRIPTORDEVICEA_EXIT, this, ETrue );
   165 		return ETrue;
   181 		return ETrue;
   166 	}
   182 	}
   167 	
   183 	
   168 void CUT_PBASE_T_USBDI_0477::DeviceInsertedL(TUint aDeviceHandle)
   184 void CUT_PBASE_T_USBDI_0477::DeviceInsertedL(TUint aDeviceHandle)
   169 	{
   185 	{
   170 	LOG_FUNC
   186 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_ENTRY, this );
   171 	Cancel();
   187 	Cancel();
   172 	TInt err(KErrNone);
   188 	TInt err(KErrNone);
   173 	
   189 	
   174 	// Validate that device is as expected
   190 	// Validate that device is as expected
   175 	CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle);
   191 	CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle);
   176 	if(testDevice.SerialNumber().Compare(TestCaseId()) != 0)
   192 	if(testDevice.SerialNumber().Compare(TestCaseId()) != 0)
   177 		{
   193 		{
   178 		// Incorrect device for this test case	
   194 		// Incorrect device for this test case	
   179 
   195 
   180 		RDebug::Printf("<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)",
   196 		OstTraceExt3(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL, "<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)",
   181 			KErrNotFound,&testDevice.SerialNumber(),&TestCaseId());
   197 			KErrNotFound,testDevice.SerialNumber(),TestCaseId());
   182 
   198 
   183 		// Start the connection timeout again
   199 		// Start the connection timeout again
   184 		TimeoutIn(30);
   200 		TimeoutIn(30);
       
   201 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_EXIT, this );
   185 		return;
   202 		return;
   186 		}
   203 		}
   187 			
   204 			
   188 	TUint32 token0,token1; // Token for an interface
   205 	TUint32 token0,token1; // Token for an interface
   189 	
   206 	
   190 	err = testDevice.Device().GetTokenForInterface(0,token0);
   207 	err = testDevice.Device().GetTokenForInterface(0,token0);
   191 	if(err != KErrNone)
   208 	if(err != KErrNone)
   192 		{
   209 		{
   193 		RDebug::Printf("<Error %d> Token for interface 0 could not be retrieved",err);
   210 		OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP01, "<Error %d> Token for interface 0 could not be retrieved",err);
   194 		return TestFailed(err);
   211 		return TestFailed(err);
   195 		}
   212 		}
   196 		
   213 		
   197 	err = iUsbInterface0.Open(token0);
   214 	err = iUsbInterface0.Open(token0);
   198 	if(err != KErrNone)
   215 	if(err != KErrNone)
   199 		{
   216 		{
   200 		RDebug::Printf("<Error %d> Unable to open interface 0 using token %d",err,token0);
   217 		OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP02, "<Error %d> Unable to open interface 0 using token %d",err,token0);
   201 		return TestFailed(err);
   218 		return TestFailed(err);
   202 		}
   219 		}
   203 	
   220 	
   204 	err = testDevice.Device().GetTokenForInterface(1,token1);
   221 	err = testDevice.Device().GetTokenForInterface(1,token1);
   205 	if(err != KErrNone)
   222 	if(err != KErrNone)
   206 		{
   223 		{
   207 		// Test case has failed
   224 		// Test case has failed
   208 		TBuf<256> msg;
   225 		TBuf<256> msg;
   209 		_LIT(string, "<Error %d> Token for interface could not be retrieved");
   226 		_LIT(string, "<Error %d> Token for interface could not be retrieved");
   210 		msg.Format(string,err);
   227 		msg.Format(string,err);
   211 		RDebug::Print(msg);
   228 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP03, msg);
   212 		iCaseStep = EFailed;
   229 		iCaseStep = EFailed;
   213 		TTestCaseFailed request(err,msg);
   230 		TTestCaseFailed request(err,msg);
   214 		iClientAction->SendRequest(request,this);
   231 		iClientAction->SendRequest(request,this);
       
   232 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_EXIT_DUP01, this );
   215 		return;
   233 		return;
   216 		}
   234 		}
   217 
   235 
   218 	err = iUsbInterface1.Open(token1); // Default interface setting 0
   236 	err = iUsbInterface1.Open(token1); // Default interface setting 0
   219 	if(err != KErrNone)
   237 	if(err != KErrNone)
   220 		{
   238 		{
   221 		TBuf<256> msg;
   239 		TBuf<256> msg;
   222 		msg.Format(_L("<Error %d> Unable to open interface using token %d"),err,token1);
   240 		msg.Format(_L("<Error %d> Unable to open interface using token %d"),err,token1);
   223 		RDebug::Print(msg);
   241 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP04, msg);
   224 		iCaseStep = EFailed;
   242 		iCaseStep = EFailed;
   225 		TTestCaseFailed request(err,msg);
   243 		TTestCaseFailed request(err,msg);
   226 		iClientAction->SendRequest(request,this);
   244 		iClientAction->SendRequest(request,this);
       
   245 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_EXIT_DUP02, this );
   227 		return;
   246 		return;
   228 		}
   247 		}
   229 		
   248 		
   230 			
   249 			
   231 	// check interface descriptor now				 
   250 	// check interface descriptor now				 
   232 	RDebug::Printf("check Interface descriptor now");
   251 	OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP05, "check Interface descriptor now");
   233 	TUsbInterfaceDescriptor ifDescriptor;
   252 	TUsbInterfaceDescriptor ifDescriptor;
   234 	CHECK(iUsbInterface1.GetInterfaceDescriptor(ifDescriptor) == KErrNone);	
   253 	CHECK(iUsbInterface1.GetInterfaceDescriptor(ifDescriptor) == KErrNone);	
   235 	CHECK(CheckFirstInterfaceDescriptorDeviceA(ifDescriptor));
   254 	CHECK(CheckFirstInterfaceDescriptorDeviceA(ifDescriptor));
   236 																				
   255 																				
   237 	//  Enumerate Endpoints On Interface 1 alt. setting 0
   256 	//  Enumerate Endpoints On Interface 1 alt. setting 0
   238 	CHECK(iUsbInterface1.EnumerateEndpointsOnInterface(0) == 2);
   257 	CHECK(iUsbInterface1.EnumerateEndpointsOnInterface(0) == 2);
   239 	
   258 	
   240 	// get busId now				
   259 	// get busId now				
   241 	TUsbBusId busId;	 
   260 	TUsbBusId busId;	 
   242 	CHECK(iUsbInterface1.GetBusId(busId) == KErrNone);
   261 	CHECK(iUsbInterface1.GetBusId(busId) == KErrNone);
   243 	RDebug::Printf("busId(Interface) = %d",busId);
   262 	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP06, "busId(Interface) = %d",busId);
   244 	
   263 	
   245 	// get device speed now
   264 	// get device speed now
   246 	RUsbInterface::TDeviceSpeed deviceSpeed;
   265 	RUsbInterface::TDeviceSpeed deviceSpeed;
   247 	CHECK(iUsbInterface1.GetDeviceSpeed(deviceSpeed) == KErrNone);
   266 	CHECK(iUsbInterface1.GetDeviceSpeed(deviceSpeed) == KErrNone);
   248 	RDebug::Printf("GetDeviceSpeed = %d", deviceSpeed);
   267 	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP07, "GetDeviceSpeed = %d", deviceSpeed);
   249 	CHECK(deviceSpeed == RUsbInterface::EFullSpeed);	
   268 	CHECK(deviceSpeed == RUsbInterface::EFullSpeed);	
   250 		
   269 		
   251 	RDebug::Printf("Number of alternate interface settings available: %d",iUsbInterface1.GetAlternateInterfaceCount());
   270 	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP08, "Number of alternate interface settings available: %d",iUsbInterface1.GetAlternateInterfaceCount());
   252 	gtest(iUsbInterface1.GetAlternateInterfaceCount() == 2);
   271 	gtest(iUsbInterface1.GetAlternateInterfaceCount() == 2);
   253 	
   272 	
   254 	// Select alternate interface setting 1	
   273 	// Select alternate interface setting 1	
   255 	err = iUsbInterface1.SelectAlternateInterface(1);
   274 	err = iUsbInterface1.SelectAlternateInterface(1);
   256 	if(err != KErrNone)
   275 	if(err != KErrNone)
   257 		{
   276 		{
   258 		TBuf<256> msg;
   277 		TBuf<256> msg;
   259 		msg.Format(_L("<Error %d> Selecting alternate interface setting 1 on interface 1"),err);
   278 		msg.Format(_L("<Error %d> Selecting alternate interface setting 1 on interface 1"),err);
   260 		RDebug::Print(msg);
   279 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP09, msg);
   261 		iCaseStep = EFailed;
   280 		iCaseStep = EFailed;
   262 		TTestCaseFailed request(err,msg);
   281 		TTestCaseFailed request(err,msg);
   263 		iClientAction->SendRequest(request,this);
   282 		iClientAction->SendRequest(request,this);
       
   283 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_EXIT_DUP03, this );
   264 		return;
   284 		return;
   265 		}	
   285 		}	
   266 	
   286 	
   267 	// Open a pipe for endpoint (Bulk out)	
   287 	// Open a pipe for endpoint (Bulk out)	
   268 	TInt endpointAddress;
   288 	TInt endpointAddress;
   269 	err = GetEndpointAddress(iUsbInterface1,1,KTransferTypeBulk,KEpDirectionOut,endpointAddress);
   289 	err = GetEndpointAddress(iUsbInterface1,1,KTransferTypeBulk,KEpDirectionOut,endpointAddress);
   270 	if(err != KErrNone)
   290 	if(err != KErrNone)
   271 		{
   291 		{
   272 		TBuf<128> msg;
   292 		TBuf<128> msg;
   273 		msg.Format(_L("<Error %d> Could not get address for Bulk out endpoint"),err);
   293 		msg.Format(_L("<Error %d> Could not get address for Bulk out endpoint"),err);
   274 		RDebug::Print(msg);
   294 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP10, msg);
   275 		TTestCaseFailed request(err,msg);
   295 		TTestCaseFailed request(err,msg);
   276 		iClientAction->SendRequest(request,this);
   296 		iClientAction->SendRequest(request,this);
   277 		return;
   297 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_EXIT_DUP04, this );
   278 		}
   298 		return;
   279 		
   299 		}
   280 	RDebug::Printf("Opening pipe for endpoint address %02x on interface 1 setting 1",endpointAddress);
   300 		
       
   301 	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP11, "Opening pipe for endpoint address %02x on interface 1 setting 1",endpointAddress);
   281 	err = iUsbInterface1.OpenPipeForEndpoint(iTestPipe,endpointAddress,EFalse);
   302 	err = iUsbInterface1.OpenPipeForEndpoint(iTestPipe,endpointAddress,EFalse);
   282 	if(err != KErrNone)
   303 	if(err != KErrNone)
   283 		{
   304 		{
   284 		TBuf<128> msg;
   305 		TBuf<128> msg;
   285 		msg.Format(_L("<Error %d> Unable to open pipe on interface 1 setting 0"),err);
   306 		msg.Format(_L("<Error %d> Unable to open pipe on interface 1 setting 0"),err);
   286 		RDebug::Print(msg);
   307 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP12, msg);
   287 		iCaseStep = EFailed;
   308 		iCaseStep = EFailed;
   288 		TTestCaseFailed request(err,msg);
   309 		TTestCaseFailed request(err,msg);
   289 		iClientAction->SendRequest(request,this);
   310 		iClientAction->SendRequest(request,this);
       
   311 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_EXIT_DUP05, this );
   290 		return;
   312 		return;
   291 		}
   313 		}
   292 		
   314 		
   293 	// get busId				
   315 	// get busId				
   294 	TUsbBusId busIdPipe;	 
   316 	TUsbBusId busIdPipe;	 
   295 	CHECK(iTestPipe.GetBusId(busIdPipe) == KErrNone);
   317 	CHECK(iTestPipe.GetBusId(busIdPipe) == KErrNone);
   296 	RDebug::Printf("busId(Pipe) = %d",busIdPipe);
   318 	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP13, "busId(Pipe) = %d",busIdPipe);
   297 	CHECK(busIdPipe == busId);
   319 	CHECK(busIdPipe == busId);
   298 	
   320 	
   299 	TUsbEndpointId usbEpId;
   321 	TUsbEndpointId usbEpId;
   300 	CHECK(iTestPipe.GetEndpointId(usbEpId) == KErrNone);
   322 	CHECK(iTestPipe.GetEndpointId(usbEpId) == KErrNone);
   301 	RDebug::Printf("EndpointId = %d",usbEpId); 
   323 	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP14, "EndpointId = %d",usbEpId); 
   302 	
   324 	
   303 	// check ep descriptor now				 
   325 	// check ep descriptor now				 
   304 	RDebug::Printf("check ep descriptor now");
   326 	OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP15, "check ep descriptor now");
   305 	TUsbEndpointDescriptor epDescriptor;
   327 	TUsbEndpointDescriptor epDescriptor;
   306 	
   328 	
   307 
   329 
   308 	CHECK(iTestPipe.GetEndpointDescriptor(epDescriptor) == KErrNone);
   330 	CHECK(iTestPipe.GetEndpointDescriptor(epDescriptor) == KErrNone);
   309 	TUsbEndpointDescriptor::Cast(&epDescriptor);
   331 	TUsbEndpointDescriptor::Cast(&epDescriptor);
   310 	CHECK(&epDescriptor != 0);
   332 	CHECK(&epDescriptor != 0);
   311 	CHECK(epDescriptor.iFirstChild == 0); // no children	
   333 	CHECK(epDescriptor.iFirstChild == 0); // no children	
   312 	CHECK(epDescriptor.iNextPeer != 0);	// 1 peer
   334 	CHECK(epDescriptor.iNextPeer != 0);	// 1 peer
   313 
   335 
   314 		
   336 		
   315 	RDebug::Printf("Pipe established now closing");
   337 	OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP16, "Pipe established now closing");
   316 	iTestPipe.Close();
   338 	iTestPipe.Close();
   317 	
   339 	
   318 	// Select alternate interface 2, error expected
   340 	// Select alternate interface 2, error expected
   319 	err = iUsbInterface1.SelectAlternateInterface(2);
   341 	err = iUsbInterface1.SelectAlternateInterface(2);
   320 	if(err != KErrNone)
   342 	if(err != KErrNone)
   321 		{
   343 		{
   322 		RDebug::Printf("<Warning %d> Selecting alternate interface 2",err);
   344 		OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP17, "<Warning %d> Selecting alternate interface 2",err);
   323 		RDebug::Printf("...Rolling Back....");
   345 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP18, "...Rolling Back....");
   324 		
   346 		
   325 		// Establish pipes on rollback
   347 		// Establish pipes on rollback
   326 		// Open a pipe for endpoint (Bulk out)		
   348 		// Open a pipe for endpoint (Bulk out)		
   327 		err = iUsbInterface1.OpenPipeForEndpoint(iTestPipe,endpointAddress,EFalse);
   349 		err = iUsbInterface1.OpenPipeForEndpoint(iTestPipe,endpointAddress,EFalse);
   328 		if(err != KErrNone)
   350 		if(err != KErrNone)
   329 			{
   351 			{
   330 			TBuf<128> msg;
   352 			TBuf<128> msg;
   331 			msg.Format(_L("<Error %d> Unable to open pipe on interface 1 setting 1 for rollback case"),err);
   353 			msg.Format(_L("<Error %d> Unable to open pipe on interface 1 setting 1 for rollback case"),err);
   332 			RDebug::Print(msg);
   354 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP19, msg);
   333 			iCaseStep = EFailed;
   355 			iCaseStep = EFailed;
   334 			TTestCaseFailed request(err,msg);
   356 			TTestCaseFailed request(err,msg);
   335 			iClientAction->SendRequest(request,this);
   357 			iClientAction->SendRequest(request,this);
       
   358 			OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_EXIT_DUP06, this );
   336 			return;
   359 			return;
   337 			}
   360 			}
   338 		
   361 		
   339 		RDebug::Printf("Pipe established on rollback now closing");
   362 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP20, "Pipe established on rollback now closing");
   340 		iTestPipe.Close();
   363 		iTestPipe.Close();
   341 		}
   364 		}
   342 	
   365 	
   343 	// Inform client device test case successful	
   366 	// Inform client device test case successful	
   344 	iCaseStep = EPassed;
   367 	iCaseStep = EPassed;
   345 	TTestCasePassed request;
   368 	TTestCasePassed request;
   346 	iClientAction->SendRequest(request,this);
   369 	iClientAction->SendRequest(request,this);
       
   370 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_EXIT_DUP07, this );
   347 	}
   371 	}
   348 	
   372 	
   349 	
   373 	
   350 void CUT_PBASE_T_USBDI_0477::DeviceRemovedL(TUint aDeviceHandle)
   374 void CUT_PBASE_T_USBDI_0477::DeviceRemovedL(TUint aDeviceHandle)
   351 	{
   375 	{
   352 	LOG_FUNC
   376     OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0477_DEVICEREMOVEDL_ENTRY, this );
   353 
   377 
   354 	// The test device should not be removed until the test case has passed
   378 	// The test device should not be removed until the test case has passed
   355 	// so this test case has not completed, and state this event as an error
   379 	// so this test case has not completed, and state this event as an error
   356 
   380 
   357 	TestFailed(KErrDisconnected);
   381 	TestFailed(KErrDisconnected);
       
   382 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEREMOVEDL_EXIT, this );
   358 	}
   383 	}
   359 	
   384 	
   360 	
   385 	
   361 void CUT_PBASE_T_USBDI_0477::BusErrorL(TInt aError)
   386 void CUT_PBASE_T_USBDI_0477::BusErrorL(TInt aError)
   362 	{
   387 	{
   363 	LOG_FUNC
   388     OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0477_BUSERRORL_ENTRY, this );
   364 
   389 
   365 	// This test case handles no failiures on the bus
   390 	// This test case handles no failiures on the bus
   366 	
   391 	
   367 	TestFailed(aError);
   392 	TestFailed(aError);
       
   393 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_BUSERRORL_EXIT, this );
   368 	}
   394 	}
   369 	
   395 	
   370 	
   396 	
   371 void CUT_PBASE_T_USBDI_0477::DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState,
   397 void CUT_PBASE_T_USBDI_0477::DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState,
   372 	RUsbDevice::TDeviceState aNewState,TInt aCompletionCode)
   398 	RUsbDevice::TDeviceState aNewState,TInt aCompletionCode)
   373 	{
   399 	{
   374 	LOG_FUNC
   400 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0477_DEVICESTATECHANGEL_ENTRY, this );
   375 	Cancel();
   401 	Cancel();
       
   402 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICESTATECHANGEL_EXIT, this );
   376 	}
   403 	}
   377 
   404 
   378 void CUT_PBASE_T_USBDI_0477::Ep0TransferCompleteL(TInt aCompletionCode)
   405 void CUT_PBASE_T_USBDI_0477::Ep0TransferCompleteL(TInt aCompletionCode)
   379 	{
   406 	{
   380 	LOG_FUNC
   407 	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0477_EP0TRANSFERCOMPLETEL_ENTRY, this );
   381 	
   408 	
   382 	RDebug::Printf("Ep0TransferCompleteL with aCompletionCode = %d",aCompletionCode);
   409 	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_EP0TRANSFERCOMPLETEL, "Ep0TransferCompleteL with aCompletionCode = %d",aCompletionCode);
   383 	
   410 	
   384 	if(iCaseStep == EPassed)
   411 	if(iCaseStep == EPassed)
   385 		{
   412 		{
   386 		TestPassed();
   413 		TestPassed();
   387 		}
   414 		}
   388 		
   415 		
   389 	if(iCaseStep == EFailed)
   416 	if(iCaseStep == EFailed)
   390 		{
   417 		{
   391 		TestFailed(KErrCompletion);
   418 		TestFailed(KErrCompletion);
   392 		}
   419 		}
       
   420 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_EP0TRANSFERCOMPLETEL_EXIT, this );
   393 	}
   421 	}
   394 	
   422 	
   395 	
   423 	
   396 void CUT_PBASE_T_USBDI_0477::HostRunL()
   424 void CUT_PBASE_T_USBDI_0477::HostRunL()
   397 	{
   425 	{
   398 	LOG_FUNC
   426     OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_HOSTRUNL_ENTRY, this );
   399 
   427 
   400 	// Obtain the completion code
   428 	// Obtain the completion code
   401 	TInt completionCode(iStatus.Int());
   429 	TInt completionCode(iStatus.Int());
   402 	
   430 	
   403 	if(completionCode == KErrNone)
   431 	if(completionCode == KErrNone)
   404 		{
   432 		{
   405 		// Action timeout
   433 		// Action timeout
   406 		RDebug::Printf("<Error> Action timeout");
   434 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_HOSTRUNL, "<Error> Action timeout");
   407 		TestFailed(KErrTimedOut);
   435 		TestFailed(KErrTimedOut);
   408 		}
   436 		}
   409 	else
   437 	else
   410 		{
   438 		{
   411 		RDebug::Printf("<Error %d> Timeout timer could not complete",completionCode);
   439 		OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_HOSTRUNL_DUP01, "<Error %d> Timeout timer could not complete",completionCode);
   412 		TestFailed(completionCode);
   440 		TestFailed(completionCode);
   413 		}
   441 		}
       
   442 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_HOSTRUNL_EXIT, this );
   414 	}
   443 	}
   415 
   444 
   416 void CUT_PBASE_T_USBDI_0477::DeviceRunL()
   445 void CUT_PBASE_T_USBDI_0477::DeviceRunL()
   417 	{
   446 	{
   418 	LOG_FUNC
   447 	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_DEVICERUNL_ENTRY, this );
   419 	
   448 	
   420 	// Disconnect the device
   449 	// Disconnect the device
   421 	
   450 	
   422 	iTestDevice->SoftwareDisconnect();
   451 	iTestDevice->SoftwareDisconnect();
   423 	
   452 	
   424 	// Complete the test case request
   453 	// Complete the test case request
   425 	
   454 	
   426 	TestPolicy().SignalTestComplete(iStatus.Int());
   455 	TestPolicy().SignalTestComplete(iStatus.Int());
   427 	}
   456 	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICERUNL_EXIT, this );
   428 	
   457 	}
   429 	
   458 	
   430 	}
   459 	
   431 
   460 	}
       
   461