1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of the License "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
22 #include <e32base_private.h> |
22 #include <e32base_private.h> |
23 #include <e32Test.h> // RTest headder |
23 #include <e32Test.h> // RTest headder |
24 #include "testcaseroot.h" |
24 #include "testcaseroot.h" |
25 #include "testcasewd.h" |
25 #include "testcasewd.h" |
26 #include "testcase0677.h" |
26 #include "testcase0677.h" |
|
27 #include "OstTraceDefinitions.h" |
|
28 #ifdef OST_TRACE_COMPILER_IN_USE |
|
29 #include "testcase0677Traces.h" |
|
30 #endif |
27 |
31 |
28 #define _REPEATS (oOpenIterations*3) |
32 #define _REPEATS (oOpenIterations*3) |
29 |
33 |
30 |
34 |
31 |
35 |
34 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0677"); |
38 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0677"); |
35 const TTestCaseFactoryReceipt<CTestCase0677> CTestCase0677::iFactoryReceipt(KTestCaseId); |
39 const TTestCaseFactoryReceipt<CTestCase0677> CTestCase0677::iFactoryReceipt(KTestCaseId); |
36 |
40 |
37 CTestCase0677* CTestCase0677::NewL(TBool aHost) |
41 CTestCase0677* CTestCase0677::NewL(TBool aHost) |
38 { |
42 { |
39 LOG_FUNC |
43 if(gVerboseOutput) |
|
44 { |
|
45 OstTraceFunctionEntry0(CTESTCASE0677_NEWL); |
|
46 } |
40 CTestCase0677* self = new (ELeave) CTestCase0677(aHost); |
47 CTestCase0677* self = new (ELeave) CTestCase0677(aHost); |
41 CleanupStack::PushL(self); |
48 CleanupStack::PushL(self); |
42 self->ConstructL(); |
49 self->ConstructL(); |
43 CleanupStack::Pop(self); |
50 CleanupStack::Pop(self); |
44 return self; |
51 return self; |
46 |
53 |
47 |
54 |
48 CTestCase0677::CTestCase0677(TBool aHost) |
55 CTestCase0677::CTestCase0677(TBool aHost) |
49 : CTestCaseRoot(KTestCaseId, aHost) |
56 : CTestCaseRoot(KTestCaseId, aHost) |
50 { |
57 { |
51 LOG_FUNC |
58 if(gVerboseOutput) |
|
59 { |
|
60 OstTraceFunctionEntry0(CTESTCASE0677_CTESTCASE0677); |
|
61 } |
52 |
62 |
53 } |
63 } |
54 |
64 |
55 |
65 |
56 /** |
66 /** |
57 ConstructL |
67 ConstructL |
58 */ |
68 */ |
59 void CTestCase0677::ConstructL() |
69 void CTestCase0677::ConstructL() |
60 { |
70 { |
61 LOG_FUNC |
71 if(gVerboseOutput) |
|
72 { |
|
73 OstTraceFunctionEntry0(CTESTCASE0677_CONSTRUCTL); |
|
74 } |
62 iWDTimer = CTestCaseWatchdog::NewL(); |
75 iWDTimer = CTestCaseWatchdog::NewL(); |
63 iRepeats = OPEN_REPEATS; |
76 iRepeats = OPEN_REPEATS; |
64 |
77 |
65 BaseConstructL(); |
78 BaseConstructL(); |
66 } |
79 } |
67 |
80 |
68 |
81 |
69 CTestCase0677::~CTestCase0677() |
82 CTestCase0677::~CTestCase0677() |
70 { |
83 { |
71 LOG_FUNC |
84 if(gVerboseOutput) |
|
85 { |
|
86 OstTraceFunctionEntry0(CTESTCASE0677_DCTESTCASE0677); |
|
87 } |
72 |
88 |
73 Cancel(); |
89 Cancel(); |
74 delete iWDTimer; |
90 delete iWDTimer; |
75 |
91 |
76 } |
92 } |
77 |
93 |
78 |
94 |
79 void CTestCase0677::ExecuteTestCaseL() |
95 void CTestCase0677::ExecuteTestCaseL() |
80 { |
96 { |
81 LOG_FUNC |
97 if(gVerboseOutput) |
|
98 { |
|
99 OstTraceFunctionEntry0(CTESTCASE0677_EXECUTETESTCASEL); |
|
100 } |
82 iCaseStep = EPreconditions; |
101 iCaseStep = EPreconditions; |
83 |
102 |
84 iRepeats = KOperationRetriesMax; // VBus event rise retries |
103 iRepeats = KOperationRetriesMax; // VBus event rise retries |
85 |
104 |
86 CActiveScheduler::Add(this); |
105 CActiveScheduler::Add(this); |
89 } |
108 } |
90 |
109 |
91 |
110 |
92 void CTestCase0677::DoCancel() |
111 void CTestCase0677::DoCancel() |
93 { |
112 { |
94 LOG_FUNC |
113 if(gVerboseOutput) |
|
114 { |
|
115 OstTraceFunctionEntry0(CTESTCASE0677_DOCANCEL); |
|
116 } |
95 |
117 |
96 // cancel our timer |
118 // cancel our timer |
97 iTimer.Cancel(); |
119 iTimer.Cancel(); |
98 } |
120 } |
99 |
121 |
100 |
122 |
101 void CTestCase0677::CancelKB(CTestCaseRoot *pThis) |
123 void CTestCase0677::CancelKB(CTestCaseRoot *pThis) |
102 { |
124 { |
103 LOG_FUNC |
125 if(gVerboseOutput) |
|
126 { |
|
127 OstTraceFunctionEntry0(CTESTCASE0677_CANCELKB); |
|
128 } |
104 CTestCase0677 * p = REINTERPRET_CAST(CTestCase0677 *,pThis); |
129 CTestCase0677 * p = REINTERPRET_CAST(CTestCase0677 *,pThis); |
105 // cancel any pending call, and then complete our active obj with a cancel value |
130 // cancel any pending call, and then complete our active obj with a cancel value |
106 p->iConsole->ReadCancel(); |
131 p->iConsole->ReadCancel(); |
107 |
132 |
108 } |
133 } |
109 |
134 |
110 |
135 |
111 void CTestCase0677::CancelNotify(CTestCaseRoot *pThis) |
136 void CTestCase0677::CancelNotify(CTestCaseRoot *pThis) |
112 { |
137 { |
113 LOG_FUNC |
138 if(gVerboseOutput) |
|
139 { |
|
140 OstTraceFunctionEntry0(CTESTCASE0677_CANCELNOTIFY); |
|
141 } |
114 CTestCase0677 * p = REINTERPRET_CAST(CTestCase0677 *,pThis); |
142 CTestCase0677 * p = REINTERPRET_CAST(CTestCase0677 *,pThis); |
115 // cancel any pending call, and then complete our active obj with a timeout value |
143 // cancel any pending call, and then complete our active obj with a timeout value |
116 switch (p->iCancelWhat) |
144 switch (p->iCancelWhat) |
117 { |
145 { |
118 case ECancelEventNotify: |
146 case ECancelEventNotify: |
134 |
162 |
135 // This test result depends on all the ID detection tests and the VBus driving and dropping tests have not yet passed |
163 // This test result depends on all the ID detection tests and the VBus driving and dropping tests have not yet passed |
136 void CTestCase0677::DescribePreconditions() |
164 void CTestCase0677::DescribePreconditions() |
137 { |
165 { |
138 test.Printf(_L("Using OET, connect oscilloscope chan.A to VBus\n")); |
166 test.Printf(_L("Using OET, connect oscilloscope chan.A to VBus\n")); |
|
167 OstTrace0(TRACE_NORMAL, CTESTCASE0677_DESCRIBEPRECONDITIONS, "Using OET, connect oscilloscope chan.A to VBus\n"); |
139 test.Printf(_L("Connect oscilloscope chan.B to D+\n")); |
168 test.Printf(_L("Connect oscilloscope chan.B to D+\n")); |
|
169 OstTrace0(TRACE_NORMAL, CTESTCASE0677_DESCRIBEPRECONDITIONS_DUP01, "Connect oscilloscope chan.B to D+\n"); |
140 test.Printf(_L("Trigger once, 200mV, 100ms \n")); |
170 test.Printf(_L("Trigger once, 200mV, 100ms \n")); |
|
171 OstTrace0(TRACE_NORMAL, CTESTCASE0677_DESCRIBEPRECONDITIONS_DUP02, "Trigger once, 200mV, 100ms \n"); |
141 test.Printf(_L("Prepare to observe VBus, D+ pulse.\n\n")); |
172 test.Printf(_L("Prepare to observe VBus, D+ pulse.\n\n")); |
|
173 OstTrace0(TRACE_NORMAL, CTESTCASE0677_DESCRIBEPRECONDITIONS_DUP03, "Prepare to observe VBus, D+ pulse.\n\n"); |
142 } |
174 } |
143 |
175 |
144 |
176 |
145 void CTestCase0677::ContinueAfter(TTimeIntervalMicroSeconds32 aMicroSecs, TCaseSteps aStep) |
177 void CTestCase0677::ContinueAfter(TTimeIntervalMicroSeconds32 aMicroSecs, TCaseSteps aStep) |
146 { |
178 { |
147 LOG_VERBOSE2(_L("Wait %dms before drop VBus"), (TInt)(aMicroSecs.Int()/1000)); |
179 LOG_VERBOSE2(_L("Wait %dms before drop VBus"), (TInt)(aMicroSecs.Int()/1000)); |
|
180 if(gVerboseOutput) |
|
181 { |
|
182 OstTrace1(TRACE_VERBOSE, CTESTCASE0677_CONTINUEAFTER, "Wait %dms before drop VBus", (TInt)(aMicroSecs.Int()/1000));; |
|
183 } |
148 iTimer.After(iStatus, aMicroSecs); |
184 iTimer.After(iStatus, aMicroSecs); |
149 iCaseStep = aStep; |
185 iCaseStep = aStep; |
150 SetActive(); |
186 SetActive(); |
151 } |
187 } |
152 |
188 |
153 |
189 |
154 // handle event completion |
190 // handle event completion |
155 void CTestCase0677::RunStepL() |
191 void CTestCase0677::RunStepL() |
156 { |
192 { |
157 LOG_FUNC |
193 if(gVerboseOutput) |
|
194 { |
|
195 OstTraceFunctionEntry0(CTESTCASE0677_RUNSTEPL); |
|
196 } |
158 // Obtain the completion code for this CActive obj. |
197 // Obtain the completion code for this CActive obj. |
159 TInt completionCode(iStatus.Int()); |
198 TInt completionCode(iStatus.Int()); |
160 TBuf<MAX_DSTRLEN> aDescription; |
199 TBuf<MAX_DSTRLEN> aDescription; |
161 TInt err(0); |
200 TInt err(0); |
162 |
201 |
197 // if doing this test in /AUTO mode, we would fail this now |
238 // if doing this test in /AUTO mode, we would fail this now |
198 // however if we can control ID_PIN through an API in future, we turn in on now. |
239 // however if we can control ID_PIN through an API in future, we turn in on now. |
199 if (otgIdPinPresent()) |
240 if (otgIdPinPresent()) |
200 { |
241 { |
201 test.Printf(KRemoveAConnectorPrompt); |
242 test.Printf(KRemoveAConnectorPrompt); |
|
243 OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP03, KRemoveAConnectorPrompt); |
202 test.Printf(KPressAnyKeyToContinue); |
244 test.Printf(KPressAnyKeyToContinue); |
|
245 OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP04, KPressAnyKeyToContinue); |
203 RequestCharacter(); |
246 RequestCharacter(); |
204 |
247 |
205 iCaseStep = EDetectBPlug; |
248 iCaseStep = EDetectBPlug; |
206 } |
249 } |
207 else |
250 else |
214 // 5. Issue SRP (request VBUS) |
257 // 5. Issue SRP (request VBUS) |
215 case ERequestBus: |
258 case ERequestBus: |
216 iWDTimer->Cancel(); |
259 iWDTimer->Cancel(); |
217 |
260 |
218 test.Printf(KMsgWaitingForSRPInitiated); |
261 test.Printf(KMsgWaitingForSRPInitiated); |
|
262 OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP05, KMsgWaitingForSRPInitiated); |
219 otgQueueOtgEventRequest( iOTGEvent, iStatus ); |
263 otgQueueOtgEventRequest( iOTGEvent, iStatus ); |
220 |
264 |
221 // turn on VBus (B-SRP) |
265 // turn on VBus (B-SRP) |
222 err = otgBusRequest(); |
266 err = otgBusRequest(); |
223 iTimeSRPStart.HomeTime(); |
267 iTimeSRPStart.HomeTime(); |
238 { |
282 { |
239 return TestFailed(KErrAbort, _L("SRP Active indication NOT fired in time - FAILED!")); |
283 return TestFailed(KErrAbort, _L("SRP Active indication NOT fired in time - FAILED!")); |
240 } |
284 } |
241 OtgEventString(iOTGEvent, aDescription); |
285 OtgEventString(iOTGEvent, aDescription); |
242 test.Printf(_L("Received event %d '%S' status(%d)\n"), iOTGEvent, &aDescription, completionCode); |
286 test.Printf(_L("Received event %d '%S' status(%d)\n"), iOTGEvent, &aDescription, completionCode); |
|
287 OstTraceExt3(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP06, "Received event %d '%S' status(%d)\n", iOTGEvent, aDescription, completionCode); |
243 if (RUsbOtgDriver::EEventSrpInitiated == iOTGEvent) |
288 if (RUsbOtgDriver::EEventSrpInitiated == iOTGEvent) |
244 { |
289 { |
245 // calc interval |
290 // calc interval |
246 TTimeIntervalMicroSeconds aIntvlMicro; |
291 TTimeIntervalMicroSeconds aIntvlMicro; |
247 TTime aNowTime; |
292 TTime aNowTime; |
248 aNowTime.HomeTime(); |
293 aNowTime.HomeTime(); |
249 aIntvlMicro = aNowTime.MicroSecondsFrom(iTimeSRPStart); |
294 aIntvlMicro = aNowTime.MicroSecondsFrom(iTimeSRPStart); |
250 LOG_VERBOSE2(_L("SRP active after %d ms\n"), (TInt)(aIntvlMicro.Int64()/1000)); |
295 LOG_VERBOSE2(_L("SRP active after %d ms\n"), (TInt)(aIntvlMicro.Int64()/1000)); |
|
296 if(gVerboseOutput) |
|
297 { |
|
298 OstTrace1(TRACE_VERBOSE, CTESTCASE0677_RUNSTEPL_DUP07, "SRP active after %d ms\n", (TInt)(aIntvlMicro.Int64()/1000));; |
|
299 } |
251 iCancelWhat = ECancelMessageNotify; |
300 iCancelWhat = ECancelMessageNotify; |
252 otgQueueOtgMessageRequest( iOTGMessage, iStatus ); |
301 otgQueueOtgMessageRequest( iOTGMessage, iStatus ); |
253 iCaseStep = EWaitForSRPTimeout; |
302 iCaseStep = EWaitForSRPTimeout; |
254 test.Printf(KMsgWaitingForSRPTimeout); |
303 test.Printf(KMsgWaitingForSRPTimeout); |
|
304 OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP08, KMsgWaitingForSRPTimeout); |
255 SetActive(); |
305 SetActive(); |
256 } |
306 } |
257 else |
307 else |
258 { |
308 { |
259 iCaseStep = EWaitForSRPInitiated; |
309 iCaseStep = EWaitForSRPInitiated; |
260 test.Printf(KMsgWaitingForSRPInitiated); |
310 test.Printf(KMsgWaitingForSRPInitiated); |
|
311 OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP09, KMsgWaitingForSRPInitiated); |
261 iStatus = KRequestPending; |
312 iStatus = KRequestPending; |
262 otgQueueOtgEventRequest( iOTGEvent, iStatus ); |
313 otgQueueOtgEventRequest( iOTGEvent, iStatus ); |
263 SetActive(); |
314 SetActive(); |
264 } |
315 } |
265 break; |
316 break; |
270 { |
321 { |
271 return TestFailed(KErrAbort, _L("SRP T/O NOT fired in time - FAILED!")); |
322 return TestFailed(KErrAbort, _L("SRP T/O NOT fired in time - FAILED!")); |
272 } |
323 } |
273 OtgMessageString(iOTGMessage, aDescription); |
324 OtgMessageString(iOTGMessage, aDescription); |
274 test.Printf(_L("Received message %d '%S' status(%d)\n"), iOTGMessage, &aDescription, completionCode); |
325 test.Printf(_L("Received message %d '%S' status(%d)\n"), iOTGMessage, &aDescription, completionCode); |
|
326 OstTraceExt3(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP10, "Received message %d '%S' status(%d)\n", iOTGMessage, aDescription, completionCode); |
275 if (RUsbOtgDriver::EMessageSrpTimeout == iOTGMessage) |
327 if (RUsbOtgDriver::EMessageSrpTimeout == iOTGMessage) |
276 { |
328 { |
277 iWDTimer->Cancel(); // Only cancel WD Timer here, when timed portion of test is over |
329 iWDTimer->Cancel(); // Only cancel WD Timer here, when timed portion of test is over |
278 // calc interval |
330 // calc interval |
279 TTimeIntervalMicroSeconds aIntvlMicro; |
331 TTimeIntervalMicroSeconds aIntvlMicro; |
280 TTime aNowTime; |
332 TTime aNowTime; |
281 aNowTime.HomeTime(); |
333 aNowTime.HomeTime(); |
282 aIntvlMicro = aNowTime.MicroSecondsFrom(iTimeSRPStart); |
334 aIntvlMicro = aNowTime.MicroSecondsFrom(iTimeSRPStart); |
283 LOG_VERBOSE2(_L("SRP times out after %d ms\n"), (TInt)(aIntvlMicro.Int64()/1000)); |
335 LOG_VERBOSE2(_L("SRP times out after %d ms\n"), (TInt)(aIntvlMicro.Int64()/1000)); |
|
336 if(gVerboseOutput) |
|
337 { |
|
338 OstTrace1(TRACE_VERBOSE, CTESTCASE0677_RUNSTEPL_DUP11, "SRP times out after %d ms\n", (TInt)(aIntvlMicro.Int64()/1000));; |
|
339 } |
284 // the correct value is 32 seconds, not 4.9 seconds as per the spec. |
340 // the correct value is 32 seconds, not 4.9 seconds as per the spec. |
285 |
341 |
286 iCaseStep = EIssueSRPObservedPrompt; |
342 iCaseStep = EIssueSRPObservedPrompt; |
287 SelfComplete(); |
343 SelfComplete(); |
288 } |
344 } |
289 else |
345 else |
290 { |
346 { |
291 iCaseStep = EWaitForSRPTimeout; |
347 iCaseStep = EWaitForSRPTimeout; |
292 test.Printf(KMsgWaitingForSRPTimeout); |
348 test.Printf(KMsgWaitingForSRPTimeout); |
|
349 OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP12, KMsgWaitingForSRPTimeout); |
293 iStatus = KRequestPending; |
350 iStatus = KRequestPending; |
294 otgQueueOtgMessageRequest( iOTGMessage, iStatus ); |
351 otgQueueOtgMessageRequest( iOTGMessage, iStatus ); |
295 SetActive(); |
352 SetActive(); |
296 } |
353 } |
297 break; |
354 break; |
298 |
355 |
299 case EIssueSRPObservedPrompt: |
356 case EIssueSRPObservedPrompt: |
300 { |
357 { |
301 test.Printf(_L("\nPress Y to verify that SRP was observed\n")); |
358 test.Printf(_L("\nPress Y to verify that SRP was observed\n")); |
|
359 OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP13, "\nPress Y to verify that SRP was observed\n"); |
302 test.Printf(_L("or any other key to fail test.\n")); |
360 test.Printf(_L("or any other key to fail test.\n")); |
|
361 OstTrace0(TRACE_NORMAL, CTESTCASE0677_RUNSTEPL_DUP14, "or any other key to fail test.\n"); |
303 RequestCharacter(); |
362 RequestCharacter(); |
304 iCaseStep = ECheckSRPObservedUserInput; |
363 iCaseStep = ECheckSRPObservedUserInput; |
305 break; |
364 break; |
306 } |
365 } |
307 |
366 |