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