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". |
23 #include <e32base_private.h> |
23 #include <e32base_private.h> |
24 #include <e32Test.h> // RTest headder |
24 #include <e32Test.h> // RTest headder |
25 #include "testcaseroot.h" |
25 #include "testcaseroot.h" |
26 #include "testcasewd.h" |
26 #include "testcasewd.h" |
27 #include "testcase0461.h" |
27 #include "testcase0461.h" |
28 #include "OstTraceDefinitions.h" |
|
29 #ifdef OST_TRACE_COMPILER_IN_USE |
|
30 #include "testcase0461Traces.h" |
|
31 #endif |
|
32 |
28 |
33 |
29 |
34 |
30 |
35 // the name below is used to add a pointer to our construction method to a pointer MAP in |
31 // the name below is used to add a pointer to our construction method to a pointer MAP in |
36 // the class factory |
32 // the class factory |
37 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0461"); |
33 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0461"); |
38 const TTestCaseFactoryReceipt<CTestCase0461> CTestCase0461::iFactoryReceipt(KTestCaseId); |
34 const TTestCaseFactoryReceipt<CTestCase0461> CTestCase0461::iFactoryReceipt(KTestCaseId); |
39 |
35 |
40 CTestCase0461* CTestCase0461::NewL(TBool aHost) |
36 CTestCase0461* CTestCase0461::NewL(TBool aHost) |
41 { |
37 { |
42 if(gVerboseOutput) |
38 LOG_FUNC |
43 { |
|
44 OstTraceFunctionEntry0(CTESTCASE0461_NEWL); |
|
45 } |
|
46 CTestCase0461* self = new (ELeave) CTestCase0461(aHost); |
39 CTestCase0461* self = new (ELeave) CTestCase0461(aHost); |
47 CleanupStack::PushL(self); |
40 CleanupStack::PushL(self); |
48 self->ConstructL(); |
41 self->ConstructL(); |
49 CleanupStack::Pop(self); |
42 CleanupStack::Pop(self); |
50 return self; |
43 return self; |
52 |
45 |
53 |
46 |
54 CTestCase0461::CTestCase0461(TBool aHost) |
47 CTestCase0461::CTestCase0461(TBool aHost) |
55 : CTestCaseRoot(KTestCaseId, aHost) |
48 : CTestCaseRoot(KTestCaseId, aHost) |
56 { |
49 { |
57 if(gVerboseOutput) |
50 LOG_FUNC |
58 { |
|
59 OstTraceFunctionEntry0(CTESTCASE0461_CTESTCASE0461); |
|
60 } |
|
61 |
51 |
62 } |
52 } |
63 |
53 |
64 |
54 |
65 /** |
55 /** |
66 ConstructL |
56 ConstructL |
67 */ |
57 */ |
68 void CTestCase0461::ConstructL() |
58 void CTestCase0461::ConstructL() |
69 { |
59 { |
70 if(gVerboseOutput) |
60 LOG_FUNC |
71 { |
|
72 OstTraceFunctionEntry0(CTESTCASE0461_CONSTRUCTL); |
|
73 } |
|
74 iRepeats = KOperationRetriesMax; |
61 iRepeats = KOperationRetriesMax; |
75 BaseConstructL(); |
62 BaseConstructL(); |
76 |
63 |
77 iWDTimer = CTestCaseWatchdog::NewL(); |
64 iWDTimer = CTestCaseWatchdog::NewL(); |
78 } |
65 } |
79 |
66 |
80 |
67 |
81 CTestCase0461::~CTestCase0461() |
68 CTestCase0461::~CTestCase0461() |
82 { |
69 { |
83 if(gVerboseOutput) |
70 LOG_FUNC |
84 { |
|
85 OstTraceFunctionEntry0(CTESTCASE0461_DCTESTCASE0461); |
|
86 } |
|
87 |
71 |
88 Cancel(); |
72 Cancel(); |
89 delete iWDTimer; |
73 delete iWDTimer; |
90 } |
74 } |
91 |
75 |
92 |
76 |
93 void CTestCase0461::ExecuteTestCaseL() |
77 void CTestCase0461::ExecuteTestCaseL() |
94 { |
78 { |
95 if(gVerboseOutput) |
79 LOG_FUNC |
96 { |
|
97 OstTraceFunctionEntry0(CTESTCASE0461_EXECUTETESTCASEL); |
|
98 } |
|
99 iCaseStep = ELoadLdd; |
80 iCaseStep = ELoadLdd; |
100 |
81 |
101 CActiveScheduler::Add(this); |
82 CActiveScheduler::Add(this); |
102 SelfComplete(); |
83 SelfComplete(); |
103 |
84 |
132 } |
109 } |
133 |
110 |
134 // handle event completion |
111 // handle event completion |
135 void CTestCase0461::RunStepL() |
112 void CTestCase0461::RunStepL() |
136 { |
113 { |
137 if(gVerboseOutput) |
114 LOG_FUNC |
138 { |
|
139 OstTraceFunctionEntry0(CTESTCASE0461_RUNSTEPL); |
|
140 } |
|
141 // Obtain the completion code for this CActive obj. |
115 // Obtain the completion code for this CActive obj. |
142 TInt completionCode(iStatus.Int()); |
116 TInt completionCode(iStatus.Int()); |
143 TBuf<MAX_DSTRLEN> aDescription; |
117 TBuf<MAX_DSTRLEN> aDescription; |
144 |
118 |
145 switch(iCaseStep) |
119 switch(iCaseStep) |
152 SelfComplete(); |
126 SelfComplete(); |
153 break; |
127 break; |
154 } |
128 } |
155 // prompt to insert connector |
129 // prompt to insert connector |
156 test.Printf(KInsertAConnectorPrompt); |
130 test.Printf(KInsertAConnectorPrompt); |
157 OstTrace0(TRACE_NORMAL, CTESTCASE0461_RUNSTEPL_DUP01, KInsertAConnectorPrompt); |
|
158 test.Printf(KPressAnyKeyToContinue); |
131 test.Printf(KPressAnyKeyToContinue); |
159 OstTrace0(TRACE_NORMAL, CTESTCASE0461_RUNSTEPL_DUP02, KPressAnyKeyToContinue); |
|
160 RequestCharacter(); |
132 RequestCharacter(); |
161 break; |
133 break; |
162 |
134 |
163 case ELoadLdd: |
135 case ELoadLdd: |
164 if (!StepLoadLDD()) |
136 if (!StepLoadLDD()) |
173 |
145 |
174 // 2. Prepare to wait on ID_PIN |
146 // 2. Prepare to wait on ID_PIN |
175 case ERegisterForEvents: |
147 case ERegisterForEvents: |
176 // prompt to remove connector |
148 // prompt to remove connector |
177 test.Printf(KRemoveAConnectorPrompt); |
149 test.Printf(KRemoveAConnectorPrompt); |
178 OstTrace0(TRACE_NORMAL, CTESTCASE0461_RUNSTEPL_DUP03, KRemoveAConnectorPrompt); |
|
179 if (iDequeAttempts > 3) |
150 if (iDequeAttempts > 3) |
180 { |
151 { |
181 return (TestFailed(KErrCorrupt, _L("<Error> too many irrelevant/incorrect events"))); |
152 return (TestFailed(KErrCorrupt, _L("<Error> too many irrelevant/incorrect events"))); |
182 } |
153 } |
183 |
154 |
206 } |
177 } |
207 }// drop through to next step |
178 }// drop through to next step |
208 case EGetAndCancelEvent: //4. |
179 case EGetAndCancelEvent: //4. |
209 OtgEventString(iOTGEvent, aDescription); |
180 OtgEventString(iOTGEvent, aDescription); |
210 test.Printf(_L("Received event %d '%S' status(%d)"), iOTGEvent, &aDescription, completionCode); |
181 test.Printf(_L("Received event %d '%S' status(%d)"), iOTGEvent, &aDescription, completionCode); |
211 OstTraceExt3(TRACE_NORMAL, CTESTCASE0461_RUNSTEPL_DUP04, "Received event %d '%S' status(%d)", iOTGEvent, aDescription, completionCode); |
|
212 if (RUsbOtgDriver::EEventAPlugRemoved == iOTGEvent) |
182 if (RUsbOtgDriver::EEventAPlugRemoved == iOTGEvent) |
213 { |
183 { |
214 otgQueueOtgEventRequest( iOTGEvent, iStatus); |
184 otgQueueOtgEventRequest( iOTGEvent, iStatus); |
215 // cancel it and then go into a loop |
185 // cancel it and then go into a loop |
216 otgCancelOtgEventRequest(); |
186 otgCancelOtgEventRequest(); |
240 // 6 |
210 // 6 |
241 case EInsertA: // insert 'A' plug |
211 case EInsertA: // insert 'A' plug |
242 iWDTimer->Cancel(); |
212 iWDTimer->Cancel(); |
243 iConsole->ReadCancel(); |
213 iConsole->ReadCancel(); |
244 test.Printf(KInsertAConnectorPrompt); |
214 test.Printf(KInsertAConnectorPrompt); |
245 OstTrace0(TRACE_NORMAL, CTESTCASE0461_RUNSTEPL_DUP05, KInsertAConnectorPrompt); |
|
246 iCaseStep = ERemoveA; |
215 iCaseStep = ERemoveA; |
247 test.Printf(KPressAnyKeyToContinue); |
216 test.Printf(KPressAnyKeyToContinue); |
248 OstTrace0(TRACE_NORMAL, CTESTCASE0461_RUNSTEPL_DUP06, KPressAnyKeyToContinue); |
|
249 |
217 |
250 RequestCharacter(); |
218 RequestCharacter(); |
251 iWDTimer->IssueRequest(KDelayDurationForUserActivityMS, this, &CancelKB); |
219 iWDTimer->IssueRequest(KDelayDurationForUserActivityMS, this, &CancelKB); |
252 |
220 |
253 iExpectedEvents++; |
221 iExpectedEvents++; |
256 // 7. remove 'A' plug |
224 // 7. remove 'A' plug |
257 case ERemoveA: |
225 case ERemoveA: |
258 iWDTimer->Cancel(); |
226 iWDTimer->Cancel(); |
259 iConsole->ReadCancel(); |
227 iConsole->ReadCancel(); |
260 test.Printf(KRemoveAConnectorPrompt); |
228 test.Printf(KRemoveAConnectorPrompt); |
261 OstTrace0(TRACE_NORMAL, CTESTCASE0461_RUNSTEPL_DUP07, KRemoveAConnectorPrompt); |
|
262 if (iRepeats-- >0) |
229 if (iRepeats-- >0) |
263 { |
230 { |
264 // Do it again please |
231 // Do it again please |
265 iCaseStep = EInsertA; |
232 iCaseStep = EInsertA; |
266 } |
233 } |
267 else |
234 else |
268 { // got enough events in Q, let's count them up |
235 { // got enough events in Q, let's count them up |
269 iCaseStep = ETallyEvents; |
236 iCaseStep = ETallyEvents; |
270 } |
237 } |
271 test.Printf(KPressAnyKeyToContinue); |
238 test.Printf(KPressAnyKeyToContinue); |
272 OstTrace0(TRACE_NORMAL, CTESTCASE0461_RUNSTEPL_DUP08, KPressAnyKeyToContinue); |
|
273 |
239 |
274 RequestCharacter(); |
240 RequestCharacter(); |
275 iWDTimer->IssueRequest(KDelayDurationForUserActivityMS, this, &CancelKB); |
241 iWDTimer->IssueRequest(KDelayDurationForUserActivityMS, this, &CancelKB); |
276 iExpectedEvents++; |
242 iExpectedEvents++; |
277 break; |
243 break; |