First public contribution.
1 // Copyright (c) 2002-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 // This program is designed the test of the MMF_ACLNT.
25 const TInt KHeapSizeToneTestEKA2 = 128000; // Heapsize for tone tests on EKA2
30 CTestMmfAclntTone::CTestMmfAclntTone(const TDesC& aTestName, const TInt aExpectedResult)
32 // store the name of this test case
33 // this is the name that is used by the script file
34 // Each test step initialises it's own name
35 iTestStepName = aTestName;
37 // need a bigger heap size on EKA2 HW
39 iHeapSize = KHeapSizeToneTestEKA2;
42 iFrequency = KToneFrequency;
43 iDuration = TTimeIntervalMicroSeconds(KOneSecond);
44 iExpectedResult = aExpectedResult;
48 CTestMmfAclntTone* CTestMmfAclntTone::NewL(const TDesC& aTestName, const TInt aExpectedResult)
50 CTestMmfAclntTone* self = new (ELeave) CTestMmfAclntTone(aTestName,aExpectedResult);
54 void CTestMmfAclntTone::MatoPrepareComplete(TInt aError)
57 INFO_PRINTF1( _L("CTestMmfAclntTone::MatoPrepareComplete MMdaAudioToneObserver Callback for CMdaAudioToneUtility complete"));
58 INFO_PRINTF2( _L("iError %d"), iError);
60 CActiveScheduler::Stop();
63 void CTestMmfAclntTone::MatoPlayComplete(TInt aError)
66 INFO_PRINTF1( _L("CTestMmfAclntTone::MatoPlayComplete MMdaAudioToneObserver Callback for CMdaAudioToneUtility complete"));
67 INFO_PRINTF2( _L("iError %d"), iError);
69 CActiveScheduler::Stop();
75 TVerdict CTestMmfAclntTone::DoTestStepL()
77 INFO_PRINTF1( _L("TestTone : Play"));
81 iError = KErrTimedOut;
83 CMdaAudioToneUtility* toneUtil = CMdaAudioToneUtility::NewL(*this);
84 CleanupStack::PushL(toneUtil);
85 toneUtil->PrepareToPlayTone(iFrequency,iDuration);
87 INFO_PRINTF1( _L("Initialise CMdaAudioToneUtility"));
88 CActiveScheduler::Start();
90 if(iError == KErrNone)
91 ret = DoTestL(toneUtil);
93 //produce another tone to confirm that the configuration is retained over multiple plays
94 if(iError == KErrNone)
95 ret = DoTestL(toneUtil);
98 ERR_PRINTF2( _L("CMdaAudioToneUtility failed with error %d"),iError );
100 CleanupStack::PopAndDestroy(toneUtil);
104 TVerdict CTestMmfAclntTone::DoTestL(CMdaAudioToneUtility* aToneUtil)
106 TVerdict ret = EFail;
107 iError = KErrTimedOut;
111 INFO_PRINTF1( _L("Play CMdaAudioToneUtility"));
112 CActiveScheduler::Start();
114 if(iError == iExpectedResult)
120 //------------------------------------------------------------------
122 //Play DualTone Test for Sirocco CR
123 CTestMmfAclntDualTone::CTestMmfAclntDualTone(const TDesC& aTestName)
124 : CTestMmfAclntTone(aTestName)
126 iFreqOne = KToneFrequency;
127 iFreqTwo = KToneFrequencyTwo;
130 CTestMmfAclntDualTone* CTestMmfAclntDualTone::NewL(const TDesC& aTestName)
132 CTestMmfAclntDualTone* self = new (ELeave) CTestMmfAclntDualTone(aTestName);
141 TVerdict CTestMmfAclntDualTone::DoTestStepL()
143 INFO_PRINTF1( _L("TestTone : Play Dual Tone"));
145 TVerdict ret = EFail;
146 iError = KErrTimedOut;
148 CMdaAudioToneUtility* toneUtil = CMdaAudioToneUtility::NewL(*this);
149 CleanupStack::PushL(toneUtil);
150 toneUtil->PrepareToPlayDualTone(iFreqOne,iFreqTwo,iDuration);
153 INFO_PRINTF1( _L("Initialise CMdaAudioToneUtility"));
154 CActiveScheduler::Start();
156 if(iError == KErrNone)
157 ret = DoTestL(toneUtil);
159 //produce another tone to confirm that the configuration is retained over multiple plays
160 if(iError == KErrNone)
161 ret = DoTestL(toneUtil);
164 ERR_PRINTF2( _L("CMdaAudioToneUtility failed with error %d"),iError );
166 CleanupStack::PopAndDestroy(toneUtil);
170 //------------------------------------------------------------------
173 CTestMmfAclntToneDtmf::CTestMmfAclntToneDtmf(const TDesC& aTestName,const TDesC& aDTMF,const TInt aExpectedResult)
174 : CTestMmfAclntTone(aTestName,aExpectedResult), iDTMF(aDTMF)
177 CTestMmfAclntToneDtmf* CTestMmfAclntToneDtmf::NewL(const TDesC& aTestName,const TDesC& aDTMF,const TInt aExpectedResult)
179 CTestMmfAclntToneDtmf* self = new (ELeave) CTestMmfAclntToneDtmf(aTestName,aDTMF,aExpectedResult);
186 TVerdict CTestMmfAclntToneDtmf::DoTestStepL()
188 INFO_PRINTF1( _L("TestTone : Play DTMF"));
190 TVerdict ret = EFail;
191 iError = KErrTimedOut;
193 CMdaAudioToneUtility* toneUtil = CMdaAudioToneUtility::NewL(*this);
194 CleanupStack::PushL(toneUtil);
195 toneUtil->PrepareToPlayDTMFString(iDTMF);
196 // Wait for prepare to complete
197 INFO_PRINTF1( _L("Initialise CMdaAudioToneUtility"));
198 CActiveScheduler::Start();
200 toneUtil->PrepareToPlayDTMFString(iDTMF);
201 // Wait for prepare to complete
202 INFO_PRINTF1( _L("Reinitialise CMdaAudioToneUtility"));
203 CActiveScheduler::Start();
205 if(iError == KErrNone)
206 ret = DoTestL(toneUtil);
207 else if (iError == iExpectedResult)
209 INFO_PRINTF2( _L("Initialisation failed as expected with code %d"), iError);
215 ERR_PRINTF2( _L("CMdaAudioToneUtility failed with error %d"),iError );
217 CleanupStack::PopAndDestroy(toneUtil);
221 //------------------------------------------------------------------
226 CTestMmfAclntToneFile::CTestMmfAclntToneFile(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
227 : CTestMmfAclntTone(aTestName)
229 // store the name of this test case
230 // this is the name that is used by the script file
231 // Each test step initialises it's own name
232 iSectName = aSectName;
236 CTestMmfAclntToneFile* CTestMmfAclntToneFile::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
238 CTestMmfAclntToneFile* self = new (ELeave) CTestMmfAclntToneFile(aTestName,aSectName,aKeyName);
242 TVerdict CTestMmfAclntToneFile::DoTestStepPreambleL()
245 if(!GetStringFromConfig(iSectName, iKeyName, filename))
246 return EInconclusive;
248 // Create a sequence file
253 CleanupClosePushL(fs);
254 #ifdef __IPC_V2_PRESENT__
255 User::LeaveIfError(fs.ShareAuto());
257 User::LeaveIfError(fs.Share(RSessionBase::EExplicitAttach));
260 User::LeaveIfError(file.Replace(fs,filename,EFileWrite));
261 CleanupClosePushL(file);
262 User::LeaveIfError(file.Write(KFixedSequenceData()));
263 User::LeaveIfError(file.Size(length));
264 CleanupStack::PopAndDestroy(2, &fs);
266 return CTestMmfAclntStep::DoTestStepPreambleL();
272 TVerdict CTestMmfAclntToneFile::DoTestStepL( void )
274 INFO_PRINTF1( _L("TestTone : Play File"));
276 TVerdict ret = EFail;
280 if(!GetStringFromConfig(iSectName, iKeyName, filename))
281 return EInconclusive;
283 iError = KErrTimedOut;
284 // perform test using this file
285 CMdaAudioToneUtility* toneUtil = CMdaAudioToneUtility::NewL(*this);
286 CleanupStack::PushL(toneUtil);
287 toneUtil->PrepareToPlayFileSequence(filename);
289 INFO_PRINTF1( _L("Initialise CMdaAudioToneUtility"));
290 CActiveScheduler::Start();
292 toneUtil->PrepareToPlayFileSequence(filename);
294 INFO_PRINTF1( _L("re-initialise CMdaAudioToneUtility"));
295 CActiveScheduler::Start();
297 if(iError == KErrNone)
298 ret = DoTestL(toneUtil);
301 ERR_PRINTF2( _L("CMdaAudioToneUtility failed with error %d"),iError );
303 CleanupStack::PopAndDestroy(toneUtil);
307 //------------------------------------------------------------------
312 CTestMmfAclntToneDes::CTestMmfAclntToneDes(const TDesC& aTestName, const TDesC8& aDes, const TInt aExpectedResult)
313 : CTestMmfAclntTone(aTestName, aExpectedResult), iDes(aDes)
316 CTestMmfAclntToneDes* CTestMmfAclntToneDes::NewL(const TDesC& aTestName, const TDesC8& aDes, const TInt aExpectedResult)
318 CTestMmfAclntToneDes* self = new (ELeave) CTestMmfAclntToneDes(aTestName,aDes, aExpectedResult);
323 * Play a tone from a descriptor.
325 TVerdict CTestMmfAclntToneDes::DoTestStepL()
327 INFO_PRINTF1( _L("TestTone : Play Des"));
329 TVerdict ret = EFail;
330 iError = KErrTimedOut;
332 CMdaAudioToneUtility* toneUtil = CMdaAudioToneUtility::NewL(*this);
333 CleanupStack::PushL(toneUtil);
334 toneUtil->PrepareToPlayDesSequence(iDes);
336 INFO_PRINTF1( _L("Initialise CMdaAudioToneUtility"));
337 CActiveScheduler::Start();
339 toneUtil->PrepareToPlayDesSequence(iDes);
341 INFO_PRINTF1( _L("re-initialise CMdaAudioToneUtility"));
342 CActiveScheduler::Start();
344 if(iError == KErrNone)
345 ret = DoTestL(toneUtil);
348 ERR_PRINTF2( _L("CMdaAudioToneUtility failed with error %d"),iError );
350 CleanupStack::PopAndDestroy(toneUtil);
354 //------------------------------------------------------------------
359 CTestMmfAclntToneFixed::CTestMmfAclntToneFixed(const TDesC& aTestName,const TInt aTone)
360 :CTestMmfAclntTone(aTestName), iTone(aTone)
363 CTestMmfAclntToneFixed* CTestMmfAclntToneFixed::NewL(const TDesC& aTestName,const TInt aTone)
365 CTestMmfAclntToneFixed* self = new (ELeave) CTestMmfAclntToneFixed(aTestName,aTone);
370 * Play a predefined/fixed tone
372 TVerdict CTestMmfAclntToneFixed::DoTestStepL()
374 #ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
375 INFO_PRINTF1( _L("TestTone : Play Fixed - no longer supported"));
377 TVerdict ret = EFail;
378 iError = KErrTimedOut;
380 CMdaAudioToneUtility* toneUtil = CMdaAudioToneUtility::NewL(*this);
381 CleanupStack::PushL(toneUtil);
382 toneUtil->PrepareToPlayFixedSequence(iTone);
384 INFO_PRINTF1( _L("Initialise CMdaAudioToneUtility"));
385 CActiveScheduler::Start();
387 toneUtil->PrepareToPlayFixedSequence(iTone);
389 INFO_PRINTF1( _L("re-initialise CMdaAudioToneUtility"));
390 CActiveScheduler::Start();
392 // Has Audio Utility intialisied ?
393 TInt sequenceCount = toneUtil->FixedSequenceCount();
394 INFO_PRINTF2( _L("FixedSequenceCount() returned %d"),sequenceCount);
395 if(sequenceCount <= 0)
397 INFO_PRINTF1( _L("Play Fixed Sequence is no longer supported"));
402 ERR_PRINTF2( _L("CMdaAudioToneUtility failed with error %d"),iError );
404 CleanupStack::PopAndDestroy(toneUtil);
408 INFO_PRINTF1( _L("TestTone : Play Fixed"));
410 TVerdict ret = EFail;
411 iError = KErrTimedOut;
413 CMdaAudioToneUtility* toneUtil = CMdaAudioToneUtility::NewL(*this);
414 CleanupStack::PushL(toneUtil);
415 toneUtil->PrepareToPlayFixedSequence(iTone);
417 INFO_PRINTF1( _L("Initialise CMdaAudioToneUtility"));
418 CActiveScheduler::Start();
420 toneUtil->PrepareToPlayFixedSequence(iTone);
422 INFO_PRINTF1( _L("re-initialise CMdaAudioToneUtility"));
423 CActiveScheduler::Start();
425 // Has Audio Utility intialisied ?
426 TInt sequenceCount = toneUtil->FixedSequenceCount() ;
427 if((iError == KErrNone) && (sequenceCount > 0))
429 INFO_PRINTF2( _L("FixedSequenceName is %S"), &toneUtil->FixedSequenceName(sequenceCount - 1)) ;
430 ret = DoTestL(toneUtil);
434 ERR_PRINTF2( _L("CMdaAudioToneUtility failed with error %d"),iError );
436 CleanupStack::PopAndDestroy(toneUtil);
440 //------------------------------------------------------------------
445 CTestMmfAclntToneAudio::CTestMmfAclntToneAudio()
447 // store the name of this test case
448 // this is the name that is used by the script file
449 // Each test step initialises it's own name
450 iTestStepName = _L("MM-MMF-ACLNT-I-0156-LP");
452 // this test does not inherit from CTestMmfAclntTone
453 // so we need to make the heap bigger here
454 // need a bigger heap size on EKA2 HW
455 #if !defined __WINS__
456 iHeapSize = KHeapSizeToneTestEKA2;
460 void CTestMmfAclntToneAudio::MatoPrepareComplete(TInt aError)
463 INFO_PRINTF1( _L("CTestMmfAclntToneAudio::MatoPrepareComplete MMdaAudioToneObserver Callback for CMdaAudioToneUtility complete"));
464 INFO_PRINTF2( _L("iToneError %d"), iToneError);
465 CActiveScheduler::Stop();
468 void CTestMmfAclntToneAudio::MatoPlayComplete(TInt aError)
470 INFO_PRINTF1( _L("CTestMmfAclntToneAudio::MatoPlayComplete MMdaAudioToneObserver Callback for CMdaAudioToneUtility called"));
472 INFO_PRINTF2( _L("iToneError %d"), iToneError);
474 if((--iCallbackCount) == 0)
475 CActiveScheduler::Stop();
478 void CTestMmfAclntToneAudio::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
480 iPlayerError = aError;
481 CActiveScheduler::Stop();
484 void CTestMmfAclntToneAudio::MapcPlayComplete(TInt aError)
486 INFO_PRINTF1( _L("CTestMmfAclntToneAudio::MatcPlayComplete MMdaAudioPlayerCallback for CMdaAudioPlayerUtility called"));
487 iPlayerError = aError;
488 INFO_PRINTF2( _L("iPlayerError %d"), iPlayerError);
490 if((--iCallbackCount) == 0)
491 CActiveScheduler::Stop();
494 //------------------------------------------------------------------
497 * Playing a tone and playing an audio file.
499 TVerdict CTestMmfAclntToneAudio::DoTestStepL( void )
501 INFO_PRINTF1( _L("TestTone : Tone/File"));
503 TBuf<KSizeBuf> filename;
505 if(!GetStringFromConfig(_L("SectionOne"), _L("playerAudioFile"), filename1))
506 return EInconclusive;
508 GetDriveName(filename);
509 filename.Append(filename1);
511 iPlayerError = KErrTimedOut;
512 CMdaAudioPlayerUtility* playerUtility =
513 //CMdaAudioPlayerUtility::NewFilePlayerL(filename,*this);//, EPriorityHigh);
514 CMdaAudioPlayerUtility::NewFilePlayerL(filename,*this, EPriorityNormal);
516 CleanupStack::PushL(playerUtility);
519 INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
520 CActiveScheduler::Start();
522 if(iPlayerError == KErrNone)
524 iToneError = KErrTimedOut;
525 INFO_PRINTF1( _L("Create audio tone utility..."));
526 CMdaAudioToneUtility* toneUtil = CMdaAudioToneUtility::NewL(*this);
527 CleanupStack::PushL(toneUtil);
529 INFO_PRINTF1( _L("Prepare to play tone..."));
530 toneUtil->PrepareToPlayTone(KToneFrequency,TTimeIntervalMicroSeconds(KOneSecond));
532 INFO_PRINTF1( _L("Initialise CMdaAudioToneUtility"));
533 CActiveScheduler::Start();
535 INFO_PRINTF1( _L("Re-prepare to play tone..."));
536 toneUtil->PrepareToPlayTone(KToneFrequency,TTimeIntervalMicroSeconds(KOneSecond));
538 INFO_PRINTF1( _L("Initialise CMdaAudioToneUtility"));
539 CActiveScheduler::Start();
541 toneUtil->SetPriority(EPriorityHigh, EMdaPriorityPreferenceNone);
542 if(iToneError == KErrNone)
544 iPlayerError = KErrTimedOut;
545 iToneError = KErrTimedOut;
547 // play files together
548 INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
549 playerUtility->Play();
550 INFO_PRINTF1( _L("Play CMdaAudioToneUtility"));
554 CActiveScheduler::Start();
555 // Wait for two callbacks
557 //Tone utility is at priority high - should complete normally
558 //Player is at priority normal should complete with KErrInUse
559 //KErrAccessDenied is OK here, at least until we can do Mixing
560 if(iToneError==KErrNone && (iPlayerError==KErrInUse || iPlayerError==KErrNone))
562 CleanupStack::PopAndDestroy(2); // playerUtility, toneUtil
566 CleanupStack::PopAndDestroy(toneUtil);
569 INFO_PRINTF1( _L("Cannot initialise CMdaAudioPlayerUtility"));
571 ERR_PRINTF2( _L("CMdaAudioToneUtility completed with player error %d"),iPlayerError );
572 ERR_PRINTF2( _L("CMdaAudioToneUtility completed with tone error %d"),iToneError );
573 CleanupStack::PopAndDestroy(playerUtility);
577 //------------------------------------------------------------------
581 CTestMmfAclntToneCancelP::CTestMmfAclntToneCancelP(const TDesC& aTestName)
582 :CTestMmfAclntTone(aTestName)
585 CTestMmfAclntToneCancelP* CTestMmfAclntToneCancelP::NewL(const TDesC& aTestName)
587 CTestMmfAclntToneCancelP* self = new (ELeave) CTestMmfAclntToneCancelP(aTestName);
594 TVerdict CTestMmfAclntToneCancelP::DoTestL(CMdaAudioToneUtility* aToneUtil)
596 INFO_PRINTF1( _L("TestTone : Cancel Play"));
599 TVerdict ret = EFail;
602 INFO_PRINTF1( _L("Play CMdaAudioToneUtility"));
603 if(aToneUtil->State() == EMdaAudioToneUtilityPlaying)
606 INFO_PRINTF1( _L("Cancel Play CMdaAudioToneUtility"));
607 aToneUtil->CancelPlay();
608 // make sure tone is no longer playing
609 if(aToneUtil->State() != EMdaAudioToneUtilityPlaying)
615 //------------------------------------------------------------------
619 CTestMmfAclntToneCancelIni::CTestMmfAclntToneCancelIni(const TDesC& aTestName)
620 :CTestMmfAclntTone(aTestName)
623 CTestMmfAclntToneCancelIni* CTestMmfAclntToneCancelIni::NewL(const TDesC& aTestName)
625 CTestMmfAclntToneCancelIni* self = new (ELeave) CTestMmfAclntToneCancelIni(aTestName);
630 * Cancel tone prepare.
632 * This fucntion cannot leave
634 TVerdict CTestMmfAclntToneCancelIni::DoTestStepL()
636 INFO_PRINTF1( _L("TestTone : Cancel Prepare"));
638 TVerdict ret = EFail;
639 iError = KErrTimedOut;
641 CMdaAudioToneUtility* toneUtil = CMdaAudioToneUtility::NewL(*this);
642 CleanupStack::PushL(toneUtil);
643 INFO_PRINTF1( _L("Initialise CMdaAudioToneUtility"));
644 toneUtil->PrepareToPlayFixedSequence(0);
645 INFO_PRINTF1( _L("Cancel Prep CMdaAudioToneUtility"));
646 toneUtil->CancelPrepare();
647 // make sure init callback did not complete
648 if((iError == KErrTimedOut) && (toneUtil->State() != EMdaAudioToneUtilityPrepared))
652 ERR_PRINTF2( _L("CMdaAudioToneUtility failed with error %d"),iError );
654 CleanupStack::PopAndDestroy(toneUtil);
658 //------------------------------------------------------------------
663 CTestMmfAclntToneNames::CTestMmfAclntToneNames(const TDesC& aTestName)
664 :CTestMmfAclntToneFixed(aTestName,1)
667 CTestMmfAclntToneNames* CTestMmfAclntToneNames::NewL(const TDesC& aTestName)
669 CTestMmfAclntToneNames* self = new (ELeave) CTestMmfAclntToneNames(aTestName);
674 * Enquire sequence name
676 * This function cannot leave
678 TVerdict CTestMmfAclntToneNames::DoTestL(CMdaAudioToneUtility* aToneUtil)
680 INFO_PRINTF1( _L("TestTone : Seq Name"));
682 TVerdict ret = EPass;
684 TInt count = aToneUtil->FixedSequenceCount();
686 for(TInt i = 0; i < count; i++)
688 seqName = aToneUtil->FixedSequenceName(i);
689 if(seqName.Length() < 1)
698 //------------------------------------------------------------------
703 CTestMmfAclntToneCount::CTestMmfAclntToneCount(const TDesC& aTestName)
704 :CTestMmfAclntToneFixed(aTestName,1)
707 CTestMmfAclntToneCount* CTestMmfAclntToneCount::NewL(const TDesC& aTestName)
709 CTestMmfAclntToneCount* self = new (ELeave) CTestMmfAclntToneCount(aTestName);
714 * Enquire sequence count
716 TVerdict CTestMmfAclntToneCount::DoTestL(CMdaAudioToneUtility* aToneUtil)
718 INFO_PRINTF1( _L("TestTone : Seq Count"));
720 iError = KErrTimedOut;
722 if(aToneUtil->FixedSequenceCount() == KFixedSequenceCount)
728 //------------------------------------------------------------------
733 CTestMmfAclntToneVolume::CTestMmfAclntToneVolume(const TDesC& aTestName,const TInt aVolume)
734 :CTestMmfAclntTone(aTestName), iVolume(aVolume)
737 CTestMmfAclntToneVolume* CTestMmfAclntToneVolume::NewL(const TDesC& aTestName,const TInt aVolume)
739 CTestMmfAclntToneVolume* self = new (ELeave) CTestMmfAclntToneVolume(aTestName,aVolume);
744 * Set volume to max and enquire volume
746 TVerdict CTestMmfAclntToneVolume::DoTestL(CMdaAudioToneUtility* aToneUtil)
748 INFO_PRINTF1( _L("TestTone : Volume"));
750 TVerdict ret = EFail;
752 // added from CTestMmfAclntTone : we need the device to be open before
753 // SetVolume() will function correctly
757 INFO_PRINTF1( _L("Play CMdaAudioToneUtility"));
759 // don't wait for it to finish - run this test while playing
760 // so we know device is open
762 // Check maxvolume function
765 iVolume = aToneUtil->MaxVolume();
766 aToneUtil->SetVolume(iVolume);
767 INFO_PRINTF3(_L("volume = %d iVolume = %d"), aToneUtil->Volume(), iVolume);
768 if(aToneUtil->Volume() == iVolume)
771 // Volume is truncated to maxvolume
772 if(iVolume > aToneUtil->MaxVolume())
774 aToneUtil->SetVolume(iVolume);
775 INFO_PRINTF3(_L("volume = %d maxVolume = %d"), aToneUtil->Volume(), aToneUtil->MaxVolume());
776 if(aToneUtil->Volume() == aToneUtil->MaxVolume())
779 // Volume is truncated to 0
782 aToneUtil->SetVolume(iVolume);
783 INFO_PRINTF2(_L("volume = %d, expecting 0"), aToneUtil->Volume());
784 if(aToneUtil->Volume() == 0)
787 // Set volume and check
790 aToneUtil->SetVolume(iVolume);
791 INFO_PRINTF3(_L("volume = %d iVolume = %d"), aToneUtil->Volume(), iVolume);
792 if(aToneUtil->Volume() == iVolume)
796 // let it finish playing
797 CActiveScheduler::Start();
803 //------------------------------------------------------------------
808 CTestMmfAclntVolumeRamp::CTestMmfAclntVolumeRamp(const TDesC& aTestName, const TInt aRamp)
809 :CTestMmfAclntTone(aTestName), iRamp(aRamp)
812 CTestMmfAclntVolumeRamp* CTestMmfAclntVolumeRamp::NewL(const TDesC& aTestName, const TInt aRamp)
814 CTestMmfAclntVolumeRamp* self = new (ELeave) CTestMmfAclntVolumeRamp(aTestName,aRamp);
820 * This function cannot leave
822 TVerdict CTestMmfAclntVolumeRamp::DoTestL(CMdaAudioToneUtility* aToneUtil)
825 INFO_PRINTF1( _L("TestTone : Ramp"));
827 TTimeIntervalMicroSeconds ramp(iRamp);
828 aToneUtil->SetVolumeRamp(ramp);
830 // aToneUtil->[Get]VolumeRamp() doesn't exist.
831 // For now, if SetVolumeRamp() doesn't panic, we have to return EPass.
832 // In future, maybe we can play the clip and get the volume at intervals?
833 INFO_PRINTF1(_L("Warning : no API function to get volume ramp"));
838 //------------------------------------------------------------------
843 CTestMmfAclntToneRepeat::CTestMmfAclntToneRepeat(const TDesC& aTestName)
844 :CTestMmfAclntTone(aTestName)
847 CTestMmfAclntToneRepeat* CTestMmfAclntToneRepeat::NewL(const TDesC& aTestName)
849 CTestMmfAclntToneRepeat* self = new (ELeave) CTestMmfAclntToneRepeat(aTestName);
856 TVerdict CTestMmfAclntToneRepeat::DoTestL(CMdaAudioToneUtility* aToneUtil)
858 INFO_PRINTF1( _L("TestTone : Repeats"));
860 iError = KErrTimedOut;
862 TTimeIntervalMicroSeconds silence(0);
863 aToneUtil->SetRepeats(NUMBER_OF_REPEATS,silence);
865 TInt duration = I64INT(iDuration.Int64());
867 iError = KErrTimedOut;
868 INFO_PRINTF1( _L("Play CMdaAudioToneUtility"));
873 CActiveScheduler::Start();
877 TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
879 INFO_PRINTF2(_L("Repeats : %d"), NUMBER_OF_REPEATS);
880 INFO_PRINTF6(_L("Error : %d Start = %d Stop = %d Duration = %d ActualDuration = %d"),
881 iError, I64INT(start.Int64()), I64INT(stop.Int64()), duration, actualDuration);
883 if((iError == KErrNone) && (TimeComparison(actualDuration, duration * (NUMBER_OF_REPEATS + 1),
884 KExpectedDeviation * NUMBER_OF_REPEATS)))
890 //------------------------------------------------------------------
895 CTestMmfAclntToneLength::CTestMmfAclntToneLength(const TDesC& aTestName)
896 :CTestMmfAclntToneDtmf(aTestName,KShortDTMFString)
899 CTestMmfAclntToneLength* CTestMmfAclntToneLength::NewL(const TDesC& aTestName)
901 CTestMmfAclntToneLength* self = new (ELeave) CTestMmfAclntToneLength(aTestName);
906 * Configure tone on length, tone off length, pause length of DTMF Tones
908 TVerdict CTestMmfAclntToneLength::DoTestL(CMdaAudioToneUtility* aToneUtil)
910 INFO_PRINTF1( _L("TestTone : Length"));
912 iError = KErrTimedOut;
913 TTimeIntervalMicroSeconds32 on(KOneSecond), off(KOneSecond), pause(0);
915 aToneUtil->SetDTMFLengths(on, off, pause);
917 iError = KErrTimedOut;
918 INFO_PRINTF1( _L("Play CMdaAudioToneUtility"));
923 CActiveScheduler::Start();
927 TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
929 INFO_PRINTF6(_L("Error : %d Start = %d Stop = %d Duration = %d ActualDuration = %d"),
930 iError, I64INT(start.Int64()), I64INT(stop.Int64()), KTwoSeconds, actualDuration);
932 if((iError == KErrNone) && (TimeComparison(actualDuration, KTwoSeconds, KExpectedDeviation)))
938 //------------------------------------------------------------------
943 CTestMmfAclntPriorityTones::CTestMmfAclntPriorityTones()
945 // store the name of this test case
946 // this is the name that is used by the script file
947 // Each test step initialises it's own name
948 iTestStepName = _L("MM-MMF-ACLNT-I-0165-HP");
951 void CTestMmfAclntPriorityTones::MchoComplete(TInt aID, TInt aError)
953 INFO_PRINTF1( _L("CTestMmfAclntPriorityTones : MMdaAudioToneObserver Callback for CMdaAudioToneUtility called"));
955 INFO_PRINTF3( _L("iError %d ID %d"), iError, aID);
957 if(iFirstCallback == -1)
958 iFirstCallback = aID;
960 if((--iCallbackCount) == 0)
961 CActiveScheduler::Stop();
965 * Set priorities of tones
967 TVerdict CTestMmfAclntPriorityTones::DoTestStepL()
969 INFO_PRINTF1( _L("TestTone : Priorities"));
971 iError = KErrTimedOut;
973 CMdaAudioToneUtility* toneUtil[2];
974 CToneCallbackHandler* callback[2];
976 for(TInt i=0; i<2; i++)
978 callback[i] = new (ELeave) CToneCallbackHandler(i,this);
979 CleanupStack::PushL(callback[i]);
982 toneUtil[0] = CMdaAudioToneUtility::NewL(*callback[0],NULL, -10, EMdaPriorityPreferenceTimeAndQuality);
983 CleanupStack::PushL(toneUtil[0]);
984 toneUtil[1] = CMdaAudioToneUtility::NewL(*callback[1],NULL, 0, EMdaPriorityPreferenceTimeAndQuality);
985 CleanupStack::PushL(toneUtil[1]);
987 toneUtil[0]->PrepareToPlayDTMFString(KDTMFString);
988 toneUtil[1]->PrepareToPlayDTMFString(KDTMFString);
990 // wait for initilisation callback
992 INFO_PRINTF1( _L("Initialise CMdaAudioToneUtility"));
993 INFO_PRINTF1( _L("Initialise CMdaAudioToneUtility"));
994 CActiveScheduler::Start();
996 if(iError == KErrNone)
998 iError = KErrTimedOut;
1000 toneUtil[0]->Play();
1001 toneUtil[1]->Play();
1003 INFO_PRINTF1( _L("Play CMdaAudioToneUtility"));
1004 INFO_PRINTF1( _L("Play CMdaAudioToneUtility"));
1006 // wait for play to complete
1008 iFirstCallback = -1;
1009 CActiveScheduler::Start();
1011 if((iError == KErrNone) && (iFirstCallback == 0))
1013 CleanupStack::PopAndDestroy(4);
1018 ERR_PRINTF2( _L("CMdaAudioToneUtility failed with error %d"),iError );
1020 CleanupStack::PopAndDestroy(4);
1024 //------------------------------------------------------------------
1029 CTestMmfAclntToneBalance::CTestMmfAclntToneBalance(const TDesC& aTestName,const TInt aBalance)
1030 :CTestMmfAclntTone(aTestName) ,iBalance(aBalance)
1033 CTestMmfAclntToneBalance* CTestMmfAclntToneBalance::NewL(const TDesC& aTestName,const TInt aBalance)
1035 CTestMmfAclntToneBalance* self = new (ELeave) CTestMmfAclntToneBalance(aTestName,aBalance);
1040 * Set balance and enquire balance
1042 TVerdict CTestMmfAclntToneBalance::DoTestL(CMdaAudioToneUtility* aToneUtil)
1044 INFO_PRINTF1( _L("TestTone : Balance"));
1046 if (iBalance < KMinBalance)
1048 TRAPD(err, aToneUtil->SetBalanceL(iBalance));
1050 if (err != KErrNone)
1052 INFO_PRINTF2(_L("SetBalanceL() returned unexpected error %d"), err);
1056 if(aToneUtil->GetBalanceL() == KMinBalance)
1059 else if (iBalance > KMaxBalance)
1061 TRAPD(err, aToneUtil->SetBalanceL(iBalance));
1063 if (err != KErrNone)
1065 INFO_PRINTF2(_L("SetBalanceL() returned unexpected error %d"), err);
1069 if(aToneUtil->GetBalanceL() == KMaxBalance)
1074 TRAPD(err, aToneUtil->SetBalanceL(iBalance));
1076 if (err != KErrNone)
1078 INFO_PRINTF2(_L("SetBalanceL() returned unexpected error %d"), err);
1082 if(aToneUtil->GetBalanceL() == iBalance)
1089 //------------------------------------------------------------------
1093 //------------------------------------------------------------------
1100 CTestMmfAclntOnOffPause::CTestMmfAclntOnOffPause()
1102 // store the name of this test case
1103 // this is the name that is used by the script file
1104 // Each test step initialises it's own name
1105 iTestStepName = _L("MM-MMF-ACLNT-I-1155-HP");
1107 // this test does not inherit from CTestMmfAclntTone
1108 // so we need to make the heap bigger here
1109 // need a bigger heap size on EKA2 HW
1110 #if !defined __WINS__
1111 iHeapSize = KHeapSizeToneTestEKA2;
1115 void CTestMmfAclntOnOffPause::MatoPrepareComplete(TInt aError)
1118 INFO_PRINTF1( _L("CTestMmfAclntOnOffPause::MatoPrepareComplete MMdaAudioToneObserver Callback for CMdaAudioToneUtility complete"));
1119 INFO_PRINTF2( _L("iError %d"), iError);
1120 CActiveScheduler::Stop();
1123 void CTestMmfAclntOnOffPause::MatoPlayComplete(TInt aError)
1126 INFO_PRINTF1( _L("CTestMmfAclntOnOffPause::MatoPlayComplete MMdaAudioToneObserver Callback for CMdaAudioToneUtility complete"));
1127 INFO_PRINTF2( _L("iError %d"), iError);
1128 CActiveScheduler::Stop();
1132 * Set up tone on, off and pause length to illegal values.
1134 TVerdict CTestMmfAclntOnOffPause::DoTestStepL( void )
1136 INFO_PRINTF1( _L("TestTone : On/Off/Pause"));
1137 TVerdict res = EFail;
1139 iError = KErrTimedOut;
1141 CMdaAudioToneUtility* toneUtil = CMdaAudioToneUtility::NewL(*this);
1142 CleanupStack::PushL(toneUtil);
1143 toneUtil->PrepareToPlayDTMFString(KDTMFString);
1145 INFO_PRINTF1( _L("Initialise CMdaAudioToneUtility"));
1146 CActiveScheduler::Start();
1148 if(iError == KErrNone)
1150 iError = KErrTimedOut;
1152 TTimeIntervalMicroSeconds32 on(-4), off(-3), pause(-5);
1154 toneUtil->SetDTMFLengths(on, off, pause);
1157 // wait for play to complete
1158 INFO_PRINTF1( _L("Play CMdaAudioToneUtility"));
1159 CActiveScheduler::Start();
1161 // check this worked
1162 if(iError == KErrNone)
1166 CleanupStack::Pop(); // toneUtil
1167 ERR_PRINTF2( _L("CMdaAudioToneUtility completed with error %d"),iError );