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 "testcase0467.h"
|
253
|
27 |
#include "OstTraceDefinitions.h"
|
|
28 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
29 |
#include "testcase0467Traces.h"
|
|
30 |
#endif
|
0
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
// # times to repeat the steps (default=3)
|
|
35 |
#define INSERT_REPEATS gOpenIterations
|
|
36 |
|
|
37 |
// the name below is used to add a pointer to our construction method to a pointer MAP in
|
|
38 |
// the class factory
|
|
39 |
_LIT(KTestCaseId,"PBASE-USB_OTGDI-0467");
|
|
40 |
const TTestCaseFactoryReceipt<CTestCase0467> CTestCase0467::iFactoryReceipt(KTestCaseId);
|
|
41 |
|
|
42 |
CTestCase0467* CTestCase0467::NewL(TBool aHost)
|
|
43 |
{
|
253
|
44 |
if(gVerboseOutput)
|
|
45 |
{
|
|
46 |
OstTraceFunctionEntry0(CTESTCASE0467_NEWL);
|
|
47 |
}
|
0
|
48 |
CTestCase0467* self = new (ELeave) CTestCase0467(aHost);
|
|
49 |
CleanupStack::PushL(self);
|
|
50 |
self->ConstructL();
|
|
51 |
CleanupStack::Pop(self);
|
|
52 |
return self;
|
|
53 |
}
|
|
54 |
|
|
55 |
|
|
56 |
CTestCase0467::CTestCase0467(TBool aHost)
|
|
57 |
: CTestCaseRoot(KTestCaseId, aHost)
|
|
58 |
{
|
253
|
59 |
if(gVerboseOutput)
|
|
60 |
{
|
|
61 |
OstTraceFunctionEntry0(CTESTCASE0467_CTESTCASE0467);
|
|
62 |
}
|
0
|
63 |
|
|
64 |
}
|
|
65 |
|
|
66 |
|
|
67 |
/**
|
|
68 |
ConstructL
|
|
69 |
*/
|
|
70 |
void CTestCase0467::ConstructL()
|
|
71 |
{
|
253
|
72 |
if(gVerboseOutput)
|
|
73 |
{
|
|
74 |
OstTraceFunctionEntry0(CTESTCASE0467_CONSTRUCTL);
|
|
75 |
}
|
0
|
76 |
iRepeats = INSERT_REPEATS;
|
|
77 |
iWDTimer = CTestCaseWatchdog::NewL();
|
|
78 |
|
|
79 |
BaseConstructL();
|
|
80 |
}
|
|
81 |
|
|
82 |
|
|
83 |
CTestCase0467::~CTestCase0467()
|
|
84 |
{
|
253
|
85 |
if(gVerboseOutput)
|
|
86 |
{
|
|
87 |
OstTraceFunctionEntry0(CTESTCASE0467_DCTESTCASE0467);
|
|
88 |
}
|
0
|
89 |
|
|
90 |
Cancel();
|
|
91 |
delete iWDTimer;
|
|
92 |
|
|
93 |
}
|
|
94 |
|
|
95 |
|
|
96 |
void CTestCase0467::ExecuteTestCaseL()
|
|
97 |
{
|
253
|
98 |
if(gVerboseOutput)
|
|
99 |
{
|
|
100 |
OstTraceFunctionEntry0(CTESTCASE0467_EXECUTETESTCASEL);
|
|
101 |
}
|
0
|
102 |
iCaseStep = EPreconditions;
|
|
103 |
|
|
104 |
iRepeats = KOperationRetriesMax; // VBus event rise retries
|
|
105 |
|
|
106 |
CActiveScheduler::Add(this);
|
|
107 |
SelfComplete();
|
|
108 |
|
|
109 |
}
|
|
110 |
|
|
111 |
|
|
112 |
void CTestCase0467::DoCancel()
|
|
113 |
{
|
253
|
114 |
if(gVerboseOutput)
|
|
115 |
{
|
|
116 |
OstTraceFunctionEntry0(CTESTCASE0467_DOCANCEL);
|
|
117 |
}
|
0
|
118 |
|
|
119 |
// cancel our timer
|
|
120 |
iTimer.Cancel();
|
|
121 |
}
|
|
122 |
|
|
123 |
|
|
124 |
void CTestCase0467::CancelKB(CTestCaseRoot *pThis)
|
|
125 |
{
|
|
126 |
CTestCase0467 * p = REINTERPRET_CAST(CTestCase0467 *,pThis);
|
|
127 |
// cancel the pending call
|
|
128 |
|
|
129 |
p->iConsole->ReadCancel();
|
|
130 |
|
|
131 |
}
|
|
132 |
|
|
133 |
|
|
134 |
void CTestCase0467::CancelIdPin(CTestCaseRoot *pThis)
|
|
135 |
{
|
253
|
136 |
if(gVerboseOutput)
|
|
137 |
{
|
|
138 |
OstTraceFunctionEntry0(CTESTCASE0467_CANCELIDPIN);
|
|
139 |
}
|
0
|
140 |
|
|
141 |
CTestCase0467 * p = REINTERPRET_CAST(CTestCase0467 *,pThis);
|
|
142 |
// cancel any pending call, and then complete our active obj with a timeout value
|
|
143 |
p->otgCancelOtgIdPinNotification();
|
|
144 |
p->SelfComplete(KTestCaseWatchdogTO);
|
|
145 |
}
|
|
146 |
|
|
147 |
|
|
148 |
// This test result depends on all the ID detection tests and the VBus driving and dropping tests have not yet passed
|
|
149 |
void CTestCase0467::DescribePreconditions()
|
|
150 |
{
|
|
151 |
test.Printf(_L("Remove 'A' connector beforehand.\n"));
|
253
|
152 |
OstTrace0(TRACE_NORMAL, CTESTCASE0467_DESCRIBEPRECONDITIONS, "Remove 'A' connector beforehand.\n");
|
0
|
153 |
test.Printf(_L("ID_PIN detection and VBus driving tests must already pass.\n"));
|
253
|
154 |
OstTrace0(TRACE_NORMAL, CTESTCASE0467_DESCRIBEPRECONDITIONS_DUP01, "ID_PIN detection and VBus driving tests must already pass.\n");
|
0
|
155 |
}
|
|
156 |
|
|
157 |
|
|
158 |
// handle event completion
|
|
159 |
void CTestCase0467::RunStepL()
|
|
160 |
{
|
253
|
161 |
if(gVerboseOutput)
|
|
162 |
{
|
|
163 |
OstTraceFunctionEntry0(CTESTCASE0467_RUNSTEPL);
|
|
164 |
}
|
0
|
165 |
// Obtain the completion code for this CActive obj.
|
|
166 |
TInt completionCode(iStatus.Int());
|
|
167 |
TBuf<MAX_DSTRLEN> aDescription;
|
|
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 remove connector
|
|
180 |
test.Printf(KRemoveAConnectorPrompt);
|
253
|
181 |
OstTrace0(TRACE_NORMAL, CTESTCASE0467_RUNSTEPL_DUP01, KRemoveAConnectorPrompt);
|
0
|
182 |
test.Printf(KPressAnyKeyToContinue);
|
253
|
183 |
OstTrace0(TRACE_NORMAL, CTESTCASE0467_RUNSTEPL_DUP02, KPressAnyKeyToContinue);
|
0
|
184 |
RequestCharacter();
|
|
185 |
break;
|
|
186 |
|
|
187 |
case ELoadLdd:
|
|
188 |
// 1. load the LDD and init.
|
|
189 |
if (!StepLoadLDD())
|
|
190 |
{
|
|
191 |
break;
|
|
192 |
}
|
|
193 |
// initialize variables for loop control
|
|
194 |
|
|
195 |
iCaseStep = EWaitForIDPresent;
|
|
196 |
SelfComplete();
|
|
197 |
break;
|
|
198 |
|
|
199 |
case ERepeatLoop: // 2
|
|
200 |
test.Printf(_L("Repeat test %d/%d\n"), INSERT_REPEATS-iRepeats+1, INSERT_REPEATS);
|
253
|
201 |
OstTraceExt2(TRACE_NORMAL, CTESTCASE0467_RUNSTEPL_DUP03, "Repeat test %d/%d\n", INSERT_REPEATS-iRepeats+1, INSERT_REPEATS);
|
0
|
202 |
|
|
203 |
if (--iRepeats)
|
|
204 |
iCaseStep = EWaitForIDPresent;
|
|
205 |
else
|
|
206 |
iCaseStep = EUnloadLdd;
|
|
207 |
SelfComplete();
|
|
208 |
break;
|
|
209 |
|
|
210 |
case EWaitForIDPresent:
|
|
211 |
// 3. prompt for insertion
|
|
212 |
test.Printf(KInsertAConnectorPrompt);
|
253
|
213 |
OstTrace0(TRACE_NORMAL, CTESTCASE0467_RUNSTEPL_DUP04, KInsertAConnectorPrompt);
|
0
|
214 |
otgQueueOtgIdPinNotification( iOTGIdPin, iStatus );
|
|
215 |
|
|
216 |
SetActive();
|
|
217 |
iCaseStep = EVerifyIDPresent;
|
|
218 |
iDetectionRetry = 0;
|
|
219 |
break;
|
|
220 |
|
|
221 |
case EVerifyIDPresent:
|
|
222 |
// 4. detect id_pin event
|
|
223 |
LOG_VERBOSE1(_L("STEP4 - detect id_pin event 'A'\n"));
|
253
|
224 |
if(gVerboseOutput)
|
|
225 |
{
|
|
226 |
OstTrace0(TRACE_VERBOSE, CTESTCASE0467_RUNSTEPL_DUP05, "STEP4 - detect id_pin event 'A'\n");;
|
|
227 |
}
|
0
|
228 |
|
|
229 |
// retrieve the current ID_PIN value
|
|
230 |
otgQueueOtgIdPinNotification( iOTGIdPin, iStatus );
|
|
231 |
otgCancelOtgIdPinNotification();
|
|
232 |
User::WaitForRequest(iStatus); // swallow the cancellation event (serves to test that it does cancel)
|
|
233 |
|
|
234 |
|
|
235 |
if (iOTGIdPin != RUsbOtgDriver::EIdPinAPlug)
|
|
236 |
{
|
|
237 |
if (iDetectionRetry++ < 3)
|
|
238 |
{
|
|
239 |
iCaseStep = EVerifyIDPresent;
|
|
240 |
otgQueueOtgIdPinNotification( iOTGIdPin, iStatus );
|
|
241 |
|
|
242 |
SetActive();
|
|
243 |
break;
|
|
244 |
}
|
|
245 |
else
|
|
246 |
{
|
|
247 |
return TestFailed(KErrAbort, _L("ID_PIN NOT 'seen' - FAILED!"));
|
|
248 |
}
|
|
249 |
}
|
|
250 |
|
|
251 |
// check using the API in a syncronous way too
|
|
252 |
// NOTE: we test this twice to explore and expose timing problems
|
|
253 |
if (!otgIdPinPresent())
|
|
254 |
{
|
|
255 |
return TestFailed(KErrAbort, _L("ID_PIN syncronous call error - FAILED!"));
|
|
256 |
}
|
|
257 |
iCaseStep = EWaitForIDGone;
|
|
258 |
SelfComplete();
|
|
259 |
iDetectionRetry = 0;
|
|
260 |
break;
|
|
261 |
|
|
262 |
case EWaitForIDGone:
|
|
263 |
// 5. prompt for insertion
|
|
264 |
test.Printf(KRemoveAConnectorPrompt);
|
253
|
265 |
OstTrace0(TRACE_NORMAL, CTESTCASE0467_RUNSTEPL_DUP06, KRemoveAConnectorPrompt);
|
0
|
266 |
otgQueueOtgIdPinNotification( iOTGIdPin, iStatus );
|
|
267 |
SetActive();
|
|
268 |
iCaseStep = EVerifyIDGone;
|
|
269 |
break;
|
|
270 |
|
|
271 |
case EVerifyIDGone:
|
|
272 |
// 6. detect id_pin gone event
|
|
273 |
LOG_VERBOSE1(_L("STEP4 - detect id_pin remove event 'B'\n"));
|
253
|
274 |
if(gVerboseOutput)
|
|
275 |
{
|
|
276 |
OstTrace0(TRACE_VERBOSE, CTESTCASE0467_RUNSTEPL_DUP07, "STEP4 - detect id_pin remove event 'B'\n");;
|
|
277 |
}
|
0
|
278 |
test.Printf(_L("ID_PIN=%d\n"), iOTGIdPin);
|
253
|
279 |
OstTrace1(TRACE_NORMAL, CTESTCASE0467_RUNSTEPL_DUP08, "ID_PIN=%d\n", iOTGIdPin);
|
0
|
280 |
|
|
281 |
User::After(5000); // 5ms
|
|
282 |
otgQueueOtgIdPinNotification( iOTGIdPin, iStatus );
|
|
283 |
otgCancelOtgIdPinNotification();
|
|
284 |
User::WaitForRequest(iStatus); // swallow it
|
|
285 |
test.Printf(_L("ID_PIN=%d\n"), iOTGIdPin);
|
253
|
286 |
OstTrace1(TRACE_NORMAL, CTESTCASE0467_RUNSTEPL_DUP09, "ID_PIN=%d\n", iOTGIdPin);
|
0
|
287 |
|
|
288 |
if (iOTGIdPin != RUsbOtgDriver::EIdPinBPlug)
|
|
289 |
{
|
|
290 |
if (iDetectionRetry++ < 3)
|
|
291 |
{
|
|
292 |
iCaseStep = EVerifyIDGone;
|
|
293 |
otgQueueOtgIdPinNotification( iOTGIdPin, iStatus );
|
|
294 |
SetActive();
|
|
295 |
break;
|
|
296 |
}
|
|
297 |
else
|
|
298 |
{
|
|
299 |
return TestFailed(KErrAbort, _L("ID_PIN NOT 'removed' - FAILED!"));
|
|
300 |
}
|
|
301 |
}
|
|
302 |
// check using the API in a syncronous way too
|
|
303 |
if (otgIdPinPresent())
|
|
304 |
{
|
|
305 |
return TestFailed(KErrAbort, _L("ID_PIN syncronous call error - FAILED!"));
|
|
306 |
}
|
|
307 |
iCaseStep = ERepeatLoop;
|
|
308 |
SelfComplete();
|
|
309 |
break;
|
|
310 |
|
|
311 |
case EUnloadLdd:
|
|
312 |
// 7. unload
|
|
313 |
if (EFalse == StepUnloadLDD())
|
|
314 |
return TestFailed(KErrAbort,_L("Unload Ldd failure"));
|
|
315 |
|
|
316 |
iCaseStep = ELastStep;
|
|
317 |
SelfComplete();
|
|
318 |
break;
|
|
319 |
|
|
320 |
case ELastStep:
|
|
321 |
TestPassed();
|
|
322 |
break;
|
|
323 |
|
|
324 |
default:
|
|
325 |
test.Printf(_L("<Error> unknown test step"));
|
253
|
326 |
OstTrace0(TRACE_NORMAL, CTESTCASE0467_RUNSTEPL_DUP10, "<Error> unknown test step");
|
0
|
327 |
Cancel();
|
|
328 |
return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
|
|
329 |
}
|
|
330 |
}
|
|
331 |
|