43 |
47 |
44 TInt CUT_PBASE_T_USBDI_0482::iExpectedTransferId = 0; |
48 TInt CUT_PBASE_T_USBDI_0482::iExpectedTransferId = 0; |
45 |
49 |
46 CUT_PBASE_T_USBDI_0482* CUT_PBASE_T_USBDI_0482::NewL(TBool aHostRole) |
50 CUT_PBASE_T_USBDI_0482* CUT_PBASE_T_USBDI_0482::NewL(TBool aHostRole) |
47 { |
51 { |
|
52 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0482_NEWL_ENTRY, aHostRole ); |
48 CUT_PBASE_T_USBDI_0482* self = new (ELeave) CUT_PBASE_T_USBDI_0482(aHostRole); |
53 CUT_PBASE_T_USBDI_0482* self = new (ELeave) CUT_PBASE_T_USBDI_0482(aHostRole); |
49 CleanupStack::PushL(self); |
54 CleanupStack::PushL(self); |
50 self->ConstructL(); |
55 self->ConstructL(); |
51 CleanupStack::Pop(self); |
56 CleanupStack::Pop(self); |
|
57 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0482_NEWL_EXIT, ( TUint )( self ) ); |
52 return self; |
58 return self; |
53 } |
59 } |
54 |
60 |
55 |
61 |
56 CUT_PBASE_T_USBDI_0482::CUT_PBASE_T_USBDI_0482(TBool aHostRole) |
62 CUT_PBASE_T_USBDI_0482::CUT_PBASE_T_USBDI_0482(TBool aHostRole) |
57 : CBaseTestCase(KTestCaseId,aHostRole), |
63 : CBaseTestCase(KTestCaseId,aHostRole), |
58 iCaseStep(EInProgress) |
64 iCaseStep(EInProgress) |
59 { |
65 { |
|
66 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0482_CUT_PBASE_T_USBDI_0482_ENTRY, this ); |
60 iEndpointAddressIn = 0x84; |
67 iEndpointAddressIn = 0x84; |
61 iEndpointAddressOut = 0x01; |
68 iEndpointAddressOut = 0x01; |
62 iOutTransferBuf.CreateL(KChunkSize); |
69 iOutTransferBuf.CreateL(KChunkSize); |
|
70 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0482_CUT_PBASE_T_USBDI_0482_EXIT, this ); |
63 } |
71 } |
64 |
72 |
65 |
73 |
66 void CUT_PBASE_T_USBDI_0482::ConstructL() |
74 void CUT_PBASE_T_USBDI_0482::ConstructL() |
67 { |
75 { |
|
76 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0482_CONSTRUCTL_ENTRY, this ); |
68 BaseConstructL(); |
77 BaseConstructL(); |
|
78 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0482_CONSTRUCTL_EXIT, this ); |
69 } |
79 } |
70 |
80 |
71 |
81 |
72 CUT_PBASE_T_USBDI_0482::~CUT_PBASE_T_USBDI_0482() |
82 CUT_PBASE_T_USBDI_0482::~CUT_PBASE_T_USBDI_0482() |
73 { |
83 { |
74 LOG_FUNC |
84 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0482_CUT_PBASE_T_USBDI_0482_ENTRY_DUP01, this ); |
75 |
85 |
76 Cancel(); |
86 Cancel(); |
77 |
87 |
78 // Close pipes before interfaces |
88 // Close pipes before interfaces |
79 iPipeOut.Close(); |
89 iPipeOut.Close(); |
90 iDataPolledBuf.Close(); |
100 iDataPolledBuf.Close(); |
91 |
101 |
92 delete iIsochInTransfer; |
102 delete iIsochInTransfer; |
93 delete iControlEp0; |
103 delete iControlEp0; |
94 delete iActorFDF; |
104 delete iActorFDF; |
|
105 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0482_CUT_PBASE_T_USBDI_0482_EXIT_DUP01, this ); |
95 } |
106 } |
96 |
107 |
97 void CUT_PBASE_T_USBDI_0482::ExecuteHostTestCaseL() |
108 void CUT_PBASE_T_USBDI_0482::ExecuteHostTestCaseL() |
98 { |
109 { |
99 LOG_FUNC |
110 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0482_EXECUTEHOSTTESTCASEL_ENTRY, this ); |
100 |
111 |
101 iActorFDF = CActorFDF::NewL(*this); |
112 iActorFDF = CActorFDF::NewL(*this); |
102 iControlEp0 = new (ELeave) CEp0Transfer(iUsbInterface0); |
113 iControlEp0 = new (ELeave) CEp0Transfer(iUsbInterface0); |
103 iActorFDF->Monitor(); |
114 iActorFDF->Monitor(); |
104 |
115 |
105 // Wait for the usb headset to be connected |
116 // Wait for the usb headset to be connected |
106 TimeoutIn(30); |
117 TimeoutIn(30); |
|
118 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0482_EXECUTEHOSTTESTCASEL_EXIT, this ); |
107 } |
119 } |
108 |
120 |
109 |
121 |
110 void CUT_PBASE_T_USBDI_0482::HostDoCancel() |
122 void CUT_PBASE_T_USBDI_0482::HostDoCancel() |
111 { |
123 { |
112 LOG_FUNC |
124 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0482_HOSTDOCANCEL_ENTRY, this ); |
|
125 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0482_HOSTDOCANCEL_EXIT, this ); |
113 } |
126 } |
114 |
127 |
115 |
128 |
116 void CUT_PBASE_T_USBDI_0482::ExecuteDeviceTestCaseL() |
129 void CUT_PBASE_T_USBDI_0482::ExecuteDeviceTestCaseL() |
117 { |
130 { |
118 LOG_FUNC |
131 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0482_EXECUTEDEVICETESTCASEL_ENTRY, this ); |
|
132 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0482_EXECUTEDEVICETESTCASEL_EXIT, this ); |
119 } |
133 } |
120 |
134 |
121 |
135 |
122 void CUT_PBASE_T_USBDI_0482::DeviceDoCancel() |
136 void CUT_PBASE_T_USBDI_0482::DeviceDoCancel() |
123 { |
137 { |
124 LOG_FUNC |
138 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0482_DEVICEDOCANCEL_ENTRY, this ); |
|
139 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0482_DEVICEDOCANCEL_EXIT, this ); |
125 } |
140 } |
126 |
141 |
127 |
142 |
128 void CUT_PBASE_T_USBDI_0482::DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState,RUsbDevice::TDeviceState aNewState, |
143 void CUT_PBASE_T_USBDI_0482::DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState,RUsbDevice::TDeviceState aNewState, |
129 TInt aCompletionCode) |
144 TInt aCompletionCode) |
130 { |
145 { |
131 LOG_FUNC |
146 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0482_DEVICESTATECHANGEL_ENTRY, this ); |
|
147 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0482_DEVICESTATECHANGEL_EXIT, this ); |
132 } |
148 } |
133 |
149 |
134 |
150 |
135 TInt CUT_PBASE_T_USBDI_0482::FindOUTIsochronousEndpoint(TUsbGenericDescriptor*& aDescriptor) |
151 TInt CUT_PBASE_T_USBDI_0482::FindOUTIsochronousEndpoint(TUsbGenericDescriptor*& aDescriptor) |
136 { |
152 { |
137 LOG_FUNC |
153 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0482_FINDOUTISOCHRONOUSENDPOINT_ENTRY, this ); |
138 aDescriptor = NULL; |
154 aDescriptor = NULL; |
139 |
155 |
140 TUsbInterfaceDescriptor alternate; |
156 TUsbInterfaceDescriptor alternate; |
141 TInt err = iUsbInterface1.GetAlternateInterfaceDescriptor(1, alternate); |
157 TInt err = iUsbInterface1.GetAlternateInterfaceDescriptor(1, alternate); |
142 if(err) |
158 if(err) |
143 { |
159 { |
144 RDebug::Printf("iUsbInterface1.GetAlternateInterfaceDescriptor error = %d",err); |
160 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_FINDOUTISOCHRONOUSENDPOINT, "iUsbInterface1.GetAlternateInterfaceDescriptor error = %d",err); |
|
161 OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0482_FINDOUTISOCHRONOUSENDPOINT_EXIT, this, err ); |
145 return err; |
162 return err; |
146 } |
163 } |
147 |
164 |
148 TUsbGenericDescriptor* descriptor = alternate.iFirstChild; |
165 TUsbGenericDescriptor* descriptor = alternate.iFirstChild; |
149 while(descriptor) |
166 while(descriptor) |
150 { |
167 { |
151 RDebug::Printf("ibDescriptorType = %d", descriptor->ibDescriptorType); |
168 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_FINDOUTISOCHRONOUSENDPOINT_DUP01, "ibDescriptorType = %d", descriptor->ibDescriptorType); |
152 if(descriptor->ibDescriptorType == EEndpoint) |
169 if(descriptor->ibDescriptorType == EEndpoint) |
153 { |
170 { |
154 aDescriptor = descriptor; |
171 aDescriptor = descriptor; |
155 RDebug::Printf("found descriptor return KErrNone"); |
172 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_FINDOUTISOCHRONOUSENDPOINT_DUP02, "found descriptor return KErrNone"); |
|
173 OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0482_FINDOUTISOCHRONOUSENDPOINT_EXIT_DUP01, this, KErrNone ); |
156 return KErrNone; |
174 return KErrNone; |
157 } |
175 } |
158 descriptor = descriptor->iNextPeer; |
176 descriptor = descriptor->iNextPeer; |
159 } |
177 } |
160 |
178 |
|
179 OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0482_FINDOUTISOCHRONOUSENDPOINT_EXIT_DUP02, this, KErrNotFound ); |
161 return KErrNotFound; |
180 return KErrNotFound; |
162 } |
181 } |
163 |
182 |
164 |
183 |
165 TInt CUT_PBASE_T_USBDI_0482::FindINIsochronousEndpoint(TUsbGenericDescriptor*& aDescriptor) |
184 TInt CUT_PBASE_T_USBDI_0482::FindINIsochronousEndpoint(TUsbGenericDescriptor*& aDescriptor) |
166 { |
185 { |
167 LOG_FUNC |
186 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0482_FINDINISOCHRONOUSENDPOINT_ENTRY, this ); |
168 aDescriptor = NULL; |
187 aDescriptor = NULL; |
169 |
188 |
170 TUsbInterfaceDescriptor alternate; |
189 TUsbInterfaceDescriptor alternate; |
171 TInt err = iUsbInterface2.GetAlternateInterfaceDescriptor(1, alternate); |
190 TInt err = iUsbInterface2.GetAlternateInterfaceDescriptor(1, alternate); |
172 if(err) |
191 if(err) |
173 { |
192 { |
174 RDebug::Printf("iUsbInterface2.GetAlternateInterfaceDescriptor error = %d",err); |
193 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_FINDINISOCHRONOUSENDPOINT, "iUsbInterface2.GetAlternateInterfaceDescriptor error = %d",err); |
|
194 OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0482_FINDINISOCHRONOUSENDPOINT_EXIT, this, err ); |
175 return err; |
195 return err; |
176 } |
196 } |
177 |
197 |
178 TUsbGenericDescriptor* descriptor = alternate.iFirstChild; |
198 TUsbGenericDescriptor* descriptor = alternate.iFirstChild; |
179 while(descriptor) |
199 while(descriptor) |
180 { |
200 { |
181 RDebug::Printf("ibDescriptorType = %d", descriptor->ibDescriptorType); |
201 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_FINDINISOCHRONOUSENDPOINT_DUP01, "ibDescriptorType = %d", descriptor->ibDescriptorType); |
182 if(descriptor->ibDescriptorType == EEndpoint) |
202 if(descriptor->ibDescriptorType == EEndpoint) |
183 { |
203 { |
184 aDescriptor = descriptor; |
204 aDescriptor = descriptor; |
185 RDebug::Printf("found descriptor return KErrNone"); |
205 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_FINDINISOCHRONOUSENDPOINT_DUP02, "found descriptor return KErrNone"); |
|
206 OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0482_FINDINISOCHRONOUSENDPOINT_EXIT_DUP01, this, KErrNone ); |
186 return KErrNone; |
207 return KErrNone; |
187 } |
208 } |
188 descriptor = descriptor->iNextPeer; |
209 descriptor = descriptor->iNextPeer; |
189 } |
210 } |
190 |
211 |
|
212 OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0482_FINDINISOCHRONOUSENDPOINT_EXIT_DUP02, this, KErrNotFound ); |
191 return KErrNotFound; |
213 return KErrNotFound; |
192 } |
214 } |
193 |
215 |
194 |
216 |
195 |
217 |
196 void CUT_PBASE_T_USBDI_0482::DeviceInsertedL(TUint aDeviceHandle) |
218 void CUT_PBASE_T_USBDI_0482::DeviceInsertedL(TUint aDeviceHandle) |
197 { |
219 { |
198 LOG_FUNC |
220 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0482_DEVICEINSERTEDL_ENTRY, this ); |
199 |
221 |
200 Cancel(); |
222 Cancel(); |
201 CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle); |
223 CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle); |
202 |
224 |
203 CHECK(CheckTreeAfterDeviceInsertion(testDevice, _L("RLogitechHeadSet")) == KErrNone); |
225 CHECK(CheckTreeAfterDeviceInsertion(testDevice, _L("RLogitechHeadSet")) == KErrNone); |
211 // open interface 1, alt. sett. 1 |
233 // open interface 1, alt. sett. 1 |
212 CHECK(testDevice.Device().GetTokenForInterface(1,token1) == KErrNone); |
234 CHECK(testDevice.Device().GetTokenForInterface(1,token1) == KErrNone); |
213 |
235 |
214 CHECK(iUsbInterface1.Open(token1) == KErrNone); // Default interface setting 0 |
236 CHECK(iUsbInterface1.Open(token1) == KErrNone); // Default interface setting 0 |
215 |
237 |
216 RDebug::Printf("Selecting alternate interface setting 1"); |
238 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_DEVICEINSERTEDL, "Selecting alternate interface setting 1"); |
217 CHECK(iUsbInterface1.SelectAlternateInterface(1) == KErrNone); |
239 CHECK(iUsbInterface1.SelectAlternateInterface(1) == KErrNone); |
218 |
240 |
219 |
241 |
220 // open interface 2, alt. sett. 1 |
242 // open interface 2, alt. sett. 1 |
221 CHECK(testDevice.Device().GetTokenForInterface(2,token2) == KErrNone); |
243 CHECK(testDevice.Device().GetTokenForInterface(2,token2) == KErrNone); |
222 |
244 |
223 CHECK(iUsbInterface2.Open(token2) == KErrNone); // Default interface setting 0 |
245 CHECK(iUsbInterface2.Open(token2) == KErrNone); // Default interface setting 0 |
224 |
246 |
225 |
247 |
226 RDebug::Printf("Selecting alternate interface setting 1"); |
248 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_DEVICEINSERTEDL_DUP01, "Selecting alternate interface setting 1"); |
227 CHECK(iUsbInterface2.SelectAlternateInterface(1) == KErrNone); |
249 CHECK(iUsbInterface2.SelectAlternateInterface(1) == KErrNone); |
228 |
250 |
229 |
251 |
230 iCaseStep = EWaitEndOfMusicTrack; |
252 iCaseStep = EWaitEndOfMusicTrack; |
231 |
253 |
232 // Open a pipe for endpoint (Isoch out) |
254 // Open a pipe for endpoint (Isoch out) |
233 RDebug::Printf("Finding address for an out isoch endpoint on interface 1 setting 1"); |
255 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_DEVICEINSERTEDL_DUP02, "Finding address for an out isoch endpoint on interface 1 setting 1"); |
234 // Isochronous OUT |
256 // Isochronous OUT |
235 TUsbGenericDescriptor* isochEpDescriptorOut; |
257 TUsbGenericDescriptor* isochEpDescriptorOut; |
236 CHECK(KErrNone == FindOUTIsochronousEndpoint(isochEpDescriptorOut)); |
258 CHECK(KErrNone == FindOUTIsochronousEndpoint(isochEpDescriptorOut)); |
237 |
259 |
238 // Get the maximum packet size for this isochronous endpoint |
260 // Get the maximum packet size for this isochronous endpoint |
239 TUint16 wMaxPacketSizeOut = isochEpDescriptorOut->TUint16At(KMaxPacketSizeOffset); |
261 TUint16 wMaxPacketSizeOut = isochEpDescriptorOut->TUint16At(KMaxPacketSizeOffset); |
240 RDebug::Printf("wMaxPacketSizeOut = %d", wMaxPacketSizeOut); |
262 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_DEVICEINSERTEDL_DUP03, "wMaxPacketSizeOut = %d", wMaxPacketSizeOut); |
241 CHECK(wMaxPacketSizeOut == KMaxPacketSizeOutExpected); |
263 CHECK(wMaxPacketSizeOut == KMaxPacketSizeOutExpected); |
242 |
264 |
243 // Isochronous IN |
265 // Isochronous IN |
244 TUsbGenericDescriptor* isochEpDescriptorIn; |
266 TUsbGenericDescriptor* isochEpDescriptorIn; |
245 CHECK(KErrNone == FindINIsochronousEndpoint(isochEpDescriptorIn)); |
267 CHECK(KErrNone == FindINIsochronousEndpoint(isochEpDescriptorIn)); |
246 |
268 |
247 // Get the maximum packet size for this isochronous endpoint |
269 // Get the maximum packet size for this isochronous endpoint |
248 TUint16 wMaxPacketSizeIn = isochEpDescriptorIn->TUint16At(KMaxPacketSizeOffset); |
270 TUint16 wMaxPacketSizeIn = isochEpDescriptorIn->TUint16At(KMaxPacketSizeOffset); |
249 RDebug::Printf("wMaxPacketSizeIn = %d", wMaxPacketSizeIn); |
271 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_DEVICEINSERTEDL_DUP04, "wMaxPacketSizeIn = %d", wMaxPacketSizeIn); |
250 CHECK(wMaxPacketSizeIn == KMaxPacketSizeInExpected); |
272 CHECK(wMaxPacketSizeIn == KMaxPacketSizeInExpected); |
251 |
273 |
252 |
274 |
253 // open pipes now. |
275 // open pipes now. |
254 // Out |
276 // Out |
255 RDebug::Printf("Opening a pipe to %08x",iEndpointAddressOut); |
277 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_DEVICEINSERTEDL_DUP05, "Opening a pipe to %08x",iEndpointAddressOut); |
256 CHECK(iUsbInterface1.OpenPipeForEndpoint(iPipeOut,iEndpointAddressOut,EFalse) == KErrNone); |
278 CHECK(iUsbInterface1.OpenPipeForEndpoint(iPipeOut,iEndpointAddressOut,EFalse) == KErrNone); |
257 |
279 |
258 RDebug::Printf("Opened pipe to endpoint address %08x for isochronous transfer to device",iEndpointAddressOut); |
280 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_DEVICEINSERTEDL_DUP06, "Opened pipe to endpoint address %08x for isochronous transfer to device",iEndpointAddressOut); |
259 |
281 |
260 // In |
282 // In |
261 RDebug::Printf("Opening a pipe to %08x",iEndpointAddressIn); |
283 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_DEVICEINSERTEDL_DUP07, "Opening a pipe to %08x",iEndpointAddressIn); |
262 CHECK(iUsbInterface2.OpenPipeForEndpoint(iPipeIn,iEndpointAddressIn,EFalse) == KErrNone); |
284 CHECK(iUsbInterface2.OpenPipeForEndpoint(iPipeIn,iEndpointAddressIn,EFalse) == KErrNone); |
263 |
285 |
264 RDebug::Printf("Opened pipe to endpoint address %08x for isochronous transfer to device",iEndpointAddressIn); |
286 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_DEVICEINSERTEDL_DUP08, "Opened pipe to endpoint address %08x for isochronous transfer to device",iEndpointAddressIn); |
265 |
287 |
266 // SET_CUR class specific command |
288 // SET_CUR class specific command |
267 TSetCurRequest request(KHighRecordSamplingRate ,iEndpointAddressIn); |
289 TSetCurRequest request(KHighRecordSamplingRate ,iEndpointAddressIn); |
268 iControlEp0->SendRequest(request,this); |
290 iControlEp0->SendRequest(request,this); |
269 |
291 |
325 iOutTransfers.AppendL(transfer); |
347 iOutTransfers.AppendL(transfer); |
326 iOutTransferBuf.Zero(); |
348 iOutTransferBuf.Zero(); |
327 } |
349 } |
328 |
350 |
329 // Initialise the descriptors for transfer |
351 // Initialise the descriptors for transfer |
330 RDebug::Printf("Initialising the transfer descriptors"); |
352 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_DEVICEINSERTEDL_DUP11, "Initialising the transfer descriptors"); |
331 CHECK(iUsbInterface1.InitialiseTransferDescriptors() == KErrNone); |
353 CHECK(iUsbInterface1.InitialiseTransferDescriptors() == KErrNone); |
332 |
354 |
333 // prepare & send transfers(TODO streaming algorithm with 3 Transfers only, filling 2 while the 3rd is transferring his data) |
355 // prepare & send transfers(TODO streaming algorithm with 3 Transfers only, filling 2 while the 3rd is transferring his data) |
334 size = KChunkSize; |
356 size = KChunkSize; |
335 for(TInt iTransfers = 0; iTransfers < iOutTransfers.Count(); iTransfers++) |
357 for(TInt iTransfers = 0; iTransfers < iOutTransfers.Count(); iTransfers++) |
336 { |
358 { |
337 RDebug::Printf("iTransfers = %d", iTransfers); |
359 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_DEVICEINSERTEDL_DUP12, "iTransfers = %d", iTransfers); |
338 // remainder(last loop) |
360 // remainder(last loop) |
339 if(remainderSize != 0 && (iTransfers == iOutTransfers.Count()-1)) |
361 if(remainderSize != 0 && (iTransfers == iOutTransfers.Count()-1)) |
340 { |
362 { |
341 RDebug::Printf("remainderSize = %d", remainderSize); |
363 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_DEVICEINSERTEDL_DUP13, "remainderSize = %d", remainderSize); |
342 size = remainderSize; |
364 size = remainderSize; |
343 } |
365 } |
344 CHECK(trackFile.Read(KChunkSize*iTransfers, iOutTransferBuf, size) == KErrNone); |
366 CHECK(trackFile.Read(KChunkSize*iTransfers, iOutTransferBuf, size) == KErrNone); |
345 CHECK(iOutTransfers[iTransfers]->PrepareTransfer(iOutTransferBuf) == KErrNone); |
367 CHECK(iOutTransfers[iTransfers]->PrepareTransfer(iOutTransferBuf) == KErrNone); |
346 CHECK(iOutTransfers[iTransfers]->TransferOut() == KErrNone); |
368 CHECK(iOutTransfers[iTransfers]->TransferOut() == KErrNone); |
347 iOutTransferBuf.Zero(); |
369 iOutTransferBuf.Zero(); |
348 } |
370 } |
|
371 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0482_DEVICEINSERTEDL_EXIT, this ); |
349 } |
372 } |
350 |
373 |
351 TBool CUT_PBASE_T_USBDI_0482::ReplayRecordedData() |
374 TBool CUT_PBASE_T_USBDI_0482::ReplayRecordedData() |
352 { |
375 { |
353 LOG_FUNC |
376 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0482_REPLAYRECORDEDDATA_ENTRY, this ); |
354 |
377 |
355 iOutTransferBuf.Zero(); |
378 iOutTransferBuf.Zero(); |
356 |
379 |
357 // Transfer OUT |
380 // Transfer OUT |
358 TInt nbChunks = iDataPolledBuf.Length()/KChunkSize; |
381 TInt nbChunks = iDataPolledBuf.Length()/KChunkSize; |
359 TInt remainderSize = iDataPolledBuf.Length()%KChunkSize; |
382 TInt remainderSize = iDataPolledBuf.Length()%KChunkSize; |
360 RDebug::Printf("nbChunks = %d", nbChunks); |
383 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_REPLAYRECORDEDDATA, "nbChunks = %d", nbChunks); |
361 RDebug::Printf("remainderSize = %d", remainderSize); |
384 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_REPLAYRECORDEDDATA_DUP01, "remainderSize = %d", remainderSize); |
362 |
385 |
363 if(remainderSize != 0) |
386 if(remainderSize != 0) |
364 { |
387 { |
365 nbChunks++; |
388 nbChunks++; |
366 } |
389 } |
367 |
390 |
368 // prepare transfers |
391 // prepare transfers |
369 for(TInt iTransfers = 0; iTransfers < nbChunks; iTransfers++) |
392 for(TInt iTransfers = 0; iTransfers < nbChunks; iTransfers++) |
370 { |
393 { |
371 RDebug::Printf("iTransfers = %d", iTransfers); |
394 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_REPLAYRECORDEDDATA_DUP02, "iTransfers = %d", iTransfers); |
372 // remainder(last loop) |
395 // remainder(last loop) |
373 if(remainderSize != 0 && (iTransfers == nbChunks-1)) |
396 if(remainderSize != 0 && (iTransfers == nbChunks-1)) |
374 { |
397 { |
375 RDebug::Printf("remainderSize = %d", remainderSize); |
398 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_REPLAYRECORDEDDATA_DUP03, "remainderSize = %d", remainderSize); |
376 } |
399 } |
377 CHECK_RET_BOOL(iOutTransfers[iTransfers]->PrepareTransfer(iDataPolledBuf) == KErrNone); // TODO retrieve relevant part of iDataPolledBuf if several chunks |
400 CHECK_RET_BOOL(iOutTransfers[iTransfers]->PrepareTransfer(iDataPolledBuf) == KErrNone); // TODO retrieve relevant part of iDataPolledBuf if several chunks |
378 CHECK_RET_BOOL(iOutTransfers[iTransfers]->TransferOut() == KErrNone); |
401 CHECK_RET_BOOL(iOutTransfers[iTransfers]->TransferOut() == KErrNone); |
379 iOutTransferBuf.Zero(); |
402 iOutTransferBuf.Zero(); |
380 } |
403 } |
|
404 OstTraceFunctionExitExt( CUT_PBASE_T_USBDI_0482_REPLAYRECORDEDDATA_EXIT, this, ETrue ); |
381 return ETrue; |
405 return ETrue; |
382 } |
406 } |
383 |
407 |
384 void CUT_PBASE_T_USBDI_0482::TransferCompleteL(TInt aTransferId,TInt aCompletionCode) |
408 void CUT_PBASE_T_USBDI_0482::TransferCompleteL(TInt aTransferId,TInt aCompletionCode) |
385 { |
409 { |
386 LOG_FUNC |
410 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0482_TRANSFERCOMPLETEL_ENTRY, this ); |
387 RDebug::Printf("Transfer completed (id=%d), aCompletionCode = %d",aTransferId, aCompletionCode); |
411 OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_TRANSFERCOMPLETEL, "Transfer completed (id=%d), aCompletionCode = %d",aTransferId, aCompletionCode); |
388 Cancel(); |
412 Cancel(); |
389 |
413 |
390 if(aCompletionCode != KErrNone) |
414 if(aCompletionCode != KErrNone) |
391 { |
415 { |
392 RDebug::Printf("<Error %d> Transfer %d not successful",aCompletionCode,aTransferId); |
416 OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_TRANSFERCOMPLETEL_DUP01, "<Error %d> Transfer %d not successful",aCompletionCode,aTransferId); |
393 TestFailed(aCompletionCode); |
417 TestFailed(aCompletionCode); |
|
418 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0482_TRANSFERCOMPLETEL_EXIT, this ); |
394 return; |
419 return; |
395 } |
420 } |
396 |
421 |
397 if(aTransferId == KRecordedDataId) |
422 if(aTransferId == KRecordedDataId) |
398 { |
423 { |
399 // data successfully recorded |
424 // data successfully recorded |
400 // 1. save data recorded |
425 // 1. save data recorded |
401 CHECK(iIsochInTransfer->DataPolled(KRecordedPacketsExpected, iDataPolledBuf)); |
426 CHECK(iIsochInTransfer->DataPolled(KRecordedPacketsExpected, iDataPolledBuf)); |
402 // 2. waiting now for the end of the music track |
427 // 2. waiting now for the end of the music track |
|
428 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0482_TRANSFERCOMPLETEL_EXIT_DUP01, this ); |
403 return; |
429 return; |
404 } |
430 } |
405 |
431 |
406 switch(iCaseStep) |
432 switch(iCaseStep) |
407 { |
433 { |
408 case EWaitEndOfMusicTrack: |
434 case EWaitEndOfMusicTrack: |
409 { |
435 { |
410 if(aTransferId != iExpectedTransferId) |
436 if(aTransferId != iExpectedTransferId) |
411 { |
437 { |
412 RDebug::Printf("unexpected transfer!"); |
438 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_TRANSFERCOMPLETEL_DUP02, "unexpected transfer!"); |
413 TestFailed(KErrCorrupt); |
439 TestFailed(KErrCorrupt); |
414 } |
440 } |
415 iExpectedTransferId++; |
441 iExpectedTransferId++; |
416 // is it the last transfer? |
442 // is it the last transfer? |
417 if(iExpectedTransferId == iOutTransfers.Count()) |
443 if(iExpectedTransferId == iOutTransfers.Count()) |
418 { |
444 { |
419 RDebug::Printf("last transfer successful! lets replay recorded data"); |
445 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_TRANSFERCOMPLETEL_DUP03, "last transfer successful! lets replay recorded data"); |
420 |
446 |
421 iCaseStep = EReplayRecordedData; // assuming that recording is finished |
447 iCaseStep = EReplayRecordedData; // assuming that recording is finished |
422 TSetCurRequest request(KLowSamplingRate ,iEndpointAddressOut); |
448 TSetCurRequest request(KLowSamplingRate ,iEndpointAddressOut); |
423 iControlEp0->SendRequest(request,this); |
449 iControlEp0->SendRequest(request,this); |
424 } |
450 } |
482 case EInProgress: |
511 case EInProgress: |
483 default: |
512 default: |
484 TestFailed(KErrDisconnected); |
513 TestFailed(KErrDisconnected); |
485 break; |
514 break; |
486 } |
515 } |
|
516 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0482_DEVICEREMOVEDL_EXIT, this ); |
487 } |
517 } |
488 |
518 |
489 |
519 |
490 void CUT_PBASE_T_USBDI_0482::BusErrorL(TInt aError) |
520 void CUT_PBASE_T_USBDI_0482::BusErrorL(TInt aError) |
491 { |
521 { |
492 LOG_FUNC |
522 OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0482_BUSERRORL_ENTRY, this ); |
493 // This test case handles no failiures on the bus |
523 // This test case handles no failiures on the bus |
494 TestFailed(KErrCompletion); |
524 TestFailed(KErrCompletion); |
|
525 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0482_BUSERRORL_EXIT, this ); |
495 } |
526 } |
496 |
527 |
497 |
528 |
498 void CUT_PBASE_T_USBDI_0482::HostRunL() |
529 void CUT_PBASE_T_USBDI_0482::HostRunL() |
499 { |
530 { |
500 LOG_FUNC |
531 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0482_HOSTRUNL_ENTRY, this ); |
501 |
532 |
502 // Obtain the completion code |
533 // Obtain the completion code |
503 TInt completionCode(iStatus.Int()); |
534 TInt completionCode(iStatus.Int()); |
504 |
535 |
505 if(completionCode == KErrNone) |
536 if(completionCode == KErrNone) |
506 { |
537 { |
507 // Action timeout |
538 // Action timeout |
508 RDebug::Printf("<Error> Action timeout"); |
539 OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_HOSTRUNL, "<Error> Action timeout"); |
509 TestFailed(KErrTimedOut); |
540 TestFailed(KErrTimedOut); |
510 } |
541 } |
511 else |
542 else |
512 { |
543 { |
513 RDebug::Printf("<Error %d> Timeout timer could not complete",completionCode); |
544 OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0482_HOSTRUNL_DUP01, "<Error %d> Timeout timer could not complete",completionCode); |
514 TestFailed(completionCode); |
545 TestFailed(completionCode); |
515 } |
546 } |
|
547 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0482_HOSTRUNL_EXIT, this ); |
516 } |
548 } |
517 |
549 |
518 void CUT_PBASE_T_USBDI_0482::DeviceRunL() |
550 void CUT_PBASE_T_USBDI_0482::DeviceRunL() |
519 { |
551 { |
520 } |
552 OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0482_DEVICERUNL_ENTRY, this ); |
521 |
553 OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0482_DEVICERUNL_EXIT, this ); |
522 } |
554 } |
|
555 |
|
556 } |