First public contribution.
1 #ifndef __BULK_BASE_TEST_CASE_H
2 #define __BULK_BASE_TEST_CASE_H
5 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
7 * This component and the accompanying materials are made available
8 * under the terms of the License "Eclipse Public License v1.0"
9 * which accompanies this distribution, and is available
10 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
12 * Initial Contributors:
13 * Nokia Corporation - initial contribution.
18 * @file BaseBulkTestCase.h
27 #include "BaseTestCase.h"
28 #include "hosttransfers.h"
29 #include "modelleddevices.h"
30 #include "controltransferrequests.h"
31 #include "TestCaseFactory.h"
38 namespace NUnitTesting_USBDI
40 const TUint KPercent = 100;
41 const TUint8 KMaxNumTimers = 4; //max number of timers used in any test
42 const TUint8 KMaxNumOutTransfers = 4; //max number of queued OUT transfers used in any Bulk test
43 const TUint8 KMaxNumInTransfers = 4; //max number of queued IN transfers used in any Bulk test
45 class MBulkTestTimerObserver
48 virtual void HandleBulkTestTimerFired() = 0;
51 class CBulkTestTimer : public CTimer
57 @param aTestDevice the test device object that will perform the remote wakeup event
59 static CBulkTestTimer* NewL(MBulkTestTimerObserver& aParent);
70 CBulkTestTimer(MBulkTestTimerObserver& aParent);
76 private: // From CTimer
83 The test device object to instruct to connect of disonnect
85 MBulkTestTimerObserver& iParent;
89 typedef TBuf<256> TMessageBuf;
92 Base policy class for basic bulk test cases. Test cases are active objects that execute their respective test cases
93 and asynchronously complete when test case has finished
95 class CBaseBulkTestCase : public CBaseTestCase,
96 public MUsbBusObserver,
97 public MBulkTestTimerObserver
100 static CBaseBulkTestCase* NewL(TBool aHostRole);
101 ~CBaseBulkTestCase();
103 public: // From MUsbBusObserver
104 virtual void DeviceInsertedL(TUint aDeviceHandle);
105 virtual void DeviceRemovedL(TUint aDeviceHandle);
106 void BusErrorL(TInt aError);
107 void DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState,RUsbDevice::TDeviceState aNewState,
108 TInt aCompletionCode);
109 void HandleBulkTestTimerFired();
113 enum TDeviceInsertedError
116 EDeviceConfigurationError
122 @param aTestCaseId the identity that this test case is to represent
123 @param aHostFlag the flag for host role
125 CBaseBulkTestCase(const TDesC& aTestCaseId,TBool aHostFlag, TBool aHostOnly = EFalse);
128 Base class 2nd phase constructor
130 void CBaseBulkTestCase::BaseBulkConstructL();
133 Common implentations for most bulk transfer tests
135 TInt BaseBulkDeviceInsertedL(TUint aDeviceHandle);
136 TInt BaseBulkDeviceInsertedL(TUint aDeviceHandle, TBool aUseTwoInterfaces);
137 TInt SetUpInterfaceAndPipesL(TUint aDeviceHandle, TUint8 aInterfaceNum);
138 void CloseInterfaceAndPipes();
139 void ExecuteHostTestCaseL();
140 void ExecuteDeviceTestCaseL();
142 void DeviceDoCancel();
145 TBool ValidateData (const TDesC8& aDataToValidate, const TDesC8& aDataPattern);
146 TBool ValidateData (const TDesC8& aDataToValidate, const TDesC8& aDataPattern, const TUint aNumBytes);
147 TBool ValidateData (const TDesC8& aDataToValidate, const TDesC8& aDataPattern, const TUint aStartPoint, const TUint aNumBytes);
148 void RecordTime(const TUint8 aTimerIndex);
149 TInt CheckTimes(const TUint8 aFirstTimerIndex, const TUint8 aSecondTimerIndex, const TUint aPercentage);
150 TInt CheckAndResetTimes(const TUint8 aFirstTimerIndex, const TUint8 aSecondTimerIndex, const TUint aPercentage);
151 void ResetTimes(const TUint8 aTimerIndex);
155 CActorFDF* iActorFDF;
156 RUsbPipe iTestPipeInterface1BulkOut;
157 RUsbPipe iTestPipeInterface1BulkIn;
158 RUsbPipe iTestPipeInterface2BulkOut1;
159 RUsbPipe iTestPipeInterface2BulkOut2;
160 RUsbPipe iTestPipeInterface2BulkIn;
162 CEp0Transfer* iControlEp0;
163 RUsbInterface iUsbInterface0;
164 RUsbInterface iUsbInterface1;
165 RUsbInterface iUsbInterface2;
168 CBulkTransfer* iOutTransfer[KMaxNumOutTransfers];
169 CBulkTransfer* iInTransfer[KMaxNumInTransfers];
171 // Timer that may be used to fire mid bulk transfer EP0 requests at the client
172 CBulkTestTimer* iBulkTestTimer;
174 // The test device to be used for this test case
175 RUsbDeviceD* iTestDevice;
176 // Buffer for storing transfer IN data
178 // Ptr for 'iInBuffer'
180 // Buffer for storing transfer OUT data
182 // Ptr for 'iOutBuffer'
184 // Buffer for storing validation data
185 HBufC8* iValidateBuffer;
186 // Ptr for 'iValidateBuffer'
187 TPtr8 iValidateBufferPtr;
189 TInt iTransferResult;
192 // TransferComplete Bit Mask
193 TUint iTransferComplete;
195 // Set of timing facilities
196 TTime iStartTime[KMaxNumTimers];
197 TTime iEndTime[KMaxNumTimers];
198 TTimeIntervalMicroSeconds iTimeElapsed[KMaxNumTimers];