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