Update contrib.
1 // Copyright (c) 2008-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Part of the TSI_MMFACLNT suite that tests CR1566 (TruePause) on AudioToneUtility
19 @file ToneTruePause.cpp
22 #include "tonetruepause.h"
27 * RMdaToneUtilityTestBase - Test step constructor
30 RMdaToneUtilityTestBase::RMdaToneUtilityTestBase(const TDesC& aTestName, const TDesC& aSectName)
31 : iToneUtilityState(EStateInitial),
47 iTestStepName = aTestName;
48 iSectName = aSectName;
53 * ~RMdaToneUtilityTestBase - Test step destructor
56 RMdaToneUtilityTestBase::~RMdaToneUtilityTestBase()
72 * KickoffTestL - Starts the test
75 void RMdaToneUtilityTestBase::KickoffTestL()
77 User::LeaveIfError(iFs.Connect());
78 INFO_PRINTF1(_L("__________ Creating Tone Utility object ___________"));
80 TRAPD(err, iToneUtility = CMdaAudioToneUtility::NewL(*this));
83 ERR_PRINTF2(_L("Could not create Tone Utility object. Error = %d"), err);
87 INFO_PRINTF1(_L("Tone Utility State: EStateCreated"));
88 iToneUtilityState = EStateCreated;
92 INFO_PRINTF1(_L("Tone Utility Event: EEventInitialize"));
93 Fsm(EEventInitialize, KErrNone);
101 void RMdaToneUtilityTestBase::CloseTest()
103 INFO_PRINTF1(_L("Deleting Tone Utility object"));
110 * StartTimer - Starts timer and timer callback
113 void RMdaToneUtilityTestBase::StartTimer(TTimeIntervalMicroSeconds32 aWaitTime)
115 TTimeIntervalMicroSeconds32 timeInterval;
117 if(aWaitTime <= TTimeIntervalMicroSeconds32(0))
119 timeInterval = KOneSecond;
123 timeInterval = aWaitTime;
125 TCallBack callback (TimerCallback, this);
126 iTimer->Start(timeInterval, timeInterval, callback);
127 INFO_PRINTF1(_L("Timer has been started"));
135 TInt RMdaToneUtilityTestBase::TimerCallback(TAny* aPtr)
137 static_cast<RMdaToneUtilityTestBase*>(aPtr)->DoTimerCallback();
143 * Fsm - Executes playing events of AudioToneUtility in sequence
146 void RMdaToneUtilityTestBase::Fsm(TMdaAudioUtilityEvent aMdaAudioUtilityEvent, TInt aError)
149 switch (iToneUtilityState)
153 if (aMdaAudioUtilityEvent == EEventInitialize)
157 INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayFileSequence"));
158 iToneUtility->PrepareToPlayFileSequence(iFile);
162 INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayDTMFString"));
163 iToneUtility->PrepareToPlayDTMFString(KDTMFString);
165 INFO_PRINTF1(_L("MdaAudioUtility State: EStateInitializing"));
166 iToneUtilityState = EStateInitializing;
170 ERR_PRINTF2(_L("MdaAudioUtility EEventInitialize not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
171 StopTest(aError, EFail);
175 case EStateInitializing:
177 if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError == KErrNone)
179 INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
180 iToneUtility->SetVolume(iToneUtility->MaxVolume()/2);
181 INFO_PRINTF1(_L("Starting playback"));
182 iToneUtility->Play();
183 iStartTime.HomeTime();
184 iToneUtilityState = EStatePlaying;
185 StartTimer(iPause*KOneSecond); //wait to pause
187 else if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError != KErrNone)
189 ERR_PRINTF2(_L("MatoPrepareComplete returned with error = %d"), aError);
194 ERR_PRINTF2(_L("MdaAudioUtility EEventPrepareComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
195 StopTest(aError, EFail);
201 if(aMdaAudioUtilityEvent == EEventTimerComplete)
203 INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Pause"));
204 error = iToneUtility->Pause();
207 INFO_PRINTF1(_L("MdaAudioUtility State: EStatePause"));
208 iToneUtilityState = EStatePause;
213 if(error == KErrNotSupported)
215 INFO_PRINTF1(_L("Pause while in a mode different than prepare to play file sequence returned with KErrNotSupported as expected"));
219 ERR_PRINTF2(_L("Pause while in a mode different than prepare to play file sequence returned with %d instead of KErrNotSupported as expected"),error);
226 ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
227 StopTest(aError, EFail);
233 if (aMdaAudioUtilityEvent == EEventTimerComplete)
235 if(!iWait && !iConfig && !iPrepare)
237 INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioToneUtility::Resume"));
238 error = iToneUtility->Resume();
239 if(error == KErrNone)
241 INFO_PRINTF1(_L("Resume returned with KErrNone as expected"));
242 iToneUtilityState = EStatePlaying;
246 ERR_PRINTF2(_L("Resume returned with %d instead of KErrNone as expected"),error);
250 else if(!iWait && iConfig)
252 INFO_PRINTF2(_L("Playback paused for %d seconds"),iPause);
253 INFO_PRINTF3(_L("Changing Volume and Balance while paused to Volume = %d and Balance = %d"),iVolume,iBalance);
254 iToneUtility->SetVolume(iVolume);
255 iToneUtility->SetBalanceL(iBalance);
256 INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioToneUtility::Resume"));
257 error = iToneUtility->Resume();
258 if(error == KErrNone)
260 INFO_PRINTF1(_L("Resume returned with KErrNone as expected"));
261 iToneUtilityState = EStatePlaying;
265 ERR_PRINTF2(_L("Resume returned with %d instead of KErrNone as expected"),error);
270 else if(!iWait && iPrepare)
272 INFO_PRINTF2(_L("Playback paused for %d seconds"),iPause);
273 INFO_PRINTF1(_L("Calling PrepareToPlayFileSequence while in Pause"));
274 iToneUtility->PrepareToPlayFileSequence(iFile);
275 iToneUtilityState = EStatePlaying;
280 ERR_PRINTF2(_L("EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
281 StopTest(aError, EFail);
287 if (aMdaAudioUtilityEvent == EEventTimerComplete)
291 INFO_PRINTF1(_L("Playback stopped for 2 seconds"));
296 INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Resume while stopped"));
297 error = iToneUtility->Resume();
298 if(error == KErrNotReady)
300 INFO_PRINTF1(_L("Resume returned with KErrNotReady as expected"));
301 iToneUtilityState = EStatePlaying;
305 ERR_PRINTF2(_L("Resume returned with %d instead of KErrNotReady as expected"),error);
308 INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioToneUtility::Play"));
309 iToneUtility->Play();
314 ERR_PRINTF2(_L("EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
315 StopTest(aError, EFail);
321 ERR_PRINTF2(_L("Invalid MdaAudioUtility state received: %d"), iToneUtilityState);
322 StopTest(KErrGeneral);
329 * MatoPrepareComplete - From MMdaAudioToneObserver
332 void RMdaToneUtilityTestBase::MatoPrepareComplete(TInt aError)
334 INFO_PRINTF1(_L("========== Tone Utility MatoPrepareComplete() callback =========="));
335 if(iToneUtilityState == EStateInitializing)
337 INFO_PRINTF1(_L("Tone Utility MatoPrepareComplete"));
338 Fsm(EEventPrepareComplete, aError);
344 * MatoPlayComplete - From MMdaAudioToneObserver
347 void RMdaToneUtilityTestBase::MatoPlayComplete(TInt aError)
349 INFO_PRINTF1(_L("========== Tone Utility MatoPlayComplete() callback =========="));
350 if (aError == KErrNone)
352 INFO_PRINTF2(_L("Tone Utility called MatoPlayComplete with error = %d as expected"), aError);
354 TTimeIntervalMicroSeconds playduration = iEndTime.MicroSecondsFrom(iStartTime);
355 if(playduration > iExpected - KVariation && playduration < iExpected + KVariation)
357 INFO_PRINTF2(_L("Tone played for %ld. Value is between acceptable threshold"),playduration.Int64());
358 StopTest(aError,EPass);
362 ERR_PRINTF2(_L("Tone played for %ld. Value is not between acceptable threshold"),playduration.Int64());
363 StopTest(KErrGeneral);
368 ERR_PRINTF2(_L("Tone Utility called MatoPlayComplete with error = %d"), aError);
369 ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
375 *========================================================================================================
376 * MM-MMF-ACLNT-I-0168-HP
377 *========================================================================================================
379 RMdaToneUtilityResumeTest::RMdaToneUtilityResumeTest(const TDesC& aTestName, const TDesC& aSectName)
380 : RMdaToneUtilityTestBase(aTestName,aSectName)
389 RMdaToneUtilityResumeTest* RMdaToneUtilityResumeTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
391 RMdaToneUtilityResumeTest * self = new(ELeave)RMdaToneUtilityResumeTest(aTestName,aSectName);
400 void RMdaToneUtilityResumeTest::DoKickoffTestL()
403 // Get the duration of the audio file to play
404 if (!GetIntFromConfig(iSectName, KDuration, iDuration))
406 ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
407 StopTest(KErrNotFound);
410 // Get the pause time
411 if (!GetIntFromConfig(iSectName, KPause, iPause))
413 ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
414 StopTest(KErrNotFound);
417 // Get the filename of the audio file to play
418 if (!GetStringFromConfig(iSectName, KSequence, filename))
420 ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
421 StopTest(KErrNotFound);
424 // open using RFile for playback
425 iFilename.Copy(filename);
426 TInt err = iFile.Open(iFs, iFilename, EFileRead);
429 ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
434 iExpected = iDuration + iPause*KOneSecond;
435 INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
436 iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
444 void RMdaToneUtilityResumeTest::DoTimerCallback()
448 INFO_PRINTF1(_L("Cancelling timer"));
453 INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
455 Fsm (EEventTimerComplete, KErrNone);
459 *========================================================================================================
460 * MM-MMF-ACLNT-I-0169-HP
461 *========================================================================================================
463 RMdaToneUtilityResumeThreeTest::RMdaToneUtilityResumeThreeTest(const TDesC& aTestName, const TDesC& aSectName)
464 : RMdaToneUtilityTestBase(aTestName,aSectName)
473 RMdaToneUtilityResumeThreeTest* RMdaToneUtilityResumeThreeTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
475 RMdaToneUtilityResumeThreeTest * self = new(ELeave)RMdaToneUtilityResumeThreeTest(aTestName,aSectName);
484 void RMdaToneUtilityResumeThreeTest::DoKickoffTestL()
487 // Get the duration of the audio file to play
488 if (!GetIntFromConfig(iSectName, KDuration, iDuration))
490 ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
491 StopTest(KErrNotFound);
494 // Get the pause time
495 if (!GetIntFromConfig(iSectName, KPause, iPause))
497 ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
498 StopTest(KErrNotFound);
501 // Get the filename of the audio file to play
502 if (!GetStringFromConfig(iSectName, KSequence, filename))
504 ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
505 StopTest(KErrNotFound);
508 // open using RFile for playback
509 iFilename.Copy(filename);
510 TInt err = iFile.Open(iFs, iFilename, EFileRead);
513 ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
518 iExpected = iDuration + 3*(iPause*KOneSecond);
519 INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
520 iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
529 void RMdaToneUtilityResumeThreeTest::DoTimerCallback()
532 if(!iWait && iCount == 6) //Repeating Pause-Resume cycle three times
535 Fsm (EEventTimerComplete, KErrNone);
539 INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
540 Fsm (EEventTimerComplete, KErrNone);
545 *========================================================================================================
546 * MM-MMF-ACLNT-I-0170-HP
547 *========================================================================================================
549 RMdaToneUtilityPlayPauseStopPlayTest::RMdaToneUtilityPlayPauseStopPlayTest(const TDesC& aTestName, const TDesC& aSectName)
550 : RMdaToneUtilityTestBase(aTestName,aSectName)
559 RMdaToneUtilityPlayPauseStopPlayTest* RMdaToneUtilityPlayPauseStopPlayTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
561 RMdaToneUtilityPlayPauseStopPlayTest * self = new(ELeave)RMdaToneUtilityPlayPauseStopPlayTest(aTestName,aSectName);
570 void RMdaToneUtilityPlayPauseStopPlayTest::DoKickoffTestL()
573 // Get the duration of the audio file to play
574 if (!GetIntFromConfig(iSectName, KDuration, iDuration))
576 ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
577 StopTest(KErrNotFound);
580 // Get the pause time
581 if (!GetIntFromConfig(iSectName, KPause, iPause))
583 ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
584 StopTest(KErrNotFound);
587 // Get the filename of the audio file to play
588 if (!GetStringFromConfig(iSectName, KSequence, filename))
590 ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
591 StopTest(KErrNotFound);
594 // open using RFile for playback
595 iFilename.Copy(filename);
596 TInt err = iFile.Open(iFs, iFilename, EFileRead);
599 ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
606 iExpected = iDuration + 3*(iPause*KOneSecond);
607 INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
608 iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
617 void RMdaToneUtilityPlayPauseStopPlayTest::DoTimerCallback()
621 INFO_PRINTF1(_L("Stopping playback"));
622 iToneUtility->CancelPlay();
624 iToneUtilityState = EStateStopped;
626 INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
627 Fsm (EEventTimerComplete, KErrNone);
629 else if(!iWait && !iStop)
632 Fsm (EEventTimerComplete, KErrNone);
636 INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
637 Fsm (EEventTimerComplete, KErrNone);
642 *========================================================================================================
643 * MM-MMF-ACLNT-I-0171-HP
644 *========================================================================================================
646 RMdaToneUtilityConfigResumeTest::RMdaToneUtilityConfigResumeTest(const TDesC& aTestName, const TDesC& aSectName)
647 : RMdaToneUtilityTestBase(aTestName,aSectName)
656 RMdaToneUtilityConfigResumeTest* RMdaToneUtilityConfigResumeTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
658 RMdaToneUtilityConfigResumeTest * self = new(ELeave)RMdaToneUtilityConfigResumeTest(aTestName,aSectName);
667 void RMdaToneUtilityConfigResumeTest::DoKickoffTestL()
670 // Get the duration of the audio file to play
671 if (!GetIntFromConfig(iSectName, KDuration, iDuration))
673 ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
674 StopTest(KErrNotFound);
677 // Get the pause time
678 if (!GetIntFromConfig(iSectName, KPause, iPause))
680 ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
681 StopTest(KErrNotFound);
684 // Get the filename of the audio file to play
685 if (!GetStringFromConfig(iSectName, KSequence, filename))
687 ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
688 StopTest(KErrNotFound);
692 if (!GetIntFromConfig(iSectName, KVolume, iVolume))
694 ERR_PRINTF1(_L("Volume could not be retrieved from ini file"));
695 StopTest(KErrNotFound);
699 if (!GetIntFromConfig(iSectName, KBalance, iBalance))
701 ERR_PRINTF1(_L("Balance could not be retrieved from ini file"));
702 StopTest(KErrNotFound);
705 // open using RFile for playback
706 iFilename.Copy(filename);
707 TInt err = iFile.Open(iFs, iFilename, EFileRead);
710 ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
717 iExpected = iDuration + iPause*KOneSecond;
718 INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
719 iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
727 void RMdaToneUtilityConfigResumeTest::DoTimerCallback()
729 if(!iWait && !iConfig)
732 INFO_PRINTF1(_L("Comparing Volume and Balance with values set"));
733 if (iVolume == iToneUtility->Volume() && Abs(iBalance - iToneUtility->GetBalanceL())<KBalanceTolerance)
735 INFO_PRINTF3(_L("Volume = %d and Balance = %d as expected"),iVolume,iBalance);
739 ERR_PRINTF1(_L("Retrieved values are different than expected"));
740 ERR_PRINTF5(_L("Retrieved Volume = %d and Balance = %d. Expected Volume = %d and Balance = %d"),iToneUtility->Volume(),iToneUtility->GetBalanceL(),iVolume,iBalance);
741 StopTest(KErrGeneral);
746 INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
747 Fsm (EEventTimerComplete, KErrNone);
752 *========================================================================================================
753 * MM-MMF-ACLNT-I-0172-HP
754 *========================================================================================================
756 RMdaToneUtilityPrepareInPauseTest::RMdaToneUtilityPrepareInPauseTest(const TDesC& aTestName, const TDesC& aSectName)
757 : RMdaToneUtilityTestBase(aTestName,aSectName)
766 RMdaToneUtilityPrepareInPauseTest* RMdaToneUtilityPrepareInPauseTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
768 RMdaToneUtilityPrepareInPauseTest * self = new(ELeave)RMdaToneUtilityPrepareInPauseTest(aTestName,aSectName);
777 void RMdaToneUtilityPrepareInPauseTest::DoKickoffTestL()
780 // Get the duration of the audio file to play
781 if (!GetIntFromConfig(iSectName, KDuration, iDuration))
783 ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
784 StopTest(KErrNotFound);
787 // Get the pause time
788 if (!GetIntFromConfig(iSectName, KPause, iPause))
790 ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
791 StopTest(KErrNotFound);
794 // Get the filename of the audio file to play
795 if (!GetStringFromConfig(iSectName, KSequence, filename))
797 ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
798 StopTest(KErrNotFound);
801 // open using RFile for playback
802 iFilename.Copy(filename);
803 TInt err = iFile.Open(iFs, iFilename, EFileRead);
806 ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
813 iExpected = iDuration;
814 INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
815 iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
823 void RMdaToneUtilityPrepareInPauseTest::DoTimerCallback()
828 Fsm (EEventTimerComplete, KErrNone);
832 INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
833 Fsm (EEventTimerComplete, KErrNone);
839 * MatoPrepareComplete - From MMdaAudioToneObserver
842 void RMdaToneUtilityPrepareInPauseTest::MatoPrepareComplete(TInt aError)
844 INFO_PRINTF1(_L("========== Tone Utility MatoPrepareComplete() callback =========="));
845 if(iToneUtilityState == EStateInitializing)
847 INFO_PRINTF1(_L("Tone Utility MatoPrepareComplete"));
848 Fsm(EEventPrepareComplete, aError);
850 else if(iToneUtilityState == EStatePlaying)
852 if(aError == KErrNone)
854 INFO_PRINTF2(_L("Tone Utility returned with expected error %d"),aError);
855 INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioToneUtility::Play"));
856 iStartTime.HomeTime(); //Register start time here. Tone should restart
857 iToneUtility->Play();
861 ERR_PRINTF1(_L("Preparing tone playback was not successful while paused. This is unexpected"));
868 *========================================================================================================
869 * MM-MMF-ACLNT-I-0173-HP
870 *========================================================================================================
872 RMdaToneUtilityPauseBeforePlayTest::RMdaToneUtilityPauseBeforePlayTest(const TDesC& aTestName, const TDesC& aSectName)
873 : RMdaToneUtilityTestBase(aTestName,aSectName)
882 RMdaToneUtilityPauseBeforePlayTest* RMdaToneUtilityPauseBeforePlayTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
884 RMdaToneUtilityPauseBeforePlayTest * self = new(ELeave)RMdaToneUtilityPauseBeforePlayTest(aTestName,aSectName);
893 void RMdaToneUtilityPauseBeforePlayTest::DoKickoffTestL()
896 // Get the duration of the audio file to play
897 if (!GetIntFromConfig(iSectName, KDuration, iDuration))
899 ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
900 StopTest(KErrNotFound);
903 // Get the filename of the audio file to play
904 if (!GetStringFromConfig(iSectName, KSequence, filename))
906 ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
907 StopTest(KErrNotFound);
910 // open using RFile for playback
911 iFilename.Copy(filename);
912 TInt err = iFile.Open(iFs, iFilename, EFileRead);
915 ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
920 iExpected = iDuration;
921 INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
922 iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
927 * MatoPrepareComplete - From MMdaAudioToneObserver
930 void RMdaToneUtilityPauseBeforePlayTest::MatoPrepareComplete(TInt aError)
932 INFO_PRINTF1(_L("========== Tone Utility MatoPrepareComplete() callback =========="));
933 if(iToneUtilityState == EStateInitializing)
935 INFO_PRINTF1(_L("Tone Utility MatoPrepareComplete"));
936 Fsm(EEventPrepareComplete, aError);
942 * Fsm - Executes playing events of AudioPlayerUtility in sequence
945 void RMdaToneUtilityPauseBeforePlayTest::Fsm(TMdaAudioUtilityEvent aMdaAudioUtilityEvent, TInt aError)
948 switch (iToneUtilityState)
952 if (aMdaAudioUtilityEvent == EEventInitialize)
954 StartTimer(20*KOneSecond); //wait twenty seconds. If timer callback occurrs then Pause worked while not in play
955 INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Pause before preparing to play"));
956 error = iToneUtility->Pause();
957 if(error == KErrNotReady)
959 INFO_PRINTF1(_L("Pause before preparing to play returned with KErrNotReady as expected"));
963 ERR_PRINTF2(_L("Pause before preparing to play returned with %d instead of KErrNotReady as expected"),error);
966 INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayFileSequence"));
967 iToneUtility->PrepareToPlayFileSequence(iFile);
969 INFO_PRINTF1(_L("MdaAudioUtility State: EStateInitializing"));
970 iToneUtilityState = EStateInitializing;
974 ERR_PRINTF2(_L("MdaAudioUtility EEventInitialize not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
975 StopTest(aError, EFail);
979 case EStateInitializing:
981 if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError == KErrNone)
983 INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
984 iToneUtility->SetVolume(iToneUtility->MaxVolume()/2);
985 INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Pause before playing"));
986 error = iToneUtility->Pause();
987 if(error == KErrNotReady)
989 INFO_PRINTF1(_L("Pause before preparing to play returned with KErrNotReady as expected"));
993 ERR_PRINTF2(_L("Pause before preparing to play returned with %d instead of KErrNotReady as expected"),error);
996 INFO_PRINTF1(_L("Starting playback"));
997 iToneUtility->Play();
998 iStartTime.HomeTime();
1000 else if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError != KErrNone)
1002 ERR_PRINTF2(_L("MatoPrepareComplete returned with error = %d"), aError);
1007 ERR_PRINTF2(_L("MdaAudioUtility EEventPrepareComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
1008 StopTest(aError, EFail);
1014 ERR_PRINTF2(_L("Invalid MdaAudioUtility state received: %d"), iToneUtilityState);
1015 StopTest(KErrGeneral);
1025 void RMdaToneUtilityPauseBeforePlayTest::DoTimerCallback()
1027 ERR_PRINTF1(_L("Timer callback received. This is unexpected"));
1028 StopTest(KErrGeneral);
1032 *========================================================================================================
1033 * MM-MMF-ACLNT-I-0174-HP Negative
1034 *========================================================================================================
1036 RMdaToneUtilityNegPauseResumeTest::RMdaToneUtilityNegPauseResumeTest(const TDesC& aTestName, const TDesC& aSectName)
1037 : RMdaToneUtilityTestBase(aTestName,aSectName)
1046 RMdaToneUtilityNegPauseResumeTest* RMdaToneUtilityNegPauseResumeTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1048 RMdaToneUtilityNegPauseResumeTest * self = new(ELeave)RMdaToneUtilityNegPauseResumeTest(aTestName,aSectName);
1057 void RMdaToneUtilityNegPauseResumeTest::DoKickoffTestL()
1060 // Get the pause time
1061 if (!GetIntFromConfig(iSectName, KPause, iPause))
1063 ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1064 StopTest(KErrNotFound);
1067 // Get the filename of the audio file to play
1068 if (!GetStringFromConfig(iSectName, KSequence, filename))
1070 ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1071 StopTest(KErrNotFound);
1074 // open using RFile for playback
1075 iFilename.Copy(filename);
1076 TInt err = iFile.Open(iFs, iFilename, EFileRead);
1077 if (err != KErrNone)
1079 ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1087 INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1088 iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1096 void RMdaToneUtilityNegPauseResumeTest::DoTimerCallback()
1098 INFO_PRINTF1(_L("Cancelling timer"));
1100 INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
1101 Fsm (EEventTimerComplete, KErrNone);
1106 * MatoPlayComplete - From MMdaAudioToneObserver
1109 void RMdaToneUtilityNegPauseResumeTest::MatoPlayComplete(TInt aError)
1111 INFO_PRINTF1(_L("========== Tone Utility MatoPlayComplete() callback =========="));
1113 if (aError == KErrNone)
1115 INFO_PRINTF2(_L("Tone Utility called MatoPlayComplete with error = %d as expected"), aError);
1118 //NOTE:"PlayFixedSequence is not supported on A3F"
1120 INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayTone"));
1121 iToneUtility->PrepareToPlayTone(KToneFrequency, KFiveSeconds);
1122 INFO_PRINTF1(_L("MdaAudioUtility State: EStateInitializing"));
1123 iToneUtilityState = EStateInitializing;
1126 INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayDualTone"));
1127 iToneUtility->PrepareToPlayDualTone(KToneFrequency, KToneFrequencyTwo, KFiveSeconds);
1128 INFO_PRINTF1(_L("MdaAudioUtility State: EStateInitializing"));
1129 iToneUtilityState = EStateInitializing;
1132 INFO_PRINTF1(_L("All tone variations have been tested"));
1139 ERR_PRINTF2(_L("Tone Utility called MatoPlayComplete with error = %d"), aError);
1140 ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
1146 *========================================================================================================
1147 * MM-MMF-ACLNT-I-0183-HP
1148 *========================================================================================================
1150 RMdaToneUtilityPauseNonA3fTest::RMdaToneUtilityPauseNonA3fTest(const TDesC& aTestName, const TDesC& aSectName)
1151 : RMdaToneUtilityTestBase(aTestName,aSectName)
1160 RMdaToneUtilityPauseNonA3fTest* RMdaToneUtilityPauseNonA3fTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1162 RMdaToneUtilityPauseNonA3fTest * self = new(ELeave)RMdaToneUtilityPauseNonA3fTest(aTestName,aSectName);
1171 void RMdaToneUtilityPauseNonA3fTest::DoKickoffTestL()
1174 // Get the filename of the audio file to play
1175 if (!GetStringFromConfig(iSectName, KSequence, filename))
1177 ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1178 StopTest(KErrNotFound);
1181 // open using RFile for playback
1182 iFilename.Copy(filename);
1183 TInt err = iFile.Open(iFs, iFilename, EFileRead);
1184 if (err != KErrNone)
1186 ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1191 // Get the duration of the audio file to play
1192 if (!GetIntFromConfig(iSectName, KDuration, iDuration))
1194 ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
1195 User::Leave(KErrNotFound);
1198 // Get the pause time
1199 if (!GetIntFromConfig(iSectName, KPause, iPause))
1201 ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1202 User::Leave(KErrNotFound);
1205 iExpected = iDuration;
1206 INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1207 iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1212 * MatoPrepareComplete - From MMdaAudioToneObserver
1215 void RMdaToneUtilityPauseNonA3fTest::MatoPrepareComplete(TInt aError)
1217 INFO_PRINTF1(_L("========== Tone Utility MatoPrepareComplete() callback =========="));
1218 if(iToneUtilityState == EStateInitializing)
1220 INFO_PRINTF1(_L("Tone Utility MatoPrepareComplete"));
1221 Fsm(EEventPrepareComplete, aError);
1227 * Fsm - Executes playing events of AudioToneUtility in sequence
1230 void RMdaToneUtilityPauseNonA3fTest::Fsm(TMdaAudioUtilityEvent aMdaAudioUtilityEvent, TInt aError)
1233 switch (iToneUtilityState)
1237 if (aMdaAudioUtilityEvent == EEventInitialize)
1239 INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayFileSequence"));
1240 iToneUtility->PrepareToPlayFileSequence(iFile);
1242 INFO_PRINTF1(_L("MdaAudioUtility State: EStateInitializing"));
1243 iToneUtilityState = EStateInitializing;
1247 ERR_PRINTF2(_L("MdaAudioUtility EEventInitialize not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
1248 StopTest(aError, EFail);
1252 case EStateInitializing:
1254 if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError == KErrNone)
1256 INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
1257 iToneUtility->SetVolume(iToneUtility->MaxVolume()/2);
1258 INFO_PRINTF1(_L("Starting playback"));
1259 iToneUtility->Play();
1260 iStartTime.HomeTime();
1261 iToneUtilityState = EStatePlaying;
1262 StartTimer(iPause*KOneSecond); //wait to pause
1264 else if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError != KErrNone)
1266 ERR_PRINTF2(_L("MatoPrepareComplete returned with error = %d"), aError);
1271 ERR_PRINTF2(_L("MdaAudioUtility EEventPrepareComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
1272 StopTest(aError, EFail);
1278 if(aMdaAudioUtilityEvent == EEventTimerComplete)
1280 INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Pause in non-a3f configuration"));
1281 error = iToneUtility->Pause();
1282 if(error == KErrNotSupported)
1284 INFO_PRINTF1(_L("Pause in ToneUtility returned with KErrNotSupported as expected"));
1288 ERR_PRINTF2(_L("Pause in ToneUtility returned with %d instead of KErrNotSupported as expected"),error);
1291 INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Resume in non-a3f configuration"));
1292 error = iToneUtility->Resume();
1293 if(error == KErrNotReady)
1295 INFO_PRINTF1(_L("Resume returned with KErrNotReady as expected"));
1296 iToneUtilityState = EStatePlaying;
1300 ERR_PRINTF2(_L("Resume returned with %d instead of KErrNotReady as expected"),error);
1306 ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
1307 StopTest(aError, EFail);
1313 ERR_PRINTF2(_L("Invalid MdaAudioUtility state received: %d"), iToneUtilityState);
1314 StopTest(KErrGeneral);
1324 void RMdaToneUtilityPauseNonA3fTest::DoTimerCallback()
1326 INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
1327 INFO_PRINTF1(_L("Cancelling timer"));
1329 Fsm (EEventTimerComplete, KErrNone);