os/mm/mmlibs/mmfw/tsrc/mmfunittest/Actrl/TestStepActrlPlay.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/Actrl/TestStepActrlPlay.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1071 @@
     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 +// TestStepActrlPlay
    1.18 +//
    1.19 +
    1.20 +#include <e32std.h>
    1.21 +#include <e32base.h>
    1.22 +#include <mmf/common/mmfcontroller.h>
    1.23 +#include <mmf/server/mmffile.h>
    1.24 +#include <mmf/server/mmfdes.h>
    1.25 +#include <mmf/plugin/mmfcontrollerimplementationuids.hrh>
    1.26 +#include <mmf/common/mmfstandardcustomcommands.h>
    1.27 +
    1.28 +#include "ActrlTestUids.h"
    1.29 +
    1.30 +// Test system includes
    1.31 +#include <testframework.h>
    1.32 +
    1.33 +// Specific includes for this test suite
    1.34 +#include "TS_MMF_ACTRL_TestStep.h"
    1.35 +#include "TS_MMF_ACTRL_TestSuite.h"
    1.36 +
    1.37 +// Specific includes for these test steps
    1.38 +#include "TestStepActrlPlay.h"
    1.39 +
    1.40 +// CONSTANTS
    1.41 +//const TInt KPlayDelayNewMail = 100000000; //arbitrary delay	// EABI warning removal
    1.42 +
    1.43 +const TUint KSampleRate8000Hz  = 8000;
    1.44 +const TUint KSampleRate11025Hz = 11025;
    1.45 +const TUint KSampleRate22050Hz = 22050;
    1.46 +const TUint KSampleRate44100Hz = 44100;
    1.47 +
    1.48 +const TUint KNone	= 0;
    1.49 +const TUint KMono	= 1;
    1.50 +const TUint KStereo = 2;
    1.51 +
    1.52 +//const TUint KFormatWAV = 0;
    1.53 +//const TUint KFormatAU  = 1;
    1.54 +//const TUint KFormatRAW = 2;
    1.55 +
    1.56 +// parameter structure for conversion tests
    1.57 +class TConvParameters
    1.58 +	{	
    1.59 +public:
    1.60 +	const TText* iTestName;
    1.61 +	TUid	iSrcFormat;
    1.62 +	TUid	iDestFormat;
    1.63 +	TUint32 iSrcEncoding;
    1.64 +	TUint32 iDestEncoding;
    1.65 +	TUint	iSrcSampleRate;
    1.66 +	TUint	iDestSampleRate;
    1.67 +	TUint	iSrcChannels;
    1.68 +	TUint	iDestChannels;
    1.69 +	const TText* iFromFilename;
    1.70 +	const TText* iRefFilename;
    1.71 +	TInt	iExpectedResult;
    1.72 +	};
    1.73 +
    1.74 +
    1.75 +// constant table of parameters for tests
    1.76 +const TConvParameters KTestParameters[] =
    1.77 +{	
    1.78 +	// straight encode test
    1.79 +	{ _S("MM-MMF-ACTRL-U-0040-HP"), {KMmfUidFormatWAVRead},	{KMmfUidFormatAUWrite},		KMMFFourCCCodePCM16,	KMMFFourCCCodePCM16B,	KSampleRate44100Hz,		KSampleRate8000Hz,	KStereo,	KMono,		_S("44KHzPCM16Stereo1KHzTone.wav"),	_S("44KHzPCM16StereoWAVTo8KHzPCM16Mono.au"),	KErrNone },
    1.80 +	{ _S("MM-MMF-ACTRL-U-0041-HP"), {KMmfUidFormatWAVRead},	{KMmfUidFormatWAVWrite},	KMMFFourCCCodePCMU8,	KMMFFourCCCodePCM16,	KSampleRate22050Hz,		KSampleRate11025Hz,	KMono,		KStereo,	_S("22KHzPCM8Mono1KHzTone.wav"),	_S("22KHzPCM8MonoWAVTo11KHzPCM16Stereo.wav"),	KErrNone },
    1.81 +	{ _S("MM-MMF-ACTRL-U-0042-HP"), {KMmfUidFormatWAVRead},	{KMmfUidFormatRAWWrite},	KMMFFourCCCodeIMAD,		KMMFFourCCCodePCM16,	KSampleRate11025Hz,		KSampleRate8000Hz,	KMono,		KMono,		_S("11KHzADPCMMono1KHzTone.wav"),	_S("11KHzADPCMMonoWAVTo8KHzPCM16Mono.raw"),		KErrNone },
    1.82 +	{ _S("MM-MMF-ACTRL-U-0043-HP"), {KMmfUidFormatAURead},	{KMmfUidFormatAUWrite},		KMMFFourCCCodePCM16B,	KMMFFourCCCodePCM16B,	KSampleRate8000Hz,		KSampleRate8000Hz,	KMono,		KMono,		_S("8KHzPCM16Mono1KHzTone.au"),		_S("8KHzPCM16MonoAUTo8KHzPCM16Mono.au"),		KErrNone },
    1.83 +	{ _S("MM-MMF-ACTRL-U-0044-HP"), {KMmfUidFormatAURead},	{KMmfUidFormatRAWWrite},	KMMFFourCCCodePCM16B,	KMMFFourCCCodePCM16,	KSampleRate44100Hz,		KSampleRate22050Hz,	KStereo,	KMono,		_S("44KHzPCM16Stereo1KHzTone.au"),	_S("44KHzPCM16StereoAUTo22KHzPCM16Mono.raw"),	KErrNone },
    1.84 +	{ _S("MM-MMF-ACTRL-U-0045-HP"), {KMmfUidFormatAURead},	{KMmfUidFormatWAVWrite},	KMMFFourCCCodePCM16B,	KMMFFourCCCodePCM16,	KSampleRate22050Hz,		KSampleRate8000Hz,	KMono,		KMono,		_S("22KHzPCM16Mono1KHzTone.au"),	_S("22KHzPCM16MonoAUTo8KhzPCM16Mono.wav"),		KErrNone },
    1.85 +	{ _S("MM-MMF-ACTRL-U-0046-HP"), {KMmfUidFormatRAWRead},	{KMmfUidFormatWAVWrite},	KMMFFourCCCodeGSM610,	KMMFFourCCCodePCM16,	KSampleRate8000Hz,		KSampleRate8000Hz,	KMono,		KMono,		_S("8KHzGSM610Mono1KHzTone.raw"),	_S("8KHzGSM610MonoRAWTo8KHzPCM16Mono.wav"),		KErrNone },
    1.86 +	{ _S("MM-MMF-ACTRL-U-0047-HP"), {KMmfUidFormatRAWRead},	{KMmfUidFormatRAWWrite},	KMMFFourCCCodeALAW,		KMMFFourCCCodePCM16,	KSampleRate22050Hz,		KSampleRate11025Hz,	KStereo,	KMono,		_S("22KHzALAWStereo1KHzTone.raw"),	_S("22KHzALAWStereoRAWTo11KHzPCM16Mono.raw"),	KErrNone },
    1.87 +	{ _S("MM-MMF-ACTRL-U-0048-HP"), {KMmfUidFormatRAWRead},	{KMmfUidFormatWAVWrite},	KMMFFourCCCodePCM16,	KMMFFourCCCodeGSM610,	KSampleRate11025Hz,		KSampleRate8000Hz,	KMono,		KMono,		_S("11KHzPCM16Mono1KHzTone.raw"),	_S("11KHzPCM16MonoRAWTo8KHzGSM610Mono.wav"),	KErrNone },
    1.88 +	{ _S("MM-MMF-ACTRL-U-0049-HP"), {KMmfUidFormatWAVRead},	{KMmfUidFormatWAVWrite},	KMMFFourCCCodeALAW,		KMMFFourCCCodePCM16,	KSampleRate22050Hz,		KSampleRate8000Hz,	KMono,		KMono,		_S("22KHzALAWMono1KHzTone.wav"),	_S("22KHzALAWMonoWAVTo8KHzPCM16Mono.wav"),		KErrNone },
    1.89 +	{ _S("MM-MMF-ACTRL-U-0050-HP"), {KMmfUidFormatWAVRead},	{KMmfUidFormatWAVWrite},	KMMFFourCCCodePCM16,	KMMFFourCCCodeMuLAW,	KSampleRate11025Hz,		KSampleRate8000Hz,	KStereo,	KMono,		_S("11KHzPCM16Stereo1KHzTone.wav"), _S("11KHzPCM16StereoWAVTo8KHzMuLAWMono.wav"),	KErrNone },
    1.90 +	{ _S("MM-MMF-ACTRL-U-0051-HP"), {KMmfUidFormatWAVRead},	{KMmfUidFormatWAVWrite},	KMMFFourCCCodePCM16,	KMMFFourCCCodeGSM610,	KSampleRate8000Hz,		KSampleRate8000Hz,	KStereo,	KMono,		_S("8KHzPCM16Stereo1KHzTone.wav"),	_S("8KHzPCM16StereoWAVTo8KHzGSM610Mono.wav"),	KErrNone },
    1.91 +	
    1.92 +	// test 52 not currently supported - should return -5
    1.93 +	{ _S("MM-MMF-ACTRL-U-0052-HP"), {KMmfUidFormatAURead},	{KMmfUidFormatAUWrite},		KMMFFourCCCodePCM16B,	KMMFFourCCCodeIMAD,		KSampleRate22050Hz,		KSampleRate8000Hz,	KMono,		KMono,		_S("22KHzPCM16Mono1KHzTone.au"),	_S("NoReferenceFile"),	KErrNotSupported },
    1.94 +	
    1.95 +	{ _S("MM-MMF-ACTRL-U-0053-HP"), {KMmfUidFormatRAWRead},	{KMmfUidFormatAUWrite},		KMMFFourCCCodePCM16,	KMMFFourCCCodePCM16B,	KSampleRate44100Hz,		KSampleRate8000Hz,	KStereo,	KStereo,	_S("44KHzPCM16Stereo1KHzTone.raw"),	_S("44KHzPCM16StereoRAWTo8KHzPCM16Stereo.au"),	KErrNone },
    1.96 +	
    1.97 +	// test below will return -5
    1.98 +	{ _S("MM-MMF-ACTRL-U-0054-HP"),	{KMmfUidFormatWAVRead},	{KMmfUidFormatWAVWrite},	KMMFFourCCCodePCM16,	KMMFFourCCCodePCM16,	KSampleRate11025Hz,		KSampleRate44100Hz,	KStereo,	KStereo,	_S("11KHzPCM16Stereo1KHzTone.wav"),	_S("NoReferenceFile"),	KErrNotSupported },
    1.99 +	{ _S("MM-MMF-ACTRL-U-0055-HP"),	{KMmfUidFormatWAVRead},	{KMmfUidFormatAUWrite},		KMMFFourCCCodePCM16,	KMMFFourCCCodeIMAD,		KSampleRate22050Hz,		KSampleRate22050Hz,	KStereo,	KStereo,	_S("22KHzPCM16Stereo1KHzTone.wav"), _S("NoReferenceFile"),	KErrNotSupported },
   1.100 +
   1.101 +	// replacement for test 039 - see DEF017344
   1.102 +	{ _S("MM-MMF-ACTRL-U-0039-HP"),	{KMmfUidFormatAURead},	{KMmfUidFormatWAVWrite},	KMMFFourCCCodePCM8,		KMMFFourCCCodePCM16,	KSampleRate11025Hz,		KSampleRate8000Hz,	KMono,		KMono,		_S("NewMail.au"),					_S("11KHzPCMU8MonoAUTo8KHzPCM16Mono.wav"),		KErrNone },
   1.103 +
   1.104 +	//DEF025783 - Convert Stereo PCM16 to IMA ADPCM
   1.105 +	//Sink channels are not configured, we are testing if negotiation will do this
   1.106 +	{ _S("MM-MMF-ACTRL-U-0056-HP"),	{KMmfUidFormatWAVRead},	{KMmfUidFormatWAVWrite},	KMMFFourCCCodePCM16,	KMMFFourCCCodeIMAD,		KSampleRate11025Hz,		KSampleRate11025Hz,	KStereo,	KNone,		_S("11KHzPCM16Stereo1KHzTone.wav"),	_S("11KHzPCM16StereoWAVTo11KHzADPCMMono.wav"),	KErrNone },
   1.107 +	{ _S("MM-MMF-ACTRL-U-0057-HP"),	{KMmfUidFormatWAVRead},	{KMmfUidFormatRAWWrite},	KMMFFourCCCodePCM16,	KMMFFourCCCodeIMAD,		KSampleRate11025Hz,		KSampleRate11025Hz,	KStereo,	KNone,		_S("11KHzPCM16Stereo1KHzTone.wav"),	_S("11KHzPCM16StereoWAVTo11KHzADPCMMono.raw"),	KErrNone },
   1.108 +	//Configure sink channels to stereo expect KErrNotSupported
   1.109 +	{ _S("MM-MMF-ACTRL-U-0058-HP"),	{KMmfUidFormatWAVRead},	{KMmfUidFormatWAVWrite},	KMMFFourCCCodePCM16,	KMMFFourCCCodeIMAD,		KSampleRate11025Hz,		KSampleRate11025Hz,	KStereo,	KStereo,	_S("11KHzPCM16Stereo1KHzTone.wav"),	_S("11KHzPCM16StereoWAVTo11KHzADPCMMono.wav"),	KErrNotSupported },
   1.110 +	{ _S("MM-MMF-ACTRL-U-0059-HP"),	{KMmfUidFormatWAVRead},	{KMmfUidFormatRAWWrite},	KMMFFourCCCodePCM16,	KMMFFourCCCodeIMAD,		KSampleRate11025Hz,		KSampleRate11025Hz,	KStereo,	KStereo,	_S("11KHzPCM16Stereo1KHzTone.wav"),	_S("11KHzPCM16StereoWAVTo11KHzADPCMMono.raw"),	KErrNotSupported }
   1.111 +
   1.112 +};
   1.113 +
   1.114 +
   1.115 +/**
   1.116 +*
   1.117 +* Test step constructor.
   1.118 +* Each test step initialises its own name.
   1.119 +*
   1.120 +*/
   1.121 +CTestStepActrlPlay::CTestStepActrlPlay()
   1.122 +	{
   1.123 +	// store the name of this test case
   1.124 +	// this is the name that is used by the script file
   1.125 +	iTestStepName = _L("MM-MMF-ACTRL-U-0018-HP");
   1.126 +	}
   1.127 +
   1.128 +/**
   1.129 +*
   1.130 +* Test step destructor.
   1.131 +* 
   1.132 +*/
   1.133 +CTestStepActrlPlay::~CTestStepActrlPlay()
   1.134 +	{
   1.135 +	}
   1.136 +
   1.137 +
   1.138 +/**
   1.139 +* @xxxx
   1.140 +* Do the test step.
   1.141 +* @return	"TVerdict" the status of the test
   1.142 +*			The result of the test step 
   1.143 +*/
   1.144 +TVerdict CTestStepActrlPlay::DoTestStepL( void )
   1.145 +	{
   1.146 +	TVerdict result = EPass;
   1.147 +	
   1.148 +	_LIT( KTestPlay, "Play Test");
   1.149 +	Log( KTestPlay );
   1.150 +	
   1.151 +	_LIT( KTestStepPlay, "This test checks playing an audio clip");
   1.152 +	Log( KTestStepPlay );
   1.153 +	
   1.154 +	// [ audio file to play ]
   1.155 +	_LIT(KTestWavFile, "newmail.wav");
   1.156 +		//[ configure the filename ]
   1.157 +	SetReadFileNameL( KTestWavFile );
   1.158 +   	
   1.159 +	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
   1.160 +	User::LeaveIfError( errorCode );
   1.161 +	
   1.162 +	//[ add data source and sink and prime the controller ]
   1.163 +    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
   1.164 +	User::LeaveIfError( errorCode );
   1.165 +	
   1.166 +	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
   1.167 +    User::LeaveIfError( errorCode );
   1.168 +	
   1.169 +	errorCode =	iController.Prime();
   1.170 +	User::LeaveIfError( errorCode );
   1.171 +	
   1.172 +	// [ wait for and process the return event from the audio output ]
   1.173 +	
   1.174 +	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
   1.175 +	result = SearchForEvent( primeEvent );
   1.176 +	if( result == EFail )
   1.177 +		{
   1.178 +		return result;
   1.179 +		}
   1.180 +	
   1.181 +    User::LeaveIfError( iController.Play() );
   1.182 +	
   1.183 +	// note this test does not wait around 
   1.184 +	// to detect that the audio has been played
   1.185 +	// [ now process the confirmation event that play has reached audio output
   1.186 +	//   this is the raison detre of the test ]
   1.187 +	TMMFEvent playEvent( KPlayTestId, KErrNone );
   1.188 +	
   1.189 +	result = SearchForEvent( playEvent );
   1.190 +	
   1.191 +	//[ ensure the controller is unloaded so that it does 
   1.192 +	// not interfere with the following test ]
   1.193 +	// There is error in this code and the stop followed by reset
   1.194 +	// ensure the controller resources are released.
   1.195 +	iController.Stop();
   1.196 +	iController.Reset();
   1.197 +	iController.Close();  
   1.198 +
   1.199 +	// test steps return a result
   1.200 +	return result;
   1.201 +	}
   1.202 +
   1.203 +/**
   1.204 +*
   1.205 +* CTestStepPlayT
   1.206 +* @param aTimesToPlay
   1.207 +*
   1.208 +*/
   1.209 +CTestStepPlayT::CTestStepPlayT( TInt aTimesToPlay )
   1.210 +: iTimesToPlay( aTimesToPlay )
   1.211 +	{
   1.212 +	// store the name of this test case
   1.213 +	// this is the name that is used by the script file
   1.214 +	iTestStepName = _L("MM-MMF-ACTRL-U-0004-HP");
   1.215 +	}
   1.216 +
   1.217 +/**
   1.218 +* 
   1.219 +* ~CTestStepPlayT
   1.220 +*/
   1.221 +CTestStepPlayT::~CTestStepPlayT()
   1.222 +	{
   1.223 +	}
   1.224 +
   1.225 +/**
   1.226 +* Do the test step.
   1.227 +* Each test step must supply an implementation for DoTestStepL.
   1.228 +* This Test step will play an audio clip n 
   1.229 +* times
   1.230 +* @return	"TVerdict" the status of the test
   1.231 +*			The result of the test step 
   1.232 +*/
   1.233 +TVerdict CTestStepPlayT::DoTestStepL()
   1.234 +	{
   1.235 +	__MM_HEAP_MARK;
   1.236 +	TVerdict result = EPass;
   1.237 +	
   1.238 +	_LIT( KTestPlay, "Play Test");
   1.239 +	Log( KTestPlay );
   1.240 +	
   1.241 +	_LIT( KTestStepPlay, "This test checks playing an audio clip n times");
   1.242 +	Log( KTestStepPlay );
   1.243 +	
   1.244 +	// [ audio file to play ]
   1.245 +	_LIT(KTestWavFile, "newmail.wav");
   1.246 +	SetReadFileNameL( KTestWavFile );
   1.247 +   	
   1.248 +	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
   1.249 +	User::LeaveIfError( errorCode );
   1.250 +
   1.251 +	//[ add data source and sink and prime the controller ]
   1.252 +    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
   1.253 +	User::LeaveIfError( errorCode );
   1.254 +	
   1.255 +	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
   1.256 +    User::LeaveIfError( errorCode );
   1.257 +
   1.258 +	
   1.259 +	for( TInt iTimes = 0; iTimes < iTimesToPlay; iTimes++)
   1.260 +		{
   1.261 +		errorCode =	iController.Prime();
   1.262 +		User::LeaveIfError( errorCode );
   1.263 +		
   1.264 +		// [ wait for and process the return event from the audio output ]
   1.265 +		
   1.266 +		TMMFEvent primeEvent( KPrimeTestId, KErrNone);
   1.267 +		TVerdict primeResult = SearchForEvent( primeEvent );
   1.268 +		if( primeResult == EFail )
   1.269 +			{
   1.270 +			return primeResult;
   1.271 +			}
   1.272 +		
   1.273 +		User::LeaveIfError( iController.Play() );
   1.274 +		
   1.275 +		// note this test does not wait around 
   1.276 +		// to detect that the audio has been played
   1.277 +		// [ now process the confirmation event that play has reached audio output
   1.278 +		//   this is the raison detre of the test ]
   1.279 +		TMMFEvent playEvent( KPlayTestId, KErrNone );
   1.280 +		
   1.281 +		TVerdict playResult = SearchForEvent( playEvent );
   1.282 +		if( playResult == EFail )
   1.283 +			{
   1.284 +			return playResult ;
   1.285 +			}
   1.286 +		
   1.287 +		// [ lets ensure we are stopped ]
   1.288 +		User::LeaveIfError( iController.Stop() );
   1.289 +		}
   1.290 +	
   1.291 +	//[ ensure the controller is unloaded so that it does 
   1.292 +	// not interfere with the following test ]
   1.293 +	// There is error in this code and the stop followed by reset
   1.294 +	// ensure the controller resources are released.
   1.295 +	iController.Stop();
   1.296 +	iController.Reset();
   1.297 +	iController.Close();  
   1.298 +
   1.299 +	__MM_HEAP_MARKEND;  
   1.300 +	// test steps return a result
   1.301 +	return result;
   1.302 +	}
   1.303 +
   1.304 +/*
   1.305 +*
   1.306 +* CTestStepPause
   1.307 +*
   1.308 +*/
   1.309 +CTestStepPause::CTestStepPause()
   1.310 +	{
   1.311 +	iTestStepName = _L("MM-MMF-ACTRL-U-0011-HP");
   1.312 +	}
   1.313 +
   1.314 +/*
   1.315 +*
   1.316 +* ~CTestStepPause
   1.317 +*
   1.318 +*/
   1.319 +CTestStepPause::~CTestStepPause()
   1.320 +	{
   1.321 +	}
   1.322 +
   1.323 +/*
   1.324 +*
   1.325 +* DoTestStepL
   1.326 +* This test checks the pause function
   1.327 +*
   1.328 +*/
   1.329 +TVerdict CTestStepPause::DoTestStepL()
   1.330 +	{
   1.331 +	__MM_HEAP_MARK;
   1.332 +	
   1.333 +	TVerdict result = EFail;
   1.334 +	
   1.335 +	_LIT( KTestPlay, "Pause Test");
   1.336 +	Log( KTestPlay );
   1.337 +	
   1.338 +	_LIT( KTestStepPlay, "This test checks the pause function");
   1.339 +	Log( KTestStepPlay );
   1.340 +	
   1.341 +	// [ audio file to play ]
   1.342 +	_LIT(KTestWavFile, "newmail.wav");
   1.343 +	SetReadFileNameL( KTestWavFile );
   1.344 +	   	
   1.345 +	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
   1.346 +	User::LeaveIfError( errorCode );
   1.347 +		
   1.348 +	//[ add data source and sink and prime the controller ]
   1.349 +    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
   1.350 +	User::LeaveIfError( errorCode );
   1.351 +	
   1.352 +	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
   1.353 +    User::LeaveIfError( errorCode );
   1.354 +
   1.355 +    // [ The controller is in the stopped state 
   1.356 +	//   and should return an error if pause is called ]
   1.357 +		
   1.358 +	TInt pauseError = iController.Pause();
   1.359 +	if( pauseError == KErrNone )
   1.360 +		{
   1.361 +		// [ we should not be able to call pause while stopped ]
   1.362 +		result = EFail;
   1.363 +		return result ;
   1.364 +		}
   1.365 +
   1.366 +	TMMFEvent pauseFailEvent( KPauseTestId, pauseError );
   1.367 +	result = SearchForEvent( pauseFailEvent );
   1.368 +	if( result == EFail )
   1.369 +		{
   1.370 +		return result;
   1.371 +		}
   1.372 +	
   1.373 +	// [ move the contoller to the primed state ]
   1.374 +	errorCode =	iController.Prime();
   1.375 +	User::LeaveIfError( errorCode );
   1.376 +
   1.377 +	//[ call pause in the paused state
   1.378 +    // should return no error ]
   1.379 +	pauseError = iController.Pause();
   1.380 +	if( pauseError == KErrNone )
   1.381 +		{
   1.382 +		//[calling paused while paused returns an error]
   1.383 +		result = EFail;
   1.384 +		return result ;
   1.385 +		}
   1.386 +	
   1.387 +	// [ wait for and process the return event from the audio output ]	
   1.388 +	TMMFEvent primeEvent( KPrimeTestId, KErrNone );
   1.389 +	result = SearchForEvent( primeEvent );
   1.390 +	if( result == EFail )
   1.391 +		{
   1.392 +		return result;
   1.393 +		}
   1.394 +
   1.395 +	result = SearchForEvent( pauseFailEvent );
   1.396 +	if( result == EFail )
   1.397 +		{
   1.398 +		return result;
   1.399 +		}
   1.400 +	
   1.401 +    User::LeaveIfError( iController.Play() );
   1.402 +
   1.403 +	// [ process the play event ]
   1.404 +	TMMFEvent playEvent( KPlayTestId, KErrNone );
   1.405 +	result = SearchForEvent( playEvent );
   1.406 +	if( result == EFail )
   1.407 +		{
   1.408 +		return result;
   1.409 +		}
   1.410 +
   1.411 +	// [ now call pause when playing ]
   1.412 +	TMMFEvent pausePassEvent( KPauseTestId, KErrNone );
   1.413 +	pauseError = iController.Pause();
   1.414 +	if( pauseError != KErrNone )
   1.415 +		{
   1.416 +		//[calling paused while paused returns an error]
   1.417 +		result = EFail;
   1.418 +		return result ;
   1.419 +		}
   1.420 +
   1.421 +	// note this test does not wait around 
   1.422 +	// to detect that the audio has been played
   1.423 +	// [ now process the confirmation event that play has reached audio output
   1.424 +	//   this is the raison detre of the test ]
   1.425 +	result = SearchForEvent( pausePassEvent );
   1.426 +	if( result == EFail )
   1.427 +		{
   1.428 +		return result;
   1.429 +		}
   1.430 +
   1.431 +	// [ we should now be in the paused state 
   1.432 +	//   try playing ]
   1.433 +	User::LeaveIfError( iController.Play() );
   1.434 +	result = SearchForEvent( playEvent );
   1.435 +	if( result == EFail )
   1.436 +		{
   1.437 +		return result;
   1.438 +		}
   1.439 +
   1.440 +	//[ ensure the controller is unloaded so that it does 
   1.441 +	// not interfere with the following test ]
   1.442 +	// There is error in this code and the stop followed by reset
   1.443 +	// ensure the controller resources are released.
   1.444 +	iController.Stop();
   1.445 +	iController.Reset();
   1.446 +	iController.Close();  
   1.447 +	
   1.448 +	__MM_HEAP_MARKEND;    
   1.449 +
   1.450 +	return result;
   1.451 +	}
   1.452 +
   1.453 +/**
   1.454 +*
   1.455 +* CTestStepStop
   1.456 +*
   1.457 +*/
   1.458 +CTestStepStop::CTestStepStop()
   1.459 +	{
   1.460 +	iTestStepName = _L("MM-MMF-ACTRL-U-0012-HP");
   1.461 +	}
   1.462 +
   1.463 +/**
   1.464 +*
   1.465 +* ~CTestStepStop
   1.466 +*
   1.467 +*/
   1.468 +CTestStepStop::~CTestStepStop()
   1.469 +	{
   1.470 +	}
   1.471 +
   1.472 +/*
   1.473 +*
   1.474 +* DoTestStepL
   1.475 +* This test checks the stop function on the controller
   1.476 +*
   1.477 +*/
   1.478 +TVerdict CTestStepStop::DoTestStepL()
   1.479 +	{
   1.480 +	__MM_HEAP_MARK;
   1.481 +	
   1.482 +	TVerdict result = EFail;
   1.483 +	
   1.484 +	_LIT( KTestPlay, "Stop Test");
   1.485 +	Log( KTestPlay );
   1.486 +	
   1.487 +	_LIT( KTestStepPlay, "This test checks the stop function");
   1.488 +	Log( KTestStepPlay );
   1.489 +	
   1.490 +	// [ audio file to play ]
   1.491 +	_LIT(KTestWavFile, "newmail.wav");
   1.492 +	SetReadFileNameL( KTestWavFile );
   1.493 +	   	
   1.494 +	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
   1.495 +	User::LeaveIfError( errorCode );
   1.496 +
   1.497 +	//[ add data source and sink and prime the controller ]
   1.498 +    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
   1.499 +	User::LeaveIfError( errorCode );
   1.500 +	
   1.501 +	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
   1.502 +    User::LeaveIfError( errorCode );
   1.503 +
   1.504 +	//[ call stop while stopped ]
   1.505 +	User::LeaveIfError( iController.Stop() );
   1.506 +
   1.507 +
   1.508 +	// [ go to primed and call stop ]
   1.509 +	errorCode =	iController.Prime();
   1.510 +	User::LeaveIfError( errorCode );
   1.511 +	
   1.512 +	// [ wait for and process the return event from the audio output ]
   1.513 +	
   1.514 +	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
   1.515 +	result = SearchForEvent( primeEvent );
   1.516 +	if( result == EFail )
   1.517 +		{
   1.518 +		return result;
   1.519 +		}	
   1.520 +
   1.521 +	User::LeaveIfError( iController.Stop() );
   1.522 +
   1.523 +	// [ go to play and call stop ]
   1.524 +	errorCode =	iController.Prime();
   1.525 +	User::LeaveIfError( errorCode );
   1.526 +	
   1.527 +	// [ wait for and process the return event from the audio output ]
   1.528 +	
   1.529 +	result = SearchForEvent( primeEvent );
   1.530 +	if( result == EFail )
   1.531 +		{
   1.532 +		return result;
   1.533 +		}	
   1.534 +
   1.535 +	User::LeaveIfError( iController.Play() );
   1.536 +	
   1.537 +	// note this test does not wait around 
   1.538 +	// to detect that the audio has been played
   1.539 +	// [ now process the confirmation event that play has reached audio output
   1.540 +	//   this is the raison detre of the test ]
   1.541 +	TMMFEvent playEvent( KPlayTestId, KErrNone );
   1.542 +	result = SearchForEvent( playEvent );
   1.543 +	if( result == EFail )
   1.544 +		{
   1.545 +		return result;
   1.546 +		}
   1.547 +
   1.548 +	User::LeaveIfError( iController.Stop() );
   1.549 +
   1.550 +
   1.551 +	// [ go to prime from stopped via playing ]
   1.552 +	// [ stopped ]
   1.553 +    // [ prime   ]
   1.554 +	// [ play    ]
   1.555 +	// [ pause   ]
   1.556 +	// [ stop    ]
   1.557 +
   1.558 +	errorCode =	iController.Prime();
   1.559 +	User::LeaveIfError( errorCode );
   1.560 +	
   1.561 +	// [ wait for and process the return event from the audio output ]
   1.562 +	
   1.563 +	result = SearchForEvent( primeEvent );
   1.564 +	if( result == EFail )
   1.565 +		{
   1.566 +		return result;
   1.567 +		}	
   1.568 +
   1.569 +	User::LeaveIfError( iController.Play() );
   1.570 +	
   1.571 +	// note this test does not wait around 
   1.572 +	// to detect that the audio has been played
   1.573 +	// [ now process the confirmation event that play has reached audio output
   1.574 +	//   this is the raison detre of the test ]
   1.575 +	result = SearchForEvent( playEvent );
   1.576 +	if( result == EFail )
   1.577 +		{
   1.578 +		return result;
   1.579 +		}
   1.580 +
   1.581 +	// [ now call pause when playing ]
   1.582 +	TMMFEvent pausePassEvent( KPauseTestId, KErrNone );
   1.583 +	TInt pauseError = iController.Pause();
   1.584 +	if( pauseError != KErrNone )
   1.585 +		{
   1.586 +		//[calling paused while paused returns an error]
   1.587 +		result = EFail;
   1.588 +		return result ;
   1.589 +		}
   1.590 +
   1.591 +	// note this test does not wait around 
   1.592 +	// to detect that the audio has been played
   1.593 +	// [ now process the confirmation event that play has reached audio output
   1.594 +	//   this is the raison detre of the test ]
   1.595 +	result = SearchForEvent( pausePassEvent );
   1.596 +	if( result == EFail )
   1.597 +		{
   1.598 +		return result;
   1.599 +		}
   1.600 +
   1.601 +	// [ now stop from paused ]
   1.602 +	User::LeaveIfError( iController.Stop() );
   1.603 +	
   1.604 +	//[ ensure the controller is unloaded so that it does 
   1.605 +	// not interfere with the following test ]
   1.606 +	// There is error in this code and the stop followed by reset
   1.607 +	// ensure the controller resources are released.
   1.608 +	iController.Stop();
   1.609 +	iController.Reset();
   1.610 +	iController.Close();  
   1.611 +
   1.612 +	return result;
   1.613 +	}
   1.614 +
   1.615 +
   1.616 +/*
   1.617 +*
   1.618 +* CTestStepConvertFormat
   1.619 +*
   1.620 +*/
   1.621 +CTestStepConvertFormat::CTestStepConvertFormat( TUint aTestIndex )
   1.622 +	{
   1.623 +	// store a pointer to the test parameters
   1.624 +	iTestParameters = &(KTestParameters[aTestIndex]);
   1.625 +
   1.626 +	// store the name of this test case
   1.627 +	// this is the name that is used by the script file
   1.628 +	iTestStepName = iTestParameters->iTestName;
   1.629 +	}
   1.630 +
   1.631 +/*
   1.632 +*
   1.633 +* ~CTestStepConvertFormat
   1.634 +*
   1.635 +*/
   1.636 +CTestStepConvertFormat::~CTestStepConvertFormat()
   1.637 +	{
   1.638 +
   1.639 +
   1.640 +	}
   1.641 +
   1.642 +
   1.643 +// test preamble
   1.644 +TVerdict CTestStepConvertFormat::DoTestStepPreambleL(void)
   1.645 +	{
   1.646 +	// connect to the file server
   1.647 +	User::LeaveIfError(iFs.Connect());
   1.648 +
   1.649 +	// call the superclass
   1.650 +	return CTestStepActrl::DoTestStepPreambleL();
   1.651 +	}
   1.652 +
   1.653 +//test postamble
   1.654 +TVerdict CTestStepConvertFormat::DoTestStepPostambleL(void)
   1.655 +	{
   1.656 +	// close connection with the file server
   1.657 +	iFs.Close();
   1.658 +
   1.659 +	// call the superclass
   1.660 +	return CTestStepActrl::DoTestStepPostambleL();
   1.661 +	}
   1.662 +/**
   1.663 + *
   1.664 + * Compare two binary files
   1.665 + *
   1.666 + * @param "const TDesC& aFile1"
   1.667 + *		  The first file to compare
   1.668 + * @param "const TDesC& aFile2"
   1.669 + *		  The second file to compare
   1.670 + * @leave "" 
   1.671 + *		  Will leave with appropriate system codes if a problem is encountered reading either file 	
   1.672 + * @return "TVerdict"
   1.673 + *		  EPass if the files are identical
   1.674 + *		  EFail otherwise
   1.675 + * @xxxx
   1.676 + *
   1.677 + */
   1.678 +TVerdict CTestStepConvertFormat::CompareFilesL(const TDesC& aFile1,const TDesC& aFile2) 
   1.679 +	{
   1.680 +	RFile file1, file2;
   1.681 +
   1.682 +	User::LeaveIfError(file1.Open(iFs, aFile1, EFileShareAny | EFileStream | EFileRead));
   1.683 +	CleanupClosePushL(file1);
   1.684 +
   1.685 +	User::LeaveIfError(file2.Open(iFs, aFile2, EFileShareAny | EFileStream | EFileRead));
   1.686 +	CleanupClosePushL(file2);
   1.687 +
   1.688 +	TInt fileSize1, fileSize2;
   1.689 +
   1.690 +	TVerdict result = EPass;
   1.691 +	TInt blockSize = 1024;
   1.692 +	
   1.693 +	User::LeaveIfError(file1.Size(fileSize1));
   1.694 +	User::LeaveIfError(file2.Size(fileSize2));
   1.695 +
   1.696 +	if (fileSize1 == fileSize2) 
   1.697 +		{
   1.698 +		HBufC8* buf1 = HBufC8::NewMaxLC(blockSize);
   1.699 +		TPtr8 buf1Ptr(buf1->Des());
   1.700 +		HBufC8* buf2 = HBufC8::NewMaxLC(blockSize);
   1.701 +		TPtr8 buf2Ptr(buf2->Des());
   1.702 +
   1.703 +		TInt length = 0;
   1.704 +
   1.705 +		while (length<fileSize1 && result == EPass)
   1.706 +			{
   1.707 +			TInt copySize;
   1.708 +
   1.709 +			if (fileSize1 - length > blockSize)
   1.710 +				copySize = blockSize;
   1.711 +			else
   1.712 +				copySize = fileSize1 - length;
   1.713 +			User::LeaveIfError(file1.Read(buf1Ptr,copySize));
   1.714 +			User::LeaveIfError(file2.Read(buf2Ptr,copySize));
   1.715 +
   1.716 +			TInt comp_res = Mem::Compare(buf1Ptr.Ptr(),copySize,buf2Ptr.Ptr(),copySize);
   1.717 +			    
   1.718 +			if (comp_res!=0)
   1.719 +			    {
   1.720 +			    INFO_PRINTF5(_L("Comparison Failed, comparison failed (%S, %S), result=%d at offset %d"),
   1.721 +			            &aFile1, &aFile2, comp_res, length);
   1.722 +				result = EFail;
   1.723 +				break;
   1.724 +			    }
   1.725 +
   1.726 +			length += copySize;
   1.727 +			}
   1.728 +		CleanupStack::PopAndDestroy(2); // buf1, buf2
   1.729 +		}
   1.730 +	else
   1.731 +	    {
   1.732 +        INFO_PRINTF5(_L("Comparison Failed, files are different sizes (%S, %S), (%d,%d)"),
   1.733 +                &aFile1, &aFile2, fileSize1, fileSize2);
   1.734 +		result = EFail;
   1.735 +	    }
   1.736 +
   1.737 +	file1.Close();
   1.738 +	file2.Close();
   1.739 +
   1.740 +	CleanupStack::PopAndDestroy(2); //file1, file2
   1.741 +
   1.742 +	return result;
   1.743 +	}
   1.744 +/*
   1.745 +*
   1.746 +* DoTestStepL
   1.747 +* This test checks the stop function on the controller
   1.748 +*
   1.749 +*/
   1.750 +TVerdict CTestStepConvertFormat::DoTestStepL( void )
   1.751 +	{
   1.752 +	TVerdict result = EPass;
   1.753 +	TInt	error;
   1.754 +
   1.755 +	// do the conversion step
   1.756 +	TRAP(error, result = DoConvertStepL( ));
   1.757 +
   1.758 +	if (error != iTestParameters->iExpectedResult )
   1.759 +		{
   1.760 +		INFO_PRINTF2(_L("Error - Test step returned %d"), error);
   1.761 +		result = EFail;
   1.762 +		}
   1.763 +
   1.764 +	//[ delete output file after comparison]
   1.765 +	//[ here because DoTestStepL() can leave ]
   1.766 +	 TInt ret = iFs.Delete( WriteFileConfig()().iPath );
   1.767 +	 if (ret != KErrNone && ret != KErrNotFound)
   1.768 +		{
   1.769 +		INFO_PRINTF2(_L("Error deleting file - Delete returned %d"), ret);
   1.770 +		}
   1.771 +		
   1.772 +	//[ ensure the controller is unloaded so that it does 
   1.773 +	// not interfere with the following test ]
   1.774 +	// There is error in this code and the stop followed by reset
   1.775 +	// ensure the controller resources are released.
   1.776 +	iController.Stop();
   1.777 +	iController.Reset();
   1.778 +	iController.Close();  
   1.779 +
   1.780 +	return result;
   1.781 +	}
   1.782 +
   1.783 +/*
   1.784 +* DoConvertL( void )
   1.785 +* Do the conversion of the files
   1.786 +* @return	"TVerdict" the result of the convert operation
   1.787 +*/
   1.788 +TVerdict CTestStepConvertFormat::DoConvertStepL( void )
   1.789 +	{
   1.790 +	 TVerdict result = EPass;
   1.791 +	
   1.792 +	 _LIT( KTestConvertFormat, "Convert Formats Test");
   1.793 +	 Log( KTestConvertFormat );
   1.794 +	
   1.795 +	 _LIT( KTestStepPlay, "This test checks converting an audio clip");
   1.796 +	 Log( KTestStepPlay );
   1.797 +	
   1.798 +	 // get filename of input file
   1.799 +	 TInt strLen = User::StringLength(iTestParameters->iFromFilename);
   1.800 +	 TPtrC ptr( iTestParameters->iFromFilename, strLen );
   1.801 +	
   1.802 +	 //[ configure the filename ]
   1.803 +	 SetReadFileNameL( ptr );
   1.804 +	 
   1.805 +	 //[ configure reference filename ]
   1.806 +	 strLen = User::StringLength(iTestParameters->iRefFilename);
   1.807 +	 ptr.Set( iTestParameters->iRefFilename, strLen );
   1.808 +
   1.809 +	 SetRefFileNameL( ptr );
   1.810 +
   1.811 +	 // [ converted audio file name ]
   1.812 +	 //_LIT(KTestOutFile, "ConvertedOutput");
   1.813 +	 TBuf<32> testFileName = _L("ConvertedOutput");
   1.814 +
   1.815 +	 switch ( iTestParameters->iDestFormat.iUid )
   1.816 +		{
   1.817 +		case KMmfUidFormatRAWWrite:
   1.818 +			testFileName.Append( _L(".raw") );
   1.819 +			break;
   1.820 +
   1.821 +		case KMmfUidFormatWAVWrite:
   1.822 +			testFileName.Append( _L(".wav") );
   1.823 +			break;
   1.824 +
   1.825 +		case KMmfUidFormatAUWrite:
   1.826 +			testFileName.Append( _L(".au") );
   1.827 +			break;
   1.828 +
   1.829 +		default:
   1.830 +			// not a recognised output format - use .tmp
   1.831 +			testFileName.Append( _L(".tmp") );
   1.832 +			break;
   1.833 +		}	
   1.834 +
   1.835 +	 //[ configure the filename ]
   1.836 +	 SetWriteFileNameL( testFileName );
   1.837 +
   1.838 +	 // open the audio controller
   1.839 +	 TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
   1.840 +	 User::LeaveIfError( errorCode );
   1.841 +	
   1.842 +	 //[ add data source and sink and prime the controller ]
   1.843 +     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
   1.844 +	 User::LeaveIfError( errorCode );
   1.845 +	
   1.846 +	 errorCode = iController.AddDataSink(KUidMmfFileSink, WriteFileConfig());
   1.847 +     User::LeaveIfError( errorCode );
   1.848 +
   1.849 +	//[ attempt to get the sink num channels ]
   1.850 +    RMMFAudioControllerCustomCommands theCommander( iController );
   1.851 +	
   1.852 +	 // if source data is RAW then need to complete the source format
   1.853 +	 if ( iTestParameters->iSrcFormat.iUid == KMmfUidFormatRAWRead )
   1.854 +		{
   1.855 +		
   1.856 +		errorCode = theCommander.SetSourceFormat( iTestParameters->iSrcFormat );
   1.857 +		User::LeaveIfError( errorCode );
   1.858 +
   1.859 +		errorCode = theCommander.SetSourceDataType( iTestParameters->iSrcEncoding );
   1.860 +		User::LeaveIfError( errorCode );
   1.861 +		 
   1.862 +		errorCode = theCommander.SetSourceSampleRate( iTestParameters->iSrcSampleRate );
   1.863 +		User::LeaveIfError( errorCode );
   1.864 +
   1.865 +		errorCode = theCommander.SetSourceNumChannels( iTestParameters->iSrcChannels );
   1.866 +		User::LeaveIfError( errorCode );
   1.867 +		}	
   1.868 +
   1.869 +	 // set sink sample rate
   1.870 +	 errorCode = theCommander.SetSinkSampleRate( iTestParameters->iDestSampleRate );
   1.871 +	 User::LeaveIfError( errorCode );
   1.872 +
   1.873 +	 // set sink number of channels
   1.874 +	 if(iTestParameters->iDestChannels != KNone)
   1.875 +		 {
   1.876 +		 errorCode = theCommander.SetSinkNumChannels( iTestParameters->iDestChannels );
   1.877 +		 User::LeaveIfError( errorCode );
   1.878 +		 }
   1.879 +
   1.880 +	 //[ ok lets try to set the sink format ]
   1.881 +	 errorCode = theCommander.SetSinkFormat( iTestParameters->iDestFormat );
   1.882 +	 User::LeaveIfError( errorCode );
   1.883 +
   1.884 +	 //[ set the sink data type ]
   1.885 +	 errorCode = theCommander.SetSinkDataType( iTestParameters->iDestEncoding );
   1.886 +	 User::LeaveIfError( errorCode );
   1.887 +
   1.888 + 	 errorCode = iController.Prime();
   1.889 +	 User::LeaveIfError( errorCode );
   1.890 +	
   1.891 +	 // [ wait for and process the return event from the audio output ]
   1.892 +	 TMMFEvent primeEvent( KPrimeTestId, KErrNone);
   1.893 +	 result = SearchForEvent( primeEvent );
   1.894 +	 if( result == EFail )
   1.895 +		{
   1.896 +		return result;
   1.897 +		}
   1.898 +	
   1.899 +	 errorCode = iController.Play();
   1.900 +     User::LeaveIfError( errorCode );
   1.901 +	
   1.902 +	 // note this test does not wait around 
   1.903 +	 // to detect that the audio has been played
   1.904 +	 // [ now process the confirmation event that play has reached audio output
   1.905 +	 //   this is the raison detre of the test ]
   1.906 +	 TMMFEvent playEvent( KPlayTestId, KErrNone );
   1.907 +	
   1.908 +	 result = SearchForEvent( playEvent );
   1.909 +	 if( result == EFail )
   1.910 +		 {
   1.911 +		 return result;
   1.912 +		 }
   1.913 +
   1.914 +	 //[ now wait for play complete event]
   1.915 +	 TMMFEvent playCompleteEvent( KPlayCompleteTestId, KErrNone);
   1.916 +	 result = SearchForEvent( playCompleteEvent );
   1.917 +	 if( result == EFail )
   1.918 +		{
   1.919 +		return result;
   1.920 +		}
   1.921 +
   1.922 +	 //[ now compare the file produced with a reference file ]
   1.923 +	 INFO_PRINTF1(_L("Comparing file to reference..."));
   1.924 +	 result = CompareFilesL( RefFileName()().iPath, WriteFileConfig()().iPath);
   1.925 +	 
   1.926 +	 if (result == EFail)
   1.927 +		 {
   1.928 +		 INFO_PRINTF1(_L("Comparison Failed - Files are not identical !"));
   1.929 +		 }
   1.930 +	
   1.931 +
   1.932 +	 return result;
   1.933 +	}
   1.934 +
   1.935 +/*
   1.936 +*
   1.937 +* SetRefFileNameL
   1.938 +*
   1.939 +*/
   1.940 +void CTestStepConvertFormat::SetRefFileNameL( const TDesC& aPathNameAndExtn )
   1.941 +	{
   1.942 +	//[ append the filename relative to the default path ]
   1.943 +	TFileName fileName = GetSuite()->DefaultPath();
   1.944 +	fileName.Append(aPathNameAndExtn);
   1.945 +	iFileConfigRef().iPath = fileName ;
   1.946 +	}
   1.947 +/*
   1.948 +*
   1.949 +* RefFileName
   1.950 +*
   1.951 +*/
   1.952 +TMMFFileConfig& CTestStepConvertFormat::RefFileName()
   1.953 +	{
   1.954 +	return iFileConfigRef;
   1.955 +	}
   1.956 +
   1.957 +/*
   1.958 +*
   1.959 +* CTestStepRampVolume
   1.960 +*/
   1.961 +CTestStepRampVolume::CTestStepRampVolume()
   1.962 +	{
   1.963 +	iTestStepName = _L("MM-MMF-ACTRL-U-0064-HP");
   1.964 +	}
   1.965 +
   1.966 +/*
   1.967 +*
   1.968 +* ~CTestStepRampVolume
   1.969 +*/
   1.970 +CTestStepRampVolume::~CTestStepRampVolume()
   1.971 +	{
   1.972 +	}
   1.973 +
   1.974 +/*
   1.975 +*
   1.976 +* CTestStepRampVolume
   1.977 +*/
   1.978 +TVerdict CTestStepRampVolume::DoTestStepL()
   1.979 +	{
   1.980 +	TVerdict result = EPass;
   1.981 +	
   1.982 +	_LIT( KTestVolumeRamp, "Volume Ramp Test");
   1.983 +	Log( KTestVolumeRamp );
   1.984 +	
   1.985 +	_LIT( KTestStepPlay, "This test checks volume ramp");
   1.986 +	Log( KTestStepPlay );
   1.987 +	
   1.988 +	// [ audio file to play ]
   1.989 +	_LIT(KTestWavFile, "RampVolume.wav");
   1.990 +		//[ configure the filename ]
   1.991 +	SetReadFileNameL( KTestWavFile );
   1.992 +   	
   1.993 +	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
   1.994 +	User::LeaveIfError( errorCode );
   1.995 +	
   1.996 +	//[ add data source and sink and prime the controller ]
   1.997 +    errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
   1.998 +	User::LeaveIfError( errorCode );
   1.999 +	
  1.1000 +	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
  1.1001 +    User::LeaveIfError( errorCode );
  1.1002 +	
  1.1003 +	errorCode =	iController.Prime();
  1.1004 +	User::LeaveIfError( errorCode );
  1.1005 +	
  1.1006 +	// [ wait for and process the return event from the audio output ]
  1.1007 +	//[ attempt to get the sink num channels ]
  1.1008 +    RMMFAudioPlayDeviceCustomCommands theCommander( iController );
  1.1009 +	//[lets say 2 seconds for now ]
  1.1010 +	TTimeIntervalMicroSeconds aRampDuration( 2000000);
  1.1011 +	errorCode = theCommander.SetVolumeRamp( aRampDuration);
  1.1012 +	User::LeaveIfError( errorCode );
  1.1013 +	
  1.1014 +	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
  1.1015 +	result = SearchForEvent( primeEvent );
  1.1016 +	if( result == EFail )
  1.1017 +		{
  1.1018 +		return result;
  1.1019 +		}
  1.1020 +
  1.1021 +	//[ lets set the volume ramp before we play ]
  1.1022 +    
  1.1023 +	
  1.1024 +    User::LeaveIfError( iController.Play() );
  1.1025 +	
  1.1026 +	// note this test does not wait around 
  1.1027 +	// to detect that the audio has been played
  1.1028 +	// [ now process the confirmation event that play has reached audio output
  1.1029 +	//   this is the raison detre of the test ]
  1.1030 +	TMMFEvent playEvent( KPlayTestId, KErrNone );
  1.1031 +	result = SearchForEvent( playEvent );
  1.1032 +	if( result == EFail )
  1.1033 +		{
  1.1034 +		return EFail;
  1.1035 +		}
  1.1036 +
  1.1037 +	//[ now wait for play complete event]
  1.1038 +	 TMMFEvent playCompleteEvent( KPlayCompleteTestId, KErrNone);
  1.1039 +	 result = SearchForEvent( playCompleteEvent );
  1.1040 +	 if( result == EFail )
  1.1041 +		{
  1.1042 +		return EFail;
  1.1043 +		}
  1.1044 +		
  1.1045 +	//[ ensure the controller is unloaded so that it does 
  1.1046 +	// not interfere with the following test ]
  1.1047 +	// There is error in this code and the stop followed by reset
  1.1048 +	// ensure the controller resources are released.
  1.1049 +	iController.Stop();
  1.1050 +	iController.Reset();
  1.1051 +	iController.Close();  
  1.1052 +
  1.1053 +	// test steps return a result
  1.1054 +	return result;
  1.1055 +	}
  1.1056 +
  1.1057 +/*
  1.1058 +*
  1.1059 +* CTestStepRampVolume
  1.1060 +*/
  1.1061 +TVerdict CTestStepRampVolume::DoTestStepPreambleL(void)
  1.1062 +	{
  1.1063 +	return EPass;
  1.1064 +	}
  1.1065 +
  1.1066 +/*
  1.1067 +*
  1.1068 +* CTestStepRampVolume
  1.1069 +*/
  1.1070 +TVerdict CTestStepRampVolume::DoTestStepPostambleL(void)
  1.1071 +	{
  1.1072 +	return CTestStepActrl::DoTestStepPostambleL();
  1.1073 +	}
  1.1074 +