253
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
|
0
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// @file PBASE-T_USBDI-1234.cpp
|
|
15 |
// @internalComponent
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include "PBASE-T_USBDI-1234.h"
|
|
20 |
#include "modelleddevices.h"
|
|
21 |
#include "testpolicy.h"
|
|
22 |
#include "testliterals.h"
|
253
|
23 |
#include "OstTraceDefinitions.h"
|
|
24 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
25 |
#include "PBASE-T_USBDI-1234Traces.h"
|
|
26 |
#endif
|
0
|
27 |
|
|
28 |
namespace NUnitTesting_USBDI
|
|
29 |
{
|
|
30 |
const TInt KBulkTransferSize = 583;
|
|
31 |
const TUint KHostNumWriteBytes1 = 210;
|
|
32 |
const TUint KHostNumWriteBytes2 = 350;
|
|
33 |
const TUint KHostNumWriteBytes3 = KBulkTransferSize - KHostNumWriteBytes1
|
|
34 |
- KHostNumWriteBytes2; // 23
|
|
35 |
const TUint KHostNumReadBytes1 = 301;
|
|
36 |
const TUint KHostNumReadBytes2 = 21;
|
|
37 |
const TUint KHostNumReadBytes3 = KBulkTransferSize - KHostNumReadBytes1
|
|
38 |
- KHostNumReadBytes2; // 261
|
|
39 |
|
|
40 |
|
|
41 |
//Make these single bit values ...
|
|
42 |
// ... so that their completion can be easily recorded in a bit mask!
|
|
43 |
const TInt KBulkTransferInId0 = 1<<0;
|
|
44 |
const TInt KBulkTransferInId1 = 1<<1;
|
|
45 |
const TInt KBulkTransferInId2 = 1<<2;
|
|
46 |
const TInt KBulkTransferOutId0 = 1<<3;
|
|
47 |
const TInt KBulkTransferOutId1 = 1<<4;
|
|
48 |
const TInt KBulkTransferOutId2 = 1<<5;
|
|
49 |
|
|
50 |
const TInt KUnexpectedTransferID = -101;
|
|
51 |
const TInt KUndefinedStep = -102;
|
|
52 |
|
|
53 |
_LIT(KTestCaseId,"PBASE-T_USBDI-1234");
|
|
54 |
// the name is very important
|
|
55 |
const TFunctorTestCase<CUT_PBASE_T_USBDI_1234,TBool>
|
|
56 |
CUT_PBASE_T_USBDI_1234::iFunctor(KTestCaseId);
|
|
57 |
|
|
58 |
CUT_PBASE_T_USBDI_1234* CUT_PBASE_T_USBDI_1234::NewL(TBool aHostRole)
|
|
59 |
{
|
253
|
60 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1234_NEWL_ENTRY, aHostRole );
|
0
|
61 |
CUT_PBASE_T_USBDI_1234* self = new (ELeave) CUT_PBASE_T_USBDI_1234(aHostRole);
|
|
62 |
CleanupStack::PushL(self);
|
|
63 |
self->ConstructL();
|
|
64 |
CleanupStack::Pop(self);
|
253
|
65 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_NEWL_EXIT, ( TUint )( self ) );
|
0
|
66 |
return self;
|
|
67 |
}
|
|
68 |
|
|
69 |
CUT_PBASE_T_USBDI_1234::CUT_PBASE_T_USBDI_1234(TBool aHostRole) :
|
|
70 |
CBaseBulkTestCase(KTestCaseId, aHostRole), iCaseStep(EInProgress)
|
|
71 |
{
|
253
|
72 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1234_CUT_PBASE_T_USBDI_1234_ENTRY, this );
|
0
|
73 |
|
253
|
74 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_CUT_PBASE_T_USBDI_1234_EXIT, this );
|
0
|
75 |
}
|
|
76 |
|
|
77 |
void CUT_PBASE_T_USBDI_1234::ExecuteHostTestCaseL()
|
|
78 |
{
|
253
|
79 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1234_EXECUTEHOSTTESTCASEL_ENTRY, this );
|
0
|
80 |
CBaseBulkTestCase::ExecuteHostTestCaseL();
|
|
81 |
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));
|
|
83 |
iInterface2Watcher = new (ELeave) CInterfaceWatcher(iUsbInterface1,TCallBack(CUT_PBASE_T_USBDI_1234::Interface2ResumedL,this));
|
253
|
84 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_EXECUTEHOSTTESTCASEL_EXIT, this );
|
0
|
85 |
}
|
|
86 |
|
|
87 |
void CUT_PBASE_T_USBDI_1234::ConstructL()
|
|
88 |
{
|
253
|
89 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1234_CONSTRUCTL_ENTRY, this );
|
0
|
90 |
BaseBulkConstructL();
|
253
|
91 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_CONSTRUCTL_EXIT, this );
|
0
|
92 |
}
|
|
93 |
|
|
94 |
CUT_PBASE_T_USBDI_1234::~CUT_PBASE_T_USBDI_1234()
|
|
95 |
{
|
253
|
96 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1234_CUT_PBASE_T_USBDI_1234_ENTRY_DUP01, this );
|
0
|
97 |
// Cancel any async operations
|
|
98 |
|
|
99 |
Cancel(); // Cancel host timer
|
|
100 |
|
|
101 |
if (iInterface1Watcher)
|
|
102 |
{
|
|
103 |
delete iInterface1Watcher;
|
|
104 |
}
|
|
105 |
if (iInterface0Watcher)
|
|
106 |
{
|
|
107 |
delete iInterface0Watcher;
|
|
108 |
}
|
|
109 |
if (iInterface2Watcher)
|
|
110 |
{
|
|
111 |
delete iInterface2Watcher;
|
|
112 |
}
|
|
113 |
|
253
|
114 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_CUT_PBASE_T_USBDI_1234_EXIT_DUP01, this );
|
0
|
115 |
}
|
|
116 |
|
|
117 |
void CUT_PBASE_T_USBDI_1234::DeviceInsertedL(TUint aDeviceHandle)
|
|
118 |
{
|
253
|
119 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1234_DEVICEINSERTEDL_ENTRY, this );
|
0
|
120 |
|
|
121 |
Cancel();
|
|
122 |
|
|
123 |
if (BaseBulkDeviceInsertedL(aDeviceHandle) == EDeviceConfigurationError)
|
|
124 |
// Prepare for response from control transfer to client
|
|
125 |
{
|
|
126 |
iCaseStep = EFailed;
|
|
127 |
}
|
|
128 |
|
|
129 |
// Create the bulk transfers
|
|
130 |
iInTransfer[0]
|
|
131 |
= new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,KBulkTransferSize,*this,KBulkTransferInId0);
|
|
132 |
iInTransfer[1]
|
|
133 |
= new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,KBulkTransferSize,*this,KBulkTransferInId1);
|
|
134 |
iInTransfer[2]
|
|
135 |
= new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,KBulkTransferSize,*this,KBulkTransferInId2);
|
|
136 |
iOutTransfer[0]
|
|
137 |
= new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkTransferSize,*this,KBulkTransferOutId0);
|
|
138 |
iOutTransfer[1]
|
|
139 |
= new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkTransferSize,*this,KBulkTransferOutId1);
|
|
140 |
iOutTransfer[2]
|
|
141 |
= new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkTransferSize,*this,KBulkTransferOutId2);
|
|
142 |
|
|
143 |
// Initialise the descriptors for transfer
|
253
|
144 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234, "Initialising the transfer descriptors");
|
0
|
145 |
TInt err = iUsbInterface1.InitialiseTransferDescriptors();
|
|
146 |
if (err != KErrNone)
|
|
147 |
{
|
|
148 |
TBuf<256> msg;
|
|
149 |
msg.Format(_L("<Error %d> Unable to initialise transfer descriptors"),err);
|
253
|
150 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP01, msg);
|
0
|
151 |
iCaseStep = EFailed;
|
|
152 |
TTestCaseFailed request(err, msg);
|
|
153 |
iControlEp0->SendRequest(request, this);
|
253
|
154 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_DEVICEINSERTEDL_EXIT, this );
|
0
|
155 |
return;
|
|
156 |
}
|
|
157 |
|
|
158 |
iCaseStep = ESuspendDevice;
|
|
159 |
|
|
160 |
TrySuspendDeviceByInterfaces();
|
|
161 |
|
253
|
162 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_DEVICEINSERTEDL_EXIT_DUP01, this );
|
0
|
163 |
}
|
|
164 |
|
|
165 |
TInt CUT_PBASE_T_USBDI_1234::Interface0ResumedL(TAny* aPtr)
|
|
166 |
{
|
253
|
167 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1234_INTERFACE0RESUMEDL_ENTRY, 0 );
|
0
|
168 |
|
|
169 |
// when device is really resumed , the whole of interfaces' previous call PermitSuspendAndWaitForResume()'s requests of the device will be completed , random chose one .
|
253
|
170 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP02, "Interface 0 resumed");
|
0
|
171 |
CUT_PBASE_T_USBDI_1234* self =
|
|
172 |
reinterpret_cast<CUT_PBASE_T_USBDI_1234*>(aPtr);
|
|
173 |
TInt completionCode = self->iInterface0Watcher->CompletionCode();
|
253
|
174 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP03, "watcher 0 errCode=%d",completionCode);
|
0
|
175 |
self->iSuspendedI0 = EFalse;
|
|
176 |
|
|
177 |
switch (self->iCaseStep)
|
|
178 |
{
|
|
179 |
|
|
180 |
case EValidateResumebyInterface:
|
|
181 |
{
|
|
182 |
if (completionCode == KErrNone)
|
|
183 |
{
|
253
|
184 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP04, "device resumed succeed, do bulk transfer!");
|
0
|
185 |
self->iCaseStep = EBulkTransferOutWhenResume;
|
|
186 |
self->SendEpTransferRequest();
|
|
187 |
}
|
|
188 |
else
|
|
189 |
{
|
253
|
190 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP05, "device resumed failed,<err %d> ",completionCode);
|
0
|
191 |
self->iCaseStep = EFailed;
|
|
192 |
self->SendEpRequest();
|
|
193 |
}
|
|
194 |
}
|
|
195 |
|
|
196 |
break;
|
|
197 |
|
|
198 |
default:
|
|
199 |
break;
|
|
200 |
};
|
|
201 |
|
253
|
202 |
OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_1234_INTERFACE0RESUMEDL_EXIT, 0, KErrNone );
|
0
|
203 |
return KErrNone;
|
|
204 |
}
|
|
205 |
|
|
206 |
TInt CUT_PBASE_T_USBDI_1234::Interface1ResumedL(TAny* aPtr)
|
|
207 |
{
|
253
|
208 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1234_INTERFACE1RESUMEDL_ENTRY, 0 );
|
|
209 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP06, "Interface 1 resumed");
|
0
|
210 |
CUT_PBASE_T_USBDI_1234* self =
|
|
211 |
reinterpret_cast<CUT_PBASE_T_USBDI_1234*>(aPtr);
|
253
|
212 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP07, "watcher 1 iStatus=%d",
|
0
|
213 |
self->iInterface1Watcher->CompletionCode());
|
|
214 |
self->iSuspendedI1 = EFalse;
|
253
|
215 |
OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_1234_INTERFACE1RESUMEDL_EXIT, 0, KErrNone );
|
0
|
216 |
return KErrNone;
|
|
217 |
}
|
|
218 |
|
|
219 |
TInt CUT_PBASE_T_USBDI_1234::Interface2ResumedL(TAny* aPtr)
|
|
220 |
{
|
253
|
221 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1234_INTERFACE2RESUMEDL_ENTRY, 0 );
|
|
222 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP08, "Interface 2 resumed");
|
0
|
223 |
CUT_PBASE_T_USBDI_1234* self =
|
|
224 |
reinterpret_cast<CUT_PBASE_T_USBDI_1234*>(aPtr);
|
253
|
225 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP09, "watcher 2 iStatus=%d",
|
0
|
226 |
self->iInterface2Watcher->CompletionCode());
|
|
227 |
self->iSuspendedI2 = EFalse;
|
253
|
228 |
OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_1234_INTERFACE2RESUMEDL_EXIT, 0, KErrNone );
|
0
|
229 |
return KErrNone;
|
|
230 |
}
|
|
231 |
|
|
232 |
void CUT_PBASE_T_USBDI_1234::DeviceStateChangeL(
|
|
233 |
RUsbDevice::TDeviceState aPreviousState,
|
|
234 |
RUsbDevice::TDeviceState aNewState, TInt aCompletionCode)
|
|
235 |
{
|
253
|
236 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1234_DEVICESTATECHANGEL_ENTRY, this );
|
0
|
237 |
Cancel();
|
|
238 |
|
|
239 |
RDebug::Printf(
|
|
240 |
"Device State change from %d to %d err=%d",
|
|
241 |
aPreviousState, aNewState, aCompletionCode);
|
253
|
242 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_DEVICESTATECHANGEL_EXIT, this );
|
0
|
243 |
}
|
|
244 |
|
|
245 |
void CUT_PBASE_T_USBDI_1234::Ep0TransferCompleteL(TInt aCompletionCode)
|
|
246 |
{
|
253
|
247 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1234_EP0TRANSFERCOMPLETEL_ENTRY, this );
|
0
|
248 |
|
|
249 |
RDebug::Printf(
|
|
250 |
"Ep0TransferCompleteL with aCompletionCode = %d",
|
|
251 |
aCompletionCode);
|
|
252 |
|
|
253 |
if (aCompletionCode != KErrNone)
|
|
254 |
{
|
|
255 |
if (iCaseStep == EFailed)
|
|
256 |
{// ignore error, and catch the TestFailed method called further down.
|
253
|
257 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP10, "***Failure sending FAIL message to client on endpoint 0***");
|
0
|
258 |
}
|
|
259 |
else
|
|
260 |
{
|
|
261 |
TBuf<256> msg;
|
|
262 |
msg.Format(_L("<Error %d> Transfer to control endpoint 0 was not successful"),aCompletionCode);
|
253
|
263 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP11, msg);
|
0
|
264 |
iCaseStep = EFailed;
|
|
265 |
TTestCaseFailed request(aCompletionCode, msg);
|
|
266 |
iControlEp0->SendRequest(request, this);
|
253
|
267 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_EP0TRANSFERCOMPLETEL_EXIT, this );
|
0
|
268 |
return;
|
|
269 |
}
|
|
270 |
}
|
|
271 |
|
|
272 |
switch (iCaseStep)
|
|
273 |
{
|
|
274 |
// Test case passed
|
|
275 |
case EPassed:
|
|
276 |
TestPassed();
|
|
277 |
break;
|
|
278 |
|
|
279 |
// Test case failed
|
|
280 |
case EFailed:
|
|
281 |
TestFailed(KErrCompletion);
|
|
282 |
break;
|
|
283 |
|
|
284 |
case EBulkTransferOutWhenResume:
|
253
|
285 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP12, "Try to send data");
|
0
|
286 |
iOutTransfer[0]->TransferOut(KLiteralEnglish8().Mid(0, KHostNumWriteBytes1), EFalse);
|
|
287 |
iOutTransfer[1]->TransferOut(KLiteralEnglish8().Mid(KHostNumWriteBytes1, KHostNumWriteBytes2), EFalse);
|
|
288 |
iOutTransfer[2]->TransferOut(KLiteralEnglish8().Mid(KHostNumWriteBytes1+KHostNumWriteBytes2,
|
|
289 |
KHostNumWriteBytes3), ETrue); //do not suppress ZLP on this last one (though should be irrelevant here)
|
|
290 |
break;
|
|
291 |
|
|
292 |
case EValidBulkTransfeOut:
|
253
|
293 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP13, "Try to receive data");
|
0
|
294 |
iInTransfer[0]->TransferIn(KHostNumReadBytes1);
|
|
295 |
iInTransfer[1]->TransferIn(KHostNumReadBytes2);
|
|
296 |
iInTransfer[2]->TransferIn(KHostNumReadBytes3);
|
|
297 |
break;
|
|
298 |
|
|
299 |
default:
|
253
|
300 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP14, "<Error> Unknown test step");
|
0
|
301 |
TestFailed(KErrUnknown);
|
|
302 |
break;
|
|
303 |
}
|
253
|
304 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_EP0TRANSFERCOMPLETEL_EXIT_DUP01, this );
|
0
|
305 |
}
|
|
306 |
|
|
307 |
void CUT_PBASE_T_USBDI_1234::TransferCompleteL(TInt aTransferId,
|
|
308 |
TInt aCompletionCode)
|
|
309 |
{
|
253
|
310 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1234_TRANSFERCOMPLETEL_ENTRY, this );
|
0
|
311 |
Cancel();
|
|
312 |
|
|
313 |
TInt err(KErrNone);
|
|
314 |
TBuf<256> msg;
|
253
|
315 |
OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP15, "Transfer completed (id=%d), aCompletionCode = %d",
|
0
|
316 |
aTransferId, aCompletionCode);
|
|
317 |
|
|
318 |
switch (iCaseStep)
|
|
319 |
{
|
|
320 |
case EBulkTransferOutWhenResume:
|
|
321 |
if (aCompletionCode != KErrNone)
|
|
322 |
{
|
|
323 |
err = KErrCorrupt;
|
|
324 |
msg.Format(_L("<Error %d> No data sent on bulk OUT request"),aCompletionCode);
|
|
325 |
break; // switch(iCaseStep)
|
|
326 |
}
|
|
327 |
|
|
328 |
switch (aTransferId)
|
|
329 |
{
|
|
330 |
case KBulkTransferOutId0:
|
|
331 |
case KBulkTransferOutId1:
|
|
332 |
case KBulkTransferOutId2:
|
|
333 |
iTransferComplete |= aTransferId;
|
253
|
334 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP16, "Transfer %d completed", aTransferId);
|
0
|
335 |
break; // switch(aTransferId)
|
|
336 |
|
|
337 |
default:
|
|
338 |
iTransferComplete = 0; //reset
|
|
339 |
err = KUnexpectedTransferID;
|
|
340 |
msg.Format(_L("<Error %d> Unexpected transfer ID, wanted %d, %d or %d, got %d"),
|
|
341 |
err, KBulkTransferOutId0, KBulkTransferOutId1, KBulkTransferOutId2, aTransferId);
|
|
342 |
break; // switch(aTransferId)
|
|
343 |
}
|
|
344 |
|
|
345 |
if (err == KErrNone && iTransferComplete
|
|
346 |
== (KBulkTransferOutId0 | KBulkTransferOutId1
|
|
347 |
| KBulkTransferOutId2))
|
|
348 |
{
|
|
349 |
RDebug::Printf(
|
|
350 |
"Try to receive back sent data. Transfers Completed %d",
|
|
351 |
iTransferComplete);
|
|
352 |
iCaseStep = EValidBulkTransfeOut;
|
|
353 |
TUint numBytes[KNumSplitWriteSections] =
|
|
354 |
{
|
|
355 |
KHostNumReadBytes1, KHostNumReadBytes2,
|
|
356 |
KHostNumReadBytes3
|
|
357 |
};
|
|
358 |
TSplitWriteCachedReadDataRequest request(1, 1, 1, numBytes);
|
|
359 |
iControlEp0->SendRequest(request, this);
|
|
360 |
iTransferComplete = 0; //reset
|
|
361 |
}
|
|
362 |
break; // switch(iCaseStep)
|
|
363 |
|
|
364 |
case EValidBulkTransfeOut: //transfer in
|
|
365 |
if (aCompletionCode != KErrNone)
|
|
366 |
{
|
|
367 |
err = KErrCorrupt;
|
|
368 |
msg.Format(_L("<Error %d> No data sent on bulk IN request"),aCompletionCode);
|
|
369 |
break; // switch(iCaseStep)
|
|
370 |
}
|
|
371 |
|
|
372 |
switch (aTransferId)
|
|
373 |
{
|
|
374 |
case KBulkTransferInId0:
|
|
375 |
case KBulkTransferInId1:
|
|
376 |
case KBulkTransferInId2:
|
|
377 |
iTransferComplete |= aTransferId;
|
|
378 |
break; // switch(aTransferId)
|
|
379 |
|
|
380 |
default:
|
|
381 |
iTransferComplete = 0; //reset
|
|
382 |
err = KUnexpectedTransferID;
|
|
383 |
msg.Format(_L("<Error %d> Unexpected transfer ID, wanted %d, %d or %d, got %d"),
|
|
384 |
err, KBulkTransferInId0, KBulkTransferInId1, KBulkTransferInId2, aTransferId);
|
|
385 |
break; // switch(aTransferId)
|
|
386 |
}
|
|
387 |
|
|
388 |
if (err==KErrNone && iTransferComplete == (KBulkTransferInId0
|
|
389 |
| KBulkTransferInId1 | KBulkTransferInId2))
|
|
390 |
{
|
|
391 |
// compare data rcvd now
|
|
392 |
TPtrC8 data1(iInTransfer[0]->DataPolled());
|
|
393 |
TPtrC8 data2(iInTransfer[1]->DataPolled());
|
|
394 |
TPtrC8 data3(iInTransfer[2]->DataPolled());
|
|
395 |
if (ValidateData(data1, KLiteralEnglish8().Mid(0, KHostNumReadBytes1)) == EFalse)
|
|
396 |
{
|
|
397 |
err = KErrCompletion; //indicates data validation failure
|
|
398 |
break; // switch(iCaseStep)
|
|
399 |
}
|
|
400 |
|
|
401 |
if (ValidateData(data2, KLiteralEnglish8().Mid(KHostNumReadBytes1, KHostNumReadBytes2))
|
|
402 |
== EFalse)
|
|
403 |
{
|
|
404 |
err = KErrCompletion; //indicates data validation failure
|
|
405 |
break; // switch(iCaseStep)
|
|
406 |
}
|
|
407 |
|
|
408 |
if (ValidateData(data3, KLiteralEnglish8().Mid(KHostNumReadBytes1+KHostNumReadBytes2,
|
|
409 |
KHostNumReadBytes3)) == EFalse)
|
|
410 |
{
|
|
411 |
err = KErrCompletion; //indicates data validation failure
|
|
412 |
break; // switch(iCaseStep)
|
|
413 |
}
|
|
414 |
|
|
415 |
// Comparison is a match
|
253
|
416 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP17, "Comparison for IN transfer is a match");
|
0
|
417 |
iCaseStep = EPassed;
|
|
418 |
TTestCasePassed request;
|
|
419 |
iControlEp0->SendRequest(request, this);
|
|
420 |
iTransferComplete = 0; //reset
|
|
421 |
}
|
|
422 |
break; // switch(iCaseStep)
|
|
423 |
|
|
424 |
default:
|
|
425 |
err = KUndefinedStep;
|
|
426 |
msg.Format(_L("<Error %d> Undefined case step %d reached"),KUndefinedStep, iCaseStep);
|
|
427 |
break; // switch(iCaseStep)
|
|
428 |
}
|
|
429 |
|
|
430 |
if (err == KErrCompletion)
|
|
431 |
{
|
|
432 |
//indicates data validation failure
|
|
433 |
msg.Format(_L("<Error %d> Bulk transfer IN data received does not match Bulk Transfer OUT data"), err);
|
|
434 |
}
|
|
435 |
|
|
436 |
if (err!=KErrNone)
|
|
437 |
{
|
253
|
438 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP18, msg);
|
0
|
439 |
iCaseStep = EFailed;
|
|
440 |
TTestCaseFailed request(err, msg);
|
|
441 |
iControlEp0->SendRequest(request, this);
|
|
442 |
}
|
|
443 |
|
253
|
444 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_TRANSFERCOMPLETEL_EXIT, this );
|
0
|
445 |
}
|
|
446 |
|
|
447 |
void CUT_PBASE_T_USBDI_1234::TrySuspendDeviceByInterfaces()
|
|
448 |
{
|
253
|
449 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1234_TRYSUSPENDDEVICEBYINTERFACES_ENTRY, this );
|
0
|
450 |
// Suspend interface 0
|
253
|
451 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP19, "Suspending interface 0");
|
0
|
452 |
iInterface0Watcher->SuspendAndWatch();
|
|
453 |
iSuspendedI0 = ETrue;
|
|
454 |
|
|
455 |
// Suspend interface 1
|
253
|
456 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP20, "Suspending interface 1");
|
0
|
457 |
iInterface1Watcher->SuspendAndWatch();
|
|
458 |
iSuspendedI1 = ETrue;
|
|
459 |
|
|
460 |
// Suspend interface 2
|
253
|
461 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1234_DCUT_PBASE_T_USBDI_1234_DUP21, "Suspending interface 2");
|
0
|
462 |
iInterface2Watcher->SuspendAndWatch();
|
|
463 |
iSuspendedI2 = ETrue;
|
|
464 |
|
|
465 |
TimeoutIn(10); // Give 10 seconds for device to suspend
|
|
466 |
|
|
467 |
// scenario2 : device could do the bulk transfer must wait device really resumed.
|
|
468 |
iUsbInterface0.CancelPermitSuspend();
|
|
469 |
|
|
470 |
iCaseStep = EValidateResumebyInterface;
|
|
471 |
|
253
|
472 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_TRYSUSPENDDEVICEBYINTERFACES_EXIT, this );
|
0
|
473 |
}
|
|
474 |
|
|
475 |
void CUT_PBASE_T_USBDI_1234::SendEpRequest()
|
|
476 |
{
|
253
|
477 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1234_SENDEPREQUEST_ENTRY, this );
|
0
|
478 |
TTestCasePassed request;
|
|
479 |
iControlEp0->SendRequest(request, this);
|
253
|
480 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_SENDEPREQUEST_EXIT, this );
|
0
|
481 |
}
|
|
482 |
void CUT_PBASE_T_USBDI_1234::SendEpTransferRequest()
|
|
483 |
{
|
253
|
484 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1234_SENDEPTRANSFERREQUEST_ENTRY, this );
|
0
|
485 |
TEndpointReadRequest request(1, 1, KBulkTransferSize);// EP1 means endpoint index 1 not the actual endpoint number
|
|
486 |
iControlEp0->SendRequest(request, this);
|
253
|
487 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1234_SENDEPTRANSFERREQUEST_EXIT, this );
|
0
|
488 |
}
|
|
489 |
|
|
490 |
}//end namespace
|
|
491 |
|
|
492 |
|