13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
|
18 |
|
19 |
|
20 |
18 // [INCLUDE FILES] - do not remove |
21 // [INCLUDE FILES] - do not remove |
19 #include <e32svr.h> |
22 #include <e32svr.h> |
20 #include <StifParser.h> |
23 #include <StifParser.h> |
21 #include <ecom/ecom.h> |
24 #include <ecom/ecom.h> |
22 #include <Stiftestinterface.h> |
25 #include <Stiftestinterface.h> |
23 #include "usbuinotifapitest.h" |
26 #include "UsbUiNotifApiTest.h" |
24 |
27 |
25 // EXTERNAL DATA STRUCTURES |
28 // EXTERNAL DATA STRUCTURES |
|
29 //extern ?external_data; |
26 |
30 |
27 // EXTERNAL FUNCTION PROTOTYPES |
31 // EXTERNAL FUNCTION PROTOTYPES |
|
32 //extern ?external_function( ?arg_type,?arg_type ); |
28 |
33 |
29 // CONSTANTS |
34 // CONSTANTS |
30 #ifdef __WINS__ |
35 //const ?type ?constant_var = ?constant; |
31 _LIT( KUsbAppProcPattern, "usb[*" ); |
|
32 #else |
|
33 _LIT( KUsbAppProcPattern, "#USBSettingsApp*" ); |
|
34 #endif |
|
35 |
36 |
36 // MACROS |
37 // MACROS |
|
38 //#define ?macro ?macro_def |
37 |
39 |
38 // LOCAL CONSTANTS AND MACROS |
40 // LOCAL CONSTANTS AND MACROS |
|
41 //const ?type ?constant_var = ?constant; |
|
42 //#define ?macro_name ?macro_def |
39 |
43 |
40 // MODULE DATA STRUCTURES |
44 // MODULE DATA STRUCTURES |
|
45 //enum ?declaration |
|
46 //typedef ?declaration |
41 |
47 |
42 // LOCAL FUNCTION PROTOTYPES |
48 // LOCAL FUNCTION PROTOTYPES |
|
49 //?type ?function_name( ?arg_type, ?arg_type ); |
43 |
50 |
44 // FORWARD DECLARATIONS |
51 // FORWARD DECLARATIONS |
|
52 //class ?FORWARD_CLASSNAME; |
45 |
53 |
46 // ============================= LOCAL FUNCTIONS =============================== |
54 // ============================= LOCAL FUNCTIONS =============================== |
47 |
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // ?function_name ?description. |
|
58 // ?description |
|
59 // Returns: ?value_1: ?description |
|
60 // ?value_n: ?description_line1 |
|
61 // ?description_line2 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 /* |
|
65 ?type ?function_name( |
|
66 ?arg_type arg, // ?description |
|
67 ?arg_type arg) // ?description |
|
68 { |
|
69 |
|
70 ?code // ?comment |
|
71 |
|
72 // ?comment |
|
73 ?code |
|
74 } |
|
75 */ |
|
76 |
48 // ============================ MEMBER FUNCTIONS =============================== |
77 // ============================ MEMBER FUNCTIONS =============================== |
49 |
78 |
50 // ----------------------------------------------------------------------------- |
79 // ----------------------------------------------------------------------------- |
51 // CUSBUiNotifApiTest::Delete |
80 // CUsbUiNotifApiTest::Delete |
52 // Delete here all resources allocated and opened from test methods. |
81 // Delete here all resources allocated and opened from test methods. |
53 // Called from destructor. |
82 // Called from destructor. |
54 // ----------------------------------------------------------------------------- |
83 // ----------------------------------------------------------------------------- |
55 // |
84 // |
56 void CUSBUiNotifApiTest::Delete() |
85 void CUsbUiNotifApiTest::Delete() |
57 { |
86 { |
58 iNotifier -> Close(); |
87 iNotifier -> Close(); |
59 delete iNotifier; |
88 delete iNotifier; |
60 iNotifier = NULL; |
89 iNotifier = NULL; |
61 } |
90 iUsbWatcher -> Close(); |
62 |
91 delete iUsbWatcher; |
63 // ----------------------------------------------------------------------------- |
92 iUsbWatcher = NULL; |
64 // CUSBUiNotifApiTest::RunMethodL |
93 delete iRepository; |
|
94 iRepository = NULL; |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CUsbUiNotifApiTest::RunMethodL |
65 // Run specified method. Contains also table of test mothods and their names. |
99 // Run specified method. Contains also table of test mothods and their names. |
66 // ----------------------------------------------------------------------------- |
100 // ----------------------------------------------------------------------------- |
67 // |
101 // |
68 TInt CUSBUiNotifApiTest::RunMethodL( |
102 TInt CUsbUiNotifApiTest::RunMethodL( |
69 CStifItemParser& aItem ) |
103 CStifItemParser& aItem ) |
70 { |
104 { |
71 |
105 |
72 static TStifFunctionInfo const KFunctions[] = |
106 static TStifFunctionInfo const KFunctions[] = |
73 { |
107 { |
74 // Copy this line for every implemented function. |
|
75 // First string is the function name used in TestScripter script file. |
|
76 // Second is the actual implementation member function. |
|
77 ENTRY( "CableConnectedNotifierTest", CUSBUiNotifApiTest::CableConnectedNotifierTest ), |
|
78 ENTRY( "FinishCableConnectedQuery", CUSBUiNotifApiTest::FinishCableConnectedQuery ), |
|
79 ENTRY( "UsbQueriesNotifierTest", CUSBUiNotifApiTest::UsbQueriesNotifierTest ), |
|
80 ENTRY( "FinishQuery", CUSBUiNotifApiTest::FinishQuery ), |
|
81 ENTRY( "UsbOTGErrorNotifierTests", CUSBUiNotifApiTest::UsbOTGErrorNotifierTests ), |
|
82 ENTRY( "UsbOTGWarningNotifierTests", CUSBUiNotifApiTest::UsbOTGWarningNotifierTests ), |
|
83 ENTRY( "LoadNotifiers", CUSBUiNotifApiTest::LoadNotifiersL ), |
|
84 ENTRY( "UnLoadNotifiers", CUSBUiNotifApiTest::UnLoadNotifiers ), |
|
85 ENTRY( "UsbMSMMNotifierTests", CUSBUiNotifApiTest::UsbMSMMNotifierTests ), |
|
86 ENTRY( "CancelMsmmNotifier", CUSBUiNotifApiTest::CancelMsmmNotifier ), |
|
87 ENTRY( "CancelQueryNotifier", CUSBUiNotifApiTest::CancelQueryNotifier ), |
|
88 ENTRY( "CancelOtgErrorNotifier", CUSBUiNotifApiTest::CancelOtgErrorNotifier ), |
|
89 ENTRY( "CancelOtgWarningNotifier", CUSBUiNotifApiTest::CancelOtgWarningNotifier ), |
|
90 ENTRY( "CancelCableConnectedNotifier", CUSBUiNotifApiTest::CancelCableConnectedNotifier ), |
|
91 ENTRY( "WaitForRequest", CUSBUiNotifApiTest::WaitForRequest ), |
|
92 ENTRY( "SynchStart", CUSBUiNotifApiTest::SynchStart ), |
|
93 ENTRY( "Update", CUSBUiNotifApiTest::Update ) |
|
94 //ADD NEW ENTRY HERE |
108 //ADD NEW ENTRY HERE |
95 // [test cases entries] - Do not remove |
109 // [test cases entries] - Do not remove |
96 |
110 ENTRY( "ExecuteApiTestBlock", CUsbUiNotifApiTest::ExecuteApiTestBlock ), |
|
111 ENTRY( "ExecuteModuleTestBlock", CUsbUiNotifApiTest::ExecuteModuleTestBlock ), |
|
112 ENTRY( "ExecuteBranchTestBlock", CUsbUiNotifApiTest::ExecuteBranchTestBlock ), |
97 }; |
113 }; |
98 |
114 |
99 const TInt count = sizeof( KFunctions ) / |
115 const TInt count = sizeof( KFunctions ) / |
100 sizeof( TStifFunctionInfo ); |
116 sizeof( TStifFunctionInfo ); |
101 |
117 |
102 return RunInternalL( KFunctions, count, aItem ); |
118 return RunInternalL( KFunctions, count, aItem ); |
103 |
119 |
104 } |
120 } |
105 |
121 |
106 // ----------------------------------------------------------------------------- |
122 // ----------------------------------------------------------------------------- |
107 // CUSBUiNotifApiTest::CableConnectedNotifierTests |
123 // CUsbUiNotifApiTest::GetTestBlockParamsL |
108 // ----------------------------------------------------------------------------- |
124 // ----------------------------------------------------------------------------- |
109 |
125 |
110 TInt CUSBUiNotifApiTest::CableConnectedNotifierTest( CStifItemParser& /*aItem*/ ) |
126 void CUsbUiNotifApiTest::GetTestBlockParamsL( CStifItemParser& aItem ) |
111 { |
127 { |
|
128 TRACE_INFO( _L(">>> GetTestBlockParamsL") ); |
|
129 |
|
130 // Add new test block branches below, get all required test parameters |
|
131 if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) ) |
|
132 { |
|
133 User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption1 ) ); |
|
134 User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) ); |
|
135 User::LeaveIfError( aItem.GetNextInt( iTestBlockParams.iTestIntOption1 ) ); |
|
136 User::LeaveIfError( aItem.GetNextChar( iTestBlockParams.iTestCharOption1 ) ); |
|
137 } |
|
138 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CableConnectedNotifierTest" ) ) ) |
|
139 { |
|
140 User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) ); |
|
141 } |
|
142 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) ) |
|
143 { |
|
144 User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) ); |
|
145 } |
|
146 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FinishQuery" ) ) ) |
|
147 { |
|
148 User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) ); |
|
149 } |
|
150 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbOTGErrorNotifierTests" ) ) ) |
|
151 { |
|
152 User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) ); |
|
153 } |
|
154 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbOTGWarningNotifierTests" ) ) ) |
|
155 { |
|
156 User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) ); |
|
157 } |
|
158 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "LoadNotifiers" ) ) ) |
|
159 { |
|
160 } |
|
161 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UnLoadNotifiers" ) ) ) |
|
162 { |
|
163 } |
|
164 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbMSMMNotifierTests" ) ) ) |
|
165 { |
|
166 User::LeaveIfError( aItem.GetNextString( iTestBlockParams.iTestOption2 ) ); |
|
167 } |
|
168 else |
|
169 { |
|
170 TRACE_INFO( _L("GetTestBlockParamsL() Test type: not found") ); |
|
171 User::Leave( KErrNotFound ); |
|
172 } |
|
173 TRACE_INFO( _L("<<< GetTestBlockParamsL") ); |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CUsbUiNotifApiTest::ExecuteApiTestBlock |
|
178 // ----------------------------------------------------------------------------- |
|
179 |
|
180 TInt CUsbUiNotifApiTest::ExecuteApiTestBlock( CStifItemParser& aItem ) |
|
181 { |
|
182 TRACE_INFO( _L(">>> ExecuteApiTestBlock") ); |
|
183 |
|
184 TInt res; |
|
185 TUsbUiNotifApiTestResult testResult = ETestCaseFailed; |
|
186 |
|
187 TRAP( res, DoExecuteApiTestBlockL( aItem, testResult ) ); |
|
188 if ( res != KErrNone ) |
|
189 { |
|
190 TRACE_INFO( (_L("DoExecuteApiTestBlockL error: %d"), res) ); |
|
191 return res; |
|
192 } |
|
193 |
|
194 STIF_ASSERT_EQUALS( ETestCasePassed, testResult ); |
|
195 TRACE_INFO( _L("Test case passed") ); |
|
196 |
|
197 TRACE_INFO( _L("<<< ExecuteApiTestBlock") ); |
|
198 |
|
199 return KErrNone; |
|
200 } |
|
201 |
|
202 |
|
203 void CUsbUiNotifApiTest::DoExecuteApiTestBlockL( CStifItemParser& aItem, TUsbUiNotifApiTestResult& aTestResult ) |
|
204 { |
|
205 TRACE_INFO( _L(">>>DoExecuteApiTestBlockL") ); |
|
206 |
|
207 User::LeaveIfError( aItem.GetString( _L( "ExecuteApiTestBlock" ), iTestBlockParams.iTestBlockName ) ); |
|
208 TRACE_INFO( (_L("Api test type: %S"), &iTestBlockParams.iTestBlockName) ); |
|
209 |
|
210 GetTestBlockParamsL( aItem ); |
|
211 |
|
212 // Add new API test block branches with optional test parameters here |
|
213 if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) ) |
|
214 { |
|
215 ExampleTestL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, |
|
216 iTestBlockParams.iTestIntOption1, iTestBlockParams.iTestCharOption1, aTestResult ); |
|
217 } |
|
218 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "CableConnectedNotifierTest" ) ) ) |
|
219 { |
|
220 CableConnectedNotifierTest( iTestBlockParams.iTestOption2, aTestResult ); |
|
221 } |
|
222 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) ) |
|
223 { |
|
224 UsbQueriesNotifierTest( iTestBlockParams.iTestOption2, aTestResult ); |
|
225 } |
|
226 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "FinishQuery" ) ) ) |
|
227 { |
|
228 FinishQuery( iTestBlockParams.iTestOption2, aTestResult ); |
|
229 } |
|
230 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) ) |
|
231 { |
|
232 UsbQueriesNotifierTest( iTestBlockParams.iTestOption2, aTestResult ); |
|
233 } |
|
234 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) ) |
|
235 { |
|
236 UsbQueriesNotifierTest( iTestBlockParams.iTestOption2, aTestResult ); |
|
237 } |
|
238 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbQueriesNotifierTest" ) ) ) |
|
239 { |
|
240 UsbQueriesNotifierTest( iTestBlockParams.iTestOption2, aTestResult ); |
|
241 } |
|
242 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbOTGErrorNotifierTests" ) ) ) |
|
243 { |
|
244 UsbOTGErrorNotifierTests( iTestBlockParams.iTestOption2, aTestResult ); |
|
245 } |
|
246 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbOTGWarningNotifierTests" ) ) ) |
|
247 { |
|
248 UsbOTGWarningNotifierTests( iTestBlockParams.iTestOption2, aTestResult ); |
|
249 } |
|
250 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "LoadNotifiers" ) ) ) |
|
251 { |
|
252 LoadNotifiersL( aTestResult ); |
|
253 } |
|
254 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UnLoadNotifiers" ) ) ) |
|
255 { |
|
256 UnLoadNotifiers( aTestResult ); |
|
257 } |
|
258 else if ( !iTestBlockParams.iTestBlockName.Compare( _L( "UsbMSMMNotifierTests" ) ) ) |
|
259 { |
|
260 UsbMSMMNotifierTests( iTestBlockParams.iTestOption2, aTestResult ); |
|
261 } |
|
262 else |
|
263 { |
|
264 TRACE_INFO( _L("DoExecuteApiTestBlockL() Test type: not found") ); |
|
265 User::Leave( KErrNotFound ); |
|
266 } |
|
267 |
|
268 TRACE_INFO( _L("<<<DoExecuteApiTestBlockL") ); |
|
269 } |
|
270 |
|
271 // ----------------------------------------------------------------------------- |
|
272 // CUsbUiNotifApiTest::ExecuteModuleTestBlock |
|
273 // ----------------------------------------------------------------------------- |
|
274 |
|
275 TInt CUsbUiNotifApiTest::ExecuteModuleTestBlock( CStifItemParser& aItem ) |
|
276 { |
|
277 TRACE_INFO( _L(">>>ExecuteModuleTestBlock") ); |
|
278 |
112 TInt res; |
279 TInt res; |
113 TPtrC8 dummyPckg; //no parameters used |
280 TUsbUiNotifApiTestResult testResult; |
114 |
281 |
115 res = iNotifier -> Connect(); |
282 TRAP( res, DoExecuteModuleTestBlockL( aItem, testResult ) ); |
116 if ( res != KErrNone ) |
283 if ( res != KErrNone ) |
117 { |
284 { |
118 iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); |
285 TRACE_INFO( (_L("DoExecuteModuleTestBlockL error: %d"), res) ); |
|
286 return res; |
|
287 } |
|
288 |
|
289 STIF_ASSERT_EQUALS( ETestCasePassed, testResult ); |
|
290 TRACE_INFO( _L("Test case passed") ); |
|
291 TRACE_INFO( _L("<<<ExecuteModuleTestBlock") ); |
|
292 return KErrNone; |
|
293 } |
|
294 |
|
295 |
|
296 void CUsbUiNotifApiTest::DoExecuteModuleTestBlockL( CStifItemParser& aItem, TUsbUiNotifApiTestResult& aTestResult ) |
|
297 { |
|
298 TRACE_INFO( _L(">>>DoExecuteModuleTestBlockL") ); |
|
299 |
|
300 User::LeaveIfError( aItem.GetString( _L( "ExecuteModuleTestBlock" ), iTestBlockParams.iTestBlockName ) ); |
|
301 TRACE_INFO( (_L("Module test type: %S"), &iTestBlockParams.iTestBlockName) ); |
|
302 |
|
303 GetTestBlockParamsL( aItem ); |
|
304 |
|
305 // Add new module test block branches with optional test parameters here |
|
306 if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) ) |
|
307 { |
|
308 ExampleTestL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, |
|
309 iTestBlockParams.iTestIntOption1, iTestBlockParams.iTestCharOption1, aTestResult ); |
|
310 } |
|
311 else |
|
312 { |
|
313 TRACE_INFO( _L("DoExecuteModuleTestBlockL() Test type: not found") ); |
|
314 User::Leave( KErrNotFound ); |
|
315 } |
|
316 |
|
317 TRACE_INFO( _L("<<<DoExecuteModuleTestBlockL") ); |
|
318 } |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // CUsbUiNotifApiTest::ExecuteBranchTestBlock |
|
322 // ----------------------------------------------------------------------------- |
|
323 |
|
324 TInt CUsbUiNotifApiTest::ExecuteBranchTestBlock( CStifItemParser& aItem ) |
|
325 { |
|
326 TRACE_INFO( _L(">>>ExecuteBranchTestBlock") ); |
|
327 |
|
328 TInt res; |
|
329 TUsbUiNotifApiTestResult testResult; |
|
330 |
|
331 TRAP( res, DoExecuteBranchTestBlockL( aItem, testResult ) ); |
|
332 if ( res != KErrNone ) |
|
333 { |
|
334 TRACE_INFO( (_L("DoExecuteBranchTestBlockL error: %d"), res) ); |
119 return res; |
335 return res; |
120 } |
336 } |
121 iLog -> Log( _L("RNotifier connected") ); |
337 |
122 |
338 STIF_ASSERT_EQUALS( ETestCasePassed, testResult ); |
123 //kill the possibly running usb application |
339 TRACE_INFO( _L("Test case passed") ); |
124 FindAndKillProcess(KUsbAppProcPattern); |
340 TRACE_INFO( _L("<<<ExecuteBranchTestBlock") ); |
125 |
|
126 iNotifier -> StartNotifierAndGetResponse( iReqStatus, KCableConnectedNotifierUid, |
|
127 dummyPckg, iConnectionNotifierResponseParamsPckg ); |
|
128 |
|
129 return KErrNone; |
341 return KErrNone; |
130 |
342 } |
131 } |
343 |
132 |
344 |
133 |
345 void CUsbUiNotifApiTest::DoExecuteBranchTestBlockL( CStifItemParser& aItem, TUsbUiNotifApiTestResult& aTestResult ) |
134 TInt CUSBUiNotifApiTest::FinishCableConnectedQuery( CStifItemParser& aItem ) |
346 { |
135 { |
347 TRACE_INFO( _L(">>>DoExecuteBranchTestBlockL") ); |
136 //give time for application to start, in microseconds |
348 |
137 const TInt KAppLaunchDelay = 5000000; |
349 User::LeaveIfError( aItem.GetString( _L( "ExecuteBranchTestBlock" ), iTestBlockParams.iTestBlockName ) ); |
|
350 TRACE_INFO( (_L("Branch test type: %S"), &iTestBlockParams.iTestBlockName) ); |
|
351 |
|
352 GetTestBlockParamsL( aItem ); |
|
353 |
|
354 // Add new branch test block branches with optional test parameters here |
|
355 if ( !iTestBlockParams.iTestBlockName.Compare( _L( "ExampleTestL" ) ) ) |
|
356 { |
|
357 ExampleTestL( iTestBlockParams.iTestOption1, iTestBlockParams.iTestOption2, |
|
358 iTestBlockParams.iTestIntOption1, iTestBlockParams.iTestCharOption1, aTestResult ); |
|
359 } |
|
360 else |
|
361 { |
|
362 TRACE_INFO( _L("DoExecuteBranchTestBlockL() Test type: not found") ); |
|
363 User::Leave( KErrNotFound ); |
|
364 } |
|
365 |
|
366 TRACE_INFO( _L("<<<DoExecuteBranchTestBlockL") ); |
|
367 } |
|
368 |
|
369 // Add test block methods implementation here |
|
370 // ----------------------------------------------------------------------------- |
|
371 // CUsbUiNotifApiTest::ExampleTestL |
|
372 // ----------------------------------------------------------------------------- |
|
373 |
|
374 void CUsbUiNotifApiTest::ExampleTestL( TPtrC aTestOption, TPtrC aTestSubOption, |
|
375 TInt aTestIntOption, TInt aTestCharOption, TUsbUiNotifApiTestResult& aTestResult ) |
|
376 { |
|
377 TRACE_INFO( _L(">>>ExampleTestL") ); |
|
378 |
|
379 if ( !aTestOption.Compare( _L( "API" ) ) ) |
|
380 { |
|
381 TRACE_INFO( (_L("Api test option: %S"), &aTestOption) ); |
|
382 TRACE_INFO( (_L("Api test sub-option: %S"), &aTestSubOption) ); |
|
383 TRACE_INFO( (_L("Api test int option: %d"), aTestIntOption) ); |
|
384 TRACE_INFO( (_L("Api test char option: %c"), aTestCharOption) ); |
|
385 } |
|
386 else if ( !aTestOption.Compare( _L( "MODULE" ) ) ) |
|
387 { |
|
388 TRACE_INFO( (_L("Module test option: %S"), &aTestOption) ); |
|
389 TRACE_INFO( (_L("Module test sub-option: %S"), &aTestSubOption) ); |
|
390 TRACE_INFO( (_L("Module test int option: %d"), aTestIntOption) ); |
|
391 TRACE_INFO( (_L("Module test char option: %c"), aTestCharOption) ); |
|
392 } |
|
393 else if ( !aTestOption.Compare( _L( "BRANCH" ) ) ) |
|
394 { |
|
395 TRACE_INFO( (_L("Branch test option: %S"), &aTestOption) ); |
|
396 TRACE_INFO( (_L("Branch test sub-option: %S"), &aTestSubOption) ); |
|
397 TRACE_INFO( (_L("Branch test int option: %d"), aTestIntOption) ); |
|
398 TRACE_INFO( (_L("Branch test char option: %c"), aTestCharOption) ); |
|
399 } |
|
400 else |
|
401 { |
|
402 TRACE_INFO( _L("Invalid test parameter") ); |
|
403 User::Leave( KErrNotFound ); |
|
404 } |
|
405 |
|
406 aTestResult = ETestCasePassed; |
|
407 |
|
408 TRACE_INFO( _L("<<<ExampleTestL") ); |
|
409 } |
|
410 |
|
411 // ----------------------------------------------------------------------------- |
|
412 // CUsbUiNotifApiTest::CableConnectedNotifierTest |
|
413 // ----------------------------------------------------------------------------- |
|
414 |
|
415 void CUsbUiNotifApiTest::CableConnectedNotifierTest( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ) |
|
416 { |
|
417 TRACE_INFO( _L(">>>CableConnectedNotifierTest") ); |
|
418 |
138 TInt res; |
419 TInt res; |
139 TPtrC optionName( KNullDesC ); |
420 TUSBConnectionNotifierParamsPckg emptyNotifierInputPckg; |
140 TTestOption option; |
421 TPtrC displayedUsbPersonalityName( KNullDesC ); |
141 TPtrC expectedUsbPersonalityName( KNullDesC ); |
422 TInt displayedUsbPersonalityId; |
142 TInt expectedErrorCode; |
423 |
143 |
424 res = GetPersonalityIdFromString( aTestSubOption, displayedUsbPersonalityId ); |
144 iLog -> Log( _L("FinishCableConnectedQuery") ); |
425 if ( res != KErrNone ) |
145 |
426 { |
146 res = aItem.GetString( _L( "FinishCableConnectedQuery" ), optionName ); |
427 TRACE_INFO( (_L("GetPersonalityIdFromString failed with value: %d"), res) ); |
|
428 return; |
|
429 } |
|
430 |
|
431 res = iRepository -> Get( KUsbWatcherPersonality, iPersonalityIdBackup ); |
|
432 if ( res != KErrNone ) |
|
433 { |
|
434 TRACE_INFO( (_L("Personality backup failed with value (cenrep): %d"), res) ); |
|
435 return; |
|
436 } |
|
437 |
|
438 res = iUsbWatcher -> Connect(); |
|
439 if ( res != KErrNone ) |
|
440 { |
|
441 TRACE_INFO( (_L("Failed to connect UsbWatcher with value: %d"), res) ); |
|
442 return; |
|
443 } |
|
444 TRACE_INFO( _L("UsbWatcher connected") ); |
147 |
445 |
148 if ( res != KErrNone ) |
446 iUsbWatcher -> SetPersonality( iReqStatus, displayedUsbPersonalityId, ETrue, ETrue ); |
149 { |
447 User::WaitForRequest( iReqStatus ); |
150 iLog -> Log( _L("GetString failed with value: %d"), res ); |
448 if ( iReqStatus.Int() != KErrNone ) |
151 iNotifier -> Close(); |
449 { |
152 return res; |
450 TRACE_INFO( (_L("Failed to set usb personality with value: %d"), iReqStatus.Int()) ); |
153 } |
|
154 |
|
155 iLog -> Log( _L("FinishCableConnectedQuery getting option") ); |
|
156 res = GetTestOption( optionName, option ); |
|
157 if ( res != KErrNone ) |
|
158 { |
|
159 iLog -> Log( _L("GetTestOption failed with value: %d"), res ); |
|
160 iUsbWatcher -> Close(); |
451 iUsbWatcher -> Close(); |
161 iNotifier -> Close(); |
452 return; |
162 return res; |
453 } |
163 } |
454 |
164 |
455 res = iNotifier -> Connect(); |
165 iLog -> Log( _L("FinishCableConnectedQuery wait for request") ); |
456 if ( res != KErrNone ) |
|
457 { |
|
458 TRACE_INFO( (_L("Failed to connect RNotifier with value: %d"), res) ); |
|
459 iUsbWatcher -> Close(); |
|
460 return; |
|
461 } |
|
462 TRACE_INFO( _L("RNotifier connected") ); |
|
463 |
|
464 iNotifier -> StartNotifierAndGetResponse( iReqStatus, KCableConnectedNotifierUid, emptyNotifierInputPckg, iConnectionNotifierResponseParamsPckg ); |
166 User::WaitForRequest( iReqStatus ); |
465 User::WaitForRequest( iReqStatus ); |
167 expectedErrorCode = iReqStatus.Int(); |
466 |
168 |
467 TRACE_INFO((_L("StartNotifierAndGetResponse Status: %d, expected: %d"), iReqStatus.Int(), KErrCancel)); |
169 iLog -> Log( _L("FinishCableConnectedQuery request complete") ); |
468 if(iReqStatus.Int() == KErrCancel) |
170 |
469 aTestResult = ETestCasePassed; |
171 iNotifier -> Close(); |
470 |
172 |
471 TRACE_INFO( _L("<<<CableConnectedNotifierTest") ); |
173 iLog -> Log( _L("FinishCableConnectedQuery close") ); |
472 } |
174 |
473 |
175 TInt ret = KErrNone; |
474 |
176 switch( option ) |
475 // ----------------------------------------------------------------------------- |
177 { |
476 // CUsbUiNotifApiTest::UsbQueriesNotifierTest |
178 case EQueryAccepted: |
477 // ----------------------------------------------------------------------------- |
179 iLog -> Log( _L("EQueryAccepted")); |
478 |
180 User::After(KAppLaunchDelay); //let the app start and let the tester person to see that |
479 void CUsbUiNotifApiTest::UsbQueriesNotifierTest( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ) |
181 ret = FindAndKillProcess(KUsbAppProcPattern); |
480 { |
182 if (ret != KErrNone) |
481 TRACE_INFO( _L(">>>UsbQueriesNotifierTest") ); |
183 { |
|
184 iLog -> Log( _L("Process start failed: %d"), ret ); |
|
185 return ret; |
|
186 } |
|
187 iLog -> Log( _L("Request status value: %d, expected: %d"), expectedErrorCode, KErrCancel ); |
|
188 //the notifier returns KErrCancel when clicked |
|
189 STIF_ASSERT_EQUALS( KErrCancel, expectedErrorCode ); |
|
190 break; |
|
191 case EQueryCanceled: |
|
192 iLog -> Log( _L("FinishCableConnectedQuery canceled") ); |
|
193 iLog -> Log( _L("Request status value: %d, expected: %d"), expectedErrorCode, KErrCancel ); |
|
194 STIF_ASSERT_EQUALS( KErrCancel, expectedErrorCode ); |
|
195 break; |
|
196 default: |
|
197 iLog -> Log( _L("FinishCableConnectedQuery default - not found") ); |
|
198 return KErrNotFound; |
|
199 } |
|
200 |
|
201 iLog -> Log( _L("Test case passed!") ); |
|
202 return KErrNone; |
|
203 } |
|
204 |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CBtNotifApiTest::UsbQueriesNotifierTests |
|
208 // ----------------------------------------------------------------------------- |
|
209 |
|
210 TInt CUSBUiNotifApiTest::UsbQueriesNotifierTest( CStifItemParser& aItem ) |
|
211 { |
|
212 TInt res; |
482 TInt res; |
213 TPtrC usbQueryName( KNullDesC ); |
|
214 TUSBUIQueries usbQueryType; |
483 TUSBUIQueries usbQueryType; |
215 |
484 |
216 res = aItem.GetString( _L( "UsbQueriesNotifierTest" ), usbQueryName ); |
485 |
217 if ( res != KErrNone ) |
486 res = GetQueryType( aTestSubOption, usbQueryType ); |
218 { |
487 if ( res != KErrNone ) |
219 iLog -> Log( _L("GetString failed with value: %d"), res ); |
488 { |
220 iNotifier -> Close(); |
489 TRACE_INFO( (_L("GetQueryType failed with value: %d"), res) ); |
221 return res; |
490 return; |
222 } |
|
223 |
|
224 res = GetQueryType( usbQueryName, usbQueryType ); |
|
225 if ( res != KErrNone ) |
|
226 { |
|
227 iLog -> Log( _L("GetQueryType failed with value: %d"), res ); |
|
228 return res; |
|
229 } |
491 } |
230 |
492 |
231 TUSBQueriesNotiferParams notifierParams; |
493 TUSBQueriesNotiferParams notifierParams; |
232 notifierParams.iDrive = 'c'; |
494 notifierParams.iDrive = 'c'; |
233 notifierParams.iQuery = usbQueryType; |
495 notifierParams.iQuery = usbQueryType; |
234 TUSBQueriesNotifierParamsPckg notifierParamsPckg( notifierParams ); |
496 TUSBQueriesNotifierParamsPckg notifierParamsPckg( notifierParams ); |
235 TPckgBuf<TBool> output; |
497 TPckgBuf<TBool> output; |
236 |
498 |
237 if (!iNotifierConnected) |
499 res = iNotifier -> Connect(); |
238 { |
500 if ( res != KErrNone ) |
239 res = iNotifier -> Connect(); |
501 { |
240 iNotifierConnected = ETrue; |
502 TRACE_INFO( (_L("Failed to connect RNotifier with value: %d"), res) ); |
241 } |
503 return; |
242 if ( res != KErrNone ) |
|
243 { |
|
244 iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); |
|
245 return res; |
|
246 } |
504 } |
247 iLog -> Log( _L("RNotifier connected") ); |
505 TRACE_INFO( _L("RNotifier connected") ); |
248 |
506 |
249 switch( usbQueryType ) |
507 switch( usbQueryType ) |
250 { |
508 { |
251 case EUSBNoMemoryCard: |
509 case EUSBNoMemoryCard: |
252 iCompleteQuery = ETrue; |
510 iCompleteQuery = ETrue; |
257 break; |
515 break; |
258 default: |
516 default: |
259 break; |
517 break; |
260 } |
518 } |
261 |
519 |
262 iNotifier -> StartNotifierAndGetResponse( iReqStatus, KQueriesNotifier, |
520 iNotifier -> StartNotifierAndGetResponse( iReqStatus, KQueriesNotifier, notifierParamsPckg, output ); |
263 notifierParamsPckg, output ); |
521 |
264 iLog -> Log( _L("StartNotifierAndGetResponse ready") ); |
522 aTestResult = ETestCasePassed; |
265 |
523 |
266 return KErrNone; |
524 TRACE_INFO( _L("<<<UsbQueriesNotifierTest") ); |
267 } |
525 } |
268 |
526 |
269 // ----------------------------------------------------------------------------- |
527 // ----------------------------------------------------------------------------- |
270 // CBtNotifApiTest::UsbOTGErrorNotifierTests |
528 // CUsbUiNotifApiTest::UsbOTGErrorNotifierTests |
271 // ----------------------------------------------------------------------------- |
529 // ----------------------------------------------------------------------------- |
272 |
530 |
273 TInt CUSBUiNotifApiTest::UsbOTGErrorNotifierTests( CStifItemParser& aItem ) |
531 void CUsbUiNotifApiTest::UsbOTGErrorNotifierTests( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ) |
274 { |
532 { |
|
533 TRACE_INFO( _L(">>>UsbOTGErrorNotifierTests") ); |
|
534 |
275 TInt res; |
535 TInt res; |
276 TPtrC usbQueryName( KNullDesC ); |
|
277 TUsbUiNotifOtgError usbOTGErrorType; |
536 TUsbUiNotifOtgError usbOTGErrorType; |
278 |
537 |
279 res = aItem.GetString( _L( "UsbOTGErrorNotifierTests" ), usbQueryName ); |
538 res = GetOTGErrorType( aTestSubOption, usbOTGErrorType ); |
280 if ( res != KErrNone ) |
539 if ( res != KErrNone ) |
281 { |
540 { |
282 iLog -> Log( _L("GetString failed with value: %d"), res ); |
541 TRACE_INFO( (_L("usbOTGErrorType failed with value: %d"), res) ); |
283 iNotifier -> Close(); |
542 return; |
284 return res; |
|
285 } |
|
286 |
|
287 res = GetOTGErrorType( usbQueryName, usbOTGErrorType ); |
|
288 if ( res != KErrNone ) |
|
289 { |
|
290 iLog -> Log( _L("usbOTGErrorType failed with value: %d"), res ); |
|
291 return res; |
|
292 } |
543 } |
293 |
544 |
294 if (!iNotifierConnected) |
545 res = iNotifier -> Connect(); |
295 { |
546 if ( res != KErrNone ) |
296 res = iNotifier -> Connect(); |
547 { |
297 iNotifierConnected = ETrue; |
548 TRACE_INFO( (_L("Failed to connect RNotifier with value: %d"), res) ); |
298 } |
549 return; |
299 if ( res != KErrNone ) |
|
300 { |
|
301 iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); |
|
302 return res; |
|
303 } |
550 } |
304 iLog -> Log( _L("RNotifier connected") ); |
551 TRACE_INFO( _L("RNotifier connected") ); |
305 |
552 |
306 TPckgBuf<TInt> notifierParamsPckg; |
553 TPckgBuf<TInt> notifierParamsPckg; |
307 notifierParamsPckg() = usbOTGErrorType; |
554 notifierParamsPckg() = usbOTGErrorType; |
308 iCompleteQuery = EFalse; |
555 iCompleteQuery = EFalse; |
309 |
556 |
310 iNotifier -> StartNotifierAndGetResponse( iReqStatus, |
557 iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifOtgError, notifierParamsPckg, iRes ); |
311 KUsbUiNotifOtgError, notifierParamsPckg, iRes ); |
558 |
312 |
559 aTestResult = ETestCasePassed; |
313 return KErrNone; |
560 |
314 } |
561 TRACE_INFO( _L("<<<UsbOTGErrorNotifierTests") ); |
315 |
562 } |
316 // ----------------------------------------------------------------------------- |
563 |
317 // CBtNotifApiTest::UsbOTGErrorNotifierTests |
564 // ----------------------------------------------------------------------------- |
318 // ----------------------------------------------------------------------------- |
565 // CUsbUiNotifApiTest::UsbOTGWarningNotifierTests |
319 |
566 // ----------------------------------------------------------------------------- |
320 TInt CUSBUiNotifApiTest::UsbOTGWarningNotifierTests( CStifItemParser& aItem ) |
567 |
|
568 void CUsbUiNotifApiTest::UsbOTGWarningNotifierTests( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ) |
321 { |
569 { |
|
570 TRACE_INFO( _L(">>>UsbOTGWarningNotifierTests") ); |
|
571 |
322 TInt res; |
572 TInt res; |
323 TPtrC usbQueryName( KNullDesC ); |
|
324 TUsbUiNotifOtgWarning usbOTGWarningType; |
573 TUsbUiNotifOtgWarning usbOTGWarningType; |
325 |
574 |
326 res = aItem.GetString( _L( "UsbOTGWarningNotifierTests" ), usbQueryName ); |
575 |
327 if ( res != KErrNone ) |
576 res = GetOTGWarningType( aTestSubOption, usbOTGWarningType ); |
328 { |
577 if ( res != KErrNone ) |
329 iLog -> Log( _L("GetString failed with value: %d"), res ); |
578 { |
330 iNotifier -> Close(); |
579 TRACE_INFO( (_L("usbOTGErrorType failed with value: %d"), res) ); |
331 return res; |
580 return; |
332 } |
|
333 |
|
334 res = GetOTGWarningType( usbQueryName, usbOTGWarningType ); |
|
335 if ( res != KErrNone ) |
|
336 { |
|
337 iLog -> Log( _L("usbOTGErrorType failed with value: %d"), res ); |
|
338 return res; |
|
339 } |
581 } |
340 |
582 |
341 if (!iNotifierConnected) |
583 res = iNotifier -> Connect(); |
342 { |
584 if ( res != KErrNone ) |
343 res = iNotifier -> Connect(); |
585 { |
344 iNotifierConnected = ETrue; |
586 TRACE_INFO( (_L("Failed to connect RNotifier with value: %d"), res) ); |
345 } |
587 return; |
346 if ( res != KErrNone ) |
|
347 { |
|
348 iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); |
|
349 return res; |
|
350 } |
588 } |
351 iLog -> Log( _L("RNotifier connected") ); |
589 TRACE_INFO( _L("RNotifier connected") ); |
352 |
590 |
353 TPckgBuf<TInt> notifierParamsPckg; |
591 TPckgBuf<TInt> notifierParamsPckg; |
354 notifierParamsPckg() = usbOTGWarningType; |
592 notifierParamsPckg() = usbOTGWarningType; |
355 iCompleteQuery = EFalse; |
593 iCompleteQuery = EFalse; |
356 |
594 |
357 iNotifier -> StartNotifierAndGetResponse( iReqStatus, |
595 iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifOtgWarning, notifierParamsPckg, iRes ); |
358 KUsbUiNotifOtgWarning, notifierParamsPckg, iRes ); |
596 |
359 |
597 aTestResult = ETestCasePassed; |
360 return KErrNone; |
598 |
361 } |
599 TRACE_INFO( _L("<<<UsbOTGWarningNotifierTests") ); |
362 |
600 } |
363 // ----------------------------------------------------------------------------- |
601 |
364 // CBtNotifApiTest::UsbMSMMNotifierTests |
602 // ----------------------------------------------------------------------------- |
365 // ----------------------------------------------------------------------------- |
603 // CUsbUiNotifApiTest::UsbMSMMNotifierTests |
366 |
604 // ----------------------------------------------------------------------------- |
367 TInt CUSBUiNotifApiTest::UsbMSMMNotifierTests( CStifItemParser& aItem ) |
605 |
|
606 void CUsbUiNotifApiTest::UsbMSMMNotifierTests( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ) |
368 { |
607 { |
|
608 TRACE_INFO( _L(">>>UsbMSMMNotifierTests") ); |
|
609 |
369 TInt res; |
610 TInt res; |
370 TPtrC usbQueryName( KNullDesC ); |
|
371 THostMsErrCode usbMSMMNErrorType; |
611 THostMsErrCode usbMSMMNErrorType; |
372 |
612 |
373 iLog -> Log( _L("------msmm------") ); |
613 res = GetMSMMrrorType( aTestSubOption, usbMSMMNErrorType ); |
374 |
614 if ( res != KErrNone ) |
375 res = aItem.GetString( _L( "UsbMSMMNotifierTests" ), usbQueryName ); |
615 { |
376 if ( res != KErrNone ) |
616 TRACE_INFO( (_L("MSMMrrorType failed with value: %d"), res) ); |
377 { |
617 return; |
378 iLog -> Log( _L("GetString failed with value: %d"), res ); |
|
379 iNotifier -> Close(); |
|
380 return res; |
|
381 } |
|
382 |
|
383 res = GetMSMMrrorType( usbQueryName, usbMSMMNErrorType ); |
|
384 if ( res != KErrNone ) |
|
385 { |
|
386 iLog -> Log( _L("MSMMrrorType failed with value: %d"), res ); |
|
387 return res; |
|
388 } |
618 } |
389 iErrData.iError=usbMSMMNErrorType; |
619 iErrData.iError=usbMSMMNErrorType; |
390 iErrPckg = iErrData; |
620 iErrPckg = iErrData; |
391 if (!iNotifierConnected) |
621 res = iNotifier -> Connect(); |
392 { |
622 if ( res != KErrNone ) |
393 res = iNotifier -> Connect(); |
623 { |
394 iNotifierConnected = ETrue; |
624 TRACE_INFO( (_L("Failed to connect RNotifier with value: %d"), res) ); |
395 } |
625 return; |
396 if ( res != KErrNone ) |
|
397 { |
|
398 iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); |
|
399 return res; |
|
400 } |
626 } |
401 iLog -> Log( _L("RNotifier connected") ); |
627 TRACE_INFO( _L("RNotifier connected") ); |
402 |
628 |
403 TPckgBuf<TInt> notifierParamsPckg; |
629 TPckgBuf<TInt> notifierParamsPckg; |
404 notifierParamsPckg() = usbMSMMNErrorType; |
630 notifierParamsPckg() = usbMSMMNErrorType; |
405 iCompleteQuery = EFalse; |
631 iCompleteQuery = EFalse; |
406 |
632 |
407 iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifMsmmError, iErrPckg, iRes ); |
633 iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifMsmmError, iErrPckg, iRes ); |
408 |
634 |
409 return KErrNone; |
635 aTestResult = ETestCasePassed; |
410 } |
636 |
411 |
637 TRACE_INFO( _L("<<<UsbMSMMNotifierTests") ); |
412 |
638 } |
413 TInt CUSBUiNotifApiTest::CancelMsmmNotifier( CStifItemParser& /*aItem*/ ) |
639 |
414 { |
640 |
415 return ( iNotifier->CancelNotifier(KUsbUiNotifMsmmError) ); |
641 // ----------------------------------------------------------------------------- |
416 } |
642 // CUsbUiNotifApiTest::FinishQuery |
417 |
643 // ----------------------------------------------------------------------------- |
418 |
644 |
419 TInt CUSBUiNotifApiTest::CancelQueryNotifier( CStifItemParser& /*aItem*/ ) |
645 TInt CUsbUiNotifApiTest::FinishQuery( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ) |
420 { |
646 { |
421 iLog -> Log( _L("CancelQueryNotifier") ); |
647 TRACE_INFO( _L(">>>FinishQuery") ); |
422 return ( iNotifier->CancelNotifier(KQueriesNotifier) ); |
648 |
423 } |
649 TInt res; |
424 |
650 TTestOption option; |
425 |
651 |
426 TInt CUSBUiNotifApiTest::CancelOtgErrorNotifier( CStifItemParser& /*aItem*/ ) |
652 if ( iCompleteQuery ) |
427 { |
653 { |
428 return ( iNotifier->CancelNotifier(KUsbUiNotifOtgError) ); |
654 TRequestStatus* statPtr = &iReqStatus; |
429 } |
655 User::RequestComplete( statPtr, KErrNone ); |
430 |
656 } |
431 TInt CUSBUiNotifApiTest::CancelOtgWarningNotifier( CStifItemParser& /*aItem*/ ) |
657 |
432 { |
658 res = GetTestOption( aTestSubOption, option ); |
433 return ( iNotifier->CancelNotifier(KUsbUiNotifOtgWarning) ); |
659 if ( res != KErrNone ) |
434 } |
660 { |
435 |
661 TRACE_INFO( (_L("GetTestOption failed with value: %d"), res) ); |
436 TInt CUSBUiNotifApiTest::CancelCableConnectedNotifier( CStifItemParser& /*aItem*/ ) |
|
437 { |
|
438 return ( iNotifier->CancelNotifier(KCableConnectedNotifierUid) ); |
|
439 } |
|
440 |
|
441 TInt CUSBUiNotifApiTest::WaitForRequest( CStifItemParser& /*aItem*/ ) |
|
442 { |
|
443 User::WaitForRequest( iReqStatus ); |
|
444 return KErrNone; |
|
445 } |
|
446 |
|
447 TInt CUSBUiNotifApiTest::SynchStart(CStifItemParser& aItem ) |
|
448 { |
|
449 TInt res; |
|
450 TPtrC usbQueryName( KNullDesC ); |
|
451 TUsbUiNotifOtgWarning usbOTGWarningType; |
|
452 |
|
453 res = aItem.GetString( _L( "SynchStart" ), usbQueryName ); |
|
454 if ( res != KErrNone ) |
|
455 { |
|
456 iLog -> Log( _L("GetString failed with value: %d"), res ); |
|
457 iNotifier -> Close(); |
662 iNotifier -> Close(); |
458 return res; |
663 return res; |
459 } |
664 } |
460 |
665 |
461 res = GetOTGWarningType( usbQueryName, usbOTGWarningType ); |
666 User::WaitForRequest( iReqStatus ); |
462 if ( res != KErrNone ) |
|
463 { |
|
464 iLog -> Log( _L("usbOTGErrorType failed with value: %d"), res ); |
|
465 return res; |
|
466 } |
|
467 |
|
468 |
|
469 res = iNotifier -> Connect(); |
|
470 if ( res != KErrNone ) |
|
471 { |
|
472 iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); |
|
473 return res; |
|
474 } |
|
475 iLog -> Log( _L("RNotifier connected") ); |
|
476 |
|
477 TPckgBuf<TInt> notifierParamsPckg; |
|
478 notifierParamsPckg() = usbOTGWarningType; |
|
479 iCompleteQuery = EFalse; |
|
480 |
|
481 TInt retVal = iNotifier -> StartNotifier( KUsbUiNotifOtgWarning, notifierParamsPckg ); |
|
482 iLog -> Log( _L("StartNotifier returned with value: %d"), retVal ); |
|
483 |
|
484 iNotifier->Close(); |
|
485 return retVal; |
|
486 } |
|
487 |
|
488 TInt CUSBUiNotifApiTest::Update(CStifItemParser& /*aItem*/ ) |
|
489 { |
|
490 //delay in microseconds before updating the notifier |
|
491 const TInt KUpdateDelay = 2000000; |
|
492 TInt res; |
|
493 TPtrC usbQueryName( KNullDesC ); |
|
494 |
|
495 res = iNotifier -> Connect(); |
|
496 if ( res != KErrNone ) |
|
497 { |
|
498 iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res ); |
|
499 return res; |
|
500 } |
|
501 iLog -> Log( _L("RNotifier connected") ); |
|
502 |
|
503 TPckgBuf<TInt> notifierParamsPckg; |
|
504 notifierParamsPckg() = EUsbOtgUnsupportedDevice; |
|
505 iCompleteQuery = EFalse; |
|
506 TPckgBuf<TInt> response ; |
|
507 iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifOtgError, |
|
508 notifierParamsPckg, iRes ); |
|
509 |
|
510 User::After(KUpdateDelay); //simulate update after a delay |
|
511 TPckgBuf<TInt> notifierParamsPckgUpdate; |
|
512 notifierParamsPckgUpdate() = EUsbOtgErrorNoMemory; |
|
513 TInt retVal = iNotifier -> UpdateNotifier( KUsbUiNotifOtgError, |
|
514 notifierParamsPckgUpdate, response); |
|
515 |
|
516 iNotifier->Close(); |
|
517 return retVal; |
|
518 } |
|
519 |
|
520 |
|
521 TInt CUSBUiNotifApiTest::FinishQuery( CStifItemParser& aItem ) |
|
522 { |
|
523 iLog -> Log( _L("FinishQuery") ); |
|
524 TInt res; |
|
525 TPtrC optionName( KNullDesC ); |
|
526 TTestOption option; |
|
527 |
|
528 if ( iCompleteQuery ) |
|
529 { |
|
530 iLog -> Log( _L("FinishQuery completing request") ); |
|
531 TRequestStatus* statPtr = &iReqStatus; |
|
532 User::RequestComplete( statPtr, KErrNone ); |
|
533 } |
|
534 |
|
535 iLog -> Log( _L("FinishQuery getting options") ); |
|
536 res = aItem.GetString( _L( "FinishQuery" ), optionName ); |
|
537 if ( res != KErrNone ) |
|
538 { |
|
539 iLog -> Log( _L("GetString failed with value: %d"), res ); |
|
540 iNotifier -> Close(); |
|
541 return res; |
|
542 } |
|
543 |
|
544 res = GetTestOption( optionName, option ); |
|
545 if ( res != KErrNone ) |
|
546 { |
|
547 iLog -> Log( _L("GetTestOption failed with value: %d"), res ); |
|
548 iNotifier -> Close(); |
|
549 return res; |
|
550 } |
|
551 |
|
552 iLog -> Log( _L("FinishQuery waiting for request") ); |
|
553 User::WaitForRequest( iReqStatus ); |
|
554 iLog -> Log( _L("FinishQuery closing notifier") ); |
|
555 iNotifier -> Close(); |
667 iNotifier -> Close(); |
556 iNotifierConnected = EFalse; |
|
557 |
668 |
558 switch( option ) |
669 switch( option ) |
559 { |
670 { |
560 case EQueryAccepted: |
671 case EQueryAccepted: |
561 iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone ); |
672 TRACE_INFO( (_L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone) ); |
562 STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() ); |
673 STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() ); |
563 break; |
674 break; |
564 case EQueryCanceled: |
675 case EQueryCanceled: |
565 iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel ); |
676 TRACE_INFO( (_L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel) ); |
566 STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() ); |
677 STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() ); |
567 break; |
678 break; |
568 default: |
679 default: |
569 return KErrNotFound; |
680 return KErrNotFound; |
570 } |
681 } |
571 |
682 |
572 iLog -> Log( _L("Test case passed!") ); |
683 aTestResult = ETestCasePassed; |
|
684 |
|
685 TRACE_INFO( _L("<<<FinishQuery") ); |
|
686 |
573 return KErrNone; |
687 return KErrNone; |
574 } |
688 } |
575 |
689 |
576 TInt CUSBUiNotifApiTest::LoadNotifiersL( CStifItemParser& /*aItem*/ ) |
690 // ----------------------------------------------------------------------------- |
577 { |
691 // CUsbUiNotifApiTest::LoadNotifiersL |
|
692 // ----------------------------------------------------------------------------- |
|
693 |
|
694 void CUsbUiNotifApiTest::LoadNotifiersL( TUsbUiNotifApiTestResult& aTestResult ) |
|
695 { |
|
696 TRACE_INFO( _L(">>>LoadNotifiersL") ); |
|
697 |
578 iNotifierArray = reinterpret_cast<CArrayPtr<MEikSrvNotifierBase2>*>( |
698 iNotifierArray = reinterpret_cast<CArrayPtr<MEikSrvNotifierBase2>*>( |
579 REComSession::CreateImplementationL(TUid::Uid(0x10281F23), iInstanceUid)); |
699 REComSession::CreateImplementationL(TUid::Uid(0x10281F23), iInstanceUid)); |
580 return KErrNone; |
700 |
581 } |
701 aTestResult = ETestCasePassed; |
582 |
702 |
583 TInt CUSBUiNotifApiTest::UnLoadNotifiers ( CStifItemParser& /*aItem*/ ) |
703 TRACE_INFO( _L("<<<LoadNotifiersL") ); |
584 { |
704 } |
|
705 |
|
706 // ----------------------------------------------------------------------------- |
|
707 // CUsbUiNotifApiTest::UnLoadNotifiers |
|
708 // ----------------------------------------------------------------------------- |
|
709 |
|
710 void CUsbUiNotifApiTest::UnLoadNotifiers ( TUsbUiNotifApiTestResult& aTestResult ) |
|
711 { |
|
712 TRACE_INFO( _L(">>>UnLoadNotifiers") ); |
|
713 |
585 TInt count = iNotifierArray->Count(); |
714 TInt count = iNotifierArray->Count(); |
586 TInt i=0; |
715 TInt i=0; |
587 for (i=0; i<count; i++) |
716 for (i=0; i<count; i++) |
588 { |
717 { |
589 iNotifierArray->At(i)->Release(); |
718 iNotifierArray->At(i)->Release(); |
590 } |
719 } |
591 iNotifierArray->Reset(); |
720 iNotifierArray->Reset(); |
592 delete iNotifierArray; |
721 delete iNotifierArray; |
593 iNotifierArray = NULL; |
|
594 REComSession::DestroyedImplementation(iInstanceUid); |
722 REComSession::DestroyedImplementation(iInstanceUid); |
|
723 |
|
724 aTestResult = ETestCasePassed; |
|
725 |
|
726 TRACE_INFO( _L("<<<UnLoadNotifiers") ); |
|
727 } |
|
728 |
|
729 // ----------------------------------------------------------------------------- |
|
730 // CUsbUiNotifApiTest::Update |
|
731 // ----------------------------------------------------------------------------- |
|
732 |
|
733 void CUsbUiNotifApiTest::Update( TUsbUiNotifApiTestResult& aTestResult ) |
|
734 { |
|
735 TRACE_INFO( _L(">>>Update") ); |
|
736 TInt count = iNotifierArray->Count(); |
|
737 TInt i=0; |
|
738 _LIT8(test, "test"); |
|
739 TBuf8<32> buf(test); |
|
740 for (i=0; i<count; i++) |
|
741 { |
|
742 iNotifierArray->At(i)->UpdateL(buf); |
|
743 } |
|
744 |
|
745 aTestResult = ETestCasePassed; |
|
746 |
|
747 TRACE_INFO( _L("<<<Update") ); |
|
748 } |
|
749 |
|
750 // ----------------------------------------------------------------------------- |
|
751 // CUsbUiNotifApiTest::Notifierstart |
|
752 // ----------------------------------------------------------------------------- |
|
753 |
|
754 void CUsbUiNotifApiTest::Notifierstart( TUsbUiNotifApiTestResult& aTestResult ) |
|
755 { |
|
756 TRACE_INFO( _L(">>>Notifierstart") ); |
|
757 TInt count = iNotifierArray->Count(); |
|
758 TInt i=0; |
|
759 _LIT8(test, "test"); |
|
760 TBuf8<32> buf(test); |
|
761 for (i=0; i<count; i++) |
|
762 { |
|
763 iNotifierArray->At(i)->StartL(buf); |
|
764 } |
|
765 |
|
766 aTestResult = ETestCasePassed; |
|
767 |
|
768 TRACE_INFO( _L("<<<Notifierstart") ); |
|
769 } |
|
770 |
|
771 |
|
772 // ----------------------------------------------------------------------------- |
|
773 // CUsbUiNotifApiTest::GetQueryType |
|
774 // ----------------------------------------------------------------------------- |
|
775 |
|
776 TInt CUsbUiNotifApiTest::GetQueryType( TPtrC aTypeString, TUSBUIQueries& aQueryType ) |
|
777 { |
|
778 TRACE_INFO( _L(">>>GetQueryType") ); |
|
779 if ( !aTypeString.Compare( _L( "EUSBNoMemoryCard" ) ) ) |
|
780 { |
|
781 aQueryType = EUSBNoMemoryCard; |
|
782 TRACE_INFO( _L("Query type: EUSBNoMemoryCard") ); |
|
783 } |
|
784 else if ( !aTypeString.Compare( _L( "EUSBStorageMediaFailure" ) ) ) |
|
785 { |
|
786 aQueryType = EUSBStorageMediaFailure; |
|
787 TRACE_INFO( _L("Query type: EUSBStorageMediaFailure") ); |
|
788 } |
|
789 else if ( !aTypeString.Compare( _L( "EUSBChangeFromMassStorage" ) ) ) |
|
790 { |
|
791 aQueryType = EUSBChangeFromMassStorage; |
|
792 TRACE_INFO( _L("Query type: EUSBChangeFromMassStorage") ); |
|
793 } |
|
794 else |
|
795 { |
|
796 TRACE_INFO( _L("Query type: not supported") ); |
|
797 return KErrNotFound; |
|
798 } |
|
799 TRACE_INFO( _L("<<<GetQueryType") ); |
595 return KErrNone; |
800 return KErrNone; |
596 } |
801 } |
597 |
802 |
598 TInt CUSBUiNotifApiTest::GetQueryType( TPtrC aTypeString, TUSBUIQueries& aQueryType ) |
803 // ----------------------------------------------------------------------------- |
599 { |
804 // CUsbUiNotifApiTest::GetOTGErrorType |
600 if ( !aTypeString.Compare( _L( "EUSBNoMemoryCard" ) ) ) |
805 // ----------------------------------------------------------------------------- |
601 { |
806 |
602 aQueryType = EUSBNoMemoryCard; |
807 TInt CUsbUiNotifApiTest::GetOTGErrorType( TPtrC aTypeString, TUsbUiNotifOtgError& aQueryType ) |
603 iLog -> Log( _L("Query type: EUSBNoMemoryCard") ); |
808 { |
604 } |
809 TRACE_INFO( _L(">>>GetOTGErrorType") ); |
605 else if ( !aTypeString.Compare( _L( "EUSBStorageMediaFailure" ) ) ) |
810 |
606 { |
|
607 aQueryType = EUSBStorageMediaFailure; |
|
608 iLog -> Log( _L("Query type: EUSBStorageMediaFailure") ); |
|
609 } |
|
610 else if ( !aTypeString.Compare( _L( "EUSBDiskFull" ) ) ) |
|
611 { |
|
612 aQueryType = EUSBDiskFull; |
|
613 iLog -> Log( _L("Query type: EUSBDiskFull") ); |
|
614 } |
|
615 else if ( !aTypeString.Compare( _L( "EUSBNotEnoughRam" ) ) ) |
|
616 { |
|
617 aQueryType = EUSBNotEnoughRam; |
|
618 iLog -> Log( _L("Query type: EUSBNotEnoughRam") ); |
|
619 } |
|
620 else |
|
621 { |
|
622 iLog -> Log( _L("Query type: not supported") ); |
|
623 return KErrNotFound; |
|
624 } |
|
625 |
|
626 return KErrNone; |
|
627 } |
|
628 |
|
629 TInt CUSBUiNotifApiTest::GetOTGErrorType( TPtrC aTypeString, TUsbUiNotifOtgError& aQueryType ) |
|
630 { |
|
631 if ( !aTypeString.Compare( _L( "EUsbOtgTooMuchPower" ) ) ) |
811 if ( !aTypeString.Compare( _L( "EUsbOtgTooMuchPower" ) ) ) |
632 { |
812 { |
633 aQueryType = EUsbOtgTooMuchPower; |
813 aQueryType = EUsbOtgTooMuchPower; |
634 iLog -> Log( _L("Query type: EUsbOtgTooMuchPower") ); |
814 TRACE_INFO( _L("Query type: EUsbOtgTooMuchPower") ); |
635 } |
815 } |
636 else if ( !aTypeString.Compare( _L( "EUsbOtgTooMuchPowerRequired" ) ) ) |
816 else if ( !aTypeString.Compare( _L( "EUsbOtgTooMuchPowerRequired" ) ) ) |
637 { |
817 { |
638 aQueryType = EUsbOtgTooMuchPowerRequired; |
818 aQueryType = EUsbOtgTooMuchPowerRequired; |
639 iLog -> Log( _L("Query type: EUsbOtgTooMuchPowerRequired") ); |
819 TRACE_INFO( _L("Query type: EUsbOtgTooMuchPowerRequired") ); |
640 } |
820 } |
641 else if ( !aTypeString.Compare( _L( "EUsbOtgUnsupportedDevice" ) ) ) |
821 else if ( !aTypeString.Compare( _L( "EUsbOtgUnsupportedDevice" ) ) ) |
642 { |
822 { |
643 aQueryType = EUsbOtgUnsupportedDevice; |
823 aQueryType = EUsbOtgUnsupportedDevice; |
644 iLog -> Log( _L("Query type: EUsbOtgUnsupportedDevice") ); |
824 TRACE_INFO( _L("Query type: EUsbOtgUnsupportedDevice") ); |
645 } |
825 } |
646 else if ( !aTypeString.Compare( _L( "EUsbOtgHubUnsupported" ) ) ) |
826 else if ( !aTypeString.Compare( _L( "EUsbOtgHubUnsupported" ) ) ) |
647 { |
827 { |
648 aQueryType = EUsbOtgHubUnsupported; |
828 aQueryType = EUsbOtgHubUnsupported; |
649 iLog -> Log( _L("Query type: EUsbOtgHubUnsupported") ); |
829 TRACE_INFO( _L("Query type: EUsbOtgHubUnsupported") ); |
650 } |
830 } |
651 else if ( !aTypeString.Compare( _L( "EUsbOtgErrorInConnection" ) ) ) |
831 else if ( !aTypeString.Compare( _L( "EUsbOtgErrorInConnection" ) ) ) |
652 { |
832 { |
653 aQueryType = EUsbOtgErrorInConnection; |
833 aQueryType = EUsbOtgErrorInConnection; |
654 iLog -> Log( _L("Query type: EUsbOtgErrorInConnection") ); |
834 TRACE_INFO( _L("Query type: EUsbOtgErrorInConnection") ); |
655 } |
835 } |
656 else if ( !aTypeString.Compare( _L( "EUsbOtgErrorAttachTimedOut" ) ) ) |
836 else if ( !aTypeString.Compare( _L( "EUsbOtgErrorAttachTimedOut" ) ) ) |
657 { |
837 { |
658 aQueryType = EUsbOtgErrorAttachTimedOut; |
838 aQueryType = EUsbOtgErrorAttachTimedOut; |
659 iLog -> Log( _L("Query type: EUsbOtgErrorAttachTimedOut") ); |
839 TRACE_INFO( _L("Query type: EUsbOtgErrorAttachTimedOut") ); |
660 } |
840 } |
661 else if ( !aTypeString.Compare( _L( "EUsbOtgErrorNoMemory" ) ) ) |
841 else |
662 { |
842 { |
663 aQueryType = EUsbOtgErrorNoMemory; |
843 TRACE_INFO( _L("Query type: not supported") ); |
664 iLog -> Log( _L("Query type: EUsbOtgErrorNoMemory") ); |
|
665 } |
|
666 else |
|
667 { |
|
668 iLog -> Log( _L("Query type: not supported") ); |
|
669 return KErrNotFound; |
844 return KErrNotFound; |
670 } |
845 } |
|
846 |
|
847 TRACE_INFO( _L("<<<GetOTGErrorType") ); |
671 return KErrNone; |
848 return KErrNone; |
672 } |
849 } |
673 |
850 |
674 |
851 |
675 TInt CUSBUiNotifApiTest::GetOTGWarningType( TPtrC aTypeString, TUsbUiNotifOtgWarning& aQueryType ) |
852 // ----------------------------------------------------------------------------- |
|
853 // CUsbUiNotifApiTest::GetOTGWarningType |
|
854 // ----------------------------------------------------------------------------- |
|
855 |
|
856 TInt CUsbUiNotifApiTest::GetOTGWarningType( TPtrC aTypeString, TUsbUiNotifOtgWarning& aQueryType ) |
676 { |
857 { |
|
858 TRACE_INFO( _L(">>>GetOTGWarningType") ); |
|
859 |
677 if ( !aTypeString.Compare( _L( "EUsbOtgPartiallySupportedDevice" ) ) ) |
860 if ( !aTypeString.Compare( _L( "EUsbOtgPartiallySupportedDevice" ) ) ) |
678 { |
861 { |
679 aQueryType = EUsbOtgPartiallySupportedDevice; |
862 aQueryType = EUsbOtgPartiallySupportedDevice; |
680 iLog -> Log( _L("Query type: EUsbOtgPartiallySupportedDevice;") ); |
863 TRACE_INFO( _L("Query type: EUsbOtgPartiallySupportedDevice;") ); |
681 } |
864 } |
682 else |
865 else |
683 { |
866 { |
684 iLog -> Log( _L("Query type: not supported") ); |
867 TRACE_INFO( _L("Query type: not supported") ); |
685 return KErrNotFound; |
868 return KErrNotFound; |
686 } |
869 } |
687 |
870 |
|
871 TRACE_INFO( _L("<<<GetOTGWarningType") ); |
|
872 |
688 return KErrNone; |
873 return KErrNone; |
689 } |
874 } |
690 |
875 |
691 TInt CUSBUiNotifApiTest::GetMSMMrrorType( TPtrC aTypeString, THostMsErrCode& aQueryType ) |
876 // ----------------------------------------------------------------------------- |
|
877 // CUsbUiNotifApiTest::GetMSMMrrorType |
|
878 // ----------------------------------------------------------------------------- |
|
879 |
|
880 TInt CUsbUiNotifApiTest::GetMSMMrrorType( TPtrC aTypeString, THostMsErrCode& aQueryType ) |
692 { |
881 { |
|
882 TRACE_INFO( _L(">>>GetMSMMrrorType") ); |
693 if ( !aTypeString.Compare( _L( "EUsbMSMMGeneralError" ) ) ) |
883 if ( !aTypeString.Compare( _L( "EUsbMSMMGeneralError" ) ) ) |
694 { |
884 { |
695 aQueryType = EHostMsErrGeneral; |
885 aQueryType = EHostMsErrGeneral; |
696 iLog -> Log( _L("Query type: EUsbOtgPartiallySupportedDevice;") ); |
886 TRACE_INFO( _L("Query type: EUsbOtgPartiallySupportedDevice;") ); |
697 } |
887 } |
698 else if ( !aTypeString.Compare( _L( "EUsbMSMMUnknownFileSystem" ) ) ) |
888 else if ( !aTypeString.Compare( _L( "EUsbMSMMUnknownFileSystem" ) ) ) |
699 { |
889 { |
700 aQueryType = EHostMsErrUnknownFileSystem; |
890 aQueryType = EHostMsErrUnknownFileSystem; |
701 iLog -> Log( _L("Query type: EUsbMSMMUnknownFileSystem") ); |
891 TRACE_INFO( _L("Query type: EUsbMSMMUnknownFileSystem") ); |
702 } |
892 } |
703 else if ( !aTypeString.Compare( _L( "EUsbMSMMOutOfMemory" ) ) ) |
893 else if ( !aTypeString.Compare( _L( "EUsbMSMMOutOfMemory" ) ) ) |
704 { |
894 { |
705 aQueryType = EHostMsErrOutOfMemory; |
895 aQueryType = EHostMsErrOutOfMemory; |
706 iLog -> Log( _L("Query type: EUsbMSMMOutOfMemory") ); |
896 TRACE_INFO( _L("Query type: EUsbMSMMOutOfMemory") ); |
707 } |
897 } |
708 else if ( !aTypeString.Compare( _L( "EUsbMSMMSafeToRemove" ) ) ) |
898 else |
709 { |
899 { |
710 aQueryType = EHostMsErrNone; |
900 TRACE_INFO( _L("Query type: not supported") ); |
711 iLog -> Log( _L("Query type: EUsbMSMMSafeToRemove") ); |
901 return KErrNotFound; |
712 } |
902 } |
713 else if ( !aTypeString.Compare( _L( "EUsbMSMMUnableToEject" ) ) ) |
903 |
714 { |
904 TRACE_INFO( _L("<<<GetMSMMrrorType") ); |
715 aQueryType = EHostMsErrInUse; |
905 return KErrNone; |
716 iLog -> Log( _L("Query type: EUsbMSMMUnableToEject") ); |
906 } |
717 } |
907 |
718 else |
908 // ----------------------------------------------------------------------------- |
719 { |
909 // CUsbUiNotifApiTest::GetTestOption |
720 iLog -> Log( _L("Query type: not supported") ); |
910 // ----------------------------------------------------------------------------- |
|
911 |
|
912 TInt CUsbUiNotifApiTest::GetTestOption( TPtrC aOptionString, TTestOption& aOption ) |
|
913 { |
|
914 if ( !aOptionString.Compare( _L( "DISCARD" ) ) ) |
|
915 { |
|
916 aOption = EQueryDiscarded; |
|
917 TRACE_INFO( _L("Test type: EQueryDiscarded") ); |
|
918 } |
|
919 else if ( !aOptionString.Compare( _L( "ACCEPT" ) ) ) |
|
920 { |
|
921 aOption = EQueryAccepted; |
|
922 TRACE_INFO( _L("Test type: EQueryAccepted") ); |
|
923 } |
|
924 else if ( !aOptionString.Compare( _L( "CANCEL" ) ) ) |
|
925 { |
|
926 aOption = EQueryCanceled; |
|
927 TRACE_INFO( _L("Test type: EQueryCanceled") ); |
|
928 } |
|
929 else |
|
930 { |
|
931 TRACE_INFO( _L("Test type: not supported") ); |
721 return KErrNotFound; |
932 return KErrNotFound; |
722 } |
933 } |
723 |
934 |
724 return KErrNone; |
935 return KErrNone; |
725 } |
936 } |
726 |
937 |
727 // ----------------------------------------------------------------------------- |
938 // ----------------------------------------------------------------------------- |
728 // CBtNotifApiTest::GetTestOption |
939 // CUsbUiNotifApiTest::GetPersonalityIdFromString |
729 // ----------------------------------------------------------------------------- |
940 // ----------------------------------------------------------------------------- |
730 |
941 |
731 TInt CUSBUiNotifApiTest::GetTestOption( TPtrC aOptionString, TTestOption& aOption ) |
942 TInt CUsbUiNotifApiTest::GetPersonalityIdFromString( TPtrC aOptionString, TInt& aPersonalityId ) |
732 { |
943 { |
733 if ( !aOptionString.Compare( _L( "DISCARD" ) ) ) |
944 if ( !aOptionString.Compare( _L( "MS" ) ) ) |
734 { |
945 { |
735 aOption = EQueryDiscarded; |
946 aPersonalityId = KUsbPersonalityIdMS; |
736 iLog -> Log( _L("Test type: EQueryDiscarded") ); |
947 TRACE_INFO( _L("Usb personality type: KUsbPersonalityIdMS") ); |
737 } |
948 } |
738 else if ( !aOptionString.Compare( _L( "ACCEPT" ) ) ) |
949 else if ( !aOptionString.Compare( _L( "PCSUITE" ) ) ) |
739 { |
950 { |
740 aOption = EQueryAccepted; |
951 aPersonalityId = KUsbPersonalityIdPCSuite; |
741 iLog -> Log( _L("Test type: EQueryAccepted") ); |
952 TRACE_INFO( _L("Usb personality type: KUsbPersonalityIdPCSuite") ); |
742 } |
953 } |
743 else if ( !aOptionString.Compare( _L( "CANCEL" ) ) ) |
954 else if ( !aOptionString.Compare( _L( "MTP" ) ) ) |
744 { |
955 { |
745 aOption = EQueryCanceled; |
956 aPersonalityId = KUsbPersonalityIdMTP; |
746 iLog -> Log( _L("Test type: EQueryCanceled") ); |
957 TRACE_INFO( _L("Usb personality type: KUsbPersonalityIdMTP") ); |
747 } |
958 } |
748 else |
959 else if ( !aOptionString.Compare( _L( "PCSUITEMTP" ) ) ) |
749 { |
960 { |
750 iLog -> Log( _L("Test type: not supported") ); |
961 aPersonalityId = KUsbPersonalityIdPCSuiteMTP; |
751 return KErrNotFound; |
962 TRACE_INFO( _L("Usb personality type: KUsbPersonalityIdPCSuiteMTP") ); |
|
963 } |
|
964 else |
|
965 { |
|
966 TRACE_INFO( _L("Usb personality type: not found") ); |
|
967 return KErrNotFound; |
752 } |
968 } |
753 |
969 |
754 return KErrNone; |
970 return KErrNone; |
755 } |
971 } |
756 |
972 |
757 // ----------------------------------------------------------------------------- |
|
758 // CBtNotifApiTest::GetPersonalityIdFromString |
|
759 // ----------------------------------------------------------------------------- |
|
760 |
|
761 TInt CUSBUiNotifApiTest::GetPersonalityIdFromString( TPtrC aOptionString, TInt& aPersonalityId ) |
|
762 { |
|
763 if ( !aOptionString.Compare( _L( "MS" ) ) ) |
|
764 { |
|
765 aPersonalityId = KUsbPersonalityIdMS; |
|
766 iLog -> Log( _L("Usb personality type: KUsbPersonalityIdMS") ); |
|
767 } |
|
768 else if ( !aOptionString.Compare( _L( "PTP" ) ) ) |
|
769 { |
|
770 aPersonalityId = KUsbPersonalityIdPTP; |
|
771 iLog -> Log( _L("Usb personality type: KUsbPersonalityIdPTP") ); |
|
772 } |
|
773 else if ( !aOptionString.Compare( _L( "MTP" ) ) ) |
|
774 { |
|
775 aPersonalityId = KUsbPersonalityIdMTP; |
|
776 iLog -> Log( _L("Usb personality type: KUsbPersonalityIdMTP") ); |
|
777 } |
|
778 else if ( !aOptionString.Compare( _L( "PCSUITEMTP" ) ) ) |
|
779 { |
|
780 aPersonalityId = KUsbPersonalityIdPCSuiteMTP; |
|
781 iLog -> Log( _L("Usb personality type: KUsbPersonalityIdPCSuiteMTP") ); |
|
782 } |
|
783 else |
|
784 { |
|
785 iLog -> Log( _L("Usb personality type: not found") ); |
|
786 return KErrNotFound; |
|
787 } |
|
788 |
|
789 return KErrNone; |
|
790 } |
|
791 |
|
792 |
|
793 TInt CUSBUiNotifApiTest::FindAndKillProcess(const TDesC& aProcessName) |
|
794 { |
|
795 iLog -> Log( _L("FindAndKillProcess") ); |
|
796 TInt ret = KErrNotFound; |
|
797 RProcess process; |
|
798 TFindProcess findProc; |
|
799 findProc.Find(aProcessName); |
|
800 TFullName procName; |
|
801 ret = findProc.Next(procName); |
|
802 iLog -> Log( _L("FindAndKillProcess findProc returned: %d"), ret ); |
|
803 if (ret == KErrNone) |
|
804 { |
|
805 ret = process.Open(procName, EOwnerThread); |
|
806 iLog -> Log( _L("FindAndKillProcess process open returned: %d"), ret ); |
|
807 if (ret == KErrNone) |
|
808 { |
|
809 process.Terminate(KErrNone); |
|
810 process.Close(); |
|
811 } |
|
812 } |
|
813 return ret; |
|
814 } |
|
815 |
|
816 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
973 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
817 // None |
974 // None |
818 |
975 |
819 // [End of File] - Do not remove |
976 // [End of File] - Do not remove |