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