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 "testcase0676.h" |
26 #include "testcase0676.h" |
|
27 #include "OstTraceDefinitions.h" |
|
28 #ifdef OST_TRACE_COMPILER_IN_USE |
|
29 #include "testcase0676Traces.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-0676"); |
38 _LIT(KTestCaseId,"PBASE-USB_OTGDI-0676"); |
35 const TTestCaseFactoryReceipt<CTestCase0676> CTestCase0676::iFactoryReceipt(KTestCaseId); |
39 const TTestCaseFactoryReceipt<CTestCase0676> CTestCase0676::iFactoryReceipt(KTestCaseId); |
36 |
40 |
37 CTestCase0676* CTestCase0676::NewL(TBool aHost) |
41 CTestCase0676* CTestCase0676::NewL(TBool aHost) |
38 { |
42 { |
39 LOG_FUNC |
43 if(gVerboseOutput) |
|
44 { |
|
45 OstTraceFunctionEntry0(CTESTCASE0676_NEWL); |
|
46 } |
40 CTestCase0676* self = new (ELeave) CTestCase0676(aHost); |
47 CTestCase0676* self = new (ELeave) CTestCase0676(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 CTestCase0676::CTestCase0676(TBool aHost) |
55 CTestCase0676::CTestCase0676(TBool aHost) |
49 : CTestCaseRoot(KTestCaseId, aHost) |
56 : CTestCaseRoot(KTestCaseId, aHost) |
50 { |
57 { |
51 LOG_FUNC |
58 if(gVerboseOutput) |
|
59 { |
|
60 OstTraceFunctionEntry0(CTESTCASE0676_CTESTCASE0676); |
|
61 } |
52 |
62 |
53 } |
63 } |
54 |
64 |
55 |
65 |
56 /** |
66 /** |
57 ConstructL |
67 ConstructL |
58 */ |
68 */ |
59 void CTestCase0676::ConstructL() |
69 void CTestCase0676::ConstructL() |
60 { |
70 { |
61 LOG_FUNC |
71 if(gVerboseOutput) |
|
72 { |
|
73 OstTraceFunctionEntry0(CTESTCASE0676_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 CTestCase0676::~CTestCase0676() |
82 CTestCase0676::~CTestCase0676() |
70 { |
83 { |
71 LOG_FUNC |
84 if(gVerboseOutput) |
|
85 { |
|
86 OstTraceFunctionEntry0(CTESTCASE0676_DCTESTCASE0676); |
|
87 } |
72 |
88 |
73 Cancel(); |
89 Cancel(); |
74 delete iWDTimer; |
90 delete iWDTimer; |
75 |
91 |
76 } |
92 } |
77 |
93 |
78 |
94 |
79 void CTestCase0676::ExecuteTestCaseL() |
95 void CTestCase0676::ExecuteTestCaseL() |
80 { |
96 { |
81 LOG_FUNC |
97 if(gVerboseOutput) |
|
98 { |
|
99 OstTraceFunctionEntry0(CTESTCASE0676_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 CTestCase0676::DoCancel() |
111 void CTestCase0676::DoCancel() |
93 { |
112 { |
94 LOG_FUNC |
113 if(gVerboseOutput) |
|
114 { |
|
115 OstTraceFunctionEntry0(CTESTCASE0676_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 CTestCase0676::CancelKB(CTestCaseRoot *pThis) |
123 void CTestCase0676::CancelKB(CTestCaseRoot *pThis) |
102 { |
124 { |
103 LOG_FUNC |
125 if(gVerboseOutput) |
|
126 { |
|
127 OstTraceFunctionEntry0(CTESTCASE0676_CANCELKB); |
|
128 } |
104 CTestCase0676 * p = REINTERPRET_CAST(CTestCase0676 *,pThis); |
129 CTestCase0676 * p = REINTERPRET_CAST(CTestCase0676 *,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 CTestCase0676::CancelNotify(CTestCaseRoot *pThis) |
136 void CTestCase0676::CancelNotify(CTestCaseRoot *pThis) |
112 { |
137 { |
113 LOG_FUNC |
138 if(gVerboseOutput) |
|
139 { |
|
140 OstTraceFunctionEntry0(CTESTCASE0676_CANCELNOTIFY); |
|
141 } |
114 CTestCase0676 * p = REINTERPRET_CAST(CTestCase0676 *,pThis); |
142 CTestCase0676 * p = REINTERPRET_CAST(CTestCase0676 *,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 CTestCase0676::DescribePreconditions() |
150 void CTestCase0676::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, CTESTCASE0676_DESCRIBEPRECONDITIONS, "Insert 'A' connector beforehand.\n"); |
125 } |
154 } |
126 |
155 |
127 void CTestCase0676::ContinueAfter(TTimeIntervalMicroSeconds32 aMicroSecs, TCaseSteps aStep) |
156 void CTestCase0676::ContinueAfter(TTimeIntervalMicroSeconds32 aMicroSecs, TCaseSteps aStep) |
128 { |
157 { |
129 LOG_VERBOSE2(_L("Wait %dms before drop VBus"), (TInt)(aMicroSecs.Int()/1000)); |
158 LOG_VERBOSE2(_L("Wait %dms before drop VBus"), (TInt)(aMicroSecs.Int()/1000)); |
|
159 if(gVerboseOutput) |
|
160 { |
|
161 OstTrace1(TRACE_VERBOSE, CTESTCASE0676_CONTINUEAFTER, "Wait %dms before drop VBus", (TInt)(aMicroSecs.Int()/1000));; |
|
162 } |
130 iTimer.After(iStatus, aMicroSecs); |
163 iTimer.After(iStatus, aMicroSecs); |
131 iCaseStep = aStep; |
164 iCaseStep = aStep; |
132 SetActive(); |
165 SetActive(); |
133 } |
166 } |
134 |
167 |
135 // handle event completion |
168 // handle event completion |
136 void CTestCase0676::RunStepL() |
169 void CTestCase0676::RunStepL() |
137 { |
170 { |
138 LOG_FUNC |
171 if(gVerboseOutput) |
|
172 { |
|
173 OstTraceFunctionEntry0(CTESTCASE0676_RUNSTEPL); |
|
174 } |
139 // Obtain the completion code for this CActive obj. |
175 // Obtain the completion code for this CActive obj. |
140 TInt completionCode(iStatus.Int()); |
176 TInt completionCode(iStatus.Int()); |
141 TBuf<MAX_DSTRLEN> aDescription; |
177 TBuf<MAX_DSTRLEN> aDescription; |
142 TInt err(0); |
178 TInt err(0); |
143 |
179 |
152 SelfComplete(); |
188 SelfComplete(); |
153 break; |
189 break; |
154 } |
190 } |
155 // prompt to insert connector |
191 // prompt to insert connector |
156 test.Printf(KInsertAConnectorPrompt); |
192 test.Printf(KInsertAConnectorPrompt); |
|
193 OstTrace0(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP01, KInsertAConnectorPrompt); |
157 test.Printf(KPressAnyKeyToContinue); |
194 test.Printf(KPressAnyKeyToContinue); |
|
195 OstTrace0(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP02, KPressAnyKeyToContinue); |
158 RequestCharacter(); |
196 RequestCharacter(); |
159 break; |
197 break; |
160 |
198 |
161 case ELoadLdd: |
199 case ELoadLdd: |
162 // 1. load the LDD and init. |
200 // 1. load the LDD and init. |
178 // if doing this test in /AUTO mode, we would fail this now |
216 // if doing this test in /AUTO mode, we would fail this now |
179 // however if we can control ID_PIN through an API in future, we turn in on now. |
217 // however if we can control ID_PIN through an API in future, we turn in on now. |
180 if (!otgIdPinPresent()) |
218 if (!otgIdPinPresent()) |
181 { |
219 { |
182 test.Printf(KInsertAConnectorPrompt); |
220 test.Printf(KInsertAConnectorPrompt); |
|
221 OstTrace0(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP03, KInsertAConnectorPrompt); |
183 test.Printf(KPressAnyKeyToContinue); |
222 test.Printf(KPressAnyKeyToContinue); |
|
223 OstTrace0(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP04, KPressAnyKeyToContinue); |
184 RequestCharacter(); |
224 RequestCharacter(); |
185 |
225 |
186 iCaseStep = EDetectAPlug; |
226 iCaseStep = EDetectAPlug; |
187 } |
227 } |
188 else |
228 else |
207 |
247 |
208 case ELoopDriveVBus: |
248 case ELoopDriveVBus: |
209 // 4. DRIVE VBUS |
249 // 4. DRIVE VBUS |
210 iWDTimer->Cancel(); |
250 iWDTimer->Cancel(); |
211 test.Printf(_L("Drive VBus, iteration %d/%d\n"), OPEN_REPEATS-iRepeats+1, OPEN_REPEATS); |
251 test.Printf(_L("Drive VBus, iteration %d/%d\n"), OPEN_REPEATS-iRepeats+1, OPEN_REPEATS); |
|
252 OstTraceExt2(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP05, "Drive VBus, iteration %d/%d\n", OPEN_REPEATS-iRepeats+1, OPEN_REPEATS); |
212 // test for VBus rise next |
253 // test for VBus rise next |
213 test.Printf(_L("Waiting for VBus Event\n")); |
254 test.Printf(_L("Waiting for VBus Event\n")); |
|
255 OstTrace0(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP06, "Waiting for VBus Event\n"); |
214 iStatus = KRequestPending; |
256 iStatus = KRequestPending; |
215 otgQueueOtgVbusNotification( iOTGVBus, iStatus ); |
257 otgQueueOtgVbusNotification( iOTGVBus, iStatus ); |
216 |
258 |
217 // turn on VBus, since the call is not a Queing a-sync call we do this after the async call |
259 // turn on VBus, since the call is not a Queing a-sync call we do this after the async call |
218 err = otgBusRequest(); // ok to turn on VBus now |
260 err = otgBusRequest(); // ok to turn on VBus now |