author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 02 Sep 2010 21:54:16 +0300 | |
changeset 259 | 57b9594f5772 |
parent 0 | a41df078684a |
child 257 | 3e88ff8f41d5 |
child 271 | dc268b18d709 |
permissions | -rw-r--r-- |
259
57b9594f5772
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 |
// @file PBASE-T_USBDI-0477.cpp |
|
15 |
// @internalComponent |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
#include "PBASE-T_USBDI-0477.h" |
|
20 |
#include "testpolicy.h" |
|
21 |
#include "modelleddevices.h" |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
22 |
#include "OstTraceDefinitions.h" |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
23 |
#ifdef OST_TRACE_COMPILER_IN_USE |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
24 |
#include "PBASE-T_USBDI-0477Traces.h" |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
25 |
#endif |
0 | 26 |
|
27 |
||
28 |
namespace NUnitTesting_USBDI |
|
29 |
{ |
|
30 |
||
31 |
_LIT(KTestCaseId,"PBASE-T_USBDI-0477"); |
|
32 |
const TFunctorTestCase<CUT_PBASE_T_USBDI_0477,TBool> CUT_PBASE_T_USBDI_0477::iFunctor(KTestCaseId); |
|
33 |
||
34 |
CUT_PBASE_T_USBDI_0477* CUT_PBASE_T_USBDI_0477::NewL(TBool aHostRole) |
|
35 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
36 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_NEWL_ENTRY, aHostRole ); |
0 | 37 |
CUT_PBASE_T_USBDI_0477* self = new (ELeave) CUT_PBASE_T_USBDI_0477(aHostRole); |
38 |
CleanupStack::PushL(self); |
|
39 |
self->ConstructL(); |
|
40 |
CleanupStack::Pop(self); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
41 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_NEWL_EXIT, ( TUint )( self ) ); |
0 | 42 |
return self; |
43 |
} |
|
44 |
||
45 |
||
46 |
CUT_PBASE_T_USBDI_0477::CUT_PBASE_T_USBDI_0477(TBool aHostRole) |
|
47 |
: CBaseTestCase(KTestCaseId,aHostRole), |
|
48 |
iCaseStep(EInProgress) |
|
49 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
50 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0477_CUT_PBASE_T_USBDI_0477_ENTRY, this ); |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
51 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_CUT_PBASE_T_USBDI_0477_EXIT, this ); |
0 | 52 |
} |
53 |
||
54 |
||
55 |
void CUT_PBASE_T_USBDI_0477::ConstructL() |
|
56 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
57 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_CONSTRUCTL_ENTRY, this ); |
0 | 58 |
iTestDevice = new RUsbDeviceA(this); |
59 |
BaseConstructL(); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
60 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_CONSTRUCTL_EXIT, this ); |
0 | 61 |
} |
62 |
||
63 |
||
64 |
CUT_PBASE_T_USBDI_0477::~CUT_PBASE_T_USBDI_0477() |
|
65 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
66 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_CUT_PBASE_T_USBDI_0477_ENTRY_DUP01, this ); |
0 | 67 |
Cancel(); |
68 |
||
69 |
iTestPipe.Close(); |
|
70 |
iUsbInterface1.Close(); |
|
71 |
iUsbInterface0.Close(); |
|
72 |
||
73 |
delete iClientAction; |
|
74 |
delete iActorFDF; |
|
75 |
if(!IsHost() && iTestDevice) |
|
76 |
{ |
|
77 |
iTestDevice->Close(); |
|
78 |
} |
|
79 |
delete iTestDevice; |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
80 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_CUT_PBASE_T_USBDI_0477_EXIT_DUP01, this ); |
0 | 81 |
} |
82 |
||
83 |
||
84 |
void CUT_PBASE_T_USBDI_0477::ExecuteHostTestCaseL() |
|
85 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
86 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_EXECUTEHOSTTESTCASEL_ENTRY, this ); |
0 | 87 |
|
88 |
iActorFDF = CActorFDF::NewL(*this); |
|
89 |
iClientAction = new (ELeave) CEp0Transfer(iUsbInterface0); |
|
90 |
iActorFDF->Monitor(); |
|
91 |
TimeoutIn(30); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
92 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_EXECUTEHOSTTESTCASEL_EXIT, this ); |
0 | 93 |
} |
94 |
||
95 |
||
96 |
void CUT_PBASE_T_USBDI_0477::ExecuteDeviceTestCaseL() |
|
97 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
98 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_EXECUTEDEVICETESTCASEL_ENTRY, this ); |
0 | 99 |
|
100 |
iTestDevice->OpenL(TestCaseId()); |
|
101 |
iTestDevice->SubscribeToReports(iStatus); |
|
102 |
SetActive(); |
|
103 |
iTestDevice->SoftwareConnect(); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
104 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_EXECUTEDEVICETESTCASEL_EXIT, this ); |
0 | 105 |
} |
106 |
||
107 |
||
108 |
void CUT_PBASE_T_USBDI_0477::HostDoCancel() |
|
109 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
110 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_HOSTDOCANCEL_ENTRY, this ); |
0 | 111 |
|
112 |
// Cancel the test step timeout |
|
113 |
||
114 |
CancelTimeout(); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
115 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_HOSTDOCANCEL_EXIT, this ); |
0 | 116 |
} |
117 |
||
118 |
||
119 |
void CUT_PBASE_T_USBDI_0477::DeviceDoCancel() |
|
120 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
121 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_DEVICEDOCANCEL_ENTRY, this ); |
0 | 122 |
|
123 |
// Cancel the device |
|
124 |
||
125 |
iTestDevice->CancelSubscriptionToReports(); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
126 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEDOCANCEL_EXIT, this ); |
0 | 127 |
} |
128 |
||
129 |
TBool CUT_PBASE_T_USBDI_0477::CheckFirstInterfaceDescriptorDeviceA(TUsbInterfaceDescriptor& aIfDescriptor) |
|
130 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
131 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0477_CHECKFIRSTINTERFACEDESCRIPTORDEVICEA_ENTRY, this ); |
0 | 132 |
/* Interface0 [setting0] |
133 |
Interface1 [setting0] |
|
134 |
[endpoint1] Bulk out |
|
135 |
[endpoint2] Bulk in |
|
136 |
[setting1] |
|
137 |
[endpoint1] Interrupt in |
|
138 |
[endpoint2] Bulk out |
|
139 |
[endpoint3] Bulk in |
|
140 |
*/ |
|
141 |
// alt. setting 0 |
|
142 |
TUsbInterfaceDescriptor::Cast(&aIfDescriptor); // is it an interface? |
|
143 |
CHECK_RET_BOOL(&aIfDescriptor != 0); |
|
144 |
||
145 |
// EP1 |
|
146 |
TUsbGenericDescriptor* desc = aIfDescriptor.iFirstChild; |
|
147 |
TUsbEndpointDescriptor::Cast(desc); |
|
148 |
CHECK_RET_BOOL(desc != 0); |
|
149 |
||
150 |
// EP 2 |
|
151 |
desc = desc->iNextPeer; |
|
152 |
TUsbEndpointDescriptor::Cast(desc); |
|
153 |
CHECK_RET_BOOL(desc != 0); |
|
154 |
desc = desc->iNextPeer; // no peer |
|
155 |
CHECK_RET_BOOL(desc == 0); |
|
156 |
||
157 |
// alt. setting 1 |
|
158 |
desc = aIfDescriptor.iNextPeer; |
|
159 |
TUsbInterfaceDescriptor::Cast(desc); |
|
160 |
CHECK_RET_BOOL(desc != 0); |
|
161 |
||
162 |
// EP1 |
|
163 |
desc = desc->iFirstChild; |
|
164 |
TUsbEndpointDescriptor::Cast(desc); |
|
165 |
CHECK_RET_BOOL(desc != 0); |
|
166 |
||
167 |
// EP 2 |
|
168 |
desc = desc->iNextPeer; |
|
169 |
TUsbEndpointDescriptor::Cast(desc); |
|
170 |
CHECK_RET_BOOL(desc != 0); |
|
171 |
||
172 |
// EP 3 |
|
173 |
desc = desc->iNextPeer; |
|
174 |
TUsbEndpointDescriptor::Cast(desc); |
|
175 |
CHECK_RET_BOOL(desc != 0); |
|
176 |
desc = desc->iNextPeer; // no peer |
|
177 |
CHECK_RET_BOOL(desc == 0); |
|
178 |
||
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
179 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_CHECKFIRSTINTERFACEDESCRIPTORDEVICEA, "CheckFirstInterfaceDescriptorDeviceA successfull!"); |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
180 |
OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0477_CHECKFIRSTINTERFACEDESCRIPTORDEVICEA_EXIT, this, ETrue ); |
0 | 181 |
return ETrue; |
182 |
} |
|
183 |
||
184 |
void CUT_PBASE_T_USBDI_0477::DeviceInsertedL(TUint aDeviceHandle) |
|
185 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
186 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_ENTRY, this ); |
0 | 187 |
Cancel(); |
188 |
TInt err(KErrNone); |
|
189 |
||
190 |
// Validate that device is as expected |
|
191 |
CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle); |
|
192 |
if(testDevice.SerialNumber().Compare(TestCaseId()) != 0) |
|
193 |
{ |
|
194 |
// Incorrect device for this test case |
|
195 |
||
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
196 |
OstTraceExt3(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL, "<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)", |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
197 |
KErrNotFound,testDevice.SerialNumber(),TestCaseId()); |
0 | 198 |
|
199 |
// Start the connection timeout again |
|
200 |
TimeoutIn(30); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
201 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_EXIT, this ); |
0 | 202 |
return; |
203 |
} |
|
204 |
||
205 |
TUint32 token0,token1; // Token for an interface |
|
206 |
||
207 |
err = testDevice.Device().GetTokenForInterface(0,token0); |
|
208 |
if(err != KErrNone) |
|
209 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
210 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP01, "<Error %d> Token for interface 0 could not be retrieved",err); |
0 | 211 |
return TestFailed(err); |
212 |
} |
|
213 |
||
214 |
err = iUsbInterface0.Open(token0); |
|
215 |
if(err != KErrNone) |
|
216 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
217 |
OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP02, "<Error %d> Unable to open interface 0 using token %d",err,token0); |
0 | 218 |
return TestFailed(err); |
219 |
} |
|
220 |
||
221 |
err = testDevice.Device().GetTokenForInterface(1,token1); |
|
222 |
if(err != KErrNone) |
|
223 |
{ |
|
224 |
// Test case has failed |
|
225 |
TBuf<256> msg; |
|
226 |
_LIT(string, "<Error %d> Token for interface could not be retrieved"); |
|
227 |
msg.Format(string,err); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
228 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP03, msg); |
0 | 229 |
iCaseStep = EFailed; |
230 |
TTestCaseFailed request(err,msg); |
|
231 |
iClientAction->SendRequest(request,this); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
232 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_EXIT_DUP01, this ); |
0 | 233 |
return; |
234 |
} |
|
235 |
||
236 |
err = iUsbInterface1.Open(token1); // Default interface setting 0 |
|
237 |
if(err != KErrNone) |
|
238 |
{ |
|
239 |
TBuf<256> msg; |
|
240 |
msg.Format(_L("<Error %d> Unable to open interface using token %d"),err,token1); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
241 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP04, msg); |
0 | 242 |
iCaseStep = EFailed; |
243 |
TTestCaseFailed request(err,msg); |
|
244 |
iClientAction->SendRequest(request,this); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
245 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_EXIT_DUP02, this ); |
0 | 246 |
return; |
247 |
} |
|
248 |
||
249 |
||
250 |
// check interface descriptor now |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
251 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP05, "check Interface descriptor now"); |
0 | 252 |
TUsbInterfaceDescriptor ifDescriptor; |
253 |
CHECK(iUsbInterface1.GetInterfaceDescriptor(ifDescriptor) == KErrNone); |
|
254 |
CHECK(CheckFirstInterfaceDescriptorDeviceA(ifDescriptor)); |
|
255 |
||
256 |
// Enumerate Endpoints On Interface 1 alt. setting 0 |
|
257 |
CHECK(iUsbInterface1.EnumerateEndpointsOnInterface(0) == 2); |
|
258 |
||
259 |
// get busId now |
|
260 |
TUsbBusId busId; |
|
261 |
CHECK(iUsbInterface1.GetBusId(busId) == KErrNone); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
262 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP06, "busId(Interface) = %d",busId); |
0 | 263 |
|
264 |
// get device speed now |
|
265 |
RUsbInterface::TDeviceSpeed deviceSpeed; |
|
266 |
CHECK(iUsbInterface1.GetDeviceSpeed(deviceSpeed) == KErrNone); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
267 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP07, "GetDeviceSpeed = %d", deviceSpeed); |
0 | 268 |
CHECK(deviceSpeed == RUsbInterface::EFullSpeed); |
269 |
||
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
270 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP08, "Number of alternate interface settings available: %d",iUsbInterface1.GetAlternateInterfaceCount()); |
0 | 271 |
gtest(iUsbInterface1.GetAlternateInterfaceCount() == 2); |
272 |
||
273 |
// Select alternate interface setting 1 |
|
274 |
err = iUsbInterface1.SelectAlternateInterface(1); |
|
275 |
if(err != KErrNone) |
|
276 |
{ |
|
277 |
TBuf<256> msg; |
|
278 |
msg.Format(_L("<Error %d> Selecting alternate interface setting 1 on interface 1"),err); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
279 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP09, msg); |
0 | 280 |
iCaseStep = EFailed; |
281 |
TTestCaseFailed request(err,msg); |
|
282 |
iClientAction->SendRequest(request,this); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
283 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_EXIT_DUP03, this ); |
0 | 284 |
return; |
285 |
} |
|
286 |
||
287 |
// Open a pipe for endpoint (Bulk out) |
|
288 |
TInt endpointAddress; |
|
289 |
err = GetEndpointAddress(iUsbInterface1,1,KTransferTypeBulk,KEpDirectionOut,endpointAddress); |
|
290 |
if(err != KErrNone) |
|
291 |
{ |
|
292 |
TBuf<128> msg; |
|
293 |
msg.Format(_L("<Error %d> Could not get address for Bulk out endpoint"),err); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
294 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP10, msg); |
0 | 295 |
TTestCaseFailed request(err,msg); |
296 |
iClientAction->SendRequest(request,this); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
297 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_EXIT_DUP04, this ); |
0 | 298 |
return; |
299 |
} |
|
300 |
||
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
301 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP11, "Opening pipe for endpoint address %02x on interface 1 setting 1",endpointAddress); |
0 | 302 |
err = iUsbInterface1.OpenPipeForEndpoint(iTestPipe,endpointAddress,EFalse); |
303 |
if(err != KErrNone) |
|
304 |
{ |
|
305 |
TBuf<128> msg; |
|
306 |
msg.Format(_L("<Error %d> Unable to open pipe on interface 1 setting 0"),err); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
307 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP12, msg); |
0 | 308 |
iCaseStep = EFailed; |
309 |
TTestCaseFailed request(err,msg); |
|
310 |
iClientAction->SendRequest(request,this); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
311 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_EXIT_DUP05, this ); |
0 | 312 |
return; |
313 |
} |
|
314 |
||
315 |
// get busId |
|
316 |
TUsbBusId busIdPipe; |
|
317 |
CHECK(iTestPipe.GetBusId(busIdPipe) == KErrNone); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
318 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP13, "busId(Pipe) = %d",busIdPipe); |
0 | 319 |
CHECK(busIdPipe == busId); |
320 |
||
321 |
TUsbEndpointId usbEpId; |
|
322 |
CHECK(iTestPipe.GetEndpointId(usbEpId) == KErrNone); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
323 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP14, "EndpointId = %d",usbEpId); |
0 | 324 |
|
325 |
// check ep descriptor now |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
326 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP15, "check ep descriptor now"); |
0 | 327 |
TUsbEndpointDescriptor epDescriptor; |
328 |
||
329 |
||
330 |
CHECK(iTestPipe.GetEndpointDescriptor(epDescriptor) == KErrNone); |
|
331 |
TUsbEndpointDescriptor::Cast(&epDescriptor); |
|
332 |
CHECK(&epDescriptor != 0); |
|
333 |
CHECK(epDescriptor.iFirstChild == 0); // no children |
|
334 |
CHECK(epDescriptor.iNextPeer != 0); // 1 peer |
|
335 |
||
336 |
||
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
337 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP16, "Pipe established now closing"); |
0 | 338 |
iTestPipe.Close(); |
339 |
||
340 |
// Select alternate interface 2, error expected |
|
341 |
err = iUsbInterface1.SelectAlternateInterface(2); |
|
342 |
if(err != KErrNone) |
|
343 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
344 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP17, "<Warning %d> Selecting alternate interface 2",err); |
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
345 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP18, "...Rolling Back...."); |
0 | 346 |
|
347 |
// Establish pipes on rollback |
|
348 |
// Open a pipe for endpoint (Bulk out) |
|
349 |
err = iUsbInterface1.OpenPipeForEndpoint(iTestPipe,endpointAddress,EFalse); |
|
350 |
if(err != KErrNone) |
|
351 |
{ |
|
352 |
TBuf<128> msg; |
|
353 |
msg.Format(_L("<Error %d> Unable to open pipe on interface 1 setting 1 for rollback case"),err); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
354 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP19, msg); |
0 | 355 |
iCaseStep = EFailed; |
356 |
TTestCaseFailed request(err,msg); |
|
357 |
iClientAction->SendRequest(request,this); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
358 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_EXIT_DUP06, this ); |
0 | 359 |
return; |
360 |
} |
|
361 |
||
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
362 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_DUP20, "Pipe established on rollback now closing"); |
0 | 363 |
iTestPipe.Close(); |
364 |
} |
|
365 |
||
366 |
// Inform client device test case successful |
|
367 |
iCaseStep = EPassed; |
|
368 |
TTestCasePassed request; |
|
369 |
iClientAction->SendRequest(request,this); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
370 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEINSERTEDL_EXIT_DUP07, this ); |
0 | 371 |
} |
372 |
||
373 |
||
374 |
void CUT_PBASE_T_USBDI_0477::DeviceRemovedL(TUint aDeviceHandle) |
|
375 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
376 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0477_DEVICEREMOVEDL_ENTRY, this ); |
0 | 377 |
|
378 |
// The test device should not be removed until the test case has passed |
|
379 |
// so this test case has not completed, and state this event as an error |
|
380 |
||
381 |
TestFailed(KErrDisconnected); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
382 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICEREMOVEDL_EXIT, this ); |
0 | 383 |
} |
384 |
||
385 |
||
386 |
void CUT_PBASE_T_USBDI_0477::BusErrorL(TInt aError) |
|
387 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
388 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0477_BUSERRORL_ENTRY, this ); |
0 | 389 |
|
390 |
// This test case handles no failiures on the bus |
|
391 |
||
392 |
TestFailed(aError); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
393 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_BUSERRORL_EXIT, this ); |
0 | 394 |
} |
395 |
||
396 |
||
397 |
void CUT_PBASE_T_USBDI_0477::DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState, |
|
398 |
RUsbDevice::TDeviceState aNewState,TInt aCompletionCode) |
|
399 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
400 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0477_DEVICESTATECHANGEL_ENTRY, this ); |
0 | 401 |
Cancel(); |
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
402 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICESTATECHANGEL_EXIT, this ); |
0 | 403 |
} |
404 |
||
405 |
void CUT_PBASE_T_USBDI_0477::Ep0TransferCompleteL(TInt aCompletionCode) |
|
406 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
407 |
OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0477_EP0TRANSFERCOMPLETEL_ENTRY, this ); |
0 | 408 |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
409 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_EP0TRANSFERCOMPLETEL, "Ep0TransferCompleteL with aCompletionCode = %d",aCompletionCode); |
0 | 410 |
|
411 |
if(iCaseStep == EPassed) |
|
412 |
{ |
|
413 |
TestPassed(); |
|
414 |
} |
|
415 |
||
416 |
if(iCaseStep == EFailed) |
|
417 |
{ |
|
418 |
TestFailed(KErrCompletion); |
|
419 |
} |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
420 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_EP0TRANSFERCOMPLETEL_EXIT, this ); |
0 | 421 |
} |
422 |
||
423 |
||
424 |
void CUT_PBASE_T_USBDI_0477::HostRunL() |
|
425 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
426 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_HOSTRUNL_ENTRY, this ); |
0 | 427 |
|
428 |
// Obtain the completion code |
|
429 |
TInt completionCode(iStatus.Int()); |
|
430 |
||
431 |
if(completionCode == KErrNone) |
|
432 |
{ |
|
433 |
// Action timeout |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
434 |
OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_HOSTRUNL, "<Error> Action timeout"); |
0 | 435 |
TestFailed(KErrTimedOut); |
436 |
} |
|
437 |
else |
|
438 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
439 |
OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0477_HOSTRUNL_DUP01, "<Error %d> Timeout timer could not complete",completionCode); |
0 | 440 |
TestFailed(completionCode); |
441 |
} |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
442 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_HOSTRUNL_EXIT, this ); |
0 | 443 |
} |
444 |
||
445 |
void CUT_PBASE_T_USBDI_0477::DeviceRunL() |
|
446 |
{ |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
447 |
OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0477_DEVICERUNL_ENTRY, this ); |
0 | 448 |
|
449 |
// Disconnect the device |
|
450 |
||
451 |
iTestDevice->SoftwareDisconnect(); |
|
452 |
||
453 |
// Complete the test case request |
|
454 |
||
455 |
TestPolicy().SignalTestComplete(iStatus.Int()); |
|
259
57b9594f5772
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
456 |
OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0477_DEVICERUNL_EXIT, this ); |
0 | 457 |
} |
458 |
||
459 |
||
460 |
} |
|
461 |