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-0474.cpp
|
|
15 |
// @internalComponent
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include "PBASE-T_USBDI-0474.h"
|
|
20 |
#include "testpolicy.h"
|
|
21 |
#include "modelleddevices.h"
|
253
|
22 |
#include "OstTraceDefinitions.h"
|
|
23 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
24 |
#include "PBASE-T_USBDI-0474Traces.h"
|
|
25 |
#endif
|
0
|
26 |
|
|
27 |
|
|
28 |
namespace NUnitTesting_USBDI
|
|
29 |
{
|
|
30 |
|
|
31 |
_LIT(KTestCaseId,"PBASE-T_USBDI-0474");
|
|
32 |
const TFunctorTestCase<CUT_PBASE_T_USBDI_0474,TBool> CUT_PBASE_T_USBDI_0474::iFunctor(KTestCaseId);
|
|
33 |
|
|
34 |
CUT_PBASE_T_USBDI_0474* CUT_PBASE_T_USBDI_0474::NewL(TBool aHostRole)
|
|
35 |
{
|
253
|
36 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0474_NEWL_ENTRY, aHostRole );
|
0
|
37 |
CUT_PBASE_T_USBDI_0474* self = new (ELeave) CUT_PBASE_T_USBDI_0474(aHostRole);
|
|
38 |
CleanupStack::PushL(self);
|
|
39 |
self->ConstructL();
|
|
40 |
CleanupStack::Pop(self);
|
253
|
41 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0474_NEWL_EXIT, ( TUint )( self ) );
|
0
|
42 |
return self;
|
|
43 |
}
|
|
44 |
|
|
45 |
|
|
46 |
CUT_PBASE_T_USBDI_0474::CUT_PBASE_T_USBDI_0474(TBool aHostRole)
|
|
47 |
: CBaseTestCase(KTestCaseId,aHostRole),
|
|
48 |
iCaseStep(EInProgress)
|
|
49 |
{
|
253
|
50 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0474_CUT_PBASE_T_USBDI_0474_ENTRY, this );
|
|
51 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0474_CUT_PBASE_T_USBDI_0474_EXIT, this );
|
0
|
52 |
}
|
|
53 |
|
|
54 |
|
|
55 |
void CUT_PBASE_T_USBDI_0474::ConstructL()
|
|
56 |
{
|
253
|
57 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0474_CONSTRUCTL_ENTRY, this );
|
0
|
58 |
iTestDevice = new RUsbDeviceB(this);
|
|
59 |
BaseConstructL();
|
253
|
60 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0474_CONSTRUCTL_EXIT, this );
|
0
|
61 |
}
|
|
62 |
|
|
63 |
|
|
64 |
CUT_PBASE_T_USBDI_0474::~CUT_PBASE_T_USBDI_0474()
|
|
65 |
{
|
253
|
66 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0474_CUT_PBASE_T_USBDI_0474_ENTRY_DUP01, this );
|
0
|
67 |
Cancel();
|
|
68 |
|
|
69 |
iUsbInterface0.Close();
|
|
70 |
|
|
71 |
delete iClientAction;
|
|
72 |
delete iActorFDF;
|
|
73 |
if(!IsHost() && iTestDevice)
|
|
74 |
{
|
|
75 |
iTestDevice->Close();
|
|
76 |
}
|
|
77 |
delete iTestDevice;
|
253
|
78 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0474_CUT_PBASE_T_USBDI_0474_EXIT_DUP01, this );
|
0
|
79 |
}
|
|
80 |
|
|
81 |
|
|
82 |
void CUT_PBASE_T_USBDI_0474::ExecuteHostTestCaseL()
|
|
83 |
{
|
253
|
84 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0474_EXECUTEHOSTTESTCASEL_ENTRY, this );
|
0
|
85 |
|
|
86 |
iActorFDF = CActorFDF::NewL(*this);
|
|
87 |
iClientAction = new (ELeave) CEp0Transfer(iUsbInterface0);
|
|
88 |
iActorFDF->Monitor();
|
|
89 |
TimeoutIn(30);
|
253
|
90 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0474_EXECUTEHOSTTESTCASEL_EXIT, this );
|
0
|
91 |
}
|
|
92 |
|
|
93 |
|
|
94 |
void CUT_PBASE_T_USBDI_0474::ExecuteDeviceTestCaseL()
|
|
95 |
{
|
253
|
96 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0474_EXECUTEDEVICETESTCASEL_ENTRY, this );
|
0
|
97 |
|
|
98 |
iTestDevice->OpenL(TestCaseId());
|
|
99 |
iTestDevice->SubscribeToReports(iStatus);
|
|
100 |
SetActive();
|
|
101 |
iTestDevice->SoftwareConnect();
|
253
|
102 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0474_EXECUTEDEVICETESTCASEL_EXIT, this );
|
0
|
103 |
}
|
|
104 |
|
|
105 |
|
|
106 |
void CUT_PBASE_T_USBDI_0474::HostDoCancel()
|
|
107 |
{
|
253
|
108 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0474_HOSTDOCANCEL_ENTRY, this );
|
0
|
109 |
|
|
110 |
// Cancel the test step timeout
|
|
111 |
|
|
112 |
CancelTimeout();
|
253
|
113 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0474_HOSTDOCANCEL_EXIT, this );
|
0
|
114 |
}
|
|
115 |
|
|
116 |
|
|
117 |
void CUT_PBASE_T_USBDI_0474::DeviceDoCancel()
|
|
118 |
{
|
253
|
119 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0474_DEVICEDOCANCEL_ENTRY, this );
|
0
|
120 |
|
|
121 |
// Cancel the device
|
|
122 |
|
|
123 |
iTestDevice->CancelSubscriptionToReports();
|
253
|
124 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0474_DEVICEDOCANCEL_EXIT, this );
|
0
|
125 |
}
|
|
126 |
|
|
127 |
void CUT_PBASE_T_USBDI_0474::DeviceInsertedL(TUint aDeviceHandle)
|
|
128 |
{
|
253
|
129 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0474_DEVICEINSERTEDL_ENTRY, this );
|
0
|
130 |
Cancel();
|
|
131 |
TInt err(KErrNone);
|
|
132 |
|
|
133 |
// Validate that device is as expected
|
|
134 |
CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle);
|
|
135 |
if(testDevice.SerialNumber().Compare(TestCaseId()) != 0)
|
|
136 |
{
|
|
137 |
// Incorrect device for this test case
|
|
138 |
|
253
|
139 |
OstTraceExt3(TRACE_NORMAL, CUT_PBASE_T_USBDI_0474_DEVICEINSERTEDL, "<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)",
|
|
140 |
KErrNotFound,testDevice.SerialNumber(),TestCaseId());
|
0
|
141 |
|
|
142 |
// Start the connection timeout again
|
|
143 |
|
|
144 |
TimeoutIn(30);
|
253
|
145 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0474_DEVICEINSERTEDL_EXIT, this );
|
0
|
146 |
return;
|
|
147 |
}
|
|
148 |
|
|
149 |
// Check tree now
|
|
150 |
TUsbGenericDescriptor deviceDesc = testDevice.DeviceDescriptor();
|
|
151 |
TUsbGenericDescriptor configDesc = testDevice.ConfigurationDescriptor();
|
|
152 |
|
|
153 |
// Check tree now
|
|
154 |
CHECK(CheckTreeAfterDeviceInsertion(testDevice, _L("RDeviceB")) == KErrNone);
|
|
155 |
|
|
156 |
// Inform client device test case successful
|
|
157 |
TUint32 token0;
|
|
158 |
err = testDevice.Device().GetTokenForInterface(0,token0);
|
|
159 |
if(err != KErrNone)
|
|
160 |
{
|
253
|
161 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0474_DEVICEINSERTEDL_DUP01, "<Error %d> Token for interface 0 could not be retrieved",err);
|
0
|
162 |
return TestFailed(err);
|
|
163 |
}
|
|
164 |
err = iUsbInterface0.Open(token0); // Default interface setting 0
|
|
165 |
if(err != KErrNone)
|
|
166 |
{
|
253
|
167 |
OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_0474_DEVICEINSERTEDL_DUP02, "<Error %d> Unable to open interface 1 using token %d",err,token0);
|
0
|
168 |
return TestFailed(err);
|
|
169 |
}
|
|
170 |
|
|
171 |
iCaseStep = EPassed;
|
|
172 |
TTestCasePassed request;
|
|
173 |
iClientAction->SendRequest(request,this);
|
253
|
174 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0474_DEVICEINSERTEDL_EXIT_DUP01, this );
|
0
|
175 |
}
|
|
176 |
|
|
177 |
|
|
178 |
void CUT_PBASE_T_USBDI_0474::DeviceRemovedL(TUint aDeviceHandle)
|
|
179 |
{
|
253
|
180 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0474_DEVICEREMOVEDL_ENTRY, this );
|
0
|
181 |
|
|
182 |
// The test device should not be removed until the test case has passed
|
|
183 |
// so this test case has not completed, and state this event as an error
|
|
184 |
|
|
185 |
TestFailed(KErrDisconnected);
|
253
|
186 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0474_DEVICEREMOVEDL_EXIT, this );
|
0
|
187 |
}
|
|
188 |
|
|
189 |
|
|
190 |
void CUT_PBASE_T_USBDI_0474::BusErrorL(TInt aError)
|
|
191 |
{
|
253
|
192 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0474_BUSERRORL_ENTRY, this );
|
0
|
193 |
|
|
194 |
// This test case handles no failiures on the bus
|
|
195 |
|
|
196 |
TestFailed(aError);
|
253
|
197 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0474_BUSERRORL_EXIT, this );
|
0
|
198 |
}
|
|
199 |
|
|
200 |
|
|
201 |
void CUT_PBASE_T_USBDI_0474::DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState,
|
|
202 |
RUsbDevice::TDeviceState aNewState,TInt aCompletionCode)
|
|
203 |
{
|
253
|
204 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0474_DEVICESTATECHANGEL_ENTRY, this );
|
0
|
205 |
Cancel();
|
253
|
206 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0474_DEVICESTATECHANGEL_EXIT, this );
|
0
|
207 |
}
|
|
208 |
|
|
209 |
void CUT_PBASE_T_USBDI_0474::Ep0TransferCompleteL(TInt aCompletionCode)
|
|
210 |
{
|
253
|
211 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0474_EP0TRANSFERCOMPLETEL_ENTRY, this );
|
|
212 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0474_EP0TRANSFERCOMPLETEL, "Ep0TransferCompleteL with aCompletionCode = %d",aCompletionCode);
|
0
|
213 |
|
|
214 |
if(iCaseStep == EPassed)
|
|
215 |
{
|
|
216 |
TestPassed();
|
|
217 |
}
|
|
218 |
|
|
219 |
if(iCaseStep == EFailed)
|
|
220 |
{
|
|
221 |
TestFailed(KErrCompletion);
|
|
222 |
}
|
253
|
223 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0474_EP0TRANSFERCOMPLETEL_EXIT, this );
|
0
|
224 |
}
|
|
225 |
|
|
226 |
|
|
227 |
void CUT_PBASE_T_USBDI_0474::HostRunL()
|
|
228 |
{
|
253
|
229 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0474_HOSTRUNL_ENTRY, this );
|
0
|
230 |
|
|
231 |
// Obtain the completion code
|
|
232 |
TInt completionCode(iStatus.Int());
|
|
233 |
|
|
234 |
if(completionCode == KErrNone)
|
|
235 |
{
|
|
236 |
// Action timeout
|
253
|
237 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0474_HOSTRUNL, "<Error> Action timeout");
|
0
|
238 |
TestFailed(KErrTimedOut);
|
|
239 |
}
|
|
240 |
else
|
|
241 |
{
|
253
|
242 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0474_HOSTRUNL_DUP01, "<Error %d> Timeout timer could not complete",completionCode);
|
0
|
243 |
TestFailed(completionCode);
|
|
244 |
}
|
253
|
245 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0474_HOSTRUNL_EXIT, this );
|
0
|
246 |
}
|
|
247 |
|
|
248 |
void CUT_PBASE_T_USBDI_0474::DeviceRunL()
|
|
249 |
{
|
253
|
250 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0474_DEVICERUNL_ENTRY, this );
|
0
|
251 |
|
|
252 |
// Disconnect the device
|
|
253 |
|
|
254 |
iTestDevice->SoftwareDisconnect();
|
|
255 |
|
|
256 |
// Complete the test case request
|
|
257 |
|
|
258 |
TestPolicy().SignalTestComplete(iStatus.Int());
|
253
|
259 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0474_DEVICERUNL_EXIT, this );
|
0
|
260 |
}
|
|
261 |
|
|
262 |
|
|
263 |
}
|
|
264 |
|