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