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-0487.cpp
|
|
15 |
// @internalComponent
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include "PBASE-T_USBDI-0487.h"
|
|
20 |
#include "testpolicy.h"
|
|
21 |
#include "modelleddevices.h"
|
253
|
22 |
#include "OstTraceDefinitions.h"
|
|
23 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
24 |
#include "PBASE-T_USBDI-0487Traces.h"
|
|
25 |
#endif
|
0
|
26 |
|
|
27 |
|
|
28 |
namespace NUnitTesting_USBDI
|
|
29 |
{
|
|
30 |
|
|
31 |
_LIT8(KDataPayload1,"12345678911111112");
|
|
32 |
// _LIT8(KDataPayload2,"12345opqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); unused
|
|
33 |
// _LIT8(KDataPayload3,"abcdefghijklmnopqrstuvwxyzopqrstuvwxyzabcdefghijklmnopqrstuvwxyz12345"); unused
|
|
34 |
|
|
35 |
const TInt KInterruptTransferId1 = 0x01;
|
|
36 |
const TInt KInterruptTransferId2 = 0x02;
|
|
37 |
const TInt KInterruptTransferId3 = 0x03;
|
|
38 |
|
|
39 |
_LIT(KTestCaseId,"PBASE-T_USBDI-0487");
|
|
40 |
const TFunctorTestCase<CUT_PBASE_T_USBDI_0487,TBool> CUT_PBASE_T_USBDI_0487::iFunctor(KTestCaseId);
|
|
41 |
|
|
42 |
CUT_PBASE_T_USBDI_0487* CUT_PBASE_T_USBDI_0487::NewL(TBool aHostRole)
|
|
43 |
{
|
253
|
44 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_NEWL_ENTRY, aHostRole );
|
0
|
45 |
CUT_PBASE_T_USBDI_0487* self = new (ELeave) CUT_PBASE_T_USBDI_0487(aHostRole);
|
|
46 |
CleanupStack::PushL(self);
|
|
47 |
self->ConstructL();
|
|
48 |
CleanupStack::Pop(self);
|
253
|
49 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_NEWL_EXIT, ( TUint )( self ) );
|
0
|
50 |
return self;
|
|
51 |
}
|
|
52 |
|
|
53 |
|
|
54 |
CUT_PBASE_T_USBDI_0487::CUT_PBASE_T_USBDI_0487(TBool aHostRole)
|
|
55 |
: CBaseTestCase(KTestCaseId,aHostRole),
|
|
56 |
iCaseStep(EInProgress)
|
|
57 |
{
|
253
|
58 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0487_CUT_PBASE_T_USBDI_0487_ENTRY, this );
|
|
59 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_CUT_PBASE_T_USBDI_0487_EXIT, this );
|
0
|
60 |
}
|
|
61 |
|
|
62 |
|
|
63 |
void CUT_PBASE_T_USBDI_0487::ConstructL()
|
|
64 |
{
|
253
|
65 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_CONSTRUCTL_ENTRY, this );
|
0
|
66 |
iTestDevice = new RUsbDeviceA(this);
|
|
67 |
BaseConstructL();
|
253
|
68 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_CONSTRUCTL_EXIT, this );
|
0
|
69 |
}
|
|
70 |
|
|
71 |
|
|
72 |
CUT_PBASE_T_USBDI_0487::~CUT_PBASE_T_USBDI_0487()
|
|
73 |
{
|
253
|
74 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_CUT_PBASE_T_USBDI_0487_ENTRY_DUP01, this );
|
0
|
75 |
|
|
76 |
Cancel();
|
|
77 |
delete iTransferIn;
|
|
78 |
delete iTransferIn2;
|
|
79 |
delete iTransferIn3;
|
|
80 |
|
|
81 |
// Close pipe(s) before interface(s)
|
|
82 |
iInPipe.Close();
|
|
83 |
|
|
84 |
// Close interfaces
|
|
85 |
iUsbInterface1.Close();
|
|
86 |
iUsbInterface0.Close();
|
|
87 |
|
|
88 |
delete iControlEp0;
|
|
89 |
delete iActorFDF;
|
|
90 |
if(!IsHost() && iTestDevice)
|
|
91 |
{
|
|
92 |
iTestDevice->Close();
|
|
93 |
}
|
|
94 |
delete iTestDevice;
|
253
|
95 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_CUT_PBASE_T_USBDI_0487_EXIT_DUP01, this );
|
0
|
96 |
}
|
|
97 |
|
|
98 |
void CUT_PBASE_T_USBDI_0487::ExecuteHostTestCaseL()
|
|
99 |
{
|
253
|
100 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_EXECUTEHOSTTESTCASEL_ENTRY, this );
|
0
|
101 |
|
|
102 |
iActorFDF = CActorFDF::NewL(*this);
|
|
103 |
iControlEp0 = new (ELeave) CEp0Transfer(iUsbInterface0);
|
|
104 |
iActorFDF->Monitor();
|
|
105 |
|
|
106 |
TimeoutIn(30);
|
253
|
107 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_EXECUTEHOSTTESTCASEL_EXIT, this );
|
0
|
108 |
}
|
|
109 |
|
|
110 |
void CUT_PBASE_T_USBDI_0487::HostDoCancel()
|
|
111 |
{
|
253
|
112 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_HOSTDOCANCEL_ENTRY, this );
|
0
|
113 |
|
|
114 |
// Cancel the timeout timer
|
|
115 |
CancelTimeout();
|
253
|
116 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_HOSTDOCANCEL_EXIT, this );
|
0
|
117 |
}
|
|
118 |
|
|
119 |
|
|
120 |
void CUT_PBASE_T_USBDI_0487::ExecuteDeviceTestCaseL()
|
|
121 |
{
|
253
|
122 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_EXECUTEDEVICETESTCASEL_ENTRY, this );
|
0
|
123 |
|
|
124 |
iTestDevice->OpenL(TestCaseId());
|
|
125 |
iTestDevice->SubscribeToReports(iStatus);
|
|
126 |
SetActive();
|
|
127 |
iTestDevice->SoftwareConnect();
|
253
|
128 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_EXECUTEDEVICETESTCASEL_EXIT, this );
|
0
|
129 |
}
|
|
130 |
|
|
131 |
void CUT_PBASE_T_USBDI_0487::DeviceDoCancel()
|
|
132 |
{
|
253
|
133 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_DEVICEDOCANCEL_ENTRY, this );
|
0
|
134 |
// Cancel the device
|
|
135 |
iTestDevice->CancelSubscriptionToReports();
|
253
|
136 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICEDOCANCEL_EXIT, this );
|
0
|
137 |
}
|
|
138 |
|
|
139 |
|
|
140 |
void CUT_PBASE_T_USBDI_0487::DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState,RUsbDevice::TDeviceState aNewState,
|
|
141 |
TInt aCompletionCode)
|
|
142 |
{
|
253
|
143 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0487_DEVICESTATECHANGEL_ENTRY, this );
|
|
144 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICESTATECHANGEL_EXIT, this );
|
0
|
145 |
}
|
|
146 |
|
|
147 |
|
|
148 |
void CUT_PBASE_T_USBDI_0487::DeviceInsertedL(TUint aDeviceHandle)
|
|
149 |
{
|
253
|
150 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_ENTRY, this );
|
0
|
151 |
Cancel();
|
|
152 |
TInt err(KErrNone);
|
|
153 |
|
|
154 |
// Validate that device is as expected
|
|
155 |
CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle);
|
|
156 |
if(testDevice.SerialNumber().Compare(TestCaseId()) != 0)
|
|
157 |
{
|
|
158 |
// Incorrect device for this test case
|
|
159 |
|
253
|
160 |
OstTraceExt3(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL, "<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)",
|
|
161 |
KErrNotFound,testDevice.SerialNumber(),TestCaseId());
|
0
|
162 |
|
|
163 |
// Start the connection timeout again
|
|
164 |
|
|
165 |
CancelTimeout();
|
|
166 |
iTimer.After(iStatus,30000000);
|
|
167 |
SetActive();
|
253
|
168 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_EXIT, this );
|
0
|
169 |
return;
|
|
170 |
}
|
|
171 |
|
|
172 |
TUint32 token0,token1;
|
|
173 |
err = testDevice.Device().GetTokenForInterface(0,token0);
|
|
174 |
if(err != KErrNone)
|
|
175 |
{
|
253
|
176 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP01, "<Error %d> Token for interface 0 could not be retrieved",err);
|
0
|
177 |
return TestFailed(err);
|
|
178 |
}
|
|
179 |
err = iUsbInterface0.Open(token0); // Default interface setting 0
|
|
180 |
if(err != KErrNone)
|
|
181 |
{
|
253
|
182 |
OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP02, "<Error %d> Unable to open interface 0 using token %d",err,token0);
|
0
|
183 |
return TestFailed(err);
|
|
184 |
}
|
|
185 |
|
|
186 |
err = testDevice.Device().GetTokenForInterface(1,token1);
|
|
187 |
if(err != KErrNone)
|
|
188 |
{
|
|
189 |
TBuf<256> msg;
|
|
190 |
msg.Format(_L("<Error %d> Token for interface 1 could not be retrieved"),err);
|
253
|
191 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP03, msg);
|
0
|
192 |
iCaseStep = EFailed;
|
|
193 |
TTestCaseFailed request(err,msg);
|
|
194 |
return iControlEp0->SendRequest(request,this);
|
|
195 |
}
|
|
196 |
err = iUsbInterface1.Open(token1); // Default interface setting 0
|
|
197 |
if(err != KErrNone)
|
|
198 |
{
|
|
199 |
TBuf<256> msg;
|
|
200 |
msg.Format(_L("<Error %d> Unable to open interface 1 using token %d"),err,token1);
|
253
|
201 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP04, msg);
|
0
|
202 |
iCaseStep = EFailed;
|
|
203 |
TTestCaseFailed request(err,msg);
|
|
204 |
return iControlEp0->SendRequest(request,this);
|
|
205 |
}
|
|
206 |
|
|
207 |
// Select alternate interface setting 1
|
|
208 |
err = iUsbInterface1.SelectAlternateInterface(1);
|
|
209 |
if(err != KErrNone)
|
|
210 |
{
|
|
211 |
TBuf<256> msg;
|
|
212 |
msg.Format(_L("<Error %d> Selecting alternate interface setting 1 on interface 1"),err);
|
253
|
213 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP05, msg);
|
0
|
214 |
iCaseStep = EFailed;
|
|
215 |
TTestCaseFailed request(err,msg);
|
|
216 |
iControlEp0->SendRequest(request,this);
|
253
|
217 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_EXIT_DUP01, this );
|
0
|
218 |
return;
|
|
219 |
}
|
|
220 |
|
|
221 |
// Open a pipe for endpoint (Int in)
|
|
222 |
TInt endpointAddress;
|
|
223 |
err = GetEndpointAddress(iUsbInterface1,1,KTransferTypeInterrupt,KEpDirectionIn,endpointAddress);
|
|
224 |
if(err != KErrNone)
|
|
225 |
{
|
|
226 |
TBuf<256> msg;
|
|
227 |
msg.Format(_L("<Error %d> unable to get endpoint address for interrupt in endpoint"),err);
|
253
|
228 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP06, msg);
|
0
|
229 |
iCaseStep = EFailed;
|
|
230 |
TTestCaseFailed request(err,msg);
|
|
231 |
iControlEp0->SendRequest(request,this);
|
253
|
232 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_EXIT_DUP02, this );
|
0
|
233 |
return;
|
|
234 |
}
|
|
235 |
|
|
236 |
err = iUsbInterface1.OpenPipeForEndpoint(iInPipe,endpointAddress,EFalse);
|
|
237 |
if(err != KErrNone)
|
|
238 |
{
|
|
239 |
TBuf<256> msg;
|
|
240 |
msg.Format(_L("<Error %d> Unable to open pipe for endpoint 1"),err);
|
253
|
241 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP07, msg);
|
0
|
242 |
iCaseStep = EFailed;
|
|
243 |
TTestCaseFailed request(err,msg);
|
|
244 |
return iControlEp0->SendRequest(request,this);
|
|
245 |
}
|
253
|
246 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP08, "Opened pipe to endpoint address %08x for interrupt transfer to host",endpointAddress);
|
0
|
247 |
|
|
248 |
|
|
249 |
// create an interrupt transfer
|
|
250 |
iTransferIn = new (ELeave) CInterruptTransfer(iInPipe,iUsbInterface1,256,*this,KInterruptTransferId1);
|
|
251 |
iTransferIn->RegisterTransferDescriptor();
|
|
252 |
|
|
253 |
// create a 2nd interrupt transfer
|
|
254 |
iTransferIn2 = new (ELeave) CInterruptTransfer(iInPipe,iUsbInterface1,256,*this,KInterruptTransferId2);
|
|
255 |
iTransferIn2->RegisterTransferDescriptor();
|
|
256 |
|
|
257 |
// create a 3rd interrupt transfer
|
|
258 |
iTransferIn3 = new (ELeave) CInterruptTransfer(iInPipe,iUsbInterface1,256,*this,KInterruptTransferId3);
|
|
259 |
iTransferIn3->RegisterTransferDescriptor();
|
|
260 |
|
|
261 |
// Initialise the descriptors for transfer
|
253
|
262 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP09, "Initialising the transfer descriptors");
|
0
|
263 |
err = iUsbInterface1.InitialiseTransferDescriptors();
|
|
264 |
if(err != KErrNone)
|
|
265 |
{
|
253
|
266 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP10, "<Error %d> Unable to initialise transfer descriptors",err);
|
|
267 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_EXIT_DUP03, this );
|
0
|
268 |
return;
|
|
269 |
}
|
|
270 |
|
|
271 |
// que interrupt transfer
|
|
272 |
err = iTransferIn->TransferInL(KDataPayload1().Length());
|
|
273 |
if(err != KErrNone)
|
|
274 |
{
|
|
275 |
TBuf<256> msg;
|
|
276 |
msg.Format(_L("<Error %d> Unable to queue an interrupt transfer"),err);
|
253
|
277 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP11, msg);
|
0
|
278 |
iCaseStep = EFailed;
|
|
279 |
TTestCaseFailed request(err,msg);
|
|
280 |
return iControlEp0->SendRequest(request,this);
|
|
281 |
}
|
|
282 |
|
|
283 |
// que interrupt transfer
|
|
284 |
err = iTransferIn2->TransferInL(KDataPayload1().Length());
|
|
285 |
if(err != KErrNone)
|
|
286 |
{
|
|
287 |
TBuf<256> msg;
|
|
288 |
msg.Format(_L("<Error %d> Unable to queue an interrupt transfer"),err);
|
253
|
289 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP12, msg);
|
0
|
290 |
iCaseStep = EFailed;
|
|
291 |
TTestCaseFailed request(err,msg);
|
|
292 |
return iControlEp0->SendRequest(request,this);
|
|
293 |
}
|
|
294 |
|
|
295 |
// Que a 3rd interrupt transfer
|
|
296 |
err = iTransferIn3->TransferInL(KDataPayload1().Length());
|
|
297 |
if(err != KErrNone)
|
|
298 |
{
|
|
299 |
TBuf<256> msg;
|
|
300 |
msg.Format(_L("<Error %d> Unable to queue an interrupt transfer"),err);
|
253
|
301 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP13, msg);
|
0
|
302 |
iCaseStep = EFailed;
|
|
303 |
TTestCaseFailed request(err,msg);
|
|
304 |
return iControlEp0->SendRequest(request,this);
|
|
305 |
}
|
|
306 |
|
|
307 |
// Timeout the interrupt transfer in 7 seconds
|
|
308 |
TimeoutIn(7);
|
|
309 |
// Instruct the client device to write the following data through the valid endpoint
|
|
310 |
TEndpointWriteRequest request(1,1,KDataPayload1);
|
|
311 |
iControlEp0->SendRequest(request,this);
|
253
|
312 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_EXIT_DUP04, this );
|
0
|
313 |
}
|
|
314 |
|
|
315 |
|
|
316 |
void CUT_PBASE_T_USBDI_0487::Ep0TransferCompleteL(TInt aCompletionCode)
|
|
317 |
{
|
253
|
318 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0487_EP0TRANSFERCOMPLETEL_ENTRY, this );
|
0
|
319 |
|
|
320 |
RDebug::Printf("Ep0TransferCompleteL with aCompletionCode = %d"),aCompletionCode;
|
|
321 |
|
|
322 |
if(aCompletionCode != KErrNone)
|
|
323 |
{
|
|
324 |
TBuf<256> msg;
|
|
325 |
msg.Format(_L("<Error %d> Transfer to control endpoint 0 was not successful"),aCompletionCode);
|
253
|
326 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_EP0TRANSFERCOMPLETEL, msg);
|
0
|
327 |
}
|
|
328 |
|
|
329 |
if(iCaseStep == EPassed)
|
|
330 |
{
|
|
331 |
if(aCompletionCode == KErrNone)
|
|
332 |
{
|
|
333 |
return TestPassed();
|
|
334 |
}
|
|
335 |
// else error
|
|
336 |
iCaseStep = EFailed;
|
|
337 |
}
|
|
338 |
|
|
339 |
if(iCaseStep == EFailed)
|
|
340 |
{
|
|
341 |
return TestFailed(KErrCompletion);
|
|
342 |
}
|
253
|
343 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_EP0TRANSFERCOMPLETEL_EXIT, this );
|
0
|
344 |
}
|
|
345 |
|
|
346 |
|
|
347 |
void CUT_PBASE_T_USBDI_0487::TransferCompleteL(TInt aTransferId,TInt aCompletionCode)
|
|
348 |
{
|
253
|
349 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_ENTRY, this );
|
0
|
350 |
Cancel();
|
|
351 |
|
253
|
352 |
OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL, "Transfer %d completed with %d",aTransferId,aCompletionCode);
|
0
|
353 |
|
|
354 |
if(aCompletionCode != KErrNone)
|
|
355 |
{
|
|
356 |
TBuf<256> msg;
|
|
357 |
msg.Format(_L("<Error %d> Transfer %d did not complete successfully"),aCompletionCode,aTransferId);
|
253
|
358 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_DUP01, msg);
|
0
|
359 |
iCaseStep = EFailed;
|
|
360 |
TTestCaseFailed request(aCompletionCode,msg);
|
|
361 |
return iControlEp0->SendRequest(request,this);
|
|
362 |
}
|
|
363 |
|
|
364 |
if(aTransferId == KInterruptTransferId1)
|
|
365 |
{
|
|
366 |
TPtrC8 data(iTransferIn->DataPolled());
|
|
367 |
|
253
|
368 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_DUP02, "data.Length 1()= %d", data.Length());
|
0
|
369 |
|
|
370 |
TBuf<256> msg;
|
|
371 |
for(int i = 0 ; i < data.Length(); i++)
|
|
372 |
{
|
|
373 |
msg.AppendFormat(_L("%02x"),data[i]);
|
|
374 |
}
|
253
|
375 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_DUP03, msg);
|
0
|
376 |
// Compare the data to what is expected
|
|
377 |
if(data.Compare(KDataPayload1) != 0)
|
|
378 |
{
|
|
379 |
TBuf<256> msg;
|
|
380 |
msg.Format(_L("<Error %d> Interrupt data received does not match data sent"),KErrCompletion);
|
253
|
381 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_DUP04, msg);
|
0
|
382 |
iCaseStep = EFailed;
|
|
383 |
TTestCaseFailed request(KErrCompletion,msg);
|
|
384 |
return iControlEp0->SendRequest(request,this);
|
|
385 |
}
|
|
386 |
User::After(3000000);
|
|
387 |
// Comparison is a match, continue
|
|
388 |
TEndpointWriteRequest request(1,1,KDataPayload1);
|
|
389 |
return iControlEp0->SendRequest(request,this);
|
|
390 |
}
|
|
391 |
else if(aTransferId == KInterruptTransferId2)
|
|
392 |
{
|
|
393 |
TPtrC8 data(iTransferIn2->DataPolled());
|
253
|
394 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_DUP05, "data.Length 2()= %d", data.Length());
|
0
|
395 |
|
|
396 |
TBuf<256> msg;
|
|
397 |
for(int i = 0 ; i < data.Length(); i++)
|
|
398 |
{
|
|
399 |
msg.AppendFormat(_L("%02x"),data[i]);
|
|
400 |
}
|
253
|
401 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_DUP06, msg);
|
0
|
402 |
|
|
403 |
// Compare the data to what is expected
|
|
404 |
if(data.Compare(KDataPayload1) != 0)
|
|
405 |
{
|
|
406 |
TBuf<256> msg;
|
|
407 |
msg.Format(_L("<Error %d> Interrupt data received does not match data sent"),KErrCompletion);
|
253
|
408 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_DUP07, msg);
|
0
|
409 |
//TODO if test fails! Test fail code below WAS commented out
|
|
410 |
iCaseStep = EFailed;
|
|
411 |
TTestCaseFailed request(KErrCompletion,msg);
|
|
412 |
return iControlEp0->SendRequest(request,this);
|
|
413 |
}
|
|
414 |
// Comparison is a match, continue
|
|
415 |
TEndpointWriteRequest request(1,1,KDataPayload1);
|
|
416 |
return iControlEp0->SendRequest(request,this);
|
|
417 |
|
|
418 |
}
|
|
419 |
else if(aTransferId == KInterruptTransferId3)
|
|
420 |
{
|
|
421 |
TPtrC8 data(iTransferIn3->DataPolled());
|
|
422 |
// Compare the data to what is expected
|
|
423 |
if(data.Compare(KDataPayload1) != 0)
|
|
424 |
{
|
|
425 |
TBuf<256> msg;
|
|
426 |
msg.Format(_L("<Error %d> Interrupt data received does not match data sent"),KErrCompletion);
|
253
|
427 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_DUP08, msg);
|
0
|
428 |
iCaseStep = EFailed;
|
|
429 |
TTestCaseFailed request(KErrCompletion,msg);
|
|
430 |
return iControlEp0->SendRequest(request,this);
|
|
431 |
}
|
|
432 |
// Comparison is a match, test passed
|
|
433 |
iCaseStep = EPassed;
|
|
434 |
TTestCasePassed request;
|
|
435 |
return iControlEp0->SendRequest(request,this);
|
|
436 |
}
|
|
437 |
else
|
|
438 |
{
|
253
|
439 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_DUP09, "<Error> Unknown transfer identity");
|
0
|
440 |
TestFailed(KErrUnknown);
|
|
441 |
}
|
253
|
442 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_EXIT, this );
|
0
|
443 |
}
|
|
444 |
|
|
445 |
|
|
446 |
void CUT_PBASE_T_USBDI_0487::DeviceRemovedL(TUint aDeviceHandle)
|
|
447 |
{
|
253
|
448 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0487_DEVICEREMOVEDL_ENTRY, this );
|
0
|
449 |
|
|
450 |
// The test device should not be removed until the test case has passed
|
|
451 |
// so this test case has not completed, and state this event as an error
|
|
452 |
TestFailed(KErrDisconnected);
|
253
|
453 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICEREMOVEDL_EXIT, this );
|
0
|
454 |
}
|
|
455 |
|
|
456 |
|
|
457 |
void CUT_PBASE_T_USBDI_0487::BusErrorL(TInt aError)
|
|
458 |
{
|
253
|
459 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0487_BUSERRORL_ENTRY, this );
|
0
|
460 |
|
|
461 |
// This test case handles no failiures on the bus
|
|
462 |
TestFailed(KErrCompletion);
|
253
|
463 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_BUSERRORL_EXIT, this );
|
0
|
464 |
}
|
|
465 |
|
|
466 |
void CUT_PBASE_T_USBDI_0487::HostRunL()
|
|
467 |
{
|
253
|
468 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_HOSTRUNL_ENTRY, this );
|
0
|
469 |
// Obtain the completion code
|
|
470 |
TInt completionCode(iStatus.Int());
|
|
471 |
|
|
472 |
if(completionCode == KErrNone)
|
|
473 |
{
|
|
474 |
// Action timeout
|
253
|
475 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_HOSTRUNL, "<Error> Action timeout");
|
0
|
476 |
TestFailed(KErrTimedOut);
|
|
477 |
}
|
|
478 |
else
|
|
479 |
{
|
253
|
480 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_HOSTRUNL_DUP01, "<Error %d> Timeout timer could not complete",completionCode);
|
0
|
481 |
TestFailed(completionCode);
|
|
482 |
}
|
253
|
483 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_HOSTRUNL_EXIT, this );
|
0
|
484 |
}
|
|
485 |
|
|
486 |
void CUT_PBASE_T_USBDI_0487::DeviceRunL()
|
|
487 |
{
|
253
|
488 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_DEVICERUNL_ENTRY, this );
|
0
|
489 |
|
|
490 |
// Disconnect the device
|
|
491 |
iTestDevice->SoftwareDisconnect();
|
|
492 |
|
|
493 |
// Complete the test case request
|
|
494 |
TestPolicy().SignalTestComplete(iStatus.Int());
|
253
|
495 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICERUNL_EXIT, this );
|
0
|
496 |
}
|
|
497 |
|
|
498 |
|
|
499 |
}
|