|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Implementation of Integraton test step classes for A3F DevSound Tone test cases. |
|
15 // |
|
16 // |
|
17 |
|
18 #include "tsi_a3f_devsound_tone.h" |
|
19 |
|
20 /* |
|
21 * |
|
22 * RTestStepA3FDevSoundToneBase - Test step constructor |
|
23 * |
|
24 */ |
|
25 RTestStepA3FDevSoundToneBase::RTestStepA3FDevSoundToneBase(const TDesC& aTestName, const TDesC& aSectName) |
|
26 :RAsyncTestStep(), |
|
27 iMMFDevSound(NULL), |
|
28 iSectName(aSectName), |
|
29 iTimer(NULL), |
|
30 iCallBack(NULL, NULL), |
|
31 iState(EStateToneStart) |
|
32 { |
|
33 // From RTestStep |
|
34 iTestStepName = aTestName; // store the name of the test case |
|
35 |
|
36 } |
|
37 |
|
38 /* |
|
39 * |
|
40 * RTestStepA3FDevSoundToneBase - Test step constructor |
|
41 * |
|
42 */ |
|
43 RTestStepA3FDevSoundToneBase::RTestStepA3FDevSoundToneBase(const TDesC& aTestName) |
|
44 :RAsyncTestStep(), |
|
45 iMMFDevSound(NULL), |
|
46 iSectName(KNullDesC), |
|
47 iTimer(NULL), |
|
48 iCallBack(NULL, NULL), |
|
49 iState(EStateToneStart) |
|
50 { |
|
51 // From RTestStep |
|
52 iTestStepName = aTestName; // store the name of the test case |
|
53 |
|
54 } |
|
55 |
|
56 /* |
|
57 * |
|
58 * KickoffTestL |
|
59 * - Starts the test |
|
60 * |
|
61 */ |
|
62 void RTestStepA3FDevSoundToneBase::KickoffTestL() |
|
63 { |
|
64 // Create instance of CMMFDevSound |
|
65 INFO_PRINTF1(_L("--- Creating DevSound object...")); |
|
66 iMMFDevSound = CMMFDevSound::NewL(); |
|
67 |
|
68 iTimer = CPeriodic::NewL(CActive::EPriorityHigh); |
|
69 |
|
70 DoKickoffTestL(); |
|
71 |
|
72 Fsm(EEventToneStart,KErrNone); // call to start the DevSound finite state machine for tone playing |
|
73 |
|
74 } |
|
75 |
|
76 /* |
|
77 * |
|
78 * CloseTest |
|
79 * |
|
80 */ |
|
81 void RTestStepA3FDevSoundToneBase::CloseTest() |
|
82 { |
|
83 if (iMMFDevSound) |
|
84 { |
|
85 INFO_PRINTF1(_L("--- Deleting DevSound object...")); |
|
86 delete iMMFDevSound; |
|
87 iMMFDevSound = NULL; |
|
88 } |
|
89 |
|
90 if (iTimer) |
|
91 { |
|
92 delete iTimer; |
|
93 iTimer = NULL; |
|
94 } |
|
95 |
|
96 } |
|
97 |
|
98 /* |
|
99 * |
|
100 * InitializeComplete |
|
101 * |
|
102 */ |
|
103 void RTestStepA3FDevSoundToneBase::InitializeComplete(TInt aError) |
|
104 { |
|
105 Fsm(EEventInitCompleteTone,aError); |
|
106 |
|
107 } |
|
108 |
|
109 /* |
|
110 * |
|
111 * ToneFinished |
|
112 * |
|
113 */ |
|
114 void RTestStepA3FDevSoundToneBase::ToneFinished(TInt aError) |
|
115 { |
|
116 if ((aError == KErrUnderflow)) |
|
117 { |
|
118 INFO_PRINTF2(_L("DevSound called ToneFinished with error = %d as expected"), aError); |
|
119 StopTest(aError,EPass); |
|
120 } |
|
121 else |
|
122 { |
|
123 INFO_PRINTF2(_L("DevSound called ToneFinished with error = %d that was NOT expected"), aError); |
|
124 StopTest(aError); |
|
125 } |
|
126 |
|
127 } |
|
128 |
|
129 /* |
|
130 * |
|
131 * BufferToBeFilled |
|
132 * |
|
133 */ |
|
134 void RTestStepA3FDevSoundToneBase::BufferToBeFilled(CMMFBuffer* /*aBuffer*/) |
|
135 { |
|
136 __ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundToneBase"),EInvalidCallbackCall)); |
|
137 |
|
138 } |
|
139 |
|
140 /* |
|
141 * |
|
142 * PlayError |
|
143 * |
|
144 */ |
|
145 void RTestStepA3FDevSoundToneBase::PlayError(TInt /*aError*/) |
|
146 { |
|
147 __ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundToneBase"),EInvalidCallbackCall)); |
|
148 |
|
149 } |
|
150 |
|
151 /* |
|
152 * |
|
153 * RecordError |
|
154 * |
|
155 */ |
|
156 |
|
157 void RTestStepA3FDevSoundToneBase::RecordError(TInt /*aError*/) |
|
158 { |
|
159 __ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundToneBase"),EInvalidCallbackCall)); |
|
160 |
|
161 } |
|
162 /* |
|
163 * |
|
164 * BufferToBeEmptied |
|
165 * |
|
166 */ |
|
167 |
|
168 void RTestStepA3FDevSoundToneBase::BufferToBeEmptied(CMMFBuffer* /*aBuffer*/) |
|
169 { |
|
170 __ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundToneBase"),EInvalidCallbackCall)); |
|
171 |
|
172 } |
|
173 |
|
174 /* |
|
175 * |
|
176 * ConvertError |
|
177 * |
|
178 */ |
|
179 void RTestStepA3FDevSoundToneBase::ConvertError(TInt /*aError*/) |
|
180 { |
|
181 __ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundToneBase"),EInvalidCallbackCall)); |
|
182 |
|
183 } |
|
184 |
|
185 /* |
|
186 * |
|
187 * DeviceMessage |
|
188 * |
|
189 */ |
|
190 void RTestStepA3FDevSoundToneBase::DeviceMessage(TUid /*aMessageType*/, const TDesC8& /*aMsg*/) |
|
191 { |
|
192 __ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundToneBase"),EInvalidCallbackCall)); |
|
193 |
|
194 } |
|
195 |
|
196 /* |
|
197 * |
|
198 * TimerCallback |
|
199 * |
|
200 */ |
|
201 TInt RTestStepA3FDevSoundToneBase::TimerCallback(TAny* aPtr) |
|
202 { |
|
203 static_cast<RTestStepA3FDevSoundToneBase*>(aPtr)->DoTimerCallback(); |
|
204 return KErrNone; |
|
205 |
|
206 } |
|
207 |
|
208 /* |
|
209 * |
|
210 * DoTimerCallback |
|
211 * |
|
212 */ |
|
213 void RTestStepA3FDevSoundToneBase::DoTimerCallback() |
|
214 { |
|
215 // The derived classes may provide the implementation if needed |
|
216 } |
|
217 |
|
218 /* |
|
219 * |
|
220 * ConvertDesToTMMFSampleRate |
|
221 * |
|
222 */ |
|
223 TUint RTestStepA3FDevSoundToneBase::ConvertDesToTMMFSampleRate(const TDesC& aSampleRateString) |
|
224 { |
|
225 TUint rate = 0; |
|
226 |
|
227 STR_SWITCH(aSampleRateString) |
|
228 |
|
229 STR_CASE(_L("EMMFSampleRate8000Hz")) |
|
230 { |
|
231 rate = EMMFSampleRate8000Hz; |
|
232 break; |
|
233 } |
|
234 STR_CASE(_L("EMMFSampleRate11025Hz")) |
|
235 { |
|
236 rate = EMMFSampleRate11025Hz; |
|
237 break; |
|
238 } |
|
239 STR_CASE(_L("EMMFSampleRate12000Hz")) |
|
240 { |
|
241 rate = EMMFSampleRate12000Hz; |
|
242 break; |
|
243 } |
|
244 STR_CASE(_L("EMMFSampleRate16000Hz")) |
|
245 { |
|
246 rate = EMMFSampleRate16000Hz; |
|
247 break; |
|
248 } |
|
249 STR_CASE(_L("EMMFSampleRate22050Hz")) |
|
250 { |
|
251 rate = EMMFSampleRate22050Hz; |
|
252 break; |
|
253 } |
|
254 STR_CASE(_L("EMMFSampleRate24000Hz")) |
|
255 { |
|
256 rate = EMMFSampleRate24000Hz; |
|
257 break; |
|
258 } |
|
259 STR_CASE(_L("EMMFSampleRate32000Hz")) |
|
260 { |
|
261 rate = EMMFSampleRate32000Hz; |
|
262 break; |
|
263 } |
|
264 STR_CASE(_L("EMMFSampleRate44100Hz")) |
|
265 { |
|
266 rate = EMMFSampleRate44100Hz; |
|
267 break; |
|
268 } |
|
269 STR_CASE(_L("EMMFSampleRate48000Hz")) |
|
270 { |
|
271 rate = EMMFSampleRate48000Hz; |
|
272 break; |
|
273 } |
|
274 STR_CASE(_L("EMMFSampleRate64000Hz")) |
|
275 { |
|
276 rate = EMMFSampleRate64000Hz; |
|
277 break; |
|
278 } |
|
279 STR_CASE(_L("EMMFSampleRate88200Hz")) |
|
280 { |
|
281 rate = EMMFSampleRate88200Hz; |
|
282 break; |
|
283 } |
|
284 STR_CASE(_L("EMMFSampleRate96000Hz")) |
|
285 { |
|
286 rate = EMMFSampleRate96000Hz; |
|
287 break; |
|
288 } |
|
289 STR_CASE(_L("InvalidRate")) |
|
290 { |
|
291 rate = 0x90000000; |
|
292 break; |
|
293 } |
|
294 |
|
295 DEFAULT_CASE() |
|
296 { |
|
297 ERR_PRINTF1(_L("Attempt to convert invalid sample rate")); |
|
298 StopTest(KErrGeneral); |
|
299 } |
|
300 |
|
301 STR_SWITCH_END() |
|
302 |
|
303 INFO_PRINTF2(_L("Sample Rate = %S"), &aSampleRateString); |
|
304 return rate; |
|
305 |
|
306 } |
|
307 |
|
308 // |
|
309 // RStepA3FDevSoundDTMFTonePlay |
|
310 // |
|
311 |
|
312 /* |
|
313 * |
|
314 * RStepA3FDevSoundDTMFTonePlay - Test step constructor |
|
315 * |
|
316 */ |
|
317 RStepA3FDevSoundDTMFTonePlay::RStepA3FDevSoundDTMFTonePlay(const TDesC& aTestName) |
|
318 :RTestStepA3FDevSoundToneBase(aTestName) |
|
319 { |
|
320 } |
|
321 |
|
322 /* |
|
323 * |
|
324 * NewL |
|
325 * |
|
326 */ |
|
327 RStepA3FDevSoundDTMFTonePlay* RStepA3FDevSoundDTMFTonePlay::NewL(const TDesC& aTestName) |
|
328 { |
|
329 RStepA3FDevSoundDTMFTonePlay* self = new (ELeave) RStepA3FDevSoundDTMFTonePlay(aTestName); |
|
330 return self; |
|
331 |
|
332 } |
|
333 |
|
334 /* |
|
335 * |
|
336 * DoKickoffTestL |
|
337 * |
|
338 */ |
|
339 void RStepA3FDevSoundDTMFTonePlay::DoKickoffTestL() |
|
340 { |
|
341 } |
|
342 |
|
343 /* |
|
344 * |
|
345 * Fsm |
|
346 * - Executes DTMF tone playing events of DevSound in sequence |
|
347 * |
|
348 */ |
|
349 void RStepA3FDevSoundDTMFTonePlay::Fsm(TDevSoundToneEvents aDevSoundEvent, TInt aError) |
|
350 { |
|
351 switch (iState) |
|
352 { |
|
353 case EStateToneStart: |
|
354 { |
|
355 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundDTMFTonePlay"),EFsmIncorrectErrorPassed)); |
|
356 if (aDevSoundEvent == EEventToneStart) |
|
357 { |
|
358 // Initializing DevSound object for tone play |
|
359 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
360 TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying)); |
|
361 if (err != KErrNone) |
|
362 { |
|
363 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
364 StopTest(err); |
|
365 break; |
|
366 } |
|
367 INFO_PRINTF1(_L("State: EStateToneInitializing")); |
|
368 iState = EStateToneInitializing; |
|
369 } |
|
370 else |
|
371 { |
|
372 ERR_PRINTF2(_L("DevSound EEventToneStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
373 StopTest(aError, EFail); |
|
374 } |
|
375 |
|
376 break; |
|
377 |
|
378 } |
|
379 |
|
380 case EStateToneInitializing: |
|
381 { |
|
382 if (aDevSoundEvent == EEventInitCompleteTone && aError == KErrNone) |
|
383 { |
|
384 TPtrC dtmfString = (_L("0123456789,abcdef,*#")); |
|
385 TTimeIntervalMicroSeconds32 on(KMicroSecsInOneSec), off(KMicroSecsInOneSec), pause(0); |
|
386 // Define the duration of tone on, tone off and tone pause to be used during the DTMF tone playback operation |
|
387 INFO_PRINTF1(_L("Calling CMMFDevSound::SetDTMFLengths")); |
|
388 iMMFDevSound->SetDTMFLengths(on,off,pause); |
|
389 // Initialize the audio device and start playing the DTMF string |
|
390 INFO_PRINTF1(_L("Calling CMMFDevSound::PlayDTMFStringL")); |
|
391 TRAPD(err, iMMFDevSound->PlayDTMFStringL(dtmfString)); |
|
392 if (err != KErrNone) |
|
393 { |
|
394 ERR_PRINTF2(_L("CMMFDevSound::PlayDTMFStringL left with error = %d"), err); |
|
395 StopTest(err); |
|
396 break; |
|
397 } |
|
398 INFO_PRINTF1(_L("State: EStateTonePlaying")); |
|
399 iState = EStateTonePlaying; |
|
400 |
|
401 } |
|
402 else if (aDevSoundEvent == EEventInitCompleteTone && aError != KErrNone) |
|
403 { |
|
404 ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError); |
|
405 StopTest(aError); |
|
406 } |
|
407 else |
|
408 { |
|
409 ERR_PRINTF2(_L("DevSound EEventInitCompleteTone not received as expected. Received event: %d"), aDevSoundEvent); |
|
410 StopTest(aError, EFail); |
|
411 } |
|
412 |
|
413 break; |
|
414 |
|
415 } |
|
416 |
|
417 default: |
|
418 { |
|
419 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iState); |
|
420 StopTest(KErrGeneral); |
|
421 } |
|
422 } |
|
423 |
|
424 } |
|
425 |
|
426 // |
|
427 // RStepA3FDevSoundNormalAndDualTonePlay |
|
428 // |
|
429 |
|
430 /* |
|
431 * |
|
432 * RStepA3FDevSoundNormalAndDualTonePlay - Test step constructor |
|
433 * |
|
434 */ |
|
435 RStepA3FDevSoundNormalAndDualTonePlay::RStepA3FDevSoundNormalAndDualTonePlay(const TDesC& aTestName, const TDesC& aSectName) |
|
436 :RTestStepA3FDevSoundToneBase(aTestName, aSectName), |
|
437 iRepeat(0), |
|
438 iDualTone(EFalse) |
|
439 { |
|
440 } |
|
441 |
|
442 /* |
|
443 * |
|
444 * NewL |
|
445 * |
|
446 */ |
|
447 RStepA3FDevSoundNormalAndDualTonePlay* RStepA3FDevSoundNormalAndDualTonePlay::NewL(const TDesC& aTestName, const TDesC& aSectName) |
|
448 { |
|
449 RStepA3FDevSoundNormalAndDualTonePlay* self = new (ELeave) RStepA3FDevSoundNormalAndDualTonePlay(aTestName, aSectName); |
|
450 return self; |
|
451 |
|
452 } |
|
453 |
|
454 /* |
|
455 * |
|
456 * DoKickoffTestL |
|
457 * |
|
458 */ |
|
459 void RStepA3FDevSoundNormalAndDualTonePlay::DoKickoffTestL() |
|
460 { |
|
461 //Getting the number of times the audio is to be repeated during the tone playback operation |
|
462 if (GetIntFromConfig(iSectName,_L("Repeat"),iRepeat)) |
|
463 { |
|
464 INFO_PRINTF2(_L("Repeat count taken from config file: %d"),iRepeat); |
|
465 } |
|
466 else |
|
467 { |
|
468 INFO_PRINTF2(_L("Default repeat count used: %d"), iRepeat); |
|
469 } |
|
470 |
|
471 // Getting the boolean flag value indicating whether dual tone playback should occur instead of the normal tone playback |
|
472 if (GetBoolFromConfig(iSectName,_L("DualTone"),iDualTone)) |
|
473 { |
|
474 INFO_PRINTF2(_L("Boolean value indicating whether to use dual tone playback taken from config file: %d"),iDualTone); |
|
475 } |
|
476 else |
|
477 { |
|
478 INFO_PRINTF2(_L("Default boolean value indicating whether to use dual tone playback used: %d"), iDualTone); |
|
479 } |
|
480 |
|
481 } |
|
482 |
|
483 /* |
|
484 * |
|
485 * Fsm |
|
486 * - Executes either the normal or dual tone playing events of DevSound in sequence |
|
487 * |
|
488 */ |
|
489 void RStepA3FDevSoundNormalAndDualTonePlay::Fsm(TDevSoundToneEvents aDevSoundEvent, TInt aError) |
|
490 { |
|
491 switch (iState) |
|
492 { |
|
493 case EStateToneStart: |
|
494 { |
|
495 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundNormalAndDualTonePlay"),EFsmIncorrectErrorPassed)); |
|
496 if (aDevSoundEvent == EEventToneStart) |
|
497 { |
|
498 // Initializing DevSound object for tone play |
|
499 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
500 TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying)); |
|
501 if (err != KErrNone) |
|
502 { |
|
503 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
504 StopTest(err); |
|
505 break; |
|
506 } |
|
507 INFO_PRINTF1(_L("State: EStateToneInitializing")); |
|
508 iState = EStateToneInitializing; |
|
509 } |
|
510 else |
|
511 { |
|
512 ERR_PRINTF2(_L("DevSound EEventToneStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
513 StopTest(aError, EFail); |
|
514 } |
|
515 |
|
516 break; |
|
517 |
|
518 } |
|
519 |
|
520 case EStateToneInitializing: |
|
521 { |
|
522 if (aDevSoundEvent == EEventInitCompleteTone && aError == KErrNone) |
|
523 { |
|
524 TTimeIntervalMicroSeconds repeatTrailingSilence(KMicroSecsInOneSec), duration(KMicroSecsInOneSec); |
|
525 // Define the number of times the audio is to be repeated during the tone playback operation |
|
526 INFO_PRINTF1(_L("Calling CMMFDevSound::SetToneRepeats")); |
|
527 iMMFDevSound->SetToneRepeats(iRepeat, repeatTrailingSilence); |
|
528 if (iDualTone) |
|
529 { |
|
530 // Initialize audio device and start playing a dual tone |
|
531 INFO_PRINTF1(_L("Calling CMMFDevSound::PlayDualToneL")); |
|
532 TRAPD(err, iMMFDevSound->PlayDualToneL(KFrequency1, KFrequency2, duration)); |
|
533 if (err != KErrNone) |
|
534 { |
|
535 ERR_PRINTF2(_L("CMMFDevSound::PlayDualToneL left with error = %d"), err); |
|
536 StopTest(err); |
|
537 break; |
|
538 } |
|
539 } |
|
540 else |
|
541 { |
|
542 // Initialize the audio device and start playing a tone |
|
543 INFO_PRINTF1(_L("Calling CMMFDevSound::PlayToneL")); |
|
544 TRAPD(err, iMMFDevSound->PlayToneL(KFrequency1, duration)); |
|
545 if (err != KErrNone) |
|
546 { |
|
547 ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error = %d"), err); |
|
548 StopTest(err); |
|
549 break; |
|
550 } |
|
551 } |
|
552 INFO_PRINTF1(_L("State: EStateTonePlaying")); |
|
553 iState = EStateTonePlaying; |
|
554 |
|
555 } |
|
556 else if (aDevSoundEvent == EEventInitCompleteTone && aError != KErrNone) |
|
557 { |
|
558 ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError); |
|
559 StopTest(aError); |
|
560 } |
|
561 else |
|
562 { |
|
563 ERR_PRINTF2(_L("DevSound EEventInitCompleteTone not received as expected. Received event: %d"), aDevSoundEvent); |
|
564 StopTest(aError, EFail); |
|
565 } |
|
566 |
|
567 break; |
|
568 |
|
569 } |
|
570 |
|
571 default: |
|
572 { |
|
573 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iState); |
|
574 StopTest(KErrGeneral); |
|
575 } |
|
576 } |
|
577 |
|
578 } |
|
579 |
|
580 // |
|
581 // RStepA3FDevSoundInitializeWhileTonePlaying |
|
582 // |
|
583 |
|
584 /* |
|
585 * |
|
586 * RStepA3FDevSoundInitializeWhileTonePlaying - Test step constructor |
|
587 * |
|
588 */ |
|
589 RStepA3FDevSoundInitializeWhileTonePlaying::RStepA3FDevSoundInitializeWhileTonePlaying(const TDesC& aTestName) |
|
590 :RTestStepA3FDevSoundToneBase(aTestName) |
|
591 { |
|
592 } |
|
593 |
|
594 /* |
|
595 * |
|
596 * NewL |
|
597 * |
|
598 */ |
|
599 RStepA3FDevSoundInitializeWhileTonePlaying* RStepA3FDevSoundInitializeWhileTonePlaying::NewL(const TDesC& aTestName) |
|
600 { |
|
601 RStepA3FDevSoundInitializeWhileTonePlaying* self = new (ELeave) RStepA3FDevSoundInitializeWhileTonePlaying(aTestName); |
|
602 return self; |
|
603 |
|
604 } |
|
605 |
|
606 /* |
|
607 * |
|
608 * DoKickoffTestL |
|
609 * |
|
610 */ |
|
611 void RStepA3FDevSoundInitializeWhileTonePlaying::DoKickoffTestL() |
|
612 { |
|
613 } |
|
614 |
|
615 /* |
|
616 * |
|
617 * Fsm |
|
618 * |
|
619 */ |
|
620 void RStepA3FDevSoundInitializeWhileTonePlaying::Fsm(TDevSoundToneEvents aDevSoundEvent, TInt aError) |
|
621 { |
|
622 switch (iState) |
|
623 { |
|
624 case EStateToneStart: |
|
625 { |
|
626 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInitializeWhileTonePlaying"),EFsmIncorrectErrorPassed)); |
|
627 if (aDevSoundEvent == EEventToneStart) |
|
628 { |
|
629 // Initializing DevSound object for tone play |
|
630 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
631 TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying)); |
|
632 if (err != KErrNone) |
|
633 { |
|
634 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
635 StopTest(err); |
|
636 break; |
|
637 } |
|
638 INFO_PRINTF1(_L("State: EStateToneInitializing")); |
|
639 iState = EStateToneInitializing; |
|
640 } |
|
641 else |
|
642 { |
|
643 ERR_PRINTF2(_L("DevSound EEventToneStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
644 StopTest(aError, EFail); |
|
645 } |
|
646 |
|
647 break; |
|
648 |
|
649 } |
|
650 |
|
651 case EStateToneInitializing: |
|
652 { |
|
653 if (aDevSoundEvent == EEventInitCompleteTone && aError == KErrNone) |
|
654 { |
|
655 TTimeIntervalMicroSeconds duration(KMicroSecsInTenSecs); |
|
656 // Initialize the audio device and start playing a tone |
|
657 INFO_PRINTF1(_L("Calling CMMFDevSound::PlayToneL")); |
|
658 TRAPD(err, iMMFDevSound->PlayToneL(KFrequency1, duration)); |
|
659 if (err != KErrNone) |
|
660 { |
|
661 ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error = %d"), err); |
|
662 StopTest(err); |
|
663 break; |
|
664 } |
|
665 INFO_PRINTF1(_L("State: EStateTonePlaying")); |
|
666 iState = EStateTonePlaying; |
|
667 |
|
668 // Calling CMMFDevSound::InitializeL again while tone playing! |
|
669 INFO_PRINTF1(_L("CMMFDevSound::InitializeL called again while tone playing!")); |
|
670 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying)); |
|
671 if (err == KErrNotReady) |
|
672 { |
|
673 INFO_PRINTF2(_L("CMMFDevSound::InitializeL left as expected with error = %d"), err); |
|
674 StopTest(err,EPass); |
|
675 } |
|
676 else |
|
677 { |
|
678 ERR_PRINTF2(_L("CMMFDevSound::InitializeL did NOT leave with KErrNotReady as expected. Error = %d"), err); |
|
679 StopTest(KErrUnknown); |
|
680 } |
|
681 } |
|
682 else if (aDevSoundEvent == EEventInitCompleteTone && aError != KErrNone) |
|
683 { |
|
684 ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError); |
|
685 StopTest(aError); |
|
686 } |
|
687 else |
|
688 { |
|
689 ERR_PRINTF2(_L("DevSound EEventInitCompleteTone not received as expected. Received event: %d"), aDevSoundEvent); |
|
690 StopTest(aError, EFail); |
|
691 } |
|
692 |
|
693 break; |
|
694 |
|
695 } |
|
696 |
|
697 default: |
|
698 { |
|
699 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iState); |
|
700 StopTest(KErrGeneral); |
|
701 } |
|
702 } |
|
703 |
|
704 } |
|
705 |
|
706 // |
|
707 // RStepA3FDevSoundNotSupportedPlayFixedSeq |
|
708 // |
|
709 |
|
710 /* |
|
711 * |
|
712 * RStepA3FDevSoundNotSupportedPlayFixedSeq - Test step constructor |
|
713 * |
|
714 */ |
|
715 RStepA3FDevSoundNotSupportedPlayFixedSeq::RStepA3FDevSoundNotSupportedPlayFixedSeq(const TDesC& aTestName) |
|
716 :RTestStepA3FDevSoundToneBase(aTestName) |
|
717 { |
|
718 } |
|
719 |
|
720 /* |
|
721 * |
|
722 * NewL |
|
723 * |
|
724 */ |
|
725 RStepA3FDevSoundNotSupportedPlayFixedSeq* RStepA3FDevSoundNotSupportedPlayFixedSeq::NewL(const TDesC& aTestName) |
|
726 { |
|
727 RStepA3FDevSoundNotSupportedPlayFixedSeq* self = new (ELeave) RStepA3FDevSoundNotSupportedPlayFixedSeq(aTestName); |
|
728 return self; |
|
729 |
|
730 } |
|
731 |
|
732 /* |
|
733 * |
|
734 * DoKickoffTestL |
|
735 * |
|
736 */ |
|
737 void RStepA3FDevSoundNotSupportedPlayFixedSeq::DoKickoffTestL() |
|
738 { |
|
739 } |
|
740 |
|
741 /* |
|
742 * |
|
743 * Fsm |
|
744 * |
|
745 */ |
|
746 void RStepA3FDevSoundNotSupportedPlayFixedSeq::Fsm(TDevSoundToneEvents aDevSoundEvent, TInt aError) |
|
747 { |
|
748 switch (iState) |
|
749 { |
|
750 case EStateToneStart: |
|
751 { |
|
752 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundNotSupportedPlayFixedSeq"),EFsmIncorrectErrorPassed)); |
|
753 if (aDevSoundEvent == EEventToneStart) |
|
754 { |
|
755 // Initializing DevSound object for tone play |
|
756 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
757 TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying)); |
|
758 if (err != KErrNone) |
|
759 { |
|
760 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
761 StopTest(err); |
|
762 break; |
|
763 } |
|
764 INFO_PRINTF1(_L("State: EStateToneInitializing")); |
|
765 iState = EStateToneInitializing; |
|
766 } |
|
767 else |
|
768 { |
|
769 ERR_PRINTF2(_L("DevSound EEventToneStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
770 StopTest(aError, EFail); |
|
771 } |
|
772 |
|
773 break; |
|
774 |
|
775 } |
|
776 |
|
777 case EStateToneInitializing: |
|
778 { |
|
779 if (aDevSoundEvent == EEventInitCompleteTone && aError == KErrNone) |
|
780 { |
|
781 TInt seqCount = iMMFDevSound->FixedSequenceCount(); |
|
782 if (seqCount != 0) |
|
783 { |
|
784 ERR_PRINTF2(_L("CMMFDevSound::FixedSequenceCount() did not return 0 as always expected. It returned %d instead!"), seqCount); |
|
785 } |
|
786 else |
|
787 { |
|
788 INFO_PRINTF1(_L("CMMFDevSound::FixedSequenceCount() call returned 0 as always expected")); |
|
789 } |
|
790 // Initialize the audio device and start playing the specified pre-defined tone sequence. |
|
791 INFO_PRINTF1(_L("Calling the not supported CMMFDevSound::PlayFixedSequenceL")); |
|
792 TRAPD(err, iMMFDevSound->PlayFixedSequenceL(0)); |
|
793 if (err == KErrNotSupported) |
|
794 { |
|
795 INFO_PRINTF2(_L("CMMFDevSound::PlayFixedSequenceL left as expected with error = %d"), err); |
|
796 StopTest(err,EPass); |
|
797 } |
|
798 else |
|
799 { |
|
800 ERR_PRINTF2(_L("CMMFDevSound::PlayFixedSequenceL did NOT leave with KErrNotSupported as expected. Error = %d"), err); |
|
801 StopTest(KErrUnknown); |
|
802 } |
|
803 } |
|
804 else if (aDevSoundEvent == EEventInitCompleteTone && aError != KErrNone) |
|
805 { |
|
806 ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError); |
|
807 StopTest(aError); |
|
808 } |
|
809 else |
|
810 { |
|
811 ERR_PRINTF2(_L("DevSound EEventInitCompleteTone not received as expected. Received event: %d"), aDevSoundEvent); |
|
812 StopTest(aError, EFail); |
|
813 } |
|
814 |
|
815 break; |
|
816 |
|
817 } |
|
818 |
|
819 default: |
|
820 { |
|
821 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iState); |
|
822 StopTest(KErrGeneral); |
|
823 } |
|
824 } |
|
825 |
|
826 } |
|
827 |
|
828 // |
|
829 // RStepA3FDevSoundInvalidInitializeForTone |
|
830 // |
|
831 |
|
832 /* |
|
833 * |
|
834 * RStepA3FDevSoundInvalidInitializeForTone - Test step constructor |
|
835 * |
|
836 */ |
|
837 RStepA3FDevSoundInvalidInitializeForTone::RStepA3FDevSoundInvalidInitializeForTone(const TDesC& aTestName) |
|
838 :RTestStepA3FDevSoundToneBase(aTestName) |
|
839 { |
|
840 } |
|
841 |
|
842 /* |
|
843 * |
|
844 * NewL |
|
845 * |
|
846 */ |
|
847 RStepA3FDevSoundInvalidInitializeForTone* RStepA3FDevSoundInvalidInitializeForTone::NewL(const TDesC& aTestName) |
|
848 { |
|
849 RStepA3FDevSoundInvalidInitializeForTone* self = new (ELeave) RStepA3FDevSoundInvalidInitializeForTone(aTestName); |
|
850 return self; |
|
851 |
|
852 } |
|
853 |
|
854 /* |
|
855 * |
|
856 * DoKickoffTestL |
|
857 * |
|
858 */ |
|
859 void RStepA3FDevSoundInvalidInitializeForTone::DoKickoffTestL() |
|
860 { |
|
861 } |
|
862 |
|
863 /* |
|
864 * |
|
865 * Fsm |
|
866 * |
|
867 */ |
|
868 void RStepA3FDevSoundInvalidInitializeForTone::Fsm(TDevSoundToneEvents aDevSoundEvent, TInt aError) |
|
869 { |
|
870 switch (iState) |
|
871 { |
|
872 case EStateToneStart: |
|
873 { |
|
874 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInvalidInitializeForTone"),EFsmIncorrectErrorPassed)); |
|
875 if (aDevSoundEvent == EEventToneStart) |
|
876 { |
|
877 TFourCC fourCCCodeMP3(KMMFFourCCCodeMP3); |
|
878 // Initializing DevSound object for tone play using invalid version of CMMFDevSound::InitializeL |
|
879 INFO_PRINTF1(_L("Calling invalid version of CMMFDevSound::InitializeL for tone play...")); |
|
880 TRAPD(err, iMMFDevSound->InitializeL(*this, fourCCCodeMP3, EMMFStateTonePlaying)); |
|
881 if (err == KErrNotSupported) |
|
882 { |
|
883 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left as expected with error = %d"), err); |
|
884 StopTest(err,EPass); |
|
885 } |
|
886 else |
|
887 { |
|
888 ERR_PRINTF2(_L("CMMFDevSound::InitializeL did NOT leave with KErrNotSupported as expected. Error = %d"), err); |
|
889 StopTest(KErrUnknown); |
|
890 } |
|
891 } |
|
892 else |
|
893 { |
|
894 ERR_PRINTF2(_L("DevSound EEventToneStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
895 StopTest(aError, EFail); |
|
896 } |
|
897 |
|
898 break; |
|
899 |
|
900 } |
|
901 |
|
902 default: |
|
903 { |
|
904 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iState); |
|
905 StopTest(KErrGeneral); |
|
906 } |
|
907 } |
|
908 |
|
909 } |
|
910 |
|
911 // |
|
912 // RStepA3FDevSoundCancelInitializeTone |
|
913 // |
|
914 |
|
915 /* |
|
916 * |
|
917 * RStepA3FDevSoundCancelInitializeTone - Test step constructor |
|
918 * |
|
919 */ |
|
920 RStepA3FDevSoundCancelInitializeTone::RStepA3FDevSoundCancelInitializeTone(const TDesC& aTestName, const TDesC& aSectName) |
|
921 :RTestStepA3FDevSoundToneBase(aTestName, aSectName) |
|
922 { |
|
923 } |
|
924 |
|
925 /* |
|
926 * |
|
927 * NewL |
|
928 * |
|
929 */ |
|
930 RStepA3FDevSoundCancelInitializeTone* RStepA3FDevSoundCancelInitializeTone::NewL(const TDesC& aTestName, const TDesC& aSectName) |
|
931 { |
|
932 RStepA3FDevSoundCancelInitializeTone* self = new (ELeave) RStepA3FDevSoundCancelInitializeTone(aTestName, aSectName); |
|
933 return self; |
|
934 |
|
935 } |
|
936 |
|
937 /* |
|
938 * |
|
939 * DoKickoffTestL |
|
940 * |
|
941 */ |
|
942 void RStepA3FDevSoundCancelInitializeTone::DoKickoffTestL() |
|
943 { |
|
944 } |
|
945 |
|
946 /* |
|
947 * |
|
948 * InitializeComplete |
|
949 * |
|
950 */ |
|
951 void RStepA3FDevSoundCancelInitializeTone::InitializeComplete(TInt aError) |
|
952 { |
|
953 INFO_PRINTF1(_L("InitializeComplete callback was received. This is not the expected behaviour")); |
|
954 INFO_PRINTF1(_L("InitializeL was not cancelled")); |
|
955 StopTest(aError, EFail); |
|
956 } |
|
957 |
|
958 /* |
|
959 * |
|
960 * DoTimerCallback |
|
961 * |
|
962 */ |
|
963 void RStepA3FDevSoundCancelInitializeTone::DoTimerCallback() |
|
964 { |
|
965 iTimer->Cancel(); // only really wanted a one-shot |
|
966 INFO_PRINTF1(_L("InitializeComplete callback was not received. This is the expected behaviour")); |
|
967 INFO_PRINTF1(_L("Use SetConfigL to verify that DevSound has not been initialised")); |
|
968 TMMFCapabilities capabilities; |
|
969 |
|
970 if(!GetStringFromConfig(iSectName, _L("SampleRate"), iSampleRate)) |
|
971 { |
|
972 TPtrC keyName(_L("SampleRate")); |
|
973 ERR_PRINTF3(_L("Error in getting sample rate from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
974 StopTest(KErrPathNotFound); |
|
975 return; |
|
976 } |
|
977 |
|
978 capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate); |
|
979 TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities)); |
|
980 if(errConfig == KErrNotReady) |
|
981 { |
|
982 INFO_PRINTF2(_L("SetConfigL returned with %d as expected"), errConfig); |
|
983 INFO_PRINTF1(_L("InitializeL was cancelled successfully")); |
|
984 StopTest(KErrNone); |
|
985 } |
|
986 else if (errConfig == KErrNone) |
|
987 { |
|
988 INFO_PRINTF2(_L("SetConfigL returned with KErrNone %d"), errConfig); |
|
989 INFO_PRINTF1(_L("InitializeL was not cancelled successfully")); |
|
990 StopTest(errConfig, EFail); |
|
991 } |
|
992 else |
|
993 { |
|
994 INFO_PRINTF2(_L("SetConfigL returned with unexpected error %d"), errConfig); |
|
995 StopTest(errConfig, EFail); |
|
996 } |
|
997 } |
|
998 |
|
999 /* |
|
1000 * |
|
1001 * Fsm |
|
1002 * - Executes Toneing events of DevSound in sequence |
|
1003 * |
|
1004 */ |
|
1005 void RStepA3FDevSoundCancelInitializeTone::Fsm(TDevSoundToneEvents aDevSoundEvent, TInt aError) |
|
1006 { |
|
1007 switch (iState) |
|
1008 { |
|
1009 case EStateToneStart: |
|
1010 { |
|
1011 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundCancelInitializeTone"),EFsmIncorrectErrorPassed)); |
|
1012 if (aDevSoundEvent == EEventToneStart) |
|
1013 { |
|
1014 // Initializing DevSound object for TonePlaying mode |
|
1015 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
1016 TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying)); |
|
1017 if (err != KErrNone) |
|
1018 { |
|
1019 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
1020 StopTest(err); |
|
1021 break; |
|
1022 } |
|
1023 else |
|
1024 { |
|
1025 INFO_PRINTF1(_L("State: EStateToneInitializing")); |
|
1026 iState = EStateToneInitializing; |
|
1027 INFO_PRINTF1(_L("Calling CMMFDevSound::CancelInitialize()")); |
|
1028 iMMFDevSound->CancelInitialize(); |
|
1029 INFO_PRINTF1(_L("Start timer to wait for InitializeComplete")); |
|
1030 TCallBack callback (TimerCallback, this); |
|
1031 iTimer->Start(KMicroSecsInTenSecs, 0, callback); |
|
1032 } |
|
1033 } |
|
1034 else |
|
1035 { |
|
1036 ERR_PRINTF2(_L("DevSound EEventToneStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
1037 StopTest(aError, EFail); |
|
1038 } |
|
1039 break; |
|
1040 } |
|
1041 default: |
|
1042 { |
|
1043 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iState); |
|
1044 StopTest(KErrGeneral); |
|
1045 } |
|
1046 } |
|
1047 |
|
1048 } |
|
1049 |
|
1050 // |
|
1051 // RStepA3FDevSoundEmptyBuffersInitializedForTone |
|
1052 // |
|
1053 |
|
1054 /* |
|
1055 * |
|
1056 * RStepA3FDevSoundInitializeWhileTonePlaying - Test step constructor |
|
1057 * |
|
1058 */ |
|
1059 RStepA3FDevSoundEmptyBuffersInitializedForTone::RStepA3FDevSoundEmptyBuffersInitializedForTone(const TDesC& aTestName, const TDesC& aSectName) |
|
1060 :RTestStepA3FDevSoundToneBase(aTestName, aSectName) |
|
1061 { |
|
1062 } |
|
1063 |
|
1064 /* |
|
1065 * |
|
1066 * NewL |
|
1067 * |
|
1068 */ |
|
1069 RStepA3FDevSoundEmptyBuffersInitializedForTone* RStepA3FDevSoundEmptyBuffersInitializedForTone::NewL(const TDesC& aTestName, const TDesC& aSectName) |
|
1070 { |
|
1071 RStepA3FDevSoundEmptyBuffersInitializedForTone* self = new (ELeave) RStepA3FDevSoundEmptyBuffersInitializedForTone(aTestName, aSectName); |
|
1072 return self; |
|
1073 |
|
1074 } |
|
1075 |
|
1076 /* |
|
1077 * |
|
1078 * DoKickoffTestL |
|
1079 * |
|
1080 */ |
|
1081 void RStepA3FDevSoundEmptyBuffersInitializedForTone::DoKickoffTestL() |
|
1082 { |
|
1083 } |
|
1084 |
|
1085 /* |
|
1086 * |
|
1087 * Fsm |
|
1088 * |
|
1089 */ |
|
1090 void RStepA3FDevSoundEmptyBuffersInitializedForTone::Fsm(TDevSoundToneEvents aDevSoundEvent, TInt aError) |
|
1091 { |
|
1092 switch (iState) |
|
1093 { |
|
1094 case EStateToneStart: |
|
1095 { |
|
1096 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInitializeWhileTonePlaying"),EFsmIncorrectErrorPassed)); |
|
1097 if (aDevSoundEvent == EEventToneStart) |
|
1098 { |
|
1099 // Initializing DevSound object for tone play |
|
1100 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
1101 TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying)); |
|
1102 if (err != KErrNone) |
|
1103 { |
|
1104 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
1105 StopTest(err); |
|
1106 break; |
|
1107 } |
|
1108 INFO_PRINTF1(_L("State: EStateToneInitializing")); |
|
1109 iState = EStateToneInitializing; |
|
1110 } |
|
1111 else |
|
1112 { |
|
1113 ERR_PRINTF2(_L("DevSound EEventToneStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
1114 StopTest(aError, EFail); |
|
1115 } |
|
1116 |
|
1117 break; |
|
1118 |
|
1119 } |
|
1120 |
|
1121 case EStateToneInitializing: |
|
1122 { |
|
1123 if (aDevSoundEvent == EEventInitCompleteTone && aError == KErrNone) |
|
1124 { |
|
1125 // Calling EmptyBuffers |
|
1126 INFO_PRINTF1(_L("Calling CMMFDevSound::EmptyBuffers()")); |
|
1127 TInt err; |
|
1128 err = iMMFDevSound->EmptyBuffers(); |
|
1129 if (err == KErrNotSupported) |
|
1130 { |
|
1131 ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() returned expected error = %d"), err); |
|
1132 StopTest(); |
|
1133 } |
|
1134 else |
|
1135 { |
|
1136 ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() did not return KErrNotSupported as expected. Returned with unexpected error = %d"), err); |
|
1137 StopTest(err); |
|
1138 } |
|
1139 } |
|
1140 else if (aDevSoundEvent == EEventInitCompleteTone && aError != KErrNone) |
|
1141 { |
|
1142 ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError); |
|
1143 StopTest(aError); |
|
1144 } |
|
1145 else |
|
1146 { |
|
1147 ERR_PRINTF2(_L("DevSound EEventInitCompleteTone not received as expected. Received event: %d"), aDevSoundEvent); |
|
1148 StopTest(aError, EFail); |
|
1149 } |
|
1150 |
|
1151 break; |
|
1152 |
|
1153 } |
|
1154 |
|
1155 default: |
|
1156 { |
|
1157 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iState); |
|
1158 StopTest(KErrGeneral); |
|
1159 } |
|
1160 } |
|
1161 } |
|
1162 |
|
1163 // |
|
1164 // RStepA3FDevSoundEmptyBuffersWhileTonePlaying |
|
1165 // |
|
1166 |
|
1167 /* |
|
1168 * |
|
1169 * RStepA3FDevSoundEmptyBuffersWhileTonePlaying - Test step constructor |
|
1170 * |
|
1171 */ |
|
1172 RStepA3FDevSoundEmptyBuffersWhileTonePlaying::RStepA3FDevSoundEmptyBuffersWhileTonePlaying(const TDesC& aTestName) |
|
1173 :RTestStepA3FDevSoundToneBase(aTestName) |
|
1174 { |
|
1175 } |
|
1176 |
|
1177 /* |
|
1178 * |
|
1179 * NewL |
|
1180 * |
|
1181 */ |
|
1182 RStepA3FDevSoundEmptyBuffersWhileTonePlaying* RStepA3FDevSoundEmptyBuffersWhileTonePlaying::NewL(const TDesC& aTestName) |
|
1183 { |
|
1184 RStepA3FDevSoundEmptyBuffersWhileTonePlaying* self = new (ELeave) RStepA3FDevSoundEmptyBuffersWhileTonePlaying(aTestName); |
|
1185 return self; |
|
1186 |
|
1187 } |
|
1188 |
|
1189 /* |
|
1190 * |
|
1191 * DoKickoffTestL |
|
1192 * |
|
1193 */ |
|
1194 void RStepA3FDevSoundEmptyBuffersWhileTonePlaying::DoKickoffTestL() |
|
1195 { |
|
1196 } |
|
1197 |
|
1198 /* |
|
1199 * |
|
1200 * Fsm |
|
1201 * |
|
1202 */ |
|
1203 void RStepA3FDevSoundEmptyBuffersWhileTonePlaying::Fsm(TDevSoundToneEvents aDevSoundEvent, TInt aError) |
|
1204 { |
|
1205 switch (iState) |
|
1206 { |
|
1207 case EStateToneStart: |
|
1208 { |
|
1209 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundEmptyBuffersWhileTonePlaying"),EFsmIncorrectErrorPassed)); |
|
1210 if (aDevSoundEvent == EEventToneStart) |
|
1211 { |
|
1212 // Initializing DevSound object for tone play |
|
1213 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
1214 TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying)); |
|
1215 if (err != KErrNone) |
|
1216 { |
|
1217 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
1218 StopTest(err); |
|
1219 break; |
|
1220 } |
|
1221 INFO_PRINTF1(_L("State: EStateToneInitializing")); |
|
1222 iState = EStateToneInitializing; |
|
1223 } |
|
1224 else |
|
1225 { |
|
1226 ERR_PRINTF2(_L("DevSound EEventToneStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
1227 StopTest(aError, EFail); |
|
1228 } |
|
1229 |
|
1230 break; |
|
1231 |
|
1232 } |
|
1233 |
|
1234 case EStateToneInitializing: |
|
1235 { |
|
1236 if (aDevSoundEvent == EEventInitCompleteTone && aError == KErrNone) |
|
1237 { |
|
1238 TTimeIntervalMicroSeconds duration(KMicroSecsInTenSecs); |
|
1239 // Initialize the audio device and start playing a tone |
|
1240 INFO_PRINTF1(_L("Calling CMMFDevSound::PlayToneL")); |
|
1241 TRAPD(err, iMMFDevSound->PlayToneL(KFrequency1, duration)); |
|
1242 if (err != KErrNone) |
|
1243 { |
|
1244 ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error = %d"), err); |
|
1245 StopTest(err); |
|
1246 break; |
|
1247 } |
|
1248 INFO_PRINTF1(_L("State: EStateTonePlaying")); |
|
1249 iState = EStateTonePlaying; |
|
1250 |
|
1251 // Calling CMMFDevSound::EmptyBuffers while tone playing |
|
1252 INFO_PRINTF1(_L("CMMFDevSound::EmptyBuffers called while tone playing")); |
|
1253 err = iMMFDevSound->EmptyBuffers(); |
|
1254 if (err == KErrNotSupported) |
|
1255 { |
|
1256 INFO_PRINTF2(_L("CMMFDevSound::EmptyBuffers left as expected with error = %d"), err); |
|
1257 StopTest(err,EPass); |
|
1258 } |
|
1259 else |
|
1260 { |
|
1261 ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers did NOT leave with KErrNotSupported as expected. Error = %d"), err); |
|
1262 StopTest(KErrUnknown); |
|
1263 } |
|
1264 } |
|
1265 else if (aDevSoundEvent == EEventInitCompleteTone && aError != KErrNone) |
|
1266 { |
|
1267 ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError); |
|
1268 StopTest(aError); |
|
1269 } |
|
1270 else |
|
1271 { |
|
1272 ERR_PRINTF2(_L("DevSound EEventInitCompleteTone not received as expected. Received event: %d"), aDevSoundEvent); |
|
1273 StopTest(aError, EFail); |
|
1274 } |
|
1275 |
|
1276 break; |
|
1277 |
|
1278 } |
|
1279 |
|
1280 default: |
|
1281 { |
|
1282 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iState); |
|
1283 StopTest(KErrGeneral); |
|
1284 } |
|
1285 } |
|
1286 |
|
1287 } |