sl@0
|
1 |
// Copyright (c) 2008-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-0498.cpp
|
sl@0
|
15 |
// @internalComponent
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "PBASE-T_USBDI-0498.h"
|
sl@0
|
20 |
#include "testpolicy.h"
|
sl@0
|
21 |
#include "modelleddevices.h"
|
sl@0
|
22 |
#include "testliterals.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
|
sl@0
|
27 |
namespace NUnitTesting_USBDI
|
sl@0
|
28 |
{
|
sl@0
|
29 |
const TInt KBulkMaxTransferSize = 40000;
|
sl@0
|
30 |
const TUint KHostNumWriteBytes1 = 32000;
|
sl@0
|
31 |
const TUint KHostNumWriteBytes2 = 32000;
|
sl@0
|
32 |
const TInt KDeviceNumReadBytes = 64000;
|
sl@0
|
33 |
const TInt KDeviceNumWriteBytes = 64000;
|
sl@0
|
34 |
const TUint KHostNumReadBytes1 = 32000;
|
sl@0
|
35 |
const TUint KHostNumReadBytes2 = 32001; //allow or ZLP
|
sl@0
|
36 |
|
sl@0
|
37 |
|
sl@0
|
38 |
//Make these single bit values ...
|
sl@0
|
39 |
// ... so that their completion can be easily recorded in a bit mask!
|
sl@0
|
40 |
const TUint32 KIfc1BulkTransferInId1 = 1<<0;
|
sl@0
|
41 |
const TUint32 KIfc1BulkTransferInId2 = 1<<1;
|
sl@0
|
42 |
const TUint32 KIfc2BulkTransferInId1 = 1<<2;
|
sl@0
|
43 |
const TUint32 KIfc2BulkTransferInId2 = 1<<3;
|
sl@0
|
44 |
const TUint32 KIfc1BulkTransferInIdMask = KIfc1BulkTransferInId1 | KIfc1BulkTransferInId2;
|
sl@0
|
45 |
const TUint32 KIfc2BulkTransferInIdMask = KIfc2BulkTransferInId1 | KIfc2BulkTransferInId2;
|
sl@0
|
46 |
const TUint32 KBulkTransferInIdMask = KIfc1BulkTransferInIdMask | KIfc2BulkTransferInIdMask;
|
sl@0
|
47 |
const TUint32 KIfc1BulkTransferOutId1 = 1<<4;
|
sl@0
|
48 |
const TUint32 KIfc1BulkTransferOutId2 = 1<<5;
|
sl@0
|
49 |
const TUint32 KIfc2BulkTransferOutId1 = 1<<6;
|
sl@0
|
50 |
const TUint32 KIfc2BulkTransferOutId2 = 1<<7;
|
sl@0
|
51 |
const TUint32 KIfc1BulkTransferOutIdMask = KIfc1BulkTransferOutId1 | KIfc1BulkTransferOutId2;
|
sl@0
|
52 |
const TUint32 KIfc2BulkTransferOutIdMask = KIfc2BulkTransferOutId1 | KIfc2BulkTransferOutId2;
|
sl@0
|
53 |
const TUint32 KBulkTransferOutIdMask = KIfc1BulkTransferOutIdMask | KIfc2BulkTransferOutIdMask;
|
sl@0
|
54 |
const TUint32 KBulkTransferIdMask = KBulkTransferInIdMask | KBulkTransferOutIdMask;
|
sl@0
|
55 |
|
sl@0
|
56 |
const TInt KUnexpectedTransferID = -101;
|
sl@0
|
57 |
const TInt KUndefinedStep = -102;
|
sl@0
|
58 |
|
sl@0
|
59 |
const TInt KMaxTimeDiffPercentage = 25;
|
sl@0
|
60 |
|
sl@0
|
61 |
|
sl@0
|
62 |
|
sl@0
|
63 |
_LIT(KTestCaseId,"PBASE-T_USBDI-0498");
|
sl@0
|
64 |
const TFunctorTestCase<CUT_PBASE_T_USBDI_0498,TBool> CUT_PBASE_T_USBDI_0498::iFunctor(KTestCaseId);
|
sl@0
|
65 |
|
sl@0
|
66 |
CUT_PBASE_T_USBDI_0498* CUT_PBASE_T_USBDI_0498::NewL(TBool aHostRole)
|
sl@0
|
67 |
{
|
sl@0
|
68 |
CUT_PBASE_T_USBDI_0498* self = new (ELeave) CUT_PBASE_T_USBDI_0498(aHostRole);
|
sl@0
|
69 |
CleanupStack::PushL(self);
|
sl@0
|
70 |
self->ConstructL();
|
sl@0
|
71 |
CleanupStack::Pop(self);
|
sl@0
|
72 |
return self;
|
sl@0
|
73 |
}
|
sl@0
|
74 |
|
sl@0
|
75 |
|
sl@0
|
76 |
CUT_PBASE_T_USBDI_0498::CUT_PBASE_T_USBDI_0498(TBool aHostRole)
|
sl@0
|
77 |
: CBaseBulkTestCase(KTestCaseId,aHostRole),
|
sl@0
|
78 |
iCaseStep(EInProgress),
|
sl@0
|
79 |
iRequestDeviceValidationResultPtr(NULL,0)
|
sl@0
|
80 |
{
|
sl@0
|
81 |
}
|
sl@0
|
82 |
|
sl@0
|
83 |
|
sl@0
|
84 |
void CUT_PBASE_T_USBDI_0498::ConstructL()
|
sl@0
|
85 |
{
|
sl@0
|
86 |
BaseBulkConstructL();
|
sl@0
|
87 |
|
sl@0
|
88 |
iInBuffer = HBufC8::NewL(KTestBufferLength);
|
sl@0
|
89 |
RDebug::Printf("CUT_PBASE_T_USBDI_0491::ConstructL(): buffer created");
|
sl@0
|
90 |
}
|
sl@0
|
91 |
|
sl@0
|
92 |
|
sl@0
|
93 |
CUT_PBASE_T_USBDI_0498::~CUT_PBASE_T_USBDI_0498()
|
sl@0
|
94 |
/**
|
sl@0
|
95 |
The transfer objects have test specific names - so perform transfer specific clean up here.
|
sl@0
|
96 |
*/
|
sl@0
|
97 |
{
|
sl@0
|
98 |
LOG_FUNC
|
sl@0
|
99 |
|
sl@0
|
100 |
Cancel();
|
sl@0
|
101 |
|
sl@0
|
102 |
//Do this before deleting the transfer objects
|
sl@0
|
103 |
CloseInterfaceAndPipes();
|
sl@0
|
104 |
|
sl@0
|
105 |
TUint8 count;
|
sl@0
|
106 |
for(count=0;count<KNumOutTransfersPerInterface;count++)
|
sl@0
|
107 |
{
|
sl@0
|
108 |
delete iIfc1OutTransfer[count];
|
sl@0
|
109 |
iIfc1OutTransfer[count] = NULL;
|
sl@0
|
110 |
delete iIfc2OutTransfer[count];
|
sl@0
|
111 |
iIfc2OutTransfer[count] = NULL;
|
sl@0
|
112 |
}
|
sl@0
|
113 |
for(count=0;count<KNumInTransfersPerInterface;count++)
|
sl@0
|
114 |
{
|
sl@0
|
115 |
delete iIfc1InTransfer[count];
|
sl@0
|
116 |
iIfc1InTransfer[count] = NULL;
|
sl@0
|
117 |
delete iIfc2InTransfer[count];
|
sl@0
|
118 |
iIfc2InTransfer[count] = NULL;
|
sl@0
|
119 |
}
|
sl@0
|
120 |
}
|
sl@0
|
121 |
|
sl@0
|
122 |
|
sl@0
|
123 |
void CUT_PBASE_T_USBDI_0498::Ep0TransferCompleteL(TInt aCompletionCode)
|
sl@0
|
124 |
{
|
sl@0
|
125 |
LOG_FUNC
|
sl@0
|
126 |
|
sl@0
|
127 |
RDebug::Printf("Ep0TransferCompleteL with aCompletionCode = %d",aCompletionCode);
|
sl@0
|
128 |
|
sl@0
|
129 |
if(aCompletionCode != KErrNone)
|
sl@0
|
130 |
{
|
sl@0
|
131 |
if(iCaseStep == EFailed)
|
sl@0
|
132 |
{// ignore error, nad catch the TestFailed method called further down.
|
sl@0
|
133 |
RDebug::Printf("***Failure sending FAIL message to client on endpoint 0***");
|
sl@0
|
134 |
}
|
sl@0
|
135 |
else
|
sl@0
|
136 |
{
|
sl@0
|
137 |
TBuf<256> msg;
|
sl@0
|
138 |
msg.Format(_L("<Error %d> Transfer to control endpoint 0 was not successful"),aCompletionCode);
|
sl@0
|
139 |
RDebug::Print(msg);
|
sl@0
|
140 |
iCaseStep = EFailed;
|
sl@0
|
141 |
TTestCaseFailed request(aCompletionCode,msg);
|
sl@0
|
142 |
iControlEp0->SendRequest(request,this);
|
sl@0
|
143 |
return;
|
sl@0
|
144 |
}
|
sl@0
|
145 |
}
|
sl@0
|
146 |
|
sl@0
|
147 |
switch(iCaseStep)
|
sl@0
|
148 |
{
|
sl@0
|
149 |
// Test case passed
|
sl@0
|
150 |
case EPassed:
|
sl@0
|
151 |
TestPassed();
|
sl@0
|
152 |
break;
|
sl@0
|
153 |
|
sl@0
|
154 |
// Test case failed
|
sl@0
|
155 |
case EFailed:
|
sl@0
|
156 |
TestFailed(KErrCompletion);
|
sl@0
|
157 |
break;
|
sl@0
|
158 |
|
sl@0
|
159 |
case ERequestDeviceIFC1Read:
|
sl@0
|
160 |
{
|
sl@0
|
161 |
RDebug::Printf("Asking client for 'Read' on interface 2");
|
sl@0
|
162 |
iCaseStep = ERequestDeviceIFC2Read;
|
sl@0
|
163 |
TEndpointReadRequest request(2,1,KDeviceNumReadBytes);// EP1 means endpoint index 1 not the actual endpoint number
|
sl@0
|
164 |
iControlEp0->SendRequest(request,this);
|
sl@0
|
165 |
}
|
sl@0
|
166 |
break;
|
sl@0
|
167 |
|
sl@0
|
168 |
case ERequestDeviceIFC2Read:
|
sl@0
|
169 |
{
|
sl@0
|
170 |
RDebug::Printf("Asking client to 'Write' on interface 1");
|
sl@0
|
171 |
iCaseStep = ERequestDeviceIFC1Write;
|
sl@0
|
172 |
TEndpointPatternWriteRequest request(1,1,KLiteralFrench4(),KDeviceNumWriteBytes);
|
sl@0
|
173 |
iControlEp0->SendRequest(request,this);
|
sl@0
|
174 |
}
|
sl@0
|
175 |
break;
|
sl@0
|
176 |
|
sl@0
|
177 |
case ERequestDeviceIFC1Write:
|
sl@0
|
178 |
{
|
sl@0
|
179 |
RDebug::Printf("Asking client to 'Write' on interface 2");
|
sl@0
|
180 |
iCaseStep = ERequestDeviceIFC2Write;
|
sl@0
|
181 |
TEndpointPatternWriteRequest request(2,1,KLiteralEnglish2(),KDeviceNumWriteBytes);
|
sl@0
|
182 |
iControlEp0->SendRequest(request,this);
|
sl@0
|
183 |
}
|
sl@0
|
184 |
break;
|
sl@0
|
185 |
|
sl@0
|
186 |
case ERequestDeviceIFC2Write:
|
sl@0
|
187 |
{
|
sl@0
|
188 |
RDebug::Printf("Try to perform ALL transfers on BOTH interfaces");
|
sl@0
|
189 |
|
sl@0
|
190 |
iCaseStep = ETransfer;
|
sl@0
|
191 |
|
sl@0
|
192 |
iStartTime[0].HomeTime();
|
sl@0
|
193 |
iStartTime[1].HomeTime();
|
sl@0
|
194 |
iStartTime[2].HomeTime();
|
sl@0
|
195 |
iStartTime[3].HomeTime();
|
sl@0
|
196 |
|
sl@0
|
197 |
iIfc1OutTransfer[0]->TransferOut(KLiteralFrench4(), KHostNumWriteBytes1, EFalse);
|
sl@0
|
198 |
iIfc1OutTransfer[1]->TransferOut(KLiteralFrench4(), KHostNumWriteBytes1, KHostNumWriteBytes2, EFalse);
|
sl@0
|
199 |
iIfc2OutTransfer[0]->TransferOut(KLiteralEnglish2(), KHostNumWriteBytes1, EFalse);
|
sl@0
|
200 |
iIfc2OutTransfer[1]->TransferOut(KLiteralEnglish2(), KHostNumWriteBytes1, KHostNumWriteBytes2, EFalse);
|
sl@0
|
201 |
|
sl@0
|
202 |
iIfc1InTransfer[0]->TransferIn(KHostNumReadBytes1);
|
sl@0
|
203 |
iIfc1InTransfer[1]->TransferIn(KHostNumReadBytes2);
|
sl@0
|
204 |
iIfc2InTransfer[0]->TransferIn(KHostNumReadBytes1);
|
sl@0
|
205 |
iIfc2InTransfer[1]->TransferIn(KHostNumReadBytes2);
|
sl@0
|
206 |
}
|
sl@0
|
207 |
break;
|
sl@0
|
208 |
|
sl@0
|
209 |
case ERequestDeviceValidateIFC1:
|
sl@0
|
210 |
{
|
sl@0
|
211 |
iCaseStep = ERequestDeviceValidationResultIFC1;
|
sl@0
|
212 |
RDebug::Printf("Interface 1: Request Client Validation Result");
|
sl@0
|
213 |
iRequestDeviceValidationResultPtr.Set(iInBuffer->Des());
|
sl@0
|
214 |
iRequestDeviceValidationResultPtr.Zero(); //reset
|
sl@0
|
215 |
iRequestDeviceValidationResultPtr.SetLength(KPassFailStringLength);
|
sl@0
|
216 |
TInterfaceGetPayloadRequest request(1,iRequestDeviceValidationResultPtr);
|
sl@0
|
217 |
iControlEp0->SendRequest(request,this);
|
sl@0
|
218 |
}
|
sl@0
|
219 |
break;
|
sl@0
|
220 |
|
sl@0
|
221 |
case ERequestDeviceValidationResultIFC1:
|
sl@0
|
222 |
{
|
sl@0
|
223 |
RDebug::Printf("Interface 1: Client Validation Result string ...");
|
sl@0
|
224 |
RDebug::RawPrint(*iInBuffer);
|
sl@0
|
225 |
RDebug::Printf("\n");
|
sl@0
|
226 |
TPtr8 ptr(iInBuffer->Des());
|
sl@0
|
227 |
if(ptr.Compare(KClientPassString) == 0)
|
sl@0
|
228 |
{
|
sl@0
|
229 |
RDebug::Printf("Client Validation Interface 1 Result is a PASS");
|
sl@0
|
230 |
RDebug::Printf("Now performing Client Validation for Interface 2");
|
sl@0
|
231 |
iCaseStep = ERequestDeviceValidateIFC2;
|
sl@0
|
232 |
TEndpointStringValidationRequest request(2,1,KLiteralEnglish2(),KDeviceNumReadBytes);
|
sl@0
|
233 |
iControlEp0->SendRequest(request,this);
|
sl@0
|
234 |
}
|
sl@0
|
235 |
else
|
sl@0
|
236 |
{
|
sl@0
|
237 |
TBuf<256> msg;
|
sl@0
|
238 |
msg.Format(_L("<Error> Bulk data VALIDATION check was NOT successful"));
|
sl@0
|
239 |
RDebug::Print(msg);
|
sl@0
|
240 |
iCaseStep = EFailed;
|
sl@0
|
241 |
TTestCaseFailed request(KErrCorrupt,msg);
|
sl@0
|
242 |
iControlEp0->SendRequest(request,this);
|
sl@0
|
243 |
}
|
sl@0
|
244 |
}
|
sl@0
|
245 |
break;
|
sl@0
|
246 |
|
sl@0
|
247 |
case ERequestDeviceValidateIFC2:
|
sl@0
|
248 |
{
|
sl@0
|
249 |
iCaseStep = ERequestDeviceValidationResultIFC2;
|
sl@0
|
250 |
RDebug::Printf("Interface 2: Request Client Validation Result");
|
sl@0
|
251 |
iRequestDeviceValidationResultPtr.Set(iInBuffer->Des());
|
sl@0
|
252 |
iRequestDeviceValidationResultPtr.Zero(); //reset
|
sl@0
|
253 |
iRequestDeviceValidationResultPtr.SetLength(KPassFailStringLength);
|
sl@0
|
254 |
TInterfaceGetPayloadRequest request(2,iRequestDeviceValidationResultPtr);
|
sl@0
|
255 |
iControlEp0->SendRequest(request,this);
|
sl@0
|
256 |
}
|
sl@0
|
257 |
break;
|
sl@0
|
258 |
|
sl@0
|
259 |
case ERequestDeviceValidationResultIFC2:
|
sl@0
|
260 |
{
|
sl@0
|
261 |
RDebug::Printf("Interface 1: Client Validation Result string ...");
|
sl@0
|
262 |
RDebug::RawPrint(*iInBuffer);
|
sl@0
|
263 |
RDebug::Printf("\n");
|
sl@0
|
264 |
TPtr8 ptr(iInBuffer->Des());
|
sl@0
|
265 |
if(ptr.Compare(KClientPassString) == 0)
|
sl@0
|
266 |
{
|
sl@0
|
267 |
RDebug::Printf("Client Validation Interface 2 Result is a PASS");
|
sl@0
|
268 |
RDebug::Printf("This is the FINAL check - the whole test has a PASSED");
|
sl@0
|
269 |
iCaseStep = EPassed;
|
sl@0
|
270 |
TTestCasePassed request;
|
sl@0
|
271 |
iControlEp0->SendRequest(request,this);
|
sl@0
|
272 |
}
|
sl@0
|
273 |
else
|
sl@0
|
274 |
{
|
sl@0
|
275 |
TBuf<256> msg;
|
sl@0
|
276 |
msg.Format(_L("<Error> Bulk data VALIDATION check was NOT successful"));
|
sl@0
|
277 |
RDebug::Print(msg);
|
sl@0
|
278 |
iCaseStep = EFailed;
|
sl@0
|
279 |
TTestCaseFailed request(KErrCorrupt,msg);
|
sl@0
|
280 |
iControlEp0->SendRequest(request,this);
|
sl@0
|
281 |
}
|
sl@0
|
282 |
}
|
sl@0
|
283 |
break;
|
sl@0
|
284 |
|
sl@0
|
285 |
default:
|
sl@0
|
286 |
RDebug::Printf("<Error> Unknown test step");
|
sl@0
|
287 |
TestFailed(KErrUnknown);
|
sl@0
|
288 |
break;
|
sl@0
|
289 |
}
|
sl@0
|
290 |
}
|
sl@0
|
291 |
|
sl@0
|
292 |
void CUT_PBASE_T_USBDI_0498::TransferCompleteL(TInt aTransferId,TInt aCompletionCode)
|
sl@0
|
293 |
{
|
sl@0
|
294 |
LOG_FUNC
|
sl@0
|
295 |
Cancel();
|
sl@0
|
296 |
|
sl@0
|
297 |
TInt err(KErrNone);
|
sl@0
|
298 |
TBuf<256> msg;
|
sl@0
|
299 |
RDebug::Printf("Transfer completed (id=%d), aCompletionCode = %d, test step = %d",aTransferId, aCompletionCode, iCaseStep);
|
sl@0
|
300 |
|
sl@0
|
301 |
|
sl@0
|
302 |
switch(iCaseStep)
|
sl@0
|
303 |
{
|
sl@0
|
304 |
case ETransfer:
|
sl@0
|
305 |
if(aCompletionCode != KErrNone)
|
sl@0
|
306 |
{
|
sl@0
|
307 |
iIfc1OutTransfer[0]->Cancel();
|
sl@0
|
308 |
iIfc1OutTransfer[1]->Cancel();
|
sl@0
|
309 |
iIfc2OutTransfer[0]->Cancel();
|
sl@0
|
310 |
iIfc2OutTransfer[1]->Cancel();
|
sl@0
|
311 |
iIfc1InTransfer[0]->Cancel();
|
sl@0
|
312 |
iIfc1InTransfer[1]->Cancel();
|
sl@0
|
313 |
iIfc2InTransfer[0]->Cancel();
|
sl@0
|
314 |
iIfc2InTransfer[1]->Cancel();
|
sl@0
|
315 |
err = KErrCorrupt;
|
sl@0
|
316 |
msg.Format(_L("<Error %d> The transfer completed with an error."), aCompletionCode);
|
sl@0
|
317 |
break; //switch(iCaseStep)
|
sl@0
|
318 |
}
|
sl@0
|
319 |
|
sl@0
|
320 |
switch(aTransferId)
|
sl@0
|
321 |
{
|
sl@0
|
322 |
case KIfc1BulkTransferOutId1:
|
sl@0
|
323 |
case KIfc1BulkTransferOutId2:
|
sl@0
|
324 |
case KIfc2BulkTransferOutId1:
|
sl@0
|
325 |
case KIfc2BulkTransferOutId2:
|
sl@0
|
326 |
iTransferComplete |= aTransferId;
|
sl@0
|
327 |
RDebug::Printf("Transfer OUT %d completed (Transfer Completion Aggregation Mask 0x%x)", aTransferId, iTransferComplete);
|
sl@0
|
328 |
break; //switch(aTransferId)
|
sl@0
|
329 |
|
sl@0
|
330 |
case KIfc1BulkTransferInId1:
|
sl@0
|
331 |
case KIfc1BulkTransferInId2:
|
sl@0
|
332 |
case KIfc2BulkTransferInId1:
|
sl@0
|
333 |
case KIfc2BulkTransferInId2:
|
sl@0
|
334 |
iTransferComplete |= aTransferId;
|
sl@0
|
335 |
RDebug::Printf("Transfer OUT %d completed (Transfer Completion Aggregation Mask 0x%x)", aTransferId, iTransferComplete);
|
sl@0
|
336 |
break; //switch(aTransferId)
|
sl@0
|
337 |
|
sl@0
|
338 |
default:
|
sl@0
|
339 |
iTransferComplete = 0; //reset
|
sl@0
|
340 |
err = KUnexpectedTransferID;
|
sl@0
|
341 |
msg.Format(_L("<Error %d> Unexpected transfer ID, GOT %d, (wanted one of:- %d, %d, %d, %d, %d, %d, %d, or%d)"),
|
sl@0
|
342 |
err, aTransferId,
|
sl@0
|
343 |
KIfc1BulkTransferInId1,
|
sl@0
|
344 |
KIfc1BulkTransferInId2,
|
sl@0
|
345 |
KIfc2BulkTransferInId1,
|
sl@0
|
346 |
KIfc2BulkTransferInId2,
|
sl@0
|
347 |
KIfc1BulkTransferOutId1,
|
sl@0
|
348 |
KIfc1BulkTransferOutId2,
|
sl@0
|
349 |
KIfc2BulkTransferOutId1,
|
sl@0
|
350 |
KIfc2BulkTransferOutId2
|
sl@0
|
351 |
);
|
sl@0
|
352 |
break; //switch(aTransferId)
|
sl@0
|
353 |
}
|
sl@0
|
354 |
|
sl@0
|
355 |
// Transfer Out Response
|
sl@0
|
356 |
if(err==KErrNone && iTimeElapsed[0] == 0 && (iTransferComplete & KIfc1BulkTransferOutIdMask) == KIfc1BulkTransferOutIdMask)
|
sl@0
|
357 |
//Record time elapsed for Interface 1 if not yet recorded.
|
sl@0
|
358 |
{
|
sl@0
|
359 |
RecordTime(0);
|
sl@0
|
360 |
}
|
sl@0
|
361 |
if(err==KErrNone && iTimeElapsed[1] == 0 && (iTransferComplete & KIfc2BulkTransferOutIdMask) == KIfc2BulkTransferOutIdMask)
|
sl@0
|
362 |
//Record time elapsed for Interface 2 if not yet recorded.
|
sl@0
|
363 |
{
|
sl@0
|
364 |
RecordTime(1);
|
sl@0
|
365 |
}
|
sl@0
|
366 |
if(err==KErrNone && (iTransferComplete & KBulkTransferOutIdMask) == KBulkTransferOutIdMask)
|
sl@0
|
367 |
{
|
sl@0
|
368 |
RDebug::Printf("All OUT Transfers Completed Successfully: Transfer Completion Aggregation Mask 0x%x", iTransferComplete);
|
sl@0
|
369 |
//Leave validation to the point at which all transfers have completed.
|
sl@0
|
370 |
}
|
sl@0
|
371 |
|
sl@0
|
372 |
// Transfer In Response
|
sl@0
|
373 |
if(err==KErrNone && iTimeElapsed[2] == 0 && (iTransferComplete & KIfc1BulkTransferInIdMask) == KIfc1BulkTransferInIdMask)
|
sl@0
|
374 |
//Record time elapsed for Interface 1 if not yet recorded.
|
sl@0
|
375 |
{
|
sl@0
|
376 |
RecordTime(2);
|
sl@0
|
377 |
}
|
sl@0
|
378 |
if(err==KErrNone && iTimeElapsed[3] == 0 && (iTransferComplete & KIfc2BulkTransferInIdMask) == KIfc2BulkTransferInIdMask)
|
sl@0
|
379 |
//Record time elapsed for Interface 2 if not yet recorded.
|
sl@0
|
380 |
{
|
sl@0
|
381 |
RecordTime(3);
|
sl@0
|
382 |
}
|
sl@0
|
383 |
if(err==KErrNone && (iTransferComplete & KBulkTransferInIdMask) == KBulkTransferInIdMask)
|
sl@0
|
384 |
{
|
sl@0
|
385 |
// ok, compare data rcvd now
|
sl@0
|
386 |
RDebug::Printf("All IN Transfers Completed Successfully: Transfer Completion Aggregation Mask 0x%x", iTransferComplete);
|
sl@0
|
387 |
|
sl@0
|
388 |
TPtrC8 data1(iIfc1InTransfer[0]->DataPolled());
|
sl@0
|
389 |
TPtrC8 data2(iIfc1InTransfer[1]->DataPolled());
|
sl@0
|
390 |
TPtrC8 data3(iIfc2InTransfer[0]->DataPolled());
|
sl@0
|
391 |
TPtrC8 data4(iIfc2InTransfer[1]->DataPolled());
|
sl@0
|
392 |
//Validate first transfer on Interface 1 for number of bytes originally written.
|
sl@0
|
393 |
if(ValidateData(data1, KLiteralFrench4(), KHostNumWriteBytes1) == EFalse)
|
sl@0
|
394 |
{
|
sl@0
|
395 |
RDebug::Printf("Validation failure 1st transfer, Interface 1");
|
sl@0
|
396 |
err = KErrCompletion; //indicates data validation failure
|
sl@0
|
397 |
break; //switch(iCaseStep)
|
sl@0
|
398 |
}
|
sl@0
|
399 |
|
sl@0
|
400 |
//Validate second transfer on Interface 1 for number of bytes originally written.
|
sl@0
|
401 |
if(ValidateData(data2, KLiteralFrench4(), KHostNumWriteBytes1, KHostNumWriteBytes2) == EFalse)
|
sl@0
|
402 |
{
|
sl@0
|
403 |
RDebug::Printf("Validation failure 2nd transfer, Interface 1");
|
sl@0
|
404 |
err = KErrCompletion; //indicates data validation failure
|
sl@0
|
405 |
break; //switch(iCaseStep)
|
sl@0
|
406 |
}
|
sl@0
|
407 |
|
sl@0
|
408 |
//Validate first transfer on Interface 2 for number of bytes originally written.
|
sl@0
|
409 |
if(ValidateData(data3, KLiteralEnglish2(), KHostNumWriteBytes1) == EFalse)
|
sl@0
|
410 |
{
|
sl@0
|
411 |
RDebug::Printf("Validation failure 1st transfer, Interface 2");
|
sl@0
|
412 |
err = KErrCompletion; //indicates data validation failure
|
sl@0
|
413 |
break; //switch(iCaseStep)
|
sl@0
|
414 |
}
|
sl@0
|
415 |
|
sl@0
|
416 |
//Validate second transfer on Interface 2 for number of bytes originally written.
|
sl@0
|
417 |
if(ValidateData(data4, KLiteralEnglish2(), KHostNumWriteBytes1, KHostNumWriteBytes2) == EFalse)
|
sl@0
|
418 |
{
|
sl@0
|
419 |
RDebug::Printf("Validation failure 2nd transfer, Interface 2");
|
sl@0
|
420 |
err = KErrCompletion; //indicates data validation failure
|
sl@0
|
421 |
break; //switch(iCaseStep)
|
sl@0
|
422 |
}
|
sl@0
|
423 |
|
sl@0
|
424 |
// Comparison is a match
|
sl@0
|
425 |
RDebug::Printf("Comparison for IN transfer is a match");
|
sl@0
|
426 |
}
|
sl@0
|
427 |
break; //switch(iCaseStep)
|
sl@0
|
428 |
|
sl@0
|
429 |
default:
|
sl@0
|
430 |
err = KUndefinedStep;
|
sl@0
|
431 |
msg.Format(_L("<Error %d> Undefined case step %d reached"),KUndefinedStep, iCaseStep);
|
sl@0
|
432 |
break; //switch(iCaseStep)
|
sl@0
|
433 |
}
|
sl@0
|
434 |
|
sl@0
|
435 |
if(err == KErrNone && iTransferComplete == KBulkTransferIdMask)
|
sl@0
|
436 |
/*
|
sl@0
|
437 |
Transfers all complete - now ask device to validate first interface's transfer OUT
|
sl@0
|
438 |
*/
|
sl@0
|
439 |
{
|
sl@0
|
440 |
RDebug::Printf("Checking all times against each other");
|
sl@0
|
441 |
err = CheckTimes(0, 1, KMaxTimeDiffPercentage);
|
sl@0
|
442 |
err = err?err:CheckTimes(0, 2, KMaxTimeDiffPercentage);
|
sl@0
|
443 |
err = err?err:CheckTimes(0, 3, KMaxTimeDiffPercentage);
|
sl@0
|
444 |
err = err?err:CheckTimes(1, 2, KMaxTimeDiffPercentage);
|
sl@0
|
445 |
err = err?err:CheckTimes(1, 3, KMaxTimeDiffPercentage);
|
sl@0
|
446 |
err = err?err:CheckTimes(2, 3, KMaxTimeDiffPercentage);
|
sl@0
|
447 |
ResetTimes(0);
|
sl@0
|
448 |
ResetTimes(1);
|
sl@0
|
449 |
ResetTimes(2);
|
sl@0
|
450 |
ResetTimes(3);
|
sl@0
|
451 |
|
sl@0
|
452 |
if(err==KErrNone)
|
sl@0
|
453 |
{
|
sl@0
|
454 |
RDebug::Printf("Asking client for 'Validate' data written on interface 1");
|
sl@0
|
455 |
iCaseStep = ERequestDeviceValidateIFC1;
|
sl@0
|
456 |
TEndpointStringValidationRequest request(1,1,KLiteralFrench4(),KDeviceNumReadBytes);
|
sl@0
|
457 |
iControlEp0->SendRequest(request,this);
|
sl@0
|
458 |
}
|
sl@0
|
459 |
}
|
sl@0
|
460 |
|
sl@0
|
461 |
if(err == KErrCompletion)
|
sl@0
|
462 |
//indicates data validation failure
|
sl@0
|
463 |
{
|
sl@0
|
464 |
msg.Format(_L("<Error %d> Bulk transfer IN data received does not match Bulk Transfer OUT data"), err);
|
sl@0
|
465 |
}
|
sl@0
|
466 |
|
sl@0
|
467 |
if(err == KErrTooBig)
|
sl@0
|
468 |
//indicates timing validation failure
|
sl@0
|
469 |
{
|
sl@0
|
470 |
msg.Format(_L("<Error %d> Timer comparison showed too great a difference in transfer times between the two interfaces"), err);
|
sl@0
|
471 |
}
|
sl@0
|
472 |
|
sl@0
|
473 |
if(err!=KErrNone)
|
sl@0
|
474 |
{
|
sl@0
|
475 |
RDebug::Print(msg);
|
sl@0
|
476 |
iCaseStep = EFailed;
|
sl@0
|
477 |
TTestCaseFailed request(err,msg);
|
sl@0
|
478 |
return iControlEp0->SendRequest(request,this);
|
sl@0
|
479 |
}
|
sl@0
|
480 |
}
|
sl@0
|
481 |
|
sl@0
|
482 |
void CUT_PBASE_T_USBDI_0498::DeviceInsertedL(TUint aDeviceHandle)
|
sl@0
|
483 |
{
|
sl@0
|
484 |
LOG_FUNC
|
sl@0
|
485 |
|
sl@0
|
486 |
Cancel();
|
sl@0
|
487 |
RDebug::Printf("this - %08x", this);
|
sl@0
|
488 |
|
sl@0
|
489 |
TBuf<256> msg;
|
sl@0
|
490 |
TInt err = KErrNone;
|
sl@0
|
491 |
if(BaseBulkDeviceInsertedL(aDeviceHandle, EFalse) == EDeviceConfigurationError)
|
sl@0
|
492 |
// Prepare for response from control transfer to client
|
sl@0
|
493 |
{
|
sl@0
|
494 |
err = KErrGeneral;
|
sl@0
|
495 |
msg.Format(_L("Base class DeviceInsertedL failed"));
|
sl@0
|
496 |
}
|
sl@0
|
497 |
else
|
sl@0
|
498 |
{
|
sl@0
|
499 |
if(SetUpInterfaceAndPipesL(aDeviceHandle, 2) == EDeviceConfigurationError)
|
sl@0
|
500 |
// Prepare for response from control transfer to client
|
sl@0
|
501 |
{
|
sl@0
|
502 |
err = KErrGeneral;
|
sl@0
|
503 |
msg.Format(_L("Base class SetUpInterfaceAndPipes for Interface 2 failed"));
|
sl@0
|
504 |
}
|
sl@0
|
505 |
else
|
sl@0
|
506 |
{
|
sl@0
|
507 |
|
sl@0
|
508 |
iIfc1InTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,KBulkMaxTransferSize,*this,KIfc1BulkTransferInId1);
|
sl@0
|
509 |
iIfc1InTransfer[1] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,KBulkMaxTransferSize,*this,KIfc1BulkTransferInId2);
|
sl@0
|
510 |
iIfc1OutTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkMaxTransferSize,*this,KIfc1BulkTransferOutId1);
|
sl@0
|
511 |
iIfc1OutTransfer[1] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkOut,iUsbInterface1,KBulkMaxTransferSize,*this,KIfc1BulkTransferOutId2);
|
sl@0
|
512 |
|
sl@0
|
513 |
iIfc2InTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface2BulkIn,iUsbInterface2,KBulkMaxTransferSize,*this,KIfc2BulkTransferInId1);
|
sl@0
|
514 |
iIfc2InTransfer[1] = new (ELeave) CBulkTransfer(iTestPipeInterface2BulkIn,iUsbInterface2,KBulkMaxTransferSize,*this,KIfc2BulkTransferInId2);
|
sl@0
|
515 |
iIfc2OutTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface2BulkOut1,iUsbInterface2,KBulkMaxTransferSize,*this,KIfc2BulkTransferOutId1);
|
sl@0
|
516 |
iIfc2OutTransfer[1] = new (ELeave) CBulkTransfer(iTestPipeInterface2BulkOut1,iUsbInterface2,KBulkMaxTransferSize,*this,KIfc2BulkTransferOutId2);
|
sl@0
|
517 |
|
sl@0
|
518 |
// Initialise the descriptors for transfer
|
sl@0
|
519 |
RDebug::Printf("Initialising the transfer descriptors - interface 1");
|
sl@0
|
520 |
err = iUsbInterface1.InitialiseTransferDescriptors();
|
sl@0
|
521 |
if(err != KErrNone)
|
sl@0
|
522 |
{
|
sl@0
|
523 |
msg.Format(_L("<Error %d> Unable to initialise transfer descriptors (Interface 1)"),err);
|
sl@0
|
524 |
}
|
sl@0
|
525 |
else
|
sl@0
|
526 |
{
|
sl@0
|
527 |
// Initialise the descriptors for transfer
|
sl@0
|
528 |
RDebug::Printf("Initialising the transfer descriptors (Interface 2)");
|
sl@0
|
529 |
err = iUsbInterface2.InitialiseTransferDescriptors();
|
sl@0
|
530 |
if(err != KErrNone)
|
sl@0
|
531 |
{
|
sl@0
|
532 |
msg.Format(_L("<Error %d> Unable to initialise transfer descriptors"),err);
|
sl@0
|
533 |
}
|
sl@0
|
534 |
}
|
sl@0
|
535 |
}
|
sl@0
|
536 |
}
|
sl@0
|
537 |
if(err != KErrNone)
|
sl@0
|
538 |
{
|
sl@0
|
539 |
RDebug::Print(msg);
|
sl@0
|
540 |
iCaseStep = EFailed;
|
sl@0
|
541 |
TTestCaseFailed request(err,msg);
|
sl@0
|
542 |
iControlEp0->SendRequest(request,this);
|
sl@0
|
543 |
}
|
sl@0
|
544 |
else
|
sl@0
|
545 |
{
|
sl@0
|
546 |
RDebug::Printf("Asking client for 'Read' on interface 1");
|
sl@0
|
547 |
iCaseStep = ERequestDeviceIFC1Read;
|
sl@0
|
548 |
TEndpointReadRequest request(1,1,KDeviceNumReadBytes);// EP1 means endpoint index 1 not the actual endpoint number
|
sl@0
|
549 |
iControlEp0->SendRequest(request,this);
|
sl@0
|
550 |
}
|
sl@0
|
551 |
}
|
sl@0
|
552 |
|
sl@0
|
553 |
} //end namespace
|