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 "testcase0465.h" |
26 #include "testcase0465.h" |
|
27 #include "OstTraceDefinitions.h" |
|
28 #ifdef OST_TRACE_COMPILER_IN_USE |
|
29 #include "testcase0465Traces.h" |
|
30 #endif |
27 |
31 |
28 |
32 |
29 |
33 |
30 |
34 |
31 // the name below is used to add a pointer to our construction method to a pointer MAP in |
35 // the name below is used to add a pointer to our construction method to a pointer MAP in |
33 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0465"); |
37 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0465"); |
34 const TTestCaseFactoryReceipt<CTestCase0465> CTestCase0465::iFactoryReceipt(KTestCaseId); |
38 const TTestCaseFactoryReceipt<CTestCase0465> CTestCase0465::iFactoryReceipt(KTestCaseId); |
35 |
39 |
36 CTestCase0465* CTestCase0465::NewL(TBool aHost) |
40 CTestCase0465* CTestCase0465::NewL(TBool aHost) |
37 { |
41 { |
38 LOG_FUNC |
42 if(gVerboseOutput) |
|
43 { |
|
44 OstTraceFunctionEntry0(CTESTCASE0465_NEWL); |
|
45 } |
39 CTestCase0465* self = new (ELeave) CTestCase0465(aHost); |
46 CTestCase0465* self = new (ELeave) CTestCase0465(aHost); |
40 CleanupStack::PushL(self); |
47 CleanupStack::PushL(self); |
41 self->ConstructL(); |
48 self->ConstructL(); |
42 CleanupStack::Pop(self); |
49 CleanupStack::Pop(self); |
43 return self; |
50 return self; |
45 |
52 |
46 |
53 |
47 CTestCase0465::CTestCase0465(TBool aHost) |
54 CTestCase0465::CTestCase0465(TBool aHost) |
48 : CTestCaseRoot(KTestCaseId, aHost) |
55 : CTestCaseRoot(KTestCaseId, aHost) |
49 { |
56 { |
50 LOG_FUNC |
57 if(gVerboseOutput) |
|
58 { |
|
59 OstTraceFunctionEntry0(CTESTCASE0465_CTESTCASE0465); |
|
60 } |
51 |
61 |
52 } |
62 } |
53 |
63 |
54 |
64 |
55 /** |
65 /** |
56 ConstructL |
66 ConstructL |
57 */ |
67 */ |
58 void CTestCase0465::ConstructL() |
68 void CTestCase0465::ConstructL() |
59 { |
69 { |
60 LOG_FUNC |
70 if(gVerboseOutput) |
|
71 { |
|
72 OstTraceFunctionEntry0(CTESTCASE0465_CONSTRUCTL); |
|
73 } |
61 iWDTimer = CTestCaseWatchdog::NewL(); |
74 iWDTimer = CTestCaseWatchdog::NewL(); |
62 |
75 |
63 BaseConstructL(); |
76 BaseConstructL(); |
64 } |
77 } |
65 |
78 |
66 |
79 |
67 CTestCase0465::~CTestCase0465() |
80 CTestCase0465::~CTestCase0465() |
68 { |
81 { |
69 LOG_FUNC |
82 if(gVerboseOutput) |
|
83 { |
|
84 OstTraceFunctionEntry0(CTESTCASE0465_DCTESTCASE0465); |
|
85 } |
70 |
86 |
71 Cancel(); |
87 Cancel(); |
72 delete iWDTimer; |
88 delete iWDTimer; |
73 |
89 |
74 } |
90 } |
75 |
91 |
76 |
92 |
77 void CTestCase0465::ExecuteTestCaseL() |
93 void CTestCase0465::ExecuteTestCaseL() |
78 { |
94 { |
79 LOG_FUNC |
95 if(gVerboseOutput) |
|
96 { |
|
97 OstTraceFunctionEntry0(CTESTCASE0465_EXECUTETESTCASEL); |
|
98 } |
80 iCaseStep = EPreconditions; |
99 iCaseStep = EPreconditions; |
81 |
100 |
82 iRepeats = KOperationRetriesMax; // VBus event rise retries |
101 iRepeats = KOperationRetriesMax; // VBus event rise retries |
83 |
102 |
84 CActiveScheduler::Add(this); |
103 CActiveScheduler::Add(this); |
116 |
138 |
117 // This test result depends on all the ID detection tests and the VBus driving and dropping tests have not yet passed |
139 // This test result depends on all the ID detection tests and the VBus driving and dropping tests have not yet passed |
118 void CTestCase0465::DescribePreconditions() |
140 void CTestCase0465::DescribePreconditions() |
119 { |
141 { |
120 test.Printf(_L("BEFORE running this test\n")); |
142 test.Printf(_L("BEFORE running this test\n")); |
|
143 OstTrace0(TRACE_NORMAL, CTESTCASE0465_DESCRIBEPRECONDITIONS, "BEFORE running this test\n"); |
121 test.Printf(_L("\n")); |
144 test.Printf(_L("\n")); |
|
145 OstTrace0(TRACE_NORMAL, CTESTCASE0465_DESCRIBEPRECONDITIONS_DUP01, "\n"); |
122 test.Printf(_L("Insert 'A' connector\n")); |
146 test.Printf(_L("Insert 'A' connector\n")); |
|
147 OstTrace0(TRACE_NORMAL, CTESTCASE0465_DESCRIBEPRECONDITIONS_DUP02, "Insert 'A' connector\n"); |
123 test.Printf(_L("\n")); |
148 test.Printf(_L("\n")); |
|
149 OstTrace0(TRACE_NORMAL, CTESTCASE0465_DESCRIBEPRECONDITIONS_DUP03, "\n"); |
124 test.Printf(_L("Confirm passing tests\n")); |
150 test.Printf(_L("Confirm passing tests\n")); |
|
151 OstTrace0(TRACE_NORMAL, CTESTCASE0465_DESCRIBEPRECONDITIONS_DUP04, "Confirm passing tests\n"); |
125 test.Printf(_L("\n")); |
152 test.Printf(_L("\n")); |
|
153 OstTrace0(TRACE_NORMAL, CTESTCASE0465_DESCRIBEPRECONDITIONS_DUP05, "\n"); |
126 test.Printf(_L("ID_PIN detection\n")); |
154 test.Printf(_L("ID_PIN detection\n")); |
|
155 OstTrace0(TRACE_NORMAL, CTESTCASE0465_DESCRIBEPRECONDITIONS_DUP06, "ID_PIN detection\n"); |
127 test.Printf(_L("VBus Driving\n")); |
156 test.Printf(_L("VBus Driving\n")); |
|
157 OstTrace0(TRACE_NORMAL, CTESTCASE0465_DESCRIBEPRECONDITIONS_DUP07, "VBus Driving\n"); |
128 test.Printf(_L("\n")); |
158 test.Printf(_L("\n")); |
|
159 OstTrace0(TRACE_NORMAL, CTESTCASE0465_DESCRIBEPRECONDITIONS_DUP08, "\n"); |
129 } |
160 } |
130 |
161 |
131 |
162 |
132 // handle event completion |
163 // handle event completion |
133 void CTestCase0465::RunStepL() |
164 void CTestCase0465::RunStepL() |
134 { |
165 { |
135 LOG_FUNC |
166 if(gVerboseOutput) |
|
167 { |
|
168 OstTraceFunctionEntry0(CTESTCASE0465_RUNSTEPL); |
|
169 } |
136 // Obtain the completion code for this CActive obj. |
170 // Obtain the completion code for this CActive obj. |
137 TInt completionCode(iStatus.Int()); |
171 TInt completionCode(iStatus.Int()); |
138 TBuf<MAX_DSTRLEN> aDescription; |
172 TBuf<MAX_DSTRLEN> aDescription; |
139 TInt err(0); |
173 TInt err(0); |
140 |
174 |
148 SelfComplete(); |
182 SelfComplete(); |
149 break; |
183 break; |
150 } |
184 } |
151 // prompt to insert connector |
185 // prompt to insert connector |
152 test.Printf(_L("\n")); |
186 test.Printf(_L("\n")); |
|
187 OstTrace0(TRACE_NORMAL, CTESTCASE0465_RUNSTEPL_DUP01, "\n"); |
153 test.Printf(KInsertAConnectorPrompt); |
188 test.Printf(KInsertAConnectorPrompt); |
154 test.Printf(_L("\n")); |
189 OstTrace0(TRACE_NORMAL, CTESTCASE0465_RUNSTEPL_DUP02, KInsertAConnectorPrompt); |
|
190 test.Printf(_L("\n")); |
|
191 OstTrace0(TRACE_NORMAL, CTESTCASE0465_RUNSTEPL_DUP03, "\n"); |
155 test.Printf(KPressAnyKeyToContinue); |
192 test.Printf(KPressAnyKeyToContinue); |
156 test.Printf(_L("\n")); |
193 OstTrace0(TRACE_NORMAL, CTESTCASE0465_RUNSTEPL_DUP04, KPressAnyKeyToContinue); |
|
194 test.Printf(_L("\n")); |
|
195 OstTrace0(TRACE_NORMAL, CTESTCASE0465_RUNSTEPL_DUP05, "\n"); |
157 RequestCharacter(); |
196 RequestCharacter(); |
158 break; |
197 break; |
159 |
198 |
160 case ELoadLdd: |
199 case ELoadLdd: |
161 // 1. load the LDD and init. |
200 // 1. load the LDD and init. |
189 case EVerifyVBus: |
228 case EVerifyVBus: |
190 // 3. get VBus rise event |
229 // 3. get VBus rise event |
191 iCaseStep = EUnloadLdd; |
230 iCaseStep = EUnloadLdd; |
192 OtgEventString(iOTGEvent, aDescription); |
231 OtgEventString(iOTGEvent, aDescription); |
193 test.Printf(_L("Received event %d '%S' status(%d)\n"), iOTGEvent, &aDescription, completionCode); |
232 test.Printf(_L("Received event %d '%S' status(%d)\n"), iOTGEvent, &aDescription, completionCode); |
|
233 OstTraceExt3(TRACE_NORMAL, CTESTCASE0465_RUNSTEPL_DUP06, "Received event %d '%S' status(%d)\n", iOTGEvent, aDescription, completionCode); |
194 |
234 |
195 if (iOTGEvent != RUsbOtgDriver::EEventVbusRaised) |
235 if (iOTGEvent != RUsbOtgDriver::EEventVbusRaised) |
196 { |
236 { |
197 iCaseStep = EVerifyVBus; |
237 iCaseStep = EVerifyVBus; |
198 iRepeats--; |
238 iRepeats--; |
219 |
260 |
220 // wait for 100 ms to allow the stack time to settle |
261 // wait for 100 ms to allow the stack time to settle |
221 User::After(100000); |
262 User::After(100000); |
222 |
263 |
223 test.Printf(_L("Use meter or oscilloscope\n")); |
264 test.Printf(_L("Use meter or oscilloscope\n")); |
|
265 OstTrace0(TRACE_NORMAL, CTESTCASE0465_RUNSTEPL_DUP08, "Use meter or oscilloscope\n"); |
224 test.Printf(_L("to measure VBUS, which should\n")); |
266 test.Printf(_L("to measure VBUS, which should\n")); |
|
267 OstTrace0(TRACE_NORMAL, CTESTCASE0465_RUNSTEPL_DUP09, "to measure VBUS, which should\n"); |
225 test.Printf(_L("have dropped\n")); |
268 test.Printf(_L("have dropped\n")); |
226 test.Printf(_L("\n")); |
269 OstTrace0(TRACE_NORMAL, CTESTCASE0465_RUNSTEPL_DUP10, "have dropped\n"); |
|
270 test.Printf(_L("\n")); |
|
271 OstTrace0(TRACE_NORMAL, CTESTCASE0465_RUNSTEPL_DUP11, "\n"); |
227 test.Printf(_L("Is it below 0.2 volts?\n")); |
272 test.Printf(_L("Is it below 0.2 volts?\n")); |
228 test.Printf(_L("\n")); |
273 OstTrace0(TRACE_NORMAL, CTESTCASE0465_RUNSTEPL_DUP12, "Is it below 0.2 volts?\n"); |
|
274 test.Printf(_L("\n")); |
|
275 OstTrace0(TRACE_NORMAL, CTESTCASE0465_RUNSTEPL_DUP13, "\n"); |
229 test.Printf(_L("Select Y or N to continue\n")); |
276 test.Printf(_L("Select Y or N to continue\n")); |
|
277 OstTrace0(TRACE_NORMAL, CTESTCASE0465_RUNSTEPL_DUP14, "Select Y or N to continue\n"); |
230 RequestCharacter(); |
278 RequestCharacter(); |
231 iWDTimer->IssueRequest(KDelayDurationForUserActivityMS, this, &CancelKB); |
279 iWDTimer->IssueRequest(KDelayDurationForUserActivityMS, this, &CancelKB); |
232 iCaseStep = EVerifyBusGone; |
280 iCaseStep = EVerifyBusGone; |
233 break; |
281 break; |
234 |
282 |