|
1 #ifndef __BULK_BASE_TEST_CASE_H |
|
2 #define __BULK_BASE_TEST_CASE_H |
|
3 |
|
4 /* |
|
5 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
6 * All rights reserved. |
|
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". |
|
11 * |
|
12 * Initial Contributors: |
|
13 * Nokia Corporation - initial contribution. |
|
14 * |
|
15 * Contributors: |
|
16 * |
|
17 * Description: |
|
18 * @file BaseBulkTestCase.h |
|
19 * @internalComponent |
|
20 * |
|
21 * |
|
22 */ |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 #include "BaseTestCase.h" |
|
28 #include "hosttransfers.h" |
|
29 #include "modelleddevices.h" |
|
30 #include "controltransferrequests.h" |
|
31 #include "TestCaseFactory.h" |
|
32 #include "FDFActor.h" |
|
33 #include <d32usbc.h> |
|
34 #include <d32usbdi.h> |
|
35 #include <e32debug.h> |
|
36 |
|
37 |
|
38 namespace NUnitTesting_USBDI |
|
39 { |
|
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 |
|
44 |
|
45 class MBulkTestTimerObserver |
|
46 { |
|
47 public: |
|
48 virtual void HandleBulkTestTimerFired() = 0; |
|
49 }; |
|
50 |
|
51 class CBulkTestTimer : public CTimer |
|
52 { |
|
53 public: |
|
54 |
|
55 /** |
|
56 2 phase construction |
|
57 @param aTestDevice the test device object that will perform the remote wakeup event |
|
58 */ |
|
59 static CBulkTestTimer* NewL(MBulkTestTimerObserver& aParent); |
|
60 |
|
61 /** |
|
62 Destructor |
|
63 */ |
|
64 ~CBulkTestTimer(); |
|
65 |
|
66 |
|
67 private: |
|
68 /** |
|
69 */ |
|
70 CBulkTestTimer(MBulkTestTimerObserver& aParent); |
|
71 |
|
72 /** |
|
73 */ |
|
74 void ConstructL(); |
|
75 |
|
76 private: // From CTimer |
|
77 /** |
|
78 */ |
|
79 void RunL(); |
|
80 |
|
81 private: |
|
82 /** |
|
83 The test device object to instruct to connect of disonnect |
|
84 */ |
|
85 MBulkTestTimerObserver& iParent; |
|
86 }; |
|
87 |
|
88 |
|
89 typedef TBuf<256> TMessageBuf; |
|
90 |
|
91 /** |
|
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 |
|
94 */ |
|
95 class CBaseBulkTestCase : public CBaseTestCase, |
|
96 public MUsbBusObserver, |
|
97 public MBulkTestTimerObserver |
|
98 { |
|
99 public: |
|
100 static CBaseBulkTestCase* NewL(TBool aHostRole); |
|
101 ~CBaseBulkTestCase(); |
|
102 |
|
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(); |
|
110 |
|
111 protected: |
|
112 |
|
113 enum TDeviceInsertedError |
|
114 { |
|
115 ENone, |
|
116 EDeviceConfigurationError |
|
117 }; |
|
118 |
|
119 protected: |
|
120 /** |
|
121 Constructor |
|
122 @param aTestCaseId the identity that this test case is to represent |
|
123 @param aHostFlag the flag for host role |
|
124 */ |
|
125 CBaseBulkTestCase(const TDesC& aTestCaseId,TBool aHostFlag, TBool aHostOnly = EFalse); |
|
126 |
|
127 /** |
|
128 Base class 2nd phase constructor |
|
129 */ |
|
130 void CBaseBulkTestCase::BaseBulkConstructL(); |
|
131 |
|
132 /** |
|
133 Common implentations for most bulk transfer tests |
|
134 */ |
|
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(); |
|
141 void HostDoCancel(); |
|
142 void DeviceDoCancel(); |
|
143 void HostRunL(); |
|
144 void DeviceRunL(); |
|
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); |
|
152 |
|
153 protected: |
|
154 |
|
155 CActorFDF* iActorFDF; |
|
156 RUsbPipe iTestPipeInterface1BulkOut; |
|
157 RUsbPipe iTestPipeInterface1BulkIn; |
|
158 RUsbPipe iTestPipeInterface2BulkOut1; |
|
159 RUsbPipe iTestPipeInterface2BulkOut2; |
|
160 RUsbPipe iTestPipeInterface2BulkIn; |
|
161 |
|
162 CEp0Transfer* iControlEp0; |
|
163 RUsbInterface iUsbInterface0; |
|
164 RUsbInterface iUsbInterface1; |
|
165 RUsbInterface iUsbInterface2; |
|
166 |
|
167 // Transfer objects |
|
168 CBulkTransfer* iOutTransfer[KMaxNumOutTransfers]; |
|
169 CBulkTransfer* iInTransfer[KMaxNumInTransfers]; |
|
170 |
|
171 // Timer that may be used to fire mid bulk transfer EP0 requests at the client |
|
172 CBulkTestTimer* iBulkTestTimer; |
|
173 |
|
174 // The test device to be used for this test case |
|
175 RUsbDeviceD* iTestDevice; |
|
176 // Buffer for storing transfer IN data |
|
177 HBufC8* iInBuffer; |
|
178 // Ptr for 'iInBuffer' |
|
179 TPtr8 iInBufferPtr; |
|
180 // Buffer for storing transfer OUT data |
|
181 HBufC8* iOutBuffer; |
|
182 // Ptr for 'iOutBuffer' |
|
183 TPtr8 iOutBufferPtr; |
|
184 // Buffer for storing validation data |
|
185 HBufC8* iValidateBuffer; |
|
186 // Ptr for 'iValidateBuffer' |
|
187 TPtr8 iValidateBufferPtr; |
|
188 |
|
189 TInt iTransferResult; |
|
190 TMessageBuf iMsg; |
|
191 |
|
192 // TransferComplete Bit Mask |
|
193 TUint iTransferComplete; |
|
194 |
|
195 // Set of timing facilities |
|
196 TTime iStartTime[KMaxNumTimers]; |
|
197 TTime iEndTime[KMaxNumTimers]; |
|
198 TTimeIntervalMicroSeconds iTimeElapsed[KMaxNumTimers]; |
|
199 TInt iTimingError; |
|
200 }; |
|
201 |
|
202 } //end namespace |
|
203 #endif |