44
|
1 |
// Copyright (c) 2007-2009 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 "b2bwatchers.h"
|
|
26 |
#include "testcase1233.h"
|
|
27 |
|
|
28 |
#include <e32debug.h>
|
|
29 |
|
|
30 |
#define LOG_INTO_STEP(a) test.Printf(_L("\nInto Step [%S]\n\n"), &a);
|
|
31 |
|
|
32 |
/* **************************************************************************************
|
|
33 |
* the name below is used to add a pointer to our construction method to a pointer MAP in
|
|
34 |
* the class factory
|
|
35 |
*/
|
|
36 |
_LIT(KTestCaseId,"PBASE-USB_OTGDI-1233");
|
|
37 |
const TTestCaseFactoryReceipt<CTestCase1233> CTestCase1233::iFactoryReceipt(KTestCaseId);
|
|
38 |
|
|
39 |
CTestCase1233* CTestCase1233::NewL(TBool aHost)
|
|
40 |
{
|
44
|
41 |
LOG_FUNC
|
0
|
42 |
CTestCase1233* self = new (ELeave) CTestCase1233(aHost);
|
|
43 |
CleanupStack::PushL(self);
|
|
44 |
self->ConstructL();
|
|
45 |
CleanupStack::Pop(self);
|
|
46 |
return self;
|
|
47 |
}
|
|
48 |
|
|
49 |
|
|
50 |
CTestCase1233::CTestCase1233(TBool aHost)
|
|
51 |
: CTestCaseB2BRoot(KTestCaseId, aHost, iStatus)
|
|
52 |
{
|
44
|
53 |
LOG_FUNC
|
0
|
54 |
|
|
55 |
}
|
|
56 |
|
|
57 |
|
|
58 |
/**
|
|
59 |
ConstructL
|
|
60 |
*/
|
|
61 |
void CTestCase1233::ConstructL()
|
|
62 |
{
|
44
|
63 |
LOG_FUNC
|
0
|
64 |
|
|
65 |
iTestVID = 0x0E22; // Symbian
|
|
66 |
iTestPID = 0xF000 + 1233; // Test 1233
|
|
67 |
|
|
68 |
BaseConstructL();
|
|
69 |
}
|
|
70 |
|
|
71 |
|
|
72 |
CTestCase1233::~CTestCase1233()
|
|
73 |
{
|
44
|
74 |
LOG_FUNC
|
0
|
75 |
iCollector.DestroyObservers();
|
|
76 |
Cancel();
|
|
77 |
}
|
|
78 |
|
|
79 |
|
|
80 |
void CTestCase1233::ExecuteTestCaseL()
|
|
81 |
{
|
44
|
82 |
LOG_FUNC
|
0
|
83 |
iCaseStep = EPreconditions;
|
|
84 |
CActiveScheduler::Add(this);
|
|
85 |
SelfComplete();
|
|
86 |
}
|
|
87 |
|
|
88 |
|
|
89 |
void CTestCase1233::DoCancel()
|
|
90 |
{
|
44
|
91 |
LOG_FUNC
|
0
|
92 |
// cancel our timer
|
|
93 |
iTimer.Cancel();
|
|
94 |
}
|
|
95 |
|
|
96 |
|
|
97 |
void CTestCase1233::RunStepL()
|
|
98 |
{
|
44
|
99 |
LOG_FUNC
|
0
|
100 |
|
|
101 |
// Obtain the completion code for this CActive obj.
|
|
102 |
TInt completionCode(iStatus.Int());
|
|
103 |
TBuf<MAX_DSTRLEN> aDescription;
|
|
104 |
|
|
105 |
switch(iCaseStep)
|
|
106 |
{
|
|
107 |
/*==================================================*/
|
|
108 |
/* Fixed 'pre' steps */
|
|
109 |
/*==================================================*/
|
|
110 |
case EPreconditions:
|
|
111 |
{
|
|
112 |
LOG_INTO_STEP(_L("EPreconditions"))
|
|
113 |
|
|
114 |
iCaseStep = ELoadLdd;
|
|
115 |
StepB2BPreconditions();
|
|
116 |
break;
|
|
117 |
}
|
|
118 |
|
|
119 |
case ELoadLdd:
|
|
120 |
{
|
|
121 |
LOG_INTO_STEP(_L("ELoadLdd"))
|
|
122 |
|
|
123 |
// Note we use here the hex equivalent of #1233 for the PID
|
|
124 |
|
|
125 |
if (!StepLoadClient(0xF4D1/*use default settings for SRP/HNP support*/))
|
|
126 |
{
|
|
127 |
return TestFailed(KErrAbort, _L("Client Load Failure"));
|
|
128 |
}
|
|
129 |
|
|
130 |
// load OTG ldd and init.
|
|
131 |
if (!StepLoadLDD())
|
|
132 |
{
|
|
133 |
return TestFailed(KErrAbort, _L("OTG Load Failure"));
|
|
134 |
}
|
|
135 |
|
|
136 |
if(otgActivateFdfActor()!=KErrNone)
|
|
137 |
{
|
|
138 |
return TestFailed(KErrAbort, _L("Couldn't load FDF Actor"));
|
|
139 |
}
|
|
140 |
|
|
141 |
// test that the right cable is in
|
|
142 |
CheckRoleConnections();
|
|
143 |
|
|
144 |
// subscribe to OTG states,events and messages now that it has loaded OK
|
|
145 |
TRAPD(result, iCollector.CreateObserversL(*this));
|
|
146 |
if (KErrNone != result)
|
|
147 |
{
|
|
148 |
return(TestFailed(KErrNoMemory, _L("Unable to create observers")));
|
|
149 |
}
|
|
150 |
|
|
151 |
// Allow enough time for 8 enumerations, say a second each, plus two of the
|
|
152 |
// tests require 15 seconds of SOF traffic
|
|
153 |
|
|
154 |
const TInt KTestCase1233Timeout = 45000;
|
|
155 |
iCollector.AddStepTimeout(KTestCase1233Timeout);
|
|
156 |
|
|
157 |
iCollector.ClearAllEvents();
|
|
158 |
iCaseStep = ERaiseVBus;
|
|
159 |
|
|
160 |
SelfComplete();
|
|
161 |
break;
|
|
162 |
}
|
|
163 |
|
|
164 |
/*==================================================*/
|
|
165 |
/* Steps for this test case only */
|
|
166 |
/*==================================================*/
|
|
167 |
|
|
168 |
case ELoopToNextPID:
|
|
169 |
{
|
|
170 |
LOG_INTO_STEP(_L("ELoopToNextPID"));
|
|
171 |
|
|
172 |
if (KTestCaseWatchdogTO == iStatus.Int())
|
|
173 |
{
|
|
174 |
iCollector.DestroyObservers();
|
|
175 |
return TestFailed(KErrAbort, _L("Timeout"));
|
|
176 |
}
|
|
177 |
|
|
178 |
if ( iTestVID == 0x0E22 )
|
|
179 |
{
|
|
180 |
iTestVID = 0x1A0A; // OPT and test devices
|
|
181 |
iTestPID = 0x0100; // One *before* the first HS test ID
|
|
182 |
}
|
|
183 |
|
|
184 |
iTestPID++;
|
|
185 |
|
|
186 |
if ( iTestPID > 0x0108 )
|
|
187 |
{
|
|
188 |
test.Printf(_L("All VID/PID pairs done\n"));
|
|
189 |
|
|
190 |
iCaseStep = EUnloadLdd;
|
|
191 |
}
|
|
192 |
else
|
|
193 |
{
|
|
194 |
if(gTestRoleMaster)
|
|
195 |
{
|
|
196 |
// B
|
|
197 |
test.Printf(_L("Setting VID/PID of 0x%04x/0x%04x\n"),iTestVID,iTestPID);
|
|
198 |
|
|
199 |
if (!StepChangeVidPid(iTestVID,iTestPID))
|
|
200 |
{
|
|
201 |
return TestFailed(KErrAbort, _L("VID/PID Change Failure"));
|
|
202 |
}
|
|
203 |
}
|
|
204 |
else
|
|
205 |
{
|
|
206 |
// A
|
|
207 |
test.Printf(_L("Expecting VID/PID of 0x%04x/0x%04x\n"),iTestVID,iTestPID);
|
|
208 |
}
|
|
209 |
|
|
210 |
iCollector.ClearAllEvents();
|
|
211 |
iCaseStep = ERaiseVBus;
|
|
212 |
}
|
|
213 |
|
|
214 |
SelfComplete();
|
|
215 |
break;
|
|
216 |
}
|
|
217 |
|
|
218 |
case ERaiseVBus:
|
|
219 |
{
|
|
220 |
LOG_INTO_STEP(_L("ERaiseVBus"));
|
|
221 |
|
|
222 |
if (KTestCaseWatchdogTO == iStatus.Int())
|
|
223 |
{
|
|
224 |
iCollector.DestroyObservers();
|
|
225 |
return TestFailed(KErrAbort, _L("Timeout"));
|
|
226 |
}
|
|
227 |
|
|
228 |
if (gTestRoleMaster)
|
|
229 |
{
|
|
230 |
// B device
|
|
231 |
iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusRaised);
|
|
232 |
iCollector.AddRequiredNotification(EWatcherState, RUsbOtgDriver::EStateBPeripheral);
|
|
233 |
iCollector.AddRequiredNotification(EWatcherPeripheralState, EUsbcDeviceStateDefault);
|
|
234 |
iCollector.AddRequiredNotification(EWatcherPeripheralState, EUsbcDeviceStateAddress);
|
|
235 |
iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventHnpEnabled);
|
|
236 |
iCollector.AddRequiredNotification(EWatcherPeripheralState, EUsbcDeviceStateConfigured);
|
|
237 |
}
|
|
238 |
else
|
|
239 |
{
|
|
240 |
// A device
|
|
241 |
test.Printf(_L("Raising VBUS for VID/PID = 0x%04x/0x%04x\n"),iTestVID,iTestPID);
|
|
242 |
|
|
243 |
if ( otgBusRequest() != KErrNone )
|
|
244 |
{
|
|
245 |
return TestFailed(KErrAbort, _L("Raise Vbus - RUsbOtgDriver::BusRequest() FAILED!"));
|
|
246 |
}
|
|
247 |
|
|
248 |
iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusRaised);
|
|
249 |
iCollector.AddRequiredNotification(EWatcherAConnectionIdle, RUsbOtgDriver::EConnectionBusy);
|
|
250 |
iCollector.AddRequiredNotification(EWatcherState, RUsbOtgDriver::EStateAHost);
|
|
251 |
}
|
|
252 |
|
|
253 |
iCaseStep = EVBusRaised;
|
|
254 |
SetActive();
|
|
255 |
break;
|
|
256 |
}
|
|
257 |
|
|
258 |
case EVBusRaised:
|
|
259 |
{
|
|
260 |
LOG_INTO_STEP(_L("EVBusRaised"));
|
|
261 |
|
|
262 |
if (KTestCaseWatchdogTO == iStatus.Int())
|
|
263 |
{
|
|
264 |
return TestFailed(KErrAbort, _L("Timeout"));
|
|
265 |
}
|
|
266 |
|
|
267 |
if ( otgVbusPresent() )
|
|
268 |
{
|
|
269 |
test.Printf(_L("...VBUS is UP\n"));
|
|
270 |
iCaseStep = EDropVBus;
|
|
271 |
}
|
|
272 |
else
|
|
273 |
{
|
|
274 |
test.Printf(_L("...VBUS is DOWN\n"));
|
|
275 |
return TestFailed(KErrAbort, _L("Vbus did not rise - FAILED!"));
|
|
276 |
}
|
|
277 |
|
|
278 |
if (gTestRoleMaster)
|
|
279 |
{
|
|
280 |
// B device
|
|
281 |
SelfComplete();
|
|
282 |
}
|
|
283 |
else
|
|
284 |
{
|
|
285 |
// A device
|
|
286 |
|
|
287 |
// The default device (0x0E22/0xB4D1) is passed to the FDF, which will (eventually)
|
|
288 |
// suspend and enter connection idle state.
|
|
289 |
|
|
290 |
// The HS test devices (0x1A0A) will not be presented to FDF, so there will be no
|
|
291 |
// trailing connection idle to find.
|
|
292 |
|
|
293 |
if ( iTestVID == 0x0E22 )
|
|
294 |
{
|
|
295 |
iCollector.AddRequiredNotification(EWatcherAConnectionIdle, RUsbOtgDriver::EConnectionIdle);
|
|
296 |
SetActive();
|
|
297 |
}
|
|
298 |
else
|
|
299 |
{
|
|
300 |
SelfComplete();
|
|
301 |
}
|
|
302 |
}
|
|
303 |
|
|
304 |
break;
|
|
305 |
}
|
|
306 |
|
|
307 |
case EDropVBus:
|
|
308 |
{
|
|
309 |
LOG_INTO_STEP(_L("EDropVBus"));
|
|
310 |
|
|
311 |
if (KTestCaseWatchdogTO == iStatus.Int())
|
|
312 |
{
|
|
313 |
iCollector.DestroyObservers();
|
|
314 |
return TestFailed(KErrAbort, _L("Timeout"));
|
|
315 |
}
|
|
316 |
|
|
317 |
if ( gTestRoleMaster)
|
|
318 |
{
|
|
319 |
// B device
|
|
320 |
iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusDropped);
|
|
321 |
}
|
|
322 |
else
|
|
323 |
{
|
|
324 |
// A device
|
|
325 |
otgBusDrop();
|
|
326 |
|
|
327 |
iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusDropped);
|
|
328 |
}
|
|
329 |
|
|
330 |
iCaseStep = EVBusDropped;
|
|
331 |
SetActive();
|
|
332 |
break;
|
|
333 |
}
|
|
334 |
|
|
335 |
case EVBusDropped:
|
|
336 |
{
|
|
337 |
LOG_INTO_STEP(_L("EVBusDropped"));
|
|
338 |
|
|
339 |
if (KTestCaseWatchdogTO == iStatus.Int())
|
|
340 |
{
|
|
341 |
return TestFailed(KErrAbort, _L("Timeout"));
|
|
342 |
}
|
|
343 |
|
|
344 |
if ( otgVbusPresent() )
|
|
345 |
{
|
|
346 |
test.Printf(_L("...VBUS is UP\n"));
|
|
347 |
return TestFailed(KErrAbort, _L("Vbus did not rise - FAILED!"));
|
|
348 |
}
|
|
349 |
else
|
|
350 |
{
|
|
351 |
test.Printf(_L("...VBUS is DOWN\n"));
|
|
352 |
iCaseStep = ELoopToNextPID;
|
|
353 |
}
|
|
354 |
|
|
355 |
SelfComplete();
|
|
356 |
break;
|
|
357 |
}
|
|
358 |
|
|
359 |
/*==================================================*/
|
|
360 |
/* Fixed 'post' steps */
|
|
361 |
/*==================================================*/
|
|
362 |
|
|
363 |
case EUnloadLdd:
|
|
364 |
{
|
|
365 |
LOG_INTO_STEP(_L("EUnloadLdd"))
|
|
366 |
|
|
367 |
otgDeactivateFdfActor();
|
|
368 |
iCollector.DestroyObservers();
|
|
369 |
if (EFalse == StepUnloadLDD()){
|
|
370 |
return TestFailed(KErrAbort,_L("unload Ldd failure"));
|
|
371 |
}
|
|
372 |
if (!StepUnloadClient()){
|
|
373 |
return TestFailed(KErrAbort,_L("Client Unload Failure"));
|
|
374 |
}
|
|
375 |
|
|
376 |
iCaseStep = ELastStep;
|
|
377 |
SelfComplete();
|
|
378 |
break;
|
|
379 |
}
|
|
380 |
|
|
381 |
case ELastStep:
|
|
382 |
{
|
|
383 |
LOG_INTO_STEP(_L("ELastStep"))
|
|
384 |
|
|
385 |
TestPassed();
|
|
386 |
RequestCharacter();
|
|
387 |
break;
|
|
388 |
}
|
|
389 |
|
|
390 |
default:
|
|
391 |
{
|
|
392 |
LOG_INTO_STEP(_L("DEFAULT! (unknown test step)"));
|
|
393 |
Cancel();
|
|
394 |
RequestCharacter();
|
|
395 |
return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
|
|
396 |
}
|
|
397 |
}
|
|
398 |
|
|
399 |
}
|