author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 256 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
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 "b2bwatchers.h" |
|
26 |
#include "testcase0681.h" |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
27 |
#include "OstTraceDefinitions.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
28 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
29 |
#include "testcase0681Traces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
30 |
#endif |
0 | 31 |
|
32 |
#define _REPEATS (oOpenIterations*3) |
|
33 |
||
34 |
||
35 |
/* ************************************************************************************** |
|
36 |
* the name below is used to add a pointer to our construction method to a pointer MAP in |
|
37 |
* the class factory |
|
38 |
*/ |
|
39 |
_LIT(KTestCaseId,"PBASE-USB_OTGDI-0681"); |
|
40 |
const TTestCaseFactoryReceipt<CTestCase0681> CTestCase0681::iFactoryReceipt(KTestCaseId); |
|
41 |
||
42 |
CTestCase0681* CTestCase0681::NewL(TBool aHost) |
|
43 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
44 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
45 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
46 |
OstTraceFunctionEntry0(CTESTCASE0681_NEWL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
47 |
} |
0 | 48 |
CTestCase0681* self = new (ELeave) CTestCase0681(aHost); |
49 |
CleanupStack::PushL(self); |
|
50 |
self->ConstructL(); |
|
51 |
CleanupStack::Pop(self); |
|
52 |
return self; |
|
53 |
} |
|
54 |
||
55 |
||
56 |
CTestCase0681::CTestCase0681(TBool aHost) |
|
57 |
: CTestCaseB2BRoot(KTestCaseId, aHost, iStatus) |
|
58 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
59 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
60 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
61 |
OstTraceFunctionEntry0(CTESTCASE0681_CTESTCASE0681); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
62 |
} |
0 | 63 |
|
64 |
} |
|
65 |
||
66 |
||
67 |
/** |
|
68 |
ConstructL |
|
69 |
*/ |
|
70 |
void CTestCase0681::ConstructL() |
|
71 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
73 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
74 |
OstTraceFunctionEntry0(CTESTCASE0681_CONSTRUCTL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
75 |
} |
0 | 76 |
|
77 |
iDualRoleCase = ETrue; // another back-back |
|
78 |
||
79 |
BaseConstructL(); |
|
80 |
} |
|
81 |
||
82 |
||
83 |
CTestCase0681::~CTestCase0681() |
|
84 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
85 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
86 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
87 |
OstTraceFunctionEntry0(CTESTCASE0681_DCTESTCASE0681); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
88 |
} |
0 | 89 |
iCollector.DestroyObservers(); |
90 |
Cancel(); |
|
91 |
} |
|
92 |
||
93 |
||
94 |
void CTestCase0681::ExecuteTestCaseL() |
|
95 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
96 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
97 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
98 |
OstTraceFunctionEntry0(CTESTCASE0681_EXECUTETESTCASEL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
99 |
} |
0 | 100 |
iCaseStep = EPreconditions; |
101 |
iHNPCounter = 3; // To be decremented to govern the number of times we do HNP. |
|
102 |
CActiveScheduler::Add(this); |
|
103 |
SelfComplete(); |
|
104 |
} |
|
105 |
||
106 |
||
107 |
void CTestCase0681::DoCancel() |
|
108 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
109 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
110 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
111 |
OstTraceFunctionEntry0(CTESTCASE0681_DOCANCEL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
112 |
} |
0 | 113 |
// cancel our timer |
114 |
iTimer.Cancel(); |
|
115 |
} |
|
116 |
||
117 |
void CTestCase0681::StepB2BPreconditions() |
|
118 |
{ |
|
119 |
// prompt to insert connector and activate A-end first... |
|
120 |
if (gTestRoleMaster) |
|
121 |
{ // "B" device |
|
122 |
test.Printf(_L("***** Important note *****\n")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
123 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_STEPB2BPRECONDITIONS, "***** Important note *****\n"); |
0 | 124 |
test.Printf(_L("Before commencing test, please\n")); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
125 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_STEPB2BPRECONDITIONS_DUP01, "Before commencing test, please\n"); |
0 | 126 |
test.Printf(_L("insert 'B'-cable end and activate\n")); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
127 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_STEPB2BPRECONDITIONS_DUP02, "insert 'B'-cable end and activate\n"); |
0 | 128 |
test.Printf(_L("the test on the 'A' device.\n")); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
129 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_STEPB2BPRECONDITIONS_DUP03, "the test on the 'A' device.\n"); |
0 | 130 |
test.Printf(_L("Then, press any key to continue.\n")); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
131 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_STEPB2BPRECONDITIONS_DUP04, "Then, press any key to continue.\n"); |
0 | 132 |
test.Printf(_L("**************************\n")); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_STEPB2BPRECONDITIONS_DUP05, "**************************\n"); |
0 | 134 |
} |
135 |
else |
|
136 |
{ |
|
137 |
test.Printf(KInsertACablePrompt); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
138 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_STEPB2BPRECONDITIONS_DUP06, KInsertACablePrompt); |
0 | 139 |
test.Printf(KPressAnyKeyToContinue); |
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
140 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_STEPB2BPRECONDITIONS_DUP07, KPressAnyKeyToContinue); |
0 | 141 |
} |
142 |
||
143 |
RequestCharacter(); |
|
144 |
} |
|
145 |
||
146 |
// handle event completion |
|
147 |
void CTestCase0681::RunStepL() |
|
148 |
{ |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
149 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
150 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
151 |
OstTraceFunctionEntry0(CTESTCASE0681_RUNSTEPL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
152 |
} |
0 | 153 |
// Obtain the completion code for this CActive obj. |
154 |
TInt completionCode(iStatus.Int()); |
|
155 |
TBuf<MAX_DSTRLEN> aDescription; |
|
156 |
TInt err(0); |
|
157 |
||
158 |
if(completionCode != KErrNone) |
|
159 |
{ |
|
160 |
||
161 |
switch(completionCode) |
|
162 |
{ |
|
163 |
case KTestCaseFailureEventReceived: |
|
164 |
{ |
|
165 |
TestFailed(KErrAbort, _L("Failure Event Received")); |
|
166 |
break; |
|
167 |
} |
|
168 |
case KTestCaseWatchdogTO: |
|
169 |
{ |
|
170 |
TestFailed(KErrAbort, _L("Watchdog timer expired")); |
|
171 |
break; |
|
172 |
} |
|
173 |
default: |
|
174 |
{ |
|
175 |
TestFailed(KErrAbort, _L("Test step completed with Error")); |
|
176 |
break; |
|
177 |
} |
|
178 |
} |
|
179 |
iCollector.DestroyObservers(); |
|
180 |
return; |
|
181 |
} |
|
182 |
||
183 |
switch(iCaseStep) |
|
184 |
{ |
|
185 |
case EPreconditions: |
|
186 |
{ |
|
187 |
LOG_STEPNAME(_L("EPreconditions")) |
|
188 |
iCaseStep = ELoadLdd; |
|
189 |
StepB2BPreconditions(); |
|
190 |
break; |
|
191 |
} |
|
192 |
||
193 |
// 1. Load the Client LDD |
|
194 |
case ELoadLdd: |
|
195 |
{ |
|
196 |
LOG_STEPNAME(_L("ELoadLdd")) |
|
197 |
if (!StepLoadClient(0xF681/*use default settings for SRP/HNP support*/)) |
|
198 |
{ |
|
199 |
return TestFailed(KErrAbort, _L("Client Load Failure")); |
|
200 |
} |
|
201 |
// load OTG ldd and init. |
|
202 |
if (!StepLoadLDD()) |
|
203 |
{ |
|
204 |
return TestFailed(KErrAbort, _L("OTG Load Failure")); |
|
205 |
} |
|
206 |
||
207 |
if(otgActivateFdfActor()!=KErrNone) |
|
208 |
{ |
|
209 |
return TestFailed(KErrAbort, _L("Couldn't load FDF Actor")); |
|
210 |
} |
|
211 |
||
212 |
// test that the right cable is in |
|
213 |
CheckRoleConnections(); |
|
214 |
||
215 |
// subscribe to OTG states,events and messages now that it has loaded OK |
|
216 |
TRAPD(result, iCollector.CreateObserversL(*this)); |
|
217 |
if (KErrNone != result) |
|
218 |
return(TestFailed(KErrNoMemory, _L("Unable to create observers"))); |
|
219 |
iCollector.ClearAllEvents(); |
|
220 |
iCaseStep = EPerformSrp; |
|
221 |
SelfComplete(); |
|
222 |
break; |
|
223 |
} |
|
224 |
||
225 |
case EPerformSrp: |
|
226 |
{ |
|
227 |
test.Printf(_L("Into EPerformSrp step...\n")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
228 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_RUNSTEPL_DUP01, "Into EPerformSrp step...\n"); |
0 | 229 |
|
230 |
if (gTestRoleMaster) |
|
231 |
{ |
|
232 |
// Trigger SRP |
|
233 |
iCollector.AddRequiredNotification(EWatcherState, RUsbOtgDriver::EStateBIdle); |
|
234 |
iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventSrpInitiated); |
|
235 |
iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusRaised); |
|
236 |
iCollector.AddRequiredNotification(EWatcherState, RUsbOtgDriver::EStateBHost); |
|
237 |
||
238 |
// We shouldn't get configured at any point however since ADevice will call |
|
239 |
// BusRespondSrp which should bypass that stage on the way to enabling us to |
|
240 |
// role swap. |
|
241 |
iCollector.AddFailureNotification(EWatcherPeripheralState, EUsbcDeviceStateConfigured); |
|
242 |
||
243 |
err = otgBusRequest(); |
|
244 |
if (KErrNone != err) |
|
245 |
{ |
|
246 |
return TestFailed(KErrAbort, _L("Raise Vbus - RUsbOtgDriver::BusRequest() FAILED!")); |
|
247 |
} |
|
248 |
||
249 |
iCaseStep = ESwappedRoles; |
|
250 |
} |
|
251 |
else |
|
252 |
{ // slave "A" |
|
253 |
// Wait for SRP |
|
254 |
||
255 |
iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventSrpReceived); |
|
256 |
||
257 |
iCaseStep = EAReceivedSrp; |
|
258 |
} |
|
259 |
const TInt KTestCase0681Timeout = 30000; // 30 seconds, should be plenty of time for 3 role swaps |
|
260 |
iCollector.AddStepTimeout(KTestCase0681Timeout); |
|
261 |
SetActive(); |
|
262 |
break; |
|
263 |
} |
|
264 |
||
265 |
case EAReceivedSrp: // A-Device step only! |
|
266 |
{ |
|
267 |
test.Printf(_L("Into EAReceivedSrp step...\n")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
268 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_RUNSTEPL_DUP02, "Into EAReceivedSrp step...\n"); |
0 | 269 |
|
270 |
if (KTestCaseWatchdogTO == iStatus.Int()) |
|
271 |
{ |
|
272 |
iCollector.DestroyObservers(); |
|
273 |
return TestFailed(KErrAbort, _L("Timeout")); |
|
274 |
} |
|
275 |
||
276 |
iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusRaised); |
|
277 |
iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventRoleChangedToDevice); |
|
278 |
iCollector.AddRequiredNotification(EWatcherState, RUsbOtgDriver::EStateAPeripheral); |
|
279 |
||
280 |
// We've received SRP. We use BusRespondSRP to raise VBus and cede the host role |
|
281 |
err = otgBusRespondSRP(); |
|
282 |
if (KErrNone != err) |
|
283 |
{ |
|
284 |
return TestFailed(KErrAbort, _L("Raise Vbus - RUsbOtgDriver::BusRequest() FAILED!")); |
|
285 |
} |
|
286 |
||
287 |
iCaseStep = ESwappedRoles; |
|
288 |
SetActive(); |
|
289 |
break; |
|
290 |
} |
|
291 |
||
292 |
case ESwappedRoles: |
|
293 |
{ |
|
294 |
test.Printf(_L("Into ESwappedRoles step...\n")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
295 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_RUNSTEPL_DUP03, "Into ESwappedRoles step...\n"); |
0 | 296 |
if (KTestCaseWatchdogTO == iStatus.Int()) |
297 |
{ |
|
298 |
iCollector.DestroyObservers(); |
|
299 |
return TestFailed(KErrAbort, _L("Timeout")); |
|
300 |
} |
|
301 |
||
302 |
if (gTestRoleMaster) |
|
303 |
{ |
|
304 |
// B-Device should now wait until it is B-Peripheral |
|
305 |
iCollector.AddRequiredNotification(EWatcherState, RUsbOtgDriver::EStateBPeripheral); |
|
306 |
iCaseStep = EDefaultRoles; |
|
307 |
} |
|
308 |
else |
|
309 |
{ |
|
310 |
// A-Device should wait to become a configured A-Peripheral |
|
311 |
iCollector.AddRequiredNotification(EWatcherPeripheralState, EUsbcDeviceStateConfigured); |
|
312 |
iCaseStep = EAConfigured; |
|
313 |
} |
|
314 |
SetActive(); |
|
315 |
break; |
|
316 |
} |
|
317 |
||
318 |
case EAConfigured: // A-Device only step |
|
319 |
{ |
|
320 |
test.Printf(_L("Into EAConfigured step...\n")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
321 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_RUNSTEPL_DUP04, "Into EAConfigured step...\n"); |
0 | 322 |
if (KTestCaseWatchdogTO == iStatus.Int()) |
323 |
{ |
|
324 |
iCollector.DestroyObservers(); |
|
325 |
return TestFailed(KErrAbort, _L("Timeout")); |
|
326 |
} |
|
327 |
||
328 |
iCollector.AddRequiredNotification(EWatcherPeripheralState, EUsbcDeviceStateSuspended); |
|
329 |
iCaseStep = EASuspended; |
|
330 |
SetActive(); |
|
331 |
break; |
|
332 |
} |
|
333 |
||
334 |
case EASuspended: // A-Device only step |
|
335 |
{ |
|
336 |
test.Printf(_L("Into EASuspended step...\n")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
337 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_RUNSTEPL_DUP05, "Into EASuspended step...\n"); |
0 | 338 |
if (KTestCaseWatchdogTO == iStatus.Int()) |
339 |
{ |
|
340 |
iCollector.DestroyObservers(); |
|
341 |
return TestFailed(KErrAbort, _L("Timeout")); |
|
342 |
} |
|
343 |
||
344 |
iCollector.AddRequiredNotification(EWatcherState, RUsbOtgDriver::EStateAHost); // Swapping back to default role |
|
345 |
||
346 |
iCaseStep = EDefaultRoles; |
|
347 |
SetActive(); |
|
348 |
break; |
|
349 |
} |
|
350 |
||
351 |
case EDefaultRoles: |
|
352 |
{ |
|
353 |
test.Printf(_L("Into EDefaultRoles step...\n")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
354 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_RUNSTEPL_DUP06, "Into EDefaultRoles step...\n"); |
0 | 355 |
|
356 |
if ( --iHNPCounter >= 0) |
|
357 |
{ |
|
358 |
// We want to do further role swapping |
|
359 |
if (gTestRoleMaster) |
|
360 |
{ |
|
361 |
// B-Device should now wait until it is configured |
|
362 |
iCollector.AddRequiredNotification(EWatcherPeripheralState, EUsbcDeviceStateConfigured); |
|
363 |
iCaseStep = EBConfigured; |
|
364 |
} |
|
365 |
else |
|
366 |
{ |
|
367 |
// A-Device should expect nothing more until it becomes A-Peripheral |
|
368 |
iCollector.AddRequiredNotification(EWatcherState, RUsbOtgDriver::EStateAPeripheral); |
|
369 |
iCaseStep = ESwappedRoles; |
|
370 |
} |
|
371 |
SetActive(); |
|
372 |
} |
|
373 |
else |
|
374 |
{ |
|
375 |
// We've done 3 x HNP cycles back to default roles. |
|
376 |
// Time to shut down VBus and stop the test case. |
|
377 |
iCaseStep = EDropVBus; |
|
378 |
SelfComplete(); |
|
379 |
} |
|
380 |
break; |
|
381 |
} |
|
382 |
||
383 |
||
384 |
case EBConfigured: // A B-Device only step! |
|
385 |
{ |
|
386 |
test.Printf(_L("Into EBConfigured step...\n")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
387 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_RUNSTEPL_DUP07, "Into EBConfigured step...\n"); |
0 | 388 |
if (KTestCaseWatchdogTO == iStatus.Int()) |
389 |
{ |
|
390 |
iCollector.DestroyObservers(); |
|
391 |
return TestFailed(KErrAbort, _L("Timeout")); |
|
392 |
} |
|
393 |
iCollector.AddRequiredNotification(EWatcherPeripheralState, EUsbcDeviceStateSuspended); |
|
394 |
iCaseStep = EBSuspended; |
|
395 |
SetActive(); |
|
396 |
break; |
|
397 |
} |
|
398 |
||
399 |
case EBSuspended: |
|
400 |
{ |
|
401 |
test.Printf(_L("Into EBSuspended step...\n")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
402 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_RUNSTEPL_DUP08, "Into EBSuspended step...\n"); |
0 | 403 |
if (KTestCaseWatchdogTO == iStatus.Int()) |
404 |
{ |
|
405 |
iCollector.DestroyObservers(); |
|
406 |
return TestFailed(KErrAbort, _L("Timeout")); |
|
407 |
} |
|
408 |
||
409 |
// issue HNP |
|
410 |
test.Printf(_L("VBus present, attempting a swap.\n")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
411 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_RUNSTEPL_DUP09, "VBus present, attempting a swap.\n"); |
0 | 412 |
iCollector.AddRequiredNotification(EWatcherState, RUsbOtgDriver::EStateBHost); |
413 |
||
414 |
err = otgBusRequest(); // Request the host role |
|
415 |
||
416 |
if (KErrNone != err) |
|
417 |
{ |
|
418 |
test.Printf(_L("BusRequest returned %d\n"),err); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
419 |
OstTrace1(TRACE_NORMAL, CTESTCASE0681_RUNSTEPL_DUP10, "BusRequest returned %d\n",err); |
0 | 420 |
return TestFailed(KErrAbort, _L("BusRequest() failed!")); |
421 |
} |
|
422 |
||
423 |
iCaseStep = ESwappedRoles; |
|
424 |
SetActive(); |
|
425 |
break; |
|
426 |
} |
|
427 |
||
428 |
||
429 |
||
430 |
case EDropVBus: |
|
431 |
LOG_STEPNAME(_L("EDropVBus")) |
|
432 |
||
433 |
iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusDropped); |
|
434 |
if ( gTestRoleMaster) |
|
435 |
{ |
|
436 |
iCollector.AddRequiredNotification(EWatcherState, RUsbOtgDriver::EStateBIdle); |
|
437 |
iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventRoleChangedToDevice); |
|
438 |
} |
|
439 |
else |
|
440 |
{ // SLAVE "A" |
|
441 |
otgBusDrop(); |
|
442 |
iCollector.AddRequiredNotification(EWatcherState, RUsbOtgDriver::EStateAIdle); |
|
443 |
iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventRoleChangedToHost); |
|
444 |
} |
|
445 |
iCaseStep = EVBusDropped; |
|
446 |
SetActive(); |
|
447 |
break; |
|
448 |
||
449 |
case EVBusDropped: |
|
450 |
LOG_STEPNAME(_L("ELoopVerifyDrop")) |
|
451 |
if (KTestCaseWatchdogTO == iStatus.Int()) |
|
452 |
{ |
|
453 |
return TestFailed(KErrAbort, _L("Timeout")); |
|
454 |
} |
|
455 |
||
456 |
if (otgVbusPresent()) |
|
457 |
{ |
|
458 |
return TestFailed(KErrAbort, _L("Vbus did not drop - FAILED!")); |
|
459 |
} |
|
460 |
iCaseStep = EUnloadLdd; |
|
461 |
SelfComplete(); |
|
462 |
break; |
|
463 |
||
464 |
case EUnloadLdd: |
|
465 |
LOG_STEPNAME(_L("EUnloadLdd")) |
|
466 |
otgDeactivateFdfActor(); |
|
467 |
iCollector.DestroyObservers(); |
|
468 |
if (EFalse == StepUnloadLDD()) |
|
469 |
return TestFailed(KErrAbort,_L("unload Ldd failure")); |
|
470 |
if (!StepUnloadClient()) |
|
471 |
return TestFailed(KErrAbort,_L("Client Unload Failure")); |
|
472 |
||
473 |
iCaseStep = ELastStep; |
|
474 |
SelfComplete(); |
|
475 |
break; |
|
476 |
||
477 |
case ELastStep: |
|
478 |
LOG_STEPNAME(_L("ELastStep")) |
|
479 |
TestPassed(); |
|
480 |
break; |
|
481 |
||
482 |
default: |
|
483 |
test.Printf(_L("<Error> unknown test step")); |
|
256
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
484 |
OstTrace0(TRACE_NORMAL, CTESTCASE0681_RUNSTEPL_DUP11, "<Error> unknown test step"); |
0 | 485 |
Cancel(); |
486 |
return (TestFailed(KErrCorrupt, _L("<Error> unknown test step"))); |
|
487 |
} |
|
488 |
} |