29 _LIT(KTestCaseId,"PBASE-T_USBDI-0480"); |
33 _LIT(KTestCaseId,"PBASE-T_USBDI-0480"); |
30 const TFunctorTestCase<CUT_PBASE_T_USBDI_0480,TBool> CUT_PBASE_T_USBDI_0480::iFunctor(KTestCaseId); |
34 const TFunctorTestCase<CUT_PBASE_T_USBDI_0480,TBool> CUT_PBASE_T_USBDI_0480::iFunctor(KTestCaseId); |
31 |
35 |
32 CUT_PBASE_T_USBDI_0480* CUT_PBASE_T_USBDI_0480::NewL(TBool aHostRole) |
36 CUT_PBASE_T_USBDI_0480* CUT_PBASE_T_USBDI_0480::NewL(TBool aHostRole) |
33 { |
37 { |
|
38 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0480_NEWL_ENTRY, aHostRole ); |
34 CUT_PBASE_T_USBDI_0480* self = new (ELeave) CUT_PBASE_T_USBDI_0480(aHostRole); |
39 CUT_PBASE_T_USBDI_0480* self = new (ELeave) CUT_PBASE_T_USBDI_0480(aHostRole); |
35 CleanupStack::PushL(self); |
40 CleanupStack::PushL(self); |
36 self->ConstructL(); |
41 self->ConstructL(); |
37 CleanupStack::Pop(self); |
42 CleanupStack::Pop(self); |
|
43 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_NEWL_EXIT, ( TUint )( self ) ); |
38 return self; |
44 return self; |
39 } |
45 } |
40 |
46 |
41 |
47 |
42 CUT_PBASE_T_USBDI_0480::CUT_PBASE_T_USBDI_0480(TBool aHostRole) |
48 CUT_PBASE_T_USBDI_0480::CUT_PBASE_T_USBDI_0480(TBool aHostRole) |
43 : CBaseTestCase(KTestCaseId,aHostRole), |
49 : CBaseTestCase(KTestCaseId,aHostRole), |
44 iPtrTemp(NULL,0) |
50 iPtrTemp(NULL,0) |
45 { |
51 { |
|
52 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0480_CUT_PBASE_T_USBDI_0480_ENTRY, this ); |
|
53 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_CUT_PBASE_T_USBDI_0480_EXIT, this ); |
46 } |
54 } |
47 |
55 |
48 |
56 |
49 void CUT_PBASE_T_USBDI_0480::ConstructL() |
57 void CUT_PBASE_T_USBDI_0480::ConstructL() |
50 { |
58 { |
|
59 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0480_CONSTRUCTL_ENTRY, this ); |
51 iTestDevice = new RUsbDeviceA(this); |
60 iTestDevice = new RUsbDeviceA(this); |
52 BaseConstructL(); |
61 BaseConstructL(); |
|
62 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_CONSTRUCTL_EXIT, this ); |
53 } |
63 } |
54 |
64 |
55 |
65 |
56 CUT_PBASE_T_USBDI_0480::~CUT_PBASE_T_USBDI_0480() |
66 CUT_PBASE_T_USBDI_0480::~CUT_PBASE_T_USBDI_0480() |
57 { |
67 { |
58 LOG_FUNC |
68 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0480_CUT_PBASE_T_USBDI_0480_ENTRY_DUP01, this ); |
59 |
69 |
60 Cancel(); |
70 Cancel(); |
61 |
71 |
62 // Close pipe before interface |
72 // Close pipe before interface |
63 iUsbInterface1.Close(); |
73 iUsbInterface1.Close(); |
69 if(!IsHost() && iTestDevice) |
79 if(!IsHost() && iTestDevice) |
70 { |
80 { |
71 iTestDevice->Close(); |
81 iTestDevice->Close(); |
72 } |
82 } |
73 delete iTestDevice; |
83 delete iTestDevice; |
|
84 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_CUT_PBASE_T_USBDI_0480_EXIT_DUP01, this ); |
74 } |
85 } |
75 |
86 |
76 void CUT_PBASE_T_USBDI_0480::ExecuteHostTestCaseL() |
87 void CUT_PBASE_T_USBDI_0480::ExecuteHostTestCaseL() |
77 { |
88 { |
78 LOG_FUNC |
89 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0480_EXECUTEHOSTTESTCASEL_ENTRY, this ); |
79 |
90 |
80 iActorFDF = CActorFDF::NewL(*this); |
91 iActorFDF = CActorFDF::NewL(*this); |
81 iControlEp0 = new (ELeave) CEp0Transfer(iUsbInterface0); |
92 iControlEp0 = new (ELeave) CEp0Transfer(iUsbInterface0); |
82 iActorFDF->Monitor(); |
93 iActorFDF->Monitor(); |
83 |
94 |
84 TimeoutIn(30); |
95 TimeoutIn(30); |
|
96 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_EXECUTEHOSTTESTCASEL_EXIT, this ); |
85 } |
97 } |
86 |
98 |
87 void CUT_PBASE_T_USBDI_0480::HostDoCancel() |
99 void CUT_PBASE_T_USBDI_0480::HostDoCancel() |
88 { |
100 { |
89 LOG_FUNC |
101 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0480_HOSTDOCANCEL_ENTRY, this ); |
90 |
102 |
91 CancelTimeout(); |
103 CancelTimeout(); |
|
104 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_HOSTDOCANCEL_EXIT, this ); |
92 } |
105 } |
93 |
106 |
94 |
107 |
95 void CUT_PBASE_T_USBDI_0480::ExecuteDeviceTestCaseL() |
108 void CUT_PBASE_T_USBDI_0480::ExecuteDeviceTestCaseL() |
96 { |
109 { |
97 LOG_FUNC |
110 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0480_EXECUTEDEVICETESTCASEL_ENTRY, this ); |
98 |
111 |
99 iTestDevice->OpenL(TestCaseId()); |
112 iTestDevice->OpenL(TestCaseId()); |
100 iTestDevice->SubscribeToReports(iStatus); |
113 iTestDevice->SubscribeToReports(iStatus); |
101 SetActive(); |
114 SetActive(); |
102 iTestDevice->SoftwareConnect(); |
115 iTestDevice->SoftwareConnect(); |
|
116 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_EXECUTEDEVICETESTCASEL_EXIT, this ); |
103 } |
117 } |
104 |
118 |
105 void CUT_PBASE_T_USBDI_0480::DeviceDoCancel() |
119 void CUT_PBASE_T_USBDI_0480::DeviceDoCancel() |
106 { |
120 { |
107 LOG_FUNC |
121 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0480_DEVICEDOCANCEL_ENTRY, this ); |
108 |
122 |
109 // Cancel the device |
123 // Cancel the device |
110 iTestDevice->CancelSubscriptionToReports(); |
124 iTestDevice->CancelSubscriptionToReports(); |
|
125 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_DEVICEDOCANCEL_EXIT, this ); |
111 } |
126 } |
112 |
127 |
113 |
128 |
114 void CUT_PBASE_T_USBDI_0480::DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState, |
129 void CUT_PBASE_T_USBDI_0480::DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState, |
115 RUsbDevice::TDeviceState aNewState,TInt aCompletionCode) |
130 RUsbDevice::TDeviceState aNewState,TInt aCompletionCode) |
116 { |
131 { |
117 LOG_FUNC |
132 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0480_DEVICESTATECHANGEL_ENTRY, this ); |
118 |
133 |
119 Cancel(); |
134 Cancel(); |
|
135 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_DEVICESTATECHANGEL_EXIT, this ); |
120 } |
136 } |
121 |
137 |
122 |
138 |
123 void CUT_PBASE_T_USBDI_0480::DeviceInsertedL(TUint aDeviceHandle) |
139 void CUT_PBASE_T_USBDI_0480::DeviceInsertedL(TUint aDeviceHandle) |
124 { |
140 { |
125 LOG_FUNC |
141 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_ENTRY, this ); |
126 |
142 |
127 Cancel(); |
143 Cancel(); |
128 TInt err(KErrNone); |
144 TInt err(KErrNone); |
129 |
145 |
130 // Validate that device is as expected |
146 // Validate that device is as expected |
131 CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle); |
147 CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle); |
132 if(testDevice.SerialNumber().Compare(TestCaseId()) != 0) |
148 if(testDevice.SerialNumber().Compare(TestCaseId()) != 0) |
133 { |
149 { |
134 // Incorrect device for this test case |
150 // Incorrect device for this test case |
135 |
151 |
136 RDebug::Printf("<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)", |
152 OstTraceExt3(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL, "<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)", |
137 KErrNotFound,&testDevice.SerialNumber(),&TestCaseId()); |
153 KErrNotFound,testDevice.SerialNumber(),TestCaseId()); |
138 |
154 |
139 // Start the connection timeout again |
155 // Start the connection timeout again |
140 TimeoutIn(30); |
156 TimeoutIn(30); |
|
157 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_EXIT, this ); |
141 return; |
158 return; |
142 } |
159 } |
143 |
160 |
144 TUint32 token0,token1; |
161 TUint32 token0,token1; |
145 |
162 |
146 err = testDevice.Device().GetTokenForInterface(0,token0); |
163 err = testDevice.Device().GetTokenForInterface(0,token0); |
147 if(err != KErrNone) |
164 if(err != KErrNone) |
148 { |
165 { |
149 RDebug::Printf("<Error %d> Token for interface 0 could not be retrieved",err); |
166 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_DUP01, "<Error %d> Token for interface 0 could not be retrieved",err); |
150 return TestFailed(err); |
167 return TestFailed(err); |
151 } |
168 } |
152 err = iUsbInterface0.Open(token0); // Default interface setting 0 |
169 err = iUsbInterface0.Open(token0); // Default interface setting 0 |
153 if(err != KErrNone) |
170 if(err != KErrNone) |
154 { |
171 { |
155 RDebug::Printf("<Error %d> Unable to open interface 0 using token %d",err,token0); |
172 OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_DUP02, "<Error %d> Unable to open interface 0 using token %d",err,token0); |
156 return TestFailed(err); |
173 return TestFailed(err); |
157 } |
174 } |
158 |
175 |
159 err = testDevice.Device().GetTokenForInterface(1,token1); |
176 err = testDevice.Device().GetTokenForInterface(1,token1); |
160 if(err != KErrNone) |
177 if(err != KErrNone) |
161 { |
178 { |
162 TBuf<64> msg; |
179 TBuf<64> msg; |
163 msg.Format(_L("<Error %d> Token for interface 1 could not be retrieved"),err); |
180 msg.Format(_L("<Error %d> Token for interface 1 could not be retrieved"),err); |
164 RDebug::Print(msg); |
181 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_DUP03, msg); |
165 iCaseStep = EFailed; |
182 iCaseStep = EFailed; |
166 TTestCaseFailed request(err,msg); |
183 TTestCaseFailed request(err,msg); |
167 iControlEp0->SendRequest(request,this); |
184 iControlEp0->SendRequest(request,this); |
|
185 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_EXIT_DUP01, this ); |
168 return; |
186 return; |
169 } |
187 } |
170 err = iUsbInterface1.Open(token1); |
188 err = iUsbInterface1.Open(token1); |
171 if(err != KErrNone) |
189 if(err != KErrNone) |
172 { |
190 { |
173 TBuf<256> msg; |
191 TBuf<256> msg; |
174 msg.Format(_L("<Error %d> Unable to open interface 1 using token %d"),err,token1); |
192 msg.Format(_L("<Error %d> Unable to open interface 1 using token %d"),err,token1); |
175 RDebug::Print(msg); |
193 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_DUP04, msg); |
176 iCaseStep = EFailed; |
194 iCaseStep = EFailed; |
177 TTestCaseFailed request(err,msg); |
195 TTestCaseFailed request(err,msg); |
178 iControlEp0->SendRequest(request,this); |
196 iControlEp0->SendRequest(request,this); |
|
197 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_EXIT_DUP02, this ); |
179 return; |
198 return; |
180 } |
199 } |
181 |
200 |
182 // Get the endpoint descriptor |
201 // Get the endpoint descriptor |
183 TUsbEndpointDescriptor endpointDescriptor; |
202 TUsbEndpointDescriptor endpointDescriptor; |
185 err = iUsbInterface1.GetEndpointDescriptor(0,1,endpointDescriptor); |
204 err = iUsbInterface1.GetEndpointDescriptor(0,1,endpointDescriptor); |
186 if(err != KErrNone) |
205 if(err != KErrNone) |
187 { |
206 { |
188 TBuf<256> msg; |
207 TBuf<256> msg; |
189 msg.Format(_L("<Error %d> Descriptor for endpoint 0 cannot be obtained"),err); |
208 msg.Format(_L("<Error %d> Descriptor for endpoint 0 cannot be obtained"),err); |
190 RDebug::Print(msg); |
209 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_DUP05, msg); |
191 iCaseStep = EFailed; |
210 iCaseStep = EFailed; |
192 TTestCaseFailed request(err,msg); |
211 TTestCaseFailed request(err,msg); |
193 iControlEp0->SendRequest(request,this); |
212 iControlEp0->SendRequest(request,this); |
|
213 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_EXIT_DUP03, this ); |
194 return; |
214 return; |
195 } |
215 } |
196 TUint16 maxPacketSize(endpointDescriptor.MaxPacketSize()); |
216 TUint16 maxPacketSize(endpointDescriptor.MaxPacketSize()); |
197 |
217 |
198 RDebug::Printf("Maximum packet size for endpoint 1 on interface 1 setting 0 is: %d",maxPacketSize); |
218 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_DUP06, "Maximum packet size for endpoint 1 on interface 1 setting 0 is: %d",maxPacketSize); |
199 |
219 |
200 // Perform a device directed control transfer |
220 // Perform a device directed control transfer |
201 User::After(1000000); |
221 User::After(1000000); |
202 iCaseStep = EEmptyDeviceXfer; |
222 iCaseStep = EEmptyDeviceXfer; |
203 TEmptyDeviceRequest request; |
223 TEmptyDeviceRequest request; |
204 iControlEp0->SendRequest(request,this); |
224 iControlEp0->SendRequest(request,this); |
|
225 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_EXIT_DUP04, this ); |
205 } |
226 } |
206 |
227 |
207 |
228 |
208 void CUT_PBASE_T_USBDI_0480::Ep0TransferCompleteL(TInt aCompletionCode) |
229 void CUT_PBASE_T_USBDI_0480::Ep0TransferCompleteL(TInt aCompletionCode) |
209 { |
230 { |
210 LOG_FUNC |
231 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0480_EP0TRANSFERCOMPLETEL_ENTRY, this ); |
211 |
232 |
212 RDebug::Printf("Ep0TransferCompleteL with aCompletionCode = %d",aCompletionCode); |
233 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_EP0TRANSFERCOMPLETEL, "Ep0TransferCompleteL with aCompletionCode = %d",aCompletionCode); |
213 |
234 |
214 if(aCompletionCode != KErrNone) |
235 if(aCompletionCode != KErrNone) |
215 { |
236 { |
216 if(iCaseStep == EFailed) |
237 if(iCaseStep == EFailed) |
217 { |
238 { |
218 } |
239 } |
219 else |
240 else |
220 { |
241 { |
221 TBuf<256> msg; |
242 TBuf<256> msg; |
222 msg.Format(_L("<Error %d> Transfer to control endpoint 0 was not successful"),aCompletionCode); |
243 msg.Format(_L("<Error %d> Transfer to control endpoint 0 was not successful"),aCompletionCode); |
223 RDebug::Print(msg); |
244 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_EP0TRANSFERCOMPLETEL_DUP01, msg); |
224 iCaseStep = EFailed; |
245 iCaseStep = EFailed; |
225 TTestCaseFailed request(aCompletionCode,msg); |
246 TTestCaseFailed request(aCompletionCode,msg); |
226 iControlEp0->SendRequest(request,this); |
247 iControlEp0->SendRequest(request,this); |
|
248 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_EP0TRANSFERCOMPLETEL_EXIT, this ); |
227 return; |
249 return; |
228 } |
250 } |
229 } |
251 } |
230 |
252 |
231 switch(iCaseStep) |
253 switch(iCaseStep) |
276 iControlEp0->SendRequest(request,this); |
298 iControlEp0->SendRequest(request,this); |
277 } |
299 } |
278 break; |
300 break; |
279 |
301 |
280 default: |
302 default: |
281 RDebug::Printf("<Error> Unknown test step"); |
303 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_EP0TRANSFERCOMPLETEL_DUP02, "<Error> Unknown test step"); |
282 TestFailed(KErrUnknown); |
304 TestFailed(KErrUnknown); |
283 break; |
305 break; |
284 } |
306 } |
|
307 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_EP0TRANSFERCOMPLETEL_EXIT_DUP01, this ); |
285 } |
308 } |
286 |
309 |
287 |
310 |
288 void CUT_PBASE_T_USBDI_0480::DeviceRemovedL(TUint aDeviceHandle) |
311 void CUT_PBASE_T_USBDI_0480::DeviceRemovedL(TUint aDeviceHandle) |
289 { |
312 { |
290 LOG_FUNC |
313 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0480_DEVICEREMOVEDL_ENTRY, this ); |
291 |
314 |
292 // The test device should not be removed until the test case has passed |
315 // The test device should not be removed until the test case has passed |
293 // so this test case has not completed, and state this event as an error |
316 // so this test case has not completed, and state this event as an error |
294 TestFailed(KErrDisconnected); |
317 TestFailed(KErrDisconnected); |
|
318 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_DEVICEREMOVEDL_EXIT, this ); |
295 } |
319 } |
296 |
320 |
297 |
321 |
298 void CUT_PBASE_T_USBDI_0480::BusErrorL(TInt aError) |
322 void CUT_PBASE_T_USBDI_0480::BusErrorL(TInt aError) |
299 { |
323 { |
300 LOG_FUNC |
324 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0480_BUSERRORL_ENTRY, this ); |
301 |
325 |
302 // This test case handles no failiures on the bus |
326 // This test case handles no failiures on the bus |
303 TestFailed(KErrGeneral); |
327 TestFailed(KErrGeneral); |
|
328 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_BUSERRORL_EXIT, this ); |
304 } |
329 } |
305 |
330 |
306 void CUT_PBASE_T_USBDI_0480::HostRunL() |
331 void CUT_PBASE_T_USBDI_0480::HostRunL() |
307 { |
332 { |
308 LOG_FUNC |
333 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0480_HOSTRUNL_ENTRY, this ); |
309 |
334 |
310 // Obtain the completion code |
335 // Obtain the completion code |
311 TInt completionCode(iStatus.Int()); |
336 TInt completionCode(iStatus.Int()); |
312 |
337 |
313 if(completionCode == KErrNone) |
338 if(completionCode == KErrNone) |
314 { |
339 { |
315 // Action timeout |
340 // Action timeout |
316 RDebug::Printf("<Error> Action timeout"); |
341 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_HOSTRUNL, "<Error> Action timeout"); |
317 TestFailed(KErrTimedOut); |
342 TestFailed(KErrTimedOut); |
318 } |
343 } |
319 else |
344 else |
320 { |
345 { |
321 RDebug::Printf("<Error %d> Timeout timer could not complete",completionCode); |
346 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_HOSTRUNL_DUP01, "<Error %d> Timeout timer could not complete",completionCode); |
322 TestFailed(completionCode); |
347 TestFailed(completionCode); |
323 } |
348 } |
|
349 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_HOSTRUNL_EXIT, this ); |
324 } |
350 } |
325 |
351 |
326 void CUT_PBASE_T_USBDI_0480::DeviceRunL() |
352 void CUT_PBASE_T_USBDI_0480::DeviceRunL() |
327 { |
353 { |
328 LOG_FUNC |
354 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0480_DEVICERUNL_ENTRY, this ); |
329 |
355 |
330 // Disconnect the device |
356 // Disconnect the device |
331 iTestDevice->SoftwareDisconnect(); |
357 iTestDevice->SoftwareDisconnect(); |
332 |
358 |
333 // Complete the test case request |
359 // Complete the test case request |
334 TestPolicy().SignalTestComplete(iStatus.Int()); |
360 TestPolicy().SignalTestComplete(iStatus.Int()); |
335 } |
361 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_DEVICERUNL_EXIT, this ); |
336 |
362 } |
337 |
363 |
338 } |
364 |
|
365 } |