kerneltest/e32test/usbho/t_usbdi/src/PBASE-T_USBDI-1235.cpp
changeset 259 57b9594f5772
parent 0 a41df078684a
child 257 3e88ff8f41d5
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".
    19 #include "PBASE-T_USBDI-1235.h"
    19 #include "PBASE-T_USBDI-1235.h"
    20 #include <d32usbc.h>
    20 #include <d32usbc.h>
    21 #include "testdebug.h"
    21 #include "testdebug.h"
    22 #include "modelleddevices.h"
    22 #include "modelleddevices.h"
    23 #include "TestPolicy.h"
    23 #include "TestPolicy.h"
       
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "PBASE-T_USBDI-1235Traces.h"
       
    27 #endif
    24 
    28 
    25 namespace NUnitTesting_USBDI
    29 namespace NUnitTesting_USBDI
    26 	{
    30 	{
    27 
    31 
    28 	_LIT(KTestCaseId,"PBASE-T_USBDI-1235");
    32 	_LIT(KTestCaseId,"PBASE-T_USBDI-1235");
    30 	const TFunctorTestCase<CUT_PBASE_T_USBDI_1235,TBool>
    34 	const TFunctorTestCase<CUT_PBASE_T_USBDI_1235,TBool>
    31 			CUT_PBASE_T_USBDI_1235::iFunctor(KTestCaseId);
    35 			CUT_PBASE_T_USBDI_1235::iFunctor(KTestCaseId);
    32 
    36 
    33 	CUT_PBASE_T_USBDI_1235* CUT_PBASE_T_USBDI_1235::NewL(TBool aHostRole)
    37 	CUT_PBASE_T_USBDI_1235* CUT_PBASE_T_USBDI_1235::NewL(TBool aHostRole)
    34 		{
    38 		{
       
    39 		OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1235_NEWL_ENTRY, aHostRole );
    35 		CUT_PBASE_T_USBDI_1235* self = new (ELeave) CUT_PBASE_T_USBDI_1235(aHostRole);
    40 		CUT_PBASE_T_USBDI_1235* self = new (ELeave) CUT_PBASE_T_USBDI_1235(aHostRole);
    36 		CleanupStack::PushL(self);
    41 		CleanupStack::PushL(self);
    37 		self->ConstructL();
    42 		self->ConstructL();
    38 		CleanupStack::Pop(self);
    43 		CleanupStack::Pop(self);
       
    44 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_NEWL_EXIT, ( TUint )( self ) );
    39 		return self;
    45 		return self;
    40 		}
    46 		}
    41 
    47 
    42 	CUT_PBASE_T_USBDI_1235::CUT_PBASE_T_USBDI_1235(TBool aHostRole) :
    48 	CUT_PBASE_T_USBDI_1235::CUT_PBASE_T_USBDI_1235(TBool aHostRole) :
    43 		CBaseTestCase(KTestCaseId, aHostRole), iSuspendedI0(EFalse),
    49 		CBaseTestCase(KTestCaseId, aHostRole), iSuspendedI0(EFalse),
    44 				iSuspendedI1(EFalse)
    50 				iSuspendedI1(EFalse)
    45 		{
    51 		{
       
    52 		OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1235_CUT_PBASE_T_USBDI_1235_ENTRY, this );
       
    53 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_CUT_PBASE_T_USBDI_1235_EXIT, this );
    46 		}
    54 		}
    47 
    55 
    48 	void CUT_PBASE_T_USBDI_1235::ConstructL()
    56 	void CUT_PBASE_T_USBDI_1235::ConstructL()
    49 		{
    57 		{
       
    58 		OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1235_CONSTRUCTL_ENTRY, this );
    50 		iTestDevice = new RUsbDeviceA(this);
    59 		iTestDevice = new RUsbDeviceA(this);
    51 		BaseConstructL();
    60 		BaseConstructL();
       
    61 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_CONSTRUCTL_EXIT, this );
    52 		}
    62 		}
    53 
    63 
    54 	CUT_PBASE_T_USBDI_1235::~CUT_PBASE_T_USBDI_1235()
    64 	CUT_PBASE_T_USBDI_1235::~CUT_PBASE_T_USBDI_1235()
    55 		{
    65 		{
    56 		LOG_FUNC
    66         OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1235_CUT_PBASE_T_USBDI_1235_ENTRY_DUP01, this );
    57 
    67 
    58 		// Cancel any async operations
    68 		// Cancel any async operations
    59 
    69 
    60 		Cancel(); // Cancel host timer
    70 		Cancel(); // Cancel host timer
    61 
    71 
    72 		if (!IsHost() && iTestDevice)
    82 		if (!IsHost() && iTestDevice)
    73 			{
    83 			{
    74 			iTestDevice->Close();
    84 			iTestDevice->Close();
    75 			}
    85 			}
    76 		delete iTestDevice;
    86 		delete iTestDevice;
       
    87 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_CUT_PBASE_T_USBDI_1235_EXIT_DUP01, this );
    77 		}
    88 		}
    78 
    89 
    79 	void CUT_PBASE_T_USBDI_1235::ExecuteHostTestCaseL()
    90 	void CUT_PBASE_T_USBDI_1235::ExecuteHostTestCaseL()
    80 		{
    91 		{
    81 		LOG_FUNC
    92         OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1235_EXECUTEHOSTTESTCASEL_ENTRY, this );
    82 
    93 
    83 		iCaseStep = EInProcess;
    94 		iCaseStep = EInProcess;
    84 		iActorFDF = CActorFDF::NewL(*this);
    95 		iActorFDF = CActorFDF::NewL(*this);
    85 		iControlEp0 = new (ELeave) CEp0Transfer(iUsbInterface0);
    96 		iControlEp0 = new (ELeave) CEp0Transfer(iUsbInterface0);
    86 		iInterface0Watcher = new (ELeave) CInterfaceWatcher(iUsbInterface0,TCallBack(CUT_PBASE_T_USBDI_1235::Interface0ResumedL,this));
    97 		iInterface0Watcher = new (ELeave) CInterfaceWatcher(iUsbInterface0,TCallBack(CUT_PBASE_T_USBDI_1235::Interface0ResumedL,this));
    89 		// Monitor for device connections
   100 		// Monitor for device connections
    90 		iActorFDF->Monitor();
   101 		iActorFDF->Monitor();
    91 
   102 
    92 		// Start the connection timeout	
   103 		// Start the connection timeout	
    93 		TimeoutIn(30);
   104 		TimeoutIn(30);
       
   105 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_EXECUTEHOSTTESTCASEL_EXIT, this );
    94 		}
   106 		}
    95 
   107 
    96 	void CUT_PBASE_T_USBDI_1235::ExecuteDeviceTestCaseL()
   108 	void CUT_PBASE_T_USBDI_1235::ExecuteDeviceTestCaseL()
    97 		{
   109 		{
    98 		LOG_FUNC
   110         OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1235_EXECUTEDEVICETESTCASEL_ENTRY, this );
    99 
   111 
   100 		// Construct the device for the test case
   112 		// Construct the device for the test case
   101 		iTestDevice->OpenL(TestCaseId());
   113 		iTestDevice->OpenL(TestCaseId());
   102 		iTestDevice->SubscribeToReports(iStatus);
   114 		iTestDevice->SubscribeToReports(iStatus);
   103 		SetActive();
   115 		SetActive();
   104 
   116 
   105 		// Connect the test device	
   117 		// Connect the test device	
   106 		iTestDevice->SoftwareConnect();
   118 		iTestDevice->SoftwareConnect();
       
   119 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_EXECUTEDEVICETESTCASEL_EXIT, this );
   107 		}
   120 		}
   108 
   121 
   109 	void CUT_PBASE_T_USBDI_1235::HostDoCancel()
   122 	void CUT_PBASE_T_USBDI_1235::HostDoCancel()
   110 		{
   123 		{
   111 		LOG_FUNC
   124         OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1235_HOSTDOCANCEL_ENTRY, this );
   112 
   125 
   113 		// Cancel the timeout timer
   126 		// Cancel the timeout timer
   114 		CancelTimeout();
   127 		CancelTimeout();
       
   128 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_HOSTDOCANCEL_EXIT, this );
   115 		}
   129 		}
   116 
   130 
   117 	void CUT_PBASE_T_USBDI_1235::DeviceDoCancel()
   131 	void CUT_PBASE_T_USBDI_1235::DeviceDoCancel()
   118 		{
   132 		{
   119 		LOG_FUNC
   133         OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1235_DEVICEDOCANCEL_ENTRY, this );
   120 
   134 
   121 		// Cancel the device	
   135 		// Cancel the device	
   122 		iTestDevice->CancelSubscriptionToReports();
   136 		iTestDevice->CancelSubscriptionToReports();
       
   137 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_DEVICEDOCANCEL_EXIT, this );
   123 		}
   138 		}
   124 
   139 
   125 	void CUT_PBASE_T_USBDI_1235::DeviceInsertedL(TUint aDeviceHandle)
   140 	void CUT_PBASE_T_USBDI_1235::DeviceInsertedL(TUint aDeviceHandle)
   126 		{
   141 		{
   127 		LOG_FUNC
   142         OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1235_DEVICEINSERTEDL_ENTRY, this );
   128 
   143 
   129 		Cancel(); // Cancel the timer
   144 		Cancel(); // Cancel the timer
   130 		TInt err(KErrNone);
   145 		TInt err(KErrNone);
   131 		iDeviceHandle = aDeviceHandle;
   146 		iDeviceHandle = aDeviceHandle;
   132 		iActorFDF->Monitor();
   147 		iActorFDF->Monitor();
   141 					"<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)",
   156 					"<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)",
   142 					KErrNotFound, &testDevice.SerialNumber(), &TestCaseId());
   157 					KErrNotFound, &testDevice.SerialNumber(), &TestCaseId());
   143 
   158 
   144 			// Start the connection timeout again
   159 			// Start the connection timeout again
   145 			TimeoutIn(30);
   160 			TimeoutIn(30);
       
   161 			OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_DEVICEINSERTEDL_EXIT, this );
   146 			return;
   162 			return;
   147 			}
   163 			}
   148 		// Check tree now	
   164 		// Check tree now	
   149 		CHECK(CheckTreeAfterDeviceInsertion(testDevice, _L("RDeviceA")) == KErrNone);
   165 		CHECK(CheckTreeAfterDeviceInsertion(testDevice, _L("RDeviceA")) == KErrNone);
   150 
   166 
   154 			case EInProcess:
   170 			case EInProcess:
   155 				{
   171 				{
   156 				TUint32 token1(0);
   172 				TUint32 token1(0);
   157 				TUint32 token2(0);
   173 				TUint32 token2(0);
   158 
   174 
   159 				RDebug::Printf("Obtaining token for interface 0");
   175 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235, "Obtaining token for interface 0");
   160 				err = testDevice.Device().GetTokenForInterface(0, token1);
   176 				err = testDevice.Device().GetTokenForInterface(0, token1);
   161 				if (err != KErrNone)
   177 				if (err != KErrNone)
   162 					{
   178 					{
   163 					RDebug::Printf(
   179 					RDebug::Printf(
   164 							"<Error %d> Token for interface 0 could not be retrieved",
   180 							"<Error %d> Token for interface 0 could not be retrieved",
   165 							err);
   181 							err);
   166 					return TestFailed(err);
   182 					return TestFailed(err);
   167 					}
   183 					}
   168 				RDebug::Printf("Token 1 (%d) retrieved", token1);
   184 				OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP01, "Token 1 (%d) retrieved", token1);
   169 				RDebug::Printf("Opening interface 0");
   185 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP02, "Opening interface 0");
   170 				err = iUsbInterface0.Open(token1); // Alternate interface setting 0
   186 				err = iUsbInterface0.Open(token1); // Alternate interface setting 0
   171 				if (err != KErrNone)
   187 				if (err != KErrNone)
   172 					{
   188 					{
   173 					RDebug::Printf(
   189 					RDebug::Printf(
   174 							"<Error %d> Interface 0 could not be opened", err);
   190 							"<Error %d> Interface 0 could not be opened", err);
   175 					return TestFailed(err);
   191 					return TestFailed(err);
   176 					}
   192 					}
   177 				RDebug::Printf("Interface 0 opened");
   193 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP03, "Interface 0 opened");
   178 
   194 
   179 				RDebug::Printf("Obtaining token for interface 1");
   195 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP04, "Obtaining token for interface 1");
   180 				err = testDevice.Device().GetTokenForInterface(1, token2);
   196 				err = testDevice.Device().GetTokenForInterface(1, token2);
   181 				if (err != KErrNone)
   197 				if (err != KErrNone)
   182 					{
   198 					{
   183 					RDebug::Printf(
   199 					RDebug::Printf(
   184 							"<Error %d> Token for interface 1 could not be retrieved",
   200 							"<Error %d> Token for interface 1 could not be retrieved",
   185 							err);
   201 							err);
   186 					return TestFailed(err);
   202 					return TestFailed(err);
   187 					}
   203 					}
   188 				RDebug::Printf("Opening interface 1");
   204 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP05, "Opening interface 1");
   189 				err = iUsbInterface1.Open(token2); // Alternate interface setting 0
   205 				err = iUsbInterface1.Open(token2); // Alternate interface setting 0
   190 				if (err != KErrNone)
   206 				if (err != KErrNone)
   191 					{
   207 					{
   192 					RDebug::Printf(
   208 					RDebug::Printf(
   193 							"<Error %d> Interface 1 could not be opened", err);
   209 							"<Error %d> Interface 1 could not be opened", err);
   194 					return TestFailed(err);
   210 					return TestFailed(err);
   195 					}
   211 					}
   196 				RDebug::Printf("Interface 1 opened");
   212 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP06, "Interface 1 opened");
   197 
   213 
   198 				SuspendDeviceByInterfacesAndCancelWaitForResume();
   214 				SuspendDeviceByInterfacesAndCancelWaitForResume();
   199 
   215 
   200 				iCaseStep = EValidCancelSuspendAfterInterfaceSuspend;
   216 				iCaseStep = EValidCancelSuspendAfterInterfaceSuspend;
   201 				
   217 				
   204 
   220 
   205 			default:
   221 			default:
   206 				TestFailed(KErrCorrupt);
   222 				TestFailed(KErrCorrupt);
   207 				break;
   223 				break;
   208 			}
   224 			}
       
   225 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_DEVICEINSERTEDL_EXIT_DUP01, this );
   209 		}
   226 		}
   210 
   227 
   211 	TInt CUT_PBASE_T_USBDI_1235::Interface0ResumedL(TAny* aPtr)
   228 	TInt CUT_PBASE_T_USBDI_1235::Interface0ResumedL(TAny* aPtr)
   212 		{
   229 		{
   213 		LOG_CFUNC
   230 		OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1235_INTERFACE0RESUMEDL_ENTRY, 0 );
   214 		RDebug::Printf("Interface 0 resumed");
   231 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP07, "Interface 0 resumed");
   215 		CUT_PBASE_T_USBDI_1235* self =
   232 		CUT_PBASE_T_USBDI_1235* self =
   216 				reinterpret_cast<CUT_PBASE_T_USBDI_1235*>(aPtr);
   233 				reinterpret_cast<CUT_PBASE_T_USBDI_1235*>(aPtr);
   217 		TInt completionCode=self->iInterface0Watcher->CompletionCode();
   234 		TInt completionCode=self->iInterface0Watcher->CompletionCode();
   218 		RDebug::Printf(
   235 		RDebug::Printf(
   219 				"watcher 0 iStatus=%d",
   236 				"watcher 0 iStatus=%d",
   225 
   242 
   226 			case EValidCancelSuspendAfterInterfaceSuspend:
   243 			case EValidCancelSuspendAfterInterfaceSuspend:
   227 				{
   244 				{
   228 				if (completionCode == KErrCancel)
   245 				if (completionCode == KErrCancel)
   229 					{
   246 					{
   230 					RDebug::Printf("CancelWaitForResume request: Success <>!",completionCode);
   247 					OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP08, "CancelWaitForResume request: Success <%d>!",completionCode);
   231 				    // do not care the device's status.
   248 				    // do not care the device's status.
   232 					self->iCaseStep = EPassed;					
   249 					self->iCaseStep = EPassed;					
   233 					}
   250 					}
   234 				else
   251 				else
   235 					{
   252 					{
   245 
   262 
   246 			default:
   263 			default:
   247 				break;
   264 				break;
   248 			};
   265 			};
   249 
   266 
       
   267 		OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_1235_INTERFACE0RESUMEDL_EXIT, 0, KErrNone );
   250 		return KErrNone;
   268 		return KErrNone;
   251 		}
   269 		}
   252 
   270 
   253 	TInt CUT_PBASE_T_USBDI_1235::Interface1ResumedL(TAny* aPtr)
   271 	TInt CUT_PBASE_T_USBDI_1235::Interface1ResumedL(TAny* aPtr)
   254 		{
   272 		{
   255 		LOG_CFUNC
   273 		OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1235_INTERFACE1RESUMEDL_ENTRY, 0 );
   256 		RDebug::Printf("Interface 1 resumed");
   274 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP09, "Interface 1 resumed");
   257 		CUT_PBASE_T_USBDI_1235* self =
   275 		CUT_PBASE_T_USBDI_1235* self =
   258 				reinterpret_cast<CUT_PBASE_T_USBDI_1235*>(aPtr);
   276 				reinterpret_cast<CUT_PBASE_T_USBDI_1235*>(aPtr);
   259 		TInt completionCode = self->iInterface1Watcher->CompletionCode();		
   277 		TInt completionCode = self->iInterface1Watcher->CompletionCode();		
   260 		RDebug::Printf("watcher 1 iStatus=%d",completionCode);
   278 		OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP10, "watcher 1 iStatus=%d",completionCode);
   261 		self->iSuspendedI1 = EFalse;
   279 		self->iSuspendedI1 = EFalse;
   262 		
   280 		
   263 		if(self->iCaseStep == EPassed && completionCode == KErrNone )
   281 		if(self->iCaseStep == EPassed && completionCode == KErrNone )
   264 			{
   282 			{
   265 			RDebug::Printf("Device resumed,test passed!");
   283 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP11, "Device resumed,test passed!");
   266 			self->SendEp0Request(); // stop client;
   284 			self->SendEp0Request(); // stop client;
   267 			}
   285 			}
   268 		
   286 		
       
   287 		OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_1235_INTERFACE1RESUMEDL_EXIT, 0, KErrNone );
   269 		return KErrNone;
   288 		return KErrNone;
   270 		}
   289 		}
   271 
   290 
   272 	void CUT_PBASE_T_USBDI_1235::DeviceRemovedL(TUint aDeviceHandle)
   291 	void CUT_PBASE_T_USBDI_1235::DeviceRemovedL(TUint aDeviceHandle)
   273 		{
   292 		{
   274 		LOG_FUNC
   293         OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1235_DEVICEREMOVEDL_ENTRY, this );
   275 
   294 
   276 		// The test device should not be removed until the test case has passed
   295 		// The test device should not be removed until the test case has passed
   277 		// so this test case has not completed, and state this event as an error
   296 		// so this test case has not completed, and state this event as an error
   278 
   297 
   279 		TestFailed(KErrDisconnected);
   298 		TestFailed(KErrDisconnected);
       
   299 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_DEVICEREMOVEDL_EXIT, this );
   280 		}
   300 		}
   281 
   301 
   282 	void CUT_PBASE_T_USBDI_1235::BusErrorL(TInt aError)
   302 	void CUT_PBASE_T_USBDI_1235::BusErrorL(TInt aError)
   283 		{
   303 		{
   284 		LOG_FUNC
   304         OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1235_BUSERRORL_ENTRY, this );
   285 
   305 
   286 		// This test case handles no failiures on the bus
   306 		// This test case handles no failiures on the bus
   287 
   307 
   288 		TestFailed(aError);
   308 		TestFailed(aError);
       
   309 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_BUSERRORL_EXIT, this );
   289 		}
   310 		}
   290 
   311 
   291 
   312 
   292 	void CUT_PBASE_T_USBDI_1235::DeviceStateChangeL(
   313 	void CUT_PBASE_T_USBDI_1235::DeviceStateChangeL(
   293 			RUsbDevice::TDeviceState aPreviousState,
   314 			RUsbDevice::TDeviceState aPreviousState,
   294 			RUsbDevice::TDeviceState aNewState, TInt aCompletionCode)
   315 			RUsbDevice::TDeviceState aNewState, TInt aCompletionCode)
   295 		{
   316 		{
   296 		LOG_FUNC
   317 		OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1235_DEVICESTATECHANGEL_ENTRY, this );
   297 		Cancel();
   318 		Cancel();
   298 		
   319 		
   299 		// test RInterface , the  RUsbDevice notification logic not used . 
   320 		// test RInterface , the  RUsbDevice notification logic not used . 
   300 		RDebug::Printf(
   321 		RDebug::Printf(
   301 				"-Device State change from %d to %d err=%d",
   322 				"-Device State change from %d to %d err=%d",
   302 				aPreviousState, aNewState, aCompletionCode);
   323 				aPreviousState, aNewState, aCompletionCode);
   303 
   324 
       
   325 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_DEVICESTATECHANGEL_EXIT, this );
   304 		}
   326 		}
   305 
   327 
   306 	void CUT_PBASE_T_USBDI_1235::Ep0TransferCompleteL(TInt aCompletionCode)
   328 	void CUT_PBASE_T_USBDI_1235::Ep0TransferCompleteL(TInt aCompletionCode)
   307 		{
   329 		{
   308 		LOG_FUNC
   330 		OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1235_EP0TRANSFERCOMPLETEL_ENTRY, this );
   309 		RDebug::Printf("Ep0TransferCompleteL with aCompletionCode = %d",
   331 		OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP12, "Ep0TransferCompleteL with aCompletionCode = %d",
   310 				aCompletionCode);
   332 				aCompletionCode);
   311 		switch (iCaseStep)
   333 		switch (iCaseStep)
   312 			{
   334 			{
   313 
   335 
   314 			default:
   336 			default:
   318 
   340 
   319 			case EPassed:
   341 			case EPassed:
   320 				TestPassed();
   342 				TestPassed();
   321 				break;
   343 				break;
   322 			}
   344 			}
       
   345 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_EP0TRANSFERCOMPLETEL_EXIT, this );
   323 		}
   346 		}
   324 
   347 
   325 	void CUT_PBASE_T_USBDI_1235::HostRunL()
   348 	void CUT_PBASE_T_USBDI_1235::HostRunL()
   326 		{
   349 		{
   327 		LOG_FUNC
   350         OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1235_HOSTRUNL_ENTRY, this );
   328 
   351 
   329 		// Obtain the completion code
   352 		// Obtain the completion code
   330 		TInt completionCode(iStatus.Int());
   353 		TInt completionCode(iStatus.Int());
   331 
   354 
   332 		if (completionCode == KErrNone)
   355 		if (completionCode == KErrNone)
   333 			{
   356 			{
   334 			// Action timeout
   357 			// Action timeout
   335 			RDebug::Printf("<Error> Action timeout");
   358 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP13, "<Error> Action timeout");
   336 			TestFailed(KErrTimedOut);
   359 			TestFailed(KErrTimedOut);
   337 			}
   360 			}
   338 		else
   361 		else
   339 			{
   362 			{
   340 			RDebug::Printf("<Error %d> Timeout timer could not complete",
   363 			OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP14, "<Error %d> Timeout timer could not complete",
   341 					completionCode);
   364 					completionCode);
   342 			TestFailed(completionCode);
   365 			TestFailed(completionCode);
   343 			}
   366 			}
       
   367 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_HOSTRUNL_EXIT, this );
   344 		}
   368 		}
   345 
   369 
   346 	void CUT_PBASE_T_USBDI_1235::DeviceRunL()
   370 	void CUT_PBASE_T_USBDI_1235::DeviceRunL()
   347 		{
   371 		{
   348 		LOG_FUNC
   372         OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1235_DEVICERUNL_ENTRY, this );
   349 
   373 
   350 		// Disconnect the device
   374 		// Disconnect the device
   351 
   375 
   352 		iTestDevice->SoftwareDisconnect();
   376 		iTestDevice->SoftwareDisconnect();
   353 
   377 
   354 		// Complete the test case request
   378 		// Complete the test case request
   355 
   379 
   356 		TestPolicy().SignalTestComplete(iStatus.Int());
   380 		TestPolicy().SignalTestComplete(iStatus.Int());
       
   381 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_DEVICERUNL_EXIT, this );
   357 		}
   382 		}
   358 
   383 
   359 	void CUT_PBASE_T_USBDI_1235::SuspendDeviceByInterfacesAndCancelWaitForResume()
   384 	void CUT_PBASE_T_USBDI_1235::SuspendDeviceByInterfacesAndCancelWaitForResume()
   360 		{
   385 		{
       
   386 		OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1235_SUSPENDDEVICEBYINTERFACESANDCANCELWAITFORRESUME_ENTRY, this );
   361 		// Suspend interface 0
   387 		// Suspend interface 0
   362 		RDebug::Printf("Suspending interface 0");
   388 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP15, "Suspending interface 0");
   363 		iInterface0Watcher->SuspendAndWatch();
   389 		iInterface0Watcher->SuspendAndWatch();
   364 		iSuspendedI0 = ETrue;
   390 		iSuspendedI0 = ETrue;
   365 		
   391 		
   366 		// Suspend interface 1
   392 		// Suspend interface 1
   367 		RDebug::Printf("Suspending interface 1");
   393 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP16, "Suspending interface 1");
   368 		iInterface1Watcher->SuspendAndWatch();
   394 		iInterface1Watcher->SuspendAndWatch();
   369 		iSuspendedI1 = ETrue;
   395 		iSuspendedI1 = ETrue;
   370 		
   396 		
   371 		RDebug::Printf("CancelPermitSuspend interface 1");
   397 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP17, "CancelPermitSuspend interface 1");
   372 		// try to resume device,then host can notify peripheral test passed.
   398 		// try to resume device,then host can notify peripheral test passed.
   373 		iUsbInterface1.CancelPermitSuspend();
   399 		iUsbInterface1.CancelPermitSuspend();
   374 
   400 
   375 		// Only test the CancelWaitForResume() operation 
   401 		// Only test the CancelWaitForResume() operation 
   376 		// If we let the devic to suspend ,the periperal site could not receive the test control transfer which test finish result.
   402 		// If we let the devic to suspend ,the periperal site could not receive the test control transfer which test finish result.
   377         // select interface0 to test the function CancelWaitForResume	
   403         // select interface0 to test the function CancelWaitForResume	
   378 		RDebug::Printf("CacelWaitForResume interface 0");
   404 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1235_DCUT_PBASE_T_USBDI_1235_DUP18, "CacelWaitForResume interface 0");
   379 		iUsbInterface0.CancelWaitForResume();
   405 		iUsbInterface0.CancelWaitForResume();
   380 
   406 
       
   407 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_SUSPENDDEVICEBYINTERFACESANDCANCELWAITFORRESUME_EXIT, this );
   381 		}
   408 		}
   382 	
   409 	
   383 	void CUT_PBASE_T_USBDI_1235::SendEp0Request()
   410 	void CUT_PBASE_T_USBDI_1235::SendEp0Request()
   384 		{		
   411 		{		
       
   412 		OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1235_SENDEP0REQUEST_ENTRY, this );
   385 		TTestCasePassed request;
   413 		TTestCasePassed request;
   386 		iControlEp0->SendRequest(request, this);
   414 		iControlEp0->SendRequest(request, this);
       
   415 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1235_SENDEP0REQUEST_EXIT, this );
   387 		}
   416 		}
   388 
   417 
   389 	}//end namespace
   418 	}//end namespace
   390 
   419 
   391 
   420