sl@0
|
1 |
#ifndef __BULK_BASE_TEST_CASE_H
|
sl@0
|
2 |
#define __BULK_BASE_TEST_CASE_H
|
sl@0
|
3 |
|
sl@0
|
4 |
/*
|
sl@0
|
5 |
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
6 |
* All rights reserved.
|
sl@0
|
7 |
* This component and the accompanying materials are made available
|
sl@0
|
8 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
9 |
* which accompanies this distribution, and is available
|
sl@0
|
10 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Initial Contributors:
|
sl@0
|
13 |
* Nokia Corporation - initial contribution.
|
sl@0
|
14 |
*
|
sl@0
|
15 |
* Contributors:
|
sl@0
|
16 |
*
|
sl@0
|
17 |
* Description:
|
sl@0
|
18 |
* @file BaseBulkTestCase.h
|
sl@0
|
19 |
* @internalComponent
|
sl@0
|
20 |
*
|
sl@0
|
21 |
*
|
sl@0
|
22 |
*/
|
sl@0
|
23 |
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
|
sl@0
|
27 |
#include "BaseTestCase.h"
|
sl@0
|
28 |
#include "hosttransfers.h"
|
sl@0
|
29 |
#include "modelleddevices.h"
|
sl@0
|
30 |
#include "controltransferrequests.h"
|
sl@0
|
31 |
#include "TestCaseFactory.h"
|
sl@0
|
32 |
#include "FDFActor.h"
|
sl@0
|
33 |
#include <d32usbc.h>
|
sl@0
|
34 |
#include <d32usbdi.h>
|
sl@0
|
35 |
#include <e32debug.h>
|
sl@0
|
36 |
|
sl@0
|
37 |
|
sl@0
|
38 |
namespace NUnitTesting_USBDI
|
sl@0
|
39 |
{
|
sl@0
|
40 |
const TUint KPercent = 100;
|
sl@0
|
41 |
const TUint8 KMaxNumTimers = 4; //max number of timers used in any test
|
sl@0
|
42 |
const TUint8 KMaxNumOutTransfers = 4; //max number of queued OUT transfers used in any Bulk test
|
sl@0
|
43 |
const TUint8 KMaxNumInTransfers = 4; //max number of queued IN transfers used in any Bulk test
|
sl@0
|
44 |
|
sl@0
|
45 |
class MBulkTestTimerObserver
|
sl@0
|
46 |
{
|
sl@0
|
47 |
public:
|
sl@0
|
48 |
virtual void HandleBulkTestTimerFired() = 0;
|
sl@0
|
49 |
};
|
sl@0
|
50 |
|
sl@0
|
51 |
class CBulkTestTimer : public CTimer
|
sl@0
|
52 |
{
|
sl@0
|
53 |
public:
|
sl@0
|
54 |
|
sl@0
|
55 |
/**
|
sl@0
|
56 |
2 phase construction
|
sl@0
|
57 |
@param aTestDevice the test device object that will perform the remote wakeup event
|
sl@0
|
58 |
*/
|
sl@0
|
59 |
static CBulkTestTimer* NewL(MBulkTestTimerObserver& aParent);
|
sl@0
|
60 |
|
sl@0
|
61 |
/**
|
sl@0
|
62 |
Destructor
|
sl@0
|
63 |
*/
|
sl@0
|
64 |
~CBulkTestTimer();
|
sl@0
|
65 |
|
sl@0
|
66 |
|
sl@0
|
67 |
private:
|
sl@0
|
68 |
/**
|
sl@0
|
69 |
*/
|
sl@0
|
70 |
CBulkTestTimer(MBulkTestTimerObserver& aParent);
|
sl@0
|
71 |
|
sl@0
|
72 |
/**
|
sl@0
|
73 |
*/
|
sl@0
|
74 |
void ConstructL();
|
sl@0
|
75 |
|
sl@0
|
76 |
private: // From CTimer
|
sl@0
|
77 |
/**
|
sl@0
|
78 |
*/
|
sl@0
|
79 |
void RunL();
|
sl@0
|
80 |
|
sl@0
|
81 |
private:
|
sl@0
|
82 |
/**
|
sl@0
|
83 |
The test device object to instruct to connect of disonnect
|
sl@0
|
84 |
*/
|
sl@0
|
85 |
MBulkTestTimerObserver& iParent;
|
sl@0
|
86 |
};
|
sl@0
|
87 |
|
sl@0
|
88 |
|
sl@0
|
89 |
typedef TBuf<256> TMessageBuf;
|
sl@0
|
90 |
|
sl@0
|
91 |
/**
|
sl@0
|
92 |
Base policy class for basic bulk test cases. Test cases are active objects that execute their respective test cases
|
sl@0
|
93 |
and asynchronously complete when test case has finished
|
sl@0
|
94 |
*/
|
sl@0
|
95 |
class CBaseBulkTestCase : public CBaseTestCase,
|
sl@0
|
96 |
public MUsbBusObserver,
|
sl@0
|
97 |
public MBulkTestTimerObserver
|
sl@0
|
98 |
{
|
sl@0
|
99 |
public:
|
sl@0
|
100 |
static CBaseBulkTestCase* NewL(TBool aHostRole);
|
sl@0
|
101 |
~CBaseBulkTestCase();
|
sl@0
|
102 |
|
sl@0
|
103 |
public: // From MUsbBusObserver
|
sl@0
|
104 |
virtual void DeviceInsertedL(TUint aDeviceHandle);
|
sl@0
|
105 |
virtual void DeviceRemovedL(TUint aDeviceHandle);
|
sl@0
|
106 |
void BusErrorL(TInt aError);
|
sl@0
|
107 |
void DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState,RUsbDevice::TDeviceState aNewState,
|
sl@0
|
108 |
TInt aCompletionCode);
|
sl@0
|
109 |
void HandleBulkTestTimerFired();
|
sl@0
|
110 |
|
sl@0
|
111 |
protected:
|
sl@0
|
112 |
|
sl@0
|
113 |
enum TDeviceInsertedError
|
sl@0
|
114 |
{
|
sl@0
|
115 |
ENone,
|
sl@0
|
116 |
EDeviceConfigurationError
|
sl@0
|
117 |
};
|
sl@0
|
118 |
|
sl@0
|
119 |
protected:
|
sl@0
|
120 |
/**
|
sl@0
|
121 |
Constructor
|
sl@0
|
122 |
@param aTestCaseId the identity that this test case is to represent
|
sl@0
|
123 |
@param aHostFlag the flag for host role
|
sl@0
|
124 |
*/
|
sl@0
|
125 |
CBaseBulkTestCase(const TDesC& aTestCaseId,TBool aHostFlag, TBool aHostOnly = EFalse);
|
sl@0
|
126 |
|
sl@0
|
127 |
/**
|
sl@0
|
128 |
Base class 2nd phase constructor
|
sl@0
|
129 |
*/
|
sl@0
|
130 |
void CBaseBulkTestCase::BaseBulkConstructL();
|
sl@0
|
131 |
|
sl@0
|
132 |
/**
|
sl@0
|
133 |
Common implentations for most bulk transfer tests
|
sl@0
|
134 |
*/
|
sl@0
|
135 |
TInt BaseBulkDeviceInsertedL(TUint aDeviceHandle);
|
sl@0
|
136 |
TInt BaseBulkDeviceInsertedL(TUint aDeviceHandle, TBool aUseTwoInterfaces);
|
sl@0
|
137 |
TInt SetUpInterfaceAndPipesL(TUint aDeviceHandle, TUint8 aInterfaceNum);
|
sl@0
|
138 |
void CloseInterfaceAndPipes();
|
sl@0
|
139 |
void ExecuteHostTestCaseL();
|
sl@0
|
140 |
void ExecuteDeviceTestCaseL();
|
sl@0
|
141 |
void HostDoCancel();
|
sl@0
|
142 |
void DeviceDoCancel();
|
sl@0
|
143 |
void HostRunL();
|
sl@0
|
144 |
void DeviceRunL();
|
sl@0
|
145 |
TBool ValidateData (const TDesC8& aDataToValidate, const TDesC8& aDataPattern);
|
sl@0
|
146 |
TBool ValidateData (const TDesC8& aDataToValidate, const TDesC8& aDataPattern, const TUint aNumBytes);
|
sl@0
|
147 |
TBool ValidateData (const TDesC8& aDataToValidate, const TDesC8& aDataPattern, const TUint aStartPoint, const TUint aNumBytes);
|
sl@0
|
148 |
void RecordTime(const TUint8 aTimerIndex);
|
sl@0
|
149 |
TInt CheckTimes(const TUint8 aFirstTimerIndex, const TUint8 aSecondTimerIndex, const TUint aPercentage);
|
sl@0
|
150 |
TInt CheckAndResetTimes(const TUint8 aFirstTimerIndex, const TUint8 aSecondTimerIndex, const TUint aPercentage);
|
sl@0
|
151 |
void ResetTimes(const TUint8 aTimerIndex);
|
sl@0
|
152 |
|
sl@0
|
153 |
protected:
|
sl@0
|
154 |
|
sl@0
|
155 |
CActorFDF* iActorFDF;
|
sl@0
|
156 |
RUsbPipe iTestPipeInterface1BulkOut;
|
sl@0
|
157 |
RUsbPipe iTestPipeInterface1BulkIn;
|
sl@0
|
158 |
RUsbPipe iTestPipeInterface2BulkOut1;
|
sl@0
|
159 |
RUsbPipe iTestPipeInterface2BulkOut2;
|
sl@0
|
160 |
RUsbPipe iTestPipeInterface2BulkIn;
|
sl@0
|
161 |
|
sl@0
|
162 |
CEp0Transfer* iControlEp0;
|
sl@0
|
163 |
RUsbInterface iUsbInterface0;
|
sl@0
|
164 |
RUsbInterface iUsbInterface1;
|
sl@0
|
165 |
RUsbInterface iUsbInterface2;
|
sl@0
|
166 |
|
sl@0
|
167 |
// Transfer objects
|
sl@0
|
168 |
CBulkTransfer* iOutTransfer[KMaxNumOutTransfers];
|
sl@0
|
169 |
CBulkTransfer* iInTransfer[KMaxNumInTransfers];
|
sl@0
|
170 |
|
sl@0
|
171 |
// Timer that may be used to fire mid bulk transfer EP0 requests at the client
|
sl@0
|
172 |
CBulkTestTimer* iBulkTestTimer;
|
sl@0
|
173 |
|
sl@0
|
174 |
// The test device to be used for this test case
|
sl@0
|
175 |
RUsbDeviceD* iTestDevice;
|
sl@0
|
176 |
// Buffer for storing transfer IN data
|
sl@0
|
177 |
HBufC8* iInBuffer;
|
sl@0
|
178 |
// Ptr for 'iInBuffer'
|
sl@0
|
179 |
TPtr8 iInBufferPtr;
|
sl@0
|
180 |
// Buffer for storing transfer OUT data
|
sl@0
|
181 |
HBufC8* iOutBuffer;
|
sl@0
|
182 |
// Ptr for 'iOutBuffer'
|
sl@0
|
183 |
TPtr8 iOutBufferPtr;
|
sl@0
|
184 |
// Buffer for storing validation data
|
sl@0
|
185 |
HBufC8* iValidateBuffer;
|
sl@0
|
186 |
// Ptr for 'iValidateBuffer'
|
sl@0
|
187 |
TPtr8 iValidateBufferPtr;
|
sl@0
|
188 |
|
sl@0
|
189 |
TInt iTransferResult;
|
sl@0
|
190 |
TMessageBuf iMsg;
|
sl@0
|
191 |
|
sl@0
|
192 |
// TransferComplete Bit Mask
|
sl@0
|
193 |
TUint iTransferComplete;
|
sl@0
|
194 |
|
sl@0
|
195 |
// Set of timing facilities
|
sl@0
|
196 |
TTime iStartTime[KMaxNumTimers];
|
sl@0
|
197 |
TTime iEndTime[KMaxNumTimers];
|
sl@0
|
198 |
TTimeIntervalMicroSeconds iTimeElapsed[KMaxNumTimers];
|
sl@0
|
199 |
TInt iTimingError;
|
sl@0
|
200 |
};
|
sl@0
|
201 |
|
sl@0
|
202 |
} //end namespace
|
sl@0
|
203 |
#endif
|