35 _LIT(KTestCaseId,"PBASE-T_USBDI-0487"); |
39 _LIT(KTestCaseId,"PBASE-T_USBDI-0487"); |
36 const TFunctorTestCase<CUT_PBASE_T_USBDI_0487,TBool> CUT_PBASE_T_USBDI_0487::iFunctor(KTestCaseId); |
40 const TFunctorTestCase<CUT_PBASE_T_USBDI_0487,TBool> CUT_PBASE_T_USBDI_0487::iFunctor(KTestCaseId); |
37 |
41 |
38 CUT_PBASE_T_USBDI_0487* CUT_PBASE_T_USBDI_0487::NewL(TBool aHostRole) |
42 CUT_PBASE_T_USBDI_0487* CUT_PBASE_T_USBDI_0487::NewL(TBool aHostRole) |
39 { |
43 { |
|
44 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_NEWL_ENTRY, aHostRole ); |
40 CUT_PBASE_T_USBDI_0487* self = new (ELeave) CUT_PBASE_T_USBDI_0487(aHostRole); |
45 CUT_PBASE_T_USBDI_0487* self = new (ELeave) CUT_PBASE_T_USBDI_0487(aHostRole); |
41 CleanupStack::PushL(self); |
46 CleanupStack::PushL(self); |
42 self->ConstructL(); |
47 self->ConstructL(); |
43 CleanupStack::Pop(self); |
48 CleanupStack::Pop(self); |
|
49 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_NEWL_EXIT, ( TUint )( self ) ); |
44 return self; |
50 return self; |
45 } |
51 } |
46 |
52 |
47 |
53 |
48 CUT_PBASE_T_USBDI_0487::CUT_PBASE_T_USBDI_0487(TBool aHostRole) |
54 CUT_PBASE_T_USBDI_0487::CUT_PBASE_T_USBDI_0487(TBool aHostRole) |
49 : CBaseTestCase(KTestCaseId,aHostRole), |
55 : CBaseTestCase(KTestCaseId,aHostRole), |
50 iCaseStep(EInProgress) |
56 iCaseStep(EInProgress) |
51 { |
57 { |
|
58 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0487_CUT_PBASE_T_USBDI_0487_ENTRY, this ); |
|
59 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_CUT_PBASE_T_USBDI_0487_EXIT, this ); |
52 } |
60 } |
53 |
61 |
54 |
62 |
55 void CUT_PBASE_T_USBDI_0487::ConstructL() |
63 void CUT_PBASE_T_USBDI_0487::ConstructL() |
56 { |
64 { |
|
65 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_CONSTRUCTL_ENTRY, this ); |
57 iTestDevice = new RUsbDeviceA(this); |
66 iTestDevice = new RUsbDeviceA(this); |
58 BaseConstructL(); |
67 BaseConstructL(); |
|
68 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_CONSTRUCTL_EXIT, this ); |
59 } |
69 } |
60 |
70 |
61 |
71 |
62 CUT_PBASE_T_USBDI_0487::~CUT_PBASE_T_USBDI_0487() |
72 CUT_PBASE_T_USBDI_0487::~CUT_PBASE_T_USBDI_0487() |
63 { |
73 { |
64 LOG_FUNC |
74 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_CUT_PBASE_T_USBDI_0487_ENTRY_DUP01, this ); |
65 |
75 |
66 Cancel(); |
76 Cancel(); |
67 delete iTransferIn; |
77 delete iTransferIn; |
68 delete iTransferIn2; |
78 delete iTransferIn2; |
69 delete iTransferIn3; |
79 delete iTransferIn3; |
80 if(!IsHost() && iTestDevice) |
90 if(!IsHost() && iTestDevice) |
81 { |
91 { |
82 iTestDevice->Close(); |
92 iTestDevice->Close(); |
83 } |
93 } |
84 delete iTestDevice; |
94 delete iTestDevice; |
|
95 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_CUT_PBASE_T_USBDI_0487_EXIT_DUP01, this ); |
85 } |
96 } |
86 |
97 |
87 void CUT_PBASE_T_USBDI_0487::ExecuteHostTestCaseL() |
98 void CUT_PBASE_T_USBDI_0487::ExecuteHostTestCaseL() |
88 { |
99 { |
89 LOG_FUNC |
100 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_EXECUTEHOSTTESTCASEL_ENTRY, this ); |
90 |
101 |
91 iActorFDF = CActorFDF::NewL(*this); |
102 iActorFDF = CActorFDF::NewL(*this); |
92 iControlEp0 = new (ELeave) CEp0Transfer(iUsbInterface0); |
103 iControlEp0 = new (ELeave) CEp0Transfer(iUsbInterface0); |
93 iActorFDF->Monitor(); |
104 iActorFDF->Monitor(); |
94 |
105 |
95 TimeoutIn(30); |
106 TimeoutIn(30); |
|
107 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_EXECUTEHOSTTESTCASEL_EXIT, this ); |
96 } |
108 } |
97 |
109 |
98 void CUT_PBASE_T_USBDI_0487::HostDoCancel() |
110 void CUT_PBASE_T_USBDI_0487::HostDoCancel() |
99 { |
111 { |
100 LOG_FUNC |
112 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_HOSTDOCANCEL_ENTRY, this ); |
101 |
113 |
102 // Cancel the timeout timer |
114 // Cancel the timeout timer |
103 CancelTimeout(); |
115 CancelTimeout(); |
|
116 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_HOSTDOCANCEL_EXIT, this ); |
104 } |
117 } |
105 |
118 |
106 |
119 |
107 void CUT_PBASE_T_USBDI_0487::ExecuteDeviceTestCaseL() |
120 void CUT_PBASE_T_USBDI_0487::ExecuteDeviceTestCaseL() |
108 { |
121 { |
109 LOG_FUNC |
122 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_EXECUTEDEVICETESTCASEL_ENTRY, this ); |
110 |
123 |
111 iTestDevice->OpenL(TestCaseId()); |
124 iTestDevice->OpenL(TestCaseId()); |
112 iTestDevice->SubscribeToReports(iStatus); |
125 iTestDevice->SubscribeToReports(iStatus); |
113 SetActive(); |
126 SetActive(); |
114 iTestDevice->SoftwareConnect(); |
127 iTestDevice->SoftwareConnect(); |
|
128 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_EXECUTEDEVICETESTCASEL_EXIT, this ); |
115 } |
129 } |
116 |
130 |
117 void CUT_PBASE_T_USBDI_0487::DeviceDoCancel() |
131 void CUT_PBASE_T_USBDI_0487::DeviceDoCancel() |
118 { |
132 { |
119 LOG_FUNC |
133 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_DEVICEDOCANCEL_ENTRY, this ); |
120 // Cancel the device |
134 // Cancel the device |
121 iTestDevice->CancelSubscriptionToReports(); |
135 iTestDevice->CancelSubscriptionToReports(); |
|
136 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICEDOCANCEL_EXIT, this ); |
122 } |
137 } |
123 |
138 |
124 |
139 |
125 void CUT_PBASE_T_USBDI_0487::DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState,RUsbDevice::TDeviceState aNewState, |
140 void CUT_PBASE_T_USBDI_0487::DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState,RUsbDevice::TDeviceState aNewState, |
126 TInt aCompletionCode) |
141 TInt aCompletionCode) |
127 { |
142 { |
128 LOG_FUNC |
143 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0487_DEVICESTATECHANGEL_ENTRY, this ); |
|
144 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICESTATECHANGEL_EXIT, this ); |
129 } |
145 } |
130 |
146 |
131 |
147 |
132 void CUT_PBASE_T_USBDI_0487::DeviceInsertedL(TUint aDeviceHandle) |
148 void CUT_PBASE_T_USBDI_0487::DeviceInsertedL(TUint aDeviceHandle) |
133 { |
149 { |
134 LOG_FUNC |
150 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_ENTRY, this ); |
135 Cancel(); |
151 Cancel(); |
136 TInt err(KErrNone); |
152 TInt err(KErrNone); |
137 |
153 |
138 // Validate that device is as expected |
154 // Validate that device is as expected |
139 CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle); |
155 CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle); |
140 if(testDevice.SerialNumber().Compare(TestCaseId()) != 0) |
156 if(testDevice.SerialNumber().Compare(TestCaseId()) != 0) |
141 { |
157 { |
142 // Incorrect device for this test case |
158 // Incorrect device for this test case |
143 |
159 |
144 RDebug::Printf("<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)", |
160 OstTraceExt3(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL, "<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)", |
145 KErrNotFound,&testDevice.SerialNumber(),&TestCaseId()); |
161 KErrNotFound,testDevice.SerialNumber(),TestCaseId()); |
146 |
162 |
147 // Start the connection timeout again |
163 // Start the connection timeout again |
148 |
164 |
149 CancelTimeout(); |
165 CancelTimeout(); |
150 iTimer.After(iStatus,30000000); |
166 iTimer.After(iStatus,30000000); |
151 SetActive(); |
167 SetActive(); |
|
168 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_EXIT, this ); |
152 return; |
169 return; |
153 } |
170 } |
154 |
171 |
155 TUint32 token0,token1; |
172 TUint32 token0,token1; |
156 err = testDevice.Device().GetTokenForInterface(0,token0); |
173 err = testDevice.Device().GetTokenForInterface(0,token0); |
157 if(err != KErrNone) |
174 if(err != KErrNone) |
158 { |
175 { |
159 RDebug::Printf("<Error %d> Token for interface 0 could not be retrieved",err); |
176 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP01, "<Error %d> Token for interface 0 could not be retrieved",err); |
160 return TestFailed(err); |
177 return TestFailed(err); |
161 } |
178 } |
162 err = iUsbInterface0.Open(token0); // Default interface setting 0 |
179 err = iUsbInterface0.Open(token0); // Default interface setting 0 |
163 if(err != KErrNone) |
180 if(err != KErrNone) |
164 { |
181 { |
165 RDebug::Printf("<Error %d> Unable to open interface 0 using token %d",err,token0); |
182 OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP02, "<Error %d> Unable to open interface 0 using token %d",err,token0); |
166 return TestFailed(err); |
183 return TestFailed(err); |
167 } |
184 } |
168 |
185 |
169 err = testDevice.Device().GetTokenForInterface(1,token1); |
186 err = testDevice.Device().GetTokenForInterface(1,token1); |
170 if(err != KErrNone) |
187 if(err != KErrNone) |
171 { |
188 { |
172 TBuf<256> msg; |
189 TBuf<256> msg; |
173 msg.Format(_L("<Error %d> Token for interface 1 could not be retrieved"),err); |
190 msg.Format(_L("<Error %d> Token for interface 1 could not be retrieved"),err); |
174 RDebug::Print(msg); |
191 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP03, msg); |
175 iCaseStep = EFailed; |
192 iCaseStep = EFailed; |
176 TTestCaseFailed request(err,msg); |
193 TTestCaseFailed request(err,msg); |
177 return iControlEp0->SendRequest(request,this); |
194 return iControlEp0->SendRequest(request,this); |
178 } |
195 } |
179 err = iUsbInterface1.Open(token1); // Default interface setting 0 |
196 err = iUsbInterface1.Open(token1); // Default interface setting 0 |
180 if(err != KErrNone) |
197 if(err != KErrNone) |
181 { |
198 { |
182 TBuf<256> msg; |
199 TBuf<256> msg; |
183 msg.Format(_L("<Error %d> Unable to open interface 1 using token %d"),err,token1); |
200 msg.Format(_L("<Error %d> Unable to open interface 1 using token %d"),err,token1); |
184 RDebug::Print(msg); |
201 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP04, msg); |
185 iCaseStep = EFailed; |
202 iCaseStep = EFailed; |
186 TTestCaseFailed request(err,msg); |
203 TTestCaseFailed request(err,msg); |
187 return iControlEp0->SendRequest(request,this); |
204 return iControlEp0->SendRequest(request,this); |
188 } |
205 } |
189 |
206 |
191 err = iUsbInterface1.SelectAlternateInterface(1); |
208 err = iUsbInterface1.SelectAlternateInterface(1); |
192 if(err != KErrNone) |
209 if(err != KErrNone) |
193 { |
210 { |
194 TBuf<256> msg; |
211 TBuf<256> msg; |
195 msg.Format(_L("<Error %d> Selecting alternate interface setting 1 on interface 1"),err); |
212 msg.Format(_L("<Error %d> Selecting alternate interface setting 1 on interface 1"),err); |
196 RDebug::Print(msg); |
213 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP05, msg); |
197 iCaseStep = EFailed; |
214 iCaseStep = EFailed; |
198 TTestCaseFailed request(err,msg); |
215 TTestCaseFailed request(err,msg); |
199 iControlEp0->SendRequest(request,this); |
216 iControlEp0->SendRequest(request,this); |
|
217 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_EXIT_DUP01, this ); |
200 return; |
218 return; |
201 } |
219 } |
202 |
220 |
203 // Open a pipe for endpoint (Int in) |
221 // Open a pipe for endpoint (Int in) |
204 TInt endpointAddress; |
222 TInt endpointAddress; |
205 err = GetEndpointAddress(iUsbInterface1,1,KTransferTypeInterrupt,KEpDirectionIn,endpointAddress); |
223 err = GetEndpointAddress(iUsbInterface1,1,KTransferTypeInterrupt,KEpDirectionIn,endpointAddress); |
206 if(err != KErrNone) |
224 if(err != KErrNone) |
207 { |
225 { |
208 TBuf<256> msg; |
226 TBuf<256> msg; |
209 msg.Format(_L("<Error %d> unable to get endpoint address for interrupt in endpoint"),err); |
227 msg.Format(_L("<Error %d> unable to get endpoint address for interrupt in endpoint"),err); |
210 RDebug::Print(msg); |
228 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP06, msg); |
211 iCaseStep = EFailed; |
229 iCaseStep = EFailed; |
212 TTestCaseFailed request(err,msg); |
230 TTestCaseFailed request(err,msg); |
213 iControlEp0->SendRequest(request,this); |
231 iControlEp0->SendRequest(request,this); |
|
232 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_EXIT_DUP02, this ); |
214 return; |
233 return; |
215 } |
234 } |
216 |
235 |
217 err = iUsbInterface1.OpenPipeForEndpoint(iInPipe,endpointAddress,EFalse); |
236 err = iUsbInterface1.OpenPipeForEndpoint(iInPipe,endpointAddress,EFalse); |
218 if(err != KErrNone) |
237 if(err != KErrNone) |
219 { |
238 { |
220 TBuf<256> msg; |
239 TBuf<256> msg; |
221 msg.Format(_L("<Error %d> Unable to open pipe for endpoint 1"),err); |
240 msg.Format(_L("<Error %d> Unable to open pipe for endpoint 1"),err); |
222 RDebug::Print(msg); |
241 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP07, msg); |
223 iCaseStep = EFailed; |
242 iCaseStep = EFailed; |
224 TTestCaseFailed request(err,msg); |
243 TTestCaseFailed request(err,msg); |
225 return iControlEp0->SendRequest(request,this); |
244 return iControlEp0->SendRequest(request,this); |
226 } |
245 } |
227 RDebug::Printf("Opened pipe to endpoint address %08x for interrupt transfer to host",endpointAddress); |
246 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP08, "Opened pipe to endpoint address %08x for interrupt transfer to host",endpointAddress); |
228 |
247 |
229 |
248 |
230 // create an interrupt transfer |
249 // create an interrupt transfer |
231 iTransferIn = new (ELeave) CInterruptTransfer(iInPipe,iUsbInterface1,256,*this,KInterruptTransferId1); |
250 iTransferIn = new (ELeave) CInterruptTransfer(iInPipe,iUsbInterface1,256,*this,KInterruptTransferId1); |
232 iTransferIn->RegisterTransferDescriptor(); |
251 iTransferIn->RegisterTransferDescriptor(); |
238 // create a 3rd interrupt transfer |
257 // create a 3rd interrupt transfer |
239 iTransferIn3 = new (ELeave) CInterruptTransfer(iInPipe,iUsbInterface1,256,*this,KInterruptTransferId3); |
258 iTransferIn3 = new (ELeave) CInterruptTransfer(iInPipe,iUsbInterface1,256,*this,KInterruptTransferId3); |
240 iTransferIn3->RegisterTransferDescriptor(); |
259 iTransferIn3->RegisterTransferDescriptor(); |
241 |
260 |
242 // Initialise the descriptors for transfer |
261 // Initialise the descriptors for transfer |
243 RDebug::Printf("Initialising the transfer descriptors"); |
262 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP09, "Initialising the transfer descriptors"); |
244 err = iUsbInterface1.InitialiseTransferDescriptors(); |
263 err = iUsbInterface1.InitialiseTransferDescriptors(); |
245 if(err != KErrNone) |
264 if(err != KErrNone) |
246 { |
265 { |
247 RDebug::Printf("<Error %d> Unable to initialise transfer descriptors",err); |
266 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP10, "<Error %d> Unable to initialise transfer descriptors",err); |
|
267 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_EXIT_DUP03, this ); |
248 return; |
268 return; |
249 } |
269 } |
250 |
270 |
251 // que interrupt transfer |
271 // que interrupt transfer |
252 err = iTransferIn->TransferInL(KDataPayload1().Length()); |
272 err = iTransferIn->TransferInL(KDataPayload1().Length()); |
253 if(err != KErrNone) |
273 if(err != KErrNone) |
254 { |
274 { |
255 TBuf<256> msg; |
275 TBuf<256> msg; |
256 msg.Format(_L("<Error %d> Unable to queue an interrupt transfer"),err); |
276 msg.Format(_L("<Error %d> Unable to queue an interrupt transfer"),err); |
257 RDebug::Print(msg); |
277 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP11, msg); |
258 iCaseStep = EFailed; |
278 iCaseStep = EFailed; |
259 TTestCaseFailed request(err,msg); |
279 TTestCaseFailed request(err,msg); |
260 return iControlEp0->SendRequest(request,this); |
280 return iControlEp0->SendRequest(request,this); |
261 } |
281 } |
262 |
282 |
276 err = iTransferIn3->TransferInL(KDataPayload1().Length()); |
296 err = iTransferIn3->TransferInL(KDataPayload1().Length()); |
277 if(err != KErrNone) |
297 if(err != KErrNone) |
278 { |
298 { |
279 TBuf<256> msg; |
299 TBuf<256> msg; |
280 msg.Format(_L("<Error %d> Unable to queue an interrupt transfer"),err); |
300 msg.Format(_L("<Error %d> Unable to queue an interrupt transfer"),err); |
281 RDebug::Print(msg); |
301 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_DUP13, msg); |
282 iCaseStep = EFailed; |
302 iCaseStep = EFailed; |
283 TTestCaseFailed request(err,msg); |
303 TTestCaseFailed request(err,msg); |
284 return iControlEp0->SendRequest(request,this); |
304 return iControlEp0->SendRequest(request,this); |
285 } |
305 } |
286 |
306 |
287 // Timeout the interrupt transfer in 7 seconds |
307 // Timeout the interrupt transfer in 7 seconds |
288 TimeoutIn(7); |
308 TimeoutIn(7); |
289 // Instruct the client device to write the following data through the valid endpoint |
309 // Instruct the client device to write the following data through the valid endpoint |
290 TEndpointWriteRequest request(1,1,KDataPayload1); |
310 TEndpointWriteRequest request(1,1,KDataPayload1); |
291 iControlEp0->SendRequest(request,this); |
311 iControlEp0->SendRequest(request,this); |
|
312 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICEINSERTEDL_EXIT_DUP04, this ); |
292 } |
313 } |
293 |
314 |
294 |
315 |
295 void CUT_PBASE_T_USBDI_0487::Ep0TransferCompleteL(TInt aCompletionCode) |
316 void CUT_PBASE_T_USBDI_0487::Ep0TransferCompleteL(TInt aCompletionCode) |
296 { |
317 { |
297 LOG_FUNC |
318 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0487_EP0TRANSFERCOMPLETEL_ENTRY, this ); |
298 |
319 |
299 RDebug::Printf("Ep0TransferCompleteL with aCompletionCode = %d"),aCompletionCode; |
320 RDebug::Printf("Ep0TransferCompleteL with aCompletionCode = %d"),aCompletionCode; |
300 |
321 |
301 if(aCompletionCode != KErrNone) |
322 if(aCompletionCode != KErrNone) |
302 { |
323 { |
303 TBuf<256> msg; |
324 TBuf<256> msg; |
304 msg.Format(_L("<Error %d> Transfer to control endpoint 0 was not successful"),aCompletionCode); |
325 msg.Format(_L("<Error %d> Transfer to control endpoint 0 was not successful"),aCompletionCode); |
305 RDebug::Print(msg); |
326 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_EP0TRANSFERCOMPLETEL, msg); |
306 } |
327 } |
307 |
328 |
308 if(iCaseStep == EPassed) |
329 if(iCaseStep == EPassed) |
309 { |
330 { |
310 if(aCompletionCode == KErrNone) |
331 if(aCompletionCode == KErrNone) |
317 |
338 |
318 if(iCaseStep == EFailed) |
339 if(iCaseStep == EFailed) |
319 { |
340 { |
320 return TestFailed(KErrCompletion); |
341 return TestFailed(KErrCompletion); |
321 } |
342 } |
|
343 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_EP0TRANSFERCOMPLETEL_EXIT, this ); |
322 } |
344 } |
323 |
345 |
324 |
346 |
325 void CUT_PBASE_T_USBDI_0487::TransferCompleteL(TInt aTransferId,TInt aCompletionCode) |
347 void CUT_PBASE_T_USBDI_0487::TransferCompleteL(TInt aTransferId,TInt aCompletionCode) |
326 { |
348 { |
327 LOG_FUNC |
349 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_ENTRY, this ); |
328 Cancel(); |
350 Cancel(); |
329 |
351 |
330 RDebug::Printf("Transfer %d completed with %d",aTransferId,aCompletionCode); |
352 OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL, "Transfer %d completed with %d",aTransferId,aCompletionCode); |
331 |
353 |
332 if(aCompletionCode != KErrNone) |
354 if(aCompletionCode != KErrNone) |
333 { |
355 { |
334 TBuf<256> msg; |
356 TBuf<256> msg; |
335 msg.Format(_L("<Error %d> Transfer %d did not complete successfully"),aCompletionCode,aTransferId); |
357 msg.Format(_L("<Error %d> Transfer %d did not complete successfully"),aCompletionCode,aTransferId); |
336 RDebug::Print(msg); |
358 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_DUP01, msg); |
337 iCaseStep = EFailed; |
359 iCaseStep = EFailed; |
338 TTestCaseFailed request(aCompletionCode,msg); |
360 TTestCaseFailed request(aCompletionCode,msg); |
339 return iControlEp0->SendRequest(request,this); |
361 return iControlEp0->SendRequest(request,this); |
340 } |
362 } |
341 |
363 |
342 if(aTransferId == KInterruptTransferId1) |
364 if(aTransferId == KInterruptTransferId1) |
343 { |
365 { |
344 TPtrC8 data(iTransferIn->DataPolled()); |
366 TPtrC8 data(iTransferIn->DataPolled()); |
345 |
367 |
346 RDebug::Printf("data.Length 1()= %d", data.Length()); |
368 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_DUP02, "data.Length 1()= %d", data.Length()); |
347 |
369 |
348 TBuf<256> msg; |
370 TBuf<256> msg; |
349 for(int i = 0 ; i < data.Length(); i++) |
371 for(int i = 0 ; i < data.Length(); i++) |
350 { |
372 { |
351 msg.AppendFormat(_L("%02x"),data[i]); |
373 msg.AppendFormat(_L("%02x"),data[i]); |
352 } |
374 } |
353 RDebug::Print(msg); |
375 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_DUP03, msg); |
354 // Compare the data to what is expected |
376 // Compare the data to what is expected |
355 if(data.Compare(KDataPayload1) != 0) |
377 if(data.Compare(KDataPayload1) != 0) |
356 { |
378 { |
357 TBuf<256> msg; |
379 TBuf<256> msg; |
358 msg.Format(_L("<Error %d> Interrupt data received does not match data sent"),KErrCompletion); |
380 msg.Format(_L("<Error %d> Interrupt data received does not match data sent"),KErrCompletion); |
359 RDebug::Print(msg); |
381 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_DUP04, msg); |
360 iCaseStep = EFailed; |
382 iCaseStep = EFailed; |
361 TTestCaseFailed request(KErrCompletion,msg); |
383 TTestCaseFailed request(KErrCompletion,msg); |
362 return iControlEp0->SendRequest(request,this); |
384 return iControlEp0->SendRequest(request,this); |
363 } |
385 } |
364 User::After(3000000); |
386 User::After(3000000); |
367 return iControlEp0->SendRequest(request,this); |
389 return iControlEp0->SendRequest(request,this); |
368 } |
390 } |
369 else if(aTransferId == KInterruptTransferId2) |
391 else if(aTransferId == KInterruptTransferId2) |
370 { |
392 { |
371 TPtrC8 data(iTransferIn2->DataPolled()); |
393 TPtrC8 data(iTransferIn2->DataPolled()); |
372 RDebug::Printf("data.Length 2()= %d", data.Length()); |
394 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_DUP05, "data.Length 2()= %d", data.Length()); |
373 |
395 |
374 TBuf<256> msg; |
396 TBuf<256> msg; |
375 for(int i = 0 ; i < data.Length(); i++) |
397 for(int i = 0 ; i < data.Length(); i++) |
376 { |
398 { |
377 msg.AppendFormat(_L("%02x"),data[i]); |
399 msg.AppendFormat(_L("%02x"),data[i]); |
378 } |
400 } |
379 RDebug::Print(msg); |
401 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_DUP06, msg); |
380 |
402 |
381 // Compare the data to what is expected |
403 // Compare the data to what is expected |
382 if(data.Compare(KDataPayload1) != 0) |
404 if(data.Compare(KDataPayload1) != 0) |
383 { |
405 { |
384 TBuf<256> msg; |
406 TBuf<256> msg; |
385 msg.Format(_L("<Error %d> Interrupt data received does not match data sent"),KErrCompletion); |
407 msg.Format(_L("<Error %d> Interrupt data received does not match data sent"),KErrCompletion); |
386 RDebug::Print(msg); |
408 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_DUP07, msg); |
387 //TODO if test fails! Test fail code below WAS commented out |
409 //TODO if test fails! Test fail code below WAS commented out |
388 iCaseStep = EFailed; |
410 iCaseStep = EFailed; |
389 TTestCaseFailed request(KErrCompletion,msg); |
411 TTestCaseFailed request(KErrCompletion,msg); |
390 return iControlEp0->SendRequest(request,this); |
412 return iControlEp0->SendRequest(request,this); |
391 } |
413 } |
412 TTestCasePassed request; |
434 TTestCasePassed request; |
413 return iControlEp0->SendRequest(request,this); |
435 return iControlEp0->SendRequest(request,this); |
414 } |
436 } |
415 else |
437 else |
416 { |
438 { |
417 RDebug::Printf("<Error> Unknown transfer identity"); |
439 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_DUP09, "<Error> Unknown transfer identity"); |
418 TestFailed(KErrUnknown); |
440 TestFailed(KErrUnknown); |
419 } |
441 } |
|
442 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_TRANSFERCOMPLETEL_EXIT, this ); |
420 } |
443 } |
421 |
444 |
422 |
445 |
423 void CUT_PBASE_T_USBDI_0487::DeviceRemovedL(TUint aDeviceHandle) |
446 void CUT_PBASE_T_USBDI_0487::DeviceRemovedL(TUint aDeviceHandle) |
424 { |
447 { |
425 LOG_FUNC |
448 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0487_DEVICEREMOVEDL_ENTRY, this ); |
426 |
449 |
427 // The test device should not be removed until the test case has passed |
450 // The test device should not be removed until the test case has passed |
428 // so this test case has not completed, and state this event as an error |
451 // so this test case has not completed, and state this event as an error |
429 TestFailed(KErrDisconnected); |
452 TestFailed(KErrDisconnected); |
|
453 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICEREMOVEDL_EXIT, this ); |
430 } |
454 } |
431 |
455 |
432 |
456 |
433 void CUT_PBASE_T_USBDI_0487::BusErrorL(TInt aError) |
457 void CUT_PBASE_T_USBDI_0487::BusErrorL(TInt aError) |
434 { |
458 { |
435 LOG_FUNC |
459 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0487_BUSERRORL_ENTRY, this ); |
436 |
460 |
437 // This test case handles no failiures on the bus |
461 // This test case handles no failiures on the bus |
438 TestFailed(KErrCompletion); |
462 TestFailed(KErrCompletion); |
|
463 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_BUSERRORL_EXIT, this ); |
439 } |
464 } |
440 |
465 |
441 void CUT_PBASE_T_USBDI_0487::HostRunL() |
466 void CUT_PBASE_T_USBDI_0487::HostRunL() |
442 { |
467 { |
443 LOG_FUNC |
468 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_HOSTRUNL_ENTRY, this ); |
444 // Obtain the completion code |
469 // Obtain the completion code |
445 TInt completionCode(iStatus.Int()); |
470 TInt completionCode(iStatus.Int()); |
446 |
471 |
447 if(completionCode == KErrNone) |
472 if(completionCode == KErrNone) |
448 { |
473 { |
449 // Action timeout |
474 // Action timeout |
450 RDebug::Printf("<Error> Action timeout"); |
475 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_HOSTRUNL, "<Error> Action timeout"); |
451 TestFailed(KErrTimedOut); |
476 TestFailed(KErrTimedOut); |
452 } |
477 } |
453 else |
478 else |
454 { |
479 { |
455 RDebug::Printf("<Error %d> Timeout timer could not complete",completionCode); |
480 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0487_HOSTRUNL_DUP01, "<Error %d> Timeout timer could not complete",completionCode); |
456 TestFailed(completionCode); |
481 TestFailed(completionCode); |
457 } |
482 } |
|
483 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_HOSTRUNL_EXIT, this ); |
458 } |
484 } |
459 |
485 |
460 void CUT_PBASE_T_USBDI_0487::DeviceRunL() |
486 void CUT_PBASE_T_USBDI_0487::DeviceRunL() |
461 { |
487 { |
462 LOG_FUNC |
488 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0487_DEVICERUNL_ENTRY, this ); |
463 |
489 |
464 // Disconnect the device |
490 // Disconnect the device |
465 iTestDevice->SoftwareDisconnect(); |
491 iTestDevice->SoftwareDisconnect(); |
466 |
492 |
467 // Complete the test case request |
493 // Complete the test case request |
468 TestPolicy().SignalTestComplete(iStatus.Int()); |
494 TestPolicy().SignalTestComplete(iStatus.Int()); |
469 } |
495 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0487_DEVICERUNL_EXIT, this ); |
470 |
496 } |
471 |
497 |
472 } |
498 |
|
499 } |