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 |
// @file PBASE-T_USBDI-0473.cpp
|
|
15 |
// @internalComponent
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include "PBASE-T_USBDI-0473.h"
|
|
20 |
#include <d32usbc.h>
|
|
21 |
#include "testdebug.h"
|
|
22 |
#include "modelleddevices.h"
|
|
23 |
#include "TestPolicy.h"
|
253
|
24 |
#include "OstTraceDefinitions.h"
|
|
25 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
26 |
#include "PBASE-T_USBDI-0473Traces.h"
|
|
27 |
#endif
|
0
|
28 |
|
|
29 |
namespace NUnitTesting_USBDI
|
|
30 |
{
|
|
31 |
|
|
32 |
_LIT(KTestCaseId,"PBASE-T_USBDI-0473");
|
|
33 |
const TFunctorTestCase<CUT_PBASE_T_USBDI_0473,TBool> CUT_PBASE_T_USBDI_0473::iFunctor(KTestCaseId);
|
|
34 |
|
|
35 |
CUT_PBASE_T_USBDI_0473* CUT_PBASE_T_USBDI_0473::NewL(TBool aHostRole)
|
|
36 |
{
|
253
|
37 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0473_NEWL_ENTRY, aHostRole );
|
0
|
38 |
CUT_PBASE_T_USBDI_0473* self = new (ELeave) CUT_PBASE_T_USBDI_0473(aHostRole);
|
|
39 |
CleanupStack::PushL(self);
|
|
40 |
self->ConstructL();
|
|
41 |
CleanupStack::Pop(self);
|
253
|
42 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0473_NEWL_EXIT, ( TUint )( self ) );
|
0
|
43 |
return self;
|
|
44 |
}
|
|
45 |
|
|
46 |
|
|
47 |
CUT_PBASE_T_USBDI_0473::CUT_PBASE_T_USBDI_0473(TBool aHostRole)
|
|
48 |
: CBaseTestCase(KTestCaseId,aHostRole),
|
|
49 |
iSuspendedI0(EFalse),
|
|
50 |
iSuspendedI1(EFalse),
|
|
51 |
iDeviceNotificationPending(ETrue)
|
|
52 |
{
|
253
|
53 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0473_CUT_PBASE_T_USBDI_0473_ENTRY, this );
|
|
54 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0473_CUT_PBASE_T_USBDI_0473_EXIT, this );
|
0
|
55 |
}
|
|
56 |
|
|
57 |
|
|
58 |
void CUT_PBASE_T_USBDI_0473::ConstructL()
|
|
59 |
{
|
253
|
60 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0473_CONSTRUCTL_ENTRY, this );
|
0
|
61 |
iTestDevice = new RUsbDeviceA(this);
|
|
62 |
BaseConstructL();
|
253
|
63 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0473_CONSTRUCTL_EXIT, this );
|
0
|
64 |
}
|
|
65 |
|
|
66 |
|
|
67 |
CUT_PBASE_T_USBDI_0473::~CUT_PBASE_T_USBDI_0473()
|
|
68 |
{
|
253
|
69 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0473_CUT_PBASE_T_USBDI_0473_ENTRY_DUP01, this );
|
0
|
70 |
|
|
71 |
// Cancel any async operations
|
|
72 |
|
|
73 |
Cancel(); // Cancel host timer
|
|
74 |
|
|
75 |
// Destroy the watchers
|
|
76 |
// they still use opened interfaces to cancel the suspend if active
|
|
77 |
delete iInterface1Watcher;
|
|
78 |
delete iInterface0Watcher;
|
|
79 |
|
|
80 |
// Close the interfaces
|
|
81 |
iUsbInterface1.Close();
|
|
82 |
iUsbInterface0.Close();
|
|
83 |
|
|
84 |
delete iControlEp0;
|
|
85 |
delete iActorFDF;
|
|
86 |
if(!IsHost() && iTestDevice)
|
|
87 |
{
|
|
88 |
iTestDevice->Close();
|
|
89 |
}
|
|
90 |
delete iTestDevice;
|
253
|
91 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0473_CUT_PBASE_T_USBDI_0473_EXIT_DUP01, this );
|
0
|
92 |
}
|
|
93 |
|
|
94 |
|
|
95 |
void CUT_PBASE_T_USBDI_0473::ExecuteHostTestCaseL()
|
|
96 |
{
|
253
|
97 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0473_EXECUTEHOSTTESTCASEL_ENTRY, this );
|
0
|
98 |
iCaseStep = EStepSuspend;
|
|
99 |
iActorFDF = CActorFDF::NewL(*this);
|
|
100 |
iControlEp0 = new (ELeave) CEp0Transfer(iUsbInterface0);
|
|
101 |
iInterface0Watcher = new (ELeave) CInterfaceWatcher(iUsbInterface0,TCallBack(CUT_PBASE_T_USBDI_0473::Interface0ResumedL,this));
|
|
102 |
iInterface1Watcher = new (ELeave) CInterfaceWatcher(iUsbInterface1,TCallBack(CUT_PBASE_T_USBDI_0473::Interface1ResumedL,this));
|
|
103 |
|
|
104 |
// Monitor for device connections
|
|
105 |
iActorFDF->Monitor();
|
|
106 |
|
|
107 |
// Start the connection timeout
|
|
108 |
TimeoutIn(30);
|
253
|
109 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0473_EXECUTEHOSTTESTCASEL_EXIT, this );
|
0
|
110 |
}
|
|
111 |
|
|
112 |
void CUT_PBASE_T_USBDI_0473::ExecuteDeviceTestCaseL()
|
|
113 |
{
|
253
|
114 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0473_EXECUTEDEVICETESTCASEL_ENTRY, this );
|
0
|
115 |
|
|
116 |
// Construct the device for the test case
|
|
117 |
iTestDevice->OpenL(TestCaseId());
|
|
118 |
iTestDevice->SubscribeToReports(iStatus);
|
|
119 |
SetActive();
|
|
120 |
|
|
121 |
// Connect the test device
|
|
122 |
iTestDevice->SoftwareConnect();
|
253
|
123 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0473_EXECUTEDEVICETESTCASEL_EXIT, this );
|
0
|
124 |
}
|
|
125 |
|
|
126 |
|
|
127 |
void CUT_PBASE_T_USBDI_0473::HostDoCancel()
|
|
128 |
{
|
253
|
129 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0473_HOSTDOCANCEL_ENTRY, this );
|
0
|
130 |
|
|
131 |
// Cancel the timeout timer
|
|
132 |
CancelTimeout();
|
253
|
133 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0473_HOSTDOCANCEL_EXIT, this );
|
0
|
134 |
}
|
|
135 |
|
|
136 |
|
|
137 |
void CUT_PBASE_T_USBDI_0473::DeviceDoCancel()
|
|
138 |
{
|
253
|
139 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0473_DEVICEDOCANCEL_ENTRY, this );
|
0
|
140 |
|
|
141 |
// Cancel the device
|
|
142 |
iTestDevice->CancelSubscriptionToReports();
|
253
|
143 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0473_DEVICEDOCANCEL_EXIT, this );
|
0
|
144 |
}
|
|
145 |
|
|
146 |
void CUT_PBASE_T_USBDI_0473::DeviceInsertedL(TUint aDeviceHandle)
|
|
147 |
{
|
253
|
148 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_ENTRY, this );
|
0
|
149 |
|
|
150 |
Cancel(); // Cancel the timer
|
|
151 |
TInt err(KErrNone);
|
|
152 |
iDeviceHandle = aDeviceHandle;
|
|
153 |
iActorFDF->Monitor();
|
|
154 |
|
|
155 |
// Validate that device is as expected
|
|
156 |
CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle);
|
|
157 |
if(testDevice.SerialNumber().Compare(TestCaseId()) != 0)
|
|
158 |
{
|
|
159 |
// Incorrect device for this test case
|
|
160 |
|
253
|
161 |
OstTraceExt3(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL, "<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)",
|
|
162 |
KErrNotFound,testDevice.SerialNumber(),TestCaseId());
|
0
|
163 |
|
|
164 |
// Start the connection timeout again
|
|
165 |
TimeoutIn(30);
|
253
|
166 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_EXIT, this );
|
0
|
167 |
return;
|
|
168 |
}
|
|
169 |
// Check tree now
|
|
170 |
CHECK(CheckTreeAfterDeviceInsertion(testDevice, _L("RDeviceA")) == KErrNone);
|
|
171 |
|
|
172 |
// Perform the correct test step
|
|
173 |
switch(iCaseStep)
|
|
174 |
{
|
|
175 |
case EStepSuspend:
|
|
176 |
{
|
|
177 |
TUint32 token1(0);
|
|
178 |
TUint32 token2(0);
|
|
179 |
|
253
|
180 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_DUP01, "Obtaining token for interface 0");
|
0
|
181 |
err = testDevice.Device().GetTokenForInterface(0,token1);
|
|
182 |
if(err != KErrNone)
|
|
183 |
{
|
253
|
184 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_DUP02, "<Error %d> Token for interface 0 could not be retrieved",err);
|
0
|
185 |
return TestFailed(err);
|
|
186 |
}
|
253
|
187 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_DUP03, "Token 1 (%d) retrieved",token1);
|
|
188 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_DUP04, "Opening interface 0");
|
0
|
189 |
err = iUsbInterface0.Open(token1); // Alternate interface setting 0
|
|
190 |
if(err != KErrNone)
|
|
191 |
{
|
253
|
192 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_DUP05, "<Error %d> Interface 0 could not be opened",err);
|
0
|
193 |
return TestFailed(err);
|
|
194 |
}
|
253
|
195 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_DUP06, "Interface 0 opened");
|
0
|
196 |
|
|
197 |
|
253
|
198 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_DUP07, "Obtaining token for interface 1");
|
0
|
199 |
err = testDevice.Device().GetTokenForInterface(1,token2);
|
|
200 |
if(err != KErrNone)
|
|
201 |
{
|
253
|
202 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_DUP08, "<Error %d> Token for interface 1 could not be retrieved",err);
|
0
|
203 |
return TestFailed(err);
|
|
204 |
}
|
253
|
205 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_DUP09, "Opening interface 1");
|
0
|
206 |
err = iUsbInterface1.Open(token2); // Alternate interface setting 0
|
|
207 |
if(err != KErrNone)
|
|
208 |
{
|
253
|
209 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_DUP10, "<Error %d> Interface 1 could not be opened",err);
|
0
|
210 |
return TestFailed(err);
|
|
211 |
}
|
253
|
212 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_DUP11, "Interface 1 opened");
|
0
|
213 |
|
|
214 |
// close it
|
|
215 |
iUsbInterface1.Close();
|
253
|
216 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_DUP12, "Interface 1 closed");
|
0
|
217 |
|
|
218 |
//re-open now
|
|
219 |
err = iUsbInterface1.Open(token2); // Alternate interface setting 0
|
|
220 |
if(err != KErrNone)
|
|
221 |
{
|
253
|
222 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_DUP13, "<Error %d> Interface 1 could not be re-opened",err);
|
0
|
223 |
return TestFailed(err);
|
|
224 |
}
|
253
|
225 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_DUP14, "Interface 1 re-opened");
|
0
|
226 |
|
|
227 |
|
|
228 |
// Suspend interface 0
|
253
|
229 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_DUP15, "Suspending interface 0");
|
0
|
230 |
iInterface0Watcher->SuspendAndWatch();
|
|
231 |
iSuspendedI0 = ETrue;
|
|
232 |
|
|
233 |
// Suspend interface 1
|
253
|
234 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_DUP16, "Suspending interface 1");
|
0
|
235 |
iInterface1Watcher->SuspendAndWatch();
|
|
236 |
iSuspendedI1 = ETrue;
|
|
237 |
|
|
238 |
iCaseStep = EValidateSuspendingInterfaces;
|
|
239 |
TimeoutIn(10); // Give 10 seconds for device to suspend
|
|
240 |
}
|
|
241 |
break;
|
|
242 |
|
|
243 |
default:
|
|
244 |
TestFailed(KErrCorrupt);
|
|
245 |
break;
|
|
246 |
}
|
253
|
247 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0473_DEVICEINSERTEDL_EXIT_DUP01, this );
|
0
|
248 |
}
|
|
249 |
|
|
250 |
|
|
251 |
TInt CUT_PBASE_T_USBDI_0473::Interface0ResumedL(TAny* aPtr)
|
|
252 |
{
|
253
|
253 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0473_INTERFACE0RESUMEDL_ENTRY, 0 );
|
|
254 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_INTERFACE0RESUMEDL, "Interface 0 resumed");
|
0
|
255 |
CUT_PBASE_T_USBDI_0473* self = reinterpret_cast<CUT_PBASE_T_USBDI_0473*>(aPtr);
|
253
|
256 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_INTERFACE0RESUMEDL_DUP01, "watcher 0 iStatus=%d",self->iInterface0Watcher->CompletionCode());
|
0
|
257 |
self->iSuspendedI0 = EFalse;
|
|
258 |
return self->CheckForAllResumedNotificationsAndContinueFSM();
|
|
259 |
}
|
|
260 |
|
|
261 |
|
|
262 |
TInt CUT_PBASE_T_USBDI_0473::Interface1ResumedL(TAny* aPtr)
|
|
263 |
{
|
253
|
264 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0473_INTERFACE1RESUMEDL_ENTRY, 0 );
|
|
265 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_INTERFACE1RESUMEDL, "Interface 1 resumed");
|
0
|
266 |
CUT_PBASE_T_USBDI_0473* self = reinterpret_cast<CUT_PBASE_T_USBDI_0473*>(aPtr);
|
253
|
267 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_INTERFACE1RESUMEDL_DUP01, "watcher 1 iStatus=%d",self->iInterface1Watcher->CompletionCode());
|
0
|
268 |
self->iSuspendedI1 = EFalse;
|
|
269 |
return self->CheckForAllResumedNotificationsAndContinueFSM();
|
|
270 |
}
|
|
271 |
|
|
272 |
|
|
273 |
void CUT_PBASE_T_USBDI_0473::DeviceRemovedL(TUint aDeviceHandle)
|
|
274 |
{
|
253
|
275 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0473_DEVICEREMOVEDL_ENTRY, this );
|
0
|
276 |
|
|
277 |
// The test device should not be removed until the test case has passed
|
|
278 |
// so this test case has not completed, and state this event as an error
|
|
279 |
|
|
280 |
TestFailed(KErrDisconnected);
|
253
|
281 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0473_DEVICEREMOVEDL_EXIT, this );
|
0
|
282 |
}
|
|
283 |
|
|
284 |
|
|
285 |
void CUT_PBASE_T_USBDI_0473::BusErrorL(TInt aError)
|
|
286 |
{
|
253
|
287 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0473_BUSERRORL_ENTRY, this );
|
0
|
288 |
|
|
289 |
// This test case handles no failiures on the bus
|
|
290 |
|
|
291 |
TestFailed(aError);
|
253
|
292 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0473_BUSERRORL_EXIT, this );
|
0
|
293 |
}
|
|
294 |
|
|
295 |
TInt CUT_PBASE_T_USBDI_0473::CheckForAllResumedNotificationsAndContinueFSM()
|
|
296 |
{
|
253
|
297 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0473_CHECKFORALLRESUMEDNOTIFICATIONSANDCONTINUEFSM_ENTRY, this );
|
0
|
298 |
TBool readyToContinueFSM= ETrue;
|
|
299 |
if( iInterface0Watcher->IsActive()
|
|
300 |
|| iInterface0Watcher->iStatus == KRequestPending)
|
|
301 |
{
|
253
|
302 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_CHECKFORALLRESUMEDNOTIFICATIONSANDCONTINUEFSM, "Interface 0 watcher still pending");
|
0
|
303 |
readyToContinueFSM= EFalse;
|
|
304 |
}
|
|
305 |
|
|
306 |
if( iInterface1Watcher->IsActive()
|
|
307 |
|| iInterface1Watcher->iStatus == KRequestPending)
|
|
308 |
{
|
253
|
309 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_CHECKFORALLRESUMEDNOTIFICATIONSANDCONTINUEFSM_DUP01, "Interface 1 watcher still pending");
|
0
|
310 |
readyToContinueFSM= EFalse;
|
|
311 |
}
|
|
312 |
|
|
313 |
if( iDeviceNotificationPending)
|
|
314 |
{
|
|
315 |
readyToContinueFSM= EFalse;
|
|
316 |
}
|
|
317 |
|
|
318 |
if( readyToContinueFSM)
|
|
319 |
{
|
|
320 |
return ContinueFSMAfterAllResumedNotifications();
|
|
321 |
}
|
|
322 |
else
|
|
323 |
{
|
253
|
324 |
OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0473_CHECKFORALLRESUMEDNOTIFICATIONSANDCONTINUEFSM_EXIT, this, KErrNone );
|
0
|
325 |
return KErrNone;
|
|
326 |
}
|
|
327 |
}
|
|
328 |
|
|
329 |
TInt CUT_PBASE_T_USBDI_0473::ContinueFSMAfterAllResumedNotifications()
|
|
330 |
{
|
253
|
331 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0473_CONTINUEFSMAFTERALLRESUMEDNOTIFICATIONS_ENTRY, this );
|
0
|
332 |
iDeviceNotificationPending= ETrue;
|
|
333 |
if(iSuspendedI0)
|
|
334 |
{
|
253
|
335 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_CONTINUEFSMAFTERALLRESUMEDNOTIFICATIONS, "<Error %d> Interface 0 still suspended",KErrCompletion);
|
0
|
336 |
TestFailed(KErrCompletion);
|
253
|
337 |
OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0473_CONTINUEFSMAFTERALLRESUMEDNOTIFICATIONS_EXIT, this, KErrCompletion );
|
0
|
338 |
return KErrCompletion;
|
|
339 |
}
|
|
340 |
|
|
341 |
if(iSuspendedI1)
|
|
342 |
{
|
253
|
343 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_CONTINUEFSMAFTERALLRESUMEDNOTIFICATIONS_DUP01, "<Error %d> Interface 1 still suspended",KErrCompletion);
|
0
|
344 |
TestFailed(KErrCompletion);
|
253
|
345 |
OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0473_CONTINUEFSMAFTERALLRESUMEDNOTIFICATIONS_EXIT_DUP01, this, KErrCompletion );
|
0
|
346 |
return KErrCompletion;
|
|
347 |
}
|
|
348 |
|
|
349 |
switch(iCaseStep)
|
|
350 |
{
|
|
351 |
case EValidateResumptionAfterInterfaceSuspension:
|
|
352 |
{
|
|
353 |
// Device is resumed, send request to client: Remote wake up in 6 secs
|
|
354 |
TInt err= iUsbInterface1.PermitRemoteWakeup(ETrue);
|
|
355 |
|
|
356 |
if(err != KErrNone)
|
|
357 |
{
|
253
|
358 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_CONTINUEFSMAFTERALLRESUMEDNOTIFICATIONS_DUP02, "<Error %d> Unable to permit remote device wakeup",err);
|
0
|
359 |
iCaseStep = EFailed;
|
|
360 |
TTestCaseFailed request(err,_L8("Unable to permit remote device wakeup"));
|
|
361 |
iControlEp0->SendRequest(request,this);
|
|
362 |
}
|
|
363 |
else
|
|
364 |
{
|
253
|
365 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_CONTINUEFSMAFTERALLRESUMEDNOTIFICATIONS_DUP03, "Device is resumed, send request to client: Remote wake up in 6 secs");
|
0
|
366 |
|
|
367 |
TRemoteWakeupRequest request(6);
|
|
368 |
iControlEp0->SendRequest(request,this);
|
|
369 |
iCaseStep = ESuspendForRemoteWakeup;
|
|
370 |
}
|
|
371 |
}
|
|
372 |
break;
|
|
373 |
|
|
374 |
case EValidateResumptionAfterWakeup:
|
|
375 |
{
|
|
376 |
if(iStoredNewState == RUsbDevice::EDeviceActive)
|
|
377 |
{
|
|
378 |
// Now suspend the device again after resumption from remote wakeup
|
|
379 |
|
253
|
380 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_CONTINUEFSMAFTERALLRESUMEDNOTIFICATIONS_DUP04, "Suspending interface 0");
|
0
|
381 |
iInterface0Watcher->SuspendAndWatch();
|
|
382 |
iSuspendedI0 = ETrue;
|
|
383 |
|
253
|
384 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_CONTINUEFSMAFTERALLRESUMEDNOTIFICATIONS_DUP05, "Suspending interface 1");
|
0
|
385 |
iInterface1Watcher->SuspendAndWatch();
|
|
386 |
iSuspendedI1 = ETrue;
|
|
387 |
|
|
388 |
iCaseStep = EValidateSuspendAfterWakeup;
|
|
389 |
}
|
|
390 |
else
|
|
391 |
{
|
253
|
392 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_CONTINUEFSMAFTERALLRESUMEDNOTIFICATIONS_DUP06, "<Error %d> Device is still suspended",KErrCompletion);
|
0
|
393 |
TestFailed(KErrCompletion);
|
253
|
394 |
OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0473_CONTINUEFSMAFTERALLRESUMEDNOTIFICATIONS_EXIT_DUP02, this, KErrCompletion );
|
0
|
395 |
return KErrCompletion;
|
|
396 |
}
|
|
397 |
}
|
|
398 |
break;
|
|
399 |
|
|
400 |
default:
|
253
|
401 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_CONTINUEFSMAFTERALLRESUMEDNOTIFICATIONS_DUP07, "CUT_PBASE_T_USBDI_0473::ContinueFSMAfterAllResumedNotifications: Invalid state %d", iCaseStep);
|
0
|
402 |
TestFailed(KErrCompletion);
|
253
|
403 |
OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0473_CONTINUEFSMAFTERALLRESUMEDNOTIFICATIONS_EXIT_DUP03, this, KErrCompletion );
|
0
|
404 |
return KErrCompletion;
|
|
405 |
}
|
|
406 |
|
253
|
407 |
OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0473_CONTINUEFSMAFTERALLRESUMEDNOTIFICATIONS_EXIT_DUP04, this, KErrNone );
|
0
|
408 |
return KErrNone;
|
|
409 |
}
|
|
410 |
|
|
411 |
void CUT_PBASE_T_USBDI_0473::DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState,RUsbDevice::TDeviceState aNewState,TInt aCompletionCode)
|
|
412 |
{
|
253
|
413 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0473_DEVICESTATECHANGEL_ENTRY, this );
|
0
|
414 |
Cancel();
|
|
415 |
|
253
|
416 |
OstTraceExt3(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICESTATECHANGEL, "Device State change from %d to %d err=%d",aPreviousState,aNewState,aCompletionCode);
|
0
|
417 |
|
|
418 |
switch(iCaseStep)
|
|
419 |
{
|
|
420 |
|
|
421 |
// Validate that the device was suspended by individual interface suspension
|
|
422 |
|
|
423 |
case EValidateSuspendingInterfaces:
|
|
424 |
{
|
|
425 |
if(aNewState == RUsbDevice::EDeviceSuspended)
|
|
426 |
{
|
|
427 |
// Device state is suspended now resume it by resuming one of the interfaces
|
|
428 |
|
253
|
429 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICESTATECHANGEL_DUP01, "Device is suspended now resume device by resuming one of the interfaces");
|
0
|
430 |
iUsbInterface0.CancelPermitSuspend();
|
|
431 |
iCaseStep = EValidateResumptionAfterInterfaceSuspension;
|
|
432 |
}
|
|
433 |
else
|
|
434 |
{
|
253
|
435 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICESTATECHANGEL_DUP02, "<Error %d> State was not suspended",KErrCompletion);
|
0
|
436 |
|
|
437 |
// Since the device is not suspended, send test case failed to the device
|
|
438 |
|
|
439 |
iCaseStep = EFailed;
|
|
440 |
TTestCaseFailed request(KErrCompletion,_L8("The device was not in the expected suspend state"));
|
|
441 |
iControlEp0->SendRequest(request,this);
|
|
442 |
}
|
|
443 |
}
|
|
444 |
break;
|
|
445 |
|
|
446 |
// Validate that device is now active after resuming one of the interfaces
|
|
447 |
|
|
448 |
case EValidateResumptionAfterInterfaceSuspension:
|
|
449 |
{
|
|
450 |
iDeviceNotificationPending= EFalse;
|
|
451 |
|
|
452 |
if(aNewState == RUsbDevice::EDeviceActive)
|
|
453 |
{
|
|
454 |
CheckForAllResumedNotificationsAndContinueFSM();
|
|
455 |
}
|
|
456 |
else
|
|
457 |
{
|
253
|
458 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICESTATECHANGEL_DUP03, "<Error %d> Device is still suspended",KErrCompletion);
|
0
|
459 |
return TestFailed(KErrCompletion);
|
|
460 |
}
|
|
461 |
}
|
|
462 |
break;
|
|
463 |
|
|
464 |
// Validate that the device is now suspended for the device to remote-wakeup
|
|
465 |
case EValidateSuspendForRemoteWakeup:
|
|
466 |
{
|
|
467 |
if(aNewState == RUsbDevice::EDeviceSuspended)
|
|
468 |
{
|
|
469 |
// Now awaiting a remote wake up state change notification
|
|
470 |
|
253
|
471 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICESTATECHANGEL_DUP04, "Now awaiting a remote wake up state change notification");
|
0
|
472 |
|
|
473 |
CancelTimeout();
|
|
474 |
iTimer.After(iStatus,10000000); // Give 10 seconds for device to signal remote wake-up
|
|
475 |
iCaseStep = EValidateResumptionAfterWakeup;
|
|
476 |
SetActive();
|
|
477 |
}
|
|
478 |
else
|
|
479 |
{
|
253
|
480 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICESTATECHANGEL_DUP05, "<Error %d> State was not suspended",KErrCompletion);
|
0
|
481 |
|
|
482 |
// Since the device is not suspended, send test case failed to the device
|
|
483 |
|
|
484 |
iCaseStep = EFailed;
|
|
485 |
TTestCaseFailed request(KErrCompletion,_L8("State was not suspended"));
|
|
486 |
iControlEp0->SendRequest(request,this);
|
|
487 |
}
|
|
488 |
}
|
|
489 |
break;
|
|
490 |
|
|
491 |
// This step should never be reached as ep0 complete traps this step, but if it does test fails.
|
|
492 |
case ESuspendForRemoteWakeup:
|
|
493 |
{
|
253
|
494 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICESTATECHANGEL_DUP06, "Resumed before suspended");
|
0
|
495 |
iCaseStep = EFailed;
|
|
496 |
TTestCaseFailed request(KErrCompletion,_L8("State was not suspended"));
|
|
497 |
iControlEp0->SendRequest(request,this);
|
|
498 |
break;
|
|
499 |
}
|
|
500 |
|
|
501 |
// Validate that the device is now active from a remote wakeup
|
|
502 |
case EValidateResumptionAfterWakeup:
|
|
503 |
{
|
|
504 |
iDeviceNotificationPending= EFalse;
|
|
505 |
iStoredNewState= aNewState;
|
|
506 |
CheckForAllResumedNotificationsAndContinueFSM();
|
|
507 |
}
|
|
508 |
break;
|
|
509 |
|
|
510 |
// Validate that the device can be suspended after a remote wakeup
|
|
511 |
|
|
512 |
case EValidateSuspendAfterWakeup:
|
|
513 |
{
|
|
514 |
// Successfully suspended after a remote wake up event
|
|
515 |
if(aNewState == RUsbDevice::EDeviceSuspended)
|
|
516 |
{
|
|
517 |
// Device is now suspended, now activate the device again to send test case
|
|
518 |
// completed request to device
|
|
519 |
|
253
|
520 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICESTATECHANGEL_DUP07, "Device is now suspended, now activate the device again to send test case completed request to device");
|
0
|
521 |
|
|
522 |
CUsbTestDevice& testDevice = iActorFDF->DeviceL(iDeviceHandle);
|
|
523 |
|
253
|
524 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICESTATECHANGEL_DUP08, "Resuming at device level");
|
0
|
525 |
TInt err(testDevice.Device().Resume());
|
|
526 |
if(err != KErrNone)
|
|
527 |
{
|
253
|
528 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICESTATECHANGEL_DUP09, "<Error %d> Unable to suspend the device",err);
|
0
|
529 |
iCaseStep = EFailed;
|
|
530 |
TTestCaseFailed request(err,_L8("Unable to suspend the device"));
|
|
531 |
iControlEp0->SendRequest(request,this);
|
|
532 |
}
|
|
533 |
|
|
534 |
iCaseStep = EPassed;
|
|
535 |
}
|
|
536 |
else
|
|
537 |
{
|
253
|
538 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICESTATECHANGEL_DUP10, "<Error %d> State was not suspended",KErrCompletion);
|
0
|
539 |
|
|
540 |
// Since the device is not suspended, send test case failed to the device
|
|
541 |
|
|
542 |
iCaseStep = EFailed;
|
|
543 |
TTestCaseFailed request(KErrCompletion,_L8("State was not suspended"));
|
|
544 |
iControlEp0->SendRequest(request,this);
|
|
545 |
}
|
|
546 |
}
|
|
547 |
break;
|
|
548 |
|
|
549 |
// Validate that the device is now active again
|
|
550 |
|
|
551 |
case EPassed:
|
|
552 |
{
|
|
553 |
if(aNewState == RUsbDevice::EDeviceActive)
|
|
554 |
{
|
253
|
555 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICESTATECHANGEL_DUP11, "Device is active again, test case passed");
|
0
|
556 |
TTestCasePassed request;
|
|
557 |
iControlEp0->SendRequest(request,this);
|
|
558 |
}
|
|
559 |
else
|
|
560 |
{
|
253
|
561 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_DEVICESTATECHANGEL_DUP12, "<Error %d> Device is still suspended",KErrCompletion);
|
0
|
562 |
return TestFailed(KErrCompletion);
|
|
563 |
}
|
|
564 |
}
|
|
565 |
break;
|
|
566 |
|
|
567 |
default:
|
|
568 |
break;
|
|
569 |
}
|
253
|
570 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0473_DEVICESTATECHANGEL_EXIT, this );
|
0
|
571 |
}
|
|
572 |
|
|
573 |
|
|
574 |
void CUT_PBASE_T_USBDI_0473::Ep0TransferCompleteL(TInt aCompletionCode)
|
|
575 |
{
|
253
|
576 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0473_EP0TRANSFERCOMPLETEL_ENTRY, this );
|
|
577 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_EP0TRANSFERCOMPLETEL, "Ep0TransferCompleteL with aCompletionCode = %d",aCompletionCode);
|
0
|
578 |
switch(iCaseStep)
|
|
579 |
{
|
|
580 |
case ESuspendForRemoteWakeup:
|
|
581 |
{
|
|
582 |
// Suspend device again so a remote wakeup can be achieved
|
253
|
583 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_EP0TRANSFERCOMPLETEL_DUP01, "Suspend device again so a remote wakeup can be achieved");
|
0
|
584 |
|
|
585 |
// Suspend interface 0
|
253
|
586 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_EP0TRANSFERCOMPLETEL_DUP02, "Suspending interface 0");
|
0
|
587 |
iInterface0Watcher->SuspendAndWatch();
|
|
588 |
iSuspendedI0 = ETrue;
|
|
589 |
|
|
590 |
// Suspend interface 1
|
253
|
591 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_EP0TRANSFERCOMPLETEL_DUP03, "Suspending interface 1");
|
0
|
592 |
iInterface1Watcher->SuspendAndWatch();
|
|
593 |
iSuspendedI1 = ETrue;
|
|
594 |
|
|
595 |
iCaseStep = EValidateSuspendForRemoteWakeup;
|
|
596 |
TimeoutIn(10); // Give 10 seconds for device to suspend
|
|
597 |
}
|
|
598 |
break;
|
|
599 |
|
|
600 |
// Fail the test case
|
|
601 |
|
|
602 |
default:
|
|
603 |
case EFailed:
|
|
604 |
TestFailed(KErrCompletion);
|
|
605 |
break;
|
|
606 |
|
|
607 |
// Pass the test case
|
|
608 |
|
|
609 |
case EPassed:
|
|
610 |
TestPassed();
|
|
611 |
break;
|
|
612 |
}
|
253
|
613 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0473_EP0TRANSFERCOMPLETEL_EXIT, this );
|
0
|
614 |
}
|
|
615 |
|
|
616 |
|
|
617 |
void CUT_PBASE_T_USBDI_0473::HostRunL()
|
|
618 |
{
|
253
|
619 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0473_HOSTRUNL_ENTRY, this );
|
0
|
620 |
|
|
621 |
// Obtain the completion code
|
|
622 |
TInt completionCode(iStatus.Int());
|
|
623 |
|
|
624 |
if(completionCode == KErrNone)
|
|
625 |
{
|
|
626 |
// Action timeout
|
253
|
627 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_HOSTRUNL, "<Error> Action timeout");
|
0
|
628 |
TestFailed(KErrTimedOut);
|
|
629 |
}
|
|
630 |
else
|
|
631 |
{
|
253
|
632 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0473_HOSTRUNL_DUP01, "<Error %d> Timeout timer could not complete",completionCode);
|
0
|
633 |
TestFailed(completionCode);
|
|
634 |
}
|
253
|
635 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0473_HOSTRUNL_EXIT, this );
|
0
|
636 |
}
|
|
637 |
|
|
638 |
|
|
639 |
void CUT_PBASE_T_USBDI_0473::DeviceRunL()
|
|
640 |
{
|
253
|
641 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0473_DEVICERUNL_ENTRY, this );
|
0
|
642 |
|
|
643 |
// Disconnect the device
|
|
644 |
|
|
645 |
iTestDevice->SoftwareDisconnect();
|
|
646 |
|
|
647 |
// Complete the test case request
|
|
648 |
|
|
649 |
TestPolicy().SignalTestComplete(iStatus.Int());
|
253
|
650 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0473_DEVICERUNL_EXIT, this );
|
0
|
651 |
}
|
|
652 |
|
|
653 |
|
|
654 |
}
|