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