os/kernelhwsrv/kerneltest/e32test/usbho/t_usbdi/src/PBASE-T_USBDI-0498.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/usbho/t_usbdi/src/PBASE-T_USBDI-0498.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,553 @@
     1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// @file PBASE-T_USBDI-0498.cpp
    1.18 +// @internalComponent
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#include "PBASE-T_USBDI-0498.h"
    1.23 +#include "testpolicy.h"
    1.24 +#include "modelleddevices.h"
    1.25 +#include "testliterals.h"
    1.26 +
    1.27 +
    1.28 + 
    1.29 +
    1.30 +namespace NUnitTesting_USBDI
    1.31 +	{
    1.32 +const TInt KBulkMaxTransferSize = 40000;
    1.33 +const TUint KHostNumWriteBytes1 = 32000;
    1.34 +const TUint KHostNumWriteBytes2 = 32000;
    1.35 +const TInt KDeviceNumReadBytes = 64000;
    1.36 +const TInt KDeviceNumWriteBytes = 64000;
    1.37 +const TUint KHostNumReadBytes1 = 32000;
    1.38 +const TUint KHostNumReadBytes2 = 32001; //allow or ZLP
    1.39 +
    1.40 +
    1.41 +//Make these single bit values ... 
    1.42 +// ... so that their completion can be easily recorded in a bit mask!
    1.43 +const TUint32 KIfc1BulkTransferInId1  = 1<<0;
    1.44 +const TUint32 KIfc1BulkTransferInId2  = 1<<1;
    1.45 +const TUint32 KIfc2BulkTransferInId1  = 1<<2;
    1.46 +const TUint32 KIfc2BulkTransferInId2  = 1<<3;
    1.47 +const TUint32 KIfc1BulkTransferInIdMask = KIfc1BulkTransferInId1 | KIfc1BulkTransferInId2; 
    1.48 +const TUint32 KIfc2BulkTransferInIdMask = KIfc2BulkTransferInId1 | KIfc2BulkTransferInId2;
    1.49 +const TUint32 KBulkTransferInIdMask = KIfc1BulkTransferInIdMask | KIfc2BulkTransferInIdMask;
    1.50 +const TUint32 KIfc1BulkTransferOutId1 = 1<<4;
    1.51 +const TUint32 KIfc1BulkTransferOutId2 = 1<<5;
    1.52 +const TUint32 KIfc2BulkTransferOutId1 = 1<<6;
    1.53 +const TUint32 KIfc2BulkTransferOutId2 = 1<<7;
    1.54 +const TUint32 KIfc1BulkTransferOutIdMask = KIfc1BulkTransferOutId1 | KIfc1BulkTransferOutId2; 
    1.55 +const TUint32 KIfc2BulkTransferOutIdMask = KIfc2BulkTransferOutId1 | KIfc2BulkTransferOutId2;
    1.56 +const TUint32 KBulkTransferOutIdMask = KIfc1BulkTransferOutIdMask | KIfc2BulkTransferOutIdMask;
    1.57 +const TUint32 KBulkTransferIdMask = KBulkTransferInIdMask | KBulkTransferOutIdMask;
    1.58 +
    1.59 +const TInt KUnexpectedTransferID = -101;
    1.60 +const TInt KUndefinedStep	 = -102;
    1.61 +
    1.62 +const TInt KMaxTimeDiffPercentage = 25;
    1.63 +
    1.64 +
    1.65 +
    1.66 +_LIT(KTestCaseId,"PBASE-T_USBDI-0498");
    1.67 +const TFunctorTestCase<CUT_PBASE_T_USBDI_0498,TBool> CUT_PBASE_T_USBDI_0498::iFunctor(KTestCaseId);	
    1.68 +
    1.69 +CUT_PBASE_T_USBDI_0498* CUT_PBASE_T_USBDI_0498::NewL(TBool aHostRole)
    1.70 +	{
    1.71 +	CUT_PBASE_T_USBDI_0498* self = new (ELeave) CUT_PBASE_T_USBDI_0498(aHostRole);
    1.72 +	CleanupStack::PushL(self);
    1.73 +	self->ConstructL();
    1.74 +	CleanupStack::Pop(self);
    1.75 +	return self;
    1.76 +	}
    1.77 +	
    1.78 +
    1.79 +CUT_PBASE_T_USBDI_0498::CUT_PBASE_T_USBDI_0498(TBool aHostRole)
    1.80 +:	CBaseBulkTestCase(KTestCaseId,aHostRole),
    1.81 +	iCaseStep(EInProgress),
    1.82 +	iRequestDeviceValidationResultPtr(NULL,0)
    1.83 +	{
    1.84 +	} 
    1.85 +
    1.86 +
    1.87 +void CUT_PBASE_T_USBDI_0498::ConstructL()
    1.88 +	{
    1.89 +	BaseBulkConstructL();
    1.90 +
    1.91 +	iInBuffer = HBufC8::NewL(KTestBufferLength);
    1.92 +	RDebug::Printf("CUT_PBASE_T_USBDI_0491::ConstructL(): buffer created");
    1.93 +	}
    1.94 +
    1.95 +
    1.96 +CUT_PBASE_T_USBDI_0498::~CUT_PBASE_T_USBDI_0498()
    1.97 +/**
    1.98 +The transfer objects have test specific names - so perform transfer specific clean up here.
    1.99 +*/
   1.100 +	{
   1.101 +	LOG_FUNC
   1.102 +	
   1.103 +	Cancel();
   1.104 +
   1.105 +	//Do this before deleting the transfer objects
   1.106 +	CloseInterfaceAndPipes();
   1.107 +	
   1.108 +	TUint8 count;
   1.109 +	for(count=0;count<KNumOutTransfersPerInterface;count++)
   1.110 +		{
   1.111 +		delete iIfc1OutTransfer[count];
   1.112 +		iIfc1OutTransfer[count] = NULL;
   1.113 +		delete iIfc2OutTransfer[count];
   1.114 +		iIfc2OutTransfer[count] = NULL;
   1.115 +		}
   1.116 +	for(count=0;count<KNumInTransfersPerInterface;count++)
   1.117 +		{
   1.118 +		delete iIfc1InTransfer[count];
   1.119 +		iIfc1InTransfer[count] = NULL;
   1.120 +		delete iIfc2InTransfer[count];
   1.121 +		iIfc2InTransfer[count] = NULL;
   1.122 +		}
   1.123 +	}
   1.124 +	
   1.125 +	
   1.126 +void CUT_PBASE_T_USBDI_0498::Ep0TransferCompleteL(TInt aCompletionCode)
   1.127 +	{
   1.128 +	LOG_FUNC
   1.129 +	
   1.130 +	RDebug::Printf("Ep0TransferCompleteL with aCompletionCode = %d",aCompletionCode);
   1.131 +	
   1.132 +	if(aCompletionCode != KErrNone)
   1.133 +		{
   1.134 +		if(iCaseStep == EFailed)
   1.135 +			{// ignore error, nad catch the TestFailed method called further down.
   1.136 +			RDebug::Printf("***Failure sending FAIL message to client on endpoint 0***");
   1.137 +			}
   1.138 +		else
   1.139 +			{
   1.140 +			TBuf<256> msg;
   1.141 +			msg.Format(_L("<Error %d> Transfer to control endpoint 0 was not successful"),aCompletionCode);
   1.142 +			RDebug::Print(msg);
   1.143 +			iCaseStep = EFailed;
   1.144 +			TTestCaseFailed request(aCompletionCode,msg);
   1.145 +			iControlEp0->SendRequest(request,this);
   1.146 +			return;
   1.147 +			}
   1.148 +		}
   1.149 +	
   1.150 +	switch(iCaseStep)
   1.151 +		{
   1.152 +		// Test case passed
   1.153 +		case EPassed:
   1.154 +			TestPassed();
   1.155 +			break;
   1.156 +		
   1.157 +		// Test case failed	
   1.158 +		case EFailed:
   1.159 +			TestFailed(KErrCompletion);
   1.160 +			break;
   1.161 +		
   1.162 +		case ERequestDeviceIFC1Read:
   1.163 +			{
   1.164 +			RDebug::Printf("Asking client for 'Read' on interface 2");
   1.165 +			iCaseStep = ERequestDeviceIFC2Read;	
   1.166 +			TEndpointReadRequest request(2,1,KDeviceNumReadBytes);// EP1 means endpoint index 1 not the actual endpoint number
   1.167 +			iControlEp0->SendRequest(request,this);
   1.168 +			}
   1.169 +			break;
   1.170 +			
   1.171 +		case ERequestDeviceIFC2Read:
   1.172 +			{
   1.173 +			RDebug::Printf("Asking client to 'Write' on interface 1");
   1.174 +			iCaseStep = ERequestDeviceIFC1Write;	
   1.175 +			TEndpointPatternWriteRequest request(1,1,KLiteralFrench4(),KDeviceNumWriteBytes);
   1.176 +			iControlEp0->SendRequest(request,this);
   1.177 +			}
   1.178 +			break;
   1.179 +			
   1.180 +		case ERequestDeviceIFC1Write:
   1.181 +			{
   1.182 +			RDebug::Printf("Asking client to 'Write' on interface 2");
   1.183 +			iCaseStep = ERequestDeviceIFC2Write;	
   1.184 +			TEndpointPatternWriteRequest request(2,1,KLiteralEnglish2(),KDeviceNumWriteBytes);
   1.185 +			iControlEp0->SendRequest(request,this);
   1.186 +			}
   1.187 +			break;
   1.188 +			
   1.189 +		case ERequestDeviceIFC2Write:
   1.190 +			{
   1.191 +			RDebug::Printf("Try to perform ALL transfers on BOTH interfaces");
   1.192 +	
   1.193 +			iCaseStep = ETransfer;	
   1.194 +	
   1.195 +			iStartTime[0].HomeTime();
   1.196 +			iStartTime[1].HomeTime();
   1.197 +			iStartTime[2].HomeTime();
   1.198 +			iStartTime[3].HomeTime();
   1.199 +	
   1.200 +			iIfc1OutTransfer[0]->TransferOut(KLiteralFrench4(), KHostNumWriteBytes1, EFalse);
   1.201 +			iIfc1OutTransfer[1]->TransferOut(KLiteralFrench4(), KHostNumWriteBytes1, KHostNumWriteBytes2, EFalse);
   1.202 +			iIfc2OutTransfer[0]->TransferOut(KLiteralEnglish2(), KHostNumWriteBytes1, EFalse);
   1.203 +			iIfc2OutTransfer[1]->TransferOut(KLiteralEnglish2(), KHostNumWriteBytes1, KHostNumWriteBytes2, EFalse);
   1.204 +	
   1.205 +			iIfc1InTransfer[0]->TransferIn(KHostNumReadBytes1);
   1.206 +			iIfc1InTransfer[1]->TransferIn(KHostNumReadBytes2);
   1.207 +			iIfc2InTransfer[0]->TransferIn(KHostNumReadBytes1);
   1.208 +			iIfc2InTransfer[1]->TransferIn(KHostNumReadBytes2);
   1.209 +			}
   1.210 +			break;
   1.211 +			
   1.212 +		case ERequestDeviceValidateIFC1:
   1.213 +			{
   1.214 +			iCaseStep = ERequestDeviceValidationResultIFC1;
   1.215 +			RDebug::Printf("Interface 1: Request Client Validation Result");
   1.216 +			iRequestDeviceValidationResultPtr.Set(iInBuffer->Des());
   1.217 +			iRequestDeviceValidationResultPtr.Zero(); //reset
   1.218 +			iRequestDeviceValidationResultPtr.SetLength(KPassFailStringLength);
   1.219 +			TInterfaceGetPayloadRequest request(1,iRequestDeviceValidationResultPtr);
   1.220 +			iControlEp0->SendRequest(request,this);
   1.221 +			}
   1.222 +			break;
   1.223 +		
   1.224 +		case ERequestDeviceValidationResultIFC1:
   1.225 +			{
   1.226 +			RDebug::Printf("Interface 1: Client Validation Result string ...");
   1.227 +			RDebug::RawPrint(*iInBuffer);
   1.228 +			RDebug::Printf("\n");
   1.229 +			TPtr8 ptr(iInBuffer->Des());
   1.230 +			if(ptr.Compare(KClientPassString) == 0)
   1.231 +				{
   1.232 +				RDebug::Printf("Client Validation Interface 1 Result is a PASS");
   1.233 +				RDebug::Printf("Now performing Client Validation for Interface 2");
   1.234 +				iCaseStep = ERequestDeviceValidateIFC2;
   1.235 +				TEndpointStringValidationRequest request(2,1,KLiteralEnglish2(),KDeviceNumReadBytes);
   1.236 +				iControlEp0->SendRequest(request,this);
   1.237 +				}
   1.238 +			else
   1.239 +				{
   1.240 +				TBuf<256> msg;
   1.241 +				msg.Format(_L("<Error> Bulk data VALIDATION check was NOT successful"));
   1.242 +				RDebug::Print(msg);
   1.243 +				iCaseStep = EFailed;
   1.244 +				TTestCaseFailed request(KErrCorrupt,msg);
   1.245 +				iControlEp0->SendRequest(request,this);
   1.246 +				}
   1.247 +			}
   1.248 +			break;
   1.249 +			
   1.250 +		case ERequestDeviceValidateIFC2:
   1.251 +			{
   1.252 +			iCaseStep = ERequestDeviceValidationResultIFC2;
   1.253 +			RDebug::Printf("Interface 2: Request Client Validation Result");
   1.254 +			iRequestDeviceValidationResultPtr.Set(iInBuffer->Des());
   1.255 +			iRequestDeviceValidationResultPtr.Zero(); //reset
   1.256 +			iRequestDeviceValidationResultPtr.SetLength(KPassFailStringLength);
   1.257 +			TInterfaceGetPayloadRequest request(2,iRequestDeviceValidationResultPtr);
   1.258 +			iControlEp0->SendRequest(request,this);
   1.259 +			}
   1.260 +			break;
   1.261 +		
   1.262 +		case ERequestDeviceValidationResultIFC2:
   1.263 +			{
   1.264 +			RDebug::Printf("Interface 1: Client Validation Result string ...");
   1.265 +			RDebug::RawPrint(*iInBuffer);
   1.266 +			RDebug::Printf("\n");
   1.267 +			TPtr8 ptr(iInBuffer->Des());
   1.268 +			if(ptr.Compare(KClientPassString) == 0)
   1.269 +				{
   1.270 +				RDebug::Printf("Client Validation Interface 2 Result is a PASS");
   1.271 +				RDebug::Printf("This is the FINAL check - the whole test has a PASSED");
   1.272 +				iCaseStep = EPassed;
   1.273 +				TTestCasePassed request;
   1.274 +				iControlEp0->SendRequest(request,this);
   1.275 +				}
   1.276 +			else
   1.277 +				{
   1.278 +				TBuf<256> msg;
   1.279 +				msg.Format(_L("<Error> Bulk data VALIDATION check was NOT successful"));
   1.280 +				RDebug::Print(msg);
   1.281 +				iCaseStep = EFailed;
   1.282 +				TTestCaseFailed request(KErrCorrupt,msg);
   1.283 +				iControlEp0->SendRequest(request,this);
   1.284 +				}
   1.285 +			}
   1.286 +			break;
   1.287 +	
   1.288 +		default:
   1.289 +			RDebug::Printf("<Error> Unknown test step");
   1.290 +			TestFailed(KErrUnknown);
   1.291 +			break;
   1.292 +		}
   1.293 +	}
   1.294 +	
   1.295 +void CUT_PBASE_T_USBDI_0498::TransferCompleteL(TInt aTransferId,TInt aCompletionCode)
   1.296 +	{
   1.297 +	LOG_FUNC
   1.298 +	Cancel();
   1.299 +	
   1.300 +	TInt err(KErrNone);
   1.301 +	TBuf<256> msg;
   1.302 +	RDebug::Printf("Transfer completed (id=%d), aCompletionCode = %d, test step = %d",aTransferId, aCompletionCode, iCaseStep);
   1.303 +
   1.304 +
   1.305 +	switch(iCaseStep)
   1.306 +		{
   1.307 +		case ETransfer:
   1.308 +			if(aCompletionCode != KErrNone)
   1.309 +				{
   1.310 +				iIfc1OutTransfer[0]->Cancel();
   1.311 +				iIfc1OutTransfer[1]->Cancel();
   1.312 +				iIfc2OutTransfer[0]->Cancel();
   1.313 +				iIfc2OutTransfer[1]->Cancel();
   1.314 +				iIfc1InTransfer[0]->Cancel();
   1.315 +				iIfc1InTransfer[1]->Cancel();
   1.316 +				iIfc2InTransfer[0]->Cancel();
   1.317 +				iIfc2InTransfer[1]->Cancel();
   1.318 +				err = KErrCorrupt;
   1.319 +				msg.Format(_L("<Error %d> The transfer completed with an error."), aCompletionCode);
   1.320 +				break; //switch(iCaseStep)
   1.321 +				}
   1.322 +	
   1.323 +			switch(aTransferId)
   1.324 +				{
   1.325 +				case KIfc1BulkTransferOutId1:
   1.326 +				case KIfc1BulkTransferOutId2:
   1.327 +				case KIfc2BulkTransferOutId1:
   1.328 +				case KIfc2BulkTransferOutId2:
   1.329 +					iTransferComplete |= aTransferId;
   1.330 +					RDebug::Printf("Transfer OUT %d completed (Transfer Completion Aggregation Mask 0x%x)", aTransferId, iTransferComplete);
   1.331 +					break; //switch(aTransferId)
   1.332 +
   1.333 +				case KIfc1BulkTransferInId1:
   1.334 +				case KIfc1BulkTransferInId2:
   1.335 +				case KIfc2BulkTransferInId1:
   1.336 +				case KIfc2BulkTransferInId2:
   1.337 +					iTransferComplete |= aTransferId;
   1.338 +					RDebug::Printf("Transfer OUT %d completed (Transfer Completion Aggregation Mask 0x%x)", aTransferId, iTransferComplete);
   1.339 +					break; //switch(aTransferId)
   1.340 +
   1.341 +				default:
   1.342 +					iTransferComplete = 0; //reset
   1.343 +					err = KUnexpectedTransferID;
   1.344 +					msg.Format(_L("<Error %d> Unexpected transfer ID, GOT %d, (wanted one of:- %d, %d, %d, %d, %d, %d, %d, or%d)"),
   1.345 +							       err, aTransferId,
   1.346 +							       KIfc1BulkTransferInId1, 
   1.347 +							       KIfc1BulkTransferInId2, 
   1.348 +							       KIfc2BulkTransferInId1, 
   1.349 +							       KIfc2BulkTransferInId2, 
   1.350 +							       KIfc1BulkTransferOutId1, 
   1.351 +							       KIfc1BulkTransferOutId2, 
   1.352 +							       KIfc2BulkTransferOutId1, 
   1.353 +							       KIfc2BulkTransferOutId2
   1.354 +							       );
   1.355 +					break; //switch(aTransferId)
   1.356 +				}
   1.357 +			
   1.358 +			// Transfer Out Response
   1.359 +			if(err==KErrNone && iTimeElapsed[0] == 0 && (iTransferComplete & KIfc1BulkTransferOutIdMask) == KIfc1BulkTransferOutIdMask) 
   1.360 +				//Record time elapsed for Interface 1 if not yet recorded.
   1.361 +				{
   1.362 +				RecordTime(0);
   1.363 +				}
   1.364 +			if(err==KErrNone && iTimeElapsed[1] == 0 && (iTransferComplete & KIfc2BulkTransferOutIdMask) == KIfc2BulkTransferOutIdMask)
   1.365 +				//Record time elapsed for Interface 2 if not yet recorded.
   1.366 +				{
   1.367 +				RecordTime(1);
   1.368 +				}
   1.369 +			if(err==KErrNone && (iTransferComplete & KBulkTransferOutIdMask) == KBulkTransferOutIdMask)
   1.370 +				{
   1.371 +				RDebug::Printf("All OUT Transfers Completed Successfully: Transfer Completion Aggregation Mask 0x%x", iTransferComplete);
   1.372 +				//Leave validation to the point at which all transfers have completed.
   1.373 +				}
   1.374 +	
   1.375 +			// Transfer In Response
   1.376 +			if(err==KErrNone && iTimeElapsed[2] == 0 && (iTransferComplete & KIfc1BulkTransferInIdMask) == KIfc1BulkTransferInIdMask)
   1.377 +				//Record time elapsed for Interface 1 if not yet recorded.
   1.378 +				{
   1.379 +				RecordTime(2);
   1.380 +				}
   1.381 +			if(err==KErrNone && iTimeElapsed[3] == 0 && (iTransferComplete & KIfc2BulkTransferInIdMask) == KIfc2BulkTransferInIdMask) 
   1.382 +				//Record time elapsed for Interface 2 if not yet recorded.
   1.383 +				{
   1.384 +				RecordTime(3);
   1.385 +				}
   1.386 +			if(err==KErrNone && (iTransferComplete & KBulkTransferInIdMask) == KBulkTransferInIdMask)
   1.387 +				{
   1.388 +				// ok, compare data rcvd now
   1.389 +				RDebug::Printf("All IN Transfers Completed Successfully: Transfer Completion Aggregation Mask 0x%x", iTransferComplete);
   1.390 +	
   1.391 +				TPtrC8 data1(iIfc1InTransfer[0]->DataPolled());	
   1.392 +				TPtrC8 data2(iIfc1InTransfer[1]->DataPolled());		
   1.393 +				TPtrC8 data3(iIfc2InTransfer[0]->DataPolled());		
   1.394 +				TPtrC8 data4(iIfc2InTransfer[1]->DataPolled());		
   1.395 +				//Validate first transfer on Interface 1 for number of bytes originally written.
   1.396 +				if(ValidateData(data1, KLiteralFrench4(), KHostNumWriteBytes1) == EFalse)
   1.397 +					{
   1.398 +					RDebug::Printf("Validation failure 1st transfer, Interface 1");
   1.399 +					err = KErrCompletion; //indicates data validation failure
   1.400 +					break; //switch(iCaseStep)
   1.401 +					}
   1.402 +
   1.403 +				//Validate second transfer on Interface 1 for number of bytes originally written.
   1.404 +				if(ValidateData(data2, KLiteralFrench4(), KHostNumWriteBytes1, KHostNumWriteBytes2) == EFalse)
   1.405 +					{
   1.406 +					RDebug::Printf("Validation failure 2nd transfer, Interface 1");
   1.407 +					err = KErrCompletion; //indicates data validation failure
   1.408 +					break; //switch(iCaseStep)
   1.409 +					}
   1.410 +				
   1.411 +				//Validate first transfer on Interface 2 for number of bytes originally written.
   1.412 +				if(ValidateData(data3, KLiteralEnglish2(), KHostNumWriteBytes1) == EFalse)
   1.413 +					{
   1.414 +					RDebug::Printf("Validation failure 1st transfer, Interface 2");
   1.415 +					err = KErrCompletion; //indicates data validation failure
   1.416 +					break; //switch(iCaseStep)
   1.417 +					}
   1.418 +				
   1.419 +				//Validate second transfer on Interface 2 for number of bytes originally written.
   1.420 +				if(ValidateData(data4, KLiteralEnglish2(), KHostNumWriteBytes1, KHostNumWriteBytes2) == EFalse)
   1.421 +					{
   1.422 +					RDebug::Printf("Validation failure 2nd transfer, Interface 2");
   1.423 +					err = KErrCompletion; //indicates data validation failure
   1.424 +					break; //switch(iCaseStep)
   1.425 +					}
   1.426 +				
   1.427 +				// Comparison is a match
   1.428 +				RDebug::Printf("Comparison for IN transfer is a match");
   1.429 +				}
   1.430 +			break; //switch(iCaseStep)
   1.431 +
   1.432 +		default:
   1.433 +			err = KUndefinedStep;
   1.434 +			msg.Format(_L("<Error %d> Undefined case step %d reached"),KUndefinedStep, iCaseStep);
   1.435 +			break; //switch(iCaseStep)
   1.436 +		}
   1.437 +
   1.438 +	if(err == KErrNone && iTransferComplete == KBulkTransferIdMask)
   1.439 +	/*
   1.440 +	Transfers all complete - now ask device to validate first interface's transfer OUT
   1.441 +	*/
   1.442 +		{
   1.443 +		RDebug::Printf("Checking all times against each other");
   1.444 +		err = CheckTimes(0, 1, KMaxTimeDiffPercentage);
   1.445 +		err = err?err:CheckTimes(0, 2, KMaxTimeDiffPercentage);
   1.446 +		err = err?err:CheckTimes(0, 3, KMaxTimeDiffPercentage);
   1.447 +		err = err?err:CheckTimes(1, 2, KMaxTimeDiffPercentage);
   1.448 +		err = err?err:CheckTimes(1, 3, KMaxTimeDiffPercentage);
   1.449 +		err = err?err:CheckTimes(2, 3, KMaxTimeDiffPercentage);
   1.450 +		ResetTimes(0);
   1.451 +		ResetTimes(1);
   1.452 +		ResetTimes(2);
   1.453 +		ResetTimes(3);
   1.454 +		
   1.455 +		if(err==KErrNone)
   1.456 +			{
   1.457 +			RDebug::Printf("Asking client for 'Validate' data written on interface 1");
   1.458 +			iCaseStep = ERequestDeviceValidateIFC1;
   1.459 +			TEndpointStringValidationRequest request(1,1,KLiteralFrench4(),KDeviceNumReadBytes);
   1.460 +			iControlEp0->SendRequest(request,this);
   1.461 +			}
   1.462 +		}
   1.463 +
   1.464 +	if(err == KErrCompletion)
   1.465 +		//indicates data validation failure
   1.466 +		{
   1.467 +		msg.Format(_L("<Error %d> Bulk transfer IN data received does not match Bulk Transfer OUT data"), err);
   1.468 +		}
   1.469 +
   1.470 +	if(err == KErrTooBig)
   1.471 +		//indicates timing validation failure
   1.472 +		{
   1.473 +		msg.Format(_L("<Error %d> Timer comparison showed too great a difference in transfer times between the two interfaces"), err);
   1.474 +		}
   1.475 +	
   1.476 +	if(err!=KErrNone)
   1.477 +		{	
   1.478 +		RDebug::Print(msg);
   1.479 +		iCaseStep = EFailed;
   1.480 +		TTestCaseFailed request(err,msg);
   1.481 +		return iControlEp0->SendRequest(request,this);
   1.482 +		}	
   1.483 +	}
   1.484 +	
   1.485 +void CUT_PBASE_T_USBDI_0498::DeviceInsertedL(TUint aDeviceHandle)
   1.486 +	{
   1.487 +	LOG_FUNC
   1.488 +	
   1.489 +	Cancel();
   1.490 +	RDebug::Printf("this - %08x", this);
   1.491 +	
   1.492 +	TBuf<256> msg;
   1.493 +	TInt err = KErrNone;
   1.494 +	if(BaseBulkDeviceInsertedL(aDeviceHandle, EFalse) == EDeviceConfigurationError)
   1.495 +		// Prepare for response from control transfer to client
   1.496 +		{
   1.497 +		err = KErrGeneral;
   1.498 +		msg.Format(_L("Base class DeviceInsertedL failed"));
   1.499 +		}
   1.500 +	else
   1.501 +		{
   1.502 +		if(SetUpInterfaceAndPipesL(aDeviceHandle, 2) == EDeviceConfigurationError)
   1.503 +			// Prepare for response from control transfer to client
   1.504 +			{
   1.505 +			err = KErrGeneral;
   1.506 +			msg.Format(_L("Base class SetUpInterfaceAndPipes for Interface 2 failed"));
   1.507 +			}
   1.508 +		else
   1.509 +			{
   1.510 +	
   1.511 +			iIfc1InTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,KBulkMaxTransferSize,*this,KIfc1BulkTransferInId1);
   1.512 +			iIfc1InTransfer[1] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,KBulkMaxTransferSize,*this,KIfc1BulkTransferInId2);
   1.513 +			iIfc1OutTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkMaxTransferSize,*this,KIfc1BulkTransferOutId1);
   1.514 +			iIfc1OutTransfer[1] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkMaxTransferSize,*this,KIfc1BulkTransferOutId2);
   1.515 +
   1.516 +			iIfc2InTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface2BulkIn,iUsbInterface2,KBulkMaxTransferSize,*this,KIfc2BulkTransferInId1);
   1.517 +			iIfc2InTransfer[1] = new (ELeave) CBulkTransfer(iTestPipeInterface2BulkIn,iUsbInterface2,KBulkMaxTransferSize,*this,KIfc2BulkTransferInId2);
   1.518 +			iIfc2OutTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface2BulkOut1,iUsbInterface2,KBulkMaxTransferSize,*this,KIfc2BulkTransferOutId1);
   1.519 +			iIfc2OutTransfer[1] = new (ELeave) CBulkTransfer(iTestPipeInterface2BulkOut1,iUsbInterface2,KBulkMaxTransferSize,*this,KIfc2BulkTransferOutId2);
   1.520 +			
   1.521 +			// Initialise the descriptors for transfer		
   1.522 +			RDebug::Printf("Initialising the transfer descriptors - interface 1");
   1.523 +			err = iUsbInterface1.InitialiseTransferDescriptors();
   1.524 +			if(err != KErrNone)
   1.525 +				{
   1.526 +				msg.Format(_L("<Error %d> Unable to initialise transfer descriptors (Interface 1)"),err);
   1.527 +				}
   1.528 +			else
   1.529 +				{
   1.530 +				// Initialise the descriptors for transfer		
   1.531 +				RDebug::Printf("Initialising the transfer descriptors (Interface 2)");
   1.532 +				err = iUsbInterface2.InitialiseTransferDescriptors();
   1.533 +				if(err != KErrNone)
   1.534 +					{
   1.535 +					msg.Format(_L("<Error %d> Unable to initialise transfer descriptors"),err);
   1.536 +					}
   1.537 +				}
   1.538 +			}
   1.539 +		}
   1.540 +	if(err != KErrNone)
   1.541 +		{
   1.542 +		RDebug::Print(msg);
   1.543 +		iCaseStep = EFailed;
   1.544 +		TTestCaseFailed request(err,msg);
   1.545 +		iControlEp0->SendRequest(request,this);
   1.546 +		}
   1.547 +	else
   1.548 +		{
   1.549 +		RDebug::Printf("Asking client for 'Read' on interface 1");
   1.550 +		iCaseStep = ERequestDeviceIFC1Read;	
   1.551 +		TEndpointReadRequest request(1,1,KDeviceNumReadBytes);// EP1 means endpoint index 1 not the actual endpoint number
   1.552 +		iControlEp0->SendRequest(request,this);
   1.553 +		}
   1.554 +	}
   1.555 +	
   1.556 +	} //end namespace