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 "testcase0468.h" |
26 #include "testcase0468.h" |
|
27 #include "OstTraceDefinitions.h" |
|
28 #ifdef OST_TRACE_COMPILER_IN_USE |
|
29 #include "testcase0468Traces.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-0468"); |
38 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0468"); |
35 const TTestCaseFactoryReceipt<CTestCase0468> CTestCase0468::iFactoryReceipt(KTestCaseId); |
39 const TTestCaseFactoryReceipt<CTestCase0468> CTestCase0468::iFactoryReceipt(KTestCaseId); |
36 |
40 |
37 CTestCase0468* CTestCase0468::NewL(TBool aHost) |
41 CTestCase0468* CTestCase0468::NewL(TBool aHost) |
38 { |
42 { |
39 LOG_FUNC |
43 if(gVerboseOutput) |
|
44 { |
|
45 OstTraceFunctionEntry0(CTESTCASE0468_NEWL); |
|
46 } |
40 CTestCase0468* self = new (ELeave) CTestCase0468(aHost); |
47 CTestCase0468* self = new (ELeave) CTestCase0468(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 CTestCase0468::CTestCase0468(TBool aHost) |
55 CTestCase0468::CTestCase0468(TBool aHost) |
49 : CTestCaseRoot(KTestCaseId, aHost) |
56 : CTestCaseRoot(KTestCaseId, aHost) |
50 { |
57 { |
51 LOG_FUNC |
58 if(gVerboseOutput) |
|
59 { |
|
60 OstTraceFunctionEntry0(CTESTCASE0468_CTESTCASE0468); |
|
61 } |
52 |
62 |
53 } |
63 } |
54 |
64 |
55 |
65 |
56 /** |
66 /** |
57 ConstructL |
67 ConstructL |
58 */ |
68 */ |
59 void CTestCase0468::ConstructL() |
69 void CTestCase0468::ConstructL() |
60 { |
70 { |
61 LOG_FUNC |
71 if(gVerboseOutput) |
|
72 { |
|
73 OstTraceFunctionEntry0(CTESTCASE0468_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 CTestCase0468::~CTestCase0468() |
82 CTestCase0468::~CTestCase0468() |
70 { |
83 { |
71 LOG_FUNC |
84 if(gVerboseOutput) |
|
85 { |
|
86 OstTraceFunctionEntry0(CTESTCASE0468_DCTESTCASE0468); |
|
87 } |
72 |
88 |
73 Cancel(); |
89 Cancel(); |
74 delete iWDTimer; |
90 delete iWDTimer; |
75 |
91 |
76 } |
92 } |
77 |
93 |
78 |
94 |
79 void CTestCase0468::ExecuteTestCaseL() |
95 void CTestCase0468::ExecuteTestCaseL() |
80 { |
96 { |
81 LOG_FUNC |
97 if(gVerboseOutput) |
|
98 { |
|
99 OstTraceFunctionEntry0(CTESTCASE0468_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 CTestCase0468::DoCancel() |
111 void CTestCase0468::DoCancel() |
93 { |
112 { |
94 LOG_FUNC |
113 if(gVerboseOutput) |
|
114 { |
|
115 OstTraceFunctionEntry0(CTESTCASE0468_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 CTestCase0468::CancelKB(CTestCaseRoot *pThis) |
123 void CTestCase0468::CancelKB(CTestCaseRoot *pThis) |
102 { |
124 { |
103 LOG_FUNC |
125 if(gVerboseOutput) |
|
126 { |
|
127 OstTraceFunctionEntry0(CTESTCASE0468_CANCELKB); |
|
128 } |
104 CTestCase0468 * p = REINTERPRET_CAST(CTestCase0468 *,pThis); |
129 CTestCase0468 * p = REINTERPRET_CAST(CTestCase0468 *,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 CTestCase0468::CancelNotify(CTestCaseRoot *pThis) |
136 void CTestCase0468::CancelNotify(CTestCaseRoot *pThis) |
112 { |
137 { |
113 LOG_FUNC |
138 if(gVerboseOutput) |
|
139 { |
|
140 OstTraceFunctionEntry0(CTESTCASE0468_CANCELNOTIFY); |
|
141 } |
114 CTestCase0468 * p = REINTERPRET_CAST(CTestCase0468 *,pThis); |
142 CTestCase0468 * p = REINTERPRET_CAST(CTestCase0468 *,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 p->otgCancelOtgVbusNotification(); |
144 p->otgCancelOtgVbusNotification(); |
117 p->SelfComplete(KTestCaseWatchdogTO); |
145 p->SelfComplete(KTestCaseWatchdogTO); |
118 } |
146 } |
120 |
148 |
121 // This test result depends on all the ID detection tests and the VBus driving and dropping tests have not yet passed |
149 // This test result depends on all the ID detection tests and the VBus driving and dropping tests have not yet passed |
122 void CTestCase0468::DescribePreconditions() |
150 void CTestCase0468::DescribePreconditions() |
123 { |
151 { |
124 test.Printf(_L("Insert 'A' connector beforehand.\n")); |
152 test.Printf(_L("Insert 'A' connector beforehand.\n")); |
|
153 OstTrace0(TRACE_NORMAL, CTESTCASE0468_DESCRIBEPRECONDITIONS, "Insert 'A' connector beforehand.\n"); |
125 test.Printf(_L("ID_PIN detection and VBus driving tests must already pass.\n")); |
154 test.Printf(_L("ID_PIN detection and VBus driving tests must already pass.\n")); |
|
155 OstTrace0(TRACE_NORMAL, CTESTCASE0468_DESCRIBEPRECONDITIONS_DUP01, "ID_PIN detection and VBus driving tests must already pass.\n"); |
126 } |
156 } |
127 |
157 |
128 void CTestCase0468::ContinueAfter(TTimeIntervalMicroSeconds32 aMicroSecs, TCaseSteps aStep) |
158 void CTestCase0468::ContinueAfter(TTimeIntervalMicroSeconds32 aMicroSecs, TCaseSteps aStep) |
129 { |
159 { |
130 LOG_VERBOSE2(_L("Wait %dms before drop VBus"), (TInt)(aMicroSecs.Int()/1000)); |
160 LOG_VERBOSE2(_L("Wait %dms before drop VBus"), (TInt)(aMicroSecs.Int()/1000)); |
|
161 if(gVerboseOutput) |
|
162 { |
|
163 OstTrace1(TRACE_VERBOSE, CTESTCASE0468_CONTINUEAFTER, "Wait %dms before drop VBus", (TInt)(aMicroSecs.Int()/1000));; |
|
164 } |
131 iTimer.After(iStatus, aMicroSecs); |
165 iTimer.After(iStatus, aMicroSecs); |
132 iCaseStep = aStep; |
166 iCaseStep = aStep; |
133 SetActive(); |
167 SetActive(); |
134 } |
168 } |
135 |
169 |
136 // handle event completion |
170 // handle event completion |
137 void CTestCase0468::RunStepL() |
171 void CTestCase0468::RunStepL() |
138 { |
172 { |
139 LOG_FUNC |
173 if(gVerboseOutput) |
|
174 { |
|
175 OstTraceFunctionEntry0(CTESTCASE0468_RUNSTEPL); |
|
176 } |
140 // Obtain the completion code for this CActive obj. |
177 // Obtain the completion code for this CActive obj. |
141 TInt completionCode(iStatus.Int()); |
178 TInt completionCode(iStatus.Int()); |
142 TBuf<MAX_DSTRLEN> aDescription; |
179 TBuf<MAX_DSTRLEN> aDescription; |
143 TInt err(0); |
180 TInt err(0); |
144 |
181 |
153 SelfComplete(); |
190 SelfComplete(); |
154 break; |
191 break; |
155 } |
192 } |
156 // prompt to insert connector |
193 // prompt to insert connector |
157 test.Printf(KInsertAConnectorPrompt); |
194 test.Printf(KInsertAConnectorPrompt); |
|
195 OstTrace0(TRACE_NORMAL, CTESTCASE0468_RUNSTEPL_DUP01, KInsertAConnectorPrompt); |
158 test.Printf(KPressAnyKeyToContinue); |
196 test.Printf(KPressAnyKeyToContinue); |
|
197 OstTrace0(TRACE_NORMAL, CTESTCASE0468_RUNSTEPL_DUP02, KPressAnyKeyToContinue); |
159 RequestCharacter(); |
198 RequestCharacter(); |
160 break; |
199 break; |
161 |
200 |
162 case ELoadLdd: |
201 case ELoadLdd: |
163 // 1. load the LDD and init. |
202 // 1. load the LDD and init. |
179 // if doing this test in /AUTO mode, we would fail this now |
218 // if doing this test in /AUTO mode, we would fail this now |
180 // however if we can control ID_PIN through an API in future, we turn in on now. |
219 // however if we can control ID_PIN through an API in future, we turn in on now. |
181 if (!otgIdPinPresent()) |
220 if (!otgIdPinPresent()) |
182 { |
221 { |
183 test.Printf(KInsertAConnectorPrompt); |
222 test.Printf(KInsertAConnectorPrompt); |
|
223 OstTrace0(TRACE_NORMAL, CTESTCASE0468_RUNSTEPL_DUP03, KInsertAConnectorPrompt); |
184 test.Printf(KPressAnyKeyToContinue); |
224 test.Printf(KPressAnyKeyToContinue); |
|
225 OstTrace0(TRACE_NORMAL, CTESTCASE0468_RUNSTEPL_DUP04, KPressAnyKeyToContinue); |
185 RequestCharacter(); |
226 RequestCharacter(); |
186 |
227 |
187 iCaseStep = EDetectAPlug; |
228 iCaseStep = EDetectAPlug; |
188 } |
229 } |
189 else |
230 else |
208 |
249 |
209 case ELoopDriveVBus: |
250 case ELoopDriveVBus: |
210 // 4. DRIVE VBUS |
251 // 4. DRIVE VBUS |
211 iWDTimer->Cancel(); |
252 iWDTimer->Cancel(); |
212 test.Printf(_L("Drive VBus, iteration %d/%d\n"), OPEN_REPEATS-iRepeats+1, OPEN_REPEATS); |
253 test.Printf(_L("Drive VBus, iteration %d/%d\n"), OPEN_REPEATS-iRepeats+1, OPEN_REPEATS); |
|
254 OstTraceExt2(TRACE_NORMAL, CTESTCASE0468_RUNSTEPL_DUP05, "Drive VBus, iteration %d/%d\n", OPEN_REPEATS-iRepeats+1, OPEN_REPEATS); |
213 // test for VBus rise next |
255 // test for VBus rise next |
214 test.Printf(_L("Waiting for VBus Event\n")); |
256 test.Printf(_L("Waiting for VBus Event\n")); |
|
257 OstTrace0(TRACE_NORMAL, CTESTCASE0468_RUNSTEPL_DUP06, "Waiting for VBus Event\n"); |
215 iStatus = KRequestPending; |
258 iStatus = KRequestPending; |
216 otgQueueOtgVbusNotification( iOTGVBus, iStatus ); |
259 otgQueueOtgVbusNotification( iOTGVBus, iStatus ); |
217 |
260 |
218 // turn on VBus, since the call is not a Queing a-sync call we do this after the async call |
261 // turn on VBus, since the call is not a Queing a-sync call we do this after the async call |
219 err = otgBusRequest(); // ok to turn on VBus now |
262 err = otgBusRequest(); // ok to turn on VBus now |
227 break; |
270 break; |
228 |
271 |
229 case ELoopVerifyVBus: |
272 case ELoopVerifyVBus: |
230 // 5. get VBus rise event |
273 // 5. get VBus rise event |
231 LOG_VERBOSE2(_L("Post notification val=%d\n\n"), iOTGVBus); |
274 LOG_VERBOSE2(_L("Post notification val=%d\n\n"), iOTGVBus); |
|
275 if(gVerboseOutput) |
|
276 { |
|
277 OstTrace1(TRACE_VERBOSE, CTESTCASE0468_RUNSTEPL_DUP07, "Post notification val=%d\n\n", iOTGVBus);; |
|
278 } |
232 if (KTestCaseWatchdogTO == iStatus.Int()) |
279 if (KTestCaseWatchdogTO == iStatus.Int()) |
233 { |
280 { |
234 return TestFailed(KErrAbort, _L("Vbus rise not signalled in time - FAILED!")); |
281 return TestFailed(KErrAbort, _L("Vbus rise not signalled in time - FAILED!")); |
235 } |
282 } |
236 iWDTimer->Cancel(); |
283 iWDTimer->Cancel(); |