|
1 /* |
|
2 * Copyright (c) 2002 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: Restricted Audio Output Test |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32svr.h> |
|
22 #include <StifParser.h> |
|
23 #include <Stiftestinterface.h> |
|
24 #include <RestrictedAudioOutputProxy.h> |
|
25 #include "RestrictedAOTestClass.h" |
|
26 #include "debug.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 . |
|
58 // |
|
59 // Returns: ?value_1: |
|
60 // ?value_n: _line1 |
|
61 // _line2 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 /* |
|
65 ?type ?function_name( |
|
66 ?arg_type arg, // |
|
67 ?arg_type arg) // |
|
68 { |
|
69 |
|
70 ?code // ?comment |
|
71 |
|
72 // ?comment |
|
73 ?code |
|
74 } |
|
75 */ |
|
76 |
|
77 // ============================ MEMBER FUNCTIONS =============================== |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CRestrictedAOTestClass::Delete |
|
81 // Delete here all resources allocated and opened from test methods. |
|
82 // Called from destructor. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CRestrictedAOTestClass::Delete() |
|
86 { |
|
87 |
|
88 FTRACE(FPrint(_L("CRestrictedAOTestClass::Delete"))); |
|
89 |
|
90 iExpectedEvents.Close(); |
|
91 iOcurredEvents.Close(); |
|
92 |
|
93 iLog->Log(_L("Deleting test class...")); |
|
94 iLog->Log(_L("")); |
|
95 iLog->Log(_L("")); |
|
96 |
|
97 if(iRestrictedAudioOutput) |
|
98 { |
|
99 delete iRestrictedAudioOutput; |
|
100 } |
|
101 |
|
102 if (iDevSound) |
|
103 { |
|
104 delete iDevSound; |
|
105 iDevSound = NULL; |
|
106 } |
|
107 REComSession::FinalClose(); |
|
108 |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CRestrictedAOTestClass::RunMethodL |
|
113 // Run specified method. Contains also table of test mothods and their names. |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 TInt CRestrictedAOTestClass::RunMethodL( |
|
117 CStifItemParser& aItem ) |
|
118 { |
|
119 |
|
120 static TStifFunctionInfo const KFunctions[] = |
|
121 { |
|
122 // Copy this line for every implemented function. |
|
123 // First string is the function name used in TestScripter script file. |
|
124 // Second is the actual implementation member function. |
|
125 |
|
126 ENTRY( "CreateFactory", CRestrictedAOTestClass::CreateFactory ), |
|
127 ENTRY( "CreateRestrictedAO", CRestrictedAOTestClass::CreateRestrictedAO ), |
|
128 ENTRY( "AppendAllowedOutput", CRestrictedAOTestClass::AppendAllowedOutput ), |
|
129 ENTRY( "RemoveAllowedOutput", CRestrictedAOTestClass::RemoveAllowedOutput ), |
|
130 ENTRY( "GetAllowedOutputCount", CRestrictedAOTestClass::GetAllowedOutputCount ), |
|
131 ENTRY( "GetAllowedOutput", CRestrictedAOTestClass::GetAllowedOutput ), |
|
132 ENTRY( "Reset", CRestrictedAOTestClass::Reset ), |
|
133 ENTRY( "Commit", CRestrictedAOTestClass::Commit ), |
|
134 |
|
135 ENTRY( "Example", CRestrictedAOTestClass::ExampleL ), |
|
136 |
|
137 }; |
|
138 |
|
139 const TInt count = sizeof( KFunctions ) / |
|
140 sizeof( TStifFunctionInfo ); |
|
141 |
|
142 return RunInternalL( KFunctions, count, aItem ); |
|
143 |
|
144 } |
|
145 |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CRestrictedAOTestClass::EventName |
|
149 // Return descriptor with the notification description |
|
150 // ----------------------------------------------------------------------------- |
|
151 TPtrC CRestrictedAOTestClass::EventName( TInt aKey ) |
|
152 { |
|
153 static TText* const badKeyword = (TText*)L"BadKeyword"; |
|
154 static TText* const keywords[] = |
|
155 { |
|
156 |
|
157 (TText*)L"EInitializeComplete", |
|
158 |
|
159 }; |
|
160 |
|
161 |
|
162 |
|
163 if( (TUint)aKey >= (sizeof( keywords )/sizeof(TText*)) ) |
|
164 { |
|
165 iLog->Log(_L("Keyword out of bounds")); |
|
166 TPtrC keyword( badKeyword ); |
|
167 return keyword; |
|
168 } |
|
169 else |
|
170 { |
|
171 TPtrC keyword( keywords[aKey] ); |
|
172 return keyword; |
|
173 } |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CRestrictedAOTestClass::AddExpectedEvent |
|
178 // Add an event to the expected events' list |
|
179 // ----------------------------------------------------------------------------- |
|
180 void CRestrictedAOTestClass::AddExpectedEvent(TROExpectedEvent event, TInt ms) |
|
181 { |
|
182 FTRACE(FPrint(_L("CRestrictedAOTestClass::AddExpectedEvent"))); |
|
183 iExpectedEvents.Append(event); |
|
184 TPtrC eventName = EventName(event); |
|
185 iLog->Log(_L("Adding expected event:(0x%02x)%S Total=%d"), event, &eventName, iExpectedEvents.Count() ); |
|
186 |
|
187 if ( iTimeoutController && !iTimeoutController->IsActive() ) |
|
188 { |
|
189 if (ms > 0) |
|
190 { |
|
191 iTimeoutController->Start( TTimeIntervalMicroSeconds(ms * 1000) ); |
|
192 } |
|
193 else |
|
194 { |
|
195 iLog->Log(_L("Timeout with default value (1s)")); |
|
196 iTimeoutController->Start( TTimeIntervalMicroSeconds(1000000) ); |
|
197 } |
|
198 } |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CRestrictedAOTestClass::RemoveExpectedEvent |
|
203 // Remove the indicated event from the expected events' list |
|
204 // ----------------------------------------------------------------------------- |
|
205 TBool CRestrictedAOTestClass::RemoveExpectedEvent(TROExpectedEvent aEvent) |
|
206 { |
|
207 FTRACE(FPrint(_L("CRestrictedAOTestClass::RemoveExpectedEvent"))); |
|
208 TBool match = EFalse; |
|
209 for (TUint i=0; i < iExpectedEvents.Count() ; i++) |
|
210 { |
|
211 if (iExpectedEvents[i] == aEvent) |
|
212 { |
|
213 iExpectedEvents.Remove(i); |
|
214 match = ETrue; |
|
215 break; |
|
216 } |
|
217 } |
|
218 |
|
219 return match; |
|
220 } |
|
221 |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // CRestrictedAOTestClass::RemoveAllExpectedEvents |
|
225 // Remove the indicated event from the expected events' list |
|
226 // ----------------------------------------------------------------------------- |
|
227 void CRestrictedAOTestClass::RemoveAllExpectedEvents() |
|
228 { |
|
229 FTRACE(FPrint(_L("CRestrictedAOTestClass::RemoveAllExpectedEvents"))); |
|
230 iLog->Log(_L("Removing all expected events")); |
|
231 |
|
232 iExpectedEvents.Reset(); |
|
233 iOcurredEvents.Reset(); |
|
234 } |
|
235 |
|
236 |
|
237 // ----------------------------------------------------------------------------- |
|
238 // CRestrictedAOTestClass::ProcessEvent |
|
239 // ----------------------------------------------------------------------------- |
|
240 void CRestrictedAOTestClass::ProcessEvent(TROExpectedEvent aEvent, TInt aError) |
|
241 { |
|
242 FTRACE(FPrint(_L("CRestrictedAOTestClass::ProcessExpectedEvent"))); |
|
243 TPtrC nameEvent = EventName(aEvent); |
|
244 |
|
245 // Check for error |
|
246 if (aError == KErrNone) |
|
247 { |
|
248 // Remove the event |
|
249 if (RemoveExpectedEvent(aEvent)) |
|
250 { |
|
251 iLog->Log(_L("Expected Event: (0x%02x)%S has ocurred Total=%d"), aEvent, &nameEvent,iExpectedEvents.Count()); |
|
252 } |
|
253 else |
|
254 { |
|
255 iLog->Log(_L("Event: (0x%02x)%S has ocurred"), aEvent, &nameEvent); |
|
256 return; |
|
257 } |
|
258 |
|
259 |
|
260 |
|
261 // All expected events have ocurred |
|
262 if (iExpectedEvents.Count() == 0 ) |
|
263 { |
|
264 Signal(); |
|
265 iTimeoutController->Cancel(); |
|
266 } |
|
267 |
|
268 |
|
269 } |
|
270 else |
|
271 { |
|
272 iLog->Log(_L("[Error] Event: (0x%02x)%S return with error code=%d"), aEvent, &nameEvent, aError); |
|
273 if (iExpectedEvents.Count() != 0 ) |
|
274 { |
|
275 RemoveExpectedEvent(aEvent); |
|
276 } |
|
277 iTimeoutController->Cancel(); |
|
278 Signal(KErrCallbackErrorCode); |
|
279 } |
|
280 } |
|
281 |
|
282 // ----------------------------------------------------------------------------- |
|
283 // CRestrictedAOTestClass::HandleTimeout |
|
284 // Review if all the expected events have ocurred once the time is over |
|
285 // ----------------------------------------------------------------------------- |
|
286 |
|
287 void CRestrictedAOTestClass::HandleTimeout(TInt aError) |
|
288 { |
|
289 FTRACE(FPrint(_L("CRestrictedAOTestClass::HandleTimeout"))); |
|
290 // All expected events have ocurred |
|
291 if (aError != KErrNone) |
|
292 { |
|
293 if (iExpectedEvents.Count() == 0 ) |
|
294 { |
|
295 iLog->Log(_L("Timing out but events have ocurred")); |
|
296 Signal(); |
|
297 } |
|
298 else |
|
299 { |
|
300 RemoveAllExpectedEvents(); |
|
301 iLog->Log(_L("Timing out and events still pending")); |
|
302 Signal(KErrEventPending); |
|
303 } |
|
304 } |
|
305 else |
|
306 { |
|
307 iLog->Log(_L("Timing out return a error %d"), aError); |
|
308 Signal(aError); |
|
309 } |
|
310 } |
|
311 |
|
312 // ----------------------------------------------------------------------------- |
|
313 // CRestrictedAOTestClass::SetTimeout |
|
314 // Create a timer and set a timeout |
|
315 // When the timeout is reached the test case is marked as failed |
|
316 // It's used rather than the "timeout" keyword in the configuration file |
|
317 // because in this way the log continues |
|
318 // ----------------------------------------------------------------------------- |
|
319 TInt CRestrictedAOTestClass::SetTimeout( CStifItemParser& aItem ) |
|
320 { |
|
321 FTRACE(FPrint(_L("CRestrictedAOTestClass::SetTimeout"))); |
|
322 TInt timeout=0; |
|
323 TInt error = aItem.GetNextInt(timeout) ; |
|
324 if ( iTimeoutController ) |
|
325 { |
|
326 if ( timeout > 0 ) |
|
327 { |
|
328 iTimeoutController->Start( TTimeIntervalMicroSeconds(timeout*1000) ); |
|
329 } |
|
330 else |
|
331 { |
|
332 iTimeoutController->Start( TTimeIntervalMicroSeconds(1000000) ); |
|
333 } |
|
334 } |
|
335 else |
|
336 { |
|
337 iLog->Log(_L("Timeout Controller doesn't exist")); |
|
338 error = KErrTimeoutController; |
|
339 } |
|
340 return error; |
|
341 } |
|
342 |
|
343 |
|
344 // ----------------------------------------------------------------------------- |
|
345 // Uses the TestModuleBase API to allow a panic as exit reason for a test case |
|
346 // ----------------------------------------------------------------------------- |
|
347 TInt CRestrictedAOTestClass::SetAllowedPanic( CStifItemParser& aItem ) |
|
348 { |
|
349 FTRACE(FPrint(_L("CRestrictedAOTestClass::SetAllowedPanic"))); |
|
350 TInt error = KErrNone; |
|
351 TInt panicCode; |
|
352 TPtrC panicType; |
|
353 if ( ( KErrNone == aItem.GetNextString(panicType) ) && |
|
354 ( KErrNone == aItem.GetNextInt(panicCode) ) ) |
|
355 { |
|
356 iLog->Log(_L("Allowing panic: %S %d"), &panicType, panicCode); |
|
357 iTestModuleIf.SetExitReason( CTestModuleIf::EPanic, panicCode ); |
|
358 iNormalExitReason = EFalse; |
|
359 } |
|
360 else |
|
361 { |
|
362 iLog->Log(KMsgBadTestParameters); |
|
363 error = KErrBadTestParameter; |
|
364 } |
|
365 return error; |
|
366 } |
|
367 |
|
368 // ----------------------------------------------------------------------------- |
|
369 // CRestrictedAOTestClass::SetExpectedEvents() |
|
370 // ----------------------------------------------------------------------------- |
|
371 TInt CRestrictedAOTestClass::SetExpectedEvents( CStifItemParser& aItem ) |
|
372 { |
|
373 FTRACE(FPrint(_L("CRestrictedAOTestClass::SetExpectedEvents"))); |
|
374 TInt error = KErrNone; |
|
375 TInt event=0; |
|
376 while ( KErrNone == aItem.GetNextInt(event)) |
|
377 { |
|
378 AddExpectedEvent(static_cast<TROExpectedEvent>(event), 0); // Default timeout value |
|
379 } |
|
380 return error; |
|
381 } |
|
382 |
|
383 |
|
384 // ----------------------------------------------------------------------------- |
|
385 // CRestrictedAOTestClass::ExampleL |
|
386 // Example test method function. |
|
387 // (other items were commented in a header). |
|
388 // ----------------------------------------------------------------------------- |
|
389 // |
|
390 TInt CRestrictedAOTestClass::ExampleL( CStifItemParser& aItem ) |
|
391 { |
|
392 |
|
393 // Print to UI |
|
394 _LIT( KRestrictedAOTestClass, "RestrictedAOTestClass" ); |
|
395 _LIT( KExample, "In Example" ); |
|
396 TestModuleIf().Printf( 0, KRestrictedAOTestClass, KExample ); |
|
397 // Print to log file |
|
398 iLog->Log( KExample ); |
|
399 |
|
400 TInt i = 0; |
|
401 TPtrC string; |
|
402 _LIT( KParam, "Param[%i]: %S" ); |
|
403 while ( aItem.GetNextString ( string ) == KErrNone ) |
|
404 { |
|
405 TestModuleIf().Printf( i, KRestrictedAOTestClass, |
|
406 KParam, i, &string ); |
|
407 i++; |
|
408 } |
|
409 |
|
410 return KErrNone; |
|
411 |
|
412 } |
|
413 |
|
414 // ----------------------------------------------------------------------------- |
|
415 // CRestrictedAOTestClass::AppendAllowedOutput |
|
416 // Append AllowedOutput |
|
417 // ----------------------------------------------------------------------------- |
|
418 // |
|
419 TInt CRestrictedAOTestClass::AppendAllowedOutput( CStifItemParser& aItem ) |
|
420 { |
|
421 FTRACE(FPrint(_L("CRestrictedAOTestClass::AppendAllowedOutput"))); |
|
422 iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput")); |
|
423 TInt error = KErrNone; |
|
424 |
|
425 TPtrC AppendType; |
|
426 error = aItem.GetNextString(AppendType); |
|
427 if (error == KErrNone) |
|
428 { |
|
429 if (AppendType == KTagAll) |
|
430 { |
|
431 iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAllAudio")); |
|
432 error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAllAudio); |
|
433 } |
|
434 else if (AppendType == KTagAudioAnalog) |
|
435 { |
|
436 iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioAnalog")); |
|
437 error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioAnalog); |
|
438 } |
|
439 else if (AppendType == KTagFM) |
|
440 { |
|
441 iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioFMTransmitter")); |
|
442 error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioFMTransmitter); |
|
443 } |
|
444 else if (AppendType == KTagStereoBT) |
|
445 { |
|
446 iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioBtHFPHSP")); |
|
447 error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioBtHFPHSP); |
|
448 } |
|
449 else if (AppendType == KTagBTA2DP) |
|
450 { |
|
451 iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioBtA2DP")); |
|
452 error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioBtA2DP); |
|
453 } |
|
454 else if (AppendType == KTagAudioUplink) |
|
455 { |
|
456 iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioUplink")); |
|
457 error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioUplink); |
|
458 } |
|
459 else if (AppendType == KTagUSB) |
|
460 { |
|
461 iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioUsb")); |
|
462 error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioUsb); |
|
463 } |
|
464 else if (AppendType == KTagRecord) |
|
465 { |
|
466 iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioRecording")); |
|
467 error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioRecording); |
|
468 } |
|
469 else if (AppendType == KTagVisualization) |
|
470 { |
|
471 iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowVisualization")); |
|
472 error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowVisualization); |
|
473 } |
|
474 |
|
475 /** |
|
476 * RIM CR 417-7642: HDMI with HDCP to Resctricted Audio Output API |
|
477 * Adding new ENUMs to CRestrictedAudioOutput::TAllowedOutputPreference for HDMI and HDCP |
|
478 * EAllowAudioHDMI and EAllowAudioHdmiHdcpRequired |
|
479 */ |
|
480 else if (AppendType == KTagHDMI) |
|
481 { |
|
482 iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioHDMI")); |
|
483 error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioHDMI); |
|
484 } |
|
485 else if (AppendType == KTagHdmiHdcpRequired) |
|
486 { |
|
487 iLog->Log(_L("CRestrictedAOTestClass::AppendAllowedOutput - EAllowAudioHdmiHdcpRequired")); |
|
488 error = iRestrictedAudioOutput->AppendAllowedOutput(CRestrictedAudioOutput::EAllowAudioHdmiHdcpRequired); |
|
489 } |
|
490 else |
|
491 { |
|
492 iLog->Log(KMsgBadTestParameters); |
|
493 error = KErrBadTestParameter; |
|
494 } |
|
495 |
|
496 } |
|
497 |
|
498 return error; |
|
499 } |
|
500 |
|
501 |
|
502 // ----------------------------------------------------------------------------- |
|
503 // CRestrictedAOTestClass::RemoveAllowedOutput |
|
504 // Remove AllowedOutput |
|
505 // ----------------------------------------------------------------------------- |
|
506 // |
|
507 TInt CRestrictedAOTestClass::RemoveAllowedOutput( CStifItemParser& aItem ) |
|
508 { |
|
509 FTRACE(FPrint(_L("CRestrictedAOTestClass::RemoveAllowedOutput"))); |
|
510 iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput")); |
|
511 TInt error = KErrNone; |
|
512 |
|
513 TPtrC RemoveType; |
|
514 error = aItem.GetNextString(RemoveType); |
|
515 if (error == KErrNone) |
|
516 { |
|
517 if (RemoveType == KTagAll) |
|
518 { |
|
519 iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowAllAudio")); |
|
520 error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowAllAudio); |
|
521 } |
|
522 else if (RemoveType == KTagAudioAnalog) |
|
523 { |
|
524 iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowAudioAnalog")); |
|
525 error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowAudioAnalog); |
|
526 } |
|
527 else if (RemoveType == KTagFM) |
|
528 { |
|
529 iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowAudioFMTransmitter")); |
|
530 error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowAudioFMTransmitter); |
|
531 } |
|
532 else if (RemoveType == KTagStereoBT) |
|
533 { |
|
534 iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowAudioBtHFPHSP")); |
|
535 error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowAudioBtHFPHSP); |
|
536 } |
|
537 else if (RemoveType == KTagBTA2DP) |
|
538 { |
|
539 iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowAudioBtA2DP")); |
|
540 error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowAudioBtA2DP); |
|
541 } |
|
542 else if (RemoveType == KTagAudioUplink) |
|
543 { |
|
544 iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowAudioUplink")); |
|
545 error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowAudioUplink); |
|
546 } |
|
547 else if (RemoveType == KTagUSB) |
|
548 { |
|
549 iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowAudioUsb")); |
|
550 error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowAudioUsb); |
|
551 } |
|
552 else if (RemoveType == KTagRecord) |
|
553 { |
|
554 iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowAudioRecording")); |
|
555 error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowAudioRecording); |
|
556 } |
|
557 else if (RemoveType == KTagVisualization) |
|
558 { |
|
559 iLog->Log(_L("CRestrictedAOTestClass::RemoveAllowedOutput - EAllowVisualization")); |
|
560 error = iRestrictedAudioOutput->RemoveAllowedOutput(CRestrictedAudioOutput::EAllowVisualization); |
|
561 } |
|
562 else |
|
563 { |
|
564 iLog->Log(KMsgBadTestParameters); |
|
565 error = KErrBadTestParameter; |
|
566 } |
|
567 |
|
568 } |
|
569 |
|
570 return error; |
|
571 } |
|
572 |
|
573 |
|
574 |
|
575 // ----------------------------------------------------------------------------- |
|
576 // CRestrictedAOTestClass::GetAllowedOutputCount |
|
577 // Get AllowedOutput Count |
|
578 // ----------------------------------------------------------------------------- |
|
579 // |
|
580 TInt CRestrictedAOTestClass::GetAllowedOutputCount( CStifItemParser& /*aItem */) |
|
581 { |
|
582 FTRACE(FPrint(_L("CRestrictedAOTestClass::GetAllowedOutputCount"))); |
|
583 iLog->Log(_L("CRestrictedAOTestClass::GetAllowedOutputCount")); |
|
584 TInt error = KErrNone; |
|
585 |
|
586 TInt aSize; |
|
587 error = iRestrictedAudioOutput->GetAllowedOutputCount(aSize); |
|
588 if (error == KErrNone) |
|
589 error = aSize; |
|
590 |
|
591 return error; |
|
592 } |
|
593 |
|
594 // ----------------------------------------------------------------------------- |
|
595 // CRestrictedAOTestClass::GetAllowedOutput |
|
596 // Get Allowed Output |
|
597 // ----------------------------------------------------------------------------- |
|
598 // |
|
599 TInt CRestrictedAOTestClass::GetAllowedOutput( CStifItemParser& aItem ) |
|
600 { |
|
601 FTRACE(FPrint(_L("CRestrictedAOTestClass::GetAllowedOutput"))); |
|
602 iLog->Log(_L("CRestrictedAOTestClass::GetAllowedOutput")); |
|
603 TInt error = KErrNone; |
|
604 TInt aCount; |
|
605 TInt index; |
|
606 TInt Found = 0; |
|
607 CRestrictedAudioOutput::TAllowedOutputPreference aOutput; |
|
608 |
|
609 error = iRestrictedAudioOutput->GetAllowedOutputCount(aCount); |
|
610 if (error != KErrNone) |
|
611 { |
|
612 iLog->Log(_L("GetAllowedOutputCount return error %d"), error); |
|
613 return error; |
|
614 } |
|
615 |
|
616 TPtrC ExpectedOutput; |
|
617 error = aItem.GetNextString(ExpectedOutput); |
|
618 if (error != KErrNone) |
|
619 { |
|
620 iLog->Log(_L("Missing parameter in config file")); |
|
621 return error; |
|
622 } |
|
623 |
|
624 for( index = 0; index < aCount; index++) |
|
625 { |
|
626 error = iRestrictedAudioOutput->GetAllowedOutput(index, aOutput); |
|
627 if (error == KErrNone) |
|
628 { |
|
629 switch (aOutput) |
|
630 { |
|
631 case 0: // ALL |
|
632 if (ExpectedOutput == KTagAll) |
|
633 { |
|
634 iLog->Log(_L("index = %d, Allow AllAudio"), index); |
|
635 Found = 1; |
|
636 } |
|
637 break; |
|
638 |
|
639 case 1: // Audio Analog |
|
640 if (ExpectedOutput == KTagAudioAnalog) |
|
641 { |
|
642 iLog->Log(_L("index = %d, Allow AudioAnalog"), index); |
|
643 Found = 1; |
|
644 } |
|
645 break; |
|
646 |
|
647 case 2: // AudioFMTransmitter |
|
648 if (ExpectedOutput == KTagFM) |
|
649 { |
|
650 iLog->Log(_L("index = %d, Allow AudioFMTransmitter"), index); |
|
651 Found = 1; |
|
652 } |
|
653 break; |
|
654 |
|
655 case 3: // AudioStereoBtHFP |
|
656 if (ExpectedOutput == KTagStereoBT) |
|
657 { |
|
658 iLog->Log(_L("index = %d, Allow AudioStereoBtHFP"), index); |
|
659 Found = 1; |
|
660 } |
|
661 break; |
|
662 |
|
663 case 4: // AudioBtA2DP |
|
664 if (ExpectedOutput == KTagBTA2DP) |
|
665 { |
|
666 iLog->Log(_L("index = %d, Allow AudioBtA2DP"), index); |
|
667 Found = 1; |
|
668 } |
|
669 break; |
|
670 |
|
671 case 5: // AudioUplink |
|
672 if (ExpectedOutput == KTagAudioUplink) |
|
673 { |
|
674 iLog->Log(_L("index = %d, Allow AudioUplink"), index); |
|
675 Found = 1; |
|
676 } |
|
677 break; |
|
678 |
|
679 case 6: // AudioUsb |
|
680 if (ExpectedOutput == KTagUSB) |
|
681 { |
|
682 iLog->Log(_L("index = %d, Allow AudioUsb"), index); |
|
683 Found = 1; |
|
684 } |
|
685 break; |
|
686 |
|
687 case 7: // Audio Recording |
|
688 if (ExpectedOutput == KTagRecord) |
|
689 { |
|
690 iLog->Log(_L("index = %d, Allow AudioRecording"), index); |
|
691 Found = 1; |
|
692 } |
|
693 break; |
|
694 |
|
695 case 8: // Visualization |
|
696 if (ExpectedOutput == KTagVisualization) |
|
697 { |
|
698 iLog->Log(_L("index = %d, Allow Visualization"), index); |
|
699 Found = 1; |
|
700 } |
|
701 break; |
|
702 |
|
703 default: |
|
704 iLog->Log(_L("unknown audio output")); |
|
705 break; |
|
706 } // switch |
|
707 if (Found == 1) |
|
708 { |
|
709 return error; |
|
710 } |
|
711 |
|
712 } // if |
|
713 } //for |
|
714 |
|
715 if (Found == 0) |
|
716 { |
|
717 error = KErrNotFound; |
|
718 } |
|
719 |
|
720 return error; |
|
721 } |
|
722 |
|
723 // ----------------------------------------------------------------------------- |
|
724 // CRestrictedAOTestClass::Reset |
|
725 // Reset AllowedOutput |
|
726 // ----------------------------------------------------------------------------- |
|
727 // |
|
728 TInt CRestrictedAOTestClass::Reset( CStifItemParser& /*aItem */) |
|
729 { |
|
730 FTRACE(FPrint(_L("CRestrictedAOTestClass::Reset"))); |
|
731 iLog->Log(_L("CRestrictedAOTestClass::Reset")); |
|
732 TInt error = KErrNone; |
|
733 |
|
734 error = iRestrictedAudioOutput->Reset(); |
|
735 |
|
736 return error; |
|
737 } |
|
738 |
|
739 // ----------------------------------------------------------------------------- |
|
740 // CRestrictedAOTestClass::Commit |
|
741 // Commit AllowedOutput |
|
742 // ----------------------------------------------------------------------------- |
|
743 // |
|
744 TInt CRestrictedAOTestClass::Commit( CStifItemParser& /*aItem */) |
|
745 { |
|
746 FTRACE(FPrint(_L("CRestrictedAOTestClass::Commit"))); |
|
747 iLog->Log(_L("CRestrictedAOTestClass::Commit")); |
|
748 TInt error = KErrNone; |
|
749 |
|
750 error = iRestrictedAudioOutput->Commit(); |
|
751 |
|
752 return error; |
|
753 } |
|
754 |
|
755 |
|
756 // ----------------------------------------------------------------------------- |
|
757 // CRestrictedAOTestClass::CreateFactory |
|
758 // Create Factory |
|
759 // ----------------------------------------------------------------------------- |
|
760 // |
|
761 TInt CRestrictedAOTestClass::CreateFactory( CStifItemParser& /*aItem */) |
|
762 { |
|
763 FTRACE(FPrint(_L("CRestrictedAOTestClass::CreateFactory"))); |
|
764 iLog->Log(_L("CRestrictedAOTestClass::CreateFactory")); |
|
765 TInt error = KErrNone; |
|
766 |
|
767 TRAP(error, iDevSound = CMMFDevSound::NewL()) ; |
|
768 // AddExpectedEvent(EInitializeComplete, KMediumTimeout); |
|
769 |
|
770 return error; |
|
771 } |
|
772 |
|
773 // ----------------------------------------------------------------------------- |
|
774 // CRestrictedAOTestClass::CreateRestrictedAO |
|
775 // Create RestrictedAO |
|
776 // ----------------------------------------------------------------------------- |
|
777 // |
|
778 TInt CRestrictedAOTestClass::CreateRestrictedAO( CStifItemParser& /*aItem */) |
|
779 { |
|
780 FTRACE(FPrint(_L("CRestrictedAOTestClass::CreateRestrictedAO"))); |
|
781 iLog->Log(_L("CRestrictedAOTestClass::CreateRestrictedAO")); |
|
782 TInt error = KErrNone; |
|
783 |
|
784 if (iDevSound != NULL) |
|
785 { |
|
786 TRAP(error, iRestrictedAudioOutput = CRestrictedAudioOutputProxy::NewL(*iDevSound)); |
|
787 } |
|
788 else |
|
789 { |
|
790 error = KErrNotSupported; |
|
791 } |
|
792 |
|
793 return error; |
|
794 } |
|
795 |
|
796 // End of File |