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 |
// @internalComponent
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <e32std.h>
|
|
19 |
#include <e32std_private.h>
|
|
20 |
#include <u32std.h> // unicode builds
|
|
21 |
#include <e32base.h>
|
|
22 |
#include <e32base_private.h>
|
|
23 |
#include <e32Test.h> // RTest headder
|
|
24 |
#include "testcaseroot.h"
|
|
25 |
#include "testcasewd.h"
|
|
26 |
#include "testcase0677.h"
|
253
|
27 |
#include "OstTraceDefinitions.h"
|
|
28 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
29 |
#include "testcase0677Traces.h"
|
|
30 |
#endif
|
0
|
31 |
|
|
32 |
#define _REPEATS (oOpenIterations*3)
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
// the name below is used to add a pointer to our construction method to a pointer MAP in
|
|
37 |
// the class factory
|
|
38 |
_LIT(KTestCaseId,"PBASE-USB_OTGDI-0677");
|
|
39 |
const TTestCaseFactoryReceipt<CTestCase0677> CTestCase0677::iFactoryReceipt(KTestCaseId);
|
|
40 |
|
|
41 |
CTestCase0677* CTestCase0677::NewL(TBool aHost)
|
|
42 |
{
|
253
|
43 |
if(gVerboseOutput)
|
|
44 |
{
|
|
45 |
OstTraceFunctionEntry0(CTESTCASE0677_NEWL);
|
|
46 |
}
|
0
|
47 |
CTestCase0677* self = new (ELeave) CTestCase0677(aHost);
|
|
48 |
CleanupStack::PushL(self);
|
|
49 |
self->ConstructL();
|
|
50 |
CleanupStack::Pop(self);
|
|
51 |
return self;
|
|
52 |
}
|
|
53 |
|
|
54 |
|
|
55 |
CTestCase0677::CTestCase0677(TBool aHost)
|
|
56 |
: CTestCaseRoot(KTestCaseId, aHost)
|
|
57 |
{
|
253
|
58 |
if(gVerboseOutput)
|
|
59 |
{
|
|
60 |
OstTraceFunctionEntry0(CTESTCASE0677_CTESTCASE0677);
|
|
61 |
}
|
0
|
62 |
|
|
63 |
}
|
|
64 |
|
|
65 |
|
|
66 |
/**
|
|
67 |
ConstructL
|
|
68 |
*/
|
|
69 |
void CTestCase0677::ConstructL()
|
|
70 |
{
|
253
|
71 |
if(gVerboseOutput)
|
|
72 |
{
|
|
73 |
OstTraceFunctionEntry0(CTESTCASE0677_CONSTRUCTL);
|
|
74 |
}
|
0
|
75 |
iWDTimer = CTestCaseWatchdog::NewL();
|
|
76 |
iRepeats = OPEN_REPEATS;
|
|
77 |
|
|
78 |
BaseConstructL();
|
|
79 |
}
|
|
80 |
|
|
81 |
|
|
82 |
CTestCase0677::~CTestCase0677()
|
|
83 |
{
|
253
|
84 |
if(gVerboseOutput)
|
|
85 |
{
|
|
86 |
OstTraceFunctionEntry0(CTESTCASE0677_DCTESTCASE0677);
|
|
87 |
}
|
0
|
88 |
|
|
89 |
Cancel();
|
|
90 |
delete iWDTimer;
|
|
91 |
|
|
92 |
}
|
|
93 |
|
|
94 |
|
|
95 |
void CTestCase0677::ExecuteTestCaseL()
|
|
96 |
{
|
253
|
97 |
if(gVerboseOutput)
|
|
98 |
{
|
|
99 |
OstTraceFunctionEntry0(CTESTCASE0677_EXECUTETESTCASEL);
|
|
100 |
}
|
0
|
101 |
iCaseStep = EPreconditions;
|
|
102 |
|
|
103 |
iRepeats = KOperationRetriesMax; // VBus event rise retries
|
|
104 |
|
|
105 |
CActiveScheduler::Add(this);
|
|
106 |
SelfComplete();
|
|
107 |
|
|
108 |
}
|
|
109 |
|
|
110 |
|
|
111 |
void CTestCase0677::DoCancel()
|
|
112 |
{
|
253
|
113 |
if(gVerboseOutput)
|
|
114 |
{
|
|
115 |
OstTraceFunctionEntry0(CTESTCASE0677_DOCANCEL);
|
|
116 |
}
|
0
|
117 |
|
|
118 |
// cancel our timer
|
|
119 |
iTimer.Cancel();
|
|
120 |
}
|
|
121 |
|
|
122 |
|
|
123 |
void CTestCase0677::CancelKB(CTestCaseRoot *pThis)
|
|
124 |
{
|
253
|
125 |
if(gVerboseOutput)
|
|
126 |
{
|
|
127 |
OstTraceFunctionEntry0(CTESTCASE0677_CANCELKB);
|
|
128 |
}
|
0
|
129 |
CTestCase0677 * p = REINTERPRET_CAST(CTestCase0677 *,pThis);
|
|
130 |
// cancel any pending call, and then complete our active obj with a cancel value
|
|
131 |
p->iConsole->ReadCancel();
|
|
132 |
|
|
133 |
}
|
|
134 |
|
|
135 |
|
|
136 |
void CTestCase0677::CancelNotify(CTestCaseRoot *pThis)
|
|
137 |
{
|
253
|
138 |
if(gVerboseOutput)
|
|
139 |
{
|
|
140 |
OstTraceFunctionEntry0(CTESTCASE0677_CANCELNOTIFY);
|
|
141 |
}
|
0
|
142 |
CTestCase0677 * p = REINTERPRET_CAST(CTestCase0677 *,pThis);
|
|
143 |
// cancel any pending call, and then complete our active obj with a timeout value
|
|
144 |
switch (p->iCancelWhat)
|
|
145 |
{
|
|
146 |
case ECancelEventNotify:
|
|
147 |
p->otgCancelOtgEventRequest();
|
|
148 |
break;
|
|
149 |
case ECancelMessageNotify:
|
|
150 |
p->otgCancelOtgMessageRequest();
|
|
151 |
break;
|
|
152 |
case ECancelVBusNotify:
|
|
153 |
p->otgCancelOtgVbusNotification();
|
|
154 |
break;
|
|
155 |
default:
|
|
156 |
ASSERT(0);
|
|
157 |
break;
|
|
158 |
}
|
|
159 |
p->SelfComplete(KTestCaseWatchdogTO);
|
|
160 |
}
|
|
161 |
|
|
162 |
|
|
163 |
// This test result depends on all the ID detection tests and the VBus driving and dropping tests have not yet passed
|
|
164 |
void CTestCase0677::DescribePreconditions()
|
|
165 |
{
|
|
166 |
test.Printf(_L("Using OET, connect oscilloscope chan.A to VBus\n"));
|
253
|
167 |
OstTrace0(TRACE_NORMAL, CTESTCASE0677_DESCRIBEPRECONDITIONS, "Using OET, connect oscilloscope chan.A to VBus\n");
|
0
|
168 |
test.Printf(_L("Connect oscilloscope chan.B to D+\n"));
|
253
|
169 |
OstTrace0(TRACE_NORMAL, CTESTCASE0677_DESCRIBEPRECONDITIONS_DUP01, "Connect oscilloscope chan.B to D+\n");
|
0
|
170 |
test.Printf(_L("Trigger once, 200mV, 100ms \n"));
|
253
|
171 |
OstTrace0(TRACE_NORMAL, CTESTCASE0677_DESCRIBEPRECONDITIONS_DUP02, "Trigger once, 200mV, 100ms \n");
|
0
|
172 |
test.Printf(_L("Prepare to observe VBus, D+ pulse.\n\n"));
|
253
|
173 |
OstTrace0(TRACE_NORMAL, CTESTCASE0677_DESCRIBEPRECONDITIONS_DUP03, "Prepare to observe VBus, D+ pulse.\n\n");
|
0
|
174 |
}
|
|
175 |
|
|
176 |
|
|
177 |
void CTestCase0677::ContinueAfter(TTimeIntervalMicroSeconds32 aMicroSecs, TCaseSteps aStep)
|
|
178 |
{
|
|
179 |
LOG_VERBOSE2(_L("Wait %dms before drop VBus"), (TInt)(aMicroSecs.Int()/1000));
|
253
|
180 |
if(gVerboseOutput)
|
|
181 |
{
|
|
182 |
OstTrace1(TRACE_VERBOSE, CTESTCASE0677_CONTINUEAFTER, "Wait %dms before drop VBus", (TInt)(aMicroSecs.Int()/1000));;
|
|
183 |
}
|
0
|
184 |
iTimer.After(iStatus, aMicroSecs);
|
|
185 |
iCaseStep = aStep;
|
|
186 |
SetActive();
|
|
187 |
}
|
|
188 |
|
|
189 |
|
|
190 |
// handle event completion
|
|
191 |
void CTestCase0677::RunStepL()
|
|
192 |
{
|
253
|
193 |
if(gVerboseOutput)
|
|
194 |
{
|
|
195 |
OstTraceFunctionEntry0(CTESTCASE0677_RUNSTEPL);
|
|
196 |
}
|
0
|
197 |
// Obtain the completion code for this CActive obj.
|
|
198 |
TInt completionCode(iStatus.Int());
|
|
199 |
TBuf<MAX_DSTRLEN> aDescription;
|
|
200 |
TInt err(0);
|
|
201 |
|
|
202 |
|
|
203 |
switch(iCaseStep)
|
|
204 |
{
|
|
205 |
case EPreconditions:
|
|
206 |
iCaseStep = ELoadLdd;
|
|
207 |
if (iAutomated)
|
|
208 |
{
|
|
209 |
iCaseStep = ELoadLdd;
|
|
210 |
SelfComplete();
|
|
211 |
break;
|
|
212 |
}
|
|
213 |
// prompt to insert connector
|
|
214 |
test.Printf(KAttachOETAsBDevice);
|
253
|
215 |
OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP01, KAttachOETAsBDevice);
|
0
|
216 |
test.Printf(KPressAnyKeyToContinue);
|
253
|
217 |
OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP02, KPressAnyKeyToContinue);
|
0
|
218 |
RequestCharacter();
|
|
219 |
break;
|
|
220 |
|
|
221 |
// 1. load the LDD and init.
|
|
222 |
case ELoadLdd:
|
|
223 |
if (!StepLoadLDD())
|
|
224 |
{
|
|
225 |
break;
|
|
226 |
}
|
|
227 |
iCaseStep = EDetectBPlug;
|
|
228 |
SelfComplete();
|
|
229 |
break;
|
|
230 |
|
|
231 |
// 2. detect 'B' plug now
|
|
232 |
case EDetectBPlug:
|
|
233 |
if (KTestCaseWatchdogTO == iStatus.Int())
|
|
234 |
{
|
|
235 |
return TestFailed(KErrAbort, _L("User response too slow - FAILED!"));
|
|
236 |
}
|
|
237 |
|
|
238 |
// if doing this test in /AUTO mode, we would fail this now
|
|
239 |
// however if we can control ID_PIN through an API in future, we turn in on now.
|
|
240 |
if (otgIdPinPresent())
|
|
241 |
{
|
|
242 |
test.Printf(KRemoveAConnectorPrompt);
|
253
|
243 |
OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP03, KRemoveAConnectorPrompt);
|
0
|
244 |
test.Printf(KPressAnyKeyToContinue);
|
253
|
245 |
OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP04, KPressAnyKeyToContinue);
|
0
|
246 |
RequestCharacter();
|
|
247 |
|
|
248 |
iCaseStep = EDetectBPlug;
|
|
249 |
}
|
|
250 |
else
|
|
251 |
{
|
|
252 |
iCaseStep = ERequestBus;
|
|
253 |
SelfComplete();
|
|
254 |
}
|
|
255 |
break;
|
|
256 |
|
|
257 |
// 5. Issue SRP (request VBUS)
|
|
258 |
case ERequestBus:
|
|
259 |
iWDTimer->Cancel();
|
|
260 |
|
|
261 |
test.Printf(KMsgWaitingForSRPInitiated);
|
253
|
262 |
OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP05, KMsgWaitingForSRPInitiated);
|
0
|
263 |
otgQueueOtgEventRequest( iOTGEvent, iStatus );
|
|
264 |
|
|
265 |
// turn on VBus (B-SRP)
|
|
266 |
err = otgBusRequest();
|
|
267 |
iTimeSRPStart.HomeTime();
|
|
268 |
|
|
269 |
if (KErrNone != err)
|
|
270 |
{
|
|
271 |
return TestFailed(KErrAbort, _L("Issue SRP - RUsbOtgDriver::BusRequest() FAILED!"));
|
|
272 |
}
|
|
273 |
iCaseStep = EWaitForSRPInitiated;
|
|
274 |
iCancelWhat = ECancelEventNotify;
|
|
275 |
iWDTimer->IssueRequest(32000*2 /*KSpec_TA_SRP_RSPNS +1000*/, this, &CancelNotify);
|
|
276 |
SetActive();
|
|
277 |
break;
|
|
278 |
|
|
279 |
// 6. get SRP initiated event, this is a local indication
|
|
280 |
case EWaitForSRPInitiated:
|
|
281 |
if (KTestCaseWatchdogTO == iStatus.Int())
|
|
282 |
{
|
|
283 |
return TestFailed(KErrAbort, _L("SRP Active indication NOT fired in time - FAILED!"));
|
|
284 |
}
|
|
285 |
OtgEventString(iOTGEvent, aDescription);
|
|
286 |
test.Printf(_L("Received event %d '%S' status(%d)\n"), iOTGEvent, &aDescription, completionCode);
|
253
|
287 |
OstTraceExt3(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP06, "Received event %d '%S' status(%d)\n", iOTGEvent, aDescription, completionCode);
|
0
|
288 |
if (RUsbOtgDriver::EEventSrpInitiated == iOTGEvent)
|
|
289 |
{
|
|
290 |
// calc interval
|
|
291 |
TTimeIntervalMicroSeconds aIntvlMicro;
|
|
292 |
TTime aNowTime;
|
|
293 |
aNowTime.HomeTime();
|
|
294 |
aIntvlMicro = aNowTime.MicroSecondsFrom(iTimeSRPStart);
|
|
295 |
LOG_VERBOSE2(_L("SRP active after %d ms\n"), (TInt)(aIntvlMicro.Int64()/1000));
|
253
|
296 |
if(gVerboseOutput)
|
|
297 |
{
|
|
298 |
OstTrace1(TRACE_VERBOSE, CTESTCASE0677_RUNSTEPL_DUP07, "SRP active after %d ms\n", (TInt)(aIntvlMicro.Int64()/1000));;
|
|
299 |
}
|
0
|
300 |
iCancelWhat = ECancelMessageNotify;
|
|
301 |
otgQueueOtgMessageRequest( iOTGMessage, iStatus );
|
|
302 |
iCaseStep = EWaitForSRPTimeout;
|
|
303 |
test.Printf(KMsgWaitingForSRPTimeout);
|
253
|
304 |
OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP08, KMsgWaitingForSRPTimeout);
|
0
|
305 |
SetActive();
|
|
306 |
}
|
|
307 |
else
|
|
308 |
{
|
|
309 |
iCaseStep = EWaitForSRPInitiated;
|
|
310 |
test.Printf(KMsgWaitingForSRPInitiated);
|
253
|
311 |
OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP09, KMsgWaitingForSRPInitiated);
|
0
|
312 |
iStatus = KRequestPending;
|
|
313 |
otgQueueOtgEventRequest( iOTGEvent, iStatus );
|
|
314 |
SetActive();
|
|
315 |
}
|
|
316 |
break;
|
|
317 |
|
|
318 |
// 6. get SRP timeout event, this is a local indication
|
|
319 |
case EWaitForSRPTimeout:
|
|
320 |
if (KTestCaseWatchdogTO == iStatus.Int())
|
|
321 |
{
|
|
322 |
return TestFailed(KErrAbort, _L("SRP T/O NOT fired in time - FAILED!"));
|
|
323 |
}
|
|
324 |
OtgMessageString(iOTGMessage, aDescription);
|
|
325 |
test.Printf(_L("Received message %d '%S' status(%d)\n"), iOTGMessage, &aDescription, completionCode);
|
253
|
326 |
OstTraceExt3(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP10, "Received message %d '%S' status(%d)\n", iOTGMessage, aDescription, completionCode);
|
0
|
327 |
if (RUsbOtgDriver::EMessageSrpTimeout == iOTGMessage)
|
|
328 |
{
|
|
329 |
iWDTimer->Cancel(); // Only cancel WD Timer here, when timed portion of test is over
|
|
330 |
// calc interval
|
|
331 |
TTimeIntervalMicroSeconds aIntvlMicro;
|
|
332 |
TTime aNowTime;
|
|
333 |
aNowTime.HomeTime();
|
|
334 |
aIntvlMicro = aNowTime.MicroSecondsFrom(iTimeSRPStart);
|
|
335 |
LOG_VERBOSE2(_L("SRP times out after %d ms\n"), (TInt)(aIntvlMicro.Int64()/1000));
|
253
|
336 |
if(gVerboseOutput)
|
|
337 |
{
|
|
338 |
OstTrace1(TRACE_VERBOSE, CTESTCASE0677_RUNSTEPL_DUP11, "SRP times out after %d ms\n", (TInt)(aIntvlMicro.Int64()/1000));;
|
|
339 |
}
|
0
|
340 |
// the correct value is 32 seconds, not 4.9 seconds as per the spec.
|
|
341 |
|
|
342 |
iCaseStep = EIssueSRPObservedPrompt;
|
|
343 |
SelfComplete();
|
|
344 |
}
|
|
345 |
else
|
|
346 |
{
|
|
347 |
iCaseStep = EWaitForSRPTimeout;
|
|
348 |
test.Printf(KMsgWaitingForSRPTimeout);
|
253
|
349 |
OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP12, KMsgWaitingForSRPTimeout);
|
0
|
350 |
iStatus = KRequestPending;
|
|
351 |
otgQueueOtgMessageRequest( iOTGMessage, iStatus );
|
|
352 |
SetActive();
|
|
353 |
}
|
|
354 |
break;
|
|
355 |
|
|
356 |
case EIssueSRPObservedPrompt:
|
|
357 |
{
|
|
358 |
test.Printf(_L("\nPress Y to verify that SRP was observed\n"));
|
253
|
359 |
OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP13, "\nPress Y to verify that SRP was observed\n");
|
0
|
360 |
test.Printf(_L("or any other key to fail test.\n"));
|
253
|
361 |
OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP14, "or any other key to fail test.\n");
|
0
|
362 |
RequestCharacter();
|
|
363 |
iCaseStep = ECheckSRPObservedUserInput;
|
|
364 |
break;
|
|
365 |
}
|
|
366 |
|
|
367 |
|
|
368 |
case ECheckSRPObservedUserInput:
|
|
369 |
{
|
|
370 |
if (('y' != iKeyCodeInput) && ('Y' != iKeyCodeInput))
|
|
371 |
{
|
|
372 |
return TestFailed(KErrAbort, _L("SRP NOT observed - FAILED!"));
|
|
373 |
}
|
|
374 |
iCaseStep = EUnloadLdd;
|
|
375 |
SelfComplete();
|
|
376 |
break;
|
|
377 |
}
|
|
378 |
|
|
379 |
// 12. unload OTG
|
|
380 |
case EUnloadLdd:
|
|
381 |
if (EFalse == StepUnloadLDD())
|
|
382 |
return TestFailed(KErrAbort,_L("Unload Ldd failure"));
|
|
383 |
|
|
384 |
iCaseStep = ELastStep;
|
|
385 |
SelfComplete();
|
|
386 |
break;
|
|
387 |
|
|
388 |
case ELastStep:
|
|
389 |
TestPassed();
|
|
390 |
break;
|
|
391 |
|
|
392 |
default:
|
|
393 |
test.Printf(_L("<Error> unknown test step\n"));
|
253
|
394 |
OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP15, "<Error> unknown test step\n");
|
0
|
395 |
Cancel();
|
|
396 |
return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
|
|
397 |
}
|
|
398 |
}
|
|
399 |
|
|
400 |
|