os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/playtruepause.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 AudioPlayerUtility
    15 // 
    16 //
    17 
    18 /**
    19  @file PlayTruePause.cpp
    20 */
    21 
    22 #include "playtruepause.h"
    23 
    24 /*
    25  *
    26  * RMdaPlayerUtilityTestBase - Test step constructor
    27  *
    28  */
    29 RMdaPlayerUtilityTestBase::RMdaPlayerUtilityTestBase(const TDesC& aTestName, const TDesC& aSectName)
    30 	:	iAudioUtilityState(EStateInitial), 
    31 		iPlayerUtility(NULL),
    32 		iTimer(NULL),
    33 		iFilename(KNullDesC),
    34 		iStop(EFalse),
    35 		iQuery(EFalse),
    36 		iVolume(0),
    37 		iBalance(0),
    38 		iResume(EFalse),
    39 		iPauseResumeTimes(0),
    40 		iPauseApplied(0),
    41 		iDuration(0),
    42 		iAllFormat(0),
    43 		iPositionSupported(EFalse),
    44 		iMiliSec(EFalse)
    45 	{
    46 	iTestStepName = aTestName;
    47 	iSectName = aSectName;
    48 	}
    49 
    50 /*
    51  *
    52  * ~RMdaPlayerUtilityTestBase - Test step destructor
    53  *
    54  */
    55 RMdaPlayerUtilityTestBase::~RMdaPlayerUtilityTestBase()
    56 	{
    57 	if (iPlayerUtility)
    58 		{
    59 		delete iPlayerUtility;
    60 		}
    61 	if(iTimer)
    62 		{
    63 		delete iTimer;
    64 		}
    65 	}
    66 
    67 /*
    68  *
    69  * KickoffTestL - Starts the test
    70  *
    71  */
    72 void RMdaPlayerUtilityTestBase::KickoffTestL()
    73 	{
    74 	INFO_PRINTF1(_L("__________  Creating Player Utility object ___________"));
    75 	TRAPD(err,  iPlayerUtility = CMdaAudioPlayerUtility::NewL(*this));
    76 	if (err != KErrNone)
    77 		{
    78 		ERR_PRINTF2(_L("Could not create Player Utility object. Error = %d"), err);
    79 		StopTest(err);
    80 		return;
    81 		}
    82 	INFO_PRINTF1(_L("Player Utility State: EStateCreated"));
    83 	iAudioUtilityState = EStateCreated;
    84 	DoKickoffTestL();
    85 	INFO_PRINTF1(_L("Audio Player Utility Event: EEventInitialize"));
    86 	Fsm(EEventInitialize, KErrNone);
    87 	}
    88 
    89 /*
    90  *
    91  * CloseTest
    92  *
    93  */
    94 void RMdaPlayerUtilityTestBase::CloseTest()
    95 	{
    96 	INFO_PRINTF1(KMsgDelete);
    97 	delete iPlayerUtility;
    98 	delete iTimer;
    99 	}
   100 
   101 /*
   102  *
   103  * StartTimer - Starts timer and timer callback
   104  *
   105  */
   106 void RMdaPlayerUtilityTestBase::StartTimer(TTimeIntervalMicroSeconds32 aWaitTime)
   107 	{
   108 	TTimeIntervalMicroSeconds32 timeInterval;
   109 	
   110 	if(aWaitTime <= TTimeIntervalMicroSeconds32(0))
   111 		{
   112 		timeInterval = KMicroSecInOneSec;
   113 		}
   114 	else
   115 		{
   116 		timeInterval = aWaitTime;
   117 		}
   118 	TCallBack callback (TimerCallback, this);
   119 	iTimer->Start(timeInterval, timeInterval, callback);
   120 	INFO_PRINTF1(_L("Timer has been started"));
   121 	}
   122 
   123 /*
   124  *
   125  * TimerCallback
   126  *
   127  */
   128 TInt RMdaPlayerUtilityTestBase::TimerCallback(TAny* aPtr)
   129 	{
   130 	static_cast<RMdaPlayerUtilityTestBase*>(aPtr)->DoTimerCallback();
   131 	return KErrNone;
   132 	}
   133 
   134 /*
   135  *
   136  * DoTimerCallback
   137  *
   138  */
   139 void RMdaPlayerUtilityTestBase::DoTimerCallback()
   140 	{
   141 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
   142 	Fsm (EEventTimerComplete, KErrNone);
   143 	}
   144 
   145 /*
   146  *
   147  * Fsm - Executes playing events of AudioPlayerUtility in sequence
   148  *
   149  */
   150 void RMdaPlayerUtilityTestBase::Fsm(TMdaAudioUtilityEvent aMdaAudioUtilityEvent, TInt aError)
   151 	{
   152 	switch (iAudioUtilityState)
   153 		{
   154 		case EStateCreated:
   155 			{
   156 			__ASSERT_ALWAYS((aError == KErrNone), Panic(iTestStepName.Right(KPanicLength), EFsmIncorrectErrorPassed));
   157 			if (aMdaAudioUtilityEvent == EEventInitialize)
   158 				{
   159 				INFO_PRINTF1(_L("Calling CMdaAudioPlayerUtility::OpenFileL"));
   160 				TRAPD(err,iPlayerUtility->OpenFileL(iFilename));
   161 				if(err)
   162 					{
   163 					ERR_PRINTF2(_L("CMdaAudioPlayerUtility::OpenFileL left with err = %d"),err);
   164 					StopTest(err);
   165 					break;
   166 					}
   167 				INFO_PRINTF1(_L("AudioPlayerUtility State: EStateInitializing"));
   168 				iAudioUtilityState = EStateInitializing;
   169 				}
   170 			else
   171 				{
   172 				ERR_PRINTF2(_L("MdaAudioUtility EEventInitialize not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
   173 				StopTest(aError, EFail);
   174 				}
   175 			break;
   176 			}
   177 		case EStateInitializing:
   178 			{
   179 			if (aMdaAudioUtilityEvent == EEventInitComplete && aError == KErrNone)
   180 				{
   181 				INFO_PRINTF1(_L("Calling CMdaAudioPlayerUtility::Play"));
   182 				iPlayerUtility->Play();
   183 				INFO_PRINTF1(_L("AudioPlayerUtility State: EStatePlaying"));
   184 				iAudioUtilityState = EStatePlaying;
   185 				if(iMiliSec)
   186 					{
   187 					StartTimer(iDuration*KMiliSecInOneSec);
   188 					}
   189 				else
   190 					{
   191 					StartTimer(iDuration*KMicroSecInOneSec);
   192 					}
   193 				}
   194 			else if (aMdaAudioUtilityEvent == EEventInitComplete && aError != KErrNone)
   195 				{
   196 				ERR_PRINTF2(_L("MapcInitComplete returned with error = %d"), aError);
   197 				StopTest(aError);	
   198 				}
   199 			else
   200 				{
   201 				ERR_PRINTF2(_L("MdaAudioUtility EEventInitComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
   202 				StopTest(aError, EFail);
   203 				}
   204 			break;
   205 			}
   206 		case EStatePlaying:
   207 			{
   208 			if(aMdaAudioUtilityEvent == EEventTimerComplete)
   209 				{
   210 				INFO_PRINTF1(_L("Calling CMdaAudioPlayerUtility::Pause"));
   211 				TInt err = iPlayerUtility->Pause();
   212 				iPauseApplied = ETrue;
   213 				INFO_PRINTF1(_L("AudioPlayerUtility State: EStatePause"));
   214 				iAudioUtilityState = EStatePause;
   215 				}
   216 			else
   217 				{
   218 				ERR_PRINTF2(_L("MdaAudioUtility EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
   219 				StopTest(aError, EFail);
   220 				}
   221 			break;
   222 			}
   223 		case EStatePause:
   224 			{
   225 			if (aMdaAudioUtilityEvent == EEventTimerComplete)
   226 				{
   227 				if(iQuery)
   228 					{
   229 					INFO_PRINTF2(_L("Setting AudioPlayerUtility volume = %d"), iVolume);
   230 					TInt err = iPlayerUtility->SetVolume(iVolume);
   231 					if (err != KErrNone)
   232 						{
   233 						ERR_PRINTF2(_L("Setting volume failed. It returned with error = %d"), err);
   234 						StopTest(err);
   235 						break;
   236 						}
   237 					TInt volume = 0;
   238 					INFO_PRINTF1(_L("Calling CMdaAudioPlayerUtility::GetVolume for verifying"));
   239 					err = iPlayerUtility->GetVolume(volume);
   240 					if (err != KErrNone)
   241 						{
   242 						ERR_PRINTF2(_L("CMdaAudioPlayerUtility::GetVolume returned with error = %d"), err);
   243 						StopTest(err);
   244 						break;
   245 						}
   246 					if(iVolume != volume)
   247 						{
   248 						ERR_PRINTF2(_L("CMdaAudioPlayerUtility::SetVolume returned different set value = %d"), volume);
   249 						StopTest(KErrGeneral);
   250 						break;
   251 						}
   252 					INFO_PRINTF2(_L("Setting AudioPlayerUtility balance = %d"), iBalance);
   253 					err = iPlayerUtility->SetBalance(iBalance);
   254 					if (err != KErrNone)
   255 						{
   256 						ERR_PRINTF2(_L("Setting balance failed. It returned with error = %d"), err);
   257 						StopTest(err);
   258 						break;
   259 						}
   260 					TInt balance = 0;
   261 					INFO_PRINTF1(_L("Calling CMdaAudioPlayerUtility::GetBalance for verifying"));
   262 					err = iPlayerUtility->GetBalance(balance);
   263 					if (err != KErrNone)
   264 						{
   265 						ERR_PRINTF2(_L("CMdaAudioPlayerUtility::GetBalance returned with error = %d"), err);
   266 						StopTest(err);
   267 						break;
   268 						}
   269 					if(Abs(iBalance - balance)<KBalanceTolerance)
   270 						{
   271 						INFO_PRINTF2(_L("CMdaAudioPlayerUtility::SetBalance returned expected set value %d"),iBalance);
   272 						}
   273 					else
   274 						{
   275 						ERR_PRINTF3(_L("CMdaAudioPlayerUtility::SetBalance returned different set value %d. Retrieved %d"), iBalance, balance);
   276 						StopTest(KErrGeneral);
   277 						break;
   278 						}
   279 					INFO_PRINTF1(_L("Calling CMdaAudioPlayerUtility::Play"));
   280 					iPlayerUtility->Play();
   281 					iTimer->Cancel();
   282 					INFO_PRINTF1(_L("Audio Player Utility State: EStatePlaying"));
   283 					iAudioUtilityState = EStatePlaying;
   284 					INFO_PRINTF1(_L("Calling CMdaAudioPlayerUtility::GetVolume for verifying"));
   285 					err = iPlayerUtility->GetVolume(volume);
   286 					if (err != KErrNone)
   287 						{
   288 						ERR_PRINTF2(_L("CMdaAudioPlayerUtility::GetVolume returned with error = %d"), err);
   289 						StopTest(err);
   290 						break;
   291 						}
   292 					if (volume == iVolume)
   293 						{
   294 						INFO_PRINTF1(_L("CMdaAudioPlayerUtility::GetVolume returned equal previous set value as expected"));
   295 						}
   296 					else
   297 						{
   298 						ERR_PRINTF2(_L("CMdaAudioPlayerUtility::GetVolume returned different set value = %d"), iVolume);
   299 						StopTest (KErrGeneral);
   300 						break;
   301 						}
   302 					INFO_PRINTF1(_L("Calling CMdaAudioPlayerUtility::GetBalance for verifying"));
   303 					err = iPlayerUtility->GetBalance(balance);
   304 					if (err != KErrNone)
   305 						{
   306 						ERR_PRINTF2(_L("CMdaAudioPlayerUtility::GetBalance returned with error = %d"), err);
   307 						StopTest(err);
   308 						break;
   309 						}
   310 					if(Abs(iBalance - balance)<KBalanceTolerance)
   311 						{
   312 						INFO_PRINTF2(_L("CMdaAudioPlayerUtility::GetBalance returned expected set value %d"),iBalance);
   313 						}
   314 					else
   315 						{
   316 						ERR_PRINTF3(_L("CMdaAudioPlayerUtility::GetBalance returned different set value = %d. Retrieved %d"), iBalance, balance);
   317 						StopTest(KErrGeneral);
   318 						break;
   319 						}
   320 					}
   321 				if(iResume || iStop)
   322 					{
   323 					TTimeIntervalMicroSeconds position1 = 0;
   324 					if(iPositionSupported)
   325 						{
   326 						INFO_PRINTF1(_L("Calling CMdaAudioPlayerUtility::GetPosition"));
   327 						TInt err = iPlayerUtility->GetPosition(position1);
   328 						if(err)
   329 							{
   330 							ERR_PRINTF2(_L("CMdaAudioPlayerUtility::GetPosition returned with err = %d"), err);
   331 							StopTest(err);
   332 							break;
   333 							}
   334 						INFO_PRINTF2(_L("AudioPlayerUtility position = %Ld"), position1.Int64());
   335 						if(position1.Int64() == 0)
   336 							{
   337 							INFO_PRINTF1(_L("AudioPlayerUtility position must be longer than 0"));
   338 							StopTest(KErrGeneral);
   339 							break;
   340 							}
   341 						}
   342 					if(iStop)
   343 						{
   344 						INFO_PRINTF1(_L("Calling CMdaAudioPlayerUtility::Stop"));
   345 						iPlayerUtility->Stop();
   346 						}
   347 					INFO_PRINTF1(_L("Calling CMdaAudioPlayerUtility::Play"));
   348 					iPlayerUtility->Play();
   349 					if((--iPauseResumeTimes) <= 0)
   350 						{
   351 						iTimer->Cancel();
   352 						}
   353 					INFO_PRINTF1(_L("AudioPlayerUtility State: EStatePlaying"));
   354 					iAudioUtilityState = EStatePlaying;
   355 					TTimeIntervalMicroSeconds position2 = 0;
   356 					if(iPositionSupported)
   357 						{
   358 						INFO_PRINTF1(_L("Calling CMdaAudioPlayerUtility::GetPosition"));
   359 						TInt err = iPlayerUtility->GetPosition(position2);
   360 						if(err)
   361 							{
   362 							ERR_PRINTF2(_L("CMdaAudioPlayerUtility::GetPosition returned with err = %d"), err);
   363 							StopTest(err);
   364 							break;
   365 							}
   366 						INFO_PRINTF2(_L(" AudioPlayerUtility position = %Ld"), position2.Int64());
   367 						}
   368 					if(iStop)
   369 						{
   370 						if(position2.Int64() == 0)
   371 							{
   372 							INFO_PRINTF1(_L("AudioPlayerUtility position was reset as expected"));
   373 							}
   374 						else
   375 							{
   376 							INFO_PRINTF1(_L("AudioPlayerUtility position was not reset"));
   377 							StopTest(KErrGeneral);
   378 							break;
   379 							}
   380 						}
   381 					else if(iPositionSupported)
   382 						{
   383 						if(Abs(position2.Int64() - position1.Int64()) <= KOneSecond/2)
   384 							{
   385 							INFO_PRINTF2(_L("AudioPlayerUtility position continued from expected position %Ld"),position2.Int64());
   386 							}
   387 						else
   388 							{
   389 							ERR_PRINTF3(_L("Playback did not resume from expected position. Expected %Ld Retrieved %Ld"),position1.Int64(),position2.Int64());
   390 							StopTest(KErrGeneral);
   391 							break;
   392 							}
   393 						}
   394 					else
   395 						{
   396 						INFO_PRINTF1(_L("AudioPlayerUtility continue playing "));
   397 						}
   398 					
   399 					}
   400 				}
   401 			else
   402 				{
   403 				ERR_PRINTF2(_L("MdaAudioUtility EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioUtilityEvent);
   404 				StopTest(aError, EFail);
   405 				}
   406 			break;
   407 			}
   408 		default:
   409 			{
   410 			ERR_PRINTF2(_L("Invalid MdaAudioUtility state received: %d"), aMdaAudioUtilityEvent);
   411 			StopTest(KErrGeneral);
   412 			}
   413 		}
   414 	}
   415 
   416 /*
   417  *
   418  * MapcInitComplete - From MMdaAudioPlayerCallback
   419  *
   420  */
   421 void RMdaPlayerUtilityTestBase::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
   422 	{
   423 	INFO_PRINTF1(_L("========== Audio Player Utility MapcInitComplete() callback =========="));
   424 	if(iAudioUtilityState == EStateInitializing)
   425 		{
   426 		INFO_PRINTF1(_L(" Audio Player Utility Event: EEventInitComplete"));
   427 		Fsm(EEventInitComplete, aError);
   428 		}
   429 	}
   430 
   431 /*
   432  *
   433  * MapcPlayComplete - From MMdaAudioPlayerCallback
   434  *
   435  */
   436 void RMdaPlayerUtilityTestBase::MapcPlayComplete(TInt aError)
   437 	{
   438 	INFO_PRINTF1(_L("========== Audio Player Utility MapcPlayComplete() callback =========="));
   439 	if (aError == KErrNone)
   440 		{
   441 		INFO_PRINTF2(_L("AudioPlayerUtility called MapcPlayComplete with error = %d as expected"), aError);
   442 		StopTest();
   443 		}
   444 	else
   445 		{
   446 		ERR_PRINTF2(_L("AudioPlayerUtility called MapcPlayComplete with error = %d"), aError);
   447 		ERR_PRINTF2(_L("Expected error = %d"), KErrNone);
   448 		StopTest(aError);
   449 		}
   450 	}
   451 
   452 /*
   453  *
   454  * Panic
   455  *
   456  */
   457 void RMdaPlayerUtilityTestBase::Panic(const TDesC &aCategory, TInt aReason)
   458 	{
   459 	User::Panic(aCategory, aReason);
   460 	}
   461 
   462 /*
   463  *========================================================================================================
   464  * MM-MMF-ACLNT-I-0185-HP
   465  *========================================================================================================
   466  */
   467 RMdaPlayerUtiliyPauseStopAndPlayWavTest::RMdaPlayerUtiliyPauseStopAndPlayWavTest(const TDesC& aTestName, const TDesC& aSectName)
   468 	:	RMdaPlayerUtilityTestBase(aTestName, aSectName)
   469 	{
   470 	iStop = ETrue;
   471 	iPositionSupported = ETrue;
   472 	}
   473 
   474 /*
   475  *
   476  * NewL
   477  *
   478  */
   479 RMdaPlayerUtiliyPauseStopAndPlayWavTest* RMdaPlayerUtiliyPauseStopAndPlayWavTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
   480 	{
   481 	RMdaPlayerUtiliyPauseStopAndPlayWavTest * self = new(ELeave)RMdaPlayerUtiliyPauseStopAndPlayWavTest(aTestName, aSectName);
   482 	return self;
   483 	}
   484 
   485 /*
   486  *
   487  * DoKickoffTestL
   488  *
   489  */
   490 void RMdaPlayerUtiliyPauseStopAndPlayWavTest::DoKickoffTestL()
   491 	{
   492 	TPtrC filename;
   493 	// Get the filename of the audio file to play
   494 	if (!GetStringFromConfig(iSectName, KFilenameWAV, filename))
   495 		{
   496 		ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
   497 		StopTest(KErrNotFound);
   498 		return;
   499 		}
   500 	// open using RFile for playback
   501 	iFilename.Copy(filename);
   502 	INFO_PRINTF2(_L("File under test  -> %S"), &iFilename);
   503 	if (!GetIntFromConfig(iSectName, KDuration1, iDuration))
   504 		{
   505 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration1);
   506 		StopTest(KErrNotFound);
   507 		return;
   508 		}
   509 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
   510 	}
   511 /*
   512  *========================================================================================================
   513  * MM-MMF-ACLNT-I-0186-HP
   514  *========================================================================================================
   515  */
   516 RMdaPlayerUtilityQueryPauseAndPlayWavTest::RMdaPlayerUtilityQueryPauseAndPlayWavTest(const TDesC& aTestName, const TDesC& aSectName)
   517 	:	RMdaPlayerUtilityTestBase(aTestName, aSectName)
   518 	{
   519 	iQuery = ETrue;
   520 	}
   521 
   522 /*
   523  *
   524  * NewL
   525  *
   526  */
   527 RMdaPlayerUtilityQueryPauseAndPlayWavTest* RMdaPlayerUtilityQueryPauseAndPlayWavTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
   528 	{
   529 	RMdaPlayerUtilityQueryPauseAndPlayWavTest * self = new(ELeave)RMdaPlayerUtilityQueryPauseAndPlayWavTest(aTestName, aSectName);
   530 	return self;
   531 	}
   532 
   533 /*
   534  *
   535  * DoKickoffTestL
   536  *
   537  */
   538 void RMdaPlayerUtilityQueryPauseAndPlayWavTest::DoKickoffTestL()
   539 	{
   540 	TPtrC filename;
   541 	// Get the filename of the audio file to play
   542 	if (!GetStringFromConfig(iSectName, KFilenameWAV, filename))
   543 		{
   544 		ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
   545 		StopTest(KErrNotFound);
   546 		return;
   547 		}
   548 	// open using RFile for playback
   549 	iFilename.Copy(filename);
   550 	INFO_PRINTF2(_L("File under test  -> %S"), &iFilename);
   551 	if (!GetIntFromConfig(iSectName, KVolume, iVolume))
   552 		{
   553 		ERR_PRINTF2(KMsgErrorGetParameter, &KVolume);
   554 		StopTest(KErrNotFound);
   555 		return;
   556 		}
   557 	if (!GetIntFromConfig(iSectName, KBalance, iBalance))
   558 		{
   559 		ERR_PRINTF2(KMsgErrorGetParameter, &KBalance);
   560 		StopTest(KErrNotFound);
   561 		return;
   562 		}
   563 	if (!GetIntFromConfig(iSectName, KDuration1, iDuration))
   564 		{
   565 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration1);
   566 		StopTest(KErrNotFound);
   567 		return;
   568 		}
   569 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
   570 	}
   571 
   572 /*
   573  *========================================================================================================
   574  * MM-MMF-ACLNT-I-0187-HP
   575  *========================================================================================================
   576  */
   577 RMdaPlayerUtilityPauseAndPlaySqnTest::RMdaPlayerUtilityPauseAndPlaySqnTest(const TDesC& aTestName, const TDesC& aSectName)
   578 	:	RMdaPlayerUtilityTestBase(aTestName, aSectName)
   579 	{
   580 	iResume = ETrue;
   581 	}
   582 
   583 /*
   584  *
   585  * NewL
   586  *
   587  */
   588 RMdaPlayerUtilityPauseAndPlaySqnTest* RMdaPlayerUtilityPauseAndPlaySqnTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
   589 	{
   590 	RMdaPlayerUtilityPauseAndPlaySqnTest * self = new(ELeave)RMdaPlayerUtilityPauseAndPlaySqnTest(aTestName, aSectName);
   591 	return self;
   592 	}
   593 
   594 /*
   595  *
   596  * DoKickoffTestL
   597  *
   598  */
   599 void RMdaPlayerUtilityPauseAndPlaySqnTest::DoKickoffTestL()
   600 	{
   601 	TPtrC filename;
   602 	// Get the filename of the audio file to play
   603 	if (!GetStringFromConfig(iSectName, KFilenameSQN, filename))
   604 		{
   605 		ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
   606 		StopTest(KErrNotFound);
   607 		return;
   608 		}
   609 	// open using RFile for playback
   610 	iFilename.Copy(filename);
   611 	INFO_PRINTF2(_L("File under test  -> %S"), &iFilename);
   612 	if (!GetIntFromConfig(iSectName, KDuration1, iDuration))
   613 		{
   614 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration1);
   615 		StopTest(KErrNotFound);
   616 		return;
   617 		}
   618 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
   619 	}
   620 
   621 /*
   622  *========================================================================================================
   623  * MM-MMF-ACLNT-I-0188-HP
   624  *========================================================================================================
   625  */
   626 RMdaPlayerUtilityPauseAndPlayThreeTimesSqnTest::RMdaPlayerUtilityPauseAndPlayThreeTimesSqnTest(const TDesC& aTestName, const TDesC& aSectName)
   627 	:	RMdaPlayerUtilityTestBase(aTestName, aSectName)
   628 	{
   629 	iResume = ETrue;
   630 	iPauseResumeTimes = KRepeatThrice;
   631 	}
   632 
   633 /*
   634  *
   635  * NewL
   636  *
   637  */
   638 RMdaPlayerUtilityPauseAndPlayThreeTimesSqnTest* RMdaPlayerUtilityPauseAndPlayThreeTimesSqnTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
   639 	{
   640 	RMdaPlayerUtilityPauseAndPlayThreeTimesSqnTest * self = new(ELeave)RMdaPlayerUtilityPauseAndPlayThreeTimesSqnTest(aTestName, aSectName);
   641 	return self;
   642 	}
   643 
   644 /*
   645  *
   646  * DoKickoffTestL
   647  *
   648  */
   649 void RMdaPlayerUtilityPauseAndPlayThreeTimesSqnTest::DoKickoffTestL()
   650 	{
   651 	TPtrC filename;
   652 	// Get the filename of the audio file to play
   653 	if (!GetStringFromConfig(iSectName, KFilenameSQN, filename))
   654 		{
   655 		ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
   656 		StopTest(KErrNotFound);
   657 		return;
   658 		}
   659 	// open using RFile for playback
   660 	iFilename.Copy(filename);
   661 	INFO_PRINTF2(_L("File under test  -> %S"), &iFilename);
   662 	if (!GetIntFromConfig(iSectName, KDuration1, iDuration))
   663 		{
   664 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration1);
   665 		StopTest(KErrNotFound);
   666 		return;
   667 		}
   668 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
   669 	}
   670 
   671 /*
   672  *========================================================================================================
   673  * MM-MMF-ACLNT-I-0189-HP
   674  *========================================================================================================
   675  */
   676 RMdaPlayerUtilityPauseStopAndPlaySqnTest::RMdaPlayerUtilityPauseStopAndPlaySqnTest(const TDesC& aTestName, const TDesC& aSectName)
   677 	:	RMdaPlayerUtilityTestBase(aTestName, aSectName)
   678 	{
   679 	iStop = ETrue;
   680 	}
   681 
   682 /*
   683  *
   684  * NewL
   685  *
   686  */
   687 RMdaPlayerUtilityPauseStopAndPlaySqnTest* RMdaPlayerUtilityPauseStopAndPlaySqnTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
   688 	{
   689 	RMdaPlayerUtilityPauseStopAndPlaySqnTest * self = new(ELeave)RMdaPlayerUtilityPauseStopAndPlaySqnTest(aTestName, aSectName);
   690 	return self;
   691 	}
   692 
   693 /*
   694  *
   695  * DoKickoffTestL
   696  *
   697  */
   698 void RMdaPlayerUtilityPauseStopAndPlaySqnTest::DoKickoffTestL()
   699 	{
   700 	TPtrC filename;
   701 	// Get the filename of the audio file to play
   702 	if (!GetStringFromConfig(iSectName, KFilenameSQN, filename))
   703 		{
   704 		ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
   705 		StopTest(KErrNotFound);
   706 		return;
   707 		}
   708 	// open using RFile for playback
   709 	iFilename.Copy(filename);
   710 	INFO_PRINTF2(_L("File under test  -> %S"), &iFilename);
   711 	if (!GetIntFromConfig(iSectName, KDuration1, iDuration))
   712 		{
   713 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration1);
   714 		StopTest(KErrNotFound);
   715 		return;
   716 		}
   717 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
   718 	}
   719 
   720 /*
   721  *========================================================================================================
   722  * MM-MMF-ACLNT-I-0190-HP
   723  *========================================================================================================
   724  */
   725 RMdaPlayerUtilityGetVolumeAndBalancePauseAndPlaySqnTest::RMdaPlayerUtilityGetVolumeAndBalancePauseAndPlaySqnTest(const TDesC& aTestName, const TDesC& aSectName)
   726 	:	RMdaPlayerUtilityTestBase(aTestName, aSectName)
   727 	{
   728 	iQuery = ETrue;
   729 	}
   730 
   731 /*
   732  *
   733  * NewL
   734  *
   735  */
   736 RMdaPlayerUtilityGetVolumeAndBalancePauseAndPlaySqnTest* RMdaPlayerUtilityGetVolumeAndBalancePauseAndPlaySqnTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
   737 	{
   738 	RMdaPlayerUtilityGetVolumeAndBalancePauseAndPlaySqnTest * self = new(ELeave)RMdaPlayerUtilityGetVolumeAndBalancePauseAndPlaySqnTest(aTestName, aSectName);
   739 	return self;
   740 	}
   741 
   742 /*
   743  *
   744  * DoKickoffTestL
   745  *
   746  */
   747 void RMdaPlayerUtilityGetVolumeAndBalancePauseAndPlaySqnTest::DoKickoffTestL()
   748 	{
   749 	TPtrC filename;
   750 	// Get the filename of the audio file to play
   751 	if (!GetStringFromConfig(iSectName, KFilenameSQN, filename))
   752 		{
   753 		ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
   754 		StopTest(KErrNotFound);
   755 		return;
   756 		}
   757 	// open using RFile for playback
   758 	iFilename.Copy(filename);
   759 	INFO_PRINTF2(_L("File under test  -> %S"), &iFilename);
   760 	if (!GetIntFromConfig(iSectName, KVolume, iVolume))
   761 		{
   762 		ERR_PRINTF2(KMsgErrorGetParameter, &KVolume);
   763 		StopTest(KErrNotFound);
   764 		return;
   765 		}
   766 	if (!GetIntFromConfig(iSectName, KBalance, iBalance))
   767 		{
   768 		ERR_PRINTF2(KMsgErrorGetParameter, &KBalance);
   769 		StopTest(KErrNotFound);
   770 		return;
   771 		}
   772 	if (!GetIntFromConfig(iSectName, KDuration1, iDuration))
   773 		{
   774 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration1);
   775 		StopTest(KErrNotFound);
   776 		return;
   777 		}
   778 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
   779 	}
   780 
   781 /*
   782  *========================================================================================================
   783  * MM-MMF-ACLNT-I-0191-HP
   784  *========================================================================================================
   785  */
   786 RMdaPlayerUtilityPauseAndPlayFormatsTest::RMdaPlayerUtilityPauseAndPlayFormatsTest(const TDesC& aTestName, const TDesC& aSectName)
   787 	:	RMdaPlayerUtilityTestBase(aTestName, aSectName)
   788 	{
   789 	iResume = ETrue;
   790 	iPositionSupported = ETrue;
   791 	iMiliSec = ETrue;
   792 	}
   793 
   794 /*
   795  *
   796  * NewL
   797  *
   798  */
   799 RMdaPlayerUtilityPauseAndPlayFormatsTest* RMdaPlayerUtilityPauseAndPlayFormatsTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
   800 	{
   801 	RMdaPlayerUtilityPauseAndPlayFormatsTest * self = new(ELeave)RMdaPlayerUtilityPauseAndPlayFormatsTest(aTestName, aSectName);
   802 	return self;
   803 	}
   804 
   805 /*
   806  *
   807  * DoKickoffTestL
   808  *
   809  */
   810 void RMdaPlayerUtilityPauseAndPlayFormatsTest::DoKickoffTestL()
   811 	{
   812 	TPtrC filename;
   813 	// Get the filename of the audio file to play
   814 	if (!GetStringFromConfig(iSectName, KFilenamePCM16, filename))
   815 		{
   816 		ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
   817 		StopTest(KErrNotFound);
   818 		return;
   819 		}
   820 	// open using RFile for playback
   821 	iFilename.Copy(filename);
   822 	INFO_PRINTF2(_L("File \"PCM16\" under test  -> %S"), &iFilename);
   823 	if (!GetIntFromConfig(iSectName, KDurationMiliSec, iDuration))
   824 		{
   825 		ERR_PRINTF2(KMsgErrorGetParameter, &KDurationMiliSec);
   826 		StopTest(KErrNotFound);
   827 		return;
   828 		}
   829 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
   830 	}
   831 
   832 /*
   833  *
   834  * MapcPlayComplete - From MMdaAudioPlayerCallback
   835  *
   836  */
   837 void RMdaPlayerUtilityPauseAndPlayFormatsTest::MapcPlayComplete(TInt aError)
   838 	{
   839 	INFO_PRINTF1(_L("========== Audio Player Utility MapcPlayComplete() callback =========="));
   840 	if (aError == KErrNone)
   841 		{
   842 		if(iPauseApplied)
   843 			{
   844 			INFO_PRINTF2(_L("AudioPlayerUtility called MapcPlayComplete with error = %d as expected"), aError);
   845 			TBuf<KFileFormatSize> fileFormat;
   846 			switch(iAllFormat)
   847 				{
   848 				case EPCM8Format:
   849 					{
   850 					fileFormat.Copy(KFilenamePCM8);
   851 					INFO_PRINTF2(_L("File \"PCM8\" under test  -> %S"), &fileFormat);
   852 					break;
   853 					}
   854 				case EPCMU16Format:
   855 					{
   856 					fileFormat.Copy(KFilenamePCMU16);
   857 					INFO_PRINTF2(_L("File \"PCMU16\" under test  -> %S"), &fileFormat);
   858 					break;
   859 					}
   860 				case EPCMU16BEFormat:
   861 					{
   862 					fileFormat.Copy(KFilenamePCMU16BE);
   863 					INFO_PRINTF2(_L("File \"PCMU16BE\" under test  -> %S"), &fileFormat);
   864 					break;
   865 					}
   866 				case EALAWFormat:
   867 					{
   868 					fileFormat.Copy(KFilenameAlaw);
   869 					INFO_PRINTF2(_L("File \"ALAW\" under test  -> %S"), &fileFormat);
   870 					break;
   871 					}
   872 				case EMULAWFormat:
   873 					{
   874 					fileFormat.Copy(KFilenameMulaw);
   875 					INFO_PRINTF2(_L("File \"MULAW\" under test  -> %S"), &fileFormat);
   876 					break;
   877 					}
   878 				case EGSM610Format:
   879 					{
   880 					fileFormat.Copy(KFilenameGSM610);
   881 					INFO_PRINTF2(_L("File \"GSM610\" under test  -> %S"), &fileFormat);
   882 					break;
   883 					}
   884 				case EIMADFormat:
   885 					{
   886 					fileFormat.Copy(KFilenameIMAD);
   887 					INFO_PRINTF2(_L("File \"IMAD\" under test  -> %S"), &fileFormat);
   888 					break;
   889 					}
   890 				case EPCMU8Format:
   891 					{
   892 					fileFormat.Copy(KFilenamePCMU8);
   893 					INFO_PRINTF2(_L("File \"PCMU8\" under test  -> %S"), &fileFormat);
   894 					break;
   895 					}
   896 				case EOGGFormat:
   897 					{
   898 					fileFormat.Copy(KFilenameOGG);
   899 					INFO_PRINTF2(_L("File \"OGG\" under test  -> %S"), &fileFormat);
   900 					break;
   901 					}
   902 				default:
   903 					{
   904 					break;
   905 					}
   906 				}
   907 			if(iAllFormat > EOGGFormat)
   908 				{
   909 				StopTest();
   910 				}
   911 			else
   912 				{
   913 				++iAllFormat;
   914 				iPauseApplied = EFalse;
   915 				TPtrC filename;
   916 				if (!GetStringFromConfig(iSectName, fileFormat, filename))
   917 					{
   918 					ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
   919 					StopTest(KErrNotFound);
   920 					return;
   921 					}
   922 				iFilename.Copy(filename);
   923 				INFO_PRINTF1(_L("Player Utility State: EStateCreated"));
   924 				iAudioUtilityState = EStateCreated;
   925 				INFO_PRINTF1(_L("Audio Player Utility Event: EEventInitialize"));
   926 				Fsm(EEventInitialize, KErrNone);
   927 				}
   928 			}
   929 		else
   930 			{
   931 			ERR_PRINTF2(_L("AudioPlayerUtility called MapcPlayComplete with error = %d"), aError);
   932 			ERR_PRINTF1(_L("Audio file was finished before continuing"));
   933 			StopTest(KErrGeneral);
   934 			}
   935 		}
   936 	else
   937 		{
   938 		ERR_PRINTF2(_L("AudioPlayerUtility called MapcPlayComplete with error = %d"), aError);
   939 		ERR_PRINTF2(_L("Expected error = %d"), KErrNone);
   940 		StopTest(aError);
   941 		}
   942 	}
   943