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