1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // [INCLUDE FILES] - do not remove |
|
22 #include <e32svr.h> |
|
23 #include <StifParser.h> |
|
24 #include <ecom/ecom.h> |
|
25 #include <Stiftestinterface.h> |
|
26 #include "UsbUiNotifApiTest.h" |
|
27 |
|
28 // EXTERNAL DATA STRUCTURES |
|
29 //extern ?external_data; |
|
30 |
|
31 // EXTERNAL FUNCTION PROTOTYPES |
|
32 //extern ?external_function( ?arg_type,?arg_type ); |
|
33 |
|
34 // CONSTANTS |
|
35 //const ?type ?constant_var = ?constant; |
|
36 |
|
37 // MACROS |
|
38 //#define ?macro ?macro_def |
|
39 |
|
40 // LOCAL CONSTANTS AND MACROS |
|
41 //const ?type ?constant_var = ?constant; |
|
42 //#define ?macro_name ?macro_def |
|
43 |
|
44 // MODULE DATA STRUCTURES |
|
45 //enum ?declaration |
|
46 //typedef ?declaration |
|
47 |
|
48 // LOCAL FUNCTION PROTOTYPES |
|
49 //?type ?function_name( ?arg_type, ?arg_type ); |
|
50 |
|
51 // FORWARD DECLARATIONS |
|
52 //class ?FORWARD_CLASSNAME; |
|
53 |
|
54 // ============================= LOCAL FUNCTIONS =============================== |
|
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 |
|
77 // ============================ MEMBER FUNCTIONS =============================== |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CUsbUiNotifApiTest::Delete |
|
81 // Delete here all resources allocated and opened from test methods. |
|
82 // Called from destructor. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CUsbUiNotifApiTest::Delete() |
|
86 { |
|
87 iNotifier -> Close(); |
|
88 delete iNotifier; |
|
89 iNotifier = NULL; |
|
90 iUsbWatcher -> Close(); |
|
91 delete iUsbWatcher; |
|
92 iUsbWatcher = NULL; |
|
93 delete iRepository; |
|
94 iRepository = NULL; |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CUsbUiNotifApiTest::RunMethodL |
|
99 // Run specified method. Contains also table of test mothods and their names. |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 TInt CUsbUiNotifApiTest::RunMethodL( |
|
103 CStifItemParser& aItem ) |
|
104 { |
|
105 |
|
106 static TStifFunctionInfo const KFunctions[] = |
|
107 { |
|
108 //ADD NEW ENTRY HERE |
|
109 // [test cases entries] - Do not remove |
|
110 ENTRY( "ExecuteApiTestBlock", CUsbUiNotifApiTest::ExecuteApiTestBlock ), |
|
111 ENTRY( "ExecuteModuleTestBlock", CUsbUiNotifApiTest::ExecuteModuleTestBlock ), |
|
112 ENTRY( "ExecuteBranchTestBlock", CUsbUiNotifApiTest::ExecuteBranchTestBlock ), |
|
113 }; |
|
114 |
|
115 const TInt count = sizeof( KFunctions ) / |
|
116 sizeof( TStifFunctionInfo ); |
|
117 |
|
118 return RunInternalL( KFunctions, count, aItem ); |
|
119 |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CUsbUiNotifApiTest::GetTestBlockParamsL |
|
124 // ----------------------------------------------------------------------------- |
|
125 |
|
126 void CUsbUiNotifApiTest::GetTestBlockParamsL( CStifItemParser& aItem ) |
|
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 |
|
279 TInt res; |
|
280 TUsbUiNotifApiTestResult testResult; |
|
281 |
|
282 TRAP( res, DoExecuteModuleTestBlockL( aItem, testResult ) ); |
|
283 if ( res != KErrNone ) |
|
284 { |
|
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) ); |
|
335 return res; |
|
336 } |
|
337 |
|
338 STIF_ASSERT_EQUALS( ETestCasePassed, testResult ); |
|
339 TRACE_INFO( _L("Test case passed") ); |
|
340 TRACE_INFO( _L("<<<ExecuteBranchTestBlock") ); |
|
341 return KErrNone; |
|
342 } |
|
343 |
|
344 |
|
345 void CUsbUiNotifApiTest::DoExecuteBranchTestBlockL( CStifItemParser& aItem, TUsbUiNotifApiTestResult& aTestResult ) |
|
346 { |
|
347 TRACE_INFO( _L(">>>DoExecuteBranchTestBlockL") ); |
|
348 |
|
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 |
|
419 TInt res; |
|
420 TUSBConnectionNotifierParamsPckg emptyNotifierInputPckg; |
|
421 TPtrC displayedUsbPersonalityName( KNullDesC ); |
|
422 TInt displayedUsbPersonalityId; |
|
423 |
|
424 res = GetPersonalityIdFromString( aTestSubOption, displayedUsbPersonalityId ); |
|
425 if ( res != KErrNone ) |
|
426 { |
|
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") ); |
|
445 |
|
446 iUsbWatcher -> SetPersonality( iReqStatus, displayedUsbPersonalityId, ETrue, ETrue ); |
|
447 User::WaitForRequest( iReqStatus ); |
|
448 if ( iReqStatus.Int() != KErrNone ) |
|
449 { |
|
450 TRACE_INFO( (_L("Failed to set usb personality with value: %d"), iReqStatus.Int()) ); |
|
451 iUsbWatcher -> Close(); |
|
452 return; |
|
453 } |
|
454 |
|
455 res = iNotifier -> Connect(); |
|
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 ); |
|
465 User::WaitForRequest( iReqStatus ); |
|
466 |
|
467 TRACE_INFO((_L("StartNotifierAndGetResponse Status: %d, expected: %d"), iReqStatus.Int(), KErrCancel)); |
|
468 if(iReqStatus.Int() == KErrCancel) |
|
469 aTestResult = ETestCasePassed; |
|
470 |
|
471 TRACE_INFO( _L("<<<CableConnectedNotifierTest") ); |
|
472 } |
|
473 |
|
474 |
|
475 // ----------------------------------------------------------------------------- |
|
476 // CUsbUiNotifApiTest::UsbQueriesNotifierTest |
|
477 // ----------------------------------------------------------------------------- |
|
478 |
|
479 void CUsbUiNotifApiTest::UsbQueriesNotifierTest( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ) |
|
480 { |
|
481 TRACE_INFO( _L(">>>UsbQueriesNotifierTest") ); |
|
482 TInt res; |
|
483 TUSBUIQueries usbQueryType; |
|
484 |
|
485 |
|
486 res = GetQueryType( aTestSubOption, usbQueryType ); |
|
487 if ( res != KErrNone ) |
|
488 { |
|
489 TRACE_INFO( (_L("GetQueryType failed with value: %d"), res) ); |
|
490 return; |
|
491 } |
|
492 |
|
493 TUSBQueriesNotiferParams notifierParams; |
|
494 notifierParams.iDrive = 'c'; |
|
495 notifierParams.iQuery = usbQueryType; |
|
496 TUSBQueriesNotifierParamsPckg notifierParamsPckg( notifierParams ); |
|
497 TPckgBuf<TBool> output; |
|
498 |
|
499 res = iNotifier -> Connect(); |
|
500 if ( res != KErrNone ) |
|
501 { |
|
502 TRACE_INFO( (_L("Failed to connect RNotifier with value: %d"), res) ); |
|
503 return; |
|
504 } |
|
505 TRACE_INFO( _L("RNotifier connected") ); |
|
506 |
|
507 switch( usbQueryType ) |
|
508 { |
|
509 case EUSBNoMemoryCard: |
|
510 iCompleteQuery = ETrue; |
|
511 break; |
|
512 case EUSBStorageMediaFailure: |
|
513 case EUSBChangeFromMassStorage: |
|
514 iCompleteQuery = EFalse; |
|
515 break; |
|
516 default: |
|
517 break; |
|
518 } |
|
519 |
|
520 iNotifier -> StartNotifierAndGetResponse( iReqStatus, KQueriesNotifier, notifierParamsPckg, output ); |
|
521 |
|
522 aTestResult = ETestCasePassed; |
|
523 |
|
524 TRACE_INFO( _L("<<<UsbQueriesNotifierTest") ); |
|
525 } |
|
526 |
|
527 // ----------------------------------------------------------------------------- |
|
528 // CUsbUiNotifApiTest::UsbOTGErrorNotifierTests |
|
529 // ----------------------------------------------------------------------------- |
|
530 |
|
531 void CUsbUiNotifApiTest::UsbOTGErrorNotifierTests( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ) |
|
532 { |
|
533 TRACE_INFO( _L(">>>UsbOTGErrorNotifierTests") ); |
|
534 |
|
535 TInt res; |
|
536 TUsbUiNotifOtgError usbOTGErrorType; |
|
537 |
|
538 res = GetOTGErrorType( aTestSubOption, usbOTGErrorType ); |
|
539 if ( res != KErrNone ) |
|
540 { |
|
541 TRACE_INFO( (_L("usbOTGErrorType failed with value: %d"), res) ); |
|
542 return; |
|
543 } |
|
544 |
|
545 res = iNotifier -> Connect(); |
|
546 if ( res != KErrNone ) |
|
547 { |
|
548 TRACE_INFO( (_L("Failed to connect RNotifier with value: %d"), res) ); |
|
549 return; |
|
550 } |
|
551 TRACE_INFO( _L("RNotifier connected") ); |
|
552 |
|
553 TPckgBuf<TInt> notifierParamsPckg; |
|
554 notifierParamsPckg() = usbOTGErrorType; |
|
555 iCompleteQuery = EFalse; |
|
556 |
|
557 iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifOtgError, notifierParamsPckg, iRes ); |
|
558 |
|
559 aTestResult = ETestCasePassed; |
|
560 |
|
561 TRACE_INFO( _L("<<<UsbOTGErrorNotifierTests") ); |
|
562 } |
|
563 |
|
564 // ----------------------------------------------------------------------------- |
|
565 // CUsbUiNotifApiTest::UsbOTGWarningNotifierTests |
|
566 // ----------------------------------------------------------------------------- |
|
567 |
|
568 void CUsbUiNotifApiTest::UsbOTGWarningNotifierTests( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ) |
|
569 { |
|
570 TRACE_INFO( _L(">>>UsbOTGWarningNotifierTests") ); |
|
571 |
|
572 TInt res; |
|
573 TUsbUiNotifOtgWarning usbOTGWarningType; |
|
574 |
|
575 |
|
576 res = GetOTGWarningType( aTestSubOption, usbOTGWarningType ); |
|
577 if ( res != KErrNone ) |
|
578 { |
|
579 TRACE_INFO( (_L("usbOTGErrorType failed with value: %d"), res) ); |
|
580 return; |
|
581 } |
|
582 |
|
583 res = iNotifier -> Connect(); |
|
584 if ( res != KErrNone ) |
|
585 { |
|
586 TRACE_INFO( (_L("Failed to connect RNotifier with value: %d"), res) ); |
|
587 return; |
|
588 } |
|
589 TRACE_INFO( _L("RNotifier connected") ); |
|
590 |
|
591 TPckgBuf<TInt> notifierParamsPckg; |
|
592 notifierParamsPckg() = usbOTGWarningType; |
|
593 iCompleteQuery = EFalse; |
|
594 |
|
595 iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifOtgWarning, notifierParamsPckg, iRes ); |
|
596 |
|
597 aTestResult = ETestCasePassed; |
|
598 |
|
599 TRACE_INFO( _L("<<<UsbOTGWarningNotifierTests") ); |
|
600 } |
|
601 |
|
602 // ----------------------------------------------------------------------------- |
|
603 // CUsbUiNotifApiTest::UsbMSMMNotifierTests |
|
604 // ----------------------------------------------------------------------------- |
|
605 |
|
606 void CUsbUiNotifApiTest::UsbMSMMNotifierTests( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ) |
|
607 { |
|
608 TRACE_INFO( _L(">>>UsbMSMMNotifierTests") ); |
|
609 |
|
610 TInt res; |
|
611 THostMsErrCode usbMSMMNErrorType; |
|
612 |
|
613 res = GetMSMMrrorType( aTestSubOption, usbMSMMNErrorType ); |
|
614 if ( res != KErrNone ) |
|
615 { |
|
616 TRACE_INFO( (_L("MSMMrrorType failed with value: %d"), res) ); |
|
617 return; |
|
618 } |
|
619 iErrData.iError=usbMSMMNErrorType; |
|
620 iErrPckg = iErrData; |
|
621 res = iNotifier -> Connect(); |
|
622 if ( res != KErrNone ) |
|
623 { |
|
624 TRACE_INFO( (_L("Failed to connect RNotifier with value: %d"), res) ); |
|
625 return; |
|
626 } |
|
627 TRACE_INFO( _L("RNotifier connected") ); |
|
628 |
|
629 TPckgBuf<TInt> notifierParamsPckg; |
|
630 notifierParamsPckg() = usbMSMMNErrorType; |
|
631 iCompleteQuery = EFalse; |
|
632 |
|
633 iNotifier -> StartNotifierAndGetResponse( iReqStatus, KUsbUiNotifMsmmError, iErrPckg, iRes ); |
|
634 |
|
635 aTestResult = ETestCasePassed; |
|
636 |
|
637 TRACE_INFO( _L("<<<UsbMSMMNotifierTests") ); |
|
638 } |
|
639 |
|
640 |
|
641 // ----------------------------------------------------------------------------- |
|
642 // CUsbUiNotifApiTest::FinishQuery |
|
643 // ----------------------------------------------------------------------------- |
|
644 |
|
645 TInt CUsbUiNotifApiTest::FinishQuery( TPtrC aTestSubOption, TUsbUiNotifApiTestResult& aTestResult ) |
|
646 { |
|
647 TRACE_INFO( _L(">>>FinishQuery") ); |
|
648 |
|
649 TInt res; |
|
650 TTestOption option; |
|
651 |
|
652 if ( iCompleteQuery ) |
|
653 { |
|
654 TRequestStatus* statPtr = &iReqStatus; |
|
655 User::RequestComplete( statPtr, KErrNone ); |
|
656 } |
|
657 |
|
658 res = GetTestOption( aTestSubOption, option ); |
|
659 if ( res != KErrNone ) |
|
660 { |
|
661 TRACE_INFO( (_L("GetTestOption failed with value: %d"), res) ); |
|
662 iNotifier -> Close(); |
|
663 return res; |
|
664 } |
|
665 |
|
666 User::WaitForRequest( iReqStatus ); |
|
667 iNotifier -> Close(); |
|
668 |
|
669 switch( option ) |
|
670 { |
|
671 case EQueryAccepted: |
|
672 TRACE_INFO( (_L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone) ); |
|
673 STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() ); |
|
674 break; |
|
675 case EQueryCanceled: |
|
676 TRACE_INFO( (_L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel) ); |
|
677 STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() ); |
|
678 break; |
|
679 default: |
|
680 return KErrNotFound; |
|
681 } |
|
682 |
|
683 aTestResult = ETestCasePassed; |
|
684 |
|
685 TRACE_INFO( _L("<<<FinishQuery") ); |
|
686 |
|
687 return KErrNone; |
|
688 } |
|
689 |
|
690 // ----------------------------------------------------------------------------- |
|
691 // CUsbUiNotifApiTest::LoadNotifiersL |
|
692 // ----------------------------------------------------------------------------- |
|
693 |
|
694 void CUsbUiNotifApiTest::LoadNotifiersL( TUsbUiNotifApiTestResult& aTestResult ) |
|
695 { |
|
696 TRACE_INFO( _L(">>>LoadNotifiersL") ); |
|
697 |
|
698 iNotifierArray = reinterpret_cast<CArrayPtr<MEikSrvNotifierBase2>*>( |
|
699 REComSession::CreateImplementationL(TUid::Uid(0x10281F23), iInstanceUid)); |
|
700 |
|
701 aTestResult = ETestCasePassed; |
|
702 |
|
703 TRACE_INFO( _L("<<<LoadNotifiersL") ); |
|
704 } |
|
705 |
|
706 // ----------------------------------------------------------------------------- |
|
707 // CUsbUiNotifApiTest::UnLoadNotifiers |
|
708 // ----------------------------------------------------------------------------- |
|
709 |
|
710 void CUsbUiNotifApiTest::UnLoadNotifiers ( TUsbUiNotifApiTestResult& aTestResult ) |
|
711 { |
|
712 TRACE_INFO( _L(">>>UnLoadNotifiers") ); |
|
713 |
|
714 TInt count = iNotifierArray->Count(); |
|
715 TInt i=0; |
|
716 for (i=0; i<count; i++) |
|
717 { |
|
718 iNotifierArray->At(i)->Release(); |
|
719 } |
|
720 iNotifierArray->Reset(); |
|
721 delete iNotifierArray; |
|
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") ); |
|
800 return KErrNone; |
|
801 } |
|
802 |
|
803 // ----------------------------------------------------------------------------- |
|
804 // CUsbUiNotifApiTest::GetOTGErrorType |
|
805 // ----------------------------------------------------------------------------- |
|
806 |
|
807 TInt CUsbUiNotifApiTest::GetOTGErrorType( TPtrC aTypeString, TUsbUiNotifOtgError& aQueryType ) |
|
808 { |
|
809 TRACE_INFO( _L(">>>GetOTGErrorType") ); |
|
810 |
|
811 if ( !aTypeString.Compare( _L( "EUsbOtgTooMuchPower" ) ) ) |
|
812 { |
|
813 aQueryType = EUsbOtgTooMuchPower; |
|
814 TRACE_INFO( _L("Query type: EUsbOtgTooMuchPower") ); |
|
815 } |
|
816 else if ( !aTypeString.Compare( _L( "EUsbOtgTooMuchPowerRequired" ) ) ) |
|
817 { |
|
818 aQueryType = EUsbOtgTooMuchPowerRequired; |
|
819 TRACE_INFO( _L("Query type: EUsbOtgTooMuchPowerRequired") ); |
|
820 } |
|
821 else if ( !aTypeString.Compare( _L( "EUsbOtgUnsupportedDevice" ) ) ) |
|
822 { |
|
823 aQueryType = EUsbOtgUnsupportedDevice; |
|
824 TRACE_INFO( _L("Query type: EUsbOtgUnsupportedDevice") ); |
|
825 } |
|
826 else if ( !aTypeString.Compare( _L( "EUsbOtgHubUnsupported" ) ) ) |
|
827 { |
|
828 aQueryType = EUsbOtgHubUnsupported; |
|
829 TRACE_INFO( _L("Query type: EUsbOtgHubUnsupported") ); |
|
830 } |
|
831 else if ( !aTypeString.Compare( _L( "EUsbOtgErrorInConnection" ) ) ) |
|
832 { |
|
833 aQueryType = EUsbOtgErrorInConnection; |
|
834 TRACE_INFO( _L("Query type: EUsbOtgErrorInConnection") ); |
|
835 } |
|
836 else if ( !aTypeString.Compare( _L( "EUsbOtgErrorAttachTimedOut" ) ) ) |
|
837 { |
|
838 aQueryType = EUsbOtgErrorAttachTimedOut; |
|
839 TRACE_INFO( _L("Query type: EUsbOtgErrorAttachTimedOut") ); |
|
840 } |
|
841 else |
|
842 { |
|
843 TRACE_INFO( _L("Query type: not supported") ); |
|
844 return KErrNotFound; |
|
845 } |
|
846 |
|
847 TRACE_INFO( _L("<<<GetOTGErrorType") ); |
|
848 return KErrNone; |
|
849 } |
|
850 |
|
851 |
|
852 // ----------------------------------------------------------------------------- |
|
853 // CUsbUiNotifApiTest::GetOTGWarningType |
|
854 // ----------------------------------------------------------------------------- |
|
855 |
|
856 TInt CUsbUiNotifApiTest::GetOTGWarningType( TPtrC aTypeString, TUsbUiNotifOtgWarning& aQueryType ) |
|
857 { |
|
858 TRACE_INFO( _L(">>>GetOTGWarningType") ); |
|
859 |
|
860 if ( !aTypeString.Compare( _L( "EUsbOtgPartiallySupportedDevice" ) ) ) |
|
861 { |
|
862 aQueryType = EUsbOtgPartiallySupportedDevice; |
|
863 TRACE_INFO( _L("Query type: EUsbOtgPartiallySupportedDevice;") ); |
|
864 } |
|
865 else |
|
866 { |
|
867 TRACE_INFO( _L("Query type: not supported") ); |
|
868 return KErrNotFound; |
|
869 } |
|
870 |
|
871 TRACE_INFO( _L("<<<GetOTGWarningType") ); |
|
872 |
|
873 return KErrNone; |
|
874 } |
|
875 |
|
876 // ----------------------------------------------------------------------------- |
|
877 // CUsbUiNotifApiTest::GetMSMMrrorType |
|
878 // ----------------------------------------------------------------------------- |
|
879 |
|
880 TInt CUsbUiNotifApiTest::GetMSMMrrorType( TPtrC aTypeString, THostMsErrCode& aQueryType ) |
|
881 { |
|
882 TRACE_INFO( _L(">>>GetMSMMrrorType") ); |
|
883 if ( !aTypeString.Compare( _L( "EUsbMSMMGeneralError" ) ) ) |
|
884 { |
|
885 aQueryType = EHostMsErrGeneral; |
|
886 TRACE_INFO( _L("Query type: EUsbOtgPartiallySupportedDevice;") ); |
|
887 } |
|
888 else if ( !aTypeString.Compare( _L( "EUsbMSMMUnknownFileSystem" ) ) ) |
|
889 { |
|
890 aQueryType = EHostMsErrUnknownFileSystem; |
|
891 TRACE_INFO( _L("Query type: EUsbMSMMUnknownFileSystem") ); |
|
892 } |
|
893 else if ( !aTypeString.Compare( _L( "EUsbMSMMOutOfMemory" ) ) ) |
|
894 { |
|
895 aQueryType = EHostMsErrOutOfMemory; |
|
896 TRACE_INFO( _L("Query type: EUsbMSMMOutOfMemory") ); |
|
897 } |
|
898 else |
|
899 { |
|
900 TRACE_INFO( _L("Query type: not supported") ); |
|
901 return KErrNotFound; |
|
902 } |
|
903 |
|
904 TRACE_INFO( _L("<<<GetMSMMrrorType") ); |
|
905 return KErrNone; |
|
906 } |
|
907 |
|
908 // ----------------------------------------------------------------------------- |
|
909 // CUsbUiNotifApiTest::GetTestOption |
|
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") ); |
|
932 return KErrNotFound; |
|
933 } |
|
934 |
|
935 return KErrNone; |
|
936 } |
|
937 |
|
938 // ----------------------------------------------------------------------------- |
|
939 // CUsbUiNotifApiTest::GetPersonalityIdFromString |
|
940 // ----------------------------------------------------------------------------- |
|
941 |
|
942 TInt CUsbUiNotifApiTest::GetPersonalityIdFromString( TPtrC aOptionString, TInt& aPersonalityId ) |
|
943 { |
|
944 if ( !aOptionString.Compare( _L( "MS" ) ) ) |
|
945 { |
|
946 aPersonalityId = KUsbPersonalityIdMS; |
|
947 TRACE_INFO( _L("Usb personality type: KUsbPersonalityIdMS") ); |
|
948 } |
|
949 else if ( !aOptionString.Compare( _L( "PCSUITE" ) ) ) |
|
950 { |
|
951 aPersonalityId = KUsbPersonalityIdPCSuite; |
|
952 TRACE_INFO( _L("Usb personality type: KUsbPersonalityIdPCSuite") ); |
|
953 } |
|
954 else if ( !aOptionString.Compare( _L( "MTP" ) ) ) |
|
955 { |
|
956 aPersonalityId = KUsbPersonalityIdMTP; |
|
957 TRACE_INFO( _L("Usb personality type: KUsbPersonalityIdMTP") ); |
|
958 } |
|
959 else if ( !aOptionString.Compare( _L( "PCSUITEMTP" ) ) ) |
|
960 { |
|
961 aPersonalityId = KUsbPersonalityIdPCSuiteMTP; |
|
962 TRACE_INFO( _L("Usb personality type: KUsbPersonalityIdPCSuiteMTP") ); |
|
963 } |
|
964 else |
|
965 { |
|
966 TRACE_INFO( _L("Usb personality type: not found") ); |
|
967 return KErrNotFound; |
|
968 } |
|
969 |
|
970 return KErrNone; |
|
971 } |
|
972 |
|
973 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
974 // None |
|
975 |
|
976 // [End of File] - Do not remove |
|