os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/tonetruepause.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // Part of the TSI_MMFACLNT suite that tests CR1566 (TruePause) on AudioToneUtility
    15 // 
    16 //
    17 
    18 /**
    19  @file ToneTruePause.cpp
    20 */
    21 
    22 #include "tonetruepause.h"
    23 #include "toneTest.h"
    24 
    25 /*
    26  *
    27  * RMdaToneUtilityTestBase - Test step constructor
    28  *
    29  */
    30 RMdaToneUtilityTestBase::RMdaToneUtilityTestBase(const TDesC& aTestName, const TDesC& aSectName)
    31 	:	iToneUtilityState(EStateInitial), 
    32 		iToneUtility(NULL),
    33 		iTimer(NULL),
    34 		iWait(EFalse),
    35 		iStop(EFalse),
    36 		iConfig(EFalse),
    37 		iPrepare(EFalse),
    38 		iNegative(EFalse),
    39 		iCount(0),
    40 		iVolume(0),	
    41 		iBalance(0),
    42 		iDuration(0),
    43 		iPause(0),
    44 		iExpected(0),
    45 		iFilename(KNullDesC)
    46 	{
    47 	iTestStepName = aTestName;
    48 	iSectName = aSectName;
    49 	}
    50 
    51 /*
    52  *
    53  * ~RMdaToneUtilityTestBase - Test step destructor
    54  *
    55  */
    56 RMdaToneUtilityTestBase::~RMdaToneUtilityTestBase()
    57 	{
    58 	if (iToneUtility)
    59 		{
    60 		delete iToneUtility;
    61 		}
    62 	if(iTimer)
    63 		{
    64 		delete iTimer;
    65 		}
    66 	iFile.Close();
    67 	iFs.Close();
    68 	}
    69 
    70 /*
    71  *
    72  * KickoffTestL - Starts the test
    73  *
    74  */
    75 void RMdaToneUtilityTestBase::KickoffTestL()
    76 	{
    77 	User::LeaveIfError(iFs.Connect());
    78 	INFO_PRINTF1(_L("__________  Creating Tone Utility object ___________"));
    79 
    80 	TRAPD(err,  iToneUtility = CMdaAudioToneUtility::NewL(*this));
    81 	if (err != KErrNone)
    82 		{
    83 		ERR_PRINTF2(_L("Could not create Tone Utility object. Error = %d"), err);
    84 		StopTest(err);
    85 		return;
    86 		}
    87 	INFO_PRINTF1(_L("Tone Utility State: EStateCreated"));
    88 	iToneUtilityState = EStateCreated;
    89 
    90 	DoKickoffTestL();
    91 	
    92 	INFO_PRINTF1(_L("Tone Utility Event: EEventInitialize"));
    93 	Fsm(EEventInitialize, KErrNone);
    94 	}
    95 
    96 /*
    97  *
    98  * CloseTest
    99  *
   100  */
   101 void RMdaToneUtilityTestBase::CloseTest()
   102 	{
   103 	INFO_PRINTF1(_L("Deleting Tone Utility object"));
   104 	delete iToneUtility;
   105 	delete iTimer;
   106 	}
   107 
   108 /*
   109  *
   110  * StartTimer - Starts timer and timer callback
   111  *
   112  */
   113 void RMdaToneUtilityTestBase::StartTimer(TTimeIntervalMicroSeconds32 aWaitTime)
   114 	{
   115 	TTimeIntervalMicroSeconds32 timeInterval;
   116 	
   117 	if(aWaitTime <= TTimeIntervalMicroSeconds32(0))
   118 		{
   119 		timeInterval = KOneSecond;
   120 		}
   121 	else
   122 		{
   123 		timeInterval = aWaitTime;
   124 		}
   125 	TCallBack callback (TimerCallback, this);
   126 	iTimer->Start(timeInterval, timeInterval, callback);
   127 	INFO_PRINTF1(_L("Timer has been started"));
   128 	}
   129 
   130 /*
   131  *
   132  * TimerCallback
   133  *
   134  */
   135 TInt RMdaToneUtilityTestBase::TimerCallback(TAny* aPtr)
   136 	{
   137 	static_cast<RMdaToneUtilityTestBase*>(aPtr)->DoTimerCallback();
   138 	return KErrNone;
   139 	}
   140 
   141 /*
   142  *
   143  * Fsm - Executes playing events of AudioToneUtility in sequence
   144  *
   145  */
   146 void RMdaToneUtilityTestBase::Fsm(TMdaAudioUtilityEvent aMdaAudioUtilityEvent, TInt aError)
   147 	{
   148 	TInt error = 0;
   149 	switch (iToneUtilityState)
   150 		{
   151 		case EStateCreated:
   152 			{
   153 			if (aMdaAudioUtilityEvent == EEventInitialize)
   154 				{
   155 				if(!iNegative)
   156 					{
   157 					INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayFileSequence"));
   158 					iToneUtility->PrepareToPlayFileSequence(iFile);					
   159 					}
   160 				else
   161 					{
   162 					INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayDTMFString"));				
   163 					iToneUtility->PrepareToPlayDTMFString(KDTMFString);					
   164 					}
   165 				INFO_PRINTF1(_L("MdaAudioUtility State: EStateInitializing"));
   166 				iToneUtilityState = EStateInitializing;
   167 				}
   168 			else
   169 				{
   170 				ERR_PRINTF2(_L("MdaAudioUtility EEventInitialize not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
   171 				StopTest(aError, EFail);
   172 				}
   173 			break;
   174 			}
   175 		case EStateInitializing:
   176 			{
   177 			if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError == KErrNone)
   178 				{
   179 				INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
   180 				iToneUtility->SetVolume(iToneUtility->MaxVolume()/2);
   181 				INFO_PRINTF1(_L("Starting playback"));
   182 				iToneUtility->Play();
   183 				iStartTime.HomeTime();
   184 				iToneUtilityState = EStatePlaying;
   185 				StartTimer(iPause*KOneSecond); //wait to pause
   186 				}
   187 			else if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError != KErrNone)
   188 				{
   189 				ERR_PRINTF2(_L("MatoPrepareComplete returned with error = %d"), aError);
   190 				StopTest(aError);	
   191 				}
   192 			else
   193 				{
   194 				ERR_PRINTF2(_L("MdaAudioUtility EEventPrepareComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
   195 				StopTest(aError, EFail);
   196 				}
   197 			break;
   198 			}
   199 		case EStatePlaying:
   200 			{
   201 			if(aMdaAudioUtilityEvent == EEventTimerComplete)
   202 				{
   203 				INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Pause"));
   204 				error = iToneUtility->Pause();
   205 				if(!iNegative)
   206 					{
   207 					INFO_PRINTF1(_L("MdaAudioUtility State: EStatePause"));
   208 					iToneUtilityState = EStatePause;
   209 					iWait = EFalse;
   210 					}
   211 				else
   212 					{
   213 					if(error == KErrNotSupported)
   214 						{
   215 						INFO_PRINTF1(_L("Pause while in a mode different than prepare to play file sequence returned with KErrNotSupported as expected"));
   216 						}
   217 					else
   218 						{
   219 						ERR_PRINTF2(_L("Pause while in a mode different than prepare to play file sequence returned with %d instead of KErrNotSupported as expected"),error);
   220 						StopTest(error);
   221 						}
   222 					}
   223 				}
   224 			else
   225 				{
   226 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
   227 				StopTest(aError, EFail);
   228 				}
   229 			break;
   230 			}
   231 		case EStatePause:
   232 			{
   233 			if (aMdaAudioUtilityEvent == EEventTimerComplete)
   234 				{
   235 				if(!iWait && !iConfig && !iPrepare)
   236 					{
   237 					INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioToneUtility::Resume"));
   238 					error = iToneUtility->Resume();
   239 					if(error == KErrNone)
   240 						{
   241 						INFO_PRINTF1(_L("Resume returned with KErrNone as expected"));
   242 						iToneUtilityState = EStatePlaying;
   243 						}
   244 					else
   245 						{
   246 						ERR_PRINTF2(_L("Resume returned with %d instead of KErrNone as expected"),error);
   247 						StopTest(error);
   248 						}
   249 					}
   250 				else if(!iWait && iConfig)
   251 					{
   252 					INFO_PRINTF2(_L("Playback paused for %d seconds"),iPause);
   253 					INFO_PRINTF3(_L("Changing Volume and Balance while paused to Volume = %d and Balance = %d"),iVolume,iBalance);
   254 					iToneUtility->SetVolume(iVolume);
   255 					iToneUtility->SetBalanceL(iBalance);
   256 					INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioToneUtility::Resume"));
   257 					error = iToneUtility->Resume();
   258 					if(error == KErrNone)
   259 						{
   260 						INFO_PRINTF1(_L("Resume returned with KErrNone as expected"));
   261 						iToneUtilityState = EStatePlaying;
   262 						}
   263 					else
   264 						{
   265 						ERR_PRINTF2(_L("Resume returned with %d instead of KErrNone as expected"),error);
   266 						StopTest(error);
   267 						}
   268 					iConfig = EFalse;
   269 					}
   270 				else if(!iWait && iPrepare)
   271 					{
   272 					INFO_PRINTF2(_L("Playback paused for %d seconds"),iPause);
   273 					INFO_PRINTF1(_L("Calling PrepareToPlayFileSequence while in Pause"));
   274 					iToneUtility->PrepareToPlayFileSequence(iFile);
   275 					iToneUtilityState = EStatePlaying;
   276 					}
   277 				}
   278 			else
   279 				{
   280 				ERR_PRINTF2(_L("EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
   281 				StopTest(aError, EFail);
   282 				}
   283 			break;
   284 			}
   285 		case EStateStopped:
   286 			{
   287 			if (aMdaAudioUtilityEvent == EEventTimerComplete)
   288 				{
   289 				if(iWait)
   290 					{
   291 					INFO_PRINTF1(_L("Playback stopped for 2 seconds"));
   292 					iWait = EFalse;
   293 					}
   294 				else
   295 					{
   296 					INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Resume while stopped"));
   297 					error = iToneUtility->Resume();
   298 					if(error == KErrNotReady)
   299 						{
   300 						INFO_PRINTF1(_L("Resume returned with KErrNotReady as expected"));
   301 						iToneUtilityState = EStatePlaying;
   302 						}
   303 					else
   304 						{
   305 						ERR_PRINTF2(_L("Resume returned with %d instead of KErrNotReady as expected"),error);
   306 						StopTest(error);
   307 						}
   308 					INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioToneUtility::Play"));
   309 					iToneUtility->Play();
   310 					}
   311 				}
   312 			else
   313 				{
   314 				ERR_PRINTF2(_L("EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
   315 				StopTest(aError, EFail);
   316 				}
   317 			break;
   318 			}
   319 		default:
   320 			{
   321 			ERR_PRINTF2(_L("Invalid MdaAudioUtility state received: %d"), iToneUtilityState);
   322 			StopTest(KErrGeneral);
   323 			}
   324 		}
   325 	}
   326 
   327 /*
   328  *
   329  * MatoPrepareComplete - From MMdaAudioToneObserver
   330  *
   331  */
   332 void RMdaToneUtilityTestBase::MatoPrepareComplete(TInt aError)
   333 	{
   334 	INFO_PRINTF1(_L("========== Tone Utility MatoPrepareComplete() callback =========="));
   335 	if(iToneUtilityState == EStateInitializing)
   336 		{
   337 		INFO_PRINTF1(_L("Tone Utility MatoPrepareComplete"));
   338 		Fsm(EEventPrepareComplete, aError);
   339 		}
   340 	}
   341 
   342 /*
   343  *
   344  * MatoPlayComplete - From MMdaAudioToneObserver
   345  *
   346  */
   347 void RMdaToneUtilityTestBase::MatoPlayComplete(TInt aError)
   348 	{
   349 	INFO_PRINTF1(_L("========== Tone Utility MatoPlayComplete() callback =========="));
   350 	if (aError == KErrNone)
   351 		{
   352 		INFO_PRINTF2(_L("Tone Utility called MatoPlayComplete with error = %d as expected"), aError);
   353 		iEndTime.HomeTime();
   354 		TTimeIntervalMicroSeconds playduration = iEndTime.MicroSecondsFrom(iStartTime);
   355 		if(playduration > iExpected - KVariation && playduration < iExpected + KVariation)
   356 			{
   357 			INFO_PRINTF2(_L("Tone played for %ld. Value is between acceptable threshold"),playduration.Int64());
   358 			StopTest(aError,EPass);
   359 			}
   360 		else
   361 			{
   362 			ERR_PRINTF2(_L("Tone played for %ld. Value is not between acceptable threshold"),playduration.Int64());
   363 			StopTest(KErrGeneral);
   364 			}
   365 		}
   366 	else
   367 		{
   368 		ERR_PRINTF2(_L("Tone Utility called MatoPlayComplete with error = %d"), aError);
   369 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
   370 		StopTest(aError);
   371 		}
   372 	}
   373 
   374 /*
   375  *========================================================================================================
   376  * MM-MMF-ACLNT-I-0168-HP
   377  *========================================================================================================
   378  */
   379 RMdaToneUtilityResumeTest::RMdaToneUtilityResumeTest(const TDesC& aTestName, const TDesC& aSectName)
   380 	:	RMdaToneUtilityTestBase(aTestName,aSectName)
   381 	{
   382 	}
   383 
   384 /*
   385  *
   386  * NewL
   387  *
   388  */
   389 RMdaToneUtilityResumeTest* RMdaToneUtilityResumeTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
   390 	{
   391 	RMdaToneUtilityResumeTest * self = new(ELeave)RMdaToneUtilityResumeTest(aTestName,aSectName);
   392 	return self;
   393 	}
   394 
   395 /*
   396  *
   397  * DoKickoffTestL
   398  *
   399  */
   400 void RMdaToneUtilityResumeTest::DoKickoffTestL()
   401 	{
   402 	TPtrC filename;
   403 	// Get the duration of the audio file to play
   404 	if (!GetIntFromConfig(iSectName, KDuration, iDuration))
   405 		{
   406 		ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
   407 		StopTest(KErrNotFound);
   408 		return;
   409 		}
   410 	// Get the pause time
   411 	if (!GetIntFromConfig(iSectName, KPause, iPause))
   412 		{
   413 		ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
   414 		StopTest(KErrNotFound);
   415 		return;
   416 		}		
   417 	// Get the filename of the audio file to play
   418 	if (!GetStringFromConfig(iSectName, KSequence, filename))
   419 		{
   420 		ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
   421 		StopTest(KErrNotFound);
   422 		return;
   423 		}
   424 	// open using RFile for playback
   425 	iFilename.Copy(filename);
   426 	TInt err = iFile.Open(iFs, iFilename, EFileRead);
   427 	if (err != KErrNone)
   428 		{
   429 		ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
   430 		iFs.Close();
   431 		User::Leave(err);
   432 		}
   433 	iWait = ETrue;
   434 	iExpected = iDuration + iPause*KOneSecond;
   435 	INFO_PRINTF2(_L("File under test  -> %S"), &iFilename);
   436 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
   437 	}
   438 
   439 /*
   440  *
   441  * DoTimerCallback
   442  *
   443  */
   444 void RMdaToneUtilityResumeTest::DoTimerCallback()
   445 	{
   446 	if(!iWait)
   447 		{
   448 		INFO_PRINTF1(_L("Cancelling timer"));
   449 		iTimer->Cancel();
   450 		}
   451 	else
   452 		{
   453 		INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
   454 		}
   455 	Fsm (EEventTimerComplete, KErrNone);
   456 	}
   457 
   458 /*
   459  *========================================================================================================
   460  * MM-MMF-ACLNT-I-0169-HP
   461  *========================================================================================================
   462  */
   463 RMdaToneUtilityResumeThreeTest::RMdaToneUtilityResumeThreeTest(const TDesC& aTestName, const TDesC& aSectName)
   464 	:	RMdaToneUtilityTestBase(aTestName,aSectName)
   465 	{
   466 	}
   467 
   468 /*
   469  *
   470  * NewL
   471  *
   472  */
   473 RMdaToneUtilityResumeThreeTest* RMdaToneUtilityResumeThreeTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
   474 	{
   475 	RMdaToneUtilityResumeThreeTest * self = new(ELeave)RMdaToneUtilityResumeThreeTest(aTestName,aSectName);
   476 	return self;
   477 	}
   478 
   479 /*
   480  *
   481  * DoKickoffTestL
   482  *
   483  */
   484 void RMdaToneUtilityResumeThreeTest::DoKickoffTestL()
   485 	{
   486 	TPtrC filename;
   487 	// Get the duration of the audio file to play
   488 	if (!GetIntFromConfig(iSectName, KDuration, iDuration))
   489 		{
   490 		ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
   491 		StopTest(KErrNotFound);
   492 		return;
   493 		}
   494 	// Get the pause time
   495 	if (!GetIntFromConfig(iSectName, KPause, iPause))
   496 		{
   497 		ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
   498 		StopTest(KErrNotFound);
   499 		return;
   500 		}	
   501 	// Get the filename of the audio file to play
   502 	if (!GetStringFromConfig(iSectName, KSequence, filename))
   503 		{
   504 		ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
   505 		StopTest(KErrNotFound);
   506 		return;
   507 		}
   508 	// open using RFile for playback
   509 	iFilename.Copy(filename);
   510 	TInt err = iFile.Open(iFs, iFilename, EFileRead);
   511 	if (err != KErrNone)
   512 		{
   513 		ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
   514 		iFs.Close();
   515 		User::Leave(err);
   516 		}
   517 	iWait = ETrue;
   518 	iExpected = iDuration + 3*(iPause*KOneSecond);
   519 	INFO_PRINTF2(_L("File under test  -> %S"), &iFilename);
   520 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
   521 	iCount = 0;
   522 	}
   523 
   524 /*
   525  *
   526  * DoTimerCallback
   527  *
   528  */
   529 void RMdaToneUtilityResumeThreeTest::DoTimerCallback()
   530 	{
   531 	iCount++;
   532 	if(!iWait && iCount == 6) //Repeating Pause-Resume cycle three times
   533 		{
   534 		iTimer->Cancel();
   535 		Fsm (EEventTimerComplete, KErrNone);
   536 		}
   537 	else
   538 		{
   539 		INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
   540 		Fsm (EEventTimerComplete, KErrNone);
   541 		}
   542 	}
   543 
   544 /*
   545  *========================================================================================================
   546  * MM-MMF-ACLNT-I-0170-HP
   547  *========================================================================================================
   548  */
   549 RMdaToneUtilityPlayPauseStopPlayTest::RMdaToneUtilityPlayPauseStopPlayTest(const TDesC& aTestName, const TDesC& aSectName)
   550 	:	RMdaToneUtilityTestBase(aTestName,aSectName)
   551 	{
   552 	}
   553 
   554 /*
   555  *
   556  * NewL
   557  *
   558  */
   559 RMdaToneUtilityPlayPauseStopPlayTest* RMdaToneUtilityPlayPauseStopPlayTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
   560 	{
   561 	RMdaToneUtilityPlayPauseStopPlayTest * self = new(ELeave)RMdaToneUtilityPlayPauseStopPlayTest(aTestName,aSectName);
   562 	return self;
   563 	}
   564 
   565 /*
   566  *
   567  * DoKickoffTestL
   568  *
   569  */
   570 void RMdaToneUtilityPlayPauseStopPlayTest::DoKickoffTestL()
   571 	{
   572 	TPtrC filename;
   573 	// Get the duration of the audio file to play
   574 	if (!GetIntFromConfig(iSectName, KDuration, iDuration))
   575 		{
   576 		ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
   577 		StopTest(KErrNotFound);
   578 		return;
   579 		}
   580 	// Get the pause time
   581 	if (!GetIntFromConfig(iSectName, KPause, iPause))
   582 		{
   583 		ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
   584 		StopTest(KErrNotFound);
   585 		return;
   586 		}	
   587 	// Get the filename of the audio file to play
   588 	if (!GetStringFromConfig(iSectName, KSequence, filename))
   589 		{
   590 		ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
   591 		StopTest(KErrNotFound);
   592 		return;
   593 		}
   594 	// open using RFile for playback
   595 	iFilename.Copy(filename);
   596 	TInt err = iFile.Open(iFs, iFilename, EFileRead);
   597 	if (err != KErrNone)
   598 		{
   599 		ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
   600 		iFs.Close();
   601 		User::Leave(err);
   602 		return;
   603 		}
   604 	iWait = ETrue;
   605 	iStop = ETrue;
   606 	iExpected = iDuration + 3*(iPause*KOneSecond);
   607 	INFO_PRINTF2(_L("File under test  -> %S"), &iFilename);
   608 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
   609 	iCount = 0;
   610 	}
   611 
   612 /*
   613  *
   614  * DoTimerCallback
   615  *
   616  */
   617 void RMdaToneUtilityPlayPauseStopPlayTest::DoTimerCallback()
   618 	{
   619 	if(!iWait && iStop)
   620 		{
   621 		INFO_PRINTF1(_L("Stopping playback"));
   622 		iToneUtility->CancelPlay();
   623 		iStop = EFalse;
   624 		iToneUtilityState = EStateStopped;
   625 		iWait = ETrue;
   626 		INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
   627 		Fsm (EEventTimerComplete, KErrNone);
   628 		}
   629 	else if(!iWait && !iStop)
   630 		{
   631 		iTimer->Cancel();
   632 		Fsm (EEventTimerComplete, KErrNone);
   633 		}
   634 	else
   635 		{
   636 		INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
   637 		Fsm (EEventTimerComplete, KErrNone);
   638 		}
   639 	}
   640 
   641 /*
   642  *========================================================================================================
   643  * MM-MMF-ACLNT-I-0171-HP
   644  *========================================================================================================
   645  */
   646 RMdaToneUtilityConfigResumeTest::RMdaToneUtilityConfigResumeTest(const TDesC& aTestName, const TDesC& aSectName)
   647 	:	RMdaToneUtilityTestBase(aTestName,aSectName)
   648 	{
   649 	}
   650 
   651 /*
   652  *
   653  * NewL
   654  *
   655  */
   656 RMdaToneUtilityConfigResumeTest* RMdaToneUtilityConfigResumeTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
   657 	{
   658 	RMdaToneUtilityConfigResumeTest * self = new(ELeave)RMdaToneUtilityConfigResumeTest(aTestName,aSectName);
   659 	return self;
   660 	}
   661 
   662 /*
   663  *
   664  * DoKickoffTestL
   665  *
   666  */
   667 void RMdaToneUtilityConfigResumeTest::DoKickoffTestL()
   668 	{
   669 	TPtrC filename;
   670 	// Get the duration of the audio file to play
   671 	if (!GetIntFromConfig(iSectName, KDuration, iDuration))
   672 		{
   673 		ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
   674 		StopTest(KErrNotFound);
   675 		return;
   676 		}
   677 	// Get the pause time
   678 	if (!GetIntFromConfig(iSectName, KPause, iPause))
   679 		{
   680 		ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
   681 		StopTest(KErrNotFound);
   682 		return;
   683 		}	
   684 	// Get the filename of the audio file to play
   685 	if (!GetStringFromConfig(iSectName, KSequence, filename))
   686 		{
   687 		ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
   688 		StopTest(KErrNotFound);
   689 		return;
   690 		}
   691 	// Get the volume
   692 	if (!GetIntFromConfig(iSectName, KVolume, iVolume))
   693 		{
   694 		ERR_PRINTF1(_L("Volume could not be retrieved from ini file"));
   695 		StopTest(KErrNotFound);
   696 		return;
   697 		}
   698 	// Get the balance
   699 	if (!GetIntFromConfig(iSectName, KBalance, iBalance))
   700 		{
   701 		ERR_PRINTF1(_L("Balance could not be retrieved from ini file"));
   702 		StopTest(KErrNotFound);
   703 		return;
   704 		}
   705 	// open using RFile for playback
   706 	iFilename.Copy(filename);
   707 	TInt err = iFile.Open(iFs, iFilename, EFileRead);
   708 	if (err != KErrNone)
   709 		{
   710 		ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
   711 		iFs.Close();
   712 		User::Leave(err);
   713 		return;
   714 		}
   715 	iWait = ETrue;
   716 	iConfig = ETrue;
   717 	iExpected = iDuration + iPause*KOneSecond;
   718 	INFO_PRINTF2(_L("File under test  -> %S"), &iFilename);
   719 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
   720 	}
   721 
   722 /*
   723  *
   724  * DoTimerCallback
   725  *
   726  */
   727 void RMdaToneUtilityConfigResumeTest::DoTimerCallback()
   728 	{
   729 	if(!iWait && !iConfig)
   730 		{
   731 		iTimer->Cancel();
   732 		INFO_PRINTF1(_L("Comparing Volume and Balance with values set"));
   733 		if (iVolume == iToneUtility->Volume() && Abs(iBalance - iToneUtility->GetBalanceL())<KBalanceTolerance)
   734 			{
   735 			INFO_PRINTF3(_L("Volume = %d and Balance = %d as expected"),iVolume,iBalance);
   736 			}
   737 		else
   738 			{
   739 			ERR_PRINTF1(_L("Retrieved values are different than expected"));
   740 			ERR_PRINTF5(_L("Retrieved Volume = %d and Balance = %d. Expected Volume = %d and Balance = %d"),iToneUtility->Volume(),iToneUtility->GetBalanceL(),iVolume,iBalance);
   741 			StopTest(KErrGeneral);
   742 			}
   743 		}
   744 	else
   745 		{
   746 		INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
   747 		Fsm (EEventTimerComplete, KErrNone);
   748 		}
   749 	}
   750 
   751 /*
   752  *========================================================================================================
   753  * MM-MMF-ACLNT-I-0172-HP
   754  *========================================================================================================
   755  */
   756 RMdaToneUtilityPrepareInPauseTest::RMdaToneUtilityPrepareInPauseTest(const TDesC& aTestName, const TDesC& aSectName)
   757 	:	RMdaToneUtilityTestBase(aTestName,aSectName)
   758 	{
   759 	}
   760 
   761 /*
   762  *
   763  * NewL
   764  *
   765  */
   766 RMdaToneUtilityPrepareInPauseTest* RMdaToneUtilityPrepareInPauseTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
   767 	{
   768 	RMdaToneUtilityPrepareInPauseTest * self = new(ELeave)RMdaToneUtilityPrepareInPauseTest(aTestName,aSectName);
   769 	return self;
   770 	}
   771 
   772 /*
   773  *
   774  * DoKickoffTestL
   775  *
   776  */
   777 void RMdaToneUtilityPrepareInPauseTest::DoKickoffTestL()
   778 	{
   779 	TPtrC filename;
   780 	// Get the duration of the audio file to play
   781 	if (!GetIntFromConfig(iSectName, KDuration, iDuration))
   782 		{
   783 		ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
   784 		StopTest(KErrNotFound);
   785 		return;
   786 		}
   787 	// Get the pause time
   788 	if (!GetIntFromConfig(iSectName, KPause, iPause))
   789 		{
   790 		ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
   791 		StopTest(KErrNotFound);
   792 		return;
   793 		}	
   794 	// Get the filename of the audio file to play
   795 	if (!GetStringFromConfig(iSectName, KSequence, filename))
   796 		{
   797 		ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
   798 		StopTest(KErrNotFound);
   799 		return;
   800 		}
   801 	// open using RFile for playback
   802 	iFilename.Copy(filename);
   803 	TInt err = iFile.Open(iFs, iFilename, EFileRead);
   804 	if (err != KErrNone)
   805 		{
   806 		ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
   807 		iFs.Close();
   808 		User::Leave(err);
   809 		return;
   810 		}
   811 	iWait = ETrue;
   812 	iPrepare = ETrue;
   813 	iExpected = iDuration;
   814 	INFO_PRINTF2(_L("File under test  -> %S"), &iFilename);
   815 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
   816 	}
   817 
   818 /*
   819  *
   820  * DoTimerCallback
   821  *
   822  */
   823 void RMdaToneUtilityPrepareInPauseTest::DoTimerCallback()
   824 	{
   825 	if(!iWait)
   826 		{
   827 		iTimer->Cancel();
   828 		Fsm (EEventTimerComplete, KErrNone);
   829 		}
   830 	else
   831 		{
   832 		INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
   833 		Fsm (EEventTimerComplete, KErrNone);
   834 		}
   835 	}
   836 
   837 /*
   838  *
   839  * MatoPrepareComplete - From MMdaAudioToneObserver
   840  *
   841  */
   842 void RMdaToneUtilityPrepareInPauseTest::MatoPrepareComplete(TInt aError)
   843 	{
   844 	INFO_PRINTF1(_L("========== Tone Utility MatoPrepareComplete() callback =========="));
   845 	if(iToneUtilityState == EStateInitializing)
   846 		{
   847 		INFO_PRINTF1(_L("Tone Utility MatoPrepareComplete"));
   848 		Fsm(EEventPrepareComplete, aError);
   849 		}
   850 	else if(iToneUtilityState == EStatePlaying)
   851 		{
   852 		if(aError == KErrNone)
   853 			{
   854 			INFO_PRINTF2(_L("Tone Utility returned with expected error %d"),aError);
   855 			INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioToneUtility::Play"));
   856 			iStartTime.HomeTime(); //Register start time here. Tone should restart
   857             iToneUtility->Play();
   858 			}
   859 		else
   860 			{
   861 			ERR_PRINTF1(_L("Preparing tone playback was not successful while paused. This is unexpected"));
   862 			StopTest(aError);
   863 			}
   864 		}
   865 	}
   866 
   867 /*
   868  *========================================================================================================
   869  * MM-MMF-ACLNT-I-0173-HP
   870  *========================================================================================================
   871  */
   872 RMdaToneUtilityPauseBeforePlayTest::RMdaToneUtilityPauseBeforePlayTest(const TDesC& aTestName, const TDesC& aSectName)
   873 	:	RMdaToneUtilityTestBase(aTestName,aSectName)
   874 	{
   875 	}
   876 
   877 /*
   878  *
   879  * NewL
   880  *
   881  */
   882 RMdaToneUtilityPauseBeforePlayTest* RMdaToneUtilityPauseBeforePlayTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
   883 	{
   884 	RMdaToneUtilityPauseBeforePlayTest * self = new(ELeave)RMdaToneUtilityPauseBeforePlayTest(aTestName,aSectName);
   885 	return self;
   886 	}
   887 
   888 /*
   889  *
   890  * DoKickoffTestL
   891  *
   892  */
   893 void RMdaToneUtilityPauseBeforePlayTest::DoKickoffTestL()
   894 	{
   895 	TPtrC filename;
   896 	// Get the duration of the audio file to play
   897 	if (!GetIntFromConfig(iSectName, KDuration, iDuration))
   898 		{
   899 		ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
   900 		StopTest(KErrNotFound);
   901 		return;
   902 		}	
   903 	// Get the filename of the audio file to play
   904 	if (!GetStringFromConfig(iSectName, KSequence, filename))
   905 		{
   906 		ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
   907 		StopTest(KErrNotFound);
   908 		return;
   909 		}
   910 	// open using RFile for playback
   911 	iFilename.Copy(filename);
   912 	TInt err = iFile.Open(iFs, iFilename, EFileRead);
   913 	if (err != KErrNone)
   914 		{
   915 		ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
   916 		iFs.Close();
   917 		User::Leave(err);
   918 		return;
   919 		}
   920 	iExpected = iDuration;		
   921 	INFO_PRINTF2(_L("File under test  -> %S"), &iFilename);
   922 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
   923 	}
   924 
   925 /*
   926  *
   927  * MatoPrepareComplete - From MMdaAudioToneObserver
   928  *
   929  */
   930 void RMdaToneUtilityPauseBeforePlayTest::MatoPrepareComplete(TInt aError)
   931 	{
   932 	INFO_PRINTF1(_L("========== Tone Utility MatoPrepareComplete() callback =========="));
   933 	if(iToneUtilityState == EStateInitializing)
   934 		{
   935 		INFO_PRINTF1(_L("Tone Utility MatoPrepareComplete"));
   936 		Fsm(EEventPrepareComplete, aError);
   937 		}
   938 	}
   939 
   940 /*
   941  *
   942  * Fsm - Executes playing events of AudioPlayerUtility in sequence
   943  *
   944  */
   945 void RMdaToneUtilityPauseBeforePlayTest::Fsm(TMdaAudioUtilityEvent aMdaAudioUtilityEvent, TInt aError)
   946 	{
   947 	TInt error = 0;
   948 	switch (iToneUtilityState)
   949 		{
   950 		case EStateCreated:
   951 			{
   952 			if (aMdaAudioUtilityEvent == EEventInitialize)
   953 				{
   954 				StartTimer(20*KOneSecond); //wait twenty seconds. If timer callback occurrs then Pause worked while not in play
   955 				INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Pause before preparing to play"));
   956 				error = iToneUtility->Pause();
   957 				if(error == KErrNotReady)
   958 					{
   959 					INFO_PRINTF1(_L("Pause before preparing to play returned with KErrNotReady as expected"));
   960 					}
   961 				else
   962 					{
   963 					ERR_PRINTF2(_L("Pause before preparing to play returned with %d instead of KErrNotReady as expected"),error);
   964 					StopTest(error);
   965 					}
   966 				INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayFileSequence"));
   967 				iToneUtility->PrepareToPlayFileSequence(iFile);
   968 
   969 				INFO_PRINTF1(_L("MdaAudioUtility State: EStateInitializing"));
   970 				iToneUtilityState = EStateInitializing;
   971 				}
   972 			else
   973 				{
   974 				ERR_PRINTF2(_L("MdaAudioUtility EEventInitialize not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
   975 				StopTest(aError, EFail);
   976 				}
   977 			break;
   978 			}
   979 		case EStateInitializing:
   980 			{
   981 			if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError == KErrNone)
   982 				{
   983 				INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
   984 				iToneUtility->SetVolume(iToneUtility->MaxVolume()/2);
   985 				INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Pause before playing"));
   986 				error = iToneUtility->Pause();
   987 				if(error == KErrNotReady)
   988 					{
   989 					INFO_PRINTF1(_L("Pause before preparing to play returned with KErrNotReady as expected"));
   990 					}
   991 				else
   992 					{
   993 					ERR_PRINTF2(_L("Pause before preparing to play returned with %d instead of KErrNotReady as expected"),error);
   994 					StopTest(error);
   995 					}
   996 				INFO_PRINTF1(_L("Starting playback"));
   997 				iToneUtility->Play();
   998 				iStartTime.HomeTime();
   999 				}
  1000 			else if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError != KErrNone)
  1001 				{
  1002 				ERR_PRINTF2(_L("MatoPrepareComplete returned with error = %d"), aError);
  1003 				StopTest(aError);	
  1004 				}
  1005 			else
  1006 				{
  1007 				ERR_PRINTF2(_L("MdaAudioUtility EEventPrepareComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
  1008 				StopTest(aError, EFail);
  1009 				}
  1010 			break;
  1011 			}
  1012 		default:
  1013 			{
  1014 			ERR_PRINTF2(_L("Invalid MdaAudioUtility state received: %d"), iToneUtilityState);
  1015 			StopTest(KErrGeneral);
  1016 			}
  1017 		}
  1018 	}
  1019 
  1020 /*
  1021  *
  1022  * DoTimerCallback
  1023  *
  1024  */
  1025 void RMdaToneUtilityPauseBeforePlayTest::DoTimerCallback()
  1026 	{
  1027 	ERR_PRINTF1(_L("Timer callback received. This is unexpected"));
  1028 	StopTest(KErrGeneral);
  1029 	}
  1030 
  1031 /*
  1032  *========================================================================================================
  1033  * MM-MMF-ACLNT-I-0174-HP Negative
  1034  *========================================================================================================
  1035  */
  1036 RMdaToneUtilityNegPauseResumeTest::RMdaToneUtilityNegPauseResumeTest(const TDesC& aTestName, const TDesC& aSectName)
  1037 	:	RMdaToneUtilityTestBase(aTestName,aSectName)
  1038 	{
  1039 	}
  1040 
  1041 /*
  1042  *
  1043  * NewL
  1044  *
  1045  */
  1046 RMdaToneUtilityNegPauseResumeTest* RMdaToneUtilityNegPauseResumeTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1047 	{
  1048 	RMdaToneUtilityNegPauseResumeTest * self = new(ELeave)RMdaToneUtilityNegPauseResumeTest(aTestName,aSectName);
  1049 	return self;
  1050 	}
  1051 
  1052 /*
  1053  *
  1054  * DoKickoffTestL
  1055  *
  1056  */
  1057 void RMdaToneUtilityNegPauseResumeTest::DoKickoffTestL()
  1058 	{
  1059 	TPtrC filename;
  1060 	// Get the pause time
  1061 	if (!GetIntFromConfig(iSectName, KPause, iPause))
  1062 		{
  1063 		ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
  1064 		StopTest(KErrNotFound);
  1065 		return;
  1066 		}	
  1067 	// Get the filename of the audio file to play	
  1068 	if (!GetStringFromConfig(iSectName, KSequence, filename))
  1069 		{
  1070 		ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
  1071 		StopTest(KErrNotFound);
  1072 		return;
  1073 		}
  1074 	// open using RFile for playback
  1075 	iFilename.Copy(filename);
  1076 	TInt err = iFile.Open(iFs, iFilename, EFileRead);
  1077 	if (err != KErrNone)
  1078 		{
  1079 		ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
  1080 		iFs.Close();
  1081 		User::Leave(err);
  1082 		return;
  1083 		}
  1084 	iWait = ETrue;
  1085 	iNegative = ETrue;
  1086 	iCount = 0;
  1087 	INFO_PRINTF2(_L("File under test  -> %S"), &iFilename);
  1088 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  1089 	}
  1090 
  1091 /*
  1092  *
  1093  * DoTimerCallback
  1094  *
  1095  */
  1096 void RMdaToneUtilityNegPauseResumeTest::DoTimerCallback()
  1097 	{
  1098 	INFO_PRINTF1(_L("Cancelling timer"));
  1099 	iTimer->Cancel();
  1100 	INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
  1101 	Fsm (EEventTimerComplete, KErrNone);
  1102 	}
  1103 
  1104 /*
  1105  *
  1106  * MatoPlayComplete - From MMdaAudioToneObserver
  1107  *
  1108  */
  1109 void RMdaToneUtilityNegPauseResumeTest::MatoPlayComplete(TInt aError)
  1110 	{
  1111 	INFO_PRINTF1(_L("========== Tone Utility MatoPlayComplete() callback =========="));
  1112 	iCount++;
  1113 	if (aError == KErrNone)
  1114 		{
  1115 		INFO_PRINTF2(_L("Tone Utility called MatoPlayComplete with error = %d as expected"), aError);
  1116 		switch(iCount)
  1117 			{
  1118 			//NOTE:"PlayFixedSequence is not supported on A3F"
  1119 			case 1:
  1120 				INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayTone"));
  1121 				iToneUtility->PrepareToPlayTone(KToneFrequency, KFiveSeconds);
  1122 				INFO_PRINTF1(_L("MdaAudioUtility State: EStateInitializing"));
  1123 				iToneUtilityState = EStateInitializing;
  1124 				break;	
  1125 			case 2:
  1126 				INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayDualTone"));
  1127 				iToneUtility->PrepareToPlayDualTone(KToneFrequency, KToneFrequencyTwo, KFiveSeconds);
  1128 				INFO_PRINTF1(_L("MdaAudioUtility State: EStateInitializing"));
  1129 				iToneUtilityState = EStateInitializing;
  1130 				break;
  1131 			case 3:
  1132 				INFO_PRINTF1(_L("All tone variations have been tested"));
  1133 				StopTest(aError);
  1134 				break;
  1135 			}
  1136 		}
  1137 	else
  1138 		{
  1139 		ERR_PRINTF2(_L("Tone Utility called MatoPlayComplete with error = %d"), aError);
  1140 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
  1141 		StopTest(aError);
  1142 		}
  1143 	}
  1144 
  1145 /*
  1146  *========================================================================================================
  1147  * MM-MMF-ACLNT-I-0183-HP
  1148  *========================================================================================================
  1149  */
  1150 RMdaToneUtilityPauseNonA3fTest::RMdaToneUtilityPauseNonA3fTest(const TDesC& aTestName, const TDesC& aSectName)
  1151 	:	RMdaToneUtilityTestBase(aTestName,aSectName)
  1152 	{
  1153 	}
  1154 
  1155 /*
  1156  *
  1157  * NewL
  1158  *
  1159  */
  1160 RMdaToneUtilityPauseNonA3fTest* RMdaToneUtilityPauseNonA3fTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1161 	{
  1162 	RMdaToneUtilityPauseNonA3fTest * self = new(ELeave)RMdaToneUtilityPauseNonA3fTest(aTestName,aSectName);
  1163 	return self;
  1164 	}
  1165 
  1166 /*
  1167  *
  1168  * DoKickoffTestL
  1169  *
  1170  */
  1171 void RMdaToneUtilityPauseNonA3fTest::DoKickoffTestL()
  1172 	{
  1173 	TPtrC filename;
  1174 	// Get the filename of the audio file to play
  1175 	if (!GetStringFromConfig(iSectName, KSequence, filename))
  1176 		{
  1177 		ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
  1178 		StopTest(KErrNotFound);
  1179 		return;
  1180 		}
  1181 	// open using RFile for playback
  1182 	iFilename.Copy(filename);
  1183 	TInt err = iFile.Open(iFs, iFilename, EFileRead);
  1184 	if (err != KErrNone)
  1185 		{
  1186 		ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
  1187 		iFs.Close();
  1188 		User::Leave(err);
  1189 		return;
  1190 		}
  1191 	// Get the duration of the audio file to play
  1192 	if (!GetIntFromConfig(iSectName, KDuration, iDuration))
  1193 		{
  1194 		ERR_PRINTF1(_L("Duration could not be retrieved from ini file"));
  1195 		User::Leave(KErrNotFound);
  1196 		return;
  1197 		}
  1198 	// Get the pause time
  1199 	if (!GetIntFromConfig(iSectName, KPause, iPause))
  1200 		{
  1201 		ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
  1202 		User::Leave(KErrNotFound);
  1203 		return;
  1204 		}
  1205 	iExpected = iDuration;		
  1206 	INFO_PRINTF2(_L("File under test  -> %S"), &iFilename);
  1207 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  1208 	}
  1209 
  1210 /*
  1211  *
  1212  * MatoPrepareComplete - From MMdaAudioToneObserver
  1213  *
  1214  */
  1215 void RMdaToneUtilityPauseNonA3fTest::MatoPrepareComplete(TInt aError)
  1216 	{
  1217 	INFO_PRINTF1(_L("========== Tone Utility MatoPrepareComplete() callback =========="));
  1218 	if(iToneUtilityState == EStateInitializing)
  1219 		{
  1220 		INFO_PRINTF1(_L("Tone Utility MatoPrepareComplete"));
  1221 		Fsm(EEventPrepareComplete, aError);
  1222 		}
  1223 	}
  1224 
  1225 /*
  1226  *
  1227  * Fsm - Executes playing events of AudioToneUtility in sequence
  1228  *
  1229  */
  1230 void RMdaToneUtilityPauseNonA3fTest::Fsm(TMdaAudioUtilityEvent aMdaAudioUtilityEvent, TInt aError)
  1231 	{
  1232 	TInt error = 0;
  1233 	switch (iToneUtilityState)
  1234 		{
  1235 		case EStateCreated:
  1236 			{
  1237 			if (aMdaAudioUtilityEvent == EEventInitialize)
  1238 				{
  1239 				INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::PrepareToPlayFileSequence"));
  1240 				iToneUtility->PrepareToPlayFileSequence(iFile);
  1241 
  1242 				INFO_PRINTF1(_L("MdaAudioUtility State: EStateInitializing"));
  1243 				iToneUtilityState = EStateInitializing;
  1244 				}
  1245 			else
  1246 				{
  1247 				ERR_PRINTF2(_L("MdaAudioUtility EEventInitialize not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
  1248 				StopTest(aError, EFail);
  1249 				}
  1250 			break;
  1251 			}
  1252 		case EStateInitializing:
  1253 			{
  1254 			if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError == KErrNone)
  1255 				{
  1256 				INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
  1257 				iToneUtility->SetVolume(iToneUtility->MaxVolume()/2);
  1258 				INFO_PRINTF1(_L("Starting playback"));
  1259 				iToneUtility->Play();
  1260 				iStartTime.HomeTime();
  1261 				iToneUtilityState = EStatePlaying;
  1262 				StartTimer(iPause*KOneSecond); //wait to pause
  1263 				}
  1264 			else if (aMdaAudioUtilityEvent == EEventPrepareComplete && aError != KErrNone)
  1265 				{
  1266 				ERR_PRINTF2(_L("MatoPrepareComplete returned with error = %d"), aError);
  1267 				StopTest(aError);	
  1268 				}
  1269 			else
  1270 				{
  1271 				ERR_PRINTF2(_L("MdaAudioUtility EEventPrepareComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
  1272 				StopTest(aError, EFail);
  1273 				}
  1274 			break;
  1275 			}
  1276 		case EStatePlaying:
  1277 			{
  1278 			if(aMdaAudioUtilityEvent == EEventTimerComplete)
  1279 				{
  1280 				INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Pause in non-a3f configuration"));
  1281 				error = iToneUtility->Pause();
  1282 				if(error == KErrNotSupported)
  1283 					{
  1284 					INFO_PRINTF1(_L("Pause in ToneUtility returned with KErrNotSupported as expected"));
  1285 					}
  1286 				else
  1287 					{
  1288 					ERR_PRINTF2(_L("Pause in ToneUtility returned with %d instead of KErrNotSupported as expected"),error);
  1289 					StopTest(error);
  1290 					}
  1291 				INFO_PRINTF1(_L("Calling CMdaAudioToneUtility::Resume in non-a3f configuration"));
  1292 				error = iToneUtility->Resume();
  1293 				if(error == KErrNotReady)
  1294 					{
  1295 					INFO_PRINTF1(_L("Resume returned with KErrNotReady as expected"));
  1296 					iToneUtilityState = EStatePlaying;
  1297 					}
  1298 				else
  1299 					{
  1300 					ERR_PRINTF2(_L("Resume returned with %d instead of KErrNotReady as expected"),error);
  1301 					StopTest(error);
  1302 					}					
  1303 				}
  1304 			else
  1305 				{
  1306 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
  1307 				StopTest(aError, EFail);
  1308 				}
  1309 			break;
  1310 			}
  1311 		default:
  1312 			{
  1313 			ERR_PRINTF2(_L("Invalid MdaAudioUtility state received: %d"), iToneUtilityState);
  1314 			StopTest(KErrGeneral);
  1315 			}
  1316 		}
  1317 	}
  1318 
  1319 /*
  1320  *
  1321  * DoTimerCallback
  1322  *
  1323  */
  1324 void RMdaToneUtilityPauseNonA3fTest::DoTimerCallback()
  1325 	{
  1326 	INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
  1327 	INFO_PRINTF1(_L("Cancelling timer"));
  1328 	iTimer->Cancel();
  1329 	Fsm (EEventTimerComplete, KErrNone);
  1330 	}