0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
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"
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
// the name below is used to add a pointer to our construction method to a pointer MAP in
|
|
31 |
// the class factory
|
|
32 |
_LIT(KTestCaseId,"PBASE-USB_OTGDI-0466");
|
|
33 |
const TTestCaseFactoryReceipt<CTestCase0466> CTestCase0466::iFactoryReceipt(KTestCaseId);
|
|
34 |
|
|
35 |
CTestCase0466* CTestCase0466::NewL(TBool aHost)
|
|
36 |
{
|
|
37 |
LOG_FUNC
|
|
38 |
CTestCase0466* self = new (ELeave) CTestCase0466(aHost);
|
|
39 |
CleanupStack::PushL(self);
|
|
40 |
self->ConstructL();
|
|
41 |
CleanupStack::Pop(self);
|
|
42 |
return self;
|
|
43 |
}
|
|
44 |
|
|
45 |
|
|
46 |
CTestCase0466::CTestCase0466(TBool aHost)
|
|
47 |
: CTestCaseRoot(KTestCaseId, aHost)
|
|
48 |
{
|
|
49 |
LOG_FUNC
|
|
50 |
|
|
51 |
}
|
|
52 |
|
|
53 |
|
|
54 |
/**
|
|
55 |
ConstructL
|
|
56 |
*/
|
|
57 |
void CTestCase0466::ConstructL()
|
|
58 |
{
|
|
59 |
LOG_FUNC
|
|
60 |
iWDTimer = CTestCaseWatchdog::NewL();
|
|
61 |
|
|
62 |
BaseConstructL();
|
|
63 |
}
|
|
64 |
|
|
65 |
|
|
66 |
CTestCase0466::~CTestCase0466()
|
|
67 |
{
|
|
68 |
LOG_FUNC
|
|
69 |
|
|
70 |
Cancel();
|
|
71 |
delete iWDTimer;
|
|
72 |
}
|
|
73 |
|
|
74 |
|
|
75 |
void CTestCase0466::ExecuteTestCaseL()
|
|
76 |
{
|
|
77 |
LOG_FUNC
|
|
78 |
iCaseStep = EPreconditions;
|
|
79 |
|
|
80 |
iRepeats = KOperationRetriesMax;
|
|
81 |
|
|
82 |
CActiveScheduler::Add(this);
|
|
83 |
SelfComplete();
|
|
84 |
|
|
85 |
}
|
|
86 |
|
|
87 |
|
|
88 |
void CTestCase0466::DescribePreconditions()
|
|
89 |
{
|
|
90 |
test.Printf(_L("BEFORE running this test\n"));
|
|
91 |
test.Printf(_L("\n"));
|
|
92 |
test.Printf(_L("Insert the connector\n"));
|
|
93 |
test.Printf(_L("from the OET with SW9\n"));
|
|
94 |
test.Printf(_L("set to 'A-DEVICE' and\n"));
|
|
95 |
test.Printf(_L("all other switches OFF\n"));
|
|
96 |
test.Printf(_L("\n"));
|
|
97 |
test.Printf(_L("Confirm passing tests\n"));
|
|
98 |
test.Printf(_L("\n"));
|
|
99 |
test.Printf(_L("ID_PIN detection\n"));
|
|
100 |
test.Printf(_L("VBus Driving\n"));
|
|
101 |
test.Printf(_L("\n"));
|
|
102 |
}
|
|
103 |
|
|
104 |
|
|
105 |
void CTestCase0466::DoCancel()
|
|
106 |
{
|
|
107 |
LOG_FUNC
|
|
108 |
|
|
109 |
// cancel our timer
|
|
110 |
iTimer.Cancel();
|
|
111 |
}
|
|
112 |
|
|
113 |
// static cb helper
|
|
114 |
void CTestCase0466::CancelDrive(CTestCaseRoot *pThis)
|
|
115 |
{
|
|
116 |
CTestCase0466 * p = REINTERPRET_CAST(CTestCase0466 *,pThis);
|
|
117 |
// cancel any pending call, and then complete our active obj with a timeout value
|
|
118 |
p->SelfComplete(KTestCaseWatchdogTO);
|
|
119 |
|
|
120 |
}
|
|
121 |
|
|
122 |
|
|
123 |
// handle event completion
|
|
124 |
void CTestCase0466::RunStepL()
|
|
125 |
{
|
|
126 |
LOG_FUNC
|
|
127 |
// Obtain the completion code for this CActive obj.
|
|
128 |
TInt completionCode(iStatus.Int());
|
|
129 |
TBuf<MAX_DSTRLEN> aDescription;
|
|
130 |
TInt err(0);
|
|
131 |
|
|
132 |
switch(iCaseStep)
|
|
133 |
{
|
|
134 |
case EPreconditions:
|
|
135 |
iCaseStep = ELoadLdd;
|
|
136 |
if (iAutomated)
|
|
137 |
{
|
|
138 |
iCaseStep = ELoadLdd;
|
|
139 |
SelfComplete();
|
|
140 |
break;
|
|
141 |
}
|
|
142 |
// prompt to insert connector
|
|
143 |
test.Printf(_L("\n"));
|
|
144 |
test.Printf(KInsertAConnectorPrompt);
|
|
145 |
test.Printf(_L("\n"));
|
|
146 |
test.Printf(KPressAnyKeyToContinue);
|
|
147 |
test.Printf(_L("\n"));
|
|
148 |
RequestCharacter();
|
|
149 |
break;
|
|
150 |
|
|
151 |
case ELoadLdd:
|
|
152 |
if (!StepLoadLDD())
|
|
153 |
{
|
|
154 |
break;
|
|
155 |
}
|
|
156 |
|
|
157 |
iCaseStep = EDriveBus;
|
|
158 |
SelfComplete();
|
|
159 |
break;
|
|
160 |
|
|
161 |
// wait on
|
|
162 |
case EDriveBus:
|
|
163 |
// wait for 100 ms to allow the stack time to settle
|
|
164 |
User::After(100000);
|
|
165 |
|
|
166 |
// drive VBus
|
|
167 |
// NOTE: A-Plug must be inserted because it is illegal to power VBus unless
|
|
168 |
// A-Plug is detected (ID pin is low). The Thunk checks this.
|
|
169 |
err = otgBusRequest();
|
|
170 |
|
|
171 |
if (KErrNone != err)
|
|
172 |
{
|
|
173 |
return TestFailed(KErrAbort, _L("Raise VBus - RUsbOtgDriver::BusRequest() FAILED!"));
|
|
174 |
}
|
|
175 |
|
|
176 |
// wait for 1 second as described in the test document
|
|
177 |
User::After(1000000);
|
|
178 |
|
|
179 |
// subscribe to error events...
|
|
180 |
otgQueueOtgMessageRequest(iOTGMessage, iStatus);
|
|
181 |
SetActive();
|
|
182 |
|
|
183 |
// ...and tell user to apply load
|
|
184 |
test.Printf(_L("\n"));
|
|
185 |
test.Printf(_L("************************\n"));
|
|
186 |
test.Printf(_L("* Using SW4 on the OET *\n"));
|
|
187 |
test.Printf(_L("* Apply 100mA LOAD now *\n"));
|
|
188 |
test.Printf(_L("************************\n"));
|
|
189 |
test.Printf(_L("\n"));
|
|
190 |
|
|
191 |
iCaseStep = EVerifyBusFail;
|
|
192 |
|
|
193 |
break;
|
|
194 |
|
|
195 |
case EVerifyBusFail:
|
|
196 |
|
|
197 |
OtgMessageString(iOTGMessage, aDescription);
|
|
198 |
test.Printf(_L("Received message %d '%S' status(%d)\n"), iOTGMessage, &aDescription, completionCode);
|
|
199 |
|
|
200 |
if (RUsbOtgDriver::EMessageVbusError == iOTGMessage)
|
|
201 |
{
|
|
202 |
err = otgBusClearError();
|
|
203 |
|
|
204 |
if ( err )
|
|
205 |
{
|
|
206 |
return TestFailed(KErrAbort, _L("VBUS Error Clear - FAILED!"));
|
|
207 |
}
|
|
208 |
|
|
209 |
iCaseStep = EUnloadLdd;
|
|
210 |
SelfComplete();
|
|
211 |
}
|
|
212 |
else
|
|
213 |
{
|
|
214 |
iRepeats--;
|
|
215 |
if (iRepeats <0)
|
|
216 |
{
|
|
217 |
return TestFailed(KErrAbort, _L("VBUS Fall FAILED!"));
|
|
218 |
}
|
|
219 |
|
|
220 |
otgQueueOtgMessageRequest(iOTGMessage, iStatus);
|
|
221 |
SetActive();
|
|
222 |
|
|
223 |
iCaseStep = EVerifyBusFail;
|
|
224 |
}
|
|
225 |
|
|
226 |
break;
|
|
227 |
|
|
228 |
case EUnloadLdd:
|
|
229 |
|
|
230 |
if (EFalse == StepUnloadLDD())
|
|
231 |
{
|
|
232 |
return TestFailed(KErrAbort,_L("unload Ldd failure"));
|
|
233 |
}
|
|
234 |
|
|
235 |
// remove 100ma Load - this reminds the user
|
|
236 |
test.Printf(_L("\n"));
|
|
237 |
test.Printf(_L("************************\n"));
|
|
238 |
test.Printf(_L("* Using SW4 on the OET *\n"));
|
|
239 |
test.Printf(_L("* Remove 100mA LOAD! *\n"));
|
|
240 |
test.Printf(_L("************************\n"));
|
|
241 |
test.Printf(_L("\n"));
|
|
242 |
|
|
243 |
iCaseStep = ELastStep;
|
|
244 |
// press any key
|
|
245 |
test.Printf(KPressAnyKeyToContinue);
|
|
246 |
RequestCharacter();
|
|
247 |
break;
|
|
248 |
|
|
249 |
case ELastStep:
|
|
250 |
return TestPassed();
|
|
251 |
|
|
252 |
default:
|
|
253 |
test.Printf(_L("<Error> unknown test step"));
|
|
254 |
Cancel();
|
|
255 |
return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
|
|
256 |
|
|
257 |
}
|
|
258 |
|
|
259 |
}
|
|
260 |
|
|
261 |
|