253
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
|
0
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// @internalComponent
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <e32std.h>
|
|
19 |
#include <e32std_private.h>
|
|
20 |
#include <u32std.h> // unicode builds
|
|
21 |
#include <e32base.h>
|
|
22 |
#include <e32base_private.h>
|
|
23 |
#include <e32Test.h> // RTest headder
|
|
24 |
#include "testcaseroot.h"
|
|
25 |
#include "testcasewd.h"
|
|
26 |
#include "testcase0466.h"
|
253
|
27 |
#include "OstTraceDefinitions.h"
|
|
28 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
29 |
#include "testcase0466Traces.h"
|
|
30 |
#endif
|
0
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
// the name below is used to add a pointer to our construction method to a pointer MAP in
|
|
35 |
// the class factory
|
|
36 |
_LIT(KTestCaseId,"PBASE-USB_OTGDI-0466");
|
|
37 |
const TTestCaseFactoryReceipt<CTestCase0466> CTestCase0466::iFactoryReceipt(KTestCaseId);
|
|
38 |
|
|
39 |
CTestCase0466* CTestCase0466::NewL(TBool aHost)
|
|
40 |
{
|
253
|
41 |
if(gVerboseOutput)
|
|
42 |
{
|
|
43 |
OstTraceFunctionEntry0(CTESTCASE0466_NEWL);
|
|
44 |
}
|
0
|
45 |
CTestCase0466* self = new (ELeave) CTestCase0466(aHost);
|
|
46 |
CleanupStack::PushL(self);
|
|
47 |
self->ConstructL();
|
|
48 |
CleanupStack::Pop(self);
|
|
49 |
return self;
|
|
50 |
}
|
|
51 |
|
|
52 |
|
|
53 |
CTestCase0466::CTestCase0466(TBool aHost)
|
|
54 |
: CTestCaseRoot(KTestCaseId, aHost)
|
|
55 |
{
|
253
|
56 |
if(gVerboseOutput)
|
|
57 |
{
|
|
58 |
OstTraceFunctionEntry0(CTESTCASE0466_CTESTCASE0466);
|
|
59 |
}
|
0
|
60 |
|
|
61 |
}
|
|
62 |
|
|
63 |
|
|
64 |
/**
|
|
65 |
ConstructL
|
|
66 |
*/
|
|
67 |
void CTestCase0466::ConstructL()
|
|
68 |
{
|
253
|
69 |
if(gVerboseOutput)
|
|
70 |
{
|
|
71 |
OstTraceFunctionEntry0(CTESTCASE0466_CONSTRUCTL);
|
|
72 |
}
|
0
|
73 |
iWDTimer = CTestCaseWatchdog::NewL();
|
|
74 |
|
|
75 |
BaseConstructL();
|
|
76 |
}
|
|
77 |
|
|
78 |
|
|
79 |
CTestCase0466::~CTestCase0466()
|
|
80 |
{
|
253
|
81 |
if(gVerboseOutput)
|
|
82 |
{
|
|
83 |
OstTraceFunctionEntry0(CTESTCASE0466_DCTESTCASE0466);
|
|
84 |
}
|
0
|
85 |
|
|
86 |
Cancel();
|
|
87 |
delete iWDTimer;
|
|
88 |
}
|
|
89 |
|
|
90 |
|
|
91 |
void CTestCase0466::ExecuteTestCaseL()
|
|
92 |
{
|
253
|
93 |
if(gVerboseOutput)
|
|
94 |
{
|
|
95 |
OstTraceFunctionEntry0(CTESTCASE0466_EXECUTETESTCASEL);
|
|
96 |
}
|
0
|
97 |
iCaseStep = EPreconditions;
|
|
98 |
|
|
99 |
iRepeats = KOperationRetriesMax;
|
|
100 |
|
|
101 |
CActiveScheduler::Add(this);
|
|
102 |
SelfComplete();
|
|
103 |
|
|
104 |
}
|
|
105 |
|
|
106 |
|
|
107 |
void CTestCase0466::DescribePreconditions()
|
|
108 |
{
|
|
109 |
test.Printf(_L("BEFORE running this test\n"));
|
253
|
110 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_DESCRIBEPRECONDITIONS, "BEFORE running this test\n");
|
0
|
111 |
test.Printf(_L("\n"));
|
253
|
112 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_DESCRIBEPRECONDITIONS_DUP01, "\n");
|
0
|
113 |
test.Printf(_L("Insert the connector\n"));
|
253
|
114 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_DESCRIBEPRECONDITIONS_DUP02, "Insert the connector\n");
|
0
|
115 |
test.Printf(_L("from the OET with SW9\n"));
|
253
|
116 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_DESCRIBEPRECONDITIONS_DUP03, "from the OET with SW9\n");
|
0
|
117 |
test.Printf(_L("set to 'A-DEVICE' and\n"));
|
253
|
118 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_DESCRIBEPRECONDITIONS_DUP04, "set to 'A-DEVICE' and\n");
|
0
|
119 |
test.Printf(_L("all other switches OFF\n"));
|
253
|
120 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_DESCRIBEPRECONDITIONS_DUP05, "all other switches OFF\n");
|
0
|
121 |
test.Printf(_L("\n"));
|
253
|
122 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_DESCRIBEPRECONDITIONS_DUP06, "\n");
|
0
|
123 |
test.Printf(_L("Confirm passing tests\n"));
|
253
|
124 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_DESCRIBEPRECONDITIONS_DUP07, "Confirm passing tests\n");
|
0
|
125 |
test.Printf(_L("\n"));
|
253
|
126 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_DESCRIBEPRECONDITIONS_DUP08, "\n");
|
0
|
127 |
test.Printf(_L("ID_PIN detection\n"));
|
253
|
128 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_DESCRIBEPRECONDITIONS_DUP09, "ID_PIN detection\n");
|
0
|
129 |
test.Printf(_L("VBus Driving\n"));
|
253
|
130 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_DESCRIBEPRECONDITIONS_DUP10, "VBus Driving\n");
|
0
|
131 |
test.Printf(_L("\n"));
|
253
|
132 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_DESCRIBEPRECONDITIONS_DUP11, "\n");
|
0
|
133 |
}
|
|
134 |
|
|
135 |
|
|
136 |
void CTestCase0466::DoCancel()
|
|
137 |
{
|
253
|
138 |
if(gVerboseOutput)
|
|
139 |
{
|
|
140 |
OstTraceFunctionEntry0(CTESTCASE0466_DOCANCEL);
|
|
141 |
}
|
0
|
142 |
|
|
143 |
// cancel our timer
|
|
144 |
iTimer.Cancel();
|
|
145 |
}
|
|
146 |
|
|
147 |
// static cb helper
|
|
148 |
void CTestCase0466::CancelDrive(CTestCaseRoot *pThis)
|
|
149 |
{
|
|
150 |
CTestCase0466 * p = REINTERPRET_CAST(CTestCase0466 *,pThis);
|
|
151 |
// cancel any pending call, and then complete our active obj with a timeout value
|
|
152 |
p->SelfComplete(KTestCaseWatchdogTO);
|
|
153 |
|
|
154 |
}
|
|
155 |
|
|
156 |
|
|
157 |
// handle event completion
|
|
158 |
void CTestCase0466::RunStepL()
|
|
159 |
{
|
253
|
160 |
if(gVerboseOutput)
|
|
161 |
{
|
|
162 |
OstTraceFunctionEntry0(CTESTCASE0466_RUNSTEPL);
|
|
163 |
}
|
0
|
164 |
// Obtain the completion code for this CActive obj.
|
|
165 |
TInt completionCode(iStatus.Int());
|
|
166 |
TBuf<MAX_DSTRLEN> aDescription;
|
|
167 |
TInt err(0);
|
|
168 |
|
|
169 |
switch(iCaseStep)
|
|
170 |
{
|
|
171 |
case EPreconditions:
|
|
172 |
iCaseStep = ELoadLdd;
|
|
173 |
if (iAutomated)
|
|
174 |
{
|
|
175 |
iCaseStep = ELoadLdd;
|
|
176 |
SelfComplete();
|
|
177 |
break;
|
|
178 |
}
|
|
179 |
// prompt to insert connector
|
|
180 |
test.Printf(_L("\n"));
|
253
|
181 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP01, "\n");
|
0
|
182 |
test.Printf(KInsertAConnectorPrompt);
|
253
|
183 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP02, KInsertAConnectorPrompt);
|
0
|
184 |
test.Printf(_L("\n"));
|
253
|
185 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP03, "\n");
|
0
|
186 |
test.Printf(KPressAnyKeyToContinue);
|
253
|
187 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP04, KPressAnyKeyToContinue);
|
0
|
188 |
test.Printf(_L("\n"));
|
253
|
189 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP05, "\n");
|
0
|
190 |
RequestCharacter();
|
|
191 |
break;
|
|
192 |
|
|
193 |
case ELoadLdd:
|
|
194 |
if (!StepLoadLDD())
|
|
195 |
{
|
|
196 |
break;
|
|
197 |
}
|
|
198 |
|
|
199 |
iCaseStep = EDriveBus;
|
|
200 |
SelfComplete();
|
|
201 |
break;
|
|
202 |
|
|
203 |
// wait on
|
|
204 |
case EDriveBus:
|
|
205 |
// wait for 100 ms to allow the stack time to settle
|
|
206 |
User::After(100000);
|
|
207 |
|
|
208 |
// drive VBus
|
|
209 |
// NOTE: A-Plug must be inserted because it is illegal to power VBus unless
|
|
210 |
// A-Plug is detected (ID pin is low). The Thunk checks this.
|
|
211 |
err = otgBusRequest();
|
|
212 |
|
|
213 |
if (KErrNone != err)
|
|
214 |
{
|
|
215 |
return TestFailed(KErrAbort, _L("Raise VBus - RUsbOtgDriver::BusRequest() FAILED!"));
|
|
216 |
}
|
|
217 |
|
|
218 |
// wait for 1 second as described in the test document
|
|
219 |
User::After(1000000);
|
|
220 |
|
|
221 |
// subscribe to error events...
|
|
222 |
otgQueueOtgMessageRequest(iOTGMessage, iStatus);
|
|
223 |
SetActive();
|
|
224 |
|
|
225 |
// ...and tell user to apply load
|
|
226 |
test.Printf(_L("\n"));
|
253
|
227 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP06, "\n");
|
0
|
228 |
test.Printf(_L("************************\n"));
|
253
|
229 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP07, "************************\n");
|
0
|
230 |
test.Printf(_L("* Using SW4 on the OET *\n"));
|
253
|
231 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP08, "* Using SW4 on the OET *\n");
|
0
|
232 |
test.Printf(_L("* Apply 100mA LOAD now *\n"));
|
253
|
233 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP09, "* Apply 100mA LOAD now *\n");
|
0
|
234 |
test.Printf(_L("************************\n"));
|
253
|
235 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP10, "************************\n");
|
0
|
236 |
test.Printf(_L("\n"));
|
253
|
237 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP11, "\n");
|
0
|
238 |
|
|
239 |
iCaseStep = EVerifyBusFail;
|
|
240 |
|
|
241 |
break;
|
|
242 |
|
|
243 |
case EVerifyBusFail:
|
|
244 |
|
|
245 |
OtgMessageString(iOTGMessage, aDescription);
|
|
246 |
test.Printf(_L("Received message %d '%S' status(%d)\n"), iOTGMessage, &aDescription, completionCode);
|
253
|
247 |
OstTraceExt3(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP12, "Received message %d '%S' status(%d)\n", iOTGMessage, aDescription, completionCode);
|
0
|
248 |
|
|
249 |
if (RUsbOtgDriver::EMessageVbusError == iOTGMessage)
|
|
250 |
{
|
|
251 |
err = otgBusClearError();
|
|
252 |
|
|
253 |
if ( err )
|
|
254 |
{
|
|
255 |
return TestFailed(KErrAbort, _L("VBUS Error Clear - FAILED!"));
|
|
256 |
}
|
|
257 |
|
|
258 |
iCaseStep = EUnloadLdd;
|
|
259 |
SelfComplete();
|
|
260 |
}
|
|
261 |
else
|
|
262 |
{
|
|
263 |
iRepeats--;
|
|
264 |
if (iRepeats <0)
|
|
265 |
{
|
|
266 |
return TestFailed(KErrAbort, _L("VBUS Fall FAILED!"));
|
|
267 |
}
|
|
268 |
|
|
269 |
otgQueueOtgMessageRequest(iOTGMessage, iStatus);
|
|
270 |
SetActive();
|
|
271 |
|
|
272 |
iCaseStep = EVerifyBusFail;
|
|
273 |
}
|
|
274 |
|
|
275 |
break;
|
|
276 |
|
|
277 |
case EUnloadLdd:
|
|
278 |
|
|
279 |
if (EFalse == StepUnloadLDD())
|
|
280 |
{
|
|
281 |
return TestFailed(KErrAbort,_L("unload Ldd failure"));
|
|
282 |
}
|
|
283 |
|
|
284 |
// remove 100ma Load - this reminds the user
|
|
285 |
test.Printf(_L("\n"));
|
253
|
286 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP13, "\n");
|
0
|
287 |
test.Printf(_L("************************\n"));
|
253
|
288 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP14, "************************\n");
|
0
|
289 |
test.Printf(_L("* Using SW4 on the OET *\n"));
|
253
|
290 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP15, "* Using SW4 on the OET *\n");
|
0
|
291 |
test.Printf(_L("* Remove 100mA LOAD! *\n"));
|
253
|
292 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP16, "* Remove 100mA LOAD! *\n");
|
0
|
293 |
test.Printf(_L("************************\n"));
|
253
|
294 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP17, "************************\n");
|
0
|
295 |
test.Printf(_L("\n"));
|
253
|
296 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP18, "\n");
|
0
|
297 |
|
|
298 |
iCaseStep = ELastStep;
|
|
299 |
// press any key
|
|
300 |
test.Printf(KPressAnyKeyToContinue);
|
253
|
301 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP19, KPressAnyKeyToContinue);
|
0
|
302 |
RequestCharacter();
|
|
303 |
break;
|
|
304 |
|
|
305 |
case ELastStep:
|
|
306 |
return TestPassed();
|
|
307 |
|
|
308 |
default:
|
|
309 |
test.Printf(_L("<Error> unknown test step"));
|
253
|
310 |
OstTrace0(TRACE_NORMAL, CTESTCASE0466_RUNSTEPL_DUP20, "<Error> unknown test step");
|
0
|
311 |
Cancel();
|
|
312 |
return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
|
|
313 |
|
|
314 |
}
|
|
315 |
|
|
316 |
}
|
|
317 |
|
|
318 |
|