mmfenh/advancedaudiocontroller/tsrc/advancedaudiocontrollertestmodule/AudioToneTestModule/src/MmfTsTone_core.cpp
changeset 0 71ca22bcf22a
child 12 2eb3b066cc7d
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  MmfTsTone class member functions
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "MmfTsTone.h"
       
    21 #include "TemplateParameters.h"
       
    22 #include "DTMFParameters.h"
       
    23 
       
    24 // EXTERNAL DATA STRUCTURES
       
    25 // None
       
    26 
       
    27 // EXTERNAL FUNCTION PROTOTYPES  
       
    28 // None
       
    29 
       
    30 // CONSTANTS
       
    31 const TInt CMmfTsTone::KTestCaseVolume=501;
       
    32 const TInt CMmfTsTone::KTestCaseVolumeRamp=502;
       
    33 const TInt CMmfTsTone::KTestCaseRepeat=503;
       
    34 const TInt CMmfTsTone::KTestCaseFixedSequences=504;
       
    35 const TInt CMmfTsTone::KTestCasePlayFileSequence=505;
       
    36 const TInt CMmfTsTone::KTestCaseBalance=506;
       
    37 const TInt CMmfTsTone::KTestCasePriorities=507;
       
    38 const TInt CMmfTsTone::KTestCaseDTMFString=508;
       
    39 const TInt CMmfTsTone::KTestCaseCancelPrepare=509;
       
    40 const TInt CMmfTsTone::KTestCaseDualTone=510;
       
    41 const TInt CMmfTsTone::KTestCasePlayToneFile=511;
       
    42 const TInt CMmfTsTone::KTestCasePlayToneRFile=512;  
       
    43 const TInt CMmfTsTone::KTestCaseCustomInterface=513;  
       
    44 const TInt CMmfTsTone:: KTestCaseCheckState=514;
       
    45 const TInt CMmfTsTone:: KTestCaseMaxVolumePlay=515;
       
    46 const TInt CMmfTsTone::KTestCasePlayCancel=516;
       
    47 const TInt CMmfTsTone::KTestCasePlayChangeVolume=517;
       
    48 const TInt CMmfTsTone::KTestCaseInvalidFrequencyCheck=518;
       
    49 const TInt CMmfTsTone::KTestCaseCorruptFile=519;
       
    50 
       
    51 
       
    52 // MACROS
       
    53 // None
       
    54 
       
    55 // LOCAL CONSTANTS AND MACROS
       
    56 //typdef TFixedArray<TInt, 2> TTwoIntArray;
       
    57 
       
    58 // MODULE DATA STRUCTURES
       
    59 // None
       
    60 
       
    61 // LOCAL FUNCTION PROTOTYPES
       
    62 // None
       
    63 
       
    64 // FORWARD DECLARATIONS
       
    65 // None
       
    66 
       
    67 // ==================== LOCAL FUNCTIONS =======================================
       
    68 // None
       
    69 
       
    70 /*-------------------------------------------------------------------------------
       
    71 
       
    72     DESCRIPTION
       
    73 
       
    74     This module contains the implementation of MmfTsTone class 
       
    75 	member functions.
       
    76 
       
    77 -------------------------------------------------------------------------------*/
       
    78 
       
    79 // ================= MEMBER FUNCTIONS =========================================
       
    80 
       
    81 TInt CMmfTsTone::RunTestCaseFunctionL(TInt id, CStifSectionParser * section, TTestResult &aResult) 
       
    82 	{
       
    83 	TInt error = KErrNone;
       
    84 	switch (id)
       
    85 		{
       
    86 		case KTestCaseVolume:
       
    87 		    {
       
    88 			error = TestCaseVolumeL(section, aResult);
       
    89 			break;
       
    90 		    }
       
    91 		case KTestCaseVolumeRamp:
       
    92 		    {
       
    93 		    error = TestCaseVolumeRampL(section, aResult);
       
    94 			break;
       
    95 		    }
       
    96 		case KTestCaseRepeat:
       
    97 		    {
       
    98 		    error = TestCaseRepeatL(section, aResult);
       
    99 			break;
       
   100 		    }
       
   101 		case KTestCaseFixedSequences:
       
   102 		    {
       
   103 		    error = TestCaseFixedSecuencesL(section, aResult);
       
   104 		    break;
       
   105 		    }
       
   106 		case KTestCasePlayFileSequence:
       
   107 		    {
       
   108 		    error = TestCasePlayFileSequenceL(section, aResult);
       
   109 			break;
       
   110 		    }
       
   111 		case KTestCaseBalance:
       
   112 		    {
       
   113 		    error = TestCaseBalanceL(section, aResult);
       
   114 			break;
       
   115 		    }
       
   116 		case KTestCasePriorities:
       
   117 		    {
       
   118 		    error = TestCasePrioritiesL(section, aResult);
       
   119 		    break;
       
   120 		    }
       
   121 		case KTestCaseDTMFString:
       
   122 		    {
       
   123 		    error = TestCaseDTMFStringL(section, aResult);
       
   124 		    break;
       
   125 		    }
       
   126 		case KTestCaseDualTone:
       
   127 		    {
       
   128 		    error = TestCaseDualToneL(section, aResult);
       
   129 			break;
       
   130 		    }
       
   131 		case KTestCaseCancelPrepare:
       
   132 		    {
       
   133 		    error = TestCaseCancelPrepareL(section, aResult);
       
   134 		    break;
       
   135 		    }
       
   136 		case KTestCasePlayToneFile:
       
   137 		    {
       
   138 		    error = TestCasePlayToneFileL(section, aResult);
       
   139 			break;
       
   140 		    }
       
   141 		case KTestCasePlayToneRFile:
       
   142 		    {
       
   143 		    error = TestCasePlayToneRFileL(section, aResult);
       
   144 		    break;
       
   145 		    }
       
   146 		case KTestCaseCustomInterface:
       
   147 		    {
       
   148 		    error = TestCaseCustomInterfaceL(section, aResult);
       
   149 		    break;
       
   150 		    }
       
   151 		case KTestCaseCheckState:
       
   152 		    {
       
   153 		    error=TestCaseCheckStateL(section,aResult);
       
   154 		    break;
       
   155 		    }
       
   156 		case KTestCaseMaxVolumePlay:
       
   157 		    {
       
   158 		    error=TestCaseMaxVolumePlayL(section,aResult);
       
   159 		    break;
       
   160 		    }
       
   161 		case KTestCasePlayCancel:
       
   162 		    {
       
   163 		    error=TestCaseCancelPlayL(section,aResult);
       
   164 		    break;
       
   165 		    }
       
   166 		case KTestCasePlayChangeVolume:
       
   167 		    {
       
   168 		    error=TestCaseVolumeChangeL(section,aResult);
       
   169 		    break;
       
   170 		    }
       
   171 		case KTestCaseInvalidFrequencyCheck:
       
   172 		    {
       
   173 		    error = TestCaseDualToneL(section, aResult);
       
   174 		    break;
       
   175 		    }
       
   176 		case KTestCaseCorruptFile:
       
   177 		    {
       
   178 		    error=TestCasePlayCorruptFileL(section,aResult);
       
   179 		    break;
       
   180 		    }
       
   181 		default:
       
   182 		    {
       
   183 		    aResult.iResultDes.Copy(KConfigInvalid());
       
   184 		    aResult.iResult = KErrNotExecuted;
       
   185 		    }
       
   186 		}
       
   187 	REComSession::FinalClose();
       
   188 	return error;
       
   189 	}
       
   190 
       
   191 TInt CMmfTsTone::TestCaseVolumeL(CStifSectionParser *section , TTestResult &aResult) 
       
   192 	{
       
   193 	TBool UsingDefault=EFalse;
       
   194 	TInt Frequency1, Frequency2;
       
   195 	TTimeIntervalMicroSeconds Duration1, Duration2;
       
   196 	TObjectCountDown counter;
       
   197 	aResult.iResult=KErrNone;
       
   198 	
       
   199 	Frequency1=Frequency2=KDefaultToneFrequency;
       
   200 	
       
   201 	//Obtain the tone's frequency
       
   202 	Frequency1 = GetIntL(section, KTagToneFrequency, UsingDefault, KDefaultToneFrequency);
       
   203 	if (UsingDefault) {iOutputPrinter.Printf(_L("Using default tone frequency for player1") );}
       
   204 	Frequency2 = GetIntL(section, KTagToneFrequency, UsingDefault, KDefaultToneFrequency, ETrue);
       
   205 	if (UsingDefault) {iOutputPrinter.Printf(_L("Using default tone frequency for player2") );}
       
   206 
       
   207 	Duration1 = GetTimeIntervalL(section, KTagToneDuration, UsingDefault, KDefaultToneDuration);
       
   208 	if (UsingDefault) {iOutputPrinter.Printf(_L("Using default tone duration for player1") );}
       
   209 	Duration2 = GetTimeIntervalL(section, KTagToneDuration, UsingDefault, KDefaultToneDuration, ETrue);
       
   210 	if (UsingDefault) {iOutputPrinter.Printf(_L("Using default tone duration for player2") );}
       
   211 
       
   212 	iOutputPrinter.Printf(_L("Creating Tone Player1 with frequency (%d) and duration (%d)") , Frequency1, Duration1);
       
   213 	CTonePlayer *Player1 = CTonePlayer::NewLC(&iOutputPrinter, Frequency1, Duration1);
       
   214 	Player1->SetId(1);
       
   215 	Player1->SetSupervisor(&counter);
       
   216 
       
   217 	iOutputPrinter.Printf(_L("Creating Tone Player2 with frequency (%d) and duration (%d)") , Frequency2, Duration2);
       
   218 	CTonePlayer *Player2 = CTonePlayer::NewLC(&iOutputPrinter, Frequency2, Duration2, EFalse);
       
   219 	Player2->SetId(2);
       
   220 	Player2->SetSupervisor(&counter);
       
   221 
       
   222 	CParameters *PlayParameters = new(ELeave) CParameters(CTonePlayer::KPlayerActionPlay);
       
   223 	CleanupStack::PushL(PlayParameters);
       
   224 	Player1->SetExitCompleteTarget(Player2, PlayParameters);
       
   225 
       
   226 	TInt MaxVolume1 = Player1->GetMaxVolume();
       
   227 	TInt MaxVolume2 = Player2->GetMaxVolume();
       
   228 
       
   229 	TInt Volume1 = MaxVolume1;
       
   230 	TInt Volume2 = MaxVolume2 / 2;
       
   231 
       
   232 	Player1->SetVolume(Volume1);
       
   233 	Player2->SetVolume(Volume2);
       
   234 
       
   235 	CActiveScheduler::Start();
       
   236 
       
   237 	iOutputPrinter.Printf( _L("Player 1: Max (%d) Set (%d) Read (%d)") , MaxVolume1, Volume1, Player1->GetVolume() );
       
   238 	iOutputPrinter.Printf( _L("Player 2: Max (%d) Set (%d) Read (%d)") , MaxVolume2, Volume2, Player2->GetVolume() );
       
   239 
       
   240 	if (Volume1 != Player1->GetVolume() )
       
   241 		{
       
   242 		aResult.iResult = KErrExpectedValueDifferent;
       
   243 		iOutputPrinter.Printf(_L("Volume for Player1 different than volume setup"));
       
   244 		return KErrExecuted;
       
   245 		}
       
   246 	if (Volume2 != Player2->GetVolume() )
       
   247 		{
       
   248 		aResult.iResult = KErrExpectedValueDifferent;
       
   249 		iOutputPrinter.Printf(_L("Volume for Player2 different than volume setup"));
       
   250 		return KErrExecuted;
       
   251 		}
       
   252 
       
   253 	if (aResult.iResult == KErrExpectedValueDifferent) 
       
   254 		{
       
   255 		aResult.iResultDes.Copy(KTestCaseResultFailExpectedValueDifferent());
       
   256 		//_LIT(LDifferentValues, "volumes are different");
       
   257 		iOutputPrinter.Printf( KTestCaseResultFinished() , &KTestCaseResultFailExpectedValueDifferent() );
       
   258 		}
       
   259 	else
       
   260 		{
       
   261 		aResult.iResult = KErrExecuted;
       
   262 		aResult.iResultDes.Copy(KTestCaseResultSuccess());
       
   263 		//_LIT(LSuccess, "success");
       
   264 		iOutputPrinter.Printf( KTestCaseResultFinished() ,  &KTestCaseResultSuccess() );
       
   265 		}
       
   266 
       
   267 	CleanupStack::PopAndDestroy(PlayParameters);
       
   268 	CleanupStack::PopAndDestroy(Player2);
       
   269 	CleanupStack::PopAndDestroy(Player1);
       
   270 
       
   271 	return KErrExecuted;
       
   272 	}
       
   273 
       
   274 TInt CMmfTsTone::TestCaseVolumeRampL(CStifSectionParser *section , TTestResult &aResult) 
       
   275 	{
       
   276 	TBool UsingDefault=EFalse;
       
   277 	TInt Frequency=KDefaultToneFrequency;
       
   278 	TTimeIntervalMicroSeconds Duration, RampDuration;
       
   279 	TTimeIntervalMicroSeconds32 Delay;
       
   280 	
       
   281 	aResult.iResult=KErrNone;
       
   282 	
       
   283 	//Obtain the tone's frequency
       
   284 	Frequency = GetIntL(section, KTagToneFrequency, UsingDefault, KDefaultToneFrequency);
       
   285 	if (UsingDefault) {iOutputPrinter.Printf(_L("Using default tone frequency for player") );}
       
   286 
       
   287 	Duration = GetTimeIntervalL(section, KTagToneDuration, UsingDefault, KDefaultToneDuration);
       
   288 	if (UsingDefault) {iOutputPrinter.Printf(_L("Using default tone duration for player") );}
       
   289 
       
   290 	RampDuration = GetTimeIntervalL(section, KTagRampDuration, UsingDefault, KDefaultRampDuration);
       
   291 	if (UsingDefault) {iOutputPrinter.Printf(_L("Using default ramp duration for player") );}
       
   292 
       
   293 	Delay = GetTimeIntervalL(section, KTagDelay, UsingDefault, KDefaultReportDelay);
       
   294 	if (UsingDefault) {iOutputPrinter.Printf(_L("Using default report delay for player") );}
       
   295 
       
   296 	iOutputPrinter.Printf(_L("Creating Tone Player with frequency (%d) and duration (%d)") , Frequency, Duration);
       
   297 	CTonePlayer *Player = CTonePlayer::NewLC(&iOutputPrinter, Frequency, Duration);
       
   298 	iOutputPrinter.Printf(_L("Setting a volume ramp of (%d) microseconds"), RampDuration);
       
   299 	iOutputPrinter.Printf(_L("Volume sampled every (%d) microseconds"), Delay);
       
   300 
       
   301 	Player->SetVolumeRamp(RampDuration);
       
   302 
       
   303 	CParameters *ReportParams = new (ELeave) CParameters( CTonePlayer::KPlayerActionReportVolume );
       
   304 	CleanupStack::PushL(ReportParams);
       
   305 	//CMediaEvent *mEventReport = CMediaEvent::NewL(TestModuleIf() , *iLogger, Delay, Delay, Player, ReportParams);
       
   306 	CMediaEvent *mEventReport = CMediaEvent::NewL(&iOutputPrinter, Delay, Delay, Player, ReportParams);
       
   307 	CleanupStack::Pop(ReportParams);
       
   308 	CleanupStack::PushL(mEventReport);
       
   309 
       
   310 	CActiveScheduler::Start();
       
   311 
       
   312 	if (mEventReport->GetCount() <= 0)
       
   313 	{
       
   314 		iOutputPrinter.Printf(_L("Not enought events"));
       
   315 	}
       
   316 
       
   317 	if (Player->GetFinalError() )
       
   318 		{
       
   319 		aResult.iResult = Player->GetFinalError();
       
   320 		aResult.iResultDes.Copy(KTestCaseResultFailExpectedValueDifferent());
       
   321 		iOutputPrinter.Printf( KTestCaseResultFinished() , &KTestCaseResultFailExpectedValueDifferent() );
       
   322 		}
       
   323 	else
       
   324 		{
       
   325 		aResult.iResult = KErrExecuted;
       
   326 		aResult.iResultDes.Copy(KTestCaseResultSuccess());
       
   327 		iOutputPrinter.Printf( KTestCaseResultFinished() ,  &KTestCaseResultSuccess() );
       
   328 		}
       
   329 	CleanupStack::PopAndDestroy(mEventReport);
       
   330 	CleanupStack::PopAndDestroy(Player);
       
   331 
       
   332 	return KErrExecuted;
       
   333 	}
       
   334 
       
   335 
       
   336 TInt CMmfTsTone::TestCaseRepeatL(CStifSectionParser *section , TTestResult &aResult)
       
   337 	{
       
   338 	CTonePlayer *Player;
       
   339 	TBool UsingDefault=EFalse;
       
   340 	RArray<TUint> RepeatArray;
       
   341 	RArray<TTimeIntervalMicroSeconds> RepeatSilenceArray;
       
   342 	RArray<TUint> FrequencyArray;
       
   343 	RArray<TTimeIntervalMicroSeconds> DurationArray;
       
   344 
       
   345 	RArray<TInt> ErrorArray;
       
   346 
       
   347 	//Obtain the error range
       
   348 	TTimeIntervalMicroSeconds ErrorRange = GetTimeIntervalL(section, KTagErrorRange, UsingDefault, KDefaultErrorRange);
       
   349 	if (UsingDefault) {iOutputPrinter.Printf(_L("Using default error range") );}
       
   350 
       
   351 	iOutputPrinter.Printf(_L("Reading list of repetition configuration"));
       
   352 	TInt RepeatTimes = GetIntL(section, KTagRepeatTimes, UsingDefault, KDefaultRepeats);
       
   353 	do {	//If the configuration is not found, at least add 1 default test
       
   354 		RepeatArray.Append(RepeatTimes);
       
   355 		iOutputPrinter.Printf(_L("Adding (%d) repetitions") , RepeatTimes);
       
   356 	} while ( RepeatTimes=GetIntL(section, KTagRepeatTimes, UsingDefault, 1, ETrue) , !UsingDefault );
       
   357 
       
   358 	iOutputPrinter.Printf(_L("Reading list of repetition silence intervals"));
       
   359 	TTimeIntervalMicroSeconds RepeatSilence = GetTimeIntervalL(section, KTagSilenceDuration, UsingDefault, KDefaultSilenceDuration);
       
   360 	do {	//If the configuration is not found, at least add 1 default test
       
   361 		RepeatSilenceArray.Append(RepeatSilence);
       
   362 		iOutputPrinter.Printf(_L("Adding silence interval of (%d) microseconds") , RepeatSilence);
       
   363 	} while ( RepeatSilence=GetTimeIntervalL(section, KTagSilenceDuration, UsingDefault, KDefaultSilenceDuration, ETrue) , !UsingDefault );
       
   364 
       
   365 	// Reading Tones
       
   366 	iOutputPrinter.Printf(_L("Reading list of tone frequencies"));
       
   367 	TInt Frequency = GetIntL(section, KTagToneFrequency, UsingDefault, KDefaultToneFrequency);
       
   368 	do {	//If the configuration is not found, at least add 1 default test
       
   369 		FrequencyArray.Append(Frequency);
       
   370 		iOutputPrinter.Printf(_L("Adding frequency (%d)") , Frequency);
       
   371 	} while ( Frequency=GetIntL(section, KTagToneFrequency, UsingDefault, KDefaultToneFrequency, ETrue) , !UsingDefault );
       
   372 
       
   373 	iOutputPrinter.Printf(_L("Reading list of tone durations"));
       
   374 	TTimeIntervalMicroSeconds Duration = GetTimeIntervalL(section, KTagToneDuration, UsingDefault, KDefaultToneDuration);
       
   375 	do {	//If the configuration is not found, at least add 1 default test
       
   376 		DurationArray.Append(Duration);
       
   377 		iOutputPrinter.Printf(_L("Adding tone duration of (%d) microseconds") , Duration);
       
   378 	} while ( Duration=GetTimeIntervalL(section, KTagToneDuration, UsingDefault, KDefaultToneDuration, ETrue) , !UsingDefault );
       
   379 
       
   380 	TInt TestNum;
       
   381 	RepeatSilence=KDefaultSilenceDuration;
       
   382 	Frequency = KDefaultToneFrequency;
       
   383 
       
   384 	TInt Error=KErrNone;
       
   385 	TBool HadErrors=EFalse;
       
   386 	for (TestNum=0; TestNum < RepeatArray.Count() && !Error ; ++TestNum) {
       
   387 		Error = KErrNone;
       
   388 		//setup the case for RepeatArray[TestNum] repeats
       
   389 		RepeatTimes=RepeatArray[TestNum];
       
   390 		if (TestNum < RepeatSilenceArray.Count() ) { RepeatSilence = RepeatSilenceArray[TestNum]; }
       
   391 		if (TestNum < FrequencyArray.Count() ) { Frequency = FrequencyArray[TestNum]; }
       
   392 		if (TestNum < DurationArray.Count() ) { Duration = DurationArray[TestNum];}
       
   393 		//TestWithRepeats: RepeatTimes & RepeatSilence
       
   394 		iOutputPrinter.Printf(_L("Creating Tone Player with frequency (%d) and duration (%d)") , Frequency, Duration);
       
   395 		Player = CTonePlayer::NewLC(&iOutputPrinter, Frequency, Duration);
       
   396 		iOutputPrinter.Printf(_L("Repeating (%d) times with silence intervals of (%d) microseconds") , RepeatTimes,RepeatSilence );
       
   397 		Player->SetRepeats(RepeatTimes,RepeatSilence);
       
   398 		CActiveScheduler::Start();
       
   399 		//Error=Player->GetFinalError() ;
       
   400 		
       
   401 		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   402 		if (!IsDurationInRange(RepeatTimes, Duration, RepeatSilence, ErrorRange, Player->GetPlayStartTime(), Player->GetPlayStopTime() ) )
       
   403 			{
       
   404 			Error = KErrExpectedValueDifferent;
       
   405 			}
       
   406 		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   407 		//TODO: Calculate the expected duration taking into account the final silence (it should be present, according to SACF)
       
   408 		if ( !Error) { Error=Player->GetFinalError(); }
       
   409 		if ( Error ) { HadErrors = ETrue; }
       
   410 		ErrorArray.Append(Error);
       
   411 
       
   412 		CleanupStack::PopAndDestroy(Player);
       
   413 	}
       
   414 
       
   415 	//Do test with the last parameters, and interrupt it.
       
   416 	if (!Error)
       
   417 		{
       
   418 		TTimeIntervalMicroSeconds32 Delay = GetTimeIntervalL(section, KTagDelay, UsingDefault, KDefaultStopDelay);
       
   419 		//Player = CTonePlayer::NewLC();
       
   420 		iOutputPrinter.Printf(_L("Creating Tone Player with frequency (%d) and duration (%d)") , Frequency, Duration);
       
   421 		CTonePlayer *Player = CTonePlayer::NewLC(&iOutputPrinter, Frequency, Duration);
       
   422 		iOutputPrinter.Printf(_L("Repeating (%d) times with silence intervals of (%d) microseconds") , RepeatTimes,RepeatSilence );
       
   423 		Player->SetRepeats(RepeatTimes,RepeatSilence);
       
   424 
       
   425 		CParameters *StopParams = new (ELeave) CParameters( CTonePlayer::KPlayerActionStop );
       
   426 		CleanupStack::PushL(StopParams);
       
   427 		//CMediaEvent *MEventStop = CMediaEvent::NewL(TestModuleIf() , *iLogger, Delay, Delay, Player, StopParams);
       
   428 		CMediaEvent *MEventStop = CMediaEvent::NewL(&iOutputPrinter, Delay, Delay, Player, StopParams);
       
   429 		CleanupStack::Pop(StopParams);
       
   430 		CleanupStack::PushL(MEventStop);
       
   431 
       
   432 		CActiveScheduler::Start();
       
   433 
       
   434 		//TODO: Calculate the expected duration taking into account the final silence (it should be present, according to SACF)
       
   435 		TTimeIntervalMicroSeconds ExpectedDuration = TInt64(Delay.Int());
       
   436 
       
   437 		TTime StartTime = Player->GetPlayStartTime();
       
   438 		TTime EndTimeRange1 = StartTime;
       
   439 		EndTimeRange1+= ExpectedDuration;
       
   440 		TTime EndTimeRange2 = EndTimeRange1;
       
   441 		EndTimeRange1-=ErrorRange;
       
   442 		EndTimeRange2+=ErrorRange;
       
   443 		
       
   444 		iOutputPrinter.Printf(_L("Play duration (%d)") , Player->GetPlayDuration() );
       
   445 		iOutputPrinter.Printf(_L("Expected duration (%d)") , ExpectedDuration);
       
   446 		TTime StopTime= Player->GetPlayStopTime();
       
   447 		if (StopTime<EndTimeRange1 
       
   448 			|| StopTime>EndTimeRange2) {
       
   449 			Error = KErrExpectedValueDifferent;
       
   450 		}
       
   451 		if ( !Error) { Error=Player->GetFinalError(); }
       
   452 		//if ( Player->GetFinalError() ) { Error = Player->GetFinalError(); }
       
   453 
       
   454 		ErrorArray.Append(Error);
       
   455 
       
   456 		CleanupStack::PopAndDestroy(MEventStop);
       
   457 		CleanupStack::PopAndDestroy(Player);
       
   458 		}
       
   459 
       
   460 	RepeatArray.Close();
       
   461 	RepeatSilenceArray.Close();
       
   462 	FrequencyArray.Close();
       
   463 	DurationArray.Close();
       
   464 	ErrorArray.Close();
       
   465 
       
   466 	if (Error == KErrExpectedValueDifferent)
       
   467 		{
       
   468 		aResult.iResult = Error;
       
   469 		aResult.iResultDes.Copy(KTestCaseResultFailExpectedValueDifferent());
       
   470 		iOutputPrinter.Printf(KTestCaseResultFinished() , &KTestCaseResultFailExpectedValueDifferent() );
       
   471 		return KErrExecuted;
       
   472 		}
       
   473 	else if (Error)
       
   474 		{
       
   475 		aResult.iResult = Error;
       
   476 		aResult.iResultDes.Copy(KTestCaseResultFail());
       
   477 		iOutputPrinter.Printf(KTestCaseResultFinished() , &KTestCaseResultFail() );
       
   478 		return KErrExecuted;
       
   479 		}
       
   480 	else
       
   481 		{
       
   482 		aResult.iResult = KErrExecuted;
       
   483 		aResult.iResultDes.Copy(KTestCaseResultSuccess());
       
   484 		iOutputPrinter.Printf(KTestCaseResultFinished() , &KTestCaseResultSuccess() );
       
   485 		return KErrExecuted;
       
   486 		}
       
   487 	}
       
   488 
       
   489 TInt CMmfTsTone::TestCaseFixedSecuencesL(CStifSectionParser * /*section*/ , TTestResult &aResult) 
       
   490 	{
       
   491 	TInt Error=KErrNone;
       
   492 	CTonePlayer *Player = CTonePlayer::NewLC(&iOutputPrinter);
       
   493 	TInt FixedSequenceCount = Player->GetFixedSequenceCount();
       
   494 	
       
   495 	iOutputPrinter.Printf(_L("count of the sequence:%d"),FixedSequenceCount);
       
   496 	for (TInt x=0; x<FixedSequenceCount && !Error; ++x)
       
   497 		{
       
   498 		const TDesC &Name = Player->GetFixedSequenceName(x);
       
   499 		iOutputPrinter.Printf(_L("Name of sequence (%d) is %S") , x , &Name );
       
   500 		Player->PrepareFixedSequence(x, ETrue);
       
   501 		CActiveScheduler::Start();
       
   502 		Error = Player->GetFinalError();
       
   503 		}
       
   504 
       
   505 	CleanupStack::PopAndDestroy(Player);
       
   506 
       
   507 	if (Error)
       
   508 		{
       
   509 		aResult.iResult=Error;
       
   510 		aResult.iResultDes.Copy( KTestCaseResultFail() );
       
   511 		iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
   512 		}
       
   513 	else
       
   514 		{
       
   515 		aResult.iResult=KErrNone;
       
   516 		aResult.iResultDes.Copy( KTestCaseResultSuccess() );
       
   517 		iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultSuccess() );
       
   518 		}
       
   519 	return KErrExecuted;
       
   520 	}
       
   521 
       
   522 TInt CMmfTsTone::TestCasePlayFileSequenceL(CStifSectionParser * section , TTestResult &aResult) 
       
   523 	{
       
   524 	TPtrC FileNamePtr;
       
   525 	TPtrC DesFilePtr;
       
   526 	TBool haveFileName = !section->GetLine(KTagSoundFile, FileNamePtr, ENoTag) ;
       
   527 	TBool haveDesFileName = !section->GetLine(KTagSoundDes, DesFilePtr, ENoTag) ;
       
   528 	if ( haveFileName && haveDesFileName )
       
   529 		{
       
   530 		TBool UsingDefault;
       
   531 		TTimeIntervalMicroSeconds RepeatSilence = GetTimeIntervalL(section, KTagSilenceDuration, UsingDefault, KDefaultSilenceDuration);
       
   532 		TTimeIntervalMicroSeconds ErrorRange = GetTimeIntervalL(section, KTagErrorRange, UsingDefault, KDefaultErrorRange);
       
   533 		TTimeIntervalMicroSeconds ToneSequenceDurationDes = GetTimeIntervalL(section, KTagExpectedDurationDes, UsingDefault, KDefaultToneDuration);
       
   534 		TTimeIntervalMicroSeconds ToneSequenceDuration = GetTimeIntervalL(section, KTagExpectedDuration, UsingDefault, KDefaultToneDuration);
       
   535 
       
   536 		TFileName FileName = DesFilePtr;
       
   537 		HBufC8 *Des = GetDescriptor8LC(FileName);
       
   538 		FileName = FileNamePtr;
       
   539 
       
   540 		TInt Error=KErrNone;
       
   541 		iOutputPrinter.Printf(_L("Creating Tone Player") );
       
   542 		CTonePlayer *Player = CTonePlayer::NewLC(&iOutputPrinter);
       
   543 
       
   544 		RArray<TUint> RepeatArray;
       
   545 		{
       
   546 		iOutputPrinter.Printf(_L("Reading list of repetition configuration"));
       
   547 		TInt RepeatTimes = GetIntL(section, KTagRepeatTimes, UsingDefault, KDefaultRepeats);
       
   548 		do {	//If the configuration is not found, at least add 1 default test
       
   549 			RepeatArray.Append(RepeatTimes);
       
   550 			iOutputPrinter.Printf(_L("Adding (%d) repetitions") , RepeatTimes);
       
   551 		} while ( RepeatTimes=GetIntL(section, KTagRepeatTimes, UsingDefault, 1, ETrue) , !UsingDefault );
       
   552 		}
       
   553 		
       
   554 	//	for (TInt x=0 ; x < RepeatArray.Count() ; ++x)
       
   555 	//		{
       
   556 			Player->PrepareFileSequence(FileName);
       
   557 //			Player->SetRepeats(RepeatArray[x], RepeatSilence);
       
   558 			CActiveScheduler::Start();
       
   559 			Error = Player->GetFinalError();
       
   560 //			if (Error) { break; }
       
   561 //			if (!IsDurationInRange(RepeatArray[x], ToneSequenceDuration, RepeatSilence, ErrorRange, Player->GetPlayStartTime() , Player->GetPlayStopTime() ))
       
   562 //				{ Error = KErrExpectedValueDifferent; break; }
       
   563 			//check durations
       
   564 
       
   565 			Player->PrepareDesSequence(*Des);
       
   566 			//Player->SetRepeats(RepeatArray[x], RepeatSilence);
       
   567 			CActiveScheduler::Start();
       
   568 			Error = Player->GetFinalError();
       
   569 //			if (Error) { break; }
       
   570 			//check durations
       
   571 //			if (!IsDurationInRange(RepeatArray[x], ToneSequenceDurationDes, RepeatSilence, ErrorRange, Player->GetPlayStartTime() , Player->GetPlayStopTime() ))
       
   572 //				{ Error = KErrExpectedValueDifferent; break;}
       
   573 
       
   574 	//		}
       
   575 
       
   576 		CleanupStack::PopAndDestroy(Player);
       
   577 		CleanupStack::PopAndDestroy(Des);
       
   578 		
       
   579 		if (Error==KErrExpectedValueDifferent) 
       
   580 			{
       
   581 			aResult.iResult=Error;
       
   582 			aResult.iResultDes.Copy( KTestCaseResultFailExpectedValueDifferent() );
       
   583 			iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFailExpectedValueDifferent() );
       
   584 			}
       
   585 		else if (Error)
       
   586 			{
       
   587 			aResult.iResult=Error;
       
   588 			aResult.iResultDes.Copy( KTestCaseResultFail() );
       
   589 			iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
   590 			}
       
   591 		else
       
   592 			{
       
   593 			aResult.iResult=KErrNone;
       
   594 			aResult.iResultDes.Copy( KTestCaseResultSuccess() );
       
   595 			iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultSuccess() );
       
   596 			}
       
   597 		RepeatArray.Close();
       
   598 		return KErrExecuted;
       
   599 		}
       
   600 	else
       
   601 		{
       
   602 		//File to play missing
       
   603 		aResult.iResultDes.Copy(KConfigInvalid());
       
   604 		aResult.iResult = KErrNotExecuted;
       
   605 		return KErrConfigInvalid;
       
   606 		}
       
   607 	}
       
   608 
       
   609 
       
   610 
       
   611 
       
   612 TInt CMmfTsTone::TestCaseBalanceL(CStifSectionParser * section , TTestResult &aResult) 
       
   613 	{
       
   614 	TBool UsingDefault;
       
   615 	TInt Error=KErrNone;
       
   616 	RArray<TInt> BalanceArray;
       
   617 
       
   618 	// Reading Balance list
       
   619 	{
       
   620 	iOutputPrinter.Printf(_L("Reading list of balance settings"));
       
   621 	TInt Balance = GetIntL(section, KTagBalance, UsingDefault, KDefaultToneFrequency);
       
   622 	do {	//If the configuration is not found, at least add 1 default test
       
   623 		BalanceArray.Append(Balance);
       
   624 		iOutputPrinter.Printf(_L("Adding balance (%d)") , Balance);
       
   625 	} while ( Balance=GetIntL(section, KTagBalance, UsingDefault, KDefaultToneFrequency, ETrue) , !UsingDefault );
       
   626 	}
       
   627 
       
   628 	CTonePlayer *Player = CTonePlayer::NewLC(&iOutputPrinter);
       
   629 	TInt FixedSequenceCount = Player->GetFixedSequenceCount();
       
   630 	iOutputPrinter.Printf(_L("Fixed sequence count is (%d)") , FixedSequenceCount );
       
   631 
       
   632 	TInt FixedSequenceNumber = GetIntL(section, KTagSequenceNumber, UsingDefault, KDefaultSequenceNumber);
       
   633 	const TDesC &Name = Player->GetFixedSequenceName(FixedSequenceNumber);
       
   634 	iOutputPrinter.Printf(_L("Name of sequence (%d) is %S") , FixedSequenceNumber , &Name );
       
   635 	
       
   636 	for (TInt x=0 ; x<BalanceArray.Count() && !Error; ++x)
       
   637 		{
       
   638 		TInt Balance;
       
   639 		Player->PrepareFixedSequence(FixedSequenceNumber);
       
   640 		iOutputPrinter.Printf(_L("Setting balance to (%d)") , BalanceArray[x] );
       
   641 		Player->SetBalanceL(BalanceArray[x]);
       
   642 		CActiveScheduler::Start();
       
   643 		Error = Player->GetFinalError();
       
   644 		if (!Error) 
       
   645 			{
       
   646 			Balance = Player->GetBalanceL();
       
   647 			iOutputPrinter.Printf(_L("Balance is set to (%d)") , Balance);
       
   648 			if ( BalanceArray[x] != Balance)
       
   649 				{
       
   650 				iOutputPrinter.Printf(_L("Balance set is different from balance read"));
       
   651 				Error = KErrExpectedValueDifferent;
       
   652 				}
       
   653 			}
       
   654 		}
       
   655 
       
   656 	CleanupStack::PopAndDestroy(Player);
       
   657 
       
   658 	if (Error==KErrExpectedValueDifferent)
       
   659 		{
       
   660 		aResult.iResult=KErrExpectedValueDifferent;
       
   661 		aResult.iResultDes.Copy( KTestCaseResultFail() );
       
   662 		iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFailExpectedValueDifferent() );
       
   663 		}
       
   664 	else if (Error)
       
   665 		{
       
   666 		aResult.iResult=Error;
       
   667 		aResult.iResultDes.Copy( KTestCaseResultFail() );
       
   668 		iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
   669 		}
       
   670 	else
       
   671 		{
       
   672 		aResult.iResult=KErrNone;
       
   673 		aResult.iResultDes.Copy( KTestCaseResultSuccess() );
       
   674 		iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultSuccess() );
       
   675 		}
       
   676 	BalanceArray.Close();
       
   677 	return KErrExecuted;
       
   678 	}
       
   679 
       
   680 TInt CMmfTsTone::TestCasePrioritiesL(CStifSectionParser * section , TTestResult &aResult) 
       
   681 	{
       
   682 	TBool UsingDefault;
       
   683 	TInt Error=KErrNone;
       
   684 	RArray<TInt> PrioritiesArray;
       
   685 
       
   686 	//Read the priorities
       
   687 	//Sort them from high to low
       
   688 
       
   689 	TInt FixedSequenceNumber = GetIntL(section, KTagSequenceNumber, UsingDefault, KDefaultSequenceNumber);
       
   690 	iOutputPrinter.Printf(_L("Fixed sequence number read (%d)") , FixedSequenceNumber);
       
   691 
       
   692 	iOutputPrinter.Printf(_L("Reading list of priorities"));
       
   693 	CStifItemParser *item = section->GetItemLineL(KTagPriority, ENoTag);
       
   694 	if (item)
       
   695 		{
       
   696 		TInt Priority=0;
       
   697 		TInt x=0;
       
   698 		CleanupStack::PushL(item);
       
   699 
       
   700 		Error = item->GetInt(KNullDesC, Priority);
       
   701 		while (!Error && x < 3)
       
   702 		{	
       
   703 			PrioritiesArray.InsertInOrderAllowRepeats(Priority);
       
   704 			Error = item->GetNextInt(Priority);
       
   705 			++x;
       
   706 		}
       
   707 		//if (Error) { Error = KErrConfigInvalid; }
       
   708 		Error = ( (PrioritiesArray.Count() < 3) ? KErrNotFound:KErrNone );
       
   709 		CleanupStack::PopAndDestroy(item);
       
   710 		}
       
   711 	else
       
   712 		{
       
   713 		Error = KErrNotFound;
       
   714 		}
       
   715 	if (Error) 
       
   716 		{
       
   717 		PrioritiesArray.Close();
       
   718 		aResult.iResult=Error;
       
   719 		aResult.iResultDes.Copy( KConfigInvalid() );
       
   720 		iOutputPrinter.Printf(KTestCaseResultFinished, &KConfigInvalid() );
       
   721 		return KErrNotExecuted;
       
   722 		}
       
   723 
       
   724 	TObjectCountDown counter;
       
   725 	
       
   726 	// We have 3 priorities sorted in PrioritiesArray
       
   727 	CTonePlayer *PlayerHigh = CTonePlayer::NewLC(&iOutputPrinter);
       
   728 	CTonePlayer *PlayerMed = CTonePlayer::NewLC(&iOutputPrinter);
       
   729 	CTonePlayer *PlayerLow = CTonePlayer::NewLC(&iOutputPrinter);
       
   730 
       
   731 	iOutputPrinter.Printf(_L("Creating PlayerLow with id (1) and priority (%d)") , PrioritiesArray[0] );
       
   732 	PlayerLow->SetPriority( PrioritiesArray[0] , EMdaPriorityPreferenceNone);
       
   733 	PlayerLow->SetId(1);
       
   734 	PlayerLow->SetSupervisor(&counter);
       
   735 
       
   736 	iOutputPrinter.Printf(_L("Creating PlayerMed with id (2) and priority (%d)") , PrioritiesArray[1] );
       
   737 	PlayerMed->SetPriority( PrioritiesArray[1] , EMdaPriorityPreferenceNone);
       
   738 	PlayerMed->SetId(2);
       
   739 	PlayerMed->SetSupervisor(&counter);
       
   740 
       
   741 	iOutputPrinter.Printf(_L("Creating PlayerLow with id (3) and priority (%d)") , PrioritiesArray[2] );
       
   742 	PlayerHigh->SetPriority( PrioritiesArray[2] , EMdaPriorityPreferenceNone);
       
   743 	PlayerHigh->SetId(3);
       
   744 	PlayerHigh->SetSupervisor(&counter);
       
   745 
       
   746 	//Test 1, Medium - Low - High
       
   747 	iOutputPrinter.Printf(_L("Playing Med(2), Low(1), High(3)"));
       
   748 	PlayerMed->PrepareFixedSequence(FixedSequenceNumber);
       
   749 	PlayerLow->PrepareFixedSequence(FixedSequenceNumber);
       
   750 	PlayerHigh->PrepareFixedSequence(FixedSequenceNumber);
       
   751 	CActiveScheduler::Start();
       
   752 
       
   753 	Error = PlayerHigh->GetFinalError();
       
   754 
       
   755 	if (!Error)
       
   756 		{
       
   757 		iOutputPrinter.Printf(_L("Playing High(3), Low(1), Med(2)"));
       
   758 		PlayerLow->SetSupervisor(&counter);
       
   759 		PlayerMed->SetSupervisor(&counter);
       
   760 		PlayerHigh->SetSupervisor(&counter);
       
   761 
       
   762 		PlayerHigh->PrepareFixedSequence(FixedSequenceNumber);
       
   763 		PlayerLow->PrepareFixedSequence(FixedSequenceNumber);
       
   764 		PlayerMed->PrepareFixedSequence(FixedSequenceNumber);
       
   765 		CActiveScheduler::Start();
       
   766 
       
   767 		Error = PlayerHigh->GetFinalError();
       
   768 		}
       
   769 	if (!Error)
       
   770 		{
       
   771 		iOutputPrinter.Printf(_L("Playing Low(1), High(3), Med(2)"));
       
   772 		PlayerLow->SetSupervisor(&counter);
       
   773 		PlayerMed->SetSupervisor(&counter);
       
   774 		PlayerHigh->SetSupervisor(&counter);
       
   775 
       
   776 		PlayerLow->PrepareFixedSequence(FixedSequenceNumber);
       
   777 		PlayerHigh->PrepareFixedSequence(FixedSequenceNumber);
       
   778 		PlayerMed->PrepareFixedSequence(FixedSequenceNumber);
       
   779 		CActiveScheduler::Start();
       
   780 
       
   781 		Error = PlayerHigh->GetFinalError();
       
   782 		}
       
   783 	
       
   784 	CleanupStack::PopAndDestroy(PlayerLow);
       
   785 	CleanupStack::PopAndDestroy(PlayerMed);
       
   786 	CleanupStack::PopAndDestroy(PlayerHigh);
       
   787 
       
   788 	if (Error)
       
   789 		{
       
   790 		aResult.iResult=Error;
       
   791 		aResult.iResultDes.Copy( KTestCaseResultFail() );
       
   792 		iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
   793 		}
       
   794 	else
       
   795 		{
       
   796 		aResult.iResult=KErrNone;
       
   797 		aResult.iResultDes.Copy( KTestCaseResultSuccess() );
       
   798 		iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultSuccess() );
       
   799 		}
       
   800 	PrioritiesArray.Close();
       
   801 	return KErrExecuted;
       
   802 	}
       
   803 
       
   804 TInt CMmfTsTone::TestCaseDTMFStringL(CStifSectionParser * section , TTestResult &aResult) 
       
   805 	{
       
   806 	//aResult.Result=KErrLeft;
       
   807 	TBool UsingDefault;
       
   808 	TTimeIntervalMicroSeconds ErrorRange = GetTimeIntervalL(section, KTagErrorRange, UsingDefault, KDefaultErrorRange);
       
   809 	TTimeIntervalMicroSeconds32 ToneDuration = GetTimeIntervalL(section, KTagToneDuration, UsingDefault, KDefaultDTMFToneDuration);
       
   810 	TTimeIntervalMicroSeconds32 ToneOffDuration = GetTimeIntervalL(section, KTagSilenceDuration, UsingDefault, KDefaultDTMFSilenceDuration);
       
   811 	TTimeIntervalMicroSeconds32 Pause = GetTimeIntervalL(section, KTagDelay, UsingDefault, KDefaultPauseDelay);
       
   812 	TInt Error = KErrNone;
       
   813 	HBufC *DTMFString;
       
   814 
       
   815 	{
       
   816 	TPtrC PtrDTMFString;
       
   817 	if (section->GetLine(KTagDTMFString, PtrDTMFString, ENoTag) )
       
   818 		{
       
   819 		DTMFString = KDefaultDTMFString().AllocLC();
       
   820 		}
       
   821 	else
       
   822 		{
       
   823 		DTMFString = PtrDTMFString.AllocLC();
       
   824 		}
       
   825 	}
       
   826 
       
   827 	iOutputPrinter.Printf(_L("Creating Tone Player") );
       
   828 	CTonePlayer *Player = CTonePlayer::NewLC(&iOutputPrinter);
       
   829 	iOutputPrinter.Printf(_L("Preparing DTMF sequence [%S]") , DTMFString);
       
   830 	Player->PrepareDTMFSequence(*DTMFString);
       
   831 	Player->SetDTMFLengths(ToneDuration, ToneOffDuration, Pause);
       
   832 
       
   833 	iOutputPrinter.Printf(_L("Starting scheduler"));
       
   834 	CActiveScheduler::Start();
       
   835 
       
   836 	Error = Player->GetFinalError();
       
   837 
       
   838 	TTime ExpectedEnd = Player->GetPlayStartTime();
       
   839 	for (TInt x=0 ; x < DTMFString->Length() ; ++x)
       
   840 		{
       
   841 		if ( (*DTMFString)[x] == KPauseCharacter()[0] )
       
   842 			{
       
   843 			ExpectedEnd += Pause;
       
   844 			}
       
   845 		else
       
   846 			{
       
   847 			ExpectedEnd += ToneDuration;
       
   848 			ExpectedEnd += ToneOffDuration;
       
   849 			}
       
   850 		}
       
   851 
       
   852 	iOutputPrinter.Printf(_L("Expected duration: (%d)") , ExpectedEnd.MicroSecondsFrom(Player->GetPlayStartTime()) );
       
   853 	iOutputPrinter.Printf(_L("Real duration: (%d)") , Player->GetPlayDuration() );
       
   854 
       
   855 	TTime ExpectedEnd2 = ExpectedEnd;
       
   856 	ExpectedEnd -= ErrorRange;
       
   857 	ExpectedEnd2 += ErrorRange;
       
   858 
       
   859 	TBool InRange = ExpectedEnd<Player->GetPlayStopTime() && Player->GetPlayStopTime()<ExpectedEnd2 ;
       
   860 	if (!InRange)
       
   861 		{
       
   862 		Error = KErrExpectedValueDifferent;
       
   863 		}
       
   864 
       
   865 	CleanupStack::PopAndDestroy(Player);
       
   866 	CleanupStack::PopAndDestroy(DTMFString);
       
   867 	
       
   868 	if (!InRange)
       
   869 		{
       
   870 		aResult.iResult = KErrExpectedValueDifferent;
       
   871 		aResult.iResultDes.Copy(KTestCaseResultFailExpectedValueDifferent());
       
   872 		iOutputPrinter.Printf( KTestCaseResultFinished() , &KTestCaseResultFailExpectedValueDifferent() );
       
   873 		}
       
   874 	else if (Error)
       
   875 		{
       
   876 		aResult.iResult=Error;
       
   877 		aResult.iResultDes.Copy( KTestCaseResultFail() );
       
   878 		iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
   879 		}
       
   880 	else
       
   881 		{
       
   882 		aResult.iResult=KErrNone;
       
   883 		aResult.iResultDes.Copy( KTestCaseResultSuccess() );
       
   884 		iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultSuccess() );
       
   885 		}
       
   886 	return KErrExecuted;
       
   887 	
       
   888 	}
       
   889 
       
   890 TInt CMmfTsTone::TestCaseDualToneL(CStifSectionParser * section , TTestResult &aResult) 
       
   891 	{
       
   892 	
       
   893 	TBool UsingDefault;
       
   894 	TTimeIntervalMicroSeconds ErrorRange = GetTimeIntervalL(section, KTagErrorRange, UsingDefault, KDefaultErrorRange);
       
   895 	TTimeIntervalMicroSeconds ToneDuration = GetTimeIntervalL(section, KTagToneDuration, UsingDefault, KDefaultToneDuration);
       
   896 	TInt Frequency1=KDefaultToneFrequency;
       
   897 	TInt Frequency2=KDefaultToneFrequency;
       
   898 	
       
   899 	TInt Error = KErrNone;
       
   900 	
       
   901     TInt ValidityCheck=GetIntL(section, KTagValidity, UsingDefault, KDefaultValidity);
       
   902 	//Obtain the tone's frequency
       
   903 	Frequency1 = GetIntL(section, KTagToneFrequency, UsingDefault, KDefaultToneFrequency);
       
   904 	if (UsingDefault)
       
   905 		{
       
   906 		iOutputPrinter.Printf(_L("Using default tone frequency for player") );
       
   907 		}
       
   908 	else
       
   909 		{
       
   910 		iOutputPrinter.Printf(_L("Using frequency 1 for player (%d)") , Frequency1);
       
   911 		}
       
   912 	Frequency2 = GetIntL(section, KTagToneFrequency, UsingDefault, KDefaultToneFrequency, ETrue);
       
   913 	if (UsingDefault)
       
   914 		{
       
   915 		iOutputPrinter.Printf(_L("Using default tone frequency for player") );
       
   916 		}
       
   917 	else
       
   918 		{
       
   919 		iOutputPrinter.Printf(_L("Using frequency 2 for player (%d)") , Frequency2);
       
   920 		}
       
   921 
       
   922 	
       
   923 
       
   924 	iOutputPrinter.Printf(_L("Creating Tone Player") );
       
   925 	CTonePlayer *Player = CTonePlayer::NewLC(&iOutputPrinter);
       
   926 	
       
   927 	Player->PrepareDualTone(Frequency1, Frequency2, ToneDuration);
       
   928 
       
   929 	iOutputPrinter.Printf(_L("Starting scheduler"));
       
   930 	CActiveScheduler::Start();
       
   931 
       
   932 	Error = Player->GetFinalError();
       
   933 
       
   934 	TBool InRange=ETrue;
       
   935 	if (!IsDurationInRange(0, ToneDuration, TTimeIntervalMicroSeconds(0), ErrorRange, Player->GetPlayStartTime(), Player->GetPlayStopTime() ) )
       
   936 		{ //validity check=1 for invalid timeduration
       
   937 		if(ValidityCheck!=1 && Error!=KErrArgument)
       
   938 		    {
       
   939 		    Error = KErrExpectedValueDifferent;
       
   940 		    }
       
   941 		
       
   942 		InRange=EFalse;
       
   943 		}
       
   944 
       
   945 
       
   946 	CleanupStack::PopAndDestroy(Player);
       
   947 	
       
   948 	
       
   949 	if (!InRange)
       
   950 		{
       
   951 		if(ValidityCheck==1)
       
   952 		    {
       
   953 		    if(Error==KErrArgument)
       
   954               {
       
   955                aResult.iResult=KErrNone;
       
   956                aResult.iResultDes.Copy( KTestCaseResultSuccess() );
       
   957                iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultSuccess() );
       
   958               }
       
   959 		    else
       
   960 		       {
       
   961 		        aResult.iResult=Error;
       
   962 		        aResult.iResultDes.Copy( KTestCaseResultFail() );
       
   963 		        iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
   964 		       }
       
   965 		    }
       
   966 		else
       
   967 		    {
       
   968 		aResult.iResult = KErrExpectedValueDifferent;
       
   969 		aResult.iResultDes.Copy(KTestCaseResultFailExpectedValueDifferent());
       
   970 		iOutputPrinter.Printf( KTestCaseResultFinished() , &KTestCaseResultFailExpectedValueDifferent() );
       
   971 		
       
   972 		}
       
   973 	}
       
   974 	//validity check=2,for invalid frequencies
       
   975 	else if(ValidityCheck==2)
       
   976 	    {
       
   977 	      if(Error==KErrArgument)
       
   978 	        {
       
   979                aResult.iResult=KErrNone;
       
   980                aResult.iResultDes.Copy( KTestCaseResultSuccess() );
       
   981                iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultSuccess() );
       
   982             }
       
   983           else
       
   984            {
       
   985                 aResult.iResult=Error;
       
   986                 aResult.iResultDes.Copy( KTestCaseResultFail() );
       
   987                 iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
   988            }
       
   989 	    }
       
   990 	
       
   991 	else if (Error)
       
   992 		{
       
   993 		aResult.iResult=Error;
       
   994 		aResult.iResultDes.Copy( KTestCaseResultFail() );
       
   995 		iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
   996 		}
       
   997 	else
       
   998 		{
       
   999 		aResult.iResult=KErrNone;
       
  1000 		aResult.iResultDes.Copy( KTestCaseResultSuccess() );
       
  1001 		iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultSuccess() );
       
  1002 		}
       
  1003 	return KErrExecuted;
       
  1004 	
       
  1005 	}
       
  1006 
       
  1007 TInt CMmfTsTone::TestCaseCancelPrepareL(CStifSectionParser *section , TTestResult &aResult)
       
  1008 	{
       
  1009 	TBool UsingDefault, NotUsingCancel;
       
  1010 	TInt PrepareWhat = GetIntL(section, KTagPrepare, UsingDefault, 1);
       
  1011 	TTimeIntervalMicroSeconds32 TimeOutDuration = GetTimeIntervalL(section, KTagTimeOut, UsingDefault, KDefaultTimeOutDuration);
       
  1012 	TInt Error = KErrNone;
       
  1013 	TInt CancelPriority = GetIntL(section, KTagCancelPriority, NotUsingCancel, CActive::EPriorityHigh);
       
  1014 	HBufC8 *Des=0;
       
  1015 
       
  1016 	CTonePlayer *Player=0;
       
  1017 	CImmediateMediaEvent *PrepareMediaEvent=0;
       
  1018 	CParameters *PrepareParameters=0;
       
  1019 
       
  1020 	switch (PrepareWhat) {
       
  1021 		case CTonePlayer::EPrepareTone:
       
  1022 			{
       
  1023 			//Obtain the tone's frequency
       
  1024 			TInt Frequency = GetIntL(section, KTagToneFrequency, UsingDefault, KDefaultToneFrequency);
       
  1025 			if (UsingDefault)
       
  1026 				{
       
  1027 				iOutputPrinter.Printf(_L("Using default tone frequency (%d) for player") , Frequency);
       
  1028 				}
       
  1029 			else
       
  1030 				{
       
  1031 				iOutputPrinter.Printf(_L("Using frequency 1 for player (%d)") , Frequency);
       
  1032 				}
       
  1033 			TTimeIntervalMicroSeconds ToneDuration = GetTimeIntervalL(section, KTagToneDuration, UsingDefault, KDefaultToneDuration);
       
  1034 			iOutputPrinter.Printf(_L("Creating Tone Player") );
       
  1035 			Player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1036 			
       
  1037 			TFixedArray<TInt64, 2> FreqAndDuration;
       
  1038 			FreqAndDuration[0] = Frequency;
       
  1039 			FreqAndDuration[1] = ToneDuration.Int64() ;
       
  1040 			PrepareParameters = CTemplateParameters<TFixedArray<TInt64, 2> >::NewL(CTonePlayer::KPlayerActionPrepareTone, FreqAndDuration);
       
  1041 			CleanupStack::PushL(PrepareParameters);
       
  1042 
       
  1043 			//PrepareMediaEvent = CImmediateMediaEvent::NewLC(TestModuleIf(), *iLogger, Player, PrepareParameters, CancelPriority+1);
       
  1044 			PrepareMediaEvent = CImmediateMediaEvent::NewLC(&iOutputPrinter, Player, PrepareParameters, CancelPriority+1);
       
  1045 			PrepareMediaEvent->FireExecute();
       
  1046 			break;
       
  1047 			}
       
  1048 
       
  1049 		case CTonePlayer::EPrepareFixedSequence:
       
  1050 			{
       
  1051 			TInt SequenceNumber = GetIntL(section, KTagSequenceNumber, UsingDefault, 0);
       
  1052 			Player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1053 			//Player->PrepareFixedSequence(SequenceNumber);
       
  1054 
       
  1055 			PrepareParameters = CTemplateParameters<TInt>::NewL(CTonePlayer::KPlayerActionPrepareFixedSequence, SequenceNumber);
       
  1056 			CleanupStack::PushL(PrepareParameters);
       
  1057 
       
  1058 			PrepareMediaEvent = CImmediateMediaEvent::NewLC(&iOutputPrinter, Player, PrepareParameters, CancelPriority+1);
       
  1059 			PrepareMediaEvent->FireExecute();
       
  1060 			break;
       
  1061 			}
       
  1062 
       
  1063 		case CTonePlayer::EPrepareFileSequence:
       
  1064 			{
       
  1065 			TPtrC FileNamePtr;
       
  1066 			TBool haveFileName = !section->GetLine(KTagSoundFile, FileNamePtr, ENoTag);
       
  1067 			if (haveFileName)
       
  1068 				{
       
  1069 				Player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1070 
       
  1071 				TFileName a = FileNamePtr;
       
  1072 				PrepareParameters = CTemplateParameters<TFileName>::NewL(CTonePlayer::KPlayerActionPrepareFileSequence, a);
       
  1073 				CleanupStack::PushL(PrepareParameters);
       
  1074 				
       
  1075 				PrepareMediaEvent = CImmediateMediaEvent::NewLC(&iOutputPrinter, Player, PrepareParameters, CancelPriority+1);
       
  1076 				PrepareMediaEvent->FireExecute();
       
  1077 				}
       
  1078 			else
       
  1079 				{
       
  1080 				iOutputPrinter.Printf(_L("File Name is required"));
       
  1081 				}
       
  1082 			break;
       
  1083 			}
       
  1084 		case CTonePlayer::EPrepareDesSequence:
       
  1085 			{
       
  1086 			TPtrC FileNamePtr;
       
  1087 			TBool haveFileName = !section->GetLine(KTagSoundFile, FileNamePtr, ENoTag);
       
  1088 			if (haveFileName)
       
  1089 				{
       
  1090 				Des = GetDescriptor8LC(FileNamePtr);
       
  1091 				Player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1092 
       
  1093 				PrepareParameters = CTemplateParameters<HBufC8*>::NewL(CTonePlayer::KPlayerActionPrepareDesSequence, Des);
       
  1094 				CleanupStack::PushL(PrepareParameters);
       
  1095 				
       
  1096 				PrepareMediaEvent = CImmediateMediaEvent::NewLC(&iOutputPrinter, Player, PrepareParameters, CancelPriority+1);
       
  1097 				PrepareMediaEvent->FireExecute();
       
  1098 				}
       
  1099 			else
       
  1100 				{
       
  1101 				iOutputPrinter.Printf(_L("File Name is required"));
       
  1102 				}
       
  1103 			break;
       
  1104 			}
       
  1105 		case CTonePlayer::EPrepareDTMF:
       
  1106 			{
       
  1107 			TTimeIntervalMicroSeconds32 ToneDuration = GetTimeIntervalL(section, KTagToneDuration, UsingDefault, KDefaultDTMFToneDuration);
       
  1108 			TTimeIntervalMicroSeconds32 ToneOffDuration = GetTimeIntervalL(section, KTagSilenceDuration, UsingDefault, KDefaultDTMFSilenceDuration);
       
  1109 			TTimeIntervalMicroSeconds32 Pause = GetTimeIntervalL(section, KTagDelay, UsingDefault, KDefaultPauseDelay, ETrue);
       
  1110 
       
  1111 			iOutputPrinter.Printf(_L("Creating Tone Player") );
       
  1112 			Player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1113 			{
       
  1114 			TPtrC PtrDTMFString;
       
  1115 			if (section->GetLine(KTagDTMFString, PtrDTMFString, ENoTag) )
       
  1116 				{
       
  1117 				PrepareParameters = CDTMFParameters::NewLC(CTonePlayer::KPlayerActionPrepareDTMFSequence, ToneDuration, ToneOffDuration, Pause, KDefaultDTMFString);
       
  1118 				}
       
  1119 			else
       
  1120 				{
       
  1121 				PrepareParameters = CDTMFParameters::NewLC(CTonePlayer::KPlayerActionPrepareDTMFSequence, ToneDuration, ToneOffDuration, Pause, PtrDTMFString);
       
  1122 				}
       
  1123 			}
       
  1124 			iOutputPrinter.Printf(_L("Preparing DTMF sequence [%S]") , static_cast<CDTMFParameters*>(PrepareParameters)->GetDTMFString() );
       
  1125 			PrepareMediaEvent = CImmediateMediaEvent::NewLC(&iOutputPrinter, Player, PrepareParameters, CancelPriority+1);
       
  1126 			PrepareMediaEvent->FireExecute();
       
  1127 			break;
       
  1128 			}
       
  1129 		case CTonePlayer::EPrepareDualTone:
       
  1130 			{
       
  1131 			//Obtain the tone's frequency
       
  1132 			TInt Frequency1 = GetIntL(section, KTagToneFrequency, UsingDefault, KDefaultToneFrequency);
       
  1133 			if (UsingDefault)
       
  1134 				{
       
  1135 				iOutputPrinter.Printf(_L("Using default tone frequency 1 for player (%d)") , Frequency1);
       
  1136 				}
       
  1137 			else
       
  1138 				{
       
  1139 				iOutputPrinter.Printf(_L("Using frequency 1 for player (%d)") , Frequency1);
       
  1140 				}
       
  1141 			TInt Frequency2 = GetIntL(section, KTagToneFrequency, UsingDefault, KDefaultToneFrequency, ETrue);
       
  1142 			if (UsingDefault)
       
  1143 				{
       
  1144 				iOutputPrinter.Printf(_L("Using default tone frequency 2 for player (%d) ") , Frequency2);
       
  1145 				}
       
  1146 			else
       
  1147 				{
       
  1148 				iOutputPrinter.Printf(_L("Using frequency 2 for player (%d)") , Frequency2);
       
  1149 				}
       
  1150 			TTimeIntervalMicroSeconds ToneDuration = GetTimeIntervalL(section, KTagToneDuration, UsingDefault, KDefaultToneDuration);
       
  1151 			iOutputPrinter.Printf(_L("Using duration (%d) for player"), ToneDuration);
       
  1152 			iOutputPrinter.Printf(_L("Creating Tone Player") );
       
  1153 			Player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1154 
       
  1155 			TFixedArray<TInt64, 3> FreqAndDuration;
       
  1156 			FreqAndDuration[0] = Frequency1;
       
  1157 			FreqAndDuration[1] = Frequency2;
       
  1158 			FreqAndDuration[2] = ToneDuration.Int64() ;
       
  1159 			PrepareParameters = CTemplateParameters<TFixedArray<TInt64, 3> >::NewL(CTonePlayer::KPlayerActionPrepareDualTone, FreqAndDuration);
       
  1160 			CleanupStack::PushL(PrepareParameters);
       
  1161 
       
  1162 			PrepareMediaEvent = CImmediateMediaEvent::NewLC(&iOutputPrinter, Player, PrepareParameters, CancelPriority+1);
       
  1163 			PrepareMediaEvent->FireExecute();
       
  1164 			break;
       
  1165 			}
       
  1166 	}
       
  1167 	if (!Player)
       
  1168 		{
       
  1169 		iOutputPrinter.Printf(_L("Tone player not created properly"));
       
  1170 		aResult.iResult=KErrNotFound;
       
  1171 		aResult.iResultDes.Copy( KTestCaseResultFail() );
       
  1172 		iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
  1173 		return KErrNotExecuted;
       
  1174 		}
       
  1175 	else
       
  1176 		{
       
  1177 		//Player created succesfully, testing
       
  1178 		
       
  1179 		// Add Timeout to check that MatoComplete in Player is not called without hanging the test
       
  1180 		CParameters *TimeOutParams = new(ELeave) CParameters(CTonePlayer::KPlayerActionStop);
       
  1181 		CleanupStack::PushL(TimeOutParams);
       
  1182 		CMediaEvent *TimeOut = CMediaEvent::NewLC(&iOutputPrinter, TimeOutDuration, TimeOutDuration, Player, TimeOutParams);
       
  1183 
       
  1184 		// Add object to cancel preparation
       
  1185 		CParameters *params = new(ELeave) CParameters(CTonePlayer::KPlayerActionCancelPrepare);
       
  1186 		CleanupStack::PushL(params);
       
  1187 		CImmediateMediaEvent *ime = CImmediateMediaEvent::NewLC(&iOutputPrinter, Player, params, CancelPriority );
       
  1188 		if (!NotUsingCancel) ime->FireExecute();
       
  1189 		
       
  1190 		iOutputPrinter.Printf(_L("Starting scheduler"));
       
  1191 		CActiveScheduler::Start();
       
  1192 
       
  1193 		Error = Player->GetFinalError();
       
  1194 		TInt CompleteCallbackCount = Player->GetPrepareCompleteCallbackCount();
       
  1195 		iOutputPrinter.Printf(_L("MatoPrepareCompleteCallback was called (%d) times, last error was (%d)"), CompleteCallbackCount, Player->GetLastPrepareCompleteError());
       
  1196 		iOutputPrinter.Printf(_L("TimeOut was called (%d) times"), TimeOut->GetCount() );
       
  1197 
       
  1198 		CleanupStack::PopAndDestroy(ime);
       
  1199 		CleanupStack::Pop(params);
       
  1200 		CleanupStack::PopAndDestroy(TimeOut);
       
  1201 		CleanupStack::Pop(TimeOutParams);
       
  1202 
       
  1203 		
       
  1204 		/*if (PrepareMediaEvent)*/ CleanupStack::PopAndDestroy(PrepareMediaEvent);
       
  1205 		/*if (PrepareParameters)*/ CleanupStack::Pop(PrepareParameters);
       
  1206 		CleanupStack::PopAndDestroy(Player);
       
  1207 		if (Des) CleanupStack::PopAndDestroy(Des);
       
  1208 		
       
  1209 		if (CompleteCallbackCount > 0) 
       
  1210 			{
       
  1211 			aResult.iResult=KErrExpectedValueDifferent;
       
  1212 			aResult.iResultDes.Copy( KTestCaseResultFailExpectedValueDifferent() );
       
  1213 			iOutputPrinter.Printf( KTestCaseResultFinished() , &KTestCaseResultFailExpectedValueDifferent() );
       
  1214 			}
       
  1215 		else if (Error)
       
  1216 			{
       
  1217 			aResult.iResult=Error;
       
  1218 			aResult.iResultDes.Copy( KTestCaseResultFail() );
       
  1219 			iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
  1220 			}
       
  1221 		else
       
  1222 			{
       
  1223 			aResult.iResult=KErrNone;
       
  1224 			aResult.iResultDes.Copy( KTestCaseResultSuccess() );
       
  1225 			iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultSuccess() );
       
  1226 			}
       
  1227 		return KErrExecuted;
       
  1228 		}
       
  1229 	}
       
  1230 
       
  1231 TInt CMmfTsTone::TestCasePlayToneFileL(CStifSectionParser *section , TTestResult &aResult)
       
  1232 	{
       
  1233 	TPtrC FileNamePtr;
       
  1234 	TBool haveFileName = !section->GetLine(KTagSoundFile, FileNamePtr, ENoTag) ;
       
  1235 	if ( haveFileName )
       
  1236 		{
       
  1237 		TBool UsingDefaultErrorRange;
       
  1238 		TBool UsingDefaultExpectedDuration;
       
  1239 		TTimeIntervalMicroSeconds ErrorRange = GetTimeIntervalL(section, KTagErrorRange, UsingDefaultErrorRange, KDefaultErrorRange);
       
  1240 		TTimeIntervalMicroSeconds ToneSequenceDuration = GetTimeIntervalL(section, KTagExpectedDuration, UsingDefaultExpectedDuration, KDefaultToneDuration);
       
  1241 
       
  1242 		TFileName FileName = FileNamePtr;
       
  1243 
       
  1244 		TInt Error=KErrNone;
       
  1245 		iOutputPrinter.Printf(_L("Creating Tone Player") );
       
  1246 		CTonePlayer *Player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1247 
       
  1248 		Player->PrepareFileSequence(FileName);
       
  1249 		CActiveScheduler::Start();
       
  1250 		Error = Player->GetFinalError();
       
  1251 
       
  1252 		if (!UsingDefaultExpectedDuration && !Error) 
       
  1253 			{
       
  1254 			iOutputPrinter.Printf(_L("Comparing duration with expected duration") );
       
  1255 			if (!IsDurationInRange(0, ToneSequenceDuration, TTimeIntervalMicroSeconds(0), ErrorRange, Player->GetPlayStartTime() , Player->GetPlayStopTime() ))
       
  1256 				{
       
  1257 				Error = KErrExpectedValueDifferent; 
       
  1258 				}
       
  1259 			}
       
  1260 
       
  1261 		CleanupStack::PopAndDestroy(Player);
       
  1262 		
       
  1263 		if (Error==KErrExpectedValueDifferent) 
       
  1264 			{
       
  1265 			aResult.iResult=Error;
       
  1266 			aResult.iResultDes.Copy( KTestCaseResultFailExpectedValueDifferent() );
       
  1267 			iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFailExpectedValueDifferent() );
       
  1268 			}
       
  1269 		else if (Error)
       
  1270 			{
       
  1271 			aResult.iResult=Error;
       
  1272 			aResult.iResultDes.Copy( KTestCaseResultFail() );
       
  1273 			iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
  1274 			}
       
  1275 		else
       
  1276 			{
       
  1277 			aResult.iResult=KErrNone;
       
  1278 			aResult.iResultDes.Copy( KTestCaseResultSuccess() );
       
  1279 			iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultSuccess() );
       
  1280 			}
       
  1281 		//RepeatArray.Close();
       
  1282 		return KErrExecuted;
       
  1283 		}
       
  1284 	else
       
  1285 		{
       
  1286 		//File to play missing
       
  1287 		iOutputPrinter.Printf(_L("Filename to play not configured"));
       
  1288 		aResult.iResultDes.Copy(KConfigInvalid());
       
  1289 		aResult.iResult = KErrNotExecuted;
       
  1290 		return KErrConfigInvalid;
       
  1291 		}
       
  1292 	}
       
  1293 
       
  1294 TInt CMmfTsTone::TestCasePlayToneRFileL(CStifSectionParser *section , TTestResult &aResult)   
       
  1295 	{
       
  1296 	TPtrC FileNamePtr;
       
  1297 	TBool haveFileName = !section->GetLine(KTagSoundFile, FileNamePtr, ENoTag) ;
       
  1298 	if ( haveFileName )
       
  1299 		{
       
  1300 		TBool UsingDefaultErrorRange;
       
  1301 		TBool UsingDefaultExpectedDuration;
       
  1302 		TTimeIntervalMicroSeconds ErrorRange = GetTimeIntervalL(section, KTagErrorRange, UsingDefaultErrorRange, KDefaultErrorRange);
       
  1303 		TTimeIntervalMicroSeconds ToneSequenceDuration = GetTimeIntervalL(section, KTagExpectedDuration, UsingDefaultExpectedDuration, KDefaultToneDuration);
       
  1304 
       
  1305 		TFileName FileName = FileNamePtr;
       
  1306 
       
  1307 		TInt Error=KErrNone;
       
  1308 		iOutputPrinter.Printf(_L("Creating Tone Player") );
       
  1309 		CTonePlayer *Player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1310 
       
  1311 		Player->PrepareRFileSequence(FileName);
       
  1312 		CActiveScheduler::Start();
       
  1313 		Error = Player->GetFinalError();
       
  1314 
       
  1315 		if (!UsingDefaultExpectedDuration && !Error) 
       
  1316 			{
       
  1317 			iOutputPrinter.Printf(_L("Comparing duration with expected duration") );
       
  1318 			if (!IsDurationInRange(0, ToneSequenceDuration, TTimeIntervalMicroSeconds(0), ErrorRange, Player->GetPlayStartTime() , Player->GetPlayStopTime() ))
       
  1319 				{
       
  1320 				Error = KErrExpectedValueDifferent; 
       
  1321 				}
       
  1322 			}
       
  1323 
       
  1324 		CleanupStack::PopAndDestroy(Player);
       
  1325 		
       
  1326 		if (Error==KErrExpectedValueDifferent) 
       
  1327 			{
       
  1328 			aResult.iResult=Error;
       
  1329 			aResult.iResultDes.Copy( KTestCaseResultFailExpectedValueDifferent() );
       
  1330 			iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFailExpectedValueDifferent() );
       
  1331 			}
       
  1332 		else if (Error)
       
  1333 			{
       
  1334 			aResult.iResult=Error;
       
  1335 			aResult.iResultDes.Copy( KTestCaseResultFail() );
       
  1336 			iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
  1337 			}
       
  1338 		else
       
  1339 			{
       
  1340 			aResult.iResult=KErrNone;
       
  1341 			aResult.iResultDes.Copy( KTestCaseResultSuccess() );
       
  1342 			iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultSuccess() );
       
  1343 			}
       
  1344 		//RepeatArray.Close();
       
  1345 		return KErrExecuted;
       
  1346 		}
       
  1347 	else
       
  1348 		{
       
  1349 		//File to play missing
       
  1350 		iOutputPrinter.Printf(_L("Filename to play not configured"));
       
  1351 		aResult.iResultDes.Copy(KConfigInvalid());
       
  1352 		aResult.iResult = KErrNotExecuted;
       
  1353 		return KErrConfigInvalid;
       
  1354 		}
       
  1355 	}
       
  1356 	
       
  1357 	
       
  1358 TInt CMmfTsTone::TestCaseCustomInterfaceL(CStifSectionParser * /*section*/ , TTestResult &aResult) 
       
  1359 	{
       
  1360 	TInt Error=KErrNone;
       
  1361 	CTonePlayer *Player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1362 	
       
  1363 	
       
  1364 	TInt FixedSequenceCount = Player->GetFixedSequenceCount();
       
  1365 	for (TInt x=0; x<FixedSequenceCount && !Error; ++x)
       
  1366 		{
       
  1367 		const TDesC &Name = Player->GetFixedSequenceName(x);
       
  1368 		iOutputPrinter.Printf(_L("Name of sequence (%d) is %S") , x , &Name );
       
  1369 		Player->PrepareFixedSequenceCustomInterface(x, ETrue);
       
  1370 		CActiveScheduler::Start();
       
  1371 		Error = Player->GetFinalError();
       
  1372 		}
       
  1373 
       
  1374 	CleanupStack::PopAndDestroy(Player);
       
  1375 
       
  1376 	if (Error)
       
  1377 		{
       
  1378 		aResult.iResult=Error;
       
  1379 		aResult.iResultDes.Copy( KTestCaseResultFail() );
       
  1380 		iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
  1381 		}
       
  1382 	else
       
  1383 		{
       
  1384 		aResult.iResult=KErrNone;
       
  1385 		aResult.iResultDes.Copy( KTestCaseResultSuccess() );
       
  1386 		iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultSuccess() );
       
  1387 		}
       
  1388 	return KErrExecuted;
       
  1389 	}
       
  1390 
       
  1391 
       
  1392 TInt CMmfTsTone::TestCaseMaxVolumePlayL(CStifSectionParser *section , TTestResult &aResult) 
       
  1393     {
       
  1394         TPtrC fileNamePtr;
       
  1395         TPtrC desFilePtr;
       
  1396         TBool haveFileName = !section->GetLine(KTagSoundFile, fileNamePtr, ENoTag) ;
       
  1397         TBool haveDesFileName = !section->GetLine(KTagSoundDes, desFilePtr, ENoTag) ;
       
  1398         //TTimeIntervalMicroSeconds ToneDuration;
       
  1399         if ( haveFileName && haveDesFileName )
       
  1400             {
       
  1401             TBool usingDefault;
       
  1402             TTimeIntervalMicroSeconds repeatSilence = GetTimeIntervalL(section, KTagSilenceDuration, usingDefault, KDefaultSilenceDuration);
       
  1403             TTimeIntervalMicroSeconds errorRange = GetTimeIntervalL(section, KTagErrorRange, usingDefault, KDefaultErrorRange);
       
  1404             TTimeIntervalMicroSeconds toneSequenceDurationDes = GetTimeIntervalL(section, KTagExpectedDurationDes, usingDefault, KDefaultToneDuration);
       
  1405             TTimeIntervalMicroSeconds toneSequenceDuration = GetTimeIntervalL(section, KTagExpectedDuration, usingDefault, KDefaultToneDuration);
       
  1406 
       
  1407             TFileName fileName = desFilePtr;
       
  1408             HBufC8 *des = GetDescriptor8LC(fileName);
       
  1409             fileName = fileNamePtr;
       
  1410 
       
  1411             TInt error1=KErrNone,error2=KErrNone;
       
  1412             iOutputPrinter.Printf(_L("Creating Tone Player") );
       
  1413             CTonePlayer *Player1 = CTonePlayer::NewLC(&iOutputPrinter);
       
  1414             CTonePlayer *Player2 = CTonePlayer::NewLC(&iOutputPrinter);
       
  1415             TInt maxVolume1 = Player1->GetMaxVolume();
       
  1416             TInt currentVolume2=Player2->GetVolume();
       
  1417             TInt volume1 = maxVolume1;
       
  1418             TInt volume2=currentVolume2;
       
  1419                     
       
  1420             Player1->SetVolume(volume1);
       
  1421 
       
  1422             iOutputPrinter.Printf( _L("Player 1: Max (%d) Set (%d) Read (%d)") , maxVolume1, volume1, Player1->GetVolume() );
       
  1423             iOutputPrinter.Printf( _L("Player 2: Max (%d) Set (%d) Read (%d)") , currentVolume2, volume2, Player2->GetVolume() );
       
  1424                     
       
  1425             Player1->PrepareDesSequence(*des);
       
  1426             CActiveScheduler::Start();
       
  1427             error1 = Player1->GetFinalError();
       
  1428                     
       
  1429             Player2->PrepareDesSequence(*des);
       
  1430             CActiveScheduler::Start();
       
  1431             error2 = Player2->GetFinalError();
       
  1432        
       
  1433 
       
  1434         
       
  1435             
       
  1436         if (volume1 != Player1->GetVolume() )
       
  1437             {
       
  1438             aResult.iResult = KErrExpectedValueDifferent;
       
  1439             iOutputPrinter.Printf(_L("Volume for Player1 different than volume setup"));
       
  1440             return KErrExecuted;
       
  1441             }
       
  1442          
       
  1443 
       
  1444        
       
  1445         if (error1==KErrExpectedValueDifferent) 
       
  1446             {
       
  1447             aResult.iResult=error1;
       
  1448             aResult.iResultDes.Copy( KTestCaseResultFailExpectedValueDifferent() );
       
  1449             iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFailExpectedValueDifferent() );
       
  1450             }
       
  1451         else if (error1)
       
  1452             {
       
  1453             aResult.iResult=error1;
       
  1454             aResult.iResultDes.Copy( KTestCaseResultFail() );
       
  1455             iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
  1456             }
       
  1457         else if(error2==KErrExpectedValueDifferent)
       
  1458             
       
  1459             {
       
  1460             aResult.iResult=error2;
       
  1461             aResult.iResultDes.Copy( KTestCaseResultFailExpectedValueDifferent() );
       
  1462             iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFailExpectedValueDifferent() );
       
  1463             }
       
  1464         else if (error2)
       
  1465             {
       
  1466             aResult.iResult=error2;
       
  1467             aResult.iResultDes.Copy( KTestCaseResultFail() );
       
  1468             iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
  1469             }
       
  1470         else
       
  1471             {
       
  1472             aResult.iResult=KErrNone;
       
  1473             aResult.iResultDes.Copy( KTestCaseResultSuccess() );
       
  1474             iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultSuccess() );
       
  1475             }
       
  1476         CleanupStack::PopAndDestroy(Player2);
       
  1477         CleanupStack::PopAndDestroy(Player1); 
       
  1478         if(des) CleanupStack::PopAndDestroy(des);
       
  1479         
       
  1480         return KErrExecuted;
       
  1481         }
       
  1482     else
       
  1483         {
       
  1484         //File to play missing
       
  1485         iOutputPrinter.Printf(_L("Filename to play not configured"));
       
  1486         aResult.iResultDes.Copy(KConfigInvalid());
       
  1487         aResult.iResult = KErrNotExecuted;
       
  1488         return KErrConfigInvalid;
       
  1489         }
       
  1490     
       
  1491 }
       
  1492 TInt CMmfTsTone::TestCaseCancelPlayL(CStifSectionParser *section , TTestResult &aResult) 
       
  1493 {
       
  1494     TBool usingDefault, notUsingCancel;
       
  1495     TInt playWhat = GetIntL(section, KTagPlay, usingDefault, 1);
       
  1496     TTimeIntervalMicroSeconds32 timeOutDuration = GetTimeIntervalL(section, KTagTimeOut, usingDefault, KDefaultTimeOutDuration);
       
  1497     TInt error = KErrNone;
       
  1498     TInt cancelPriority = GetIntL(section, KTagCancelPriority, notUsingCancel, CActive::EPriorityHigh);
       
  1499     HBufC8 *des=0;
       
  1500     TTimeIntervalMicroSeconds toneDuration;
       
  1501     CTonePlayer *player=0;
       
  1502     CImmediateMediaEvent *prepareMediaEvent=0;
       
  1503     CParameters *prepareParameters=0;
       
  1504     TTimeIntervalMicroSeconds32 delay = GetTimeIntervalL(section, KTagDelay, usingDefault, KDefaultReportDelay);;
       
  1505     
       
  1506     switch (playWhat) {
       
  1507         case CTonePlayer::EPlayTone:
       
  1508             {
       
  1509             //Obtain the tone's frequency
       
  1510             TInt frequency = GetIntL(section, KTagToneFrequency, usingDefault, KDefaultToneFrequency);
       
  1511             if (usingDefault)
       
  1512                 {
       
  1513                 iOutputPrinter.Printf(_L("Using default tone frequency (%d) for player") , frequency);
       
  1514                 }
       
  1515             else
       
  1516                 {
       
  1517                 iOutputPrinter.Printf(_L("Using frequency 1 for player (%d)") , frequency);
       
  1518                 }
       
  1519             TTimeIntervalMicroSeconds toneDuration = GetTimeIntervalL(section, KTagToneDuration, usingDefault, KDefaultToneDuration);
       
  1520             iOutputPrinter.Printf(_L("Creating Tone Player") );
       
  1521             player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1522             
       
  1523             TFixedArray<TInt64, 2> freqAndDuration;
       
  1524             freqAndDuration[0] = frequency;
       
  1525             freqAndDuration[1] = toneDuration.Int64() ;
       
  1526            
       
  1527             
       
  1528             prepareParameters = CTemplateParameters<TFixedArray<TInt64, 2> >::NewL(CTonePlayer::KPlayerActionPrepareTone, freqAndDuration);
       
  1529             CleanupStack::PushL(prepareParameters);
       
  1530 
       
  1531             //PrepareMediaEvent = CImmediateMediaEvent::NewLC(TestModuleIf(), *iLogger, Player, PrepareParameters, CancelPriority+1);
       
  1532             prepareMediaEvent = CImmediateMediaEvent::NewLC(&iOutputPrinter, player, prepareParameters, cancelPriority+1);
       
  1533             prepareMediaEvent->FireExecute();
       
  1534             break;
       
  1535             }
       
  1536         case CTonePlayer::EPlayFixedSequence:
       
  1537             {
       
  1538             TInt sequenceNumber = GetIntL(section, KTagSequenceNumber, usingDefault, 0);
       
  1539           
       
  1540             player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1541             
       
  1542             prepareParameters = CTemplateParameters<TInt>::NewL(CTonePlayer::KPlayerActionPrepareFixedSequence, sequenceNumber);
       
  1543             CleanupStack::PushL(prepareParameters);
       
  1544 
       
  1545             prepareMediaEvent = CImmediateMediaEvent::NewLC(&iOutputPrinter, player, prepareParameters, cancelPriority+1);
       
  1546             prepareMediaEvent->FireExecute();
       
  1547             break;
       
  1548             }
       
  1549 
       
  1550         case CTonePlayer::EPlayFileSequence:
       
  1551             {
       
  1552             TPtrC fileNamePtr;
       
  1553           
       
  1554             TBool haveFileName = !section->GetLine(KTagSoundFile, fileNamePtr, ENoTag);
       
  1555             if (haveFileName)
       
  1556                 {
       
  1557                 player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1558 
       
  1559                 TFileName file = fileNamePtr;
       
  1560                 
       
  1561                 prepareParameters = CTemplateParameters<TFileName>::NewL(CTonePlayer::KPlayerActionPrepareFileSequence, file);
       
  1562                 CleanupStack::PushL(prepareParameters);
       
  1563                 
       
  1564                 prepareMediaEvent = CImmediateMediaEvent::NewLC(&iOutputPrinter, player, prepareParameters, cancelPriority+1);
       
  1565                 prepareMediaEvent->FireExecute();
       
  1566                 }
       
  1567             else
       
  1568                 {
       
  1569                 iOutputPrinter.Printf(_L("File Name is required"));
       
  1570                 }
       
  1571             break;
       
  1572             }
       
  1573         case CTonePlayer::EPlayDesSequence:
       
  1574             {
       
  1575             TPtrC fileNamePtr;
       
  1576           
       
  1577             TBool haveFileName = !section->GetLine(KTagSoundFile, fileNamePtr, ENoTag);
       
  1578             if (haveFileName)
       
  1579                 {
       
  1580                 des = GetDescriptor8LC(fileNamePtr);
       
  1581                 player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1582                 
       
  1583                 prepareParameters = CTemplateParameters<HBufC8*>::NewL(CTonePlayer::KPlayerActionPrepareDesSequence, des);
       
  1584                 CleanupStack::PushL(prepareParameters);
       
  1585                 
       
  1586                 prepareMediaEvent = CImmediateMediaEvent::NewLC(&iOutputPrinter, player, prepareParameters, cancelPriority+1);
       
  1587                
       
  1588                 prepareMediaEvent->FireExecute();
       
  1589                 }
       
  1590             else
       
  1591                 {
       
  1592                 iOutputPrinter.Printf(_L("File Name is required"));
       
  1593                 }
       
  1594             break;
       
  1595             }
       
  1596         case CTonePlayer::EPlayDTMF:
       
  1597             {
       
  1598             TTimeIntervalMicroSeconds32 toneDuration = GetTimeIntervalL(section, KTagToneDuration, usingDefault, KDefaultDTMFToneDuration);
       
  1599             TTimeIntervalMicroSeconds32 toneOffDuration = GetTimeIntervalL(section, KTagSilenceDuration, usingDefault, KDefaultDTMFSilenceDuration);
       
  1600             TTimeIntervalMicroSeconds32 pause = GetTimeIntervalL(section, KTagDelay, usingDefault, KDefaultPauseDelay, ETrue);
       
  1601             
       
  1602             iOutputPrinter.Printf(_L("Creating Tone Player") );
       
  1603             player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1604             {
       
  1605             TPtrC PtrDTMFString;
       
  1606             if (section->GetLine(KTagDTMFString, PtrDTMFString, ENoTag) )
       
  1607                 {
       
  1608                 prepareParameters = CDTMFParameters::NewLC(CTonePlayer::KPlayerActionPrepareDTMFSequence, toneDuration, toneOffDuration, pause, KDefaultDTMFString);
       
  1609                 }
       
  1610             else
       
  1611                 {
       
  1612                 prepareParameters = CDTMFParameters::NewLC(CTonePlayer::KPlayerActionPrepareDTMFSequence, toneDuration, toneOffDuration, pause, PtrDTMFString);
       
  1613                 }
       
  1614             }
       
  1615             iOutputPrinter.Printf(_L("Preparing DTMF sequence [%S]") , static_cast<CDTMFParameters*>(prepareParameters)->GetDTMFString() );
       
  1616             prepareMediaEvent = CImmediateMediaEvent::NewLC(&iOutputPrinter, player, prepareParameters, cancelPriority+1);
       
  1617             prepareMediaEvent->FireExecute();
       
  1618             break;
       
  1619             }
       
  1620         case CTonePlayer::EPlayDualTone:
       
  1621             {
       
  1622             //Obtain the tone's frequency
       
  1623             TInt frequency1 = GetIntL(section, KTagToneFrequency, usingDefault, KDefaultToneFrequency);
       
  1624             if (usingDefault)
       
  1625                 {
       
  1626                 iOutputPrinter.Printf(_L("Using default tone frequency 1 for player (%d)") , frequency1);
       
  1627                 }
       
  1628             else
       
  1629                 {
       
  1630                 iOutputPrinter.Printf(_L("Using frequency 1 for player (%d)") , frequency1);
       
  1631                 }
       
  1632             TInt frequency2 = GetIntL(section, KTagToneFrequency, usingDefault, KDefaultToneFrequency, ETrue);
       
  1633             if (usingDefault)
       
  1634                 {
       
  1635                 iOutputPrinter.Printf(_L("Using default tone frequency 2 for player (%d) ") , frequency2);
       
  1636                 }
       
  1637             else
       
  1638                 {
       
  1639                 iOutputPrinter.Printf(_L("Using frequency 2 for player (%d)") , frequency2);
       
  1640                 }
       
  1641             toneDuration = GetTimeIntervalL(section, KTagToneDuration, usingDefault, KDefaultToneDuration);
       
  1642             iOutputPrinter.Printf(_L("Using duration (%d) for player"), toneDuration);
       
  1643             iOutputPrinter.Printf(_L("Creating Tone Player") );
       
  1644             player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1645 
       
  1646             TFixedArray<TInt64, 3> freqAndDuration;
       
  1647             freqAndDuration[0] = frequency1;
       
  1648             freqAndDuration[1] = frequency2;
       
  1649             freqAndDuration[2] = toneDuration.Int64() ;
       
  1650            
       
  1651             
       
  1652             prepareParameters = CTemplateParameters<TFixedArray<TInt64, 3> >::NewL(CTonePlayer::KPlayerActionPrepareDualTone, freqAndDuration);
       
  1653             CleanupStack::PushL(prepareParameters);
       
  1654 
       
  1655             prepareMediaEvent = CImmediateMediaEvent::NewLC(&iOutputPrinter, player, prepareParameters, cancelPriority+1);
       
  1656             prepareMediaEvent->FireExecute();
       
  1657          
       
  1658             break;
       
  1659             }
       
  1660             
       
  1661     }
       
  1662             if (!player)
       
  1663                 {
       
  1664                 iOutputPrinter.Printf(_L("Tone player not created properly"));
       
  1665                 aResult.iResult=KErrNotFound;
       
  1666                 aResult.iResultDes.Copy( KTestCaseResultFail() );
       
  1667                 iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
  1668                 return KErrNotExecuted;
       
  1669                 }
       
  1670             else
       
  1671                 {
       
  1672 
       
  1673                 CParameters *params = new (ELeave) CParameters( CTonePlayer::KPlayerActionStop );
       
  1674                 CleanupStack::PushL(params);
       
  1675                 CMediaEvent *ime = CMediaEvent::NewL(&iOutputPrinter,delay,0, player, params);
       
  1676                 CleanupStack::PushL(ime);
       
  1677           
       
  1678                 
       
  1679                 iOutputPrinter.Printf(_L("Starting scheduler"));
       
  1680                 CActiveScheduler::Start();
       
  1681                 error=player->GetFinalError();
       
  1682                 CleanupStack::PopAndDestroy(ime);
       
  1683                 CleanupStack::Pop(params);
       
  1684         
       
  1685                                                                                                                                                                                                                                                                                                                                                                                                                
       
  1686               
       
  1687                 
       
  1688                 /*if (PrepareMediaEvent)*/ CleanupStack::PopAndDestroy(prepareMediaEvent);
       
  1689                 /*if (PrepareParameters)*/ CleanupStack::Pop(prepareParameters);
       
  1690                 CleanupStack::PopAndDestroy(player);
       
  1691                 if (des) CleanupStack::PopAndDestroy(des);
       
  1692                
       
  1693                 
       
  1694 
       
  1695                 
       
  1696                 if (error==KErrExpectedValueDifferent) 
       
  1697                     {
       
  1698                     aResult.iResult=error;
       
  1699                     aResult.iResultDes.Copy( KTestCaseResultFailExpectedValueDifferent() );
       
  1700                     iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFailExpectedValueDifferent() );
       
  1701                     }
       
  1702                 else if (error)
       
  1703                     {
       
  1704                     aResult.iResult=error;
       
  1705                     aResult.iResultDes.Copy( KTestCaseResultFail() );
       
  1706                     iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
  1707                     }
       
  1708                 else
       
  1709                     {
       
  1710                     aResult.iResult=KErrNone;
       
  1711                     aResult.iResultDes.Copy( KTestCaseResultSuccess() );
       
  1712                     iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultSuccess() );
       
  1713                     }
       
  1714                 
       
  1715                 
       
  1716                 return KErrExecuted;
       
  1717                 }
       
  1718             
       
  1719     }
       
  1720 
       
  1721 
       
  1722 TInt CMmfTsTone::TestCaseVolumeChangeL(CStifSectionParser *section , TTestResult &aResult) 
       
  1723     {   
       
  1724         TBool notUsingCancel;
       
  1725         TTimeIntervalMicroSeconds32 delay;
       
  1726       
       
  1727         TInt volumeLevel=GetIntL(section,KTagVolume,notUsingCancel,1);
       
  1728         HBufC8 *des=0;
       
  1729     
       
  1730         CTonePlayer *player=0;
       
  1731         CImmediateMediaEvent *prepareMediaEvent=0;
       
  1732         CParameters *prepareParameters=0;
       
  1733         
       
  1734         TBool usingDefault;
       
  1735         TTimeIntervalMicroSeconds errorRange = GetTimeIntervalL(section, KTagErrorRange, usingDefault, KDefaultErrorRange);
       
  1736         TTimeIntervalMicroSeconds toneDuration = GetTimeIntervalL(section, KTagToneDuration, usingDefault, KDefaultToneDuration);
       
  1737         TInt frequency1=KDefaultToneFrequency;
       
  1738         TInt frequency2=KDefaultToneFrequency;
       
  1739         delay = GetTimeIntervalL(section, KTagDelay, usingDefault, KDefaultReportDelay);
       
  1740        
       
  1741         TInt error = KErrNone;
       
  1742        
       
  1743 
       
  1744         //Obtain the tone's frequency
       
  1745         frequency1 = GetIntL(section, KTagToneFrequency, usingDefault, KDefaultToneFrequency);
       
  1746         if (usingDefault)
       
  1747             {
       
  1748             iOutputPrinter.Printf(_L("Using default tone frequency for player") );
       
  1749             }
       
  1750         else
       
  1751             {
       
  1752             iOutputPrinter.Printf(_L("Using frequency 1 for player (%d)") , frequency1);
       
  1753             }
       
  1754         frequency2 = GetIntL(section, KTagToneFrequency, usingDefault, KDefaultToneFrequency, ETrue);
       
  1755         if (usingDefault)
       
  1756             {
       
  1757             iOutputPrinter.Printf(_L("Using default tone frequency for player") );
       
  1758             }
       
  1759         else
       
  1760             {
       
  1761             iOutputPrinter.Printf(_L("Using frequency 2 for player (%d)") , frequency2);
       
  1762             }
       
  1763         iOutputPrinter.Printf(_L("Creating Tone Player") );
       
  1764             
       
  1765           
       
  1766         iOutputPrinter.Printf(_L("Using duration (%d) for player"), toneDuration);
       
  1767         iOutputPrinter.Printf(_L("Creating Tone Player") );
       
  1768         player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1769 
       
  1770         TFixedArray<TInt64, 3> freqAndDuration;
       
  1771         freqAndDuration[0] = frequency1;
       
  1772         freqAndDuration[1] = frequency2;
       
  1773         freqAndDuration[2] = toneDuration.Int64() ;
       
  1774         
       
  1775        
       
  1776         prepareParameters = CTemplateParameters<TFixedArray<TInt64, 3> >::NewL(CTonePlayer::KPlayerActionPrepareDualTone, freqAndDuration);
       
  1777         CleanupStack::PushL(prepareParameters);
       
  1778 
       
  1779         prepareMediaEvent = CImmediateMediaEvent::NewLC(&iOutputPrinter, player, prepareParameters, 80);
       
  1780         prepareMediaEvent->FireExecute();
       
  1781                      
       
  1782         iOutputPrinter.Printf(_L("Starting scheduler"));
       
  1783         //volumelevel=11(max volume),=12(average volume),=13(zero volume)        
       
  1784         CParameters *reportParams = new (ELeave) CParameters( volumeLevel );
       
  1785         CleanupStack::PushL(reportParams);
       
  1786        
       
  1787        
       
  1788         CMediaEvent *ime = CMediaEvent::NewL(&iOutputPrinter,delay,0, player, reportParams);
       
  1789                           
       
  1790         CleanupStack::PushL(ime);
       
  1791         TInt expectedVolume;
       
  1792         iOutputPrinter.Printf(_L("current volume before change:%d"),player->GetVolume());
       
  1793         RDebug::Print(_L("current volume before change:%d"),player->GetVolume());
       
  1794         switch(volumeLevel)
       
  1795             {
       
  1796             case EMaxVolume:
       
  1797                 {
       
  1798                 expectedVolume=player->GetMaxVolume();
       
  1799                 break;
       
  1800                 }
       
  1801             case EAvgVolume:
       
  1802                 {
       
  1803                 expectedVolume=(player->GetMaxVolume())/2;
       
  1804                 break;
       
  1805                 }
       
  1806             case EZeroVolume:
       
  1807                 {
       
  1808                 expectedVolume=0;
       
  1809                 break;
       
  1810                 }
       
  1811             }
       
  1812         iOutputPrinter.Printf(_L("Starting scheduler"));
       
  1813         CActiveScheduler::Start();
       
  1814         error=player->GetFinalError();
       
  1815         RDebug::Print(_L("current volume after change:%d"),player->GetVolume());
       
  1816         iOutputPrinter.Printf(_L("current volume after change:%d"),player->GetVolume());
       
  1817         if (player->GetVolume()!=expectedVolume)
       
  1818             {
       
  1819             error=KErrExpectedValueDifferent;
       
  1820             }
       
  1821         CleanupStack::PopAndDestroy(ime);
       
  1822         CleanupStack::Pop(reportParams);
       
  1823 
       
  1824     if (error )
       
  1825         {
       
  1826         aResult.iResult = error;
       
  1827         aResult.iResultDes.Copy(KTestCaseResultFailExpectedValueDifferent());
       
  1828         iOutputPrinter.Printf( KTestCaseResultFinished() , &KTestCaseResultFailExpectedValueDifferent() );
       
  1829         }
       
  1830     else
       
  1831         {
       
  1832         aResult.iResult = KErrExecuted;
       
  1833         aResult.iResultDes.Copy(KTestCaseResultSuccess());
       
  1834         iOutputPrinter.Printf( KTestCaseResultFinished() ,  &KTestCaseResultSuccess() );
       
  1835         }
       
  1836    
       
  1837     /*if (PrepareMediaEvent)*/ CleanupStack::PopAndDestroy(prepareMediaEvent);
       
  1838     /*if (PrepareParameters)*/ CleanupStack::Pop(prepareParameters);
       
  1839            
       
  1840     CleanupStack::PopAndDestroy(player);
       
  1841     return KErrExecuted;
       
  1842     }
       
  1843 
       
  1844 
       
  1845 TInt CMmfTsTone::TestCasePlayCorruptFileL(CStifSectionParser *section , TTestResult &aResult)
       
  1846     {
       
  1847     TPtrC fileNamePtr;
       
  1848     TBool haveFileName = !section->GetLine(KTagSoundFile, fileNamePtr, ENoTag) ;
       
  1849     if ( haveFileName )
       
  1850         {
       
  1851         TBool usingDefaultErrorRange;
       
  1852         TBool usingDefaultExpectedDuration;
       
  1853         TTimeIntervalMicroSeconds errorRange = GetTimeIntervalL(section, KTagErrorRange, usingDefaultErrorRange, KDefaultErrorRange);
       
  1854         TTimeIntervalMicroSeconds toneSequenceDuration = GetTimeIntervalL(section, KTagExpectedDuration, usingDefaultExpectedDuration, KDefaultToneDuration);
       
  1855 
       
  1856         TFileName fileName = fileNamePtr;
       
  1857 
       
  1858         TInt error=KErrNone;
       
  1859         iOutputPrinter.Printf(_L("Creating Tone Player") );
       
  1860         CTonePlayer *player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1861 
       
  1862         player->PrepareFileSequence(fileName);
       
  1863         CActiveScheduler::Start();
       
  1864         error = player->GetFinalError();
       
  1865 
       
  1866         if (!usingDefaultExpectedDuration && !error) 
       
  1867             {
       
  1868             iOutputPrinter.Printf(_L("Comparing duration with expected duration") );
       
  1869             if (!IsDurationInRange(0, toneSequenceDuration, TTimeIntervalMicroSeconds(0), errorRange, player->GetPlayStartTime() , player->GetPlayStopTime() ))
       
  1870                 {
       
  1871                 error = KErrExpectedValueDifferent; 
       
  1872                 }
       
  1873             }
       
  1874 
       
  1875         CleanupStack::PopAndDestroy(player);
       
  1876         
       
  1877         if (error==KErrExpectedValueDifferent) 
       
  1878             {
       
  1879             aResult.iResult=error;
       
  1880             aResult.iResultDes.Copy( KTestCaseResultFailExpectedValueDifferent() );
       
  1881             iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFailExpectedValueDifferent() );
       
  1882             }
       
  1883         else if (error==KErrCorrupt)
       
  1884             {
       
  1885             aResult.iResult=KErrNone;
       
  1886             aResult.iResultDes.Copy( KTestCaseResultSuccess() );
       
  1887             iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultSuccess() );
       
  1888             
       
  1889             }
       
  1890         else
       
  1891             {
       
  1892             aResult.iResult=error;
       
  1893             aResult.iResultDes.Copy( KTestCaseResultFail() );
       
  1894             iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
  1895             }
       
  1896         
       
  1897         return KErrExecuted;
       
  1898         }
       
  1899     else
       
  1900         {
       
  1901         //File to play missing
       
  1902         iOutputPrinter.Printf(_L("Filename to play not configured"));
       
  1903         aResult.iResultDes.Copy(KConfigInvalid());
       
  1904         aResult.iResult = KErrNotExecuted;
       
  1905         return KErrConfigInvalid;
       
  1906         }
       
  1907     }
       
  1908 TInt CMmfTsTone::TestCaseCheckStateL(CStifSectionParser * section , TTestResult &aResult) 
       
  1909     {
       
  1910     
       
  1911     TBool usingDefault;
       
  1912     TTimeIntervalMicroSeconds errorRange = GetTimeIntervalL(section, KTagErrorRange, usingDefault, KDefaultErrorRange);
       
  1913     TTimeIntervalMicroSeconds toneDuration = GetTimeIntervalL(section, KTagToneDuration, usingDefault, KDefaultToneDuration);
       
  1914     TInt frequency1=KDefaultToneFrequency;
       
  1915     TInt frequency2=KDefaultToneFrequency;
       
  1916     CImmediateMediaEvent *prepareMediaEvent=0;
       
  1917     CParameters *prepareParameters=0;
       
  1918     
       
  1919     TInt error = KErrNone;
       
  1920     TInt initialState=KErrNone,preparedState=KErrNone,playingState=KErrNone;
       
  1921     //HBufC *DTMFString;
       
  1922     TInt validityCheck=GetIntL(section, KTagValidity, usingDefault, KDefaultValidity);
       
  1923     //Obtain the tone's frequency
       
  1924     frequency1 = GetIntL(section, KTagToneFrequency, usingDefault, KDefaultToneFrequency);
       
  1925     if (usingDefault)
       
  1926         {
       
  1927         iOutputPrinter.Printf(_L("Using default tone frequency for player") );
       
  1928         }
       
  1929     else
       
  1930         {
       
  1931         iOutputPrinter.Printf(_L("Using frequency 1 for player (%d)") , frequency1);
       
  1932         }
       
  1933     frequency2 = GetIntL(section, KTagToneFrequency, usingDefault, KDefaultToneFrequency, ETrue);
       
  1934     if (usingDefault)
       
  1935         {
       
  1936         iOutputPrinter.Printf(_L("Using default tone frequency for player") );
       
  1937         }
       
  1938     else
       
  1939         {
       
  1940         iOutputPrinter.Printf(_L("Using frequency 2 for player (%d)") , frequency2);
       
  1941         }
       
  1942 
       
  1943    
       
  1944 
       
  1945     iOutputPrinter.Printf(_L("Creating Tone Player") );
       
  1946     CTonePlayer *player = CTonePlayer::NewLC(&iOutputPrinter);
       
  1947     
       
  1948     if (player->State()==CTonePlayer::ETonePlayerNotReady)
       
  1949         {
       
  1950         initialState=KErrNone;
       
  1951         RDebug::Printf("current state:EMdaAudioUtilityNotReady");
       
  1952         }
       
  1953     else
       
  1954         {
       
  1955         initialState=KErrExpectedValueDifferent;
       
  1956         }
       
  1957     
       
  1958     player->PrepareDualTone(frequency1,frequency2,toneDuration,EFalse);
       
  1959     
       
  1960     iOutputPrinter.Printf(_L("Starting scheduler"));
       
  1961     CActiveScheduler::Start();
       
  1962     if (player->State()==CTonePlayer::ETonePlayerPrepared)
       
  1963        {
       
  1964        preparedState=KErrNone;
       
  1965        RDebug::Printf("current state:EMdaAudioUtilityPrepared");
       
  1966        }
       
  1967    else
       
  1968        {
       
  1969        preparedState=KErrExpectedValueDifferent;
       
  1970        }
       
  1971    error = player->GetFinalError();
       
  1972    player->Play();
       
  1973    if(player->State()==CTonePlayer::ETonePlayerPlaying)
       
  1974        {
       
  1975        playingState=KErrNone;
       
  1976        RDebug::Printf("current state:EMdaAudioUtilityPlaying");
       
  1977        }
       
  1978    else
       
  1979        {
       
  1980        playingState=KErrExpectedValueDifferent;
       
  1981        }
       
  1982     CActiveScheduler::Start();
       
  1983 
       
  1984     error = player->GetFinalError();
       
  1985     TBool InRange=ETrue;
       
  1986     if (!IsDurationInRange(0, toneDuration, TTimeIntervalMicroSeconds(0), errorRange, player->GetPlayStartTime(), player->GetPlayStopTime() ) )
       
  1987         {
       
  1988         error = KErrExpectedValueDifferent;
       
  1989         InRange=EFalse;
       
  1990         }
       
  1991 
       
  1992     CleanupStack::PopAndDestroy(player);
       
  1993     
       
  1994      if (!InRange)
       
  1995         {       
       
  1996         aResult.iResult = KErrExpectedValueDifferent;
       
  1997         aResult.iResultDes.Copy(KTestCaseResultFailExpectedValueDifferent());
       
  1998         iOutputPrinter.Printf( KTestCaseResultFinished() , &KTestCaseResultFailExpectedValueDifferent() );
       
  1999         }
       
  2000     
       
  2001     
       
  2002     else if (error || initialState || preparedState || playingState)
       
  2003         {
       
  2004         aResult.iResult=error;
       
  2005         aResult.iResultDes.Copy( KTestCaseResultFail() );
       
  2006         iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultFail() );
       
  2007         }
       
  2008    
       
  2009     else
       
  2010         {
       
  2011         aResult.iResult=KErrNone;
       
  2012         aResult.iResultDes.Copy( KTestCaseResultSuccess() );
       
  2013         iOutputPrinter.Printf(KTestCaseResultFinished, &KTestCaseResultSuccess() );
       
  2014         }
       
  2015     return KErrExecuted;
       
  2016     
       
  2017     }
       
  2018