kerneltest/e32test/usbho/t_usbdi/src/PBASE-T_USBDI-1234.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-1234.h"
    19 #include "PBASE-T_USBDI-1234.h"
    20 #include "modelleddevices.h"
    20 #include "modelleddevices.h"
    21 #include "testpolicy.h"
    21 #include "testpolicy.h"
    22 #include "testliterals.h"
    22 #include "testliterals.h"
       
    23 #include "OstTraceDefinitions.h"
       
    24 #ifdef OST_TRACE_COMPILER_IN_USE
       
    25 #include "PBASE-T_USBDI-1234Traces.h"
       
    26 #endif
    23 
    27 
    24 namespace NUnitTesting_USBDI
    28 namespace NUnitTesting_USBDI
    25 	{
    29 	{
    26 	const TInt KBulkTransferSize = 583;
    30 	const TInt KBulkTransferSize = 583;
    27 	const TUint KHostNumWriteBytes1 = 210;
    31 	const TUint KHostNumWriteBytes1 = 210;
    51 	const TFunctorTestCase<CUT_PBASE_T_USBDI_1234,TBool>
    55 	const TFunctorTestCase<CUT_PBASE_T_USBDI_1234,TBool>
    52 			CUT_PBASE_T_USBDI_1234::iFunctor(KTestCaseId);
    56 			CUT_PBASE_T_USBDI_1234::iFunctor(KTestCaseId);
    53 
    57 
    54 	CUT_PBASE_T_USBDI_1234* CUT_PBASE_T_USBDI_1234::NewL(TBool aHostRole)
    58 	CUT_PBASE_T_USBDI_1234* CUT_PBASE_T_USBDI_1234::NewL(TBool aHostRole)
    55 		{
    59 		{
       
    60 		OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1234_NEWL_ENTRY, aHostRole );
    56 		CUT_PBASE_T_USBDI_1234* self = new (ELeave) CUT_PBASE_T_USBDI_1234(aHostRole);
    61 		CUT_PBASE_T_USBDI_1234* self = new (ELeave) CUT_PBASE_T_USBDI_1234(aHostRole);
    57 		CleanupStack::PushL(self);
    62 		CleanupStack::PushL(self);
    58 		self->ConstructL();
    63 		self->ConstructL();
    59 		CleanupStack::Pop(self);
    64 		CleanupStack::Pop(self);
       
    65 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_NEWL_EXIT, ( TUint )( self ) );
    60 		return self;
    66 		return self;
    61 		}
    67 		}
    62 
    68 
    63 	CUT_PBASE_T_USBDI_1234::CUT_PBASE_T_USBDI_1234(TBool aHostRole) :
    69 	CUT_PBASE_T_USBDI_1234::CUT_PBASE_T_USBDI_1234(TBool aHostRole) :
    64 		CBaseBulkTestCase(KTestCaseId, aHostRole), iCaseStep(EInProgress)
    70 		CBaseBulkTestCase(KTestCaseId, aHostRole), iCaseStep(EInProgress)
    65 		{
    71 		{
    66 
    72         OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1234_CUT_PBASE_T_USBDI_1234_ENTRY, this );
       
    73 
       
    74 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_CUT_PBASE_T_USBDI_1234_EXIT, this );
    67 		}
    75 		}
    68 
    76 
    69 	void CUT_PBASE_T_USBDI_1234::ExecuteHostTestCaseL()
    77 	void CUT_PBASE_T_USBDI_1234::ExecuteHostTestCaseL()
    70 		{
    78 		{
       
    79 		OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1234_EXECUTEHOSTTESTCASEL_ENTRY, this );
    71 		CBaseBulkTestCase::ExecuteHostTestCaseL();
    80 		CBaseBulkTestCase::ExecuteHostTestCaseL();
    72 		iInterface0Watcher = new (ELeave) CInterfaceWatcher(iUsbInterface0,TCallBack(CUT_PBASE_T_USBDI_1234::Interface0ResumedL,this));
    81 		iInterface0Watcher = new (ELeave) CInterfaceWatcher(iUsbInterface0,TCallBack(CUT_PBASE_T_USBDI_1234::Interface0ResumedL,this));
    73 		iInterface1Watcher = new (ELeave) CInterfaceWatcher(iUsbInterface1,TCallBack(CUT_PBASE_T_USBDI_1234::Interface1ResumedL,this));
    82 		iInterface1Watcher = new (ELeave) CInterfaceWatcher(iUsbInterface1,TCallBack(CUT_PBASE_T_USBDI_1234::Interface1ResumedL,this));
    74 		iInterface2Watcher = new (ELeave) CInterfaceWatcher(iUsbInterface1,TCallBack(CUT_PBASE_T_USBDI_1234::Interface2ResumedL,this));
    83 		iInterface2Watcher = new (ELeave) CInterfaceWatcher(iUsbInterface1,TCallBack(CUT_PBASE_T_USBDI_1234::Interface2ResumedL,this));
       
    84 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_EXECUTEHOSTTESTCASEL_EXIT, this );
    75 		}
    85 		}
    76 
    86 
    77 	void CUT_PBASE_T_USBDI_1234::ConstructL()
    87 	void CUT_PBASE_T_USBDI_1234::ConstructL()
    78 		{
    88 		{
       
    89 		OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1234_CONSTRUCTL_ENTRY, this );
    79 		BaseBulkConstructL();
    90 		BaseBulkConstructL();
       
    91 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_CONSTRUCTL_EXIT, this );
    80 		}
    92 		}
    81 
    93 
    82 	CUT_PBASE_T_USBDI_1234::~CUT_PBASE_T_USBDI_1234()
    94 	CUT_PBASE_T_USBDI_1234::~CUT_PBASE_T_USBDI_1234()
    83 		{
    95 		{
    84 		LOG_FUNC
    96 		OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1234_CUT_PBASE_T_USBDI_1234_ENTRY_DUP01, this );
    85 		// Cancel any async operations
    97 		// Cancel any async operations
    86 
    98 
    87 		Cancel(); // Cancel host timer
    99 		Cancel(); // Cancel host timer
    88 
   100 
    89 		if (iInterface1Watcher)
   101 		if (iInterface1Watcher)
    97 		if (iInterface2Watcher)
   109 		if (iInterface2Watcher)
    98 			{
   110 			{
    99 			delete iInterface2Watcher;
   111 			delete iInterface2Watcher;
   100 			}
   112 			}
   101 
   113 
       
   114 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_CUT_PBASE_T_USBDI_1234_EXIT_DUP01, this );
   102 		}
   115 		}
   103 
   116 
   104 	void CUT_PBASE_T_USBDI_1234::DeviceInsertedL(TUint aDeviceHandle)
   117 	void CUT_PBASE_T_USBDI_1234::DeviceInsertedL(TUint aDeviceHandle)
   105 		{
   118 		{
   106 		LOG_FUNC
   119         OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1234_DEVICEINSERTEDL_ENTRY, this );
   107 
   120 
   108 		Cancel();
   121 		Cancel();
   109 
   122 
   110 		if (BaseBulkDeviceInsertedL(aDeviceHandle) == EDeviceConfigurationError)
   123 		if (BaseBulkDeviceInsertedL(aDeviceHandle) == EDeviceConfigurationError)
   111 		// Prepare for response from control transfer to client
   124 		// Prepare for response from control transfer to client
   126 				= new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkTransferSize,*this,KBulkTransferOutId1);
   139 				= new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkTransferSize,*this,KBulkTransferOutId1);
   127 		iOutTransfer[2]
   140 		iOutTransfer[2]
   128 				= new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkTransferSize,*this,KBulkTransferOutId2);
   141 				= new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkTransferSize,*this,KBulkTransferOutId2);
   129 
   142 
   130 		// Initialise the descriptors for transfer		
   143 		// Initialise the descriptors for transfer		
   131 		RDebug::Printf("Initialising the transfer descriptors");
   144 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234, "Initialising the transfer descriptors");
   132 		TInt err = iUsbInterface1.InitialiseTransferDescriptors();
   145 		TInt err = iUsbInterface1.InitialiseTransferDescriptors();
   133 		if (err != KErrNone)
   146 		if (err != KErrNone)
   134 			{
   147 			{
   135 			TBuf<256> msg;
   148 			TBuf<256> msg;
   136 			msg.Format(_L("<Error %d> Unable to initialise transfer descriptors"),err);
   149 			msg.Format(_L("<Error %d> Unable to initialise transfer descriptors"),err);
   137 			RDebug::Print(msg);
   150 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP01, msg);
   138 			iCaseStep = EFailed;
   151 			iCaseStep = EFailed;
   139 			TTestCaseFailed request(err, msg);
   152 			TTestCaseFailed request(err, msg);
   140 			iControlEp0->SendRequest(request, this);
   153 			iControlEp0->SendRequest(request, this);
       
   154 			OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_DEVICEINSERTEDL_EXIT, this );
   141 			return;
   155 			return;
   142 			}
   156 			}
   143 
   157 
   144 		iCaseStep = ESuspendDevice;
   158 		iCaseStep = ESuspendDevice;
   145 
   159 
   146 		TrySuspendDeviceByInterfaces();
   160 		TrySuspendDeviceByInterfaces();
   147 
   161 
       
   162 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_DEVICEINSERTEDL_EXIT_DUP01, this );
   148 		}
   163 		}
   149 
   164 
   150 	TInt CUT_PBASE_T_USBDI_1234::Interface0ResumedL(TAny* aPtr)
   165 	TInt CUT_PBASE_T_USBDI_1234::Interface0ResumedL(TAny* aPtr)
   151 		{
   166 		{
       
   167 		OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1234_INTERFACE0RESUMEDL_ENTRY, 0 );
   152 		
   168 		
   153 		// when device is really resumed , the whole of interfaces' previous call  PermitSuspendAndWaitForResume()'s requests of the device will be completed , random chose one .
   169 		// when device is really resumed , the whole of interfaces' previous call  PermitSuspendAndWaitForResume()'s requests of the device will be completed , random chose one .
   154 		LOG_CFUNC
   170 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP02, "Interface 0 resumed");
   155 		RDebug::Printf("Interface 0 resumed");
       
   156 		CUT_PBASE_T_USBDI_1234* self =
   171 		CUT_PBASE_T_USBDI_1234* self =
   157 				reinterpret_cast<CUT_PBASE_T_USBDI_1234*>(aPtr);
   172 				reinterpret_cast<CUT_PBASE_T_USBDI_1234*>(aPtr);
   158 		TInt completionCode = self->iInterface0Watcher->CompletionCode();
   173 		TInt completionCode = self->iInterface0Watcher->CompletionCode();
   159 		RDebug::Printf("watcher 0 errCode=%d",completionCode);
   174 		OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP03, "watcher 0 errCode=%d",completionCode);
   160 		self->iSuspendedI0 = EFalse;
   175 		self->iSuspendedI0 = EFalse;
   161 
   176 
   162 		switch (self->iCaseStep)
   177 		switch (self->iCaseStep)
   163 			{
   178 			{
   164 
   179 
   165 			case EValidateResumebyInterface:
   180 			case EValidateResumebyInterface:
   166 				{
   181 				{
   167 				if (completionCode == KErrNone)
   182 				if (completionCode == KErrNone)
   168 					{
   183 					{
   169 					RDebug::Printf("device resumed succeed, do bulk transfer!");
   184 					OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP04, "device resumed succeed, do bulk transfer!");
   170 					self->iCaseStep = EBulkTransferOutWhenResume;
   185 					self->iCaseStep = EBulkTransferOutWhenResume;
   171 					self->SendEpTransferRequest();
   186 					self->SendEpTransferRequest();
   172 					}
   187 					}
   173 				else
   188 				else
   174 					{
   189 					{
   175 					RDebug::Printf("device resumed failed,<err %d> ",completionCode);
   190 					OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP05, "device resumed failed,<err %d> ",completionCode);
   176 					self->iCaseStep = EFailed;
   191 					self->iCaseStep = EFailed;
   177 					self->SendEpRequest();
   192 					self->SendEpRequest();
   178 					}
   193 					}
   179 				}
   194 				}
   180 
   195 
   182 
   197 
   183 			default:
   198 			default:
   184 				break;
   199 				break;
   185 			};
   200 			};
   186 
   201 
       
   202 		OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_1234_INTERFACE0RESUMEDL_EXIT, 0, KErrNone );
   187 		return KErrNone;
   203 		return KErrNone;
   188 		}
   204 		}
   189 
   205 
   190 	TInt CUT_PBASE_T_USBDI_1234::Interface1ResumedL(TAny* aPtr)
   206 	TInt CUT_PBASE_T_USBDI_1234::Interface1ResumedL(TAny* aPtr)
   191 		{
   207 		{
   192 		LOG_CFUNC
   208 		OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1234_INTERFACE1RESUMEDL_ENTRY, 0 );
   193 		RDebug::Printf("Interface 1 resumed");
   209 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP06, "Interface 1 resumed");
   194 		CUT_PBASE_T_USBDI_1234* self =
   210 		CUT_PBASE_T_USBDI_1234* self =
   195 				reinterpret_cast<CUT_PBASE_T_USBDI_1234*>(aPtr);
   211 				reinterpret_cast<CUT_PBASE_T_USBDI_1234*>(aPtr);
   196 		RDebug::Printf("watcher 1 iStatus=%d",
   212 		OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP07, "watcher 1 iStatus=%d",
   197 				self->iInterface1Watcher->CompletionCode());
   213 				self->iInterface1Watcher->CompletionCode());
   198 		self->iSuspendedI1 = EFalse;
   214 		self->iSuspendedI1 = EFalse;
       
   215 		OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_1234_INTERFACE1RESUMEDL_EXIT, 0, KErrNone );
   199 		return KErrNone;
   216 		return KErrNone;
   200 		}
   217 		}
   201 
   218 
   202 	TInt CUT_PBASE_T_USBDI_1234::Interface2ResumedL(TAny* aPtr)
   219 	TInt CUT_PBASE_T_USBDI_1234::Interface2ResumedL(TAny* aPtr)
   203 		{
   220 		{
   204 		LOG_CFUNC
   221 		OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1234_INTERFACE2RESUMEDL_ENTRY, 0 );
   205 		RDebug::Printf("Interface 2 resumed");
   222 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP08, "Interface 2 resumed");
   206 		CUT_PBASE_T_USBDI_1234* self =
   223 		CUT_PBASE_T_USBDI_1234* self =
   207 				reinterpret_cast<CUT_PBASE_T_USBDI_1234*>(aPtr);
   224 				reinterpret_cast<CUT_PBASE_T_USBDI_1234*>(aPtr);
   208 		RDebug::Printf("watcher 2 iStatus=%d",
   225 		OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP09, "watcher 2 iStatus=%d",
   209 				self->iInterface2Watcher->CompletionCode());
   226 				self->iInterface2Watcher->CompletionCode());
   210 		self->iSuspendedI2 = EFalse;
   227 		self->iSuspendedI2 = EFalse;
       
   228 		OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_1234_INTERFACE2RESUMEDL_EXIT, 0, KErrNone );
   211 		return KErrNone;
   229 		return KErrNone;
   212 		}
   230 		}
   213 
   231 
   214 	void CUT_PBASE_T_USBDI_1234::DeviceStateChangeL(
   232 	void CUT_PBASE_T_USBDI_1234::DeviceStateChangeL(
   215 			RUsbDevice::TDeviceState aPreviousState,
   233 			RUsbDevice::TDeviceState aPreviousState,
   216 			RUsbDevice::TDeviceState aNewState, TInt aCompletionCode)
   234 			RUsbDevice::TDeviceState aNewState, TInt aCompletionCode)
   217 		{
   235 		{
   218 		LOG_FUNC
   236 		OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1234_DEVICESTATECHANGEL_ENTRY, this );
   219 		Cancel();
   237 		Cancel();
   220 
   238 
   221 		RDebug::Printf(
   239 		RDebug::Printf(
   222 				"Device State change from %d to %d err=%d",
   240 				"Device State change from %d to %d err=%d",
   223 				aPreviousState, aNewState, aCompletionCode);
   241 				aPreviousState, aNewState, aCompletionCode);
       
   242 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_DEVICESTATECHANGEL_EXIT, this );
   224 		}
   243 		}
   225 
   244 
   226 	void CUT_PBASE_T_USBDI_1234::Ep0TransferCompleteL(TInt aCompletionCode)
   245 	void CUT_PBASE_T_USBDI_1234::Ep0TransferCompleteL(TInt aCompletionCode)
   227 		{
   246 		{
   228 		LOG_FUNC
   247         OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1234_EP0TRANSFERCOMPLETEL_ENTRY, this );
   229 
   248 
   230 		RDebug::Printf(
   249 		RDebug::Printf(
   231 				"Ep0TransferCompleteL with aCompletionCode = %d",
   250 				"Ep0TransferCompleteL with aCompletionCode = %d",
   232 				aCompletionCode);
   251 				aCompletionCode);
   233 
   252 
   234 		if (aCompletionCode != KErrNone)
   253 		if (aCompletionCode != KErrNone)
   235 			{
   254 			{
   236 			if (iCaseStep == EFailed)
   255 			if (iCaseStep == EFailed)
   237 				{// ignore error, and catch the TestFailed method called further down.
   256 				{// ignore error, and catch the TestFailed method called further down.
   238 				RDebug::Printf("***Failure sending FAIL message to client on endpoint 0***");
   257 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP10, "***Failure sending FAIL message to client on endpoint 0***");
   239 				}
   258 				}
   240 			else
   259 			else
   241 				{
   260 				{
   242 				TBuf<256> msg;
   261 				TBuf<256> msg;
   243 				msg.Format(_L("<Error %d> Transfer to control endpoint 0 was not successful"),aCompletionCode);
   262 				msg.Format(_L("<Error %d> Transfer to control endpoint 0 was not successful"),aCompletionCode);
   244 				RDebug::Print(msg);
   263 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP11, msg);
   245 				iCaseStep = EFailed;
   264 				iCaseStep = EFailed;
   246 				TTestCaseFailed request(aCompletionCode, msg);
   265 				TTestCaseFailed request(aCompletionCode, msg);
   247 				iControlEp0->SendRequest(request, this);
   266 				iControlEp0->SendRequest(request, this);
       
   267 				OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_EP0TRANSFERCOMPLETEL_EXIT, this );
   248 				return;
   268 				return;
   249 				}
   269 				}
   250 			}
   270 			}
   251 
   271 
   252 		switch (iCaseStep)
   272 		switch (iCaseStep)
   260 			case EFailed:
   280 			case EFailed:
   261 				TestFailed(KErrCompletion);
   281 				TestFailed(KErrCompletion);
   262 				break;
   282 				break;
   263 
   283 
   264 			case EBulkTransferOutWhenResume:
   284 			case EBulkTransferOutWhenResume:
   265 				RDebug::Printf("Try to send data");
   285 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP12, "Try to send data");
   266 				iOutTransfer[0]->TransferOut(KLiteralEnglish8().Mid(0, KHostNumWriteBytes1), EFalse);
   286 				iOutTransfer[0]->TransferOut(KLiteralEnglish8().Mid(0, KHostNumWriteBytes1), EFalse);
   267 				iOutTransfer[1]->TransferOut(KLiteralEnglish8().Mid(KHostNumWriteBytes1, KHostNumWriteBytes2), EFalse);
   287 				iOutTransfer[1]->TransferOut(KLiteralEnglish8().Mid(KHostNumWriteBytes1, KHostNumWriteBytes2), EFalse);
   268 				iOutTransfer[2]->TransferOut(KLiteralEnglish8().Mid(KHostNumWriteBytes1+KHostNumWriteBytes2,
   288 				iOutTransfer[2]->TransferOut(KLiteralEnglish8().Mid(KHostNumWriteBytes1+KHostNumWriteBytes2,
   269 						KHostNumWriteBytes3), ETrue); //do not suppress ZLP on this last one  (though should be irrelevant here)    
   289 						KHostNumWriteBytes3), ETrue); //do not suppress ZLP on this last one  (though should be irrelevant here)    
   270 				break;
   290 				break;
   271 
   291 
   272 			case EValidBulkTransfeOut:
   292 			case EValidBulkTransfeOut:
   273 				RDebug::Printf("Try to receive data");
   293 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP13, "Try to receive data");
   274 				iInTransfer[0]->TransferIn(KHostNumReadBytes1);
   294 				iInTransfer[0]->TransferIn(KHostNumReadBytes1);
   275 				iInTransfer[1]->TransferIn(KHostNumReadBytes2);
   295 				iInTransfer[1]->TransferIn(KHostNumReadBytes2);
   276 				iInTransfer[2]->TransferIn(KHostNumReadBytes3);
   296 				iInTransfer[2]->TransferIn(KHostNumReadBytes3);
   277 				break;
   297 				break;
   278 
   298 
   279 			default:
   299 			default:
   280 				RDebug::Printf("<Error> Unknown test step");
   300 				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP14, "<Error> Unknown test step");
   281 				TestFailed(KErrUnknown);
   301 				TestFailed(KErrUnknown);
   282 				break;
   302 				break;
   283 			}
   303 			}
       
   304 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_EP0TRANSFERCOMPLETEL_EXIT_DUP01, this );
   284 		}
   305 		}
   285 
   306 
   286 	void CUT_PBASE_T_USBDI_1234::TransferCompleteL(TInt aTransferId,
   307 	void CUT_PBASE_T_USBDI_1234::TransferCompleteL(TInt aTransferId,
   287 			TInt aCompletionCode)
   308 			TInt aCompletionCode)
   288 		{
   309 		{
   289 		LOG_FUNC
   310 		OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1234_TRANSFERCOMPLETEL_ENTRY, this );
   290 		Cancel();
   311 		Cancel();
   291 
   312 
   292 		TInt err(KErrNone);
   313 		TInt err(KErrNone);
   293 		TBuf<256> msg;
   314 		TBuf<256> msg;
   294 		RDebug::Printf("Transfer completed (id=%d), aCompletionCode = %d",
   315 		OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP15, "Transfer completed (id=%d), aCompletionCode = %d",
   295 				aTransferId, aCompletionCode);
   316 				aTransferId, aCompletionCode);
   296 
   317 
   297 		switch (iCaseStep)
   318 		switch (iCaseStep)
   298 			{
   319 			{
   299 			case EBulkTransferOutWhenResume:
   320 			case EBulkTransferOutWhenResume:
   308 					{
   329 					{
   309 					case KBulkTransferOutId0:
   330 					case KBulkTransferOutId0:
   310 					case KBulkTransferOutId1:
   331 					case KBulkTransferOutId1:
   311 					case KBulkTransferOutId2:
   332 					case KBulkTransferOutId2:
   312 						iTransferComplete |= aTransferId;
   333 						iTransferComplete |= aTransferId;
   313 						RDebug::Printf("Transfer %d completed", aTransferId);
   334 						OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP16, "Transfer %d completed", aTransferId);
   314 						break; // switch(aTransferId)
   335 						break; // switch(aTransferId)
   315 
   336 
   316 					default:
   337 					default:
   317 						iTransferComplete = 0; //reset
   338 						iTransferComplete = 0; //reset
   318 						err = KUnexpectedTransferID;
   339 						err = KUnexpectedTransferID;
   390 						err = KErrCompletion; //indicates data validation failure
   411 						err = KErrCompletion; //indicates data validation failure
   391 						break; // switch(iCaseStep)
   412 						break; // switch(iCaseStep)
   392 						}
   413 						}
   393 
   414 
   394 					// Comparison is a match
   415 					// Comparison is a match
   395 					RDebug::Printf("Comparison for IN transfer is a match");
   416 					OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP17, "Comparison for IN transfer is a match");
   396 					iCaseStep = EPassed;
   417 					iCaseStep = EPassed;
   397 					TTestCasePassed request;
   418 					TTestCasePassed request;
   398 					iControlEp0->SendRequest(request, this);
   419 					iControlEp0->SendRequest(request, this);
   399 					iTransferComplete = 0; //reset
   420 					iTransferComplete = 0; //reset
   400 					}
   421 					}
   412 			msg.Format(_L("<Error %d> Bulk transfer IN data received does not match Bulk Transfer OUT data"), err);
   433 			msg.Format(_L("<Error %d> Bulk transfer IN data received does not match Bulk Transfer OUT data"), err);
   413 			}
   434 			}
   414 
   435 
   415 		if (err!=KErrNone)
   436 		if (err!=KErrNone)
   416 			{
   437 			{
   417 			RDebug::Print(msg);
   438 			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP18, msg);
   418 			iCaseStep = EFailed;
   439 			iCaseStep = EFailed;
   419 			TTestCaseFailed request(err, msg);
   440 			TTestCaseFailed request(err, msg);
   420 			iControlEp0->SendRequest(request, this);
   441 			iControlEp0->SendRequest(request, this);
   421 			}
   442 			}
   422 
   443 
       
   444 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_TRANSFERCOMPLETEL_EXIT, this );
   423 		}
   445 		}
   424 
   446 
   425 	void CUT_PBASE_T_USBDI_1234::TrySuspendDeviceByInterfaces()
   447 	void CUT_PBASE_T_USBDI_1234::TrySuspendDeviceByInterfaces()
   426 		{
   448 		{
       
   449 		OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1234_TRYSUSPENDDEVICEBYINTERFACES_ENTRY, this );
   427 		// Suspend interface 0
   450 		// Suspend interface 0
   428 		RDebug::Printf("Suspending interface 0");
   451 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP19, "Suspending interface 0");
   429 		iInterface0Watcher->SuspendAndWatch();
   452 		iInterface0Watcher->SuspendAndWatch();
   430 		iSuspendedI0 = ETrue;
   453 		iSuspendedI0 = ETrue;
   431 
   454 
   432 		// Suspend interface 1
   455 		// Suspend interface 1
   433 		RDebug::Printf("Suspending interface 1");
   456 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP20, "Suspending interface 1");
   434 		iInterface1Watcher->SuspendAndWatch();
   457 		iInterface1Watcher->SuspendAndWatch();
   435 		iSuspendedI1 = ETrue;
   458 		iSuspendedI1 = ETrue;
   436 
   459 
   437 		// Suspend interface 2
   460 		// Suspend interface 2
   438 		RDebug::Printf("Suspending interface 2");
   461 		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP21, "Suspending interface 2");
   439 		iInterface2Watcher->SuspendAndWatch();
   462 		iInterface2Watcher->SuspendAndWatch();
   440 		iSuspendedI2 = ETrue;
   463 		iSuspendedI2 = ETrue;
   441 
   464 
   442 		TimeoutIn(10); // Give 10 seconds for device to suspend
   465 		TimeoutIn(10); // Give 10 seconds for device to suspend
   443 
   466 
   444 		// scenario2 : device could do the bulk transfer must wait device really resumed. 
   467 		// scenario2 : device could do the bulk transfer must wait device really resumed. 
   445 		iUsbInterface0.CancelPermitSuspend();
   468 		iUsbInterface0.CancelPermitSuspend();
   446 
   469 
   447 		iCaseStep = EValidateResumebyInterface;
   470 		iCaseStep = EValidateResumebyInterface;
   448 
   471 
       
   472 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_TRYSUSPENDDEVICEBYINTERFACES_EXIT, this );
   449 		}
   473 		}
   450 
   474 
   451 	void CUT_PBASE_T_USBDI_1234::SendEpRequest()
   475 	void CUT_PBASE_T_USBDI_1234::SendEpRequest()
   452 		{
   476 		{
       
   477 		OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1234_SENDEPREQUEST_ENTRY, this );
   453 		TTestCasePassed request;
   478 		TTestCasePassed request;
   454 		iControlEp0->SendRequest(request, this);
   479 		iControlEp0->SendRequest(request, this);
       
   480 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_SENDEPREQUEST_EXIT, this );
   455 		}
   481 		}
   456 	void CUT_PBASE_T_USBDI_1234::SendEpTransferRequest()
   482 	void CUT_PBASE_T_USBDI_1234::SendEpTransferRequest()
   457 		{
   483 		{
       
   484 		OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1234_SENDEPTRANSFERREQUEST_ENTRY, this );
   458 		TEndpointReadRequest request(1, 1, KBulkTransferSize);// EP1 means endpoint index 1 not the actual endpoint number
   485 		TEndpointReadRequest request(1, 1, KBulkTransferSize);// EP1 means endpoint index 1 not the actual endpoint number
   459 		iControlEp0->SendRequest(request, this);
   486 		iControlEp0->SendRequest(request, this);
       
   487 		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_SENDEPTRANSFERREQUEST_EXIT, this );
   460 		}
   488 		}
   461 
   489 
   462 	}//end namespace
   490 	}//end namespace
   463 
   491 
   464 
   492