os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/TestPlayerUtils.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/TestPlayerUtils.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,4466 @@
     1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// This program is designed the test of the MMF_ACLNT.
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file TestPlayerUtils.cpp
    1.23 +*/
    1.24 +
    1.25 +
    1.26 +#include "TestPlayerUtils.h"
    1.27 +#include <caf/caf.h>
    1.28 +
    1.29 +// constant table of parameters for tests
    1.30 +const TRepeatParameters KTestParameters[] =
    1.31 +{	
    1.32 +	{ _S("playerAudioFile"), 1, 1},
    1.33 +	{ _S("Pcm16Mono12khz"), 3, 3},
    1.34 +	{ _S("PCM8"), 3, 3},
    1.35 +	{ _S("PCM8-6144bytes"), 1, 1},
    1.36 +	{ _S("ALAW"), 3, 3},
    1.37 +	{ _S("PCM16"), 1, 1},
    1.38 +	{ _S("PCMU8"), 2, 2},
    1.39 +	{ _S("PCMU16BE"), 3, 3},
    1.40 +	{ _S("PCMU16"), 1, 1},
    1.41 +	{ _S("MULAW"), 2, 2},
    1.42 +	{ _S("Sequence1"), 2, 2},
    1.43 +	{ _S("Sequence2"), 3, 3},
    1.44 +	{ _S("IMAD"), 3, 3},
    1.45 +	{ _S("GSM610"), 1, 1},
    1.46 +	{ _S("Pcm8Mono44khz"), 2, 2},
    1.47 +	{ _S("Pcm16Mono44khz"), 3, 3},
    1.48 +	{ _S("Pcm16Mono48khz"), 1, 1},
    1.49 +	{ _S("100khzSRate1KhzTone"), 2, 2},
    1.50 +	{ _S("Pcm16Mono24khz"), 3, 3},
    1.51 +	{ _S("playerAudioFile2"), 2, 2}
    1.52 +};
    1.53 +
    1.54 +const TInt KNoOfTestFiles = 20;
    1.55 +TAny	GetDriveName(TDes& aFileName)
    1.56 +{
    1.57 +#ifdef __WINS__
    1.58 +	aFileName = _L("c:");	
    1.59 +#elif defined(__MARM__) || defined(__X86GCC__)
    1.60 +	#ifdef __TEST_FILES_ON_C_DRIVE__
    1.61 +		aFileName = _L("c:");
    1.62 +	#else
    1.63 +		aFileName = _L("z:");	
    1.64 +	#endif // __TEST_FILES_ON_C_DRIVE__
    1.65 +#endif	
    1.66 +}
    1.67 +
    1.68 +
    1.69 +#define STOP_TEST_GEN_ERROR ERR_PRINTF1(_L("State machine error")), StopTest(KErrGeneral, EFail)
    1.70 +/**
    1.71 + * Constructor
    1.72 + */
    1.73 +CTestMmfAclntFile::CTestMmfAclntFile(const TDesC& aTestName,const TDesC& aSectName,
    1.74 +									 const TDesC& aKeyName,const TBool aPlay, 
    1.75 +									 const TInt aExpectedError)
    1.76 +	:iPlay (aPlay)
    1.77 +	,iExpectedError (aExpectedError)
    1.78 +	{
    1.79 +	// store the name of this test case
    1.80 +	// this is the name that is used by the script file
    1.81 +	// Each test step initialises it's own name
    1.82 +	iTestStepName = aTestName;
    1.83 +	iSectName = aSectName;
    1.84 +	iKeyName = aKeyName;
    1.85 +	}
    1.86 +
    1.87 +CTestMmfAclntFile* CTestMmfAclntFile::NewL(const TDesC& aTestName, const TDesC& aSectName,
    1.88 +										   const TDesC& aKeyName,const TBool aPlay, 
    1.89 +										   const TInt aExpectedError = KErrNone)
    1.90 +	{
    1.91 +	CTestMmfAclntFile* self = new (ELeave) CTestMmfAclntFile(aTestName,aSectName,aKeyName,aPlay,aExpectedError);
    1.92 +	return self;
    1.93 +	}
    1.94 +
    1.95 +CTestMmfAclntFile* CTestMmfAclntFile::NewLC(const TDesC& aTestName, const TDesC& aSectName,
    1.96 +											const TDesC& aKeyName,
    1.97 +											const TBool aPlay,  
    1.98 +											const TInt aExpectedError)
    1.99 +	{
   1.100 +	CTestMmfAclntFile* self = CTestMmfAclntFile::NewL(aTestName,aSectName,aKeyName,aPlay,aExpectedError);
   1.101 +	CleanupStack::PushL(self);
   1.102 +	return self;
   1.103 +	}
   1.104 +
   1.105 +void CTestMmfAclntFile::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration)
   1.106 +	{
   1.107 +	iError = aError;
   1.108 +	iDuration = aDuration;
   1.109 +	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
   1.110 +	CActiveScheduler::Stop();
   1.111 +	}
   1.112 +
   1.113 +void CTestMmfAclntFile::MapcPlayComplete(TInt aError)
   1.114 +	{
   1.115 +	iError = aError;
   1.116 +	INFO_PRINTF1(_L("MMdaAudioPlayerCallback Play Complete"));
   1.117 +	CActiveScheduler::Stop();
   1.118 +	}
   1.119 +
   1.120 +
   1.121 +
   1.122 +/** Load and initialise an audio file.
   1.123 + */
   1.124 +TVerdict CTestMmfAclntFile::DoTestStepL( void )
   1.125 +	{
   1.126 +	INFO_PRINTF1( _L("TestPlayerUtils : File"));
   1.127 +	TVerdict ret = EFail;
   1.128 +
   1.129 +	iError = KErrTimedOut;
   1.130 +
   1.131 +	TBuf<KSizeBuf>	filename;
   1.132 +	TPtrC			filename1; 
   1.133 +	if(!GetStringFromConfig(iSectName,iKeyName,filename1))
   1.134 +		{
   1.135 +		return EInconclusive;
   1.136 +		}
   1.137 +		
   1.138 +	GetDriveName(filename);
   1.139 +	filename.Append(filename1);
   1.140 +
   1.141 +	CMdaAudioPlayerUtility* player = NULL;
   1.142 +	INFO_PRINTF2(_L("CMdaAudioPlayerUtility::NewFilePlayerL() - %S"), &filename);
   1.143 +	player = CMdaAudioPlayerUtility::NewFilePlayerL(filename, *this);
   1.144 +
   1.145 +	if (iTestStepName.Compare(_L("MM-MMF-ACLNT-I-2001-HP"))==0)
   1.146 +		{
   1.147 +		// Check file size is more than 0
   1.148 +		RFs fs;
   1.149 +		TInt err = fs.Connect();
   1.150 +		if (err != KErrNone)
   1.151 +			{
   1.152 +			INFO_PRINTF2(_L("Error connecting to file session (%d)"), err);
   1.153 +			return EInconclusive;
   1.154 +			}
   1.155 +		CleanupClosePushL(fs);
   1.156 +		TEntry fileEntry;
   1.157 +		err = fs.Entry(filename, fileEntry);
   1.158 +		if (err != KErrNone)
   1.159 +			{
   1.160 +			INFO_PRINTF2(_L("Error getting file entry (%d)"), err);
   1.161 +			fs.Close();
   1.162 +			return EInconclusive;
   1.163 +			}
   1.164 +		if (fileEntry.iSize <= 0)
   1.165 +			{
   1.166 +			INFO_PRINTF2(_L("Test file '%S' has size %d"), fileEntry.iSize);
   1.167 +			fs.Close();
   1.168 +			return EInconclusive;
   1.169 +			
   1.170 +			}
   1.171 +		CleanupStack::PopAndDestroy();	// fs
   1.172 +		}
   1.173 +		
   1.174 +#ifndef __WINS__
   1.175 +	if (iTestStepName.Compare(_L("MM-MMF-ACLNT-I-2014-LP")) == 0)
   1.176 +		{
   1.177 +		// this test should not be run on Lubbock
   1.178 +		INFO_PRINTF1(_L("Lubbock hardware is not fast enough to convert 100KHz audio."));
   1.179 +		INFO_PRINTF1(_L("This test has been skipped for this reason..."));
   1.180 +		
   1.181 +		delete player;
   1.182 +		User::After(KOneSecond); // wait for deletion to shut down devsound
   1.183 +		
   1.184 +		return EPass;
   1.185 +		}
   1.186 +#endif
   1.187 +
   1.188 +	// Wait for initialisation callback
   1.189 +	INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
   1.190 +	CActiveScheduler::Start();
   1.191 +
   1.192 +	if(iError != KErrNone && (iExpectedError == iError))
   1.193 +		{
   1.194 +		if (iTestStepName.Compare(_L("MM-MMF-ACLNT-I-1008-HP")) == 0)
   1.195 +			{
   1.196 +			// Test is for non-existent file - check that the file has not been created
   1.197 +			RFs fs;
   1.198 +			TInt err = fs.Connect();
   1.199 +			if (err != KErrNone)
   1.200 +				{
   1.201 +				ret = EInconclusive;
   1.202 +				}
   1.203 +			else
   1.204 +				{
   1.205 +				TEntry entry;
   1.206 +				if (fs.Entry(filename, entry) == KErrNone)
   1.207 +					{
   1.208 +					ret = EFail;	// file exists - test fails
   1.209 +					}
   1.210 +					
   1.211 +				else
   1.212 +					ret = EPass;
   1.213 +				fs.Close();
   1.214 +				}
   1.215 +			}
   1.216 +		else
   1.217 +			{
   1.218 +			ret = EPass;	// all other tests pass
   1.219 +			}
   1.220 +		delete player;
   1.221 +		User::After(KOneSecond); // wait for deletion to shut down devsound
   1.222 +		ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with expectable error %d"),iError );
   1.223 +		return ret;
   1.224 +		}
   1.225 +	// Check for errors.
   1.226 +	if (iError == KErrNone && player != NULL)
   1.227 +		{
   1.228 +		if(iPlay)
   1.229 +			{
   1.230 +			iError = KErrTimedOut;
   1.231 +			player->Play();
   1.232 +			
   1.233 +			// Wait for init callback
   1.234 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
   1.235 +			CActiveScheduler::Start();
   1.236 +
   1.237 +			//can't use iExpected Error as is doesn't distinguish between 
   1.238 +			//error from NewFilePlayerL or PlayL.
   1.239 +			if ((iTestStepName.Compare(_L("MM-MMF-ACLNT-I-2015-LP")) == 0))
   1.240 +				{
   1.241 +				if(iError == KErrNotSupported)
   1.242 +					{
   1.243 +					ret = EPass;
   1.244 +					}
   1.245 +				}
   1.246 +			else if(iError == KErrNone)
   1.247 +				ret = EPass;
   1.248 +			}
   1.249 +		else
   1.250 +			ret = EPass;			
   1.251 +		}
   1.252 +	
   1.253 +	delete player;
   1.254 +	User::After(KOneSecond); // wait for deletion to shut down devsound
   1.255 +	if(iError != KErrNone)
   1.256 +		{
   1.257 +		if ((iTestStepName.Compare(_L("MM-MMF-ACLNT-I-2014-LP")) == 0) && iError==KErrNotSupported)
   1.258 +			{
   1.259 +			//Sampling Rate greater than 96000 Hz is not expected in data , and we dont support this.
   1.260 +			//This test has been changed to expect KErrNotSupported due to fix in PDEF131534 
   1.261 +			INFO_PRINTF1( _L("CMdaAudiPlayerUtility returned KErrNotSupported as expected"));
   1.262 +			ret= EPass;
   1.263 +			}
   1.264 +		else
   1.265 +			{
   1.266 +			ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with error %d"),iError );
   1.267 +			}
   1.268 +		}
   1.269 +		
   1.270 +	return	ret;
   1.271 +	}
   1.272 +
   1.273 +
   1.274 +
   1.275 +
   1.276 +
   1.277 +
   1.278 +
   1.279 +/**
   1.280 + * Constructor
   1.281 + */
   1.282 +CTestMmfAclntSEQNFile::CTestMmfAclntSEQNFile(const TDesC& aTestName,const TDesC& aSectName,
   1.283 +									 const TDesC& aKeyName,
   1.284 +									 const TBool aPlay, 
   1.285 +									 const TBool aIsFile)
   1.286 +	:iPlay (aPlay)
   1.287 +	,iIsFile (aIsFile)
   1.288 +	{
   1.289 +	// store the name of this test case
   1.290 +	// this is the name that is used by the script file
   1.291 +	// Each test step initialises it's own name
   1.292 +	iTestStepName = aTestName;
   1.293 +	iSectName = aSectName;
   1.294 +	iKeyName = aKeyName;
   1.295 +	}
   1.296 +
   1.297 +CTestMmfAclntSEQNFile* CTestMmfAclntSEQNFile::NewL(const TDesC& aTestName, const TDesC& aSectName,
   1.298 +										   const TDesC& aKeyName,
   1.299 +										   const TBool aPlay, 
   1.300 +										   const TBool aIsFile)
   1.301 +	{
   1.302 +	CTestMmfAclntSEQNFile* self = new (ELeave) CTestMmfAclntSEQNFile(aTestName,aSectName,aKeyName,aPlay,aIsFile);
   1.303 +	return self;
   1.304 +	}
   1.305 +
   1.306 +CTestMmfAclntSEQNFile* CTestMmfAclntSEQNFile::NewLC(const TDesC& aTestName, const TDesC& aSectName,
   1.307 +											const TDesC& aKeyName,
   1.308 +											const TBool aPlay,  
   1.309 +											const TBool aIsFile)
   1.310 +	{
   1.311 +	CTestMmfAclntSEQNFile* self = CTestMmfAclntSEQNFile::NewL(aTestName,aSectName,aKeyName,aPlay,aIsFile);
   1.312 +	CleanupStack::PushL(self);
   1.313 +	return self;
   1.314 +	}
   1.315 +
   1.316 +void CTestMmfAclntSEQNFile::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration)
   1.317 +	{
   1.318 +	iError = aError;
   1.319 +	iDuration = aDuration;
   1.320 +	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
   1.321 +	CActiveScheduler::Stop();
   1.322 +	}
   1.323 +
   1.324 +void CTestMmfAclntSEQNFile::MapcPlayComplete(TInt aError)
   1.325 +	{
   1.326 +	iError = aError;
   1.327 +	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
   1.328 +	CActiveScheduler::Stop();
   1.329 +	}
   1.330 + 
   1.331 +
   1.332 +//This method is used to stop playing the file 1 second after we started
   1.333 +void CTestMmfAclntSEQNFile::DelayedMethodCallL()
   1.334 +{
   1.335 +CActiveScheduler::Stop();
   1.336 +}
   1.337 +
   1.338 +
   1.339 +
   1.340 +/** Load and play an audio sequence file.
   1.341 + */
   1.342 +TVerdict CTestMmfAclntSEQNFile::DoTestStepL( void )
   1.343 +	{
   1.344 +	INFO_PRINTF1( _L("TestPlayerUtils : File"));
   1.345 +	TVerdict ret = EFail;
   1.346 +
   1.347 +	iError = KErrTimedOut;
   1.348 +
   1.349 +	TBuf<KSizeBuf>	filename;
   1.350 +	TPtrC			filename1; 
   1.351 +	if(!GetStringFromConfig(iSectName,iKeyName,filename1))
   1.352 +		{
   1.353 +		return EInconclusive;
   1.354 +		}
   1.355 +	
   1.356 +	GetDriveName(filename);
   1.357 +	filename.Append(filename1);
   1.358 +
   1.359 +
   1.360 +	CMdaAudioPlayerUtility* player = NULL;
   1.361 +	HBufC8* seqnDesc = NULL;
   1.362 +	RFile file;
   1.363 +	RFs fs;
   1.364 +
   1.365 +	if(iIsFile)
   1.366 +		{
   1.367 +		player = CMdaAudioPlayerUtility::NewFilePlayerL(filename, *this);
   1.368 +		}
   1.369 +	else
   1.370 +		{
   1.371 +
   1.372 +		User::LeaveIfError(fs.Connect());
   1.373 +//TIMB
   1.374 +		User::LeaveIfError(file.Open(fs, filename, EFileShareReadersOnly | EFileStream));
   1.375 +		CleanupClosePushL(file);
   1.376 +
   1.377 +		TInt size;
   1.378 +		User::LeaveIfError(file.Size(size));
   1.379 +
   1.380 +		seqnDesc = HBufC8::NewMaxLC(size);
   1.381 +
   1.382 +		TPtr8 bufferDes(seqnDesc->Des());
   1.383 +		User::LeaveIfError(file.Read(bufferDes));
   1.384 +		
   1.385 +		player = CMdaAudioPlayerUtility::NewDesPlayerL(bufferDes, *this);
   1.386 +		}
   1.387 +
   1.388 +	CleanupStack::PushL(player);
   1.389 +
   1.390 +	// Wait for initialisation callback
   1.391 +	INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
   1.392 +	CActiveScheduler::Start();
   1.393 +
   1.394 +
   1.395 +	if(iError == KErrNone)
   1.396 +		{
   1.397 +		TInt maxVol = player->MaxVolume();
   1.398 +		player->SetVolume(maxVol/2);
   1.399 +		TInt gotVol;
   1.400 +		iError = player->GetVolume(gotVol);
   1.401 +
   1.402 +		if((iError != KErrNone) || (maxVol/2 != gotVol))
   1.403 +			{
   1.404 +			ERR_PRINTF1( _L("CMdaAudioPlayerUtility failed volume tests"));
   1.405 +			if(iError == KErrNone)
   1.406 +				iError = KErrGeneral;
   1.407 +			}
   1.408 +		}
   1.409 +
   1.410 +
   1.411 +	if(iError == KErrNone)
   1.412 +		{
   1.413 +		TTimeIntervalMicroSeconds t(0);
   1.414 +		TTimeIntervalMicroSeconds zeroUs(0);
   1.415 +
   1.416 +		t = player->Duration();
   1.417 +
   1.418 +		if(t != zeroUs)
   1.419 +			{
   1.420 +			ERR_PRINTF1( _L("CMdaAudioPlayerUtility failed duration test"));
   1.421 +			iError = KErrGeneral;
   1.422 +			}
   1.423 +
   1.424 +		player->SetPosition(zeroUs);
   1.425 +		iError = player->GetPosition(t);
   1.426 +
   1.427 +		if((t != zeroUs) || (iError != KErrNone))
   1.428 +			{
   1.429 +			ERR_PRINTF1( _L("CMdaAudioPlayerUtility failed duration test"));
   1.430 +			if(iError == KErrNone)
   1.431 +				iError = KErrGeneral;
   1.432 +			}
   1.433 +		}
   1.434 +
   1.435 +	if(iError == KErrNone)
   1.436 +		{
   1.437 +		TInt entries;
   1.438 +		TInt metaErr = KErrNone;
   1.439 +
   1.440 +		metaErr = player->GetNumberOfMetaDataEntries(entries);
   1.441 +
   1.442 +		if(metaErr != KErrNotSupported)
   1.443 +			{
   1.444 +			ERR_PRINTF1( _L("CMdaAudioPlayerUtility failed volume tests"));
   1.445 +			iError = metaErr;
   1.446 +			}
   1.447 +		else
   1.448 +			{
   1.449 +			CMMFMetaDataEntry* metaEntry = NULL;	// EABI warning removal - "metaEntry was set but never used"
   1.450 +
   1.451 +			TRAP(metaErr, metaEntry = player->GetMetaDataEntryL(0));	// EABI warning removal - "metaEntry was set but never used"
   1.452 +
   1.453 +
   1.454 +			if(metaErr != KErrNotSupported)
   1.455 +				{
   1.456 +				ERR_PRINTF1( _L("CMdaAudioPlayerUtility failed volume tests"));
   1.457 +				iError = metaErr;
   1.458 +				if (metaErr==KErrNone)
   1.459 +					{
   1.460 +					delete metaEntry;
   1.461 +					}
   1.462 +				}
   1.463 +			}
   1.464 +		}
   1.465 +	
   1.466 +
   1.467 +
   1.468 +	if(iError == KErrNone)
   1.469 +		{
   1.470 +		player->SetBalance(KMMFBalanceMaxLeft);
   1.471 +		TInt bal = KMMFBalanceCenter;
   1.472 +
   1.473 +		iError = player->GetBalance(bal);
   1.474 +
   1.475 +		if(bal != KMMFBalanceMaxLeft)
   1.476 +			{
   1.477 +			ERR_PRINTF1( _L("CMdaAudioPlayerUtility failed balance tests"));
   1.478 +			if(iError == KErrNone)
   1.479 +				iError = KErrGeneral;
   1.480 +			}
   1.481 +		else
   1.482 +			player->SetBalance(KMMFBalanceCenter);
   1.483 +		}
   1.484 +
   1.485 +
   1.486 +	if(iError == KErrNone)
   1.487 +		{
   1.488 +		TInt priErr = player->SetPriority(EMdaPriorityMin, EMdaPriorityPreferenceNone);
   1.489 +
   1.490 +		if(priErr != KErrNone)
   1.491 +			{
   1.492 +			ERR_PRINTF1( _L("CMdaAudioPlayerUtility failed priority tests"));
   1.493 +			iError = KErrGeneral;
   1.494 +			}
   1.495 +		else
   1.496 +			player->SetPriority(EMdaPriorityNormal, EMdaPriorityPreferenceNone);
   1.497 +		}
   1.498 +
   1.499 +
   1.500 +
   1.501 +
   1.502 +	if(iError == KErrNone)
   1.503 +		{
   1.504 +		iError = KErrTimedOut;
   1.505 +		player->Play();
   1.506 +
   1.507 +		//Stop the player after one second and restart
   1.508 +		CDelayedMethodCall* delayedMethodCall = CDelayedMethodCall::NewL(this);
   1.509 +		CleanupStack::PushL(delayedMethodCall);
   1.510 +		delayedMethodCall->After(KOneSecond);
   1.511 +
   1.512 +		CActiveScheduler::Start();
   1.513 +
   1.514 +		CleanupStack::PopAndDestroy(delayedMethodCall);
   1.515 +
   1.516 +		player->Stop();
   1.517 +
   1.518 +		player->Play();
   1.519 +		CActiveScheduler::Start();
   1.520 +		}
   1.521 +
   1.522 +	
   1.523 +
   1.524 +	CleanupStack::PopAndDestroy(player);
   1.525 +	if(iIsFile == EFalse)
   1.526 +		{
   1.527 +		CleanupStack::PopAndDestroy(seqnDesc);
   1.528 +		CleanupStack::PopAndDestroy(&file);
   1.529 +		}
   1.530 +
   1.531 +	User::After(KOneSecond); // wait for deletion to shut down devsound
   1.532 +	if(iError == KErrNone)
   1.533 +	{
   1.534 +		ret = EPass;
   1.535 +	}
   1.536 +		
   1.537 +	else
   1.538 +		ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with error %d"),iError );
   1.539 +
   1.540 +	return	ret;
   1.541 +	}
   1.542 +
   1.543 +
   1.544 +
   1.545 +
   1.546 +
   1.547 +//------------------------------------------------------------------
   1.548 +
   1.549 +/**
   1.550 + * Constructor
   1.551 + */
   1.552 +CTestMmfAclntDesc::CTestMmfAclntDesc(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, const TBool aPlay, const TInt aExpectedError)
   1.553 +	:iPlay (aPlay),
   1.554 +	iExpectedError(aExpectedError)
   1.555 +
   1.556 +	{
   1.557 +	// store the name of this test case
   1.558 +	// this is the name that is used by the script file
   1.559 +	// Each test step initialises it's own name
   1.560 +	iTestStepName = aTestName;
   1.561 +	iSectName = aSectName;
   1.562 +	iKeyName = aKeyName;
   1.563 +	}
   1.564 +
   1.565 +CTestMmfAclntDesc* CTestMmfAclntDesc::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay, const TInt aExpectedError)
   1.566 +	{
   1.567 +	CTestMmfAclntDesc* self = new (ELeave) CTestMmfAclntDesc(aTestName,aSectName,aKeyName,aPlay,aExpectedError);
   1.568 +	return self;
   1.569 +	}
   1.570 +
   1.571 +CTestMmfAclntDesc* CTestMmfAclntDesc::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay, const TInt aExpectedError = KErrNone)
   1.572 +	{
   1.573 +	CTestMmfAclntDesc* self = CTestMmfAclntDesc::NewLC(aTestName,aSectName,aKeyName,aPlay, aExpectedError);
   1.574 +	CleanupStack::PushL(self);
   1.575 +	return self;
   1.576 +	}
   1.577 +
   1.578 +void CTestMmfAclntDesc::MapcInitComplete(TInt aError, 
   1.579 +								const TTimeIntervalMicroSeconds &aDuration)
   1.580 +	{
   1.581 +	iError = aError;
   1.582 +	iDuration = aDuration;
   1.583 +	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
   1.584 +	CActiveScheduler::Stop();
   1.585 +	}
   1.586 +
   1.587 +void CTestMmfAclntDesc::MapcPlayComplete(TInt aError)
   1.588 +	{
   1.589 +	iError = aError;
   1.590 +	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
   1.591 +	CActiveScheduler::Stop();
   1.592 +	}
   1.593 +
   1.594 +TVerdict  CTestMmfAclntDesc::DoTestStepPreambleL()
   1.595 +	{
   1.596 +	TBuf<KSizeBuf>	filename;
   1.597 +	TPtrC			filename1; 
   1.598 +	
   1.599 +	if(!GetStringFromConfig(iSectName, iKeyName, filename1))
   1.600 +		{
   1.601 +		return EInconclusive;
   1.602 +		}
   1.603 +		
   1.604 +	GetDriveName(filename);
   1.605 +	filename.Append(filename1);
   1.606 +
   1.607 +	RFs fs;
   1.608 +	RFile file;
   1.609 +	TInt size = 0;
   1.610 +    TInt returnCode = 0;
   1.611 +	// connect to file system and open file
   1.612 +	
   1.613 +	CleanupClosePushL(file);
   1.614 +	
   1.615 +    returnCode = fs.Connect();
   1.616 +    if (returnCode != KErrNone)
   1.617 +        {
   1.618 +        ERR_PRINTF2(_L("Failed to connect to file server, error %d"), returnCode);
   1.619 +        fs.Close();
   1.620 +        return EFail;
   1.621 +        }
   1.622 +        
   1.623 +    returnCode = file.Open(fs,filename,EFileRead);
   1.624 +    if (returnCode != KErrNone)
   1.625 +        {
   1.626 +        ERR_PRINTF2(_L("Failed to Open the file, error %d"), returnCode);
   1.627 +        file.Close();
   1.628 +        return EFail;
   1.629 +        }
   1.630 +    
   1.631 +	INFO_PRINTF2( _L("File opened successfully %S"), &filename);
   1.632 +	    
   1.633 +    // Set HBuf size
   1.634 +	User::LeaveIfError(file.Size(size));
   1.635 +	INFO_PRINTF2(_L("size of file = %d\n"),size); //Statement Changed under DEF105143
   1.636 +	iAudio = HBufC8::NewMaxL(size);
   1.637 +	// read data into Hbuf
   1.638 +	TPtr8 bufferDes(iAudio->Des());
   1.639 +	User::LeaveIfError(file.Read(bufferDes));
   1.640 +	
   1.641 +	CleanupStack::PopAndDestroy(); //file
   1.642 +	return CTestMmfAclntStep::DoTestStepPreambleL();
   1.643 +	}
   1.644 +
   1.645 +TVerdict CTestMmfAclntDesc::DoTestStepPostambleL()
   1.646 +	{
   1.647 +	delete iAudio;
   1.648 +	delete iPlayer;
   1.649 +    iPlayer = NULL;
   1.650 +	return CTestMmfAclntStep::DoTestStepPostambleL();
   1.651 +	}
   1.652 +
   1.653 +/**
   1.654 + * Load and initialise an audio descriptor.
   1.655 + */
   1.656 +TVerdict CTestMmfAclntDesc::DoTestStepL( void )
   1.657 +	{
   1.658 +	INFO_PRINTF1( _L("TestPlayerUtils : Desc"));
   1.659 +	TVerdict ret = EFail;
   1.660 +
   1.661 +	iError = KErrTimedOut;
   1.662 +
   1.663 +	TPtr8 bufferDes(iAudio->Des());
   1.664 +    iPlayer = CMdaAudioPlayerUtility::NewDesPlayerL(bufferDes, *this);
   1.665 +	// Wait for init callback
   1.666 +	INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
   1.667 +	CActiveScheduler::Start();
   1.668 +
   1.669 +	if(iError != KErrNone && iError == iExpectedError)
   1.670 +		{
   1.671 +		delete iPlayer;
   1.672 +		iPlayer = NULL;
   1.673 +		ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with expected error %d"),iError );
   1.674 +		return EPass;	
   1.675 +		}
   1.676 +	
   1.677 +	if (iError == KErrNone && iPlayer != NULL)
   1.678 +		{
   1.679 +		if(iPlay)
   1.680 +			{
   1.681 +			iError = KErrTimedOut;
   1.682 +			iPlayer->Play();
   1.683 +			// Wait for init callback
   1.684 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
   1.685 +			CActiveScheduler::Start();
   1.686 +			if(iError == KErrNone)
   1.687 +				{
   1.688 +				ret = EPass;
   1.689 +				}
   1.690 +				
   1.691 +			}
   1.692 +		else
   1.693 +			ret = EPass;			
   1.694 +		}
   1.695 +	
   1.696 +	if(iError != KErrNone)
   1.697 +		ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with error %d"),iError );
   1.698 +	return	ret;
   1.699 +	}
   1.700 +
   1.701 +//------------------------------------------------------------------
   1.702 +
   1.703 +/**
   1.704 + * Load and initialise an audio descriptor - read-only
   1.705 + */
   1.706 +
   1.707 +CTestMmfAclntDescReadOnly::CTestMmfAclntDescReadOnly(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, const TBool aPlay, const TInt aExpectedError)
   1.708 +	:CTestMmfAclntDesc(aTestName, aSectName, aKeyName, aPlay, aExpectedError)
   1.709 +	{
   1.710 +	}
   1.711 +
   1.712 +CTestMmfAclntDescReadOnly* CTestMmfAclntDescReadOnly::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay, const TInt aExpectedError)
   1.713 +	{
   1.714 +	CTestMmfAclntDescReadOnly* self = new (ELeave) CTestMmfAclntDescReadOnly(aTestName,aSectName,aKeyName,aPlay,aExpectedError);
   1.715 +	return self;
   1.716 +	}
   1.717 +
   1.718 +CTestMmfAclntDescReadOnly* CTestMmfAclntDescReadOnly::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay, const TInt aExpectedError = KErrNone)
   1.719 +	{
   1.720 +	CTestMmfAclntDescReadOnly* self = CTestMmfAclntDescReadOnly::NewLC(aTestName,aSectName,aKeyName,aPlay, aExpectedError);
   1.721 +	CleanupStack::PushL(self);
   1.722 +	return self;
   1.723 +	}
   1.724 +
   1.725 +TVerdict CTestMmfAclntDescReadOnly::DoTestStepL( void )
   1.726 +	{
   1.727 +	INFO_PRINTF1( _L("TestPlayerUtils : Desc (Read-Only)"));
   1.728 +	TVerdict ret = EFail;
   1.729 +
   1.730 +	iError = KErrTimedOut;
   1.731 +
   1.732 +	TPtr8 bufferDes(iAudio->Des());
   1.733 +	iPlayer = CMdaAudioPlayerUtility::NewDesPlayerReadOnlyL(bufferDes, *this);
   1.734 +	// Wait for init callback
   1.735 +	INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
   1.736 +	CActiveScheduler::Start();
   1.737 +
   1.738 +	if(iError != KErrNone && iError == iExpectedError)
   1.739 +		{
   1.740 +		delete iPlayer;
   1.741 +		iPlayer = NULL;
   1.742 +		ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with expected error %d"),iError );
   1.743 +		return EPass;	
   1.744 +		}
   1.745 +	
   1.746 +	if (iError == KErrNone && iPlayer != NULL)
   1.747 +		{
   1.748 +		if(iPlay)
   1.749 +			{
   1.750 +			iError = KErrTimedOut;
   1.751 +			iPlayer->Play();
   1.752 +			// Wait for init callback
   1.753 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
   1.754 +			CActiveScheduler::Start();
   1.755 +			if(iError == KErrNone)
   1.756 +				{
   1.757 +				ret = EPass;
   1.758 +				}
   1.759 +			}
   1.760 +		else
   1.761 +			ret = EPass;			
   1.762 +		}
   1.763 +	
   1.764 +	delete iPlayer;
   1.765 +	iPlayer = NULL;
   1.766 +	if(iError != KErrNone)
   1.767 +		{
   1.768 +		ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with error %d"),iError );
   1.769 +		}
   1.770 +		
   1.771 +	return	ret;
   1.772 +	}
   1.773 +
   1.774 +//------------------------------------------------------------------
   1.775 +
   1.776 +/**
   1.777 + * Load and initialise an audio descriptor, using Open only
   1.778 + */
   1.779 +
   1.780 +CTestMmfAclntDescOpen::CTestMmfAclntDescOpen(const TDesC& aTestName,const TDesC& aSectName,const TDesC& aKeyName, const TBool aPlay, const TInt aExpectedError)
   1.781 +	:CTestMmfAclntDesc(aTestName, aSectName, aKeyName, aPlay, aExpectedError)
   1.782 +	{
   1.783 +	}
   1.784 +
   1.785 +CTestMmfAclntDescOpen* CTestMmfAclntDescOpen::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay, const TInt aExpectedError)
   1.786 +	{
   1.787 +	CTestMmfAclntDescOpen* self = new (ELeave) CTestMmfAclntDescOpen(aTestName,aSectName,aKeyName,aPlay,aExpectedError);
   1.788 +	return self;
   1.789 +	}
   1.790 +
   1.791 +CTestMmfAclntDescOpen* CTestMmfAclntDescOpen::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay, const TInt aExpectedError = KErrNone)
   1.792 +	{
   1.793 +	CTestMmfAclntDescOpen* self = CTestMmfAclntDescOpen::NewLC(aTestName,aSectName,aKeyName,aPlay, aExpectedError);
   1.794 +	CleanupStack::PushL(self);
   1.795 +	return self;
   1.796 +	}
   1.797 +
   1.798 +TVerdict CTestMmfAclntDescOpen::DoTestStepL( void )
   1.799 +	{
   1.800 +	INFO_PRINTF1( _L("TestPlayerUtils : Desc (Open)"));
   1.801 +	TVerdict ret = EFail;
   1.802 +
   1.803 +	TPtr8 bufferDes(iAudio->Des());
   1.804 +	TRAPD(err, iPlayer = CMdaAudioPlayerUtility::NewL(*this));
   1.805 +	if(err != KErrNone)
   1.806 +		{
   1.807 +		delete iPlayer;
   1.808 +		iPlayer = NULL;
   1.809 +		ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with expected error %d"),iError );
   1.810 +		return EFail;	
   1.811 +		}
   1.812 +	
   1.813 +	if (err == KErrNone && iPlayer != NULL)
   1.814 +		{
   1.815 +			iError = KErrTimedOut;
   1.816 +			TRAP_IGNORE(iPlayer->OpenDesL(bufferDes));
   1.817 +			// Wait for init callback
   1.818 +			INFO_PRINTF1( _L("OpenDesL CMdaAudioPlayerUtility"));
   1.819 +			CActiveScheduler::Start();
   1.820 +			if(iError == KErrNone)
   1.821 +				{
   1.822 +				ret = EPass;
   1.823 +				}
   1.824 +		}
   1.825 +	
   1.826 +	delete iPlayer;
   1.827 +	iPlayer = NULL;
   1.828 +	if(iError != KErrNone)
   1.829 +		{
   1.830 +		ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with error %d"),iError );
   1.831 +		}
   1.832 +		
   1.833 +	return	ret;
   1.834 +	}
   1.835 +
   1.836 +//------------------------------------------------------------------
   1.837 +
   1.838 +/**
   1.839 + * Constructor
   1.840 + */
   1.841 +CTestMmfAclntUrl::CTestMmfAclntUrl(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
   1.842 +	:iPlay (aPlay)
   1.843 +	{
   1.844 +	// store the name of this test case
   1.845 +	// this is the name that is used by the script file
   1.846 +	// Each test step initialises it's own name
   1.847 +	iTestStepName = aTestName;
   1.848 +	iSectName = aSectName;
   1.849 +	iKeyName = aKeyName;
   1.850 +	}
   1.851 +
   1.852 +CTestMmfAclntUrl* CTestMmfAclntUrl::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
   1.853 +	{
   1.854 +	CTestMmfAclntUrl* self = new (ELeave) CTestMmfAclntUrl(aTestName,aSectName,aKeyName,aPlay);
   1.855 +	return self;
   1.856 +	}
   1.857 +
   1.858 +CTestMmfAclntUrl* CTestMmfAclntUrl::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TBool aPlay)
   1.859 +	{
   1.860 +	CTestMmfAclntUrl* self = CTestMmfAclntUrl::NewLC(aTestName,aSectName,aKeyName,aPlay);
   1.861 +	CleanupStack::PushL(self);
   1.862 +	return self;
   1.863 +	}
   1.864 +
   1.865 +void CTestMmfAclntUrl::MapcInitComplete(TInt aError, 
   1.866 +								const TTimeIntervalMicroSeconds &aDuration)
   1.867 +	{
   1.868 +	iError = aError;
   1.869 +	iDuration = aDuration;
   1.870 +	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
   1.871 +	CActiveScheduler::Stop();
   1.872 +	}
   1.873 +
   1.874 +void CTestMmfAclntUrl::MapcPlayComplete(TInt aError)
   1.875 +	{
   1.876 +	iError = aError;
   1.877 +	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
   1.878 +	CActiveScheduler::Stop();
   1.879 +	}
   1.880 +
   1.881 +/**
   1.882 + * Open audio from a URL and play.
   1.883 + */
   1.884 +TVerdict CTestMmfAclntUrl::DoTestStepL()
   1.885 +	{
   1.886 +	INFO_PRINTF1( _L("TestPlayerUtils : URL"));
   1.887 +	TVerdict ret = EFail;
   1.888 +
   1.889 +	iError = KErrTimedOut;	
   1.890 +
   1.891 +	TPtrC urlname;
   1.892 +	if(!GetStringFromConfig(iSectName,iKeyName,urlname))
   1.893 +		{
   1.894 +		return EInconclusive;
   1.895 +		}
   1.896 +		
   1.897 +
   1.898 + 	CMdaAudioPlayerUtility* player = CMdaAudioPlayerUtility::NewL(*this);
   1.899 +	CleanupStack::PushL(player);
   1.900 +
   1.901 +	TRAPD(err, player->OpenUrlL(urlname));
   1.902 +	if(err)
   1.903 +		{
   1.904 +		if(err != KErrNotSupported)
   1.905 +			{
   1.906 +			ERR_PRINTF2( _L("OpenUrlL left with error %d"), err);
   1.907 +			CleanupStack::PopAndDestroy(player);
   1.908 +			return EFail;
   1.909 +			}
   1.910 +		else
   1.911 +			{
   1.912 +			INFO_PRINTF2( _L("OpenUrlL left with expected error %d"), err);
   1.913 +			CleanupStack::PopAndDestroy(player);
   1.914 +			return EPass;
   1.915 +			}
   1.916 +		}
   1.917 +	
   1.918 +	INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
   1.919 +	CActiveScheduler::Start();
   1.920 +
   1.921 +	if (iError == KErrNotSupported)
   1.922 +		{
   1.923 +		ret = EPass;
   1.924 +		}
   1.925 +		
   1.926 +
   1.927 +	CleanupStack::PopAndDestroy(player);
   1.928 +	if(iError != KErrNone)
   1.929 +		{
   1.930 +		ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with error %d"),iError );
   1.931 +		}
   1.932 +		
   1.933 +	return	ret;
   1.934 +	}
   1.935 +
   1.936 +//------------------------------------------------------------------
   1.937 +
   1.938 +/**
   1.939 + * Constructor
   1.940 + */
   1.941 +CTestMmfAclntAudioPlayerUtil::CTestMmfAclntAudioPlayerUtil(const TDesC& aTestName, const TDesC& aSectName)
   1.942 +	{
   1.943 +	// store the name of this test case
   1.944 +	// this is the name that is used by the script file
   1.945 +	// Each test step initialises it's own name
   1.946 +	iTestStepName=aTestName;
   1.947 +	iStop = ETrue;
   1.948 +	iSectName = aSectName;
   1.949 +	}
   1.950 +
   1.951 +
   1.952 +void CTestMmfAclntAudioPlayerUtil::MapcInitComplete(TInt aError, 
   1.953 +								const TTimeIntervalMicroSeconds &aDuration)
   1.954 +	{
   1.955 +	iError = aError;
   1.956 +	iDuration = aDuration;
   1.957 +	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
   1.958 +	CActiveScheduler::Stop();
   1.959 +	
   1.960 +	}
   1.961 +
   1.962 +void CTestMmfAclntAudioPlayerUtil::MapcPlayComplete(TInt aError)
   1.963 +	{
   1.964 +	iError = aError;
   1.965 +	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
   1.966 +	if(iStop)
   1.967 +		{
   1.968 +		CActiveScheduler::Stop();	
   1.969 +		}
   1.970 +	}
   1.971 +
   1.972 +
   1.973 +
   1.974 +/**
   1.975 + * Pause play and continue play.
   1.976 + */
   1.977 +TVerdict CTestMmfAclntAudioPlayerUtil::DoTestStepL( void )
   1.978 +	{
   1.979 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Player Util"));
   1.980 +
   1.981 +	TVerdict ret = EFail;
   1.982 +	iError = KErrTimedOut;
   1.983 +
   1.984 +	TBuf<KSizeBuf>	filename;
   1.985 +	TPtrC			filename1; 
   1.986 +	if(!GetStringFromConfig(iSectName, _L("playerAudioFile"), filename1))
   1.987 +		{
   1.988 +		return EInconclusive;
   1.989 +		}
   1.990 +	
   1.991 +	GetDriveName(filename);
   1.992 +	filename.Append(filename1);
   1.993 +	INFO_PRINTF2(_L("CMdaAudioPlayerUtility::NewFilePlayerL() - %S"), &filename);
   1.994 +	CMdaAudioPlayerUtility* player = CMdaAudioPlayerUtility::NewFilePlayerL(filename,*this);
   1.995 +	CleanupStack::PushL(player);
   1.996 +	// wait for initilisation callback
   1.997 +	INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
   1.998 +	CActiveScheduler::Start();
   1.999 +
  1.1000 +	// Attempt to wait out the in use error message!!!
  1.1001 +	// It may just be that we have the file locked.
  1.1002 +	if(iError == KErrInUse)
  1.1003 +		{
  1.1004 +		if(!GetStringFromConfig(iSectName, _L("playerAudioFile2"), filename1))
  1.1005 +		{
  1.1006 +			return EInconclusive;	
  1.1007 +		}
  1.1008 +			
  1.1009 +		GetDriveName(filename);
  1.1010 +		filename.Append(filename1);
  1.1011 +		User::After(KTwoSeconds);
  1.1012 +		CleanupStack::PopAndDestroy(player);
  1.1013 +		User::After(KTwoSeconds);
  1.1014 +		INFO_PRINTF2(_L("CMdaAudioPlayerUtility::NewFilePlayerL() - %S"), &filename);
  1.1015 +		player = CMdaAudioPlayerUtility::NewFilePlayerL(filename,*this);
  1.1016 +		CleanupStack::PushL(player);
  1.1017 +		// wait for initilisation callback
  1.1018 +		INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
  1.1019 +		CActiveScheduler::Start();
  1.1020 +		}
  1.1021 +
  1.1022 +	if (iError == KErrNone)
  1.1023 +		{
  1.1024 +		// no errors so far, Do Test!
  1.1025 +		ret = DoTestL(player);
  1.1026 +		}
  1.1027 +
  1.1028 +	CleanupStack::PopAndDestroy(player);
  1.1029 +	User::After(KOneSecond);
  1.1030 +	if (iError != KErrNone)
  1.1031 +		{
  1.1032 +		ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with error %d"),iError );	
  1.1033 +		}
  1.1034 +	
  1.1035 +	return	ret;
  1.1036 +	}
  1.1037 +//=======================================================================================
  1.1038 +/**
  1.1039 + * Constructor
  1.1040 + */
  1.1041 +CAsyncTestMmfAclntAudioPlayerUtil::CAsyncTestMmfAclntAudioPlayerUtil ( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.1042 +	{
  1.1043 +	// store the name of this test case
  1.1044 +	// this is the name that is used by the script file
  1.1045 +	// Each test step initialises it's own name
  1.1046 +	iTestStepName=aTestName;
  1.1047 +	iSectName = aSectName;
  1.1048 +	iKeyName = aKeyName;
  1.1049 +	}
  1.1050 +
  1.1051 +
  1.1052 +void CAsyncTestMmfAclntAudioPlayerUtil::MapcInitComplete(TInt aError, 
  1.1053 +								const TTimeIntervalMicroSeconds &aDuration)
  1.1054 +	{
  1.1055 +	iError = aError;
  1.1056 +	iClipDuration = aDuration;
  1.1057 +	if (aError != KErrNone)
  1.1058 +		{
  1.1059 +		ERR_PRINTF2(_L("*MapcInitComplete* Error: %d."), aError);
  1.1060 +		StopTest(aError, EFail);
  1.1061 +		}
  1.1062 +	else
  1.1063 +		{
  1.1064 +		INFO_PRINTF2(_L("*MapcInitComplete* Error: %d."), aError);
  1.1065 +		iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.1066 +		iTrigger->StartTimer(500000); 
  1.1067 +		iTestState = EStateOpened;
  1.1068 +		iPlayerState = EOpened;	
  1.1069 +		}	
  1.1070 +	}
  1.1071 +
  1.1072 +void CAsyncTestMmfAclntAudioPlayerUtil::MapcPlayComplete(TInt aError)
  1.1073 +	{
  1.1074 +	if(aError == KErrNone)
  1.1075 +		{
  1.1076 +		INFO_PRINTF2(_L("*MapcPlayComplete* Error: %d."), iError);
  1.1077 +		iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.1078 +		iTrigger->StartTimer(500000); 
  1.1079 +		iTestState = EStateStopTest;
  1.1080 +		}
  1.1081 +	else
  1.1082 +		{
  1.1083 +		ERR_PRINTF2(_L("*MapcPlayComplete* Error: %d."), aError);
  1.1084 +		StopTest(aError, EFail);
  1.1085 +		}
  1.1086 +	}
  1.1087 +	
  1.1088 +/**
  1.1089 + * 
  1.1090 + */
  1.1091 +void CAsyncTestMmfAclntAudioPlayerUtil::KickoffTestL( void )
  1.1092 +	{
  1.1093 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Player Util"));
  1.1094 +	TPtrC			filename1; 
  1.1095 +	TInt			repeatCount;
  1.1096 +	TInt			silence;
  1.1097 +	if(!GetStringFromConfig(iSectName, iKeyName, filename1))
  1.1098 +		{
  1.1099 +		INFO_PRINTF1(_L("GetStringFromConfig Failed"));
  1.1100 +		StopTest(KErrGeneral, EInconclusive);
  1.1101 +		return;
  1.1102 +		}
  1.1103 +		
  1.1104 +	if(!GetIntFromConfig(_L("SectionRepeatCount"), _L("numOfRepeat"), repeatCount))
  1.1105 +		{
  1.1106 +		INFO_PRINTF1(_L("GetIntFromConfig Failed"));
  1.1107 +		StopTest(KErrGeneral, EInconclusive);
  1.1108 +		return;
  1.1109 +		}
  1.1110 +	if(!GetIntFromConfig(_L("SectionSilence"), _L("silence"), silence))
  1.1111 +		{
  1.1112 +		INFO_PRINTF1(_L("GetIntFromConfig Failed"));
  1.1113 +		StopTest(KErrGeneral, EInconclusive);
  1.1114 +		return;
  1.1115 +		}	
  1.1116 +	iNumOfRepeatsSet = 	repeatCount;
  1.1117 +	iSilence = silence;
  1.1118 +	
  1.1119 +	GetDriveName(iFileName);
  1.1120 +	iFileName.Append(filename1);
  1.1121 +	INFO_PRINTF2(_L("CMdaAudioPlayerUtility::NewFilePlayerL() - %S"), &iFileName);
  1.1122 +	iTrigger = CFsmTrigger::NewL(*this);
  1.1123 +	iPlayer = CMdaAudioPlayerUtility::NewFilePlayerL(iFileName,*this);
  1.1124 +	iPlayerState = EOpening;
  1.1125 +	}
  1.1126 +
  1.1127 +/**
  1.1128 + * Time comparison utility function
  1.1129 + *
  1.1130 + * @param	"const TUint aActual"
  1.1131 + *			The actual timer value produced
  1.1132 + * @param	"const TUint aExpected"
  1.1133 + *			Expected timer value
  1.1134 + * @param	"const TUint aDeviation"
  1.1135 + *			Allowed deviation of the expected value
  1.1136 + *			from the actual value.
  1.1137 + * @return	"TBool"
  1.1138 + *			Did actual timed value fall within deviation limits
  1.1139 + */ 
  1.1140 +TBool CAsyncTestMmfAclntAudioPlayerUtil::TimeComparison(const TUint aActual, const TUint aExpected, const TUint aDeviation)
  1.1141 +	{
  1.1142 +	// save unnessary conditions
  1.1143 +	if(aActual == aExpected)
  1.1144 +		return ETrue;	
  1.1145 +
  1.1146 +	// Prevent unsigned wrapping errors 
  1.1147 +	TUint difference;
  1.1148 +	if(aActual > aExpected)
  1.1149 +		difference = aActual - aExpected;
  1.1150 +	else
  1.1151 +		difference = aExpected - aActual;
  1.1152 +
  1.1153 +	// comapare
  1.1154 +	if(difference < aDeviation)
  1.1155 +		return ETrue;
  1.1156 +	return EFalse;
  1.1157 +	}
  1.1158 +	
  1.1159 +void CAsyncTestMmfAclntAudioPlayerUtil::CloseTest()
  1.1160 +	{
  1.1161 +	if (iTrigger)
  1.1162 +		{
  1.1163 +		iTrigger->Cancel();
  1.1164 +		delete iTrigger;
  1.1165 +		}
  1.1166 +	
  1.1167 +	if (iPlayer)
  1.1168 +		{
  1.1169 +		delete iPlayer;
  1.1170 +		}
  1.1171 +	}
  1.1172 +//
  1.1173 +/**
  1.1174 + * Implementation of AO timer used to invoke test processing at desired intervals (i.e. State Machine)
  1.1175 + **/
  1.1176 +
  1.1177 +CFsmTrigger* CFsmTrigger::NewL(CAsyncTestMmfAclntAudioPlayerUtil& aObserver)
  1.1178 +	{
  1.1179 +	CFsmTrigger* self = new (ELeave) CFsmTrigger(aObserver);	
  1.1180 +	CleanupStack::PushL(self);
  1.1181 +	self->ConstructL();
  1.1182 +	CleanupStack::Pop(self);	
  1.1183 +	return self;
  1.1184 +	}
  1.1185 +
  1.1186 +CFsmTrigger::CFsmTrigger(CAsyncTestMmfAclntAudioPlayerUtil& aObserver)
  1.1187 +:	CActive(CActive::EPriorityStandard),
  1.1188 +	iObserver (aObserver)
  1.1189 +	{
  1.1190 +	// nothing to do
  1.1191 +	}
  1.1192 +
  1.1193 +void CFsmTrigger::ConstructL()
  1.1194 +	{
  1.1195 +	User::LeaveIfError (iTimer.CreateLocal());
  1.1196 +	CActiveScheduler::Add (this);
  1.1197 +	}
  1.1198 +	
  1.1199 +CFsmTrigger::~CFsmTrigger()
  1.1200 +	{
  1.1201 +	Cancel();
  1.1202 +	iTimer.Close();
  1.1203 +	}
  1.1204 +	
  1.1205 +void CFsmTrigger::RunL()
  1.1206 +	{
  1.1207 +	// need to call Fsm
  1.1208 +	iObserver.FsmL();
  1.1209 +	}
  1.1210 +
  1.1211 +void CFsmTrigger::DoCancel()
  1.1212 +	{
  1.1213 +	iTimer.Cancel();
  1.1214 +	}
  1.1215 +
  1.1216 +void CFsmTrigger::StartTimer(TTimeIntervalMicroSeconds32 aDelay)
  1.1217 +	{
  1.1218 +	__ASSERT_ALWAYS(!IsActive(), User::Panic(_L("CFsmTrigger"), 1));
  1.1219 +	iTimer.After(iStatus, aDelay);
  1.1220 +	SetActive();
  1.1221 +	}
  1.1222 +
  1.1223 +//============================================================================================================
  1.1224 +//------------------------------------------------------------------
  1.1225 +
  1.1226 +CTestMmfAclntAudioPlayStopStart::CTestMmfAclntAudioPlayStopStart(const TDesC& aTestName, const TDesC& aSectName)
  1.1227 +	: CTestMmfAclntAudioPlayerUtil(aTestName, aSectName)
  1.1228 +	{}
  1.1229 +
  1.1230 +CTestMmfAclntAudioPlayStopStart* CTestMmfAclntAudioPlayStopStart::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1.1231 +	{
  1.1232 +	CTestMmfAclntAudioPlayStopStart* self = new (ELeave) CTestMmfAclntAudioPlayStopStart(aTestName, aSectName);
  1.1233 +	return self;
  1.1234 +	}
  1.1235 +
  1.1236 +TVerdict CTestMmfAclntAudioPlayStopStart::DoTestL(CMdaAudioPlayerUtility* aPlayer)
  1.1237 +	{
  1.1238 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Play Stop/Start"));
  1.1239 +	TVerdict ret = EFail;
  1.1240 +
  1.1241 +	TInt duration = I64INT(aPlayer->Duration().Int64());
  1.1242 +
  1.1243 +	// Tests pause functionality
  1.1244 +	aPlayer->Play();
  1.1245 +	INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.1246 +	User::After(KTwoSeconds);
  1.1247 +	INFO_PRINTF1( _L("Stop CMdaAudioPlayerUtility"));
  1.1248 +	aPlayer->Stop();
  1.1249 +
  1.1250 +	
  1.1251 +	User::After(KTwoSeconds);
  1.1252 +	// only wait for second call to play.
  1.1253 +	iError = KErrTimedOut;
  1.1254 +	INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.1255 +	aPlayer->Play();
  1.1256 +
  1.1257 +	TTime start;
  1.1258 +	start.HomeTime();
  1.1259 +	CActiveScheduler::Start();
  1.1260 +	TTime stop;
  1.1261 +	stop.HomeTime();
  1.1262 +
  1.1263 +	TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
  1.1264 +
  1.1265 +
  1.1266 +	INFO_PRINTF6(_L("Error : %d Start = %d Stop = %d Duration = %d ActualDuration = %d"),
  1.1267 +		iError, I64INT(start.Int64()), I64INT(stop.Int64()), 
  1.1268 +		duration, actualDuration);
  1.1269 +	if((iError == KErrNone) && 
  1.1270 +		(TimeComparison(actualDuration, duration , KExpectedDeviation)))
  1.1271 +		{
  1.1272 +		ret = EPass;
  1.1273 +		}
  1.1274 +	
  1.1275 +	return ret;
  1.1276 +	}
  1.1277 +
  1.1278 +//------------------------------------------------------------------
  1.1279 +
  1.1280 +// same as above, but with Pause instead of Stop
  1.1281 +CTestMmfAclntAudioPlayPauseStart::CTestMmfAclntAudioPlayPauseStart(const TDesC& aTestName, const TDesC& aSectName)
  1.1282 +	: CTestMmfAclntAudioPlayerUtil(aTestName, aSectName)
  1.1283 +	{}
  1.1284 +
  1.1285 +CTestMmfAclntAudioPlayPauseStart* CTestMmfAclntAudioPlayPauseStart::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1.1286 +	{
  1.1287 +	CTestMmfAclntAudioPlayPauseStart* self = new (ELeave) CTestMmfAclntAudioPlayPauseStart(aTestName, aSectName);
  1.1288 +	return self;
  1.1289 +	}
  1.1290 +
  1.1291 +TVerdict CTestMmfAclntAudioPlayPauseStart::DoTestL(CMdaAudioPlayerUtility* aPlayer)
  1.1292 +	{
  1.1293 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Play Pause/Start"));
  1.1294 +	TVerdict ret = EFail;
  1.1295 +
  1.1296 +	TInt duration = I64INT(aPlayer->Duration().Int64());
  1.1297 +
  1.1298 +	// Tests pause functionality
  1.1299 +	// NB we must take the duration from the time at PAUSE, as pause (unlike stop)
  1.1300 +	// does not reset the clip to start
  1.1301 +	INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.1302 +	aPlayer->Play();
  1.1303 +	TTime start;
  1.1304 +	start.HomeTime();
  1.1305 +	User::After(KTwoSeconds);
  1.1306 +	INFO_PRINTF1( _L("Pause CMdaAudioPlayerUtility"));
  1.1307 +    INFO_PRINTF1(_L("Pause()"));//Statement Changed under DEF105143
  1.1308 +	aPlayer->Pause();
  1.1309 +	TTime stop;
  1.1310 +	stop.HomeTime();
  1.1311 +	TUint beforeDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
  1.1312 +	User::After(KTwoSeconds);
  1.1313 +	
  1.1314 +	// wait for second call to play.
  1.1315 +	iError = KErrTimedOut;
  1.1316 +	INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.1317 +	INFO_PRINTF1(_L("Play()"));//Statement Changed under DEF105143
  1.1318 +	aPlayer->Play();
  1.1319 +	start.HomeTime();
  1.1320 +	CActiveScheduler::Start();
  1.1321 +	stop.HomeTime();
  1.1322 +
  1.1323 +	TUint afterDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
  1.1324 +
  1.1325 +
  1.1326 +	INFO_PRINTF7(_L("Error : %d Start = %u Stop = %u Duration = %u ActualDuration = %u + %u"),
  1.1327 +		iError, I64INT(start.Int64()), I64INT(stop.Int64()), 
  1.1328 +		duration, beforeDuration, afterDuration);
  1.1329 +	if((iError == KErrNone) && 
  1.1330 +		(TimeComparison(beforeDuration+afterDuration, duration, KExpectedDeviation*2)))
  1.1331 +		{
  1.1332 +		ret = EPass;
  1.1333 +		}
  1.1334 +	
  1.1335 +	return ret;
  1.1336 +	}
  1.1337 +
  1.1338 +//------------------------------------------------------------------
  1.1339 +
  1.1340 +// Play, pause, play
  1.1341 +CTestMmfAclntAudioPlayPausePlayTest::CTestMmfAclntAudioPlayPausePlayTest(const TDesC& aTestName, const TDesC& aSectName)
  1.1342 +	: CTestMmfAclntAudioPlayerUtil(aTestName, aSectName)
  1.1343 +	{}
  1.1344 +
  1.1345 +CTestMmfAclntAudioPlayPausePlayTest* CTestMmfAclntAudioPlayPausePlayTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1.1346 +	{
  1.1347 +	CTestMmfAclntAudioPlayPausePlayTest* self = new (ELeave) CTestMmfAclntAudioPlayPausePlayTest(aTestName, aSectName);
  1.1348 +	return self;
  1.1349 +	}
  1.1350 +
  1.1351 +TVerdict CTestMmfAclntAudioPlayPausePlayTest::DoTestL(CMdaAudioPlayerUtility* aPlayer)
  1.1352 +	{
  1.1353 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Play-Pause-Play"));
  1.1354 +	TVerdict ret = EFail;
  1.1355 +
  1.1356 +	// Play #1
  1.1357 +	INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.1358 +	aPlayer->Play();
  1.1359 +	User::After(KTwoSeconds);
  1.1360 +
  1.1361 +	// Pause #1
  1.1362 +	INFO_PRINTF1( _L("Pause CMdaAudioPlayerUtility"));
  1.1363 +	aPlayer->Pause();
  1.1364 +	User::After(KTwoSeconds);
  1.1365 +
  1.1366 +	// Play #2
  1.1367 +	iError = KErrTimedOut;
  1.1368 +	INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.1369 +	aPlayer->Play();
  1.1370 +	User::After(KOneSecond);
  1.1371 +
  1.1372 +	// Pause #2
  1.1373 +	INFO_PRINTF1( _L("Pause CMdaAudioPlayerUtility"));
  1.1374 +	aPlayer->Pause();
  1.1375 +	User::After(KOneSecond);
  1.1376 +
  1.1377 +	// Play #3
  1.1378 +	iError = KErrTimedOut;
  1.1379 +	INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.1380 +	aPlayer->Play();
  1.1381 +	User::After(KOneSecond);
  1.1382 +
  1.1383 +	// Pause #3
  1.1384 +	INFO_PRINTF1( _L("Pause CMdaAudioPlayerUtility"));
  1.1385 +	aPlayer->Pause();
  1.1386 +	User::After(400000);
  1.1387 +
  1.1388 +	// Play #4
  1.1389 +	iError = KErrTimedOut;
  1.1390 +	INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.1391 +	aPlayer->Play();
  1.1392 +	CActiveScheduler::Start();		// play to end
  1.1393 +
  1.1394 +	if (iError == KErrNone)
  1.1395 +		{
  1.1396 +		ret = EPass;
  1.1397 +		}
  1.1398 +	
  1.1399 +	return ret;
  1.1400 +	}
  1.1401 +
  1.1402 +//------------------------------------------------------------------
  1.1403 +
  1.1404 +CTestMmfAclntAudioPlayVolume::CTestMmfAclntAudioPlayVolume(const TDesC& aTestName, const TDesC& aSectName, const TInt aVolume,TBool aNegativeTest)
  1.1405 +	: CTestMmfAclntAudioPlayerUtil(aTestName, aSectName), iVolume(aVolume) , iNegativeTest(aNegativeTest)
  1.1406 +	{}
  1.1407 +
  1.1408 +CTestMmfAclntAudioPlayVolume* CTestMmfAclntAudioPlayVolume::NewL(const TDesC& aTestName, const TDesC& aSectName, const TInt aVolume,TBool aNegativeTest)
  1.1409 +	{
  1.1410 +	CTestMmfAclntAudioPlayVolume* self = new (ELeave) CTestMmfAclntAudioPlayVolume(aTestName, aSectName, aVolume, aNegativeTest);
  1.1411 +	return self;
  1.1412 +	}
  1.1413 +
  1.1414 +
  1.1415 +TVerdict CTestMmfAclntAudioPlayVolume::DoTestL(CMdaAudioPlayerUtility* aPlayer)
  1.1416 +	{
  1.1417 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Play Volume"));
  1.1418 +	TVerdict ret = EFail;
  1.1419 +
  1.1420 +
  1.1421 +	// Check maxvolume function
  1.1422 +	if(iVolume == -1)
  1.1423 +		{
  1.1424 +		INFO_PRINTF1( _L("Volume CHK 1"));
  1.1425 +		iVolume = aPlayer->MaxVolume();
  1.1426 +		INFO_PRINTF2( _L("Volume: Max Volume = %d"),iVolume);
  1.1427 +		
  1.1428 +		//on device & emulator KMaxVolume have different values
  1.1429 +		//if(iVolume != KMaxVolume) // XXX: how to cross ref. this appears to be random values at the moment 
  1.1430 +		//	{
  1.1431 +		//	INFO_PRINTF3( _L("Expected volume: %d, received volume : %d"), 
  1.1432 +		//		KMaxVolume, iVolume);
  1.1433 +			
  1.1434 +		//	return EFail;
  1.1435 +		//	}
  1.1436 +		}
  1.1437 +	// Volume is truncated to maxvolume
  1.1438 +	if(iVolume > aPlayer->MaxVolume())
  1.1439 +		{
  1.1440 +		INFO_PRINTF1( _L("Volume CHK 2"));
  1.1441 +		TInt volume;
  1.1442 +		INFO_PRINTF2( _L("Volume: SetVolume(%d)"),iVolume);
  1.1443 +		aPlayer->SetVolume(iVolume);
  1.1444 +		aPlayer->GetVolume(volume);
  1.1445 +		INFO_PRINTF2( _L("Volume: GetVolume() returned"),volume);
  1.1446 +		if(volume == aPlayer->MaxVolume())
  1.1447 +			{
  1.1448 +			ret = EPass;
  1.1449 +			}
  1.1450 +			
  1.1451 +		}
  1.1452 +	// Volume is truncated to 0
  1.1453 +	else if(iVolume < 0)
  1.1454 +		{
  1.1455 +		INFO_PRINTF1( _L("Volume CHK 3"));
  1.1456 +		TInt volume;
  1.1457 +		INFO_PRINTF2( _L("Volume: SetVolume(%d)"),iVolume);
  1.1458 +		aPlayer->SetVolume(iVolume);
  1.1459 +		aPlayer->GetVolume(volume);
  1.1460 +		INFO_PRINTF2( _L("Volume: GetVolume() returned"),volume);
  1.1461 +		if(volume == 0)
  1.1462 +			{
  1.1463 +			ret = EPass;
  1.1464 +			}
  1.1465 +			
  1.1466 +		}
  1.1467 +	// Set volume and check
  1.1468 +	else
  1.1469 +		{
  1.1470 +		INFO_PRINTF1( _L("Volume CHK 4"));
  1.1471 +		INFO_PRINTF2( _L("Volume: SetVolume(%d)"),iVolume);
  1.1472 +		TInt volume;
  1.1473 +		aPlayer->SetVolume(iVolume);
  1.1474 +		aPlayer->GetVolume(volume);
  1.1475 +		INFO_PRINTF2( _L("Volume: GetVolume() returned"),volume);
  1.1476 +		if(volume == iVolume)
  1.1477 +			{
  1.1478 +			ret = EPass;
  1.1479 +			}
  1.1480 +			
  1.1481 +		else
  1.1482 +			INFO_PRINTF3( _L("Expected volume: %d, received volume : %d"), iVolume, volume);
  1.1483 +
  1.1484 +		}
  1.1485 +
  1.1486 +	return ret;
  1.1487 +	}
  1.1488 +
  1.1489 +//------------------------------------------------------------------
  1.1490 +
  1.1491 +CTestMmfAclntAudioRepeat::CTestMmfAclntAudioRepeat(const TDesC& aTestName, const TDesC& aSectName)
  1.1492 +	: CTestMmfAclntAudioPlayerUtil(aTestName, aSectName)
  1.1493 +	{}
  1.1494 +
  1.1495 +CTestMmfAclntAudioRepeat* CTestMmfAclntAudioRepeat::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1.1496 +	{
  1.1497 +	CTestMmfAclntAudioRepeat* self = new (ELeave) CTestMmfAclntAudioRepeat(aTestName, aSectName);
  1.1498 +	return self;
  1.1499 +	}
  1.1500 +
  1.1501 +TVerdict CTestMmfAclntAudioRepeat::DoTestL(CMdaAudioPlayerUtility* aPlayer)
  1.1502 +	{
  1.1503 +	INFO_PRINTF1( _L("TestPlayerUtils : Repeats"));
  1.1504 +
  1.1505 +	TVerdict ret = EFail;
  1.1506 +	TTimeIntervalMicroSeconds silence(0); // silence gap
  1.1507 +	TInt duration = I64INT(aPlayer->Duration().Int64());
  1.1508 +
  1.1509 +	aPlayer->SetRepeats(NUMBER_OF_REPEATS,silence);
  1.1510 +
  1.1511 +	iError = KErrTimedOut;
  1.1512 +	INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.1513 +	aPlayer->Play();
  1.1514 +
  1.1515 +	TTime start;
  1.1516 +	start.HomeTime();
  1.1517 +	CActiveScheduler::Start();
  1.1518 +	TTime stop;
  1.1519 +	stop.HomeTime();
  1.1520 +
  1.1521 +	TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
  1.1522 +
  1.1523 +	INFO_PRINTF2( _L("Repeats : %d"), NUMBER_OF_REPEATS);
  1.1524 +	INFO_PRINTF6(_L("Error : %d Start = %d Stop = %d Duration = %d ActualDuration = %d"),
  1.1525 +		iError, I64INT(start.Int64()), I64INT(stop.Int64()), duration, actualDuration);
  1.1526 +	if((iError == KErrNone) && (TimeComparison(actualDuration, duration * (NUMBER_OF_REPEATS + 1),
  1.1527 +											   KExpectedDeviation * NUMBER_OF_REPEATS)))
  1.1528 +		{
  1.1529 +		ret = EPass;
  1.1530 +		}
  1.1531 +		
  1.1532 +	return ret;
  1.1533 +	}
  1.1534 +
  1.1535 +//-------------------------------------------------
  1.1536 +
  1.1537 +CTestMmfAclntAudioBalance::CTestMmfAclntAudioBalance(const TDesC& aTestName, const TDesC& aSectName,const TInt aValue, const TInt aExpectedError)
  1.1538 +	: CTestMmfAclntAudioPlayerUtil(aTestName,aSectName), iBalance(aValue),
  1.1539 +	iExpectedError(aExpectedError)
  1.1540 +	{}
  1.1541 +
  1.1542 +CTestMmfAclntAudioBalance* CTestMmfAclntAudioBalance::NewL(const TDesC& aTestName, const TDesC& aSectName,const TInt aValue, const TInt aExpectedError)
  1.1543 +	{
  1.1544 +	CTestMmfAclntAudioBalance* self = new (ELeave) CTestMmfAclntAudioBalance(aTestName,aSectName,aValue, aExpectedError);
  1.1545 +	return self;
  1.1546 +	}
  1.1547 +
  1.1548 +TVerdict CTestMmfAclntAudioBalance::DoTestL(CMdaAudioPlayerUtility* aPlayer)
  1.1549 +	{
  1.1550 +	TVerdict verdict = EFail;
  1.1551 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Balance"));
  1.1552 +	TInt	theErr = KErrNone;
  1.1553 +	if (iBalance < KMinBalance)
  1.1554 +		{
  1.1555 +		theErr = aPlayer->SetBalance(iBalance);
  1.1556 +		if(theErr != KErrNone)
  1.1557 +			{
  1.1558 +			return EFail;
  1.1559 +			}
  1.1560 +			
  1.1561 +		theErr = aPlayer->GetBalance(iBalance);
  1.1562 +		if(theErr != iExpectedError)
  1.1563 +			{
  1.1564 +			return EFail;	
  1.1565 +			}
  1.1566 +	
  1.1567 +		INFO_PRINTF2( _L("Test finished with expectable error: %d"), iExpectedError);
  1.1568 +		return EPass;
  1.1569 +		}
  1.1570 +	else if (iBalance > KMaxBalance)
  1.1571 +		{
  1.1572 +		theErr = aPlayer->SetBalance(iBalance);		
  1.1573 +		if(theErr != KErrNone)
  1.1574 +			{
  1.1575 +			return EFail;
  1.1576 +			}
  1.1577 +			
  1.1578 +		theErr = aPlayer->GetBalance(iBalance);
  1.1579 +		if(theErr != iExpectedError)
  1.1580 +			{
  1.1581 +			return EFail;	
  1.1582 +			}
  1.1583 +		
  1.1584 +
  1.1585 +		INFO_PRINTF2( _L("Test finished with expectable error: %d"), iExpectedError);
  1.1586 +		return EPass;
  1.1587 +		}
  1.1588 +	else 
  1.1589 +		{
  1.1590 +		theErr = aPlayer->SetBalance(iBalance);		
  1.1591 +		if(theErr != iExpectedError)
  1.1592 +			{
  1.1593 +			return EFail;
  1.1594 +			}
  1.1595 +		
  1.1596 +		theErr = aPlayer->GetBalance(iBalance);
  1.1597 +		if(theErr != iExpectedError)
  1.1598 +			{
  1.1599 +			return EFail;	
  1.1600 +			}
  1.1601 +		
  1.1602 +		
  1.1603 +		INFO_PRINTF2( _L("Test finished with expectable error: %d"), iExpectedError);
  1.1604 +		verdict = EPass;
  1.1605 +		}
  1.1606 +	return verdict;
  1.1607 +	}
  1.1608 +
  1.1609 +CTestMmfAclntAudioDuration::CTestMmfAclntAudioDuration(const TDesC& aTestName, const TDesC& aSectName)
  1.1610 +	: CTestMmfAclntAudioPlayerUtil(aTestName, aSectName)
  1.1611 +	{}
  1.1612 +
  1.1613 +CTestMmfAclntAudioDuration* CTestMmfAclntAudioDuration::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1.1614 +	{
  1.1615 +	CTestMmfAclntAudioDuration* self = new (ELeave) CTestMmfAclntAudioDuration(aTestName, aSectName);
  1.1616 +	return self;
  1.1617 +	}
  1.1618 +
  1.1619 +TVerdict CTestMmfAclntAudioDuration::DoTestL(CMdaAudioPlayerUtility* aPlayer)
  1.1620 +	{
  1.1621 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Duration"));
  1.1622 +	TVerdict ret = EFail;
  1.1623 +	if (iDuration == aPlayer->Duration())
  1.1624 +		{
  1.1625 +		ret = EPass;
  1.1626 +		}
  1.1627 +	
  1.1628 +	return ret;
  1.1629 +	}
  1.1630 +
  1.1631 +//------------------------------------------------------------------
  1.1632 +
  1.1633 +CDelayedMethodCall* CDelayedMethodCall::NewL(MDelayedMethodCall* aThat)
  1.1634 +		{
  1.1635 +		__ASSERT_ALWAYS(aThat, User::Leave(KErrArgument));
  1.1636 +		CDelayedMethodCall* self = new (ELeave) CDelayedMethodCall(aThat);
  1.1637 +		CleanupStack::PushL(self);
  1.1638 +		self->ConstructL();
  1.1639 +		CleanupStack::Pop(self);
  1.1640 +		return self;
  1.1641 +		};
  1.1642 +
  1.1643 +
  1.1644 +void CDelayedMethodCall::RunL() 
  1.1645 +	{
  1.1646 +	iThat->DelayedMethodCallL();
  1.1647 +	}
  1.1648 +
  1.1649 +TInt CDelayedMethodCall::RunError(TInt aError) 
  1.1650 +	{
  1.1651 +	RDebug::Print( _L("CDelayedMethodCall::RunL Left %d\n"), aError);
  1.1652 +	return KErrNone;
  1.1653 +	}
  1.1654 +
  1.1655 +
  1.1656 +CDelayedMethodCall::CDelayedMethodCall(MDelayedMethodCall* aThat) : CTimer(0), iThat(aThat)
  1.1657 +	{
  1.1658 +	CActiveScheduler::Add(this);
  1.1659 +	}
  1.1660 +
  1.1661 +
  1.1662 +
  1.1663 +//------------------------------------------------------------------
  1.1664 +/**
  1.1665 + * Constructor
  1.1666 + */
  1.1667 +CTestMmfAclntPriority::CTestMmfAclntPriority(const TDesC& aTestName, const TDesC& aSectName, const TMdaPriority aPriority)
  1.1668 +	{
  1.1669 +	// store the name of this test case
  1.1670 +	// this is the name that is used by the script file
  1.1671 +// Each test step initialises it's own name
  1.1672 +	iTestStepName = aTestName;
  1.1673 +	iPriority = aPriority;
  1.1674 +	iPriorityManual = ETrue;
  1.1675 +	iSectName = aSectName;
  1.1676 +	}
  1.1677 +
  1.1678 +CTestMmfAclntPriority* CTestMmfAclntPriority::NewL(const TDesC& aTestName, const TDesC& aSectName, const TMdaPriority aPriority)
  1.1679 +	{
  1.1680 +	CTestMmfAclntPriority* self = new (ELeave) CTestMmfAclntPriority(aTestName, aSectName, aPriority);
  1.1681 +	return self;
  1.1682 +	}
  1.1683 +
  1.1684 +// overridden constructor for no priority setting
  1.1685 +CTestMmfAclntPriority::CTestMmfAclntPriority(const TDesC& aTestName, const TDesC& aSectName)
  1.1686 +	{
  1.1687 +	// store the name of this test case
  1.1688 +	// this is the name that is used by the script file
  1.1689 +	// Each test step initialises it's own name
  1.1690 +	iTestStepName = aTestName;
  1.1691 +	iPriority = EMdaPriorityNormal;
  1.1692 +	iPriorityManual = EFalse;
  1.1693 +	iSectName = aSectName;
  1.1694 +	}
  1.1695 +
  1.1696 +
  1.1697 +CTestMmfAclntPriority* CTestMmfAclntPriority::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1.1698 +	{
  1.1699 +	CTestMmfAclntPriority* self = new (ELeave) CTestMmfAclntPriority(aTestName, aSectName);
  1.1700 +	return self;
  1.1701 +	}
  1.1702 +
  1.1703 +void CTestMmfAclntPriority::MchoComplete(TInt aID, TInt aError)
  1.1704 +	{
  1.1705 +	INFO_PRINTF3( _L("Callback for CMdaAudioPlayerUtility called : ID %d, error %d"), aID, aError);
  1.1706 +
  1.1707 +	iError = aError;
  1.1708 +
  1.1709 +	iCallbackError[aID] = aError;
  1.1710 +
  1.1711 +
  1.1712 +	if(iFirstCallback == -1)
  1.1713 +		{
  1.1714 +		iFirstCallback = aID;
  1.1715 +		}
  1.1716 +		
  1.1717 +	
  1.1718 +	if((--iCallbackCount) <= 0)
  1.1719 +		{
  1.1720 +		CActiveScheduler::Stop();	
  1.1721 +		}
  1.1722 +		
  1.1723 +	}
  1.1724 +
  1.1725 +
  1.1726 +//This method is used to start playing file 0 after file 1 has started
  1.1727 +void CTestMmfAclntPriority::DelayedMethodCallL()
  1.1728 +{
  1.1729 +	audioUtil[0]->Play();
  1.1730 +	if(iError == KErrNone)
  1.1731 +		{
  1.1732 +		INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility 0"));
  1.1733 +		}
  1.1734 +}
  1.1735 +
  1.1736 +
  1.1737 +
  1.1738 +
  1.1739 +/**
  1.1740 + * Audio priority.
  1.1741 + */
  1.1742 +TVerdict CTestMmfAclntPriority::DoTestStepL()
  1.1743 +	{ 
  1.1744 +	INFO_PRINTF1( _L("TestPlayerUtils : Priority"));
  1.1745 +
  1.1746 +	TBuf<KSizeBuf>	filename0, filename1;
  1.1747 +
  1.1748 +	TPtrC file; 
  1.1749 +	if(!GetStringFromConfig(iSectName, _L("playerAudioFile"), file))
  1.1750 +		{
  1.1751 +		return EInconclusive;
  1.1752 +		}
  1.1753 +		
  1.1754 +	GetDriveName(filename0);
  1.1755 +	filename0.Append(file);
  1.1756 +
  1.1757 +	if(!GetStringFromConfig(iSectName, _L("playerAudioFile2"), file))
  1.1758 +		{
  1.1759 +		return EInconclusive;
  1.1760 +		}
  1.1761 +		
  1.1762 +	GetDriveName(filename1);
  1.1763 +	filename1.Append(file);
  1.1764 +
  1.1765 +	TVerdict ret=EFail;
  1.1766 +
  1.1767 +	CPlayerCallbackHandler* callback[2];
  1.1768 +
  1.1769 +	iError = KErrNone;
  1.1770 +
  1.1771 +	for(TInt i=0; i<2; i++)
  1.1772 +		{
  1.1773 +		callback[i] = new (ELeave) CPlayerCallbackHandler(i,this);
  1.1774 +		CleanupStack::PushL(callback[i]);
  1.1775 +		}
  1.1776 +
  1.1777 +
  1.1778 +	audioUtil[0] = CMdaAudioPlayerUtility::NewFilePlayerL(filename0,*callback[0],EMdaPriorityNormal);
  1.1779 +	CleanupStack::PushL(audioUtil[0]);
  1.1780 +	audioUtil[1] = CMdaAudioPlayerUtility::NewFilePlayerL(filename1,*callback[1],EMdaPriorityNormal);
  1.1781 +	CleanupStack::PushL(audioUtil[1]);
  1.1782 +
  1.1783 +	INFO_PRINTF2( _L("Initialise CMdaAudioPlayerUtility 0 - %S"), &filename0);
  1.1784 +	INFO_PRINTF2( _L("Initialise CMdaAudioPlayerUtility 1 - %S"), &filename1);
  1.1785 +
  1.1786 +	iCallbackCount = 2;
  1.1787 +	// wait for initilisation callback
  1.1788 +	CActiveScheduler::Start();
  1.1789 +
  1.1790 +	if(iError == KErrNone && iCallbackCount == 0)
  1.1791 +		{
  1.1792 +		// set manual priority on audioUtil[0] ?
  1.1793 +		if(iPriorityManual)
  1.1794 +			{
  1.1795 +			TInt priErr = audioUtil[0]->SetPriority(iPriority, EMdaPriorityPreferenceNone);
  1.1796 +			INFO_PRINTF3(_L("Priority set manually to %d - return %d"), iPriority, priErr); 
  1.1797 +			}
  1.1798 +
  1.1799 +		audioUtil[1]->Play();
  1.1800 +		if(iError == KErrNone)
  1.1801 +			{
  1.1802 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility 1"));
  1.1803 +			}
  1.1804 +
  1.1805 +		iCallbackCount = 2;
  1.1806 +		iFirstCallback = -1;
  1.1807 +		
  1.1808 +		CDelayedMethodCall* delayedMethodCall = CDelayedMethodCall::NewL(this);
  1.1809 +		CleanupStack::PushL(delayedMethodCall);
  1.1810 +		delayedMethodCall->After(KOneSecond);
  1.1811 +		
  1.1812 +		// wait for play to complete
  1.1813 +		INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.1814 +		CActiveScheduler::Start();
  1.1815 +
  1.1816 +		CleanupStack::PopAndDestroy(delayedMethodCall); //delayedMethodCall
  1.1817 +			
  1.1818 +		if(iError == KErrNone && iCallbackCount == 0)
  1.1819 +			{			
  1.1820 +			if(	((iPriority <  EMdaPriorityNormal) && (iFirstCallback == 0 ) && (iCallbackError[0]==KErrInUse) && (iCallbackError[1]==KErrNone)) || 
  1.1821 +				((iPriority ==  EMdaPriorityNormal) && (iFirstCallback == 0 ) && (iCallbackError[0]==KErrInUse) && (iCallbackError[1]==KErrNone)) || 
  1.1822 +				((iPriority >  EMdaPriorityNormal) && (iFirstCallback == 1 ) && (iCallbackError[0]==KErrNone) && (iCallbackError[1]==KErrInUse)) 
  1.1823 +				)
  1.1824 +				{
  1.1825 +				ret = EPass;
  1.1826 +				}
  1.1827 +			INFO_PRINTF2( _L("First callback with Id: %d"), iFirstCallback);
  1.1828 +			INFO_PRINTF3( _L("Error codes - file 0 = %d   file 1 = %d"), iCallbackError[0], iCallbackError[1]);
  1.1829 +			}
  1.1830 +		}
  1.1831 +
  1.1832 +	if(iError != 0)
  1.1833 +		{
  1.1834 +		ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with error %d"),iError );
  1.1835 +		}
  1.1836 +		
  1.1837 +
  1.1838 +	CleanupStack::PopAndDestroy(4); // audioUtil , callback
  1.1839 +
  1.1840 +	User::After(KOneSecond);
  1.1841 +	return ret;
  1.1842 +	}
  1.1843 +
  1.1844 +
  1.1845 +
  1.1846 +//------------------------------------------------------------------
  1.1847 +
  1.1848 +CTestMmfAclntAudioPosition::CTestMmfAclntAudioPosition(const TDesC& aTestName, const TDesC& aSectName, const TTimeIntervalMicroSeconds& aPosition)
  1.1849 +	: CTestMmfAclntAudioPlayerUtil(aTestName,aSectName), iPosition(aPosition)
  1.1850 +	{}
  1.1851 +
  1.1852 +CTestMmfAclntAudioPosition* CTestMmfAclntAudioPosition::NewL(const TDesC& aTestName, const TDesC& aSectName, const TTimeIntervalMicroSeconds& aPosition)
  1.1853 +	{
  1.1854 +	CTestMmfAclntAudioPosition* self = new (ELeave) CTestMmfAclntAudioPosition(aTestName,aSectName,aPosition);
  1.1855 +	return self;
  1.1856 +	}
  1.1857 +
  1.1858 +TVerdict CTestMmfAclntAudioPosition::DoTestL(CMdaAudioPlayerUtility* aPlayer)
  1.1859 +	{
  1.1860 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Position"));
  1.1861 +	TVerdict ret = EFail;
  1.1862 +	TTimeIntervalMicroSeconds position;
  1.1863 +	TBool validPosition = EFalse;
  1.1864 +	INFO_PRINTF3(_L("Set Position %d Duration = %d"),
  1.1865 +		I64INT(iPosition.Int64()), I64INT(aPlayer->Duration().Int64()));
  1.1866 +
  1.1867 +	//  Set position: middle of clip.
  1.1868 +	if (I64INT(iPosition.Int64()) == 0)
  1.1869 +		{
  1.1870 +		iPosition = I64INT(aPlayer->Duration().Int64())/2;
  1.1871 +		}
  1.1872 +		
  1.1873 +	// Set position: end of clip.
  1.1874 +	if (I64INT(iPosition.Int64()) == -1)
  1.1875 +		{
  1.1876 +		iPosition = aPlayer->Duration();
  1.1877 +		}
  1.1878 +	
  1.1879 +	// Position is beyond the end of the clips duration.
  1.1880 +	// so check that the value is clipped.
  1.1881 +	if(aPlayer->Duration() < iPosition)
  1.1882 +		{
  1.1883 +		aPlayer->SetPosition(iPosition);
  1.1884 +		
  1.1885 +		//aPlayer->Play();           // Playing the clip will reset the position to 0 when finished.
  1.1886 +		//CActiveScheduler::Start();
  1.1887 +
  1.1888 +		/*TInt theRes1 = */aPlayer->GetPosition(position);
  1.1889 +		
  1.1890 +		
  1.1891 +		INFO_PRINTF2(_L("Longer than duration : Setting position to %d"), I64INT(iPosition.Int64()));
  1.1892 +		INFO_PRINTF3(_L("Set : position = %d (if clipped : %d)"), 
  1.1893 +			I64INT(position.Int64()), I64INT(aPlayer->Duration().Int64()));
  1.1894 +
  1.1895 +		TInt theRes = aPlayer->GetPosition(position);
  1.1896 +		if(theRes == KErrNone && (position.Int64() == aPlayer->Duration().Int64()))
  1.1897 +			{
  1.1898 +			validPosition = ETrue;
  1.1899 +			}
  1.1900 +		}
  1.1901 +			
  1.1902 +		
  1.1903 +	// Position is before the end of the clips duration.
  1.1904 +	// so check that the value is clipped to 0
  1.1905 +	// *** added by JW after discussion re. expected behaviour -
  1.1906 +	// for test 1009
  1.1907 +	else if(iPosition < TTimeIntervalMicroSeconds(0))
  1.1908 +		{
  1.1909 +		aPlayer->SetPosition(iPosition);
  1.1910 +		
  1.1911 +		aPlayer->Play();
  1.1912 +		CActiveScheduler::Start();
  1.1913 +
  1.1914 +		/*TInt theRes1 = */aPlayer->GetPosition(position);
  1.1915 +		
  1.1916 +		
  1.1917 +		INFO_PRINTF2(_L("Shorter than 0 : Setting position to %d"), I64INT(iPosition.Int64()));
  1.1918 +		INFO_PRINTF2(_L("Set : position = %d (if clipped : 0)"), 
  1.1919 +			I64INT(position.Int64()));
  1.1920 +
  1.1921 +		TInt theRes = aPlayer->GetPosition(position);
  1.1922 +		if(theRes == KErrNone && I64INT(position.Int64()) == 0)
  1.1923 +			{
  1.1924 +			validPosition = ETrue;
  1.1925 +			}
  1.1926 +			
  1.1927 +		}
  1.1928 +
  1.1929 +	else
  1.1930 +		{
  1.1931 +
  1.1932 +		aPlayer->SetPosition(iPosition);
  1.1933 +		aPlayer->GetPosition(position);
  1.1934 +		INFO_PRINTF3(_L("Set : position = %d, duration = %d)"), 
  1.1935 +			I64INT(position.Int64()), I64INT(aPlayer->Duration().Int64()));
  1.1936 +		aPlayer->Play();
  1.1937 +
  1.1938 +		CActiveScheduler::Start();
  1.1939 +
  1.1940 +		// For test 1009, we check that the expected error code was returned
  1.1941 +		// *** removed by JW after discussion re. expected behaviour
  1.1942 +		/*
  1.1943 +		if (iPosition < TTimeIntervalMicroSeconds(0))
  1.1944 +			{
  1.1945 +			TVerdict ret = EFail;
  1.1946 +			if (iError == KErrArgument)
  1.1947 +				{
  1.1948 +				if (position != TTimeIntervalMicroSeconds(0))
  1.1949 +					{
  1.1950 +					INFO_PRINTF2(_L("ERROR: KErrArgument returned, but position was %d, expected position = 0"),position);
  1.1951 +					ret = EFail;
  1.1952 +					}
  1.1953 +				else
  1.1954 +					{
  1.1955 +					// Test passed
  1.1956 +					ret = EPass;
  1.1957 +					}
  1.1958 +				}
  1.1959 +			else
  1.1960 +				{
  1.1961 +				INFO_PRINTF3(_L("Expected error not returned, expecting %d, got %d"), KErrArgument, iError);
  1.1962 +				ret = EFail;
  1.1963 +				}
  1.1964 +			return ret;
  1.1965 +			}
  1.1966 +		*/
  1.1967 +
  1.1968 +		aPlayer->Stop();		
  1.1969 +
  1.1970 +		//TInt64 temp = (iPosition.Int64() / KPcm16FrameInterval) - 1; // -1 for DevSound
  1.1971 +		aPlayer->GetPosition(position);
  1.1972 +		// returned position should equal the original position or number of frames * frame intervals.
  1.1973 +		// The above comment is invalid, one the clip has played the position should be reset to 0. - INC24264
  1.1974 +		if (position.Int64() == 0)
  1.1975 +		//if(position.Int64() == (temp * KPcm16FrameInterval) || (position == iPosition))
  1.1976 +			{
  1.1977 +			validPosition = ETrue;
  1.1978 +			}
  1.1979 +		//else
  1.1980 +			INFO_PRINTF3( _L("Expected position : %f, received position  : %f"), 
  1.1981 +					I64REAL(iPosition.Int64()), I64REAL(position.Int64()));
  1.1982 +		}
  1.1983 +
  1.1984 +	// Postion was set to a valid value.
  1.1985 +	if(validPosition)
  1.1986 +		{
  1.1987 +		aPlayer->Play();
  1.1988 +		// wait for play to complete
  1.1989 +		INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.1990 +		CActiveScheduler::Start();
  1.1991 +
  1.1992 +		INFO_PRINTF2( _L("Error : %d"), iError);
  1.1993 +		if (iError == KErrNone)
  1.1994 +			ret = EPass;
  1.1995 +		}
  1.1996 +	return ret;
  1.1997 +	}
  1.1998 +
  1.1999 +//------------------------------------------------------------------
  1.2000 +
  1.2001 +CTestMmfAclntAudioPlayWindow::CTestMmfAclntAudioPlayWindow(const TDesC& aTestName, const TDesC& aSectName, const TBool aNegative)
  1.2002 +	: CTestMmfAclntAudioPlayerUtil(aTestName, aSectName), iNegative(aNegative)
  1.2003 +	{}
  1.2004 +
  1.2005 +CTestMmfAclntAudioPlayWindow* CTestMmfAclntAudioPlayWindow::NewL(const TDesC& aTestName, const TDesC& aSectName, const TBool aNegative)
  1.2006 +	{
  1.2007 +	CTestMmfAclntAudioPlayWindow* self = new (ELeave) CTestMmfAclntAudioPlayWindow(aTestName, aSectName, aNegative);
  1.2008 +	return self;
  1.2009 +	}
  1.2010 +
  1.2011 +TVerdict CTestMmfAclntAudioPlayWindow::DoTestL(CMdaAudioPlayerUtility* aPlayer)
  1.2012 +	{
  1.2013 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Play Window"));
  1.2014 +	TVerdict ret = EFail;
  1.2015 +	TInt64 temp1, temp2;
  1.2016 +	TInt duration = I64INT(aPlayer->Duration().Int64());
  1.2017 +
  1.2018 +	TInt windowDuration = 0;
  1.2019 +	if(iNegative)
  1.2020 +		{
  1.2021 +		INFO_PRINTF1( _L("Attempting to set an invalid play window"));
  1.2022 +		temp1 = -KInvalidNumber;
  1.2023 +		temp2 = aPlayer->Duration().Int64() + KInvalidNumber;
  1.2024 +		windowDuration = I64INT(aPlayer->Duration().Int64());
  1.2025 +		}
  1.2026 +	else
  1.2027 +		{
  1.2028 +		temp1 = aPlayer->Duration().Int64()/2;
  1.2029 +		temp2 = aPlayer->Duration().Int64();
  1.2030 +
  1.2031 +		windowDuration = (I64INT(temp2) - I64INT(temp1));
  1.2032 +		}
  1.2033 +
  1.2034 +
  1.2035 +	TTimeIntervalMicroSeconds startTime(temp1);
  1.2036 +	TTimeIntervalMicroSeconds endTime(temp2); 
  1.2037 +
  1.2038 +	INFO_PRINTF4(_L("StartTime = %d EndTime = %d WindowDuration = %d"),
  1.2039 +		I64INT(startTime.Int64()), I64INT(endTime.Int64()), windowDuration);
  1.2040 +	
  1.2041 +	TInt windowSet = aPlayer->SetPlayWindow(startTime,endTime);
  1.2042 +
  1.2043 +	if (iNegative && (windowSet == KErrArgument))
  1.2044 +		{
  1.2045 +		INFO_PRINTF1( _L("Correct return from SetPlayWindow (KErrArgument) when attempting to set an invalid window range"));
  1.2046 +		return EPass;
  1.2047 +		}
  1.2048 +
  1.2049 +	if (windowSet != KErrNone)
  1.2050 +		{
  1.2051 +		INFO_PRINTF2( _L("Unexpected error returned from SetPlayWindow - %d"),windowSet);
  1.2052 +		return EFail;
  1.2053 +		}
  1.2054 +
  1.2055 +	iError = KErrTimedOut;
  1.2056 +	INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.2057 +	aPlayer->Play();
  1.2058 +
  1.2059 +	TTime start;
  1.2060 +	start.HomeTime();
  1.2061 +	CActiveScheduler::Start();
  1.2062 +	TTime stop;
  1.2063 +	stop.HomeTime();
  1.2064 +
  1.2065 +	TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
  1.2066 +
  1.2067 +	INFO_PRINTF6(_L("Error : %d Start = %d Stop = %d WindowDuration = %d ActualDuration = %d"),
  1.2068 +		iError, I64INT(start.Int64()), I64INT(stop.Int64()), windowDuration, actualDuration);
  1.2069 +
  1.2070 +	if((iError == KErrNone) && (TimeComparison(actualDuration, windowDuration, KExpectedDeviation)))
  1.2071 +		{
  1.2072 +		aPlayer->ClearPlayWindow();
  1.2073 +
  1.2074 +		iError = KErrTimedOut;
  1.2075 +		INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.2076 +		aPlayer->Play();
  1.2077 +
  1.2078 +		TTime start;
  1.2079 +		start.HomeTime();
  1.2080 +		CActiveScheduler::Start();
  1.2081 +		TTime stop;
  1.2082 +		stop.HomeTime();
  1.2083 +
  1.2084 +		TUint actualDuration = I64INT(stop.MicroSecondsFrom(start).Int64());
  1.2085 +
  1.2086 +		INFO_PRINTF6(_L("Error : %d Start = %d Stop = %d Duration = %d ActualDuration = %d"),
  1.2087 +			iError, I64INT(start.Int64()), I64INT(stop.Int64()), duration, actualDuration);
  1.2088 +			ret =  EPass;
  1.2089 +		}
  1.2090 +	return ret;
  1.2091 +	}
  1.2092 +
  1.2093 +//------------------------------------------------------------------
  1.2094 +
  1.2095 +CTestMmfAclntAudioType::CTestMmfAclntAudioType(const TDesC& aTestName, const TDesC& aSectName)
  1.2096 +	: CTestMmfAclntAudioPlayerUtil(aTestName, aSectName)
  1.2097 +	{}
  1.2098 +
  1.2099 +CTestMmfAclntAudioType* CTestMmfAclntAudioType::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1.2100 +	{
  1.2101 +	CTestMmfAclntAudioType* self = new (ELeave) CTestMmfAclntAudioType(aTestName, aSectName);
  1.2102 +	return self;
  1.2103 +	}
  1.2104 +
  1.2105 +TVerdict CTestMmfAclntAudioType::DoTestL(CMdaAudioPlayerUtility* /*aPlayer*/)
  1.2106 +	{
  1.2107 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Type"));
  1.2108 +	INFO_PRINTF1( _L("#######################################################"));
  1.2109 +	INFO_PRINTF1( _L("No Audio Type API call for class CMdaAudioPlayerUtility"));
  1.2110 +	INFO_PRINTF1( _L("This test is therefore inconclusive."));
  1.2111 +	INFO_PRINTF1( _L("#######################################################"));
  1.2112 +	TVerdict ret = EInconclusive;
  1.2113 +
  1.2114 +	// what code should/might look like.
  1.2115 +	//CMdaAudioType* type = aPlayer->TypeL();
  1.2116 +
  1.2117 +	// CMdaAudioType class not complete:
  1.2118 +	// XXX check data returned is valid???
  1.2119 +
  1.2120 +	return ret;
  1.2121 +	}
  1.2122 +
  1.2123 +//--------------------------------------------------------------
  1.2124 +
  1.2125 +CTestMmfAclntAudioRamp::CTestMmfAclntAudioRamp(const TDesC& aTestName, const TDesC& aSectName)
  1.2126 +	: CTestMmfAclntAudioPlayerUtil(aTestName, aSectName)
  1.2127 +	{}
  1.2128 +
  1.2129 +CTestMmfAclntAudioRamp* CTestMmfAclntAudioRamp::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1.2130 +	{
  1.2131 +	CTestMmfAclntAudioRamp* self = new (ELeave) CTestMmfAclntAudioRamp(aTestName, aSectName);
  1.2132 +	return self;
  1.2133 +	}
  1.2134 +
  1.2135 +TVerdict CTestMmfAclntAudioRamp::DoTestL(CMdaAudioPlayerUtility* aPlayer)
  1.2136 +	{
  1.2137 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Ramp"));
  1.2138 +	TVerdict ret = EFail;
  1.2139 +	TTimeIntervalMicroSeconds ramp(100);
  1.2140 +	aPlayer->SetVolumeRamp(ramp);
  1.2141 +
  1.2142 +	aPlayer->Play();
  1.2143 +	// wait for open to complete
  1.2144 +	iError = KErrTimedOut;
  1.2145 +	CActiveScheduler::Start();
  1.2146 +	if(iError == KErrNone)	
  1.2147 +		ret = EPass;
  1.2148 +	return ret;
  1.2149 +	}
  1.2150 +
  1.2151 +//------------------------------------------------------------------
  1.2152 +
  1.2153 +CTestMmfAclntAudioMeta::CTestMmfAclntAudioMeta(const TDesC& aTestName, const TDesC& aSectName)
  1.2154 +	: CTestMmfAclntAudioPlayerUtil(aTestName, aSectName)
  1.2155 +	{}
  1.2156 +
  1.2157 +CTestMmfAclntAudioMeta* CTestMmfAclntAudioMeta::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1.2158 +	{
  1.2159 +	CTestMmfAclntAudioMeta* self = new (ELeave) CTestMmfAclntAudioMeta(aTestName, aSectName);
  1.2160 +	return self;
  1.2161 +	}
  1.2162 +
  1.2163 +_LIT(name,"Title");
  1.2164 +_LIT(data,"Symbian");
  1.2165 +TVerdict CTestMmfAclntAudioMeta::DoTestL(CMdaAudioPlayerUtility* aPlayer)
  1.2166 +	{
  1.2167 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Metadata"));
  1.2168 +	
  1.2169 +	TInt numEntries;
  1.2170 +	TInt theErr = aPlayer->GetNumberOfMetaDataEntries(numEntries);
  1.2171 +	INFO_PRINTF3(_L("Error : %d NumEntries : %d"), theErr, numEntries);
  1.2172 +
  1.2173 +	if(theErr && theErr != KErrNotSupported) // Audio Controller doesn't support - this is ok
  1.2174 +		{
  1.2175 +		ERR_PRINTF2(_L("GetNumberOfMetaDataEntries returned unexpected error %d"), theErr);
  1.2176 +		return EFail;
  1.2177 +		}
  1.2178 +
  1.2179 +	CMMFMetaDataEntry* testData = NULL;
  1.2180 +			
  1.2181 +	TRAPD(theErr2, testData = aPlayer->GetMetaDataEntryL(0));
  1.2182 +	if(!theErr2)
  1.2183 +		{
  1.2184 +		if((testData->Name() == name) && (testData->Value() == data))
  1.2185 +			return EPass;
  1.2186 +		}
  1.2187 +	else
  1.2188 +		{
  1.2189 +		if(theErr == KErrNotSupported) // Audio Controller doesn't support - this is ok
  1.2190 +			{
  1.2191 +			INFO_PRINTF1(_L("Note : Audio Controller does not support metadata"));
  1.2192 +			return EPass;
  1.2193 +			}
  1.2194 +		else if(numEntries == 0)
  1.2195 +			{
  1.2196 +			INFO_PRINTF1(_L("No metadata entries found"));
  1.2197 +			return EPass;
  1.2198 +			}
  1.2199 +		else
  1.2200 +			{
  1.2201 +			ERR_PRINTF2(_L("GetMetaDataEntryL left with unexpected error %d"), theErr2);
  1.2202 +			return EFail;
  1.2203 +			}
  1.2204 +		}
  1.2205 +	return EPass;
  1.2206 +	}
  1.2207 +
  1.2208 +//------------------------------------------------------------------
  1.2209 +
  1.2210 +CTestMmfAclntAudioCloseOpen::CTestMmfAclntAudioCloseOpen(const TDesC& aTestName, const TDesC& aSectName)
  1.2211 +	: CTestMmfAclntAudioPlayerUtil(aTestName, aSectName)
  1.2212 +	{}
  1.2213 +
  1.2214 +CTestMmfAclntAudioCloseOpen* CTestMmfAclntAudioCloseOpen::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1.2215 +	{
  1.2216 +	CTestMmfAclntAudioCloseOpen* self = new (ELeave) CTestMmfAclntAudioCloseOpen(aTestName, aSectName);
  1.2217 +	return self;
  1.2218 +	}
  1.2219 +
  1.2220 +
  1.2221 +
  1.2222 +
  1.2223 +TVerdict CTestMmfAclntAudioCloseOpen::DoTestL(CMdaAudioPlayerUtility* aPlayer)
  1.2224 +	{
  1.2225 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Close/Open"));
  1.2226 +
  1.2227 +	TVerdict ret = EFail;
  1.2228 +	aPlayer->Close(); 
  1.2229 +
  1.2230 +	// get second file name
  1.2231 +	TBuf<KSizeBuf>	filename2;
  1.2232 +	TPtrC			filename; 
  1.2233 +	if(!GetStringFromConfig(iSectName, _L("playerAudioFile"), filename))
  1.2234 +		{
  1.2235 +		return EInconclusive;
  1.2236 +		}
  1.2237 +		
  1.2238 +	GetDriveName(filename2);
  1.2239 +	filename2.Append(filename);
  1.2240 +
  1.2241 +	// Open second file
  1.2242 +	aPlayer->OpenFileL(filename2);
  1.2243 +	// wait for open to complete
  1.2244 +	INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
  1.2245 +	CActiveScheduler::Start();
  1.2246 +
  1.2247 +	TInt openErr = iError;
  1.2248 +
  1.2249 +	INFO_PRINTF2( _L("OpenFileL completed with error %d"), iError);
  1.2250 +
  1.2251 +	if (iError == KErrNone && openErr == KErrNone)
  1.2252 +		{
  1.2253 +		ret = EPass;
  1.2254 +		}
  1.2255 +	
  1.2256 +	return ret;
  1.2257 +	}
  1.2258 +
  1.2259 +//------------------------------------------------------------------
  1.2260 +
  1.2261 +CTestMmfAclntAudioBitRate::CTestMmfAclntAudioBitRate(const TDesC& aTestName,const TDesC& aKeyName1, const TDesC& aKeyName2)
  1.2262 +	{
  1.2263 +	// store the name of this test case
  1.2264 +	// this is the name that is used by the script file
  1.2265 +	// Each test step initialises it's own name
  1.2266 +	iTestStepName = aTestName;
  1.2267 +	iKeyFileName = aKeyName1;
  1.2268 +	iKeyBitRateName = aKeyName2;
  1.2269 +	}
  1.2270 +
  1.2271 +CTestMmfAclntAudioBitRate* CTestMmfAclntAudioBitRate::NewL(const TDesC& aTestName,const TDesC& aKeyName1, const TDesC& aKeyName2)
  1.2272 +	{													   
  1.2273 +	CTestMmfAclntAudioBitRate* self = new (ELeave) CTestMmfAclntAudioBitRate(aTestName,aKeyName1,aKeyName2);
  1.2274 +	return self;
  1.2275 +	}
  1.2276 +
  1.2277 +void CTestMmfAclntAudioBitRate::MapcInitComplete(TInt aError, 
  1.2278 +								const TTimeIntervalMicroSeconds & /*aDuration*/)
  1.2279 +	{
  1.2280 +	iError = aError;
  1.2281 +	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
  1.2282 +	CActiveScheduler::Stop();
  1.2283 +	}
  1.2284 +
  1.2285 +void CTestMmfAclntAudioBitRate::MapcPlayComplete(TInt aError)
  1.2286 +	{
  1.2287 +	iError = aError;
  1.2288 +	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
  1.2289 +	CActiveScheduler::Stop();
  1.2290 +	}
  1.2291 +
  1.2292 +
  1.2293 +TVerdict CTestMmfAclntAudioBitRate::DoTestStepL( void )
  1.2294 +	{
  1.2295 +	
  1.2296 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Bit Rate"));
  1.2297 +		
  1.2298 +	iError = KErrTimedOut;
  1.2299 +	TUint bitRate = 0;
  1.2300 +	TVerdict res = EFail;
  1.2301 +
  1.2302 +	TBuf<KSizeBuf>	filename;
  1.2303 +	TPtrC			filename1; 
  1.2304 +	if(!GetStringFromConfig(_L("SectionNine"),iKeyFileName,filename1))
  1.2305 +		{
  1.2306 +		return EInconclusive;
  1.2307 +		}
  1.2308 +	if(!GetIntFromConfig(_L("SectionNine"),iKeyBitRateName,iExpectedBitRate))
  1.2309 +		{
  1.2310 +		return EInconclusive;
  1.2311 +		}
  1.2312 +	
  1.2313 +	INFO_PRINTF2(_L("Expected bit rate: %d"), iExpectedBitRate);
  1.2314 +	
  1.2315 +	GetDriveName(filename);
  1.2316 +	filename.Append(filename1);
  1.2317 +
  1.2318 +	CMdaAudioPlayerUtility* player = CMdaAudioPlayerUtility::NewFilePlayerL(filename1,*this);
  1.2319 +	CleanupStack::PushL(player);
  1.2320 +	CActiveScheduler::Start();
  1.2321 +	
  1.2322 +	if (iError == KErrNone)
  1.2323 +		{
  1.2324 +		player->Play();
  1.2325 +		CActiveScheduler::Start();
  1.2326 +		if(iError == KErrNone) 
  1.2327 +			{
  1.2328 +			TInt err = player->GetBitRate(bitRate);
  1.2329 +			if(err == KErrNone)
  1.2330 +				{
  1.2331 +				INFO_PRINTF2(_L("Retrieved bit rate: %d"), bitRate);
  1.2332 +				if(static_cast<TInt>(bitRate) == iExpectedBitRate)
  1.2333 +					{
  1.2334 +					INFO_PRINTF1(_L("The Expected bit rate and retrieved bit rate matched"));
  1.2335 +					res = EPass;
  1.2336 +					}
  1.2337 +				else
  1.2338 +					{
  1.2339 +					INFO_PRINTF1(_L("The Expected bit rate and retrieved bit rate does not match"));	
  1.2340 +					}
  1.2341 +				}
  1.2342 +			else
  1.2343 +				{
  1.2344 +				INFO_PRINTF2(_L("Failed with error %d while getting the bit rate"), err);
  1.2345 +				}
  1.2346 +			}
  1.2347 +		else
  1.2348 +			{
  1.2349 +			INFO_PRINTF1(_L("Failed during playing the audio"));
  1.2350 +			}
  1.2351 +		}
  1.2352 +	else
  1.2353 +		{
  1.2354 +		INFO_PRINTF2(_L("Failed during opening the file. Error =  %d "), iError);
  1.2355 +		}
  1.2356 +	CleanupStack::PopAndDestroy(player);
  1.2357 +	return res;
  1.2358 +	}
  1.2359 +	
  1.2360 +
  1.2361 +//------------------------------------------------------------------	
  1.2362 +CTestMmfAclntAudioQuery::CTestMmfAclntAudioQuery(const TDesC& aTestName, const TDesC& aSectName)
  1.2363 +	: CTestMmfAclntAudioPlayerUtil(aTestName, aSectName)
  1.2364 +	{}
  1.2365 +
  1.2366 +CTestMmfAclntAudioQuery* CTestMmfAclntAudioQuery::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1.2367 +	{
  1.2368 +	CTestMmfAclntAudioQuery* self = new (ELeave) CTestMmfAclntAudioQuery(aTestName, aSectName);
  1.2369 +	return self;
  1.2370 +	}
  1.2371 +
  1.2372 +TVerdict CTestMmfAclntAudioQuery::DoTestL(CMdaAudioPlayerUtility* /*aPlayer*/)
  1.2373 +	{
  1.2374 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Query"));
  1.2375 +
  1.2376 +	TVerdict ret = EFail;
  1.2377 +
  1.2378 +	// enhanced - to use CMMFControllerPluginSelectionParameters
  1.2379 +
  1.2380 +	INFO_PRINTF1(_L("Querying play formats..."));
  1.2381 +
  1.2382 +	CMMFControllerPluginSelectionParameters* cSelect = CMMFControllerPluginSelectionParameters::NewLC();
  1.2383 +	CMMFFormatSelectionParameters* fSelect = CMMFFormatSelectionParameters::NewLC();
  1.2384 +
  1.2385 +	RArray<TUid> mediaIds;
  1.2386 +	mediaIds.Append(KUidMediaTypeAudio);
  1.2387 +	cSelect->SetMediaIdsL(mediaIds, CMMFPluginSelectionParameters::EAllowOtherMediaIds);
  1.2388 +	cSelect->SetRequiredPlayFormatSupportL(*fSelect); 
  1.2389 +
  1.2390 +	RMMFControllerImplInfoArray controllers; // Array to hold all the controllers support the match data
  1.2391 +	CleanupResetAndDestroyPushL(controllers);
  1.2392 +	cSelect->ListImplementationsL(controllers);  // Populates the array with all the suitable controllers
  1.2393 +	TInt numControllers = controllers.Count();
  1.2394 +	if(!numControllers)
  1.2395 +		{
  1.2396 +		ERR_PRINTF1(_L("Could not find any controllers"));
  1.2397 +		}
  1.2398 +	else
  1.2399 +		{
  1.2400 +		INFO_PRINTF2(_L("Found %d controllers"), numControllers);
  1.2401 +		for(int i = 0; i < numControllers; i++)
  1.2402 +			{
  1.2403 +			RMMFFormatImplInfoArray cFormats = controllers[i]->PlayFormats();
  1.2404 +			const CDesC8Array* fileExtensions = &cFormats[0]->SupportedMimeTypes();
  1.2405 +			INFO_PRINTF3(_L("- Controller: %d Extensions : %d"), i, fileExtensions->Count());
  1.2406 +			for(int j = 0; j < fileExtensions->Count(); j++)
  1.2407 +				{
  1.2408 +				TBuf<24> ext16;
  1.2409 +				ext16.Copy(fileExtensions->MdcaPoint(j));
  1.2410 +				INFO_PRINTF2(_L("-- %S"), &ext16);
  1.2411 +				}
  1.2412 +			}
  1.2413 +		ret = EPass;
  1.2414 +		}
  1.2415 +
  1.2416 +	CleanupStack::PopAndDestroy(3);//controllers, fSelect, cSelect
  1.2417 +
  1.2418 +	return ret;
  1.2419 +	}
  1.2420 +
  1.2421 +//--------------------------------------------------------------------
  1.2422 +
  1.2423 +// Negative tests
  1.2424 +
  1.2425 +//--------------------------------------------------------------------
  1.2426 +
  1.2427 +/**
  1.2428 + * Constructor
  1.2429 + */
  1.2430 +CTestMmfAclntNoLoad::CTestMmfAclntNoLoad(const TDesC& aTestName, const TDesC& aSectName)
  1.2431 +	:CTestMmfAclntAudioPlayerUtil(aTestName, aSectName)
  1.2432 +	{
  1.2433 +	}
  1.2434 +
  1.2435 +CTestMmfAclntNoLoad* CTestMmfAclntNoLoad::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1.2436 +	{
  1.2437 +	CTestMmfAclntNoLoad* self = new (ELeave) CTestMmfAclntNoLoad(aTestName, aSectName);
  1.2438 +	return self;
  1.2439 +	}
  1.2440 +
  1.2441 +TVerdict CTestMmfAclntNoLoad::DoTestL(CMdaAudioPlayerUtility* /*aPlayer*/)
  1.2442 +	{
  1.2443 +	return EPass;
  1.2444 +	}
  1.2445 +
  1.2446 +/**
  1.2447 + * Play with no loaded sound file.
  1.2448 + */
  1.2449 +TVerdict CTestMmfAclntNoLoad::DoTestStepL()
  1.2450 +	{
  1.2451 +	INFO_PRINTF1( _L("TestPlayerUtils : No Load"));
  1.2452 +
  1.2453 +	iError = KErrTimedOut;
  1.2454 +	iStop = ETrue;
  1.2455 +
  1.2456 +	CMdaAudioPlayerUtility* player = CMdaAudioPlayerUtility::NewL(*this);
  1.2457 +	CleanupStack::PushL(player);
  1.2458 + 	player->Play();
  1.2459 +
  1.2460 +	CActiveScheduler::Start();
  1.2461 +
  1.2462 +	if(iError == KErrNotReady) 
  1.2463 +		{
  1.2464 +		CleanupStack::PopAndDestroy(player);
  1.2465 +		return EPass; 
  1.2466 +		}
  1.2467 +	
  1.2468 +	ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with error %d (expected KErrNotReady)"),iError );
  1.2469 +	CleanupStack::PopAndDestroy(player);
  1.2470 +	return	EFail;
  1.2471 +	}
  1.2472 +
  1.2473 +//------------------------------------------------------------------
  1.2474 +
  1.2475 +CTestMmfAclntDeletePlay::CTestMmfAclntDeletePlay(const TDesC& aTestName, const TDesC& aSectName)
  1.2476 +	: CTestMmfAclntAudioPlayerUtil(aTestName, aSectName)
  1.2477 +	{}
  1.2478 +
  1.2479 +CTestMmfAclntDeletePlay* CTestMmfAclntDeletePlay::NewL(const TDesC& aTestName, const TDesC& aSectName)
  1.2480 +	{
  1.2481 +	CTestMmfAclntDeletePlay* self = new (ELeave) CTestMmfAclntDeletePlay(aTestName, aSectName);
  1.2482 +	return self;
  1.2483 +	}
  1.2484 +
  1.2485 +
  1.2486 +
  1.2487 +/**
  1.2488 + * Audio clip - Delete object before play operation has completed.
  1.2489 + */
  1.2490 +TVerdict CTestMmfAclntDeletePlay::DoTestL(CMdaAudioPlayerUtility* /*aPlayer*/)
  1.2491 +	{
  1.2492 +	INFO_PRINTF1( _L("TestPlayerUtils : Delete/Play"));
  1.2493 +
  1.2494 +	TBuf<KSizeBuf>	filename;
  1.2495 +	TPtrC			filename1; 
  1.2496 +	if(!GetStringFromConfig(iSectName, _L("playerAudioFile"), filename1))
  1.2497 +		{
  1.2498 +		return EInconclusive;
  1.2499 +		}
  1.2500 +		
  1.2501 +	GetDriveName(filename);
  1.2502 +	filename.Append(filename1);
  1.2503 +
  1.2504 +	iError = KErrTimedOut;
  1.2505 +	__MM_HEAP_MARK;
  1.2506 +
  1.2507 +	CMdaAudioPlayerUtility* player = CMdaAudioPlayerUtility::NewFilePlayerL(filename,*this);
  1.2508 +	CleanupStack::PushL(player);
  1.2509 +	// wait for open to complete
  1.2510 +	CActiveScheduler::Start();
  1.2511 +
  1.2512 +	if(iError == KErrNone)
  1.2513 +		{
  1.2514 +		player->Play();
  1.2515 +		CleanupStack::PopAndDestroy(player); // destroy player before play has completed
  1.2516 +		__MM_HEAP_MARKEND;
  1.2517 +		User::Heap().Check();
  1.2518 +		return EPass;
  1.2519 +		}
  1.2520 +
  1.2521 +	CleanupStack::PopAndDestroy(player);
  1.2522 +	ERR_PRINTF2( _L("CMdaAudioRecorderUtility failed with error %d"),iError );
  1.2523 +	__MM_HEAP_MARKEND;
  1.2524 +	return EFail;
  1.2525 +	}
  1.2526 +
  1.2527 +//------------------------------------------------------------------
  1.2528 +
  1.2529 +CTestMmfAclntPlayPlay::CTestMmfAclntPlayPlay(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.2530 +	: CTestMmfAclntAudioPlayerUtil(aTestName, aSectName), iKeyName(aKeyName)
  1.2531 +	{}
  1.2532 +
  1.2533 +CTestMmfAclntPlayPlay* CTestMmfAclntPlayPlay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.2534 +	{
  1.2535 +	CTestMmfAclntPlayPlay* self = new (ELeave) CTestMmfAclntPlayPlay(aTestName, aSectName, aKeyName);
  1.2536 +	return self;
  1.2537 +	}
  1.2538 +
  1.2539 +
  1.2540 +/**
  1.2541 + * Open new file while audio player is playing.
  1.2542 + */
  1.2543 +TVerdict CTestMmfAclntPlayPlay::DoTestL(CMdaAudioPlayerUtility* aPlayer)
  1.2544 +	{
  1.2545 +	INFO_PRINTF1( _L("TestPlayerUtils : Play/Play"));
  1.2546 +
  1.2547 +	TVerdict ret = EFail;
  1.2548 +	iError = KErrTimedOut;
  1.2549 +
  1.2550 +	TBuf<KSizeBuf>	filename;
  1.2551 +	TPtrC			filename1; 
  1.2552 +	//if(!GetStringFromConfig(_L("SectionOne"), _L("playerAudioFile"), filename1))
  1.2553 +	if(!GetStringFromConfig(iSectName, iKeyName, filename1))
  1.2554 +		{
  1.2555 +		return EInconclusive;
  1.2556 +		}
  1.2557 +		
  1.2558 +	GetDriveName(filename);
  1.2559 +	filename.Append(filename1);
  1.2560 +
  1.2561 +	aPlayer->Play();
  1.2562 +
  1.2563 +
  1.2564 +	TInt error = KErrNone;
  1.2565 +	TRAP(error,aPlayer->OpenFileL(filename));
  1.2566 +	// wait for open to complete
  1.2567 +	CActiveScheduler::Start();
  1.2568 +	aPlayer->Play();
  1.2569 +	CActiveScheduler::Start();
  1.2570 +
  1.2571 +	if(error == KErrNone)
  1.2572 +		ret = EPass;
  1.2573 +
  1.2574 +	return ret;
  1.2575 +	}
  1.2576 +
  1.2577 +//------------------------------------------------------------------
  1.2578 +
  1.2579 +/**
  1.2580 + * Constructor
  1.2581 + */
  1.2582 +CTestMmfAclntCorruptDes::CTestMmfAclntCorruptDes(const TDesC& aTestName,const TDesC& aSectName)
  1.2583 +	{
  1.2584 +	// store the name of this test case
  1.2585 +	// this is the name that is used by the script file
  1.2586 +	// Each test step initialises it's own name
  1.2587 +	iTestStepName = aTestName; 
  1.2588 +	iSectName = aSectName;
  1.2589 +	}
  1.2590 +
  1.2591 +void CTestMmfAclntCorruptDes::MapcInitComplete(TInt aError, 
  1.2592 +								const TTimeIntervalMicroSeconds &/*aDuration*/)
  1.2593 +	{
  1.2594 +	iError = aError;
  1.2595 +	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
  1.2596 +	CActiveScheduler::Stop();
  1.2597 +	}
  1.2598 +
  1.2599 +void CTestMmfAclntCorruptDes::MapcPlayComplete(TInt aError)
  1.2600 +	{
  1.2601 +	iError = aError;
  1.2602 +	INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
  1.2603 +	CActiveScheduler::Stop();
  1.2604 +	}
  1.2605 +
  1.2606 +
  1.2607 +
  1.2608 +TVerdict  CTestMmfAclntCorruptDes::DoTestStepPreambleL()
  1.2609 +	{
  1.2610 +	RFs fs;
  1.2611 +	RFile file;
  1.2612 +	TInt size = 0;
  1.2613 +
  1.2614 +	TBuf<KSizeBuf>	filename;
  1.2615 +	TPtrC			filename1; 
  1.2616 +	if(!GetStringFromConfig(iSectName, _L("playerAudioFile"), filename1))
  1.2617 +		{
  1.2618 +		return EInconclusive;
  1.2619 +		}
  1.2620 +		
  1.2621 +	GetDriveName(filename);
  1.2622 +	filename.Append(filename1);
  1.2623 +
  1.2624 +	User::LeaveIfError(fs.Connect());
  1.2625 +	User::LeaveIfError(file.Open(fs,filename,EFileRead));
  1.2626 +	CleanupClosePushL(file);
  1.2627 +	
  1.2628 +	INFO_PRINTF2( _L("File under test - %S"), &filename);
  1.2629 +	
  1.2630 +	User::LeaveIfError(file.Size(size));
  1.2631 +	INFO_PRINTF2(_L("size of file = %d\n"),size);//Statement Changed under DEF105143
  1.2632 +	iAudio = HBufC8::NewMaxL(size);
  1.2633 +	// Buffer has not been init with data.
  1.2634 +	CleanupStack::PopAndDestroy(); //file
  1.2635 +
  1.2636 +	return CTestMmfAclntStep::DoTestStepPreambleL();
  1.2637 +	}
  1.2638 +
  1.2639 +TVerdict CTestMmfAclntCorruptDes::DoTestStepPostambleL()
  1.2640 +	{
  1.2641 +	delete iAudio;
  1.2642 +	return CTestMmfAclntStep::DoTestStepPostambleL();
  1.2643 +	}
  1.2644 +
  1.2645 +/**
  1.2646 + * Play using a corrupt descriptor.
  1.2647 + */
  1.2648 +TVerdict CTestMmfAclntCorruptDes::DoTestStepL( void )
  1.2649 +	{
  1.2650 +	INFO_PRINTF1( _L("TestPlayerUtils : Corrupt Des"));
  1.2651 +	iError = KErrTimedOut;
  1.2652 +
  1.2653 +	TPtr8 bufferDes(iAudio->Des());
  1.2654 +	CMdaAudioPlayerUtility * player = CMdaAudioPlayerUtility::NewDesPlayerL(bufferDes, *this);
  1.2655 +	CleanupStack::PushL(player);
  1.2656 +
  1.2657 +	// Wait for init callback
  1.2658 +	INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));
  1.2659 +	CActiveScheduler::Start();
  1.2660 +
  1.2661 +	if (iError == KErrBadDescriptor || iError == KErrNotSupported)
  1.2662 +		{
  1.2663 +		CleanupStack::PopAndDestroy(player);
  1.2664 +		return EPass;			
  1.2665 +		}
  1.2666 +	if (iError == KErrNone)
  1.2667 +		{
  1.2668 +		iError = KErrTimedOut;
  1.2669 +		player->Play();
  1.2670 +		// wait for play.
  1.2671 +		if (iError == KErrNone)
  1.2672 +			{
  1.2673 +			CleanupStack::PopAndDestroy(player);
  1.2674 +			return EPass;			
  1.2675 +			}
  1.2676 +		}
  1.2677 +	CleanupStack::PopAndDestroy(player);
  1.2678 +	return	EFail;
  1.2679 +	}
  1.2680 +
  1.2681 +//
  1.2682 +//=============================================================================================
  1.2683 +//
  1.2684 +
  1.2685 +CAsyncTestMmfAclntAudioRepeatPlayPausePlay* CAsyncTestMmfAclntAudioRepeatPlayPausePlay::NewL( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.2686 +	{
  1.2687 +	return new (ELeave) CAsyncTestMmfAclntAudioRepeatPlayPausePlay( aTestName, aSectName, aKeyName);
  1.2688 +	}
  1.2689 +
  1.2690 +CAsyncTestMmfAclntAudioRepeatPlayPausePlay::CAsyncTestMmfAclntAudioRepeatPlayPausePlay( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.2691 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, aKeyName)
  1.2692 +	{
  1.2693 +	}
  1.2694 +
  1.2695 +void CAsyncTestMmfAclntAudioRepeatPlayPausePlay::FsmL()
  1.2696 +	{
  1.2697 +	switch (iTestState)
  1.2698 +		{
  1.2699 +		case EStateOpened:
  1.2700 +			{
  1.2701 +			INFO_PRINTF1( _L("TestPlayerUtils : Audio Repeat/Play/Pause/Play"));
  1.2702 +			iDuration = I64INT(iPlayer->Duration().Int64());
  1.2703 +	
  1.2704 +			INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.2705 +			INFO_PRINTF2( _L("Trailing silence = %ld\n"),iSilence.Int64());
  1.2706 +			INFO_PRINTF2( _L("Repeats = %d\n"),iNumOfRepeatsSet);
  1.2707 +			iPlayer->SetRepeats(iNumOfRepeatsSet,iSilence);
  1.2708 +			
  1.2709 +			iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.2710 +			iTrigger->StartTimer(500000);
  1.2711 +			iTestState = EStatePlay;
  1.2712 +			break;
  1.2713 +			}
  1.2714 +		case EStatePlay:
  1.2715 +			{
  1.2716 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.2717 +			if(iPlayerState == EOpened)
  1.2718 +				{
  1.2719 +				iPlayer->Play();
  1.2720 +				iPlayerState = EPlaying;
  1.2721 +				iStart.HomeTime();// start the timer
  1.2722 +				
  1.2723 +				iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.2724 +				iTrigger->StartTimer(KTwoSeconds); // Call Pause for this test case after two sec
  1.2725 +				iTestState = EStatePause;
  1.2726 +				}
  1.2727 +			else if(iPlayerState == EPaused || iPlayerState == EStopped )
  1.2728 +				{
  1.2729 +				iPlayer->Play();
  1.2730 +				iStart.HomeTime();// start the timer for resuming playback
  1.2731 +				iPlayerState = EPlaying;	
  1.2732 +				}
  1.2733 +			break;
  1.2734 +			}
  1.2735 +		case EStatePause:
  1.2736 +			{
  1.2737 +			if(iPlayerState == EPlaying)
  1.2738 +				{
  1.2739 +				INFO_PRINTF1( _L("Pause CMdaAudioPlayerUtility"));
  1.2740 +				iPlayer->Pause();
  1.2741 +				iStop.HomeTime();
  1.2742 +				
  1.2743 +				iPausedDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64());
  1.2744 +				
  1.2745 +				iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.2746 +				iTrigger->StartTimer(KTwoSeconds); // Resume after two seconds
  1.2747 +				iPlayerState = EPaused;
  1.2748 +				iTestState = EStatePlay;
  1.2749 +				}
  1.2750 +			break;	
  1.2751 +			}
  1.2752 +		case EStateStopTest:
  1.2753 +			{
  1.2754 +			if(iDuration)
  1.2755 +				{
  1.2756 +				iStop.HomeTime();
  1.2757 +				iResumedDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64()); 
  1.2758 +				iActualDuration = iPausedDuration + iResumedDuration;
  1.2759 +				INFO_PRINTF2( _L("Clip Duration = %d "),iDuration);
  1.2760 +				INFO_PRINTF2( _L("Actual Duration = %u "),iActualDuration);
  1.2761 +				INFO_PRINTF2( _L("Expected Duration = %d "),iDuration *(iNumOfRepeatsSet+1));
  1.2762 +				
  1.2763 +				#ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
  1.2764 +					if(TimeComparison(iActualDuration, iDuration * (iNumOfRepeatsSet + 1),
  1.2765 +													   2*KExpectedDeviation))//more because of the latency during pausing
  1.2766 +						{
  1.2767 +						StopTest(); // success
  1.2768 +						break;	
  1.2769 +						}
  1.2770 +					else
  1.2771 +						{
  1.2772 +						STOP_TEST_GEN_ERROR;
  1.2773 +						break;	
  1.2774 +						}
  1.2775 +				#else
  1.2776 +					if(TimeComparison(iActualDuration, iDuration * (iNumOfRepeatsSet + 1),
  1.2777 +													   2*iNumOfRepeatsSet*KExpectedDeviation))
  1.2778 +						{
  1.2779 +						StopTest(); // success
  1.2780 +						break;	
  1.2781 +						}
  1.2782 +					else
  1.2783 +						{
  1.2784 +						STOP_TEST_GEN_ERROR;
  1.2785 +						break;	
  1.2786 +						}
  1.2787 +				#endif
  1.2788 +				}
  1.2789 +			else // In case of .sqn file there will be no duration
  1.2790 +				{
  1.2791 +				StopTest();
  1.2792 +				break;
  1.2793 +				}
  1.2794 +			}
  1.2795 +			
  1.2796 +		default:
  1.2797 +				STOP_TEST_GEN_ERROR;
  1.2798 +				break;
  1.2799 +		}
  1.2800 +	}
  1.2801 +	
  1.2802 +CAsyncTestMmfAclntAudioRepeatPlayRepositionPlay* CAsyncTestMmfAclntAudioRepeatPlayRepositionPlay::NewL( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, const TTimeIntervalMicroSeconds aPosition)
  1.2803 +	{
  1.2804 +	return new (ELeave) CAsyncTestMmfAclntAudioRepeatPlayRepositionPlay( aTestName, aSectName, aKeyName, aPosition);
  1.2805 +	}
  1.2806 +
  1.2807 +CAsyncTestMmfAclntAudioRepeatPlayRepositionPlay::CAsyncTestMmfAclntAudioRepeatPlayRepositionPlay( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, const TTimeIntervalMicroSeconds aPosition)
  1.2808 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, aKeyName), iPosition(aPosition)
  1.2809 +	{
  1.2810 +	}
  1.2811 +
  1.2812 +void CAsyncTestMmfAclntAudioRepeatPlayRepositionPlay::FsmL()
  1.2813 +	{
  1.2814 +	switch (iTestState)
  1.2815 +		{
  1.2816 +		case EStateOpened:
  1.2817 +			{
  1.2818 +			INFO_PRINTF1( _L("TestPlayerUtils : Audio Play/Reposition/Play"));
  1.2819 +			iDuration = I64INT(iPlayer->Duration().Int64());
  1.2820 +			INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.2821 +			INFO_PRINTF2( _L("Repeats = %d\n"),iNumOfRepeatsSet);
  1.2822 +			iPlayer->SetRepeats(iNumOfRepeatsSet,iSilence);
  1.2823 +			
  1.2824 +			iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.2825 +			iTrigger->StartTimer(500000);
  1.2826 +			iTestState = EStatePlay;
  1.2827 +			break;
  1.2828 +			}
  1.2829 +		case EStatePlay:
  1.2830 +			{
  1.2831 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.2832 +			if(iPlayerState == EOpened)
  1.2833 +				{
  1.2834 +				iPlayer->Play();
  1.2835 +				iPlayerState = EPlaying;
  1.2836 +				iStart.HomeTime();// start the timer
  1.2837 +				
  1.2838 +				iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.2839 +				iTrigger->StartTimer(KOneSecond); // Call Setposition for this test case after two sec
  1.2840 +				iTestState = EStateSetPosition;
  1.2841 +				}
  1.2842 +			break;
  1.2843 +			}
  1.2844 +		case EStateSetPosition:
  1.2845 +			{
  1.2846 +			if(iPlayerState == EPlaying)
  1.2847 +				{
  1.2848 +				INFO_PRINTF1( _L("SetPosition CMdaAudioPlayerUtility"));
  1.2849 +				iPlayer->SetPosition(iPosition);
  1.2850 +				iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.2851 +				}
  1.2852 +			break;	
  1.2853 +			}
  1.2854 +		case EStateStopTest:
  1.2855 +			{
  1.2856 +			if(iDuration)
  1.2857 +				{
  1.2858 +				iStop.HomeTime();
  1.2859 +				iResumedDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64()); 
  1.2860 +				iActualDuration = iPausedDuration + iResumedDuration;
  1.2861 +				INFO_PRINTF2( _L("Clip Duration = %d "),iDuration);
  1.2862 +				INFO_PRINTF2( _L("Actual Duration = %u "),iActualDuration);
  1.2863 +				INFO_PRINTF2( _L("Expected Duration = %d "),iDuration *(iNumOfRepeatsSet+1));
  1.2864 +				
  1.2865 +				#ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
  1.2866 +				if(TimeComparison(iActualDuration, (iDuration * (iNumOfRepeatsSet + 1))+1,
  1.2867 +												   2*KExpectedDeviation))//more because of the latency during repositioning
  1.2868 +					{
  1.2869 +					StopTest(); // success
  1.2870 +					}
  1.2871 +				else
  1.2872 +					{
  1.2873 +					STOP_TEST_GEN_ERROR;
  1.2874 +					}
  1.2875 +				#else
  1.2876 +				if(TimeComparison(iActualDuration, (iDuration * (iNumOfRepeatsSet + 1))+1,
  1.2877 +												   2*iNumOfRepeatsSet*KExpectedDeviation))//more because of the latency during repositioning
  1.2878 +					{
  1.2879 +					StopTest(); // success
  1.2880 +					}
  1.2881 +				else
  1.2882 +					{
  1.2883 +					STOP_TEST_GEN_ERROR;
  1.2884 +					}
  1.2885 +				#endif
  1.2886 +				break;
  1.2887 +				}
  1.2888 +			else // In case of .sqn file there will be no duration
  1.2889 +				{
  1.2890 +				StopTest();
  1.2891 +				break;
  1.2892 +				}
  1.2893 +		
  1.2894 +			}
  1.2895 +			
  1.2896 +		default:
  1.2897 +			STOP_TEST_GEN_ERROR;
  1.2898 +			break;
  1.2899 +		}
  1.2900 +	}
  1.2901 +	
  1.2902 +//============================================================================================================
  1.2903 +
  1.2904 +
  1.2905 +CAsyncTestMmfAclntAudioRepeatPlayPauseRepeatPlay* CAsyncTestMmfAclntAudioRepeatPlayPauseRepeatPlay::NewL( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.2906 +	{
  1.2907 +	return new (ELeave) CAsyncTestMmfAclntAudioRepeatPlayPauseRepeatPlay( aTestName, aSectName, aKeyName);
  1.2908 +	}
  1.2909 +
  1.2910 +CAsyncTestMmfAclntAudioRepeatPlayPauseRepeatPlay::CAsyncTestMmfAclntAudioRepeatPlayPauseRepeatPlay( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.2911 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, aKeyName)
  1.2912 +	{
  1.2913 +	}
  1.2914 +
  1.2915 +void CAsyncTestMmfAclntAudioRepeatPlayPauseRepeatPlay::FsmL()
  1.2916 +	{
  1.2917 +	switch (iTestState)
  1.2918 +	{
  1.2919 +		case EStateOpened:
  1.2920 +			{
  1.2921 +			INFO_PRINTF1( _L("TestPlayerUtils : Audio Repeat/Play/Pause/Repeat/Play"));
  1.2922 +			iDuration = I64INT(iPlayer->Duration().Int64());
  1.2923 +			INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.2924 +			INFO_PRINTF2( _L("Repeats = %d\n"),iNumOfRepeatsSet );
  1.2925 +			iPlayer->SetRepeats(iNumOfRepeatsSet,iSilence);
  1.2926 +			
  1.2927 +			iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.2928 +			iTrigger->StartTimer(500000);
  1.2929 +			iTestState = EStatePlay;
  1.2930 +			break;	
  1.2931 +			}
  1.2932 +		case EStatePlay:
  1.2933 +			{
  1.2934 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.2935 +			if(iPlayerState == EOpened)
  1.2936 +				{
  1.2937 +				iPlayer->Play();	
  1.2938 +				iPlayerState = EPlaying;
  1.2939 +				iStart.HomeTime();
  1.2940 +				
  1.2941 +				iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.2942 +				iTrigger->StartTimer(KTwoSeconds); // Call Pause for this test case after two sec
  1.2943 +				iTestState = EStatePause;
  1.2944 +				}
  1.2945 +			else if(iPlayerState == EPaused || iPlayerState == EStopped )
  1.2946 +				{
  1.2947 +				iPlayer->Play(); // wait till play completes
  1.2948 +				iStart.HomeTime();// start the timer after resuming playback
  1.2949 +				iPlayerState = EPlaying;	
  1.2950 +				}
  1.2951 +			break;
  1.2952 +			}
  1.2953 +		case EStatePause:
  1.2954 +			{
  1.2955 +			if(iPlayerState == EPlaying)
  1.2956 +				{
  1.2957 +				INFO_PRINTF1( _L("Pause CMdaAudioPlayerUtility"));
  1.2958 +				iPlayer->Pause();
  1.2959 +				iStop.HomeTime();
  1.2960 +				
  1.2961 +				iPausedDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64());
  1.2962 +				//Now Set New Repeat Value
  1.2963 +				if(!GetIntFromConfig(_L("SectionRepeatCount"), _L("newRepeatValue"), iNumOfRepeatsSet))
  1.2964 +					{
  1.2965 +					ERR_PRINTF1(_L("GetIntFromConfig Failed"));
  1.2966 +					StopTest(KErrGeneral, EInconclusive);
  1.2967 +					return;
  1.2968 +					}
  1.2969 +				INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.2970 +				INFO_PRINTF2( _L("Repeats = %d\n"),iNumOfRepeatsSet);
  1.2971 +				iPlayer->SetRepeats(iNumOfRepeatsSet,iSilence);
  1.2972 +				
  1.2973 +				iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.2974 +				iTrigger->StartTimer(KTwoSeconds); // Resume after two seconds
  1.2975 +				iPlayerState = EPaused;
  1.2976 +				iTestState = EStatePlay;
  1.2977 +				}
  1.2978 +			break;	
  1.2979 +			}
  1.2980 +		case EStateStopTest:
  1.2981 +			{
  1.2982 +			if(iDuration)
  1.2983 +				{
  1.2984 +				iStop.HomeTime();
  1.2985 +				iResumedDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64()); 
  1.2986 +				iActualDuration = iPausedDuration + iResumedDuration;
  1.2987 +				INFO_PRINTF2( _L("Clip Duration = %d "),iDuration);
  1.2988 +				INFO_PRINTF2( _L("Actual Duration = %u "),iActualDuration);
  1.2989 +				INFO_PRINTF2( _L("Expected Duration = %d "),iDuration *(iNumOfRepeatsSet+1));
  1.2990 +				#ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
  1.2991 +				if(TimeComparison(iActualDuration, iDuration * (iNumOfRepeatsSet + 1),
  1.2992 +												   KExpectedDeviation * 2))//more because of latency during Pausing
  1.2993 +					{
  1.2994 +					StopTest(); // success
  1.2995 +					}
  1.2996 +				else
  1.2997 +					{
  1.2998 +					STOP_TEST_GEN_ERROR;
  1.2999 +					}
  1.3000 +				#else
  1.3001 +					if(TimeComparison(iActualDuration, iDuration * (iNumOfRepeatsSet + 1),
  1.3002 +												   KExpectedDeviation * 2*iNumOfRepeatsSet))//more because of latency during Pausing
  1.3003 +					{
  1.3004 +					StopTest(); // success
  1.3005 +					}
  1.3006 +				else
  1.3007 +					{
  1.3008 +					STOP_TEST_GEN_ERROR;
  1.3009 +					}
  1.3010 +					#endif
  1.3011 +				break;	
  1.3012 +				}
  1.3013 +			else
  1.3014 +				{
  1.3015 +				StopTest(); // success
  1.3016 +				break;		
  1.3017 +				}
  1.3018 +			}
  1.3019 +		
  1.3020 +			
  1.3021 +		default:
  1.3022 +			ERR_PRINTF1(_L("State machine error"));
  1.3023 +			STOP_TEST_GEN_ERROR;
  1.3024 +			break;
  1.3025 +		}
  1.3026 +	}
  1.3027 +	
  1.3028 +//============================================================================================================
  1.3029 +
  1.3030 +CAsyncTestMmfAclntAudioPlayPauseRepeatPlay* CAsyncTestMmfAclntAudioPlayPauseRepeatPlay::NewL( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3031 +	{
  1.3032 +	return new (ELeave) CAsyncTestMmfAclntAudioPlayPauseRepeatPlay( aTestName, aSectName, aKeyName);
  1.3033 +	}
  1.3034 +
  1.3035 +CAsyncTestMmfAclntAudioPlayPauseRepeatPlay::CAsyncTestMmfAclntAudioPlayPauseRepeatPlay( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3036 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, aKeyName)
  1.3037 +	{
  1.3038 +	}
  1.3039 +
  1.3040 +void CAsyncTestMmfAclntAudioPlayPauseRepeatPlay::FsmL()
  1.3041 +	{
  1.3042 +	switch (iTestState)
  1.3043 +		{
  1.3044 +		case EStateOpened:
  1.3045 +			{
  1.3046 +			INFO_PRINTF1( _L("TestPlayerUtils : Audio Play/Pause/Repeat/Play"));
  1.3047 +			iDuration = I64INT(iPlayer->Duration().Int64());
  1.3048 +			iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.3049 +			iTrigger->StartTimer(500000);
  1.3050 +			iTestState = EStatePlay;
  1.3051 +			break;
  1.3052 +			}
  1.3053 +		case EStatePlay:
  1.3054 +			{
  1.3055 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.3056 +			if(iPlayerState == EOpened)
  1.3057 +				{
  1.3058 +				iPlayer->Play();	
  1.3059 +				iPlayerState = EPlaying;
  1.3060 +				iStart.HomeTime();
  1.3061 +				
  1.3062 +				iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.3063 +				iTrigger->StartTimer(KOneSecond); // Call Pause for this test case after two sec
  1.3064 +				iTestState = EStatePause;
  1.3065 +				}
  1.3066 +			else if(iPlayerState == EPaused || iPlayerState == EStopped )
  1.3067 +				{
  1.3068 +				iPlayer->Play(); // wait till play completes
  1.3069 +				iStart.HomeTime();//start the timer after resuming playback
  1.3070 +				
  1.3071 +				iPlayerState = EPlaying;
  1.3072 +				}
  1.3073 +			break;
  1.3074 +			}
  1.3075 +		case EStatePause:
  1.3076 +			{
  1.3077 +			if(iPlayerState == EPlaying)
  1.3078 +				{
  1.3079 +				INFO_PRINTF1(_L("Pause CMdaAudioPlayerUtility"));
  1.3080 +				iPlayer->Pause();
  1.3081 +				iStop.HomeTime();
  1.3082 +				
  1.3083 +				iPausedDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64());
  1.3084 +				
  1.3085 +				iPlayerState = EPaused;
  1.3086 +				
  1.3087 +				INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.3088 +				INFO_PRINTF2( _L("Repeats = %d\n"),iNumOfRepeatsSet);
  1.3089 +				iPlayer->SetRepeats(iNumOfRepeatsSet,iSilence);
  1.3090 +				
  1.3091 +				iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.3092 +				iTrigger->StartTimer(KOneSecond); // Resume after one seconds
  1.3093 +				iTestState = EStatePlay;
  1.3094 +				}
  1.3095 +			break;	
  1.3096 +			}
  1.3097 +		case EStateStopTest:
  1.3098 +			{
  1.3099 +			if(iDuration)
  1.3100 +				{
  1.3101 +				iStop.HomeTime();
  1.3102 +				iResumedDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64()); 
  1.3103 +				iActualDuration = iPausedDuration + iResumedDuration;
  1.3104 +				INFO_PRINTF2( _L("Clip Duration = %d "),iDuration);
  1.3105 +				INFO_PRINTF2( _L("Actual Duration = %u "),iActualDuration);
  1.3106 +				INFO_PRINTF2( _L("Expected Duration = %d "),iDuration *(iNumOfRepeatsSet+1));
  1.3107 +				#ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
  1.3108 +				if(TimeComparison(iActualDuration, iDuration * (iNumOfRepeatsSet + 1),
  1.3109 +												   KExpectedDeviation * 2))//more because of latency during pausing
  1.3110 +					{
  1.3111 +					StopTest(); // success
  1.3112 +					break;	
  1.3113 +					}
  1.3114 +				else
  1.3115 +					{
  1.3116 +					STOP_TEST_GEN_ERROR;
  1.3117 +					}
  1.3118 +				#else
  1.3119 +				if(TimeComparison(iActualDuration, iDuration * (iNumOfRepeatsSet + 1),
  1.3120 +												   KExpectedDeviation *iNumOfRepeatsSet* 2))//more because of latency during pausing
  1.3121 +					{
  1.3122 +					StopTest(); // success
  1.3123 +					}
  1.3124 +				else
  1.3125 +					{
  1.3126 +					STOP_TEST_GEN_ERROR;
  1.3127 +					}
  1.3128 +				#endif
  1.3129 +				break;
  1.3130 +				}
  1.3131 +			else
  1.3132 +				{
  1.3133 +				StopTest(); // success
  1.3134 +				break;	
  1.3135 +				}
  1.3136 +			}
  1.3137 +			
  1.3138 +		default:
  1.3139 +				STOP_TEST_GEN_ERROR;
  1.3140 +				break;
  1.3141 +		}
  1.3142 +	}
  1.3143 +	
  1.3144 +//============================================================================================================
  1.3145 +
  1.3146 +CAsyncTestMmfAclntAudioPlayRepeat* CAsyncTestMmfAclntAudioPlayRepeat::NewL( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3147 +	{
  1.3148 +	return new (ELeave) CAsyncTestMmfAclntAudioPlayRepeat( aTestName, aSectName, aKeyName);
  1.3149 +	}
  1.3150 +
  1.3151 +CAsyncTestMmfAclntAudioPlayRepeat::CAsyncTestMmfAclntAudioPlayRepeat( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3152 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, aKeyName)
  1.3153 +	{
  1.3154 +	}
  1.3155 +
  1.3156 +void CAsyncTestMmfAclntAudioPlayRepeat::FsmL()
  1.3157 +	{
  1.3158 +	switch (iTestState)
  1.3159 +		{
  1.3160 +		case EStateOpened:
  1.3161 +			{
  1.3162 +			INFO_PRINTF1( _L("TestPlayerUtils : Audio Play/Repeat"));
  1.3163 +			iDuration = I64INT(iPlayer->Duration().Int64());
  1.3164 +			iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.3165 +			iTrigger->StartTimer(500000);
  1.3166 +			iTestState = EStatePlay;
  1.3167 +			break;
  1.3168 +			}
  1.3169 +		case EStatePlay:
  1.3170 +			{
  1.3171 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.3172 +			if(iPlayerState == EOpened)
  1.3173 +				{
  1.3174 +				iPlayer->Play();	
  1.3175 +				iPlayerState = EPlaying;
  1.3176 +				iStart.HomeTime();// Start the timer
  1.3177 +			
  1.3178 +				TTimeIntervalMicroSeconds silence(0); // silence gap
  1.3179 +				INFO_PRINTF1( _L("SetRepeats with higher value CMdaAudioPlayerUtility"));
  1.3180 +				if(!GetIntFromConfig(_L("SectionRepeatCount"), _L("maxRepeatValue"), iNumOfRepeatsSet))
  1.3181 +					{
  1.3182 +					ERR_PRINTF1(_L("GetIntFromConfig Failed"));
  1.3183 +					StopTest(KErrGeneral, EInconclusive);
  1.3184 +					break;
  1.3185 +					}
  1.3186 +				INFO_PRINTF2( _L("Repeats = %d\n"),iNumOfRepeatsSet);
  1.3187 +				iPlayer->SetRepeats(iNumOfRepeatsSet,iSilence);
  1.3188 +				}
  1.3189 +			break;
  1.3190 +			}
  1.3191 +		case EStateStopTest:
  1.3192 +			{
  1.3193 +			if(iDuration)
  1.3194 +				{
  1.3195 +				iStop.HomeTime();
  1.3196 +				iActualDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64()); 
  1.3197 +				INFO_PRINTF2( _L("Clip Duration = %d "),iDuration);
  1.3198 +				INFO_PRINTF2( _L("Actual Duration = %u "),iActualDuration);
  1.3199 +				INFO_PRINTF2( _L("Expected Duration = %d "),iDuration *(iNumOfRepeatsSet+1));
  1.3200 +				#ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
  1.3201 +				if(TimeComparison(iActualDuration, iDuration * (iNumOfRepeatsSet + 1),
  1.3202 +												   KExpectedDeviation))
  1.3203 +					{
  1.3204 +					StopTest(); // success
  1.3205 +					}
  1.3206 +				else
  1.3207 +					{
  1.3208 +					if(TimeComparison(iActualDuration, (iDuration + 100000) * (iNumOfRepeatsSet + 1),
  1.3209 +												   KExpectedDeviation))
  1.3210 +						{
  1.3211 +						StopTest(KErrGeneral, EKnownFailure);
  1.3212 +						}
  1.3213 +					else
  1.3214 +						{
  1.3215 +						STOP_TEST_GEN_ERROR;
  1.3216 +						}
  1.3217 +					}
  1.3218 +				#else
  1.3219 +				if(TimeComparison(iActualDuration, iDuration * (iNumOfRepeatsSet + 1),
  1.3220 +											   KExpectedDeviation*iNumOfRepeatsSet))
  1.3221 +					{
  1.3222 +					StopTest(); // success
  1.3223 +					}
  1.3224 +				else
  1.3225 +					{
  1.3226 +					STOP_TEST_GEN_ERROR;
  1.3227 +					}
  1.3228 +				#endif	
  1.3229 +				break;	
  1.3230 +				}
  1.3231 +			else
  1.3232 +				{
  1.3233 +				StopTest(); // success
  1.3234 +				break;		
  1.3235 +				}
  1.3236 +			}			
  1.3237 +		default:
  1.3238 +				STOP_TEST_GEN_ERROR;
  1.3239 +				break;
  1.3240 +		}
  1.3241 +	}
  1.3242 +
  1.3243 +//============================================================================================================
  1.3244 +
  1.3245 +CAsyncTestMmfAclntAudioRepeatBeforeOpen* CAsyncTestMmfAclntAudioRepeatBeforeOpen::NewL( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3246 +	{
  1.3247 +	return new (ELeave) CAsyncTestMmfAclntAudioRepeatBeforeOpen( aTestName, aSectName, aKeyName);
  1.3248 +	}
  1.3249 +
  1.3250 +CAsyncTestMmfAclntAudioRepeatBeforeOpen::CAsyncTestMmfAclntAudioRepeatBeforeOpen( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3251 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, aKeyName)
  1.3252 +	{
  1.3253 +	}
  1.3254 +
  1.3255 +void CAsyncTestMmfAclntAudioRepeatBeforeOpen::KickoffTestL( void )
  1.3256 +	{
  1.3257 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Player Util"));
  1.3258 +	TPtrC			filename1; 
  1.3259 +	TInt			repeatCount;
  1.3260 +	
  1.3261 +	if(!GetStringFromConfig(iSectName, iKeyName, filename1))
  1.3262 +		{
  1.3263 +		ERR_PRINTF1(_L("GetStringFromConfig Failed"));
  1.3264 +		StopTest(KErrGeneral, EInconclusive);
  1.3265 +		return;
  1.3266 +		}
  1.3267 +	if(!GetIntFromConfig(_L("SectionRepeatCount"), _L("numOfRepeat"), repeatCount))
  1.3268 +		{
  1.3269 +		ERR_PRINTF1(_L("GetIntFromConfig Failed"));
  1.3270 +		StopTest(KErrGeneral, EInconclusive);
  1.3271 +		return;
  1.3272 +		}
  1.3273 +	iNumOfRepeatsSet = 	repeatCount;
  1.3274 +	GetDriveName(iFileName);
  1.3275 +	iFileName.Append(filename1);
  1.3276 +	INFO_PRINTF2(_L("CMdaAudioPlayerUtility::NewFilePlayerL() - %S"), &iFileName);
  1.3277 +	iTrigger = CFsmTrigger::NewL(*this);
  1.3278 +		
  1.3279 +	iPlayer = CMdaAudioPlayerUtility::NewL(*this);
  1.3280 +	
  1.3281 +	TTimeIntervalMicroSeconds trailingSilence(1); 
  1.3282 +	INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility before opening the clip"));
  1.3283 +	iNumOfRepeatsSet = NUMBER_OF_REPEATS;
  1.3284 +	INFO_PRINTF2( _L("Repeats = %d\n"),iNumOfRepeatsSet);
  1.3285 +	iPlayer->SetRepeats(iNumOfRepeatsSet,trailingSilence);
  1.3286 +	iPlayer->OpenFileL(iFileName);
  1.3287 +	iPlayerState = EOpening;
  1.3288 +	}
  1.3289 +
  1.3290 +void CAsyncTestMmfAclntAudioRepeatBeforeOpen::FsmL()
  1.3291 +	{
  1.3292 +	switch (iTestState)
  1.3293 +		{
  1.3294 +		case EStateOpened:
  1.3295 +			{
  1.3296 +			iDuration = I64INT(iPlayer->Duration().Int64());
  1.3297 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.3298 +			if(iPlayerState == EOpened)
  1.3299 +				{
  1.3300 +				iPlayer->Play();	
  1.3301 +				iPlayerState = EPlaying;
  1.3302 +				iStart.HomeTime();// Start the timer
  1.3303 +				}
  1.3304 +			break;
  1.3305 +			}
  1.3306 +		case EStateStopTest:
  1.3307 +			{
  1.3308 +			if(iDuration)
  1.3309 +				{
  1.3310 +				iStop.HomeTime();
  1.3311 +				iActualDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64()); 
  1.3312 +				INFO_PRINTF2( _L("Clip Duration = %d "),iDuration);
  1.3313 +				INFO_PRINTF2( _L("Actual Duration = %u "),iActualDuration);
  1.3314 +				INFO_PRINTF2( _L("Expected Duration = %d "),iDuration *(iNumOfRepeatsSet+1));
  1.3315 +				#ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
  1.3316 +				if(TimeComparison(iActualDuration, iDuration * (iNumOfRepeatsSet + 1),
  1.3317 +												   KExpectedDeviation))
  1.3318 +					{
  1.3319 +					StopTest(); // success
  1.3320 +					}
  1.3321 +				else
  1.3322 +					{
  1.3323 +					STOP_TEST_GEN_ERROR;
  1.3324 +					}
  1.3325 +				#else
  1.3326 +				if(TimeComparison(iActualDuration, iDuration * (iNumOfRepeatsSet + 1),
  1.3327 +												   KExpectedDeviation*iNumOfRepeatsSet))
  1.3328 +					{
  1.3329 +					StopTest(); // success
  1.3330 +					}
  1.3331 +				else
  1.3332 +					{
  1.3333 +					STOP_TEST_GEN_ERROR;
  1.3334 +					}
  1.3335 +				#endif
  1.3336 +				break;
  1.3337 +				}
  1.3338 +			else
  1.3339 +				{
  1.3340 +				StopTest(); // success
  1.3341 +				break;		
  1.3342 +				}
  1.3343 +			}			
  1.3344 +		default:
  1.3345 +				STOP_TEST_GEN_ERROR;
  1.3346 +				break;
  1.3347 +		}
  1.3348 +	}
  1.3349 +		
  1.3350 +//============================================================================================================
  1.3351 +
  1.3352 +CAsyncTestMmfAclntAudioPlayRepeatPauseRepeatPlay* CAsyncTestMmfAclntAudioPlayRepeatPauseRepeatPlay::NewL( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3353 +	{
  1.3354 +	return new (ELeave) CAsyncTestMmfAclntAudioPlayRepeatPauseRepeatPlay( aTestName, aSectName, aKeyName);
  1.3355 +	}
  1.3356 +
  1.3357 +CAsyncTestMmfAclntAudioPlayRepeatPauseRepeatPlay::CAsyncTestMmfAclntAudioPlayRepeatPauseRepeatPlay( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3358 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, aKeyName)
  1.3359 +	{
  1.3360 +	}
  1.3361 +
  1.3362 +void CAsyncTestMmfAclntAudioPlayRepeatPauseRepeatPlay::FsmL()
  1.3363 +	{
  1.3364 +	switch (iTestState)
  1.3365 +		{
  1.3366 +		case EStateOpened:
  1.3367 +			{
  1.3368 +			INFO_PRINTF1( _L("TestPlayerUtils : Audio Play/Repeat/Pause/Repeat/Play"));
  1.3369 +			iDuration = I64INT(iPlayer->Duration().Int64());
  1.3370 +			iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.3371 +			iTrigger->StartTimer(500000);
  1.3372 +			iTestState = EStatePlay;
  1.3373 +			break;
  1.3374 +			}
  1.3375 +		case EStateSetRepeat:
  1.3376 +			{
  1.3377 +			INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.3378 +			INFO_PRINTF2( _L("Repeats = %d"),iNumOfRepeatsSet);
  1.3379 +			iPlayer->SetRepeats(iNumOfRepeatsSet,iSilence);
  1.3380 +			
  1.3381 +			iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.3382 +			iTrigger->StartTimer(KOneSecond);// Call Pause after two seconds  
  1.3383 +			iTestState = EStatePause;
  1.3384 +			break;	
  1.3385 +			}
  1.3386 +		case EStatePlay:
  1.3387 +			{
  1.3388 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.3389 +			if(iPlayerState == EOpened)
  1.3390 +				{
  1.3391 +				iPlayer->Play();	
  1.3392 +				iPlayerState = EPlaying;
  1.3393 +				iStart.HomeTime();
  1.3394 +				
  1.3395 +				iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.3396 +				iTrigger->StartTimer(500000);
  1.3397 +				iTestState = EStateSetRepeat;
  1.3398 +				}
  1.3399 +			else if(iPlayerState == EPaused || iPlayerState == EStopped )
  1.3400 +				{
  1.3401 +				iPlayer->Play(); // wait till play completes
  1.3402 +				iStart.HomeTime();
  1.3403 +				iPlayerState = EPlaying;	
  1.3404 +				}
  1.3405 +			break;
  1.3406 +			}
  1.3407 +		case EStatePause:
  1.3408 +			{
  1.3409 +			if(iPlayerState == EPlaying)
  1.3410 +				{
  1.3411 +				INFO_PRINTF1( _L("Pause CMdaAudioPlayerUtility"));
  1.3412 +				iPlayer->Pause();
  1.3413 +				iStop.HomeTime();
  1.3414 +				iPausedDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64());
  1.3415 +				
  1.3416 +					//Now Set New Repeat Value
  1.3417 +				if(!GetIntFromConfig(_L("SectionRepeatCount"), _L("newRepeatValue"), iNumOfRepeatsSet))
  1.3418 +					{
  1.3419 +					ERR_PRINTF1(_L("GetIntFromConfig Failed"));
  1.3420 +					StopTest(KErrGeneral, EInconclusive);
  1.3421 +					break;
  1.3422 +					}
  1.3423 +				INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.3424 +				INFO_PRINTF2( _L("Repeats = %d"),iNumOfRepeatsSet);
  1.3425 +				iPlayer->SetRepeats(iNumOfRepeatsSet,iSilence);
  1.3426 +				
  1.3427 +				iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.3428 +				iTrigger->StartTimer(KTwoSeconds); // Resume after two seconds
  1.3429 +				iPlayerState = EPaused;
  1.3430 +				iTestState = EStatePlay;
  1.3431 +				}
  1.3432 +			break;	
  1.3433 +			}
  1.3434 +		case EStateStopTest:
  1.3435 +			{
  1.3436 +			if(iDuration)
  1.3437 +				{
  1.3438 +				iStop.HomeTime();
  1.3439 +				iResumedDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64()); 
  1.3440 +				iActualDuration = iPausedDuration + iResumedDuration;
  1.3441 +				INFO_PRINTF2( _L("Clip Duration = %d "),iDuration);
  1.3442 +				INFO_PRINTF2( _L("Actual Duration = %u "),iActualDuration);
  1.3443 +				INFO_PRINTF2( _L("Expected Duration = %d "),iDuration *(iNumOfRepeatsSet+1));
  1.3444 +				#ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
  1.3445 +				if(TimeComparison(iActualDuration, iDuration * (iNumOfRepeatsSet + 1),
  1.3446 +												   KExpectedDeviation * 2))
  1.3447 +					{
  1.3448 +					StopTest(); // success
  1.3449 +					}
  1.3450 +				else
  1.3451 +					{
  1.3452 +					STOP_TEST_GEN_ERROR;
  1.3453 +					}					
  1.3454 +				#else
  1.3455 +				if(TimeComparison(iActualDuration, iDuration * (iNumOfRepeatsSet + 1),
  1.3456 +												   KExpectedDeviation * iNumOfRepeatsSet* 2))
  1.3457 +					{
  1.3458 +					StopTest(); // success
  1.3459 +					}
  1.3460 +				else
  1.3461 +					{
  1.3462 +					STOP_TEST_GEN_ERROR;
  1.3463 +					}
  1.3464 +				#endif
  1.3465 +				break;
  1.3466 +				}
  1.3467 +			else
  1.3468 +				{
  1.3469 +				StopTest(); // success
  1.3470 +				break;		
  1.3471 +				}
  1.3472 +			}
  1.3473 +		default:
  1.3474 +				STOP_TEST_GEN_ERROR;
  1.3475 +				break;
  1.3476 +		}
  1.3477 +	}
  1.3478 +	
  1.3479 +//============================================================================================================
  1.3480 +
  1.3481 +
  1.3482 +CAsyncTestMmfAclntAudioRepeatPlayStopPlay* CAsyncTestMmfAclntAudioRepeatPlayStopPlay::NewL( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3483 +	{
  1.3484 +	return new (ELeave) CAsyncTestMmfAclntAudioRepeatPlayStopPlay( aTestName, aSectName, aKeyName);
  1.3485 +	}
  1.3486 +
  1.3487 +CAsyncTestMmfAclntAudioRepeatPlayStopPlay::CAsyncTestMmfAclntAudioRepeatPlayStopPlay( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3488 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, aKeyName)
  1.3489 +	{
  1.3490 +	}
  1.3491 +
  1.3492 +void CAsyncTestMmfAclntAudioRepeatPlayStopPlay::FsmL()
  1.3493 +	{
  1.3494 +	switch (iTestState)
  1.3495 +		{
  1.3496 +		case EStateOpened:
  1.3497 +			{
  1.3498 +			INFO_PRINTF1( _L("TestPlayerUtils : Audio Repeat/Play/Stop/Play"));
  1.3499 +			iDuration = I64INT(iPlayer->Duration().Int64());
  1.3500 +			INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.3501 +			INFO_PRINTF2( _L("Repeats = %d\n"),iNumOfRepeatsSet);
  1.3502 +			iPlayer->SetRepeats(iNumOfRepeatsSet,iSilence);
  1.3503 +			
  1.3504 +			iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.3505 +			iTrigger->StartTimer(500000);
  1.3506 +			iTestState = EStatePlay;
  1.3507 +			break;
  1.3508 +			}
  1.3509 +		case EStatePlay:
  1.3510 +			{
  1.3511 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.3512 +			if(iPlayerState == EOpened)
  1.3513 +				{
  1.3514 +				iPlayer->Play();
  1.3515 +				iStart.HomeTime();
  1.3516 +				
  1.3517 +				iPlayerState = EPlaying;
  1.3518 +				iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.3519 +				iTrigger->StartTimer(KOneSecond); // Call Stop for this test case after two sec
  1.3520 +				iTestState = EStateStop;
  1.3521 +				}
  1.3522 +			else if(iPlayerState == EPaused || iPlayerState == EStopped )
  1.3523 +				{
  1.3524 +				iPlayer->Play(); // wait till play completes
  1.3525 +				iStart.HomeTime();
  1.3526 +				iPlayerState = EPlaying;	
  1.3527 +				}
  1.3528 +			break;
  1.3529 +			}
  1.3530 +		case EStateStop:
  1.3531 +			{
  1.3532 +			INFO_PRINTF1( _L("Stop CMdaAudioPlayerUtility"));
  1.3533 +			iPlayer->Stop();
  1.3534 +			iPlayerState = EStopped;
  1.3535 +			iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.3536 +			iTrigger->StartTimer(KTwoSeconds); // Call Pause for this test case after two sec
  1.3537 +			iTestState = EStatePlay;
  1.3538 +			break;
  1.3539 +			}	
  1.3540 +		case EStateStopTest:
  1.3541 +			{
  1.3542 +			if(iDuration)
  1.3543 +				{
  1.3544 +				iStop.HomeTime();
  1.3545 +				iActualDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64());
  1.3546 +				INFO_PRINTF2( _L("Clip Duration = %d "),iDuration);
  1.3547 +				INFO_PRINTF2( _L("Actual Duration = %u "),iActualDuration);
  1.3548 +				INFO_PRINTF2( _L("Expected Duration = %d "),iDuration*(iNumOfRepeatsSet+1));
  1.3549 +				#ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
  1.3550 +				if(TimeComparison(iActualDuration, iDuration*(iNumOfRepeatsSet+1), KExpectedDeviation))
  1.3551 +					{
  1.3552 +					StopTest(); // success
  1.3553 +					}
  1.3554 +				else
  1.3555 +					{
  1.3556 +					STOP_TEST_GEN_ERROR;
  1.3557 +					}
  1.3558 +				#else
  1.3559 +				if(TimeComparison(iActualDuration, iDuration*(iNumOfRepeatsSet+1), KExpectedDeviation*iNumOfRepeatsSet))
  1.3560 +					{
  1.3561 +					StopTest(); // success
  1.3562 +					}
  1.3563 +				else
  1.3564 +					{
  1.3565 +					STOP_TEST_GEN_ERROR;
  1.3566 +					}
  1.3567 +				#endif
  1.3568 +				break;
  1.3569 +				}
  1.3570 +			else
  1.3571 +				{
  1.3572 +				StopTest();
  1.3573 +				break;	
  1.3574 +				}
  1.3575 +			}
  1.3576 +			
  1.3577 +		default:
  1.3578 +				STOP_TEST_GEN_ERROR;
  1.3579 +				break;
  1.3580 +		}	
  1.3581 +	}
  1.3582 +	
  1.3583 +//============================================================================================================
  1.3584 +
  1.3585 +
  1.3586 +CAsyncTestMmfAclntAudioRepeatPlayRepeatPlay* CAsyncTestMmfAclntAudioRepeatPlayRepeatPlay::NewL( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3587 +	{
  1.3588 +	return new (ELeave) CAsyncTestMmfAclntAudioRepeatPlayRepeatPlay( aTestName, aSectName, aKeyName);
  1.3589 +	}
  1.3590 +
  1.3591 +CAsyncTestMmfAclntAudioRepeatPlayRepeatPlay::CAsyncTestMmfAclntAudioRepeatPlayRepeatPlay( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3592 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, aKeyName)
  1.3593 +	{
  1.3594 +	}
  1.3595 +
  1.3596 +void CAsyncTestMmfAclntAudioRepeatPlayRepeatPlay::FsmL()
  1.3597 +	{
  1.3598 +	switch (iTestState)
  1.3599 +		{
  1.3600 +		case EStateOpened:
  1.3601 +			{
  1.3602 +			INFO_PRINTF1( _L("TestPlayerUtils : Audio Repeat/Play/Repeat/Play"));
  1.3603 +			iDuration = I64INT(iPlayer->Duration().Int64());
  1.3604 +			
  1.3605 +			INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.3606 +			INFO_PRINTF2( _L("Repeats = %d\n"),iNumOfRepeatsSet);
  1.3607 +			iPlayer->SetRepeats(iNumOfRepeatsSet,iSilence);
  1.3608 +			
  1.3609 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.3610 +			if(iPlayerState == EOpened)
  1.3611 +				{
  1.3612 +				iPlayer->Play();	
  1.3613 +				iPlayerState = EPlaying;
  1.3614 +				iStart.HomeTime();
  1.3615 +				
  1.3616 +				INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.3617 +				if(!GetIntFromConfig(_L("SectionRepeatCount"), _L("newRepeatValue"), iNumOfRepeatsSet))
  1.3618 +					{
  1.3619 +					ERR_PRINTF1(_L("GetIntFromConfig Failed"));
  1.3620 +					StopTest(KErrGeneral, EInconclusive);
  1.3621 +					break;
  1.3622 +					}
  1.3623 +				INFO_PRINTF2( _L("Repeats = %d\n"),iNumOfRepeatsSet );
  1.3624 +				iPlayer->SetRepeats(iNumOfRepeatsSet, iSilence);				
  1.3625 +				}
  1.3626 +			break;
  1.3627 +			}
  1.3628 +		case EStateStopTest:
  1.3629 +			{
  1.3630 +			if(iDuration)
  1.3631 +				{
  1.3632 +				iStop.HomeTime();
  1.3633 +				iActualDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64()); 
  1.3634 +				INFO_PRINTF2( _L("Clip Duration = %d "),iDuration);
  1.3635 +				INFO_PRINTF2( _L("Actual Duration = %u "),iActualDuration);
  1.3636 +				INFO_PRINTF2( _L("Expected Duration = %d "),iDuration *(iNumOfRepeatsSet+1));
  1.3637 +				#ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
  1.3638 +				if(TimeComparison(iActualDuration, iDuration *(iNumOfRepeatsSet+1),
  1.3639 +												   KExpectedDeviation))
  1.3640 +					{
  1.3641 +					StopTest(); // success
  1.3642 +					}
  1.3643 +				else
  1.3644 +					{
  1.3645 +					STOP_TEST_GEN_ERROR;
  1.3646 +					}
  1.3647 +				#else
  1.3648 +				if(TimeComparison(iActualDuration, iDuration *(iNumOfRepeatsSet+1),
  1.3649 +												   KExpectedDeviation*iNumOfRepeatsSet))
  1.3650 +					{
  1.3651 +					StopTest(); // success
  1.3652 +					}
  1.3653 +				else
  1.3654 +					{
  1.3655 +					STOP_TEST_GEN_ERROR;
  1.3656 +					}				
  1.3657 +				#endif
  1.3658 +				break;
  1.3659 +				}
  1.3660 +			else
  1.3661 +				{
  1.3662 +				StopTest(); // success
  1.3663 +				break;		
  1.3664 +				}
  1.3665 +			}
  1.3666 +		default:
  1.3667 +				STOP_TEST_GEN_ERROR;
  1.3668 +				break;
  1.3669 +		}		
  1.3670 +	}
  1.3671 +	
  1.3672 +//============================================================================================================
  1.3673 +
  1.3674 +
  1.3675 +
  1.3676 +CAsyncTestMmfAclntAudioPlayRepeatRepeatPlay* CAsyncTestMmfAclntAudioPlayRepeatRepeatPlay::NewL( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3677 +	{
  1.3678 +	return new (ELeave) CAsyncTestMmfAclntAudioPlayRepeatRepeatPlay( aTestName, aSectName, aKeyName);
  1.3679 +	}
  1.3680 +
  1.3681 +CAsyncTestMmfAclntAudioPlayRepeatRepeatPlay::CAsyncTestMmfAclntAudioPlayRepeatRepeatPlay( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3682 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, aKeyName)
  1.3683 +	{
  1.3684 +	}
  1.3685 +
  1.3686 +void CAsyncTestMmfAclntAudioPlayRepeatRepeatPlay::FsmL()
  1.3687 +	{
  1.3688 +	switch (iTestState)
  1.3689 +		{
  1.3690 +		case EStateOpened:
  1.3691 +			{
  1.3692 +			INFO_PRINTF1( _L("TestPlayerUtils : Audio Play/Repeat/Repeat/Play"));
  1.3693 +			iDuration = I64INT(iPlayer->Duration().Int64());
  1.3694 +			
  1.3695 +			if(iPlayerState == EOpened)
  1.3696 +				{
  1.3697 +				iPlayer->Play();
  1.3698 +				iPlayerState = EPlaying;
  1.3699 +				iStart.HomeTime();
  1.3700 +				
  1.3701 +				INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.3702 +				INFO_PRINTF2( _L("Repeats = %d"),iNumOfRepeatsSet);
  1.3703 +				iPlayer->SetRepeats(iNumOfRepeatsSet,iSilence);
  1.3704 +				
  1.3705 +				INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.3706 +				if(!GetIntFromConfig(_L("SectionRepeatCount"), _L("newRepeatValue"), iNumOfRepeatsSet))
  1.3707 +					{
  1.3708 +					ERR_PRINTF1(_L("GetIntFromConfig Failed"));
  1.3709 +					StopTest(KErrGeneral, EInconclusive);
  1.3710 +					break;
  1.3711 +					}
  1.3712 +				INFO_PRINTF2( _L("Repeats = %d"),iNumOfRepeatsSet);
  1.3713 +				iPlayer->SetRepeats(iNumOfRepeatsSet,iSilence);
  1.3714 +				}
  1.3715 +			break;
  1.3716 +			}
  1.3717 +		case EStateStopTest:
  1.3718 +			{
  1.3719 +			if(iDuration)
  1.3720 +				{
  1.3721 +				iStop.HomeTime();
  1.3722 +				iActualDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64()); 
  1.3723 +				INFO_PRINTF2( _L("Clip Duration = %d "),iDuration);
  1.3724 +				INFO_PRINTF2( _L("Actual Duration = %u "),iActualDuration);
  1.3725 +				INFO_PRINTF2( _L("Expected Duration = %d "),iDuration *(iNumOfRepeatsSet+1));
  1.3726 +				#ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
  1.3727 +				if(TimeComparison(iActualDuration, iDuration *(iNumOfRepeatsSet+1),KExpectedDeviation))
  1.3728 +												   // since we setting repeats during first playback of first repeat, we need to take into consideration of first playback
  1.3729 +					{
  1.3730 +					StopTest(); // success
  1.3731 +					}
  1.3732 +				else
  1.3733 +					{
  1.3734 +					STOP_TEST_GEN_ERROR;
  1.3735 +					}
  1.3736 +				#else
  1.3737 +				if(TimeComparison(iActualDuration, iDuration *(iNumOfRepeatsSet+1),KExpectedDeviation*iNumOfRepeatsSet))
  1.3738 +												   // since we setting repeats during first playback of first repeat, we need to take into consideration of first playback
  1.3739 +					{
  1.3740 +					StopTest(); // success
  1.3741 +					}
  1.3742 +				else
  1.3743 +					{
  1.3744 +					STOP_TEST_GEN_ERROR;
  1.3745 +					}
  1.3746 +				#endif
  1.3747 +				break;
  1.3748 +				}
  1.3749 +			else
  1.3750 +				{
  1.3751 +				StopTest(); // success
  1.3752 +				break;		
  1.3753 +				}
  1.3754 +		
  1.3755 +			}
  1.3756 +		default:
  1.3757 +				STOP_TEST_GEN_ERROR;
  1.3758 +				break;
  1.3759 +		}	
  1.3760 +	}
  1.3761 +	
  1.3762 +//============================================================================================================
  1.3763 +
  1.3764 +
  1.3765 +
  1.3766 +CAsyncTestMmfAclntAudioPlayRepeatRamp* CAsyncTestMmfAclntAudioPlayRepeatRamp::NewL( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3767 +	{
  1.3768 +	return new (ELeave) CAsyncTestMmfAclntAudioPlayRepeatRamp( aTestName, aSectName, aKeyName);
  1.3769 +	}
  1.3770 +
  1.3771 +CAsyncTestMmfAclntAudioPlayRepeatRamp::CAsyncTestMmfAclntAudioPlayRepeatRamp( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3772 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, aKeyName)
  1.3773 +	{
  1.3774 +	}
  1.3775 +
  1.3776 +void CAsyncTestMmfAclntAudioPlayRepeatRamp::FsmL()
  1.3777 +	{
  1.3778 +	switch (iTestState)
  1.3779 +		{
  1.3780 +		case EStateOpened:
  1.3781 +			{
  1.3782 +			INFO_PRINTF1( _L("TestPlayerUtils : Audio Repeat/SetVolumeRamp/Play"));
  1.3783 +			iDuration = I64INT(iPlayer->Duration().Int64());
  1.3784 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.3785 +
  1.3786 +			iPlayer->Play();	
  1.3787 +			iPlayerState = EPlaying;
  1.3788 +			iStart.HomeTime();
  1.3789 +			
  1.3790 +			INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.3791 +			INFO_PRINTF2( _L("Repeats = %d\n"),iNumOfRepeatsSet);
  1.3792 +			iPlayer->SetRepeats(iNumOfRepeatsSet,iSilence);
  1.3793 +			
  1.3794 +			INFO_PRINTF1( _L("SetVolumeRamp CMdaAudioPlayerUtility"));
  1.3795 +			iPlayer->SetVolumeRamp(TTimeIntervalMicroSeconds(5000000));	
  1.3796 +			break;
  1.3797 +			}
  1.3798 +		case EStateStopTest:
  1.3799 +			{
  1.3800 +			if(iDuration)
  1.3801 +				{
  1.3802 +				iStop.HomeTime();
  1.3803 +				iActualDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64());
  1.3804 +				INFO_PRINTF2( _L("Clip Duration = %d "),iDuration);
  1.3805 +				INFO_PRINTF2( _L("Actual Duration = %u "),iActualDuration);
  1.3806 +				INFO_PRINTF2( _L("Expected Duration = %d "),iDuration *(iNumOfRepeatsSet+1));
  1.3807 +				#ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
  1.3808 +				if(TimeComparison(iActualDuration, iDuration *(iNumOfRepeatsSet+1),
  1.3809 +												   KExpectedDeviation))
  1.3810 +					{
  1.3811 +					StopTest(); // success
  1.3812 +					}
  1.3813 +				else
  1.3814 +					{
  1.3815 +					STOP_TEST_GEN_ERROR;
  1.3816 +					}
  1.3817 +				#else
  1.3818 +				if(TimeComparison(iActualDuration, iDuration *(iNumOfRepeatsSet+1),
  1.3819 +												   KExpectedDeviation*iNumOfRepeatsSet))
  1.3820 +					{
  1.3821 +					StopTest(); // success
  1.3822 +					}
  1.3823 +				else
  1.3824 +					{
  1.3825 +					STOP_TEST_GEN_ERROR;
  1.3826 +					}
  1.3827 +				#endif
  1.3828 +				break;
  1.3829 +				}
  1.3830 +			else
  1.3831 +				{
  1.3832 +				StopTest(); // success
  1.3833 +				break;	
  1.3834 +				}
  1.3835 +			}	
  1.3836 +		default:
  1.3837 +				STOP_TEST_GEN_ERROR;
  1.3838 +				break;
  1.3839 +			}
  1.3840 +		}
  1.3841 +//============================================================================================================
  1.3842 +
  1.3843 +CAsyncTestMmfAclntAudioRepeatForeverPlay* CAsyncTestMmfAclntAudioRepeatForeverPlay::NewL( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TTimeIntervalMicroSeconds aTrailingSilence)
  1.3844 +	{
  1.3845 +	return new (ELeave) CAsyncTestMmfAclntAudioRepeatForeverPlay( aTestName, aSectName, aKeyName, aTrailingSilence);
  1.3846 +	}
  1.3847 +
  1.3848 +CAsyncTestMmfAclntAudioRepeatForeverPlay::CAsyncTestMmfAclntAudioRepeatForeverPlay( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TTimeIntervalMicroSeconds aTrailingSilence)
  1.3849 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, aKeyName)
  1.3850 +	{
  1.3851 +	iTrailingSilence = aTrailingSilence;
  1.3852 +	}
  1.3853 +
  1.3854 +void CAsyncTestMmfAclntAudioRepeatForeverPlay::FsmL()
  1.3855 +	{
  1.3856 +	switch (iTestState)
  1.3857 +		{
  1.3858 +		case EStateOpened:
  1.3859 +			{
  1.3860 +			INFO_PRINTF1( _L("TestPlayerUtils : Audio RepeatForever/Play"));
  1.3861 +			iDuration = I64INT(iPlayer->Duration().Int64());
  1.3862 +			
  1.3863 +			INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.3864 +			INFO_PRINTF2( _L("Repeats (KMdaRepeatForever) = %d\n"),KMdaRepeatForever);
  1.3865 +			INFO_PRINTF2( _L("Trailing silence = %ld\n"),iTrailingSilence.Int64());
  1.3866 +			iPlayer->SetRepeats(KMdaRepeatForever,iTrailingSilence);
  1.3867 +			
  1.3868 +			if(iPlayerState == EOpened)
  1.3869 +				{
  1.3870 +				iPlayer->Play();	
  1.3871 +				iPlayerState = EPlaying;
  1.3872 +				if(iDuration)
  1.3873 +					{
  1.3874 +					iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.3875 +					iTrigger->StartTimer(iDuration * 6); // Wait till complettion of 5 repeats then issue stop	
  1.3876 +					}
  1.3877 +				else
  1.3878 +					{
  1.3879 +					iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.3880 +					iTrigger->StartTimer(KOneSecond * 40); // Wait for 40 sec of playback and then issue stop
  1.3881 +					}
  1.3882 +				iTestState = EStateStop;
  1.3883 +				}
  1.3884 +			break;
  1.3885 +			}
  1.3886 +		case EStateStop:
  1.3887 +			{
  1.3888 +			INFO_PRINTF1( _L("Stop CMdaAudioPlayerUtility"));
  1.3889 +			iPlayer->Stop();
  1.3890 +			iPlayerState = EStopped;
  1.3891 +			iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.3892 +			iTrigger->StartTimer(500000); // Call Pause for this test case after two sec
  1.3893 +			iTestState = EStateStopTest;
  1.3894 +			break;
  1.3895 +			}
  1.3896 +		case EStateStopTest:
  1.3897 +			{
  1.3898 +			StopTest(); // success
  1.3899 +			break;	
  1.3900 +			}			
  1.3901 +		default:
  1.3902 +				STOP_TEST_GEN_ERROR;
  1.3903 +				break;
  1.3904 +		}
  1.3905 +	}
  1.3906 +	
  1.3907 +	
  1.3908 +//============================================================================================================
  1.3909 +
  1.3910 +CAsyncTestMmfAclntAudioRepeatPlayGetPosition* CAsyncTestMmfAclntAudioRepeatPlayGetPosition::NewL( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3911 +	{
  1.3912 +	return new (ELeave) CAsyncTestMmfAclntAudioRepeatPlayGetPosition( aTestName, aSectName, aKeyName);
  1.3913 +	}
  1.3914 +
  1.3915 +CAsyncTestMmfAclntAudioRepeatPlayGetPosition::CAsyncTestMmfAclntAudioRepeatPlayGetPosition( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.3916 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, aKeyName)
  1.3917 +	{
  1.3918 +	
  1.3919 +	}
  1.3920 +
  1.3921 +void CAsyncTestMmfAclntAudioRepeatPlayGetPosition::FsmL()
  1.3922 +	{
  1.3923 +	switch (iTestState)
  1.3924 +		{
  1.3925 +		case EStateOpened:
  1.3926 +			{
  1.3927 +			INFO_PRINTF1( _L("TestPlayerUtils : Audio Repeat/Play/GetPosition"));
  1.3928 +			iDuration = I64INT(iPlayer->Duration().Int64());
  1.3929 +			
  1.3930 +			INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.3931 +			INFO_PRINTF2( _L("Repeats = %d\n"),iNumOfRepeatsSet);
  1.3932 +			iPlayer->SetRepeats(iNumOfRepeatsSet,iSilence);
  1.3933 +			
  1.3934 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.3935 +		
  1.3936 +			if(iPlayerState == EOpened)
  1.3937 +				{
  1.3938 +				iPlayer->Play();	
  1.3939 +				iPlayerState = EPlaying;
  1.3940 +				
  1.3941 +				iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.3942 +				iTrigger->StartTimer(KOneSecond); // Call GetPosition (during Playback of Second repeat) for every 2 sec
  1.3943 +				iTestState = EStateGetPosition;
  1.3944 +				}
  1.3945 +			break;
  1.3946 +			}
  1.3947 +		case EStateGetPosition:
  1.3948 +			{
  1.3949 +			INFO_PRINTF1( _L("GetPosition CMdaAudioPlayerUtility"));
  1.3950 +			TInt err = iPlayer->GetPosition(iPosition);
  1.3951 +			if(err == KErrNone && iPosition <= iDuration * (iNumOfRepeatsSet+1) )
  1.3952 +				{
  1.3953 +				INFO_PRINTF2(_L("GetPosition = %d"),I64INT(iPosition.Int64()));
  1.3954 +				INFO_PRINTF2(_L("TotalClip Duration Including Repeats = %d"),iDuration * (iNumOfRepeatsSet+1));
  1.3955 +				
  1.3956 +				iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.3957 +				iTrigger->StartTimer(KOneSecond); // Call GetPosition (during Playback of Second repeat) for every 2 sec
  1.3958 +				iTestState = EStateGetPosition;
  1.3959 +				
  1.3960 +				break;	
  1.3961 +				}
  1.3962 +			else
  1.3963 +				{
  1.3964 +				StopTest(err, EFail);
  1.3965 +				break;	
  1.3966 +				}			
  1.3967 +			}
  1.3968 +		case EStateStopTest:
  1.3969 +			{
  1.3970 +			StopTest(); // success
  1.3971 +			break;	
  1.3972 +			}			
  1.3973 +		default:
  1.3974 +				STOP_TEST_GEN_ERROR;
  1.3975 +				break;
  1.3976 +		}
  1.3977 +	}	
  1.3978 +	
  1.3979 +//============================================================================================================
  1.3980 +
  1.3981 +
  1.3982 +CAsyncTestMmfAclntDRMRepeatPlay* CAsyncTestMmfAclntDRMRepeatPlay::NewL( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, const TDesC& aUniqueId, const TInt aRepeatCount)
  1.3983 +	{
  1.3984 +	return new (ELeave) CAsyncTestMmfAclntDRMRepeatPlay( aTestName, aSectName, aKeyName, aUniqueId, aRepeatCount);
  1.3985 +	}
  1.3986 +
  1.3987 +CAsyncTestMmfAclntDRMRepeatPlay::CAsyncTestMmfAclntDRMRepeatPlay( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, const TDesC& aUniqueId,const TInt aRepeatCount)
  1.3988 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, aKeyName)
  1.3989 +	{
  1.3990 +	 iUniqueId = aUniqueId;
  1.3991 +	 iNumOfRepeatsSet = aRepeatCount;
  1.3992 +	}
  1.3993 +	
  1.3994 +void CAsyncTestMmfAclntDRMRepeatPlay::KickoffTestL()
  1.3995 +	{
  1.3996 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Player Util"));
  1.3997 +	TPtrC			filename1; 
  1.3998 +	TInt 			repeatCount;
  1.3999 +	TInt			silence;
  1.4000 +	if(!GetStringFromConfig(iSectName, iKeyName, filename1))
  1.4001 +		{
  1.4002 +		ERR_PRINTF1(_L("GetStringFromConfig Failed"));
  1.4003 +		StopTest(KErrGeneral, EInconclusive);
  1.4004 +		return;
  1.4005 +		}
  1.4006 +	if(!GetIntFromConfig(_L("SectionRepeatCount"), _L("numOfRepeat"), repeatCount))
  1.4007 +		{
  1.4008 +		ERR_PRINTF1(_L("GetIntFromConfig Failed"));
  1.4009 +		StopTest(KErrGeneral, EInconclusive);
  1.4010 +		return;
  1.4011 +		}
  1.4012 +	if(!GetIntFromConfig(_L("SectionSilence"), _L("silence"), silence))
  1.4013 +		{
  1.4014 +		ERR_PRINTF1(_L("GetIntFromConfig Failed"));
  1.4015 +		StopTest(KErrGeneral, EInconclusive);
  1.4016 +		return;
  1.4017 +		}
  1.4018 +	iSilence = silence;
  1.4019 +	iNumOfRepeatsSet = 	repeatCount;
  1.4020 +	
  1.4021 +	GetDriveName(iFileName);
  1.4022 +	iFileName.Append(filename1);
  1.4023 +	INFO_PRINTF2(_L("CMdaAudioPlayerUtility::NewFilePlayerL() - %S"), &iFileName);
  1.4024 +	iTrigger = CFsmTrigger::NewL(*this);
  1.4025 +		
  1.4026 +	INFO_PRINTF1( _L("TestPlayerUtils : DRM Audio  Repeat/Play"));
  1.4027 +	iPlayer = CMdaAudioPlayerUtility::NewL(*this);
  1.4028 +	iPlayer->OpenFileL(TMMFileSource(iFileName, iUniqueId, ContentAccess::EPlay));
  1.4029 +	iPlayerState = EOpening;
  1.4030 +	}
  1.4031 +
  1.4032 +void CAsyncTestMmfAclntDRMRepeatPlay::MapcInitComplete(TInt aError, 
  1.4033 +								const TTimeIntervalMicroSeconds &aDuration)
  1.4034 +	{
  1.4035 +	iError = aError;
  1.4036 +	iClipDuration = aDuration;
  1.4037 +	if (aError == KErrNone)
  1.4038 +		{
  1.4039 +		INFO_PRINTF2(_L("*MapcInitComplete* Error: %d."), aError);
  1.4040 +		iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.4041 +		iTrigger->StartTimer(500000); 
  1.4042 +		iTestState = EStateStopTest;
  1.4043 +		}
  1.4044 +	else if(aError == KErrCANoPermission)
  1.4045 +		{
  1.4046 +		INFO_PRINTF2(_L("*MapcInitComplete* Error: %d Rights expired"), aError);
  1.4047 +		iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.4048 +		iTrigger->StartTimer(500000); 
  1.4049 +		iTestState = EStateStopTest;	
  1.4050 +		}
  1.4051 +	else
  1.4052 +		{
  1.4053 +		StopTest(aError, EFail);	
  1.4054 +		}
  1.4055 +	}
  1.4056 +void CAsyncTestMmfAclntDRMRepeatPlay::MapcPlayComplete(TInt aError)
  1.4057 +	{
  1.4058 +	if(aError == KErrNone )
  1.4059 +		{
  1.4060 +		INFO_PRINTF2(_L("*MapcPlayComplete* Error: %d"), aError);
  1.4061 +		iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.4062 +		iTrigger->StartTimer(500000); 
  1.4063 +		iTestState = EStateStopTest;
  1.4064 +		}
  1.4065 +	else if(aError == KErrCANoPermission)
  1.4066 +		{
  1.4067 +		INFO_PRINTF2(_L("*MapcPlayComplete* Error: %d Rights expired"), aError);
  1.4068 +		iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.4069 +		iTrigger->StartTimer(500000); 
  1.4070 +		iTestState = EStateStopTest;	
  1.4071 +		}
  1.4072 +	else
  1.4073 +		{
  1.4074 +		StopTest(aError, EFail);
  1.4075 +		}	
  1.4076 +	}
  1.4077 +void CAsyncTestMmfAclntDRMRepeatPlay::FsmL()
  1.4078 +	{
  1.4079 +	switch (iTestState)
  1.4080 +		{
  1.4081 +		case EStateOpened:
  1.4082 +			{
  1.4083 +			iDuration = I64INT(iPlayer->Duration().Int64());
  1.4084 +			
  1.4085 +			INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.4086 +			INFO_PRINTF2( _L("Repeats = %d\n"),iNumOfRepeatsSet);
  1.4087 +			iPlayer->SetRepeats(iNumOfRepeatsSet,iSilence);
  1.4088 +			
  1.4089 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.4090 +		
  1.4091 +			if(iPlayerState == EOpened)
  1.4092 +				{
  1.4093 +				iPlayer->Play();	
  1.4094 +				iPlayerState = EPlaying;
  1.4095 +				}
  1.4096 +			break;
  1.4097 +			}
  1.4098 +		case EStateStopTest:
  1.4099 +			{
  1.4100 +			StopTest(); // success
  1.4101 +			break;	
  1.4102 +			}			
  1.4103 +		default:
  1.4104 +				STOP_TEST_GEN_ERROR;
  1.4105 +				break;
  1.4106 +		}
  1.4107 +	}
  1.4108 +
  1.4109 +
  1.4110 +
  1.4111 +
  1.4112 +//=============================================================================================================
  1.4113 +//RAsync Negative tests
  1.4114 +//==============================================================================================================
  1.4115 +
  1.4116 +
  1.4117 +
  1.4118 +CAsyncTestMmfAclntAudioNegativeRepeatPlay* CAsyncTestMmfAclntAudioNegativeRepeatPlay::NewL( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.4119 +	{
  1.4120 +	return new (ELeave) CAsyncTestMmfAclntAudioNegativeRepeatPlay( aTestName, aSectName, aKeyName);
  1.4121 +	}
  1.4122 +
  1.4123 +CAsyncTestMmfAclntAudioNegativeRepeatPlay::CAsyncTestMmfAclntAudioNegativeRepeatPlay( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.4124 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, aKeyName)
  1.4125 +	{
  1.4126 +	}
  1.4127 +
  1.4128 +void CAsyncTestMmfAclntAudioNegativeRepeatPlay::FsmL()
  1.4129 +	{
  1.4130 +	switch (iTestState)
  1.4131 +		{
  1.4132 +		case EStateOpened:
  1.4133 +			{
  1.4134 +			INFO_PRINTF1( _L("TestPlayerUtils : Audio  NegativeRepeat/Play"));
  1.4135 +			iDuration = I64INT(iPlayer->Duration().Int64());
  1.4136 +			
  1.4137 +			INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.4138 +			INFO_PRINTF2( _L("Repeats = %d\n"),KNegativeRepeat);
  1.4139 +			iPlayer->SetRepeats(KNegativeRepeat,iSilence);
  1.4140 +		
  1.4141 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.4142 +		
  1.4143 +			if(iPlayerState == EOpened)
  1.4144 +				{
  1.4145 +				iPlayer->Play();	
  1.4146 +				iPlayerState = EPlaying;
  1.4147 +				iStart.HomeTime();
  1.4148 +				}
  1.4149 +			break;
  1.4150 +			}
  1.4151 +		case EStateStopTest:
  1.4152 +			{
  1.4153 +			if(iDuration)
  1.4154 +				{
  1.4155 +				iStop.HomeTime();
  1.4156 +				iActualDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64());
  1.4157 +				INFO_PRINTF2( _L("Clip Duration = %d "),iDuration);
  1.4158 +				INFO_PRINTF2( _L("Actual Duration = %u "),iActualDuration);
  1.4159 +				INFO_PRINTF2( _L("Expected Duration = %d "),iDuration);
  1.4160 +				if(TimeComparison(iActualDuration, iDuration,
  1.4161 +												   KExpectedDeviation))
  1.4162 +					{
  1.4163 +					StopTest(); // success
  1.4164 +					break;	
  1.4165 +					}
  1.4166 +				else
  1.4167 +					{
  1.4168 +					STOP_TEST_GEN_ERROR;
  1.4169 +					break;	
  1.4170 +					}						
  1.4171 +				}
  1.4172 +			else
  1.4173 +				{
  1.4174 +				StopTest();
  1.4175 +				break;
  1.4176 +				}
  1.4177 +			}			
  1.4178 +		default:
  1.4179 +				STOP_TEST_GEN_ERROR;
  1.4180 +				break;
  1.4181 +		}
  1.4182 +	}
  1.4183 +	
  1.4184 +//============================================================================================================
  1.4185 +
  1.4186 +
  1.4187 +CAsyncTestMmfAclntAudioPlayNegativeRepeat* CAsyncTestMmfAclntAudioPlayNegativeRepeat::NewL( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.4188 +	{
  1.4189 +	return new (ELeave) CAsyncTestMmfAclntAudioPlayNegativeRepeat( aTestName, aSectName, aKeyName);
  1.4190 +	}
  1.4191 +
  1.4192 +CAsyncTestMmfAclntAudioPlayNegativeRepeat::CAsyncTestMmfAclntAudioPlayNegativeRepeat( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.4193 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, aKeyName)
  1.4194 +	{
  1.4195 +	}
  1.4196 +
  1.4197 +void CAsyncTestMmfAclntAudioPlayNegativeRepeat::FsmL()
  1.4198 +	{
  1.4199 +	switch (iTestState)
  1.4200 +		{
  1.4201 +		case EStateOpened:
  1.4202 +			{
  1.4203 +			INFO_PRINTF1( _L("TestPlayerUtils : Audio  Play/NegativeRepeat"));
  1.4204 +			iDuration = I64INT(iPlayer->Duration().Int64());
  1.4205 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.4206 +			iPlayer->Play();	
  1.4207 +			iPlayerState = EPlaying;
  1.4208 +			iStart.HomeTime();
  1.4209 +				
  1.4210 +			INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.4211 +			INFO_PRINTF2( _L("Repeats = %d\n"),KNegativeRepeat);
  1.4212 +			iPlayer->SetRepeats(KNegativeRepeat,iSilence);
  1.4213 +
  1.4214 +			break;
  1.4215 +			}
  1.4216 +		case EStateStopTest:
  1.4217 +			{
  1.4218 +			if(iDuration)
  1.4219 +				{
  1.4220 +				iStop.HomeTime();
  1.4221 +				iActualDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64()); 
  1.4222 +				INFO_PRINTF2( _L("Clip Duration = %d "),iDuration);
  1.4223 +				INFO_PRINTF2( _L("Actual Duration = %u "),iActualDuration);
  1.4224 +				INFO_PRINTF2( _L("Expected Duration = %d "),iDuration);
  1.4225 +				if(TimeComparison(iActualDuration, iDuration,
  1.4226 +												   KExpectedDeviation))
  1.4227 +					{
  1.4228 +					StopTest(); // success
  1.4229 +					break;	
  1.4230 +					}
  1.4231 +				else
  1.4232 +					{
  1.4233 +					STOP_TEST_GEN_ERROR;
  1.4234 +					break;	
  1.4235 +					}					
  1.4236 +				}
  1.4237 +			else
  1.4238 +				{
  1.4239 +				StopTest();
  1.4240 +				break;
  1.4241 +				}
  1.4242 +			}			
  1.4243 +		default:
  1.4244 +				STOP_TEST_GEN_ERROR;
  1.4245 +				break;
  1.4246 +		}
  1.4247 +	}
  1.4248 +
  1.4249 +//============================================================================================================
  1.4250 +
  1.4251 +CAsyncTestMmfAclntRepeatMultipleFiles* CAsyncTestMmfAclntRepeatMultipleFiles::NewL( const TDesC& aTestName, const TDesC& aSectName)
  1.4252 +	{
  1.4253 +	return new (ELeave) CAsyncTestMmfAclntRepeatMultipleFiles( aTestName, aSectName);
  1.4254 +	}
  1.4255 +
  1.4256 +CAsyncTestMmfAclntRepeatMultipleFiles::CAsyncTestMmfAclntRepeatMultipleFiles( const TDesC& aTestName, const TDesC& aSectName)
  1.4257 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, KNullDesC), iCount(0)
  1.4258 +	{
  1.4259 +	}
  1.4260 +void CAsyncTestMmfAclntRepeatMultipleFiles::KickoffTestL()
  1.4261 +	{
  1.4262 +	INFO_PRINTF1( _L("TestPlayerUtils : Audio Player Util"));
  1.4263 +	TInt 		repeatCount;
  1.4264 +	
  1.4265 +	if(!GetIntFromConfig(_L("SectionRepeatCount"), _L("numOfRepeat"), repeatCount))
  1.4266 +		{
  1.4267 +		ERR_PRINTF1(_L("GetIntFromConfig Failed"));
  1.4268 +		StopTest(KErrGeneral, EInconclusive);
  1.4269 +		return;
  1.4270 +		}
  1.4271 +	iTrigger = CFsmTrigger::NewL(*this);
  1.4272 +	iPlayer = CMdaAudioPlayerUtility::NewL(*this);	
  1.4273 +	iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.4274 +	iTrigger->StartTimer(500000);
  1.4275 +	}
  1.4276 +void CAsyncTestMmfAclntRepeatMultipleFiles::FsmL()
  1.4277 +	{
  1.4278 +	switch (iTestState)
  1.4279 +		{
  1.4280 +		case EStateOpen:
  1.4281 +			{
  1.4282 +			INFO_PRINTF1( _L("TestPlayerUtils :Audio  Repeat/Play for multiple files"));
  1.4283 +			TPtrC fileName;
  1.4284 +			iFileName = KTestParameters[iCount].iFilename;
  1.4285 +			if(!GetStringFromConfig(iSectName, iFileName, fileName))
  1.4286 +				{
  1.4287 +				//return EInconclusive;
  1.4288 +				ERR_PRINTF1(_L("GetStringFromConfig Failed"));
  1.4289 +				StopTest(KErrGeneral, EInconclusive);
  1.4290 +				return;
  1.4291 +				}
  1.4292 +			
  1.4293 +			GetDriveName(iFileName);
  1.4294 +			iFileName.Append(fileName);
  1.4295 +			INFO_PRINTF2(_L("CMdaAudioPlayerUtility::NewFilePlayerL() - %S"), &iFileName);
  1.4296 +			iPlayer->OpenFileL(iFileName);
  1.4297 +			iPlayerState = EOpening;
  1.4298 +			break;
  1.4299 +			}
  1.4300 +		case EStateOpened:
  1.4301 +			{
  1.4302 +			iDuration = I64INT(iPlayer->Duration().Int64());
  1.4303 +			iPlayer->SetRepeats(KTestParameters[iCount].iRepeatCount, TTimeIntervalMicroSeconds(KTestParameters[iCount].iSilence));
  1.4304 +			iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.4305 +			iTrigger->StartTimer(500000);
  1.4306 +			iTestState = EStatePlay;
  1.4307 +			break;
  1.4308 +			}
  1.4309 +		case EStatePlay:
  1.4310 +			{
  1.4311 +			if(iPlayerState == EOpened)
  1.4312 +				{
  1.4313 +				INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.4314 +				iPlayer->Play();	
  1.4315 +				iPlayerState = EPlaying;
  1.4316 +				}
  1.4317 +			break;
  1.4318 +			}
  1.4319 +		case EStateStopTest:
  1.4320 +			{
  1.4321 +			if(iCount == KNoOfTestFiles-1)
  1.4322 +				{
  1.4323 +				StopTest(); // success
  1.4324 +				}
  1.4325 +			else
  1.4326 +				{
  1.4327 +				iCount++;
  1.4328 +				iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.4329 +				iTrigger->StartTimer(KOneSecond); // Call SetRepeat for this test case after two sec
  1.4330 +				iTestState = EStateOpen;
  1.4331 +				}
  1.4332 +			break;
  1.4333 +			}			
  1.4334 +		default:
  1.4335 +				STOP_TEST_GEN_ERROR;
  1.4336 +				break;
  1.4337 +		}
  1.4338 +	}
  1.4339 +
  1.4340 +// PDEF131534 SPPR_PERF: Music player crashes when opening corrupted wav file.
  1.4341 +// WAV file of 96000 Hz is not supported.
  1.4342 +void CAsyncTestMmfAclntRepeatMultipleFiles::MapcInitComplete(TInt aError, 
  1.4343 +								const TTimeIntervalMicroSeconds &aDuration)
  1.4344 +	{
  1.4345 +	iError = aError;
  1.4346 +	iClipDuration = aDuration;
  1.4347 +	if (aError != KErrNone)
  1.4348 +		{
  1.4349 +		TInt match = iFileName.Match(_L("*100khzSRate1KhzTone.wav"));
  1.4350 +		if (aError == KErrNotSupported && match != KErrNotFound)
  1.4351 +			{
  1.4352 +			INFO_PRINTF1( _L("WAV file of frequency more than 96 KHz is not supported."));
  1.4353 +			INFO_PRINTF1( _L("*MapcInitComplete* Expected Error: KErrNotSupported(-5)"));
  1.4354 +			INFO_PRINTF2(_L("*MapcInitComplete* Actual Error: %d."), aError);
  1.4355 +			StopTest(aError, EPass);
  1.4356 +			}
  1.4357 +		else
  1.4358 +			{
  1.4359 +			ERR_PRINTF2(_L("*MapcInitComplete* Error: %d."), aError);
  1.4360 +			StopTest(aError, EFail);
  1.4361 +			}
  1.4362 +		}
  1.4363 +	else
  1.4364 +		{
  1.4365 +		INFO_PRINTF2(_L("*MapcInitComplete* Error: %d."), aError);
  1.4366 +		iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
  1.4367 +		iTrigger->StartTimer(500000); 
  1.4368 +		iTestState = EStateOpened;
  1.4369 +		iPlayerState = EOpened;	
  1.4370 +		}	
  1.4371 +	}
  1.4372 +//============================================================================================================
  1.4373 +
  1.4374 +
  1.4375 +CAsyncTestMmfAclntAudioSetPlayWindowRepeatPlay* CAsyncTestMmfAclntAudioSetPlayWindowRepeatPlay::NewL( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.4376 +	{
  1.4377 +	return new (ELeave) CAsyncTestMmfAclntAudioSetPlayWindowRepeatPlay( aTestName, aSectName, aKeyName);
  1.4378 +	}
  1.4379 +
  1.4380 +CAsyncTestMmfAclntAudioSetPlayWindowRepeatPlay::CAsyncTestMmfAclntAudioSetPlayWindowRepeatPlay( const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
  1.4381 +	: CAsyncTestMmfAclntAudioPlayerUtil( aTestName, aSectName, aKeyName)
  1.4382 +	{
  1.4383 +	}
  1.4384 +
  1.4385 +void CAsyncTestMmfAclntAudioSetPlayWindowRepeatPlay::FsmL()
  1.4386 +	{
  1.4387 +	switch (iTestState)
  1.4388 +		{
  1.4389 +		case EStateOpened:
  1.4390 +			{
  1.4391 +			INFO_PRINTF1( _L("TestPlayerUtils : SetPlayWindow Repeat Play"));
  1.4392 +			iDuration = I64INT(iPlayer->Duration().Int64());			
  1.4393 +			
  1.4394 +			TInt64 temp1, temp2;
  1.4395 +			temp1 = iPlayer->Duration().Int64()/2;
  1.4396 +			temp2 = iPlayer->Duration().Int64();
  1.4397 +			iWindowDuration = (I64INT(temp2) - I64INT(temp1));
  1.4398 +
  1.4399 +			TTimeIntervalMicroSeconds startTime(temp1);
  1.4400 +			TTimeIntervalMicroSeconds endTime(temp2); 
  1.4401 +
  1.4402 +			INFO_PRINTF4(_L("StartTime = %d EndTime = %d WindowDuration = %d"),
  1.4403 +				I64INT(startTime.Int64()), I64INT(endTime.Int64()), iWindowDuration);
  1.4404 +			
  1.4405 +			TInt windowSet = iPlayer->SetPlayWindow(startTime,endTime);
  1.4406 +			if (windowSet != KErrNone)
  1.4407 +				{
  1.4408 +				ERR_PRINTF2( _L("Unexpected error returned from SetPlayWindow - %d"),windowSet);
  1.4409 +				StopTest(windowSet, EFail);
  1.4410 +				break;
  1.4411 +				}
  1.4412 +			
  1.4413 +			INFO_PRINTF1( _L("SetRepeats CMdaAudioPlayerUtility"));
  1.4414 +			INFO_PRINTF2( _L("Repeats = %d\n"),iNumOfRepeatsSet);
  1.4415 +			iPlayer->SetRepeats(iNumOfRepeatsSet,iSilence);
  1.4416 +			
  1.4417 +			INFO_PRINTF1( _L("Play CMdaAudioPlayerUtility"));
  1.4418 +		
  1.4419 +			if(iPlayerState == EOpened)
  1.4420 +				{
  1.4421 +				iPlayer->Play();	
  1.4422 +				iPlayerState = EPlaying;
  1.4423 +				iStart.HomeTime();
  1.4424 +				}
  1.4425 +			break;
  1.4426 +			}
  1.4427 +		case EStateStopTest:
  1.4428 +			{
  1.4429 +			if(iDuration)
  1.4430 +				{
  1.4431 +				iStop.HomeTime();
  1.4432 +				iActualDuration = I64INT(iStop.MicroSecondsFrom(iStart).Int64()); 
  1.4433 +				INFO_PRINTF2( _L("Clip Duration = %d "),iDuration);
  1.4434 +				INFO_PRINTF2( _L("Actual Duration = %u "),iActualDuration);
  1.4435 +				INFO_PRINTF2( _L("Window Duration = %d "),iWindowDuration);
  1.4436 +				#ifdef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
  1.4437 +				if(TimeComparison(iActualDuration, iWindowDuration*(iNumOfRepeatsSet+1),
  1.4438 +												   KExpectedDeviation))
  1.4439 +					{
  1.4440 +					StopTest(); // success
  1.4441 +					}
  1.4442 +				else
  1.4443 +					{
  1.4444 +					STOP_TEST_GEN_ERROR;
  1.4445 +					}
  1.4446 +				#else
  1.4447 +				if(TimeComparison(iActualDuration, iWindowDuration*(iNumOfRepeatsSet+1),
  1.4448 +												   KExpectedDeviation*iNumOfRepeatsSet))
  1.4449 +					{
  1.4450 +					StopTest(); // success
  1.4451 +					}
  1.4452 +				else
  1.4453 +					{
  1.4454 +					STOP_TEST_GEN_ERROR;
  1.4455 +					}
  1.4456 +				#endif
  1.4457 +				break;			
  1.4458 +				}
  1.4459 +			else
  1.4460 +				{
  1.4461 +				StopTest();
  1.4462 +				break;
  1.4463 +				}
  1.4464 +			}			
  1.4465 +		default:
  1.4466 +				STOP_TEST_GEN_ERROR;
  1.4467 +				break;
  1.4468 +		}
  1.4469 +	}