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 "testcase0467.h" |
26 #include "testcase0467.h" |
|
27 #include "OstTraceDefinitions.h" |
|
28 #ifdef OST_TRACE_COMPILER_IN_USE |
|
29 #include "testcase0467Traces.h" |
|
30 #endif |
27 |
31 |
28 |
32 |
29 |
33 |
30 // # times to repeat the steps (default=3) |
34 // # times to repeat the steps (default=3) |
31 #define INSERT_REPEATS gOpenIterations |
35 #define INSERT_REPEATS gOpenIterations |
35 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0467"); |
39 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0467"); |
36 const TTestCaseFactoryReceipt<CTestCase0467> CTestCase0467::iFactoryReceipt(KTestCaseId); |
40 const TTestCaseFactoryReceipt<CTestCase0467> CTestCase0467::iFactoryReceipt(KTestCaseId); |
37 |
41 |
38 CTestCase0467* CTestCase0467::NewL(TBool aHost) |
42 CTestCase0467* CTestCase0467::NewL(TBool aHost) |
39 { |
43 { |
40 LOG_FUNC |
44 if(gVerboseOutput) |
|
45 { |
|
46 OstTraceFunctionEntry0(CTESTCASE0467_NEWL); |
|
47 } |
41 CTestCase0467* self = new (ELeave) CTestCase0467(aHost); |
48 CTestCase0467* self = new (ELeave) CTestCase0467(aHost); |
42 CleanupStack::PushL(self); |
49 CleanupStack::PushL(self); |
43 self->ConstructL(); |
50 self->ConstructL(); |
44 CleanupStack::Pop(self); |
51 CleanupStack::Pop(self); |
45 return self; |
52 return self; |
47 |
54 |
48 |
55 |
49 CTestCase0467::CTestCase0467(TBool aHost) |
56 CTestCase0467::CTestCase0467(TBool aHost) |
50 : CTestCaseRoot(KTestCaseId, aHost) |
57 : CTestCaseRoot(KTestCaseId, aHost) |
51 { |
58 { |
52 LOG_FUNC |
59 if(gVerboseOutput) |
|
60 { |
|
61 OstTraceFunctionEntry0(CTESTCASE0467_CTESTCASE0467); |
|
62 } |
53 |
63 |
54 } |
64 } |
55 |
65 |
56 |
66 |
57 /** |
67 /** |
58 ConstructL |
68 ConstructL |
59 */ |
69 */ |
60 void CTestCase0467::ConstructL() |
70 void CTestCase0467::ConstructL() |
61 { |
71 { |
62 LOG_FUNC |
72 if(gVerboseOutput) |
|
73 { |
|
74 OstTraceFunctionEntry0(CTESTCASE0467_CONSTRUCTL); |
|
75 } |
63 iRepeats = INSERT_REPEATS; |
76 iRepeats = INSERT_REPEATS; |
64 iWDTimer = CTestCaseWatchdog::NewL(); |
77 iWDTimer = CTestCaseWatchdog::NewL(); |
65 |
78 |
66 BaseConstructL(); |
79 BaseConstructL(); |
67 } |
80 } |
68 |
81 |
69 |
82 |
70 CTestCase0467::~CTestCase0467() |
83 CTestCase0467::~CTestCase0467() |
71 { |
84 { |
72 LOG_FUNC |
85 if(gVerboseOutput) |
|
86 { |
|
87 OstTraceFunctionEntry0(CTESTCASE0467_DCTESTCASE0467); |
|
88 } |
73 |
89 |
74 Cancel(); |
90 Cancel(); |
75 delete iWDTimer; |
91 delete iWDTimer; |
76 |
92 |
77 } |
93 } |
78 |
94 |
79 |
95 |
80 void CTestCase0467::ExecuteTestCaseL() |
96 void CTestCase0467::ExecuteTestCaseL() |
81 { |
97 { |
82 LOG_FUNC |
98 if(gVerboseOutput) |
|
99 { |
|
100 OstTraceFunctionEntry0(CTESTCASE0467_EXECUTETESTCASEL); |
|
101 } |
83 iCaseStep = EPreconditions; |
102 iCaseStep = EPreconditions; |
84 |
103 |
85 iRepeats = KOperationRetriesMax; // VBus event rise retries |
104 iRepeats = KOperationRetriesMax; // VBus event rise retries |
86 |
105 |
87 CActiveScheduler::Add(this); |
106 CActiveScheduler::Add(this); |
109 } |
131 } |
110 |
132 |
111 |
133 |
112 void CTestCase0467::CancelIdPin(CTestCaseRoot *pThis) |
134 void CTestCase0467::CancelIdPin(CTestCaseRoot *pThis) |
113 { |
135 { |
114 LOG_FUNC |
136 if(gVerboseOutput) |
|
137 { |
|
138 OstTraceFunctionEntry0(CTESTCASE0467_CANCELIDPIN); |
|
139 } |
115 |
140 |
116 CTestCase0467 * p = REINTERPRET_CAST(CTestCase0467 *,pThis); |
141 CTestCase0467 * p = REINTERPRET_CAST(CTestCase0467 *,pThis); |
117 // cancel any pending call, and then complete our active obj with a timeout value |
142 // cancel any pending call, and then complete our active obj with a timeout value |
118 p->otgCancelOtgIdPinNotification(); |
143 p->otgCancelOtgIdPinNotification(); |
119 p->SelfComplete(KTestCaseWatchdogTO); |
144 p->SelfComplete(KTestCaseWatchdogTO); |
122 |
147 |
123 // This test result depends on all the ID detection tests and the VBus driving and dropping tests have not yet passed |
148 // This test result depends on all the ID detection tests and the VBus driving and dropping tests have not yet passed |
124 void CTestCase0467::DescribePreconditions() |
149 void CTestCase0467::DescribePreconditions() |
125 { |
150 { |
126 test.Printf(_L("Remove 'A' connector beforehand.\n")); |
151 test.Printf(_L("Remove 'A' connector beforehand.\n")); |
|
152 OstTrace0(TRACE_NORMAL, CTESTCASE0467_DESCRIBEPRECONDITIONS, "Remove 'A' connector beforehand.\n"); |
127 test.Printf(_L("ID_PIN detection and VBus driving tests must already pass.\n")); |
153 test.Printf(_L("ID_PIN detection and VBus driving tests must already pass.\n")); |
|
154 OstTrace0(TRACE_NORMAL, CTESTCASE0467_DESCRIBEPRECONDITIONS_DUP01, "ID_PIN detection and VBus driving tests must already pass.\n"); |
128 } |
155 } |
129 |
156 |
130 |
157 |
131 // handle event completion |
158 // handle event completion |
132 void CTestCase0467::RunStepL() |
159 void CTestCase0467::RunStepL() |
133 { |
160 { |
134 LOG_FUNC |
161 if(gVerboseOutput) |
|
162 { |
|
163 OstTraceFunctionEntry0(CTESTCASE0467_RUNSTEPL); |
|
164 } |
135 // Obtain the completion code for this CActive obj. |
165 // Obtain the completion code for this CActive obj. |
136 TInt completionCode(iStatus.Int()); |
166 TInt completionCode(iStatus.Int()); |
137 TBuf<MAX_DSTRLEN> aDescription; |
167 TBuf<MAX_DSTRLEN> aDescription; |
138 |
168 |
139 switch(iCaseStep) |
169 switch(iCaseStep) |
146 SelfComplete(); |
176 SelfComplete(); |
147 break; |
177 break; |
148 } |
178 } |
149 // prompt to remove connector |
179 // prompt to remove connector |
150 test.Printf(KRemoveAConnectorPrompt); |
180 test.Printf(KRemoveAConnectorPrompt); |
|
181 OstTrace0(TRACE_NORMAL, CTESTCASE0467_RUNSTEPL_DUP01, KRemoveAConnectorPrompt); |
151 test.Printf(KPressAnyKeyToContinue); |
182 test.Printf(KPressAnyKeyToContinue); |
|
183 OstTrace0(TRACE_NORMAL, CTESTCASE0467_RUNSTEPL_DUP02, KPressAnyKeyToContinue); |
152 RequestCharacter(); |
184 RequestCharacter(); |
153 break; |
185 break; |
154 |
186 |
155 case ELoadLdd: |
187 case ELoadLdd: |
156 // 1. load the LDD and init. |
188 // 1. load the LDD and init. |
164 SelfComplete(); |
196 SelfComplete(); |
165 break; |
197 break; |
166 |
198 |
167 case ERepeatLoop: // 2 |
199 case ERepeatLoop: // 2 |
168 test.Printf(_L("Repeat test %d/%d\n"), INSERT_REPEATS-iRepeats+1, INSERT_REPEATS); |
200 test.Printf(_L("Repeat test %d/%d\n"), INSERT_REPEATS-iRepeats+1, INSERT_REPEATS); |
|
201 OstTraceExt2(TRACE_NORMAL, CTESTCASE0467_RUNSTEPL_DUP03, "Repeat test %d/%d\n", INSERT_REPEATS-iRepeats+1, INSERT_REPEATS); |
169 |
202 |
170 if (--iRepeats) |
203 if (--iRepeats) |
171 iCaseStep = EWaitForIDPresent; |
204 iCaseStep = EWaitForIDPresent; |
172 else |
205 else |
173 iCaseStep = EUnloadLdd; |
206 iCaseStep = EUnloadLdd; |
175 break; |
208 break; |
176 |
209 |
177 case EWaitForIDPresent: |
210 case EWaitForIDPresent: |
178 // 3. prompt for insertion |
211 // 3. prompt for insertion |
179 test.Printf(KInsertAConnectorPrompt); |
212 test.Printf(KInsertAConnectorPrompt); |
|
213 OstTrace0(TRACE_NORMAL, CTESTCASE0467_RUNSTEPL_DUP04, KInsertAConnectorPrompt); |
180 otgQueueOtgIdPinNotification( iOTGIdPin, iStatus ); |
214 otgQueueOtgIdPinNotification( iOTGIdPin, iStatus ); |
181 |
215 |
182 SetActive(); |
216 SetActive(); |
183 iCaseStep = EVerifyIDPresent; |
217 iCaseStep = EVerifyIDPresent; |
184 iDetectionRetry = 0; |
218 iDetectionRetry = 0; |
185 break; |
219 break; |
186 |
220 |
187 case EVerifyIDPresent: |
221 case EVerifyIDPresent: |
188 // 4. detect id_pin event |
222 // 4. detect id_pin event |
189 LOG_VERBOSE1(_L("STEP4 - detect id_pin event 'A'\n")); |
223 LOG_VERBOSE1(_L("STEP4 - detect id_pin event 'A'\n")); |
|
224 if(gVerboseOutput) |
|
225 { |
|
226 OstTrace0(TRACE_VERBOSE, CTESTCASE0467_RUNSTEPL_DUP05, "STEP4 - detect id_pin event 'A'\n");; |
|
227 } |
190 |
228 |
191 // retrieve the current ID_PIN value |
229 // retrieve the current ID_PIN value |
192 otgQueueOtgIdPinNotification( iOTGIdPin, iStatus ); |
230 otgQueueOtgIdPinNotification( iOTGIdPin, iStatus ); |
193 otgCancelOtgIdPinNotification(); |
231 otgCancelOtgIdPinNotification(); |
194 User::WaitForRequest(iStatus); // swallow the cancellation event (serves to test that it does cancel) |
232 User::WaitForRequest(iStatus); // swallow the cancellation event (serves to test that it does cancel) |
222 break; |
260 break; |
223 |
261 |
224 case EWaitForIDGone: |
262 case EWaitForIDGone: |
225 // 5. prompt for insertion |
263 // 5. prompt for insertion |
226 test.Printf(KRemoveAConnectorPrompt); |
264 test.Printf(KRemoveAConnectorPrompt); |
|
265 OstTrace0(TRACE_NORMAL, CTESTCASE0467_RUNSTEPL_DUP06, KRemoveAConnectorPrompt); |
227 otgQueueOtgIdPinNotification( iOTGIdPin, iStatus ); |
266 otgQueueOtgIdPinNotification( iOTGIdPin, iStatus ); |
228 SetActive(); |
267 SetActive(); |
229 iCaseStep = EVerifyIDGone; |
268 iCaseStep = EVerifyIDGone; |
230 break; |
269 break; |
231 |
270 |
232 case EVerifyIDGone: |
271 case EVerifyIDGone: |
233 // 6. detect id_pin gone event |
272 // 6. detect id_pin gone event |
234 LOG_VERBOSE1(_L("STEP4 - detect id_pin remove event 'B'\n")); |
273 LOG_VERBOSE1(_L("STEP4 - detect id_pin remove event 'B'\n")); |
|
274 if(gVerboseOutput) |
|
275 { |
|
276 OstTrace0(TRACE_VERBOSE, CTESTCASE0467_RUNSTEPL_DUP07, "STEP4 - detect id_pin remove event 'B'\n");; |
|
277 } |
235 test.Printf(_L("ID_PIN=%d\n"), iOTGIdPin); |
278 test.Printf(_L("ID_PIN=%d\n"), iOTGIdPin); |
|
279 OstTrace1(TRACE_NORMAL, CTESTCASE0467_RUNSTEPL_DUP08, "ID_PIN=%d\n", iOTGIdPin); |
236 |
280 |
237 User::After(5000); // 5ms |
281 User::After(5000); // 5ms |
238 otgQueueOtgIdPinNotification( iOTGIdPin, iStatus ); |
282 otgQueueOtgIdPinNotification( iOTGIdPin, iStatus ); |
239 otgCancelOtgIdPinNotification(); |
283 otgCancelOtgIdPinNotification(); |
240 User::WaitForRequest(iStatus); // swallow it |
284 User::WaitForRequest(iStatus); // swallow it |
241 test.Printf(_L("ID_PIN=%d\n"), iOTGIdPin); |
285 test.Printf(_L("ID_PIN=%d\n"), iOTGIdPin); |
|
286 OstTrace1(TRACE_NORMAL, CTESTCASE0467_RUNSTEPL_DUP09, "ID_PIN=%d\n", iOTGIdPin); |
242 |
287 |
243 if (iOTGIdPin != RUsbOtgDriver::EIdPinBPlug) |
288 if (iOTGIdPin != RUsbOtgDriver::EIdPinBPlug) |
244 { |
289 { |
245 if (iDetectionRetry++ < 3) |
290 if (iDetectionRetry++ < 3) |
246 { |
291 { |