sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: // Implementation of Integraton test step classes for A3F DevSound Tone test cases.
sl@0: // 
sl@0: //
sl@0: 
sl@0: #include "tsi_a3f_devsound_tone.h"
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RTestStepA3FDevSoundToneBase - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RTestStepA3FDevSoundToneBase::RTestStepA3FDevSoundToneBase(const TDesC& aTestName, const TDesC& aSectName)
sl@0: :RAsyncTestStep(),
sl@0:  iMMFDevSound(NULL),
sl@0:  iSectName(aSectName),
sl@0:  iTimer(NULL),
sl@0:  iCallBack(NULL, NULL),
sl@0:  iState(EStateToneStart)
sl@0: 	{
sl@0: 	// From RTestStep
sl@0: 	iTestStepName = aTestName; // store the name of the test case
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RTestStepA3FDevSoundToneBase - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RTestStepA3FDevSoundToneBase::RTestStepA3FDevSoundToneBase(const TDesC& aTestName)
sl@0: :RAsyncTestStep(),
sl@0:  iMMFDevSound(NULL),
sl@0:  iSectName(KNullDesC),
sl@0:  iTimer(NULL),
sl@0:  iCallBack(NULL, NULL),
sl@0:  iState(EStateToneStart)
sl@0: 	{
sl@0: 	// From RTestStep
sl@0: 	iTestStepName = aTestName; // store the name of the test case
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * KickoffTestL
sl@0:  * - Starts the test
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundToneBase::KickoffTestL()
sl@0: 	{
sl@0: 	// Create instance of CMMFDevSound
sl@0: 	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0: 	iMMFDevSound = CMMFDevSound::NewL();
sl@0: 
sl@0: 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
sl@0: 	
sl@0: 	DoKickoffTestL();
sl@0: 
sl@0: 	Fsm(EEventToneStart,KErrNone); // call to start the DevSound finite state machine for tone playing
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * CloseTest
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundToneBase::CloseTest()
sl@0: 	{
sl@0: 	if (iMMFDevSound)
sl@0: 		{
sl@0: 		INFO_PRINTF1(_L("--- Deleting DevSound object..."));
sl@0: 		delete iMMFDevSound;
sl@0: 		iMMFDevSound = NULL;
sl@0: 		}
sl@0: 	
sl@0: 	if (iTimer)
sl@0: 		{
sl@0: 		delete iTimer;
sl@0: 		iTimer = NULL;
sl@0: 		}
sl@0: 		
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * InitializeComplete
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundToneBase::InitializeComplete(TInt aError)
sl@0: 	{
sl@0: 	Fsm(EEventInitCompleteTone,aError);
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * ToneFinished
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundToneBase::ToneFinished(TInt aError)
sl@0: 	{
sl@0: 	if ((aError == KErrUnderflow))
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("DevSound called ToneFinished with error = %d as expected"), aError);
sl@0: 		StopTest(aError,EPass);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("DevSound called ToneFinished with error = %d that was NOT expected"), aError);
sl@0: 		StopTest(aError);
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * BufferToBeFilled
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundToneBase::BufferToBeFilled(CMMFBuffer* /*aBuffer*/)
sl@0: 	{
sl@0: 	__ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundToneBase"),EInvalidCallbackCall));
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * PlayError
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundToneBase::PlayError(TInt /*aError*/)
sl@0: 	{
sl@0: 	__ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundToneBase"),EInvalidCallbackCall));
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RecordError
sl@0:  *
sl@0:  */
sl@0: 
sl@0: void RTestStepA3FDevSoundToneBase::RecordError(TInt /*aError*/)
sl@0: 	{
sl@0: 	__ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundToneBase"),EInvalidCallbackCall));
sl@0: 
sl@0: 	}
sl@0: /*
sl@0:  *
sl@0:  * BufferToBeEmptied
sl@0:  *
sl@0:  */
sl@0: 
sl@0: void RTestStepA3FDevSoundToneBase::BufferToBeEmptied(CMMFBuffer* /*aBuffer*/)
sl@0: 	{
sl@0: 	__ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundToneBase"),EInvalidCallbackCall));
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * ConvertError
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundToneBase::ConvertError(TInt /*aError*/)
sl@0: 	{
sl@0: 	__ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundToneBase"),EInvalidCallbackCall));
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DeviceMessage
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundToneBase::DeviceMessage(TUid /*aMessageType*/, const TDesC8& /*aMsg*/)
sl@0: 	{
sl@0: 	__ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundToneBase"),EInvalidCallbackCall));
sl@0: 
sl@0: 	}
sl@0: 	
sl@0: /*
sl@0:  *
sl@0:  * TimerCallback
sl@0:  *
sl@0:  */
sl@0: TInt RTestStepA3FDevSoundToneBase::TimerCallback(TAny* aPtr)
sl@0: 	{
sl@0: 	static_cast<RTestStepA3FDevSoundToneBase*>(aPtr)->DoTimerCallback();
sl@0: 	return KErrNone;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoTimerCallback
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundToneBase::DoTimerCallback()
sl@0: 	{
sl@0: 	// The derived classes may provide the implementation if needed
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * ConvertDesToTMMFSampleRate
sl@0:  *
sl@0:  */
sl@0: TUint RTestStepA3FDevSoundToneBase::ConvertDesToTMMFSampleRate(const TDesC& aSampleRateString)
sl@0: 	{
sl@0: 	TUint rate = 0;
sl@0: 
sl@0: 	STR_SWITCH(aSampleRateString)
sl@0: 
sl@0: 	STR_CASE(_L("EMMFSampleRate8000Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate8000Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate11025Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate11025Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate12000Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate12000Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate16000Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate16000Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate22050Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate22050Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate24000Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate24000Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate32000Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate32000Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate44100Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate44100Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate48000Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate48000Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate64000Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate64000Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate88200Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate88200Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate96000Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate96000Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("InvalidRate"))
sl@0: 		{
sl@0: 		rate = 0x90000000;
sl@0: 		break;
sl@0: 		}
sl@0: 
sl@0: 	DEFAULT_CASE()
sl@0: 		{
sl@0: 		ERR_PRINTF1(_L("Attempt to convert invalid sample rate"));
sl@0: 		StopTest(KErrGeneral);
sl@0: 		}
sl@0: 
sl@0: 	STR_SWITCH_END()
sl@0: 
sl@0: 	INFO_PRINTF2(_L("Sample Rate = %S"), &aSampleRateString);
sl@0: 	return rate;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundDTMFTonePlay
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundDTMFTonePlay - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundDTMFTonePlay::RStepA3FDevSoundDTMFTonePlay(const TDesC& aTestName)
sl@0: :RTestStepA3FDevSoundToneBase(aTestName)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundDTMFTonePlay* RStepA3FDevSoundDTMFTonePlay::NewL(const TDesC& aTestName)
sl@0: 	{
sl@0: 	RStepA3FDevSoundDTMFTonePlay* self = new (ELeave) RStepA3FDevSoundDTMFTonePlay(aTestName);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoKickoffTestL
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundDTMFTonePlay::DoKickoffTestL()
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  * - Executes DTMF tone playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundDTMFTonePlay::Fsm(TDevSoundToneEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iState)
sl@0: 		{
sl@0: 		case EStateToneStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundDTMFTonePlay"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventToneStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for tone play
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStateToneInitializing"));
sl@0: 				iState = EStateToneInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventToneStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 
sl@0: 			}
sl@0: 
sl@0: 		case EStateToneInitializing:
sl@0: 			{
sl@0: 			if (aDevSoundEvent == EEventInitCompleteTone && aError == KErrNone)
sl@0: 				{
sl@0: 				TPtrC dtmfString = (_L("0123456789,abcdef,*#"));
sl@0: 				TTimeIntervalMicroSeconds32 on(KMicroSecsInOneSec), off(KMicroSecsInOneSec), pause(0);
sl@0: 				// Define the duration of tone on, tone off and tone pause to be used during the DTMF tone playback operation
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::SetDTMFLengths"));
sl@0: 				iMMFDevSound->SetDTMFLengths(on,off,pause);
sl@0: 				// Initialize the audio device and start playing the DTMF string
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayDTMFStringL"));
sl@0: 				TRAPD(err, iMMFDevSound->PlayDTMFStringL(dtmfString));
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::PlayDTMFStringL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStateTonePlaying"));
sl@0: 				iState = EStateTonePlaying;
sl@0: 
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventInitCompleteTone && aError != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0: 				StopTest(aError);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventInitCompleteTone not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 
sl@0: 			}
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundNormalAndDualTonePlay
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundNormalAndDualTonePlay - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundNormalAndDualTonePlay::RStepA3FDevSoundNormalAndDualTonePlay(const TDesC& aTestName, const TDesC& aSectName)
sl@0: :RTestStepA3FDevSoundToneBase(aTestName, aSectName),
sl@0:  iRepeat(0),
sl@0:  iDualTone(EFalse)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundNormalAndDualTonePlay* RStepA3FDevSoundNormalAndDualTonePlay::NewL(const TDesC& aTestName, const TDesC& aSectName)
sl@0: 	{
sl@0: 	RStepA3FDevSoundNormalAndDualTonePlay* self = new (ELeave) RStepA3FDevSoundNormalAndDualTonePlay(aTestName, aSectName);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoKickoffTestL
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundNormalAndDualTonePlay::DoKickoffTestL()
sl@0: 	{
sl@0: 	//Getting the number of times the audio is to be repeated during the tone playback operation
sl@0: 	if (GetIntFromConfig(iSectName,_L("Repeat"),iRepeat))
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("Repeat count taken from config file: %d"),iRepeat);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("Default repeat count used: %d"), iRepeat);
sl@0: 		}
sl@0: 
sl@0: 	// Getting the boolean flag value indicating whether dual tone playback should occur instead of the normal tone playback
sl@0: 	if (GetBoolFromConfig(iSectName,_L("DualTone"),iDualTone))
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("Boolean value indicating whether to use dual tone playback taken from config file: %d"),iDualTone);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("Default boolean value indicating whether to use dual tone playback used: %d"), iDualTone);
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  * - Executes either the normal or dual tone playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundNormalAndDualTonePlay::Fsm(TDevSoundToneEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iState)
sl@0: 		{
sl@0: 		case EStateToneStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundNormalAndDualTonePlay"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventToneStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for tone play
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStateToneInitializing"));
sl@0: 				iState = EStateToneInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventToneStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 
sl@0: 			}
sl@0: 
sl@0: 		case EStateToneInitializing:
sl@0: 			{
sl@0: 			if (aDevSoundEvent == EEventInitCompleteTone && aError == KErrNone)
sl@0: 				{
sl@0: 				TTimeIntervalMicroSeconds repeatTrailingSilence(KMicroSecsInOneSec), duration(KMicroSecsInOneSec);
sl@0: 				// Define the number of times the audio is to be repeated during the tone playback operation
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::SetToneRepeats"));
sl@0: 				iMMFDevSound->SetToneRepeats(iRepeat, repeatTrailingSilence);
sl@0: 				if (iDualTone)
sl@0: 					{
sl@0: 					// Initialize audio device and start playing a dual tone
sl@0: 					INFO_PRINTF1(_L("Calling CMMFDevSound::PlayDualToneL"));
sl@0: 					TRAPD(err, iMMFDevSound->PlayDualToneL(KFrequency1, KFrequency2, duration));
sl@0: 					if (err != KErrNone)
sl@0: 						{
sl@0: 						ERR_PRINTF2(_L("CMMFDevSound::PlayDualToneL left with error = %d"), err);
sl@0: 						StopTest(err);
sl@0: 						break;
sl@0: 						}
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					// Initialize the audio device and start playing a tone
sl@0: 					INFO_PRINTF1(_L("Calling CMMFDevSound::PlayToneL"));
sl@0: 					TRAPD(err, iMMFDevSound->PlayToneL(KFrequency1, duration));
sl@0: 					if (err != KErrNone)
sl@0: 						{
sl@0: 						ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error = %d"), err);
sl@0: 						StopTest(err);
sl@0: 						break;
sl@0: 						}
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStateTonePlaying"));
sl@0: 				iState = EStateTonePlaying;
sl@0: 
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventInitCompleteTone && aError != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0: 				StopTest(aError);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventInitCompleteTone not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 
sl@0: 			}
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundInitializeWhileTonePlaying
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundInitializeWhileTonePlaying - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundInitializeWhileTonePlaying::RStepA3FDevSoundInitializeWhileTonePlaying(const TDesC& aTestName)
sl@0: :RTestStepA3FDevSoundToneBase(aTestName)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundInitializeWhileTonePlaying* RStepA3FDevSoundInitializeWhileTonePlaying::NewL(const TDesC& aTestName)
sl@0: 	{
sl@0: 	RStepA3FDevSoundInitializeWhileTonePlaying* self = new (ELeave) RStepA3FDevSoundInitializeWhileTonePlaying(aTestName);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoKickoffTestL
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundInitializeWhileTonePlaying::DoKickoffTestL()
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundInitializeWhileTonePlaying::Fsm(TDevSoundToneEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iState)
sl@0: 		{
sl@0: 		case EStateToneStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInitializeWhileTonePlaying"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventToneStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for tone play
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStateToneInitializing"));
sl@0: 				iState = EStateToneInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventToneStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 
sl@0: 			}
sl@0: 
sl@0: 		case EStateToneInitializing:
sl@0: 			{
sl@0: 			if (aDevSoundEvent == EEventInitCompleteTone && aError == KErrNone)
sl@0: 				{
sl@0: 				TTimeIntervalMicroSeconds duration(KMicroSecsInTenSecs);
sl@0: 				// Initialize the audio device and start playing a tone
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayToneL"));
sl@0: 				TRAPD(err, iMMFDevSound->PlayToneL(KFrequency1, duration));
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStateTonePlaying"));
sl@0: 				iState = EStateTonePlaying;
sl@0: 
sl@0: 				// Calling CMMFDevSound::InitializeL again while tone playing!
sl@0: 				INFO_PRINTF1(_L("CMMFDevSound::InitializeL called again while tone playing!"));
sl@0: 				TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
sl@0: 				if (err == KErrNotReady)
sl@0: 					{
sl@0: 					INFO_PRINTF2(_L("CMMFDevSound::InitializeL left as expected with error = %d"), err);
sl@0: 					StopTest(err,EPass);
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL did NOT leave with KErrNotReady as expected. Error = %d"), err);
sl@0: 					StopTest(KErrUnknown);
sl@0: 					}
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventInitCompleteTone && aError != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0: 				StopTest(aError);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventInitCompleteTone not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 
sl@0: 			}
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundNotSupportedPlayFixedSeq
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundNotSupportedPlayFixedSeq - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundNotSupportedPlayFixedSeq::RStepA3FDevSoundNotSupportedPlayFixedSeq(const TDesC& aTestName)
sl@0: :RTestStepA3FDevSoundToneBase(aTestName)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundNotSupportedPlayFixedSeq* RStepA3FDevSoundNotSupportedPlayFixedSeq::NewL(const TDesC& aTestName)
sl@0: 	{
sl@0: 	RStepA3FDevSoundNotSupportedPlayFixedSeq* self = new (ELeave) RStepA3FDevSoundNotSupportedPlayFixedSeq(aTestName);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoKickoffTestL
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundNotSupportedPlayFixedSeq::DoKickoffTestL()
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundNotSupportedPlayFixedSeq::Fsm(TDevSoundToneEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iState)
sl@0: 		{
sl@0: 		case EStateToneStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundNotSupportedPlayFixedSeq"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventToneStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for tone play
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStateToneInitializing"));
sl@0: 				iState = EStateToneInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventToneStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 
sl@0: 			}
sl@0: 
sl@0: 		case EStateToneInitializing:
sl@0: 			{
sl@0: 			if (aDevSoundEvent == EEventInitCompleteTone && aError == KErrNone)
sl@0: 				{
sl@0: 				TInt seqCount = iMMFDevSound->FixedSequenceCount();
sl@0: 				if (seqCount != 0)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::FixedSequenceCount() did not return 0 as always expected. It returned %d instead!"), seqCount);
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					INFO_PRINTF1(_L("CMMFDevSound::FixedSequenceCount() call returned 0 as always expected"));
sl@0: 					}
sl@0: 				// Initialize the audio device and start playing the specified pre-defined tone sequence.
sl@0: 				INFO_PRINTF1(_L("Calling the not supported CMMFDevSound::PlayFixedSequenceL"));
sl@0: 				TRAPD(err, iMMFDevSound->PlayFixedSequenceL(0));
sl@0: 				if (err == KErrNotSupported)
sl@0: 					{
sl@0: 					INFO_PRINTF2(_L("CMMFDevSound::PlayFixedSequenceL left as expected with error = %d"), err);
sl@0: 					StopTest(err,EPass);
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::PlayFixedSequenceL did NOT leave with KErrNotSupported as expected. Error = %d"), err);
sl@0: 					StopTest(KErrUnknown);
sl@0: 					}
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventInitCompleteTone && aError != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0: 				StopTest(aError);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventInitCompleteTone not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 
sl@0: 			}
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundInvalidInitializeForTone
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundInvalidInitializeForTone - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundInvalidInitializeForTone::RStepA3FDevSoundInvalidInitializeForTone(const TDesC& aTestName)
sl@0: :RTestStepA3FDevSoundToneBase(aTestName)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundInvalidInitializeForTone* RStepA3FDevSoundInvalidInitializeForTone::NewL(const TDesC& aTestName)
sl@0: 	{
sl@0: 	RStepA3FDevSoundInvalidInitializeForTone* self = new (ELeave) RStepA3FDevSoundInvalidInitializeForTone(aTestName);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoKickoffTestL
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundInvalidInitializeForTone::DoKickoffTestL()
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundInvalidInitializeForTone::Fsm(TDevSoundToneEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iState)
sl@0: 		{
sl@0: 		case EStateToneStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInvalidInitializeForTone"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventToneStart)
sl@0: 				{
sl@0: 				TFourCC fourCCCodeMP3(KMMFFourCCCodeMP3);
sl@0: 				// Initializing DevSound object for tone play using invalid version of CMMFDevSound::InitializeL
sl@0: 				INFO_PRINTF1(_L("Calling invalid version of CMMFDevSound::InitializeL for tone play..."));
sl@0: 				TRAPD(err, iMMFDevSound->InitializeL(*this, fourCCCodeMP3, EMMFStateTonePlaying));
sl@0: 				if (err == KErrNotSupported)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left as expected with error = %d"), err);
sl@0: 					StopTest(err,EPass);
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL did NOT leave with KErrNotSupported as expected. Error = %d"), err);
sl@0: 					StopTest(KErrUnknown);
sl@0: 					}
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventToneStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 
sl@0: 			}
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundCancelInitializeTone
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundCancelInitializeTone - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundCancelInitializeTone::RStepA3FDevSoundCancelInitializeTone(const TDesC& aTestName, const TDesC& aSectName)
sl@0: :RTestStepA3FDevSoundToneBase(aTestName, aSectName)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundCancelInitializeTone* RStepA3FDevSoundCancelInitializeTone::NewL(const TDesC& aTestName, const TDesC& aSectName)
sl@0: 	{
sl@0: 	RStepA3FDevSoundCancelInitializeTone* self = new (ELeave) RStepA3FDevSoundCancelInitializeTone(aTestName, aSectName);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoKickoffTestL
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundCancelInitializeTone::DoKickoffTestL()
sl@0: 	{
sl@0: 	}
sl@0: 	
sl@0: /*
sl@0:  *
sl@0:  * InitializeComplete
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundCancelInitializeTone::InitializeComplete(TInt aError)
sl@0: 	{
sl@0: 	INFO_PRINTF1(_L("InitializeComplete callback was received. This is not the expected behaviour"));
sl@0: 	INFO_PRINTF1(_L("InitializeL was not cancelled"));
sl@0: 	StopTest(aError, EFail);
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoTimerCallback
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundCancelInitializeTone::DoTimerCallback()
sl@0: 	{
sl@0: 	iTimer->Cancel(); // only really wanted a one-shot
sl@0: 	INFO_PRINTF1(_L("InitializeComplete callback was not received. This is the expected behaviour"));
sl@0: 	INFO_PRINTF1(_L("Use SetConfigL to verify that DevSound has not been initialised"));
sl@0: 	TMMFCapabilities capabilities;
sl@0: 
sl@0: 	if(!GetStringFromConfig(iSectName, _L("SampleRate"), iSampleRate))
sl@0: 		{
sl@0: 		TPtrC keyName(_L("SampleRate"));
sl@0: 		ERR_PRINTF3(_L("Error in getting sample rate from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0: 	TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));	
sl@0: 	if(errConfig == KErrNotReady)
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("SetConfigL returned with %d as expected"), errConfig);
sl@0: 		INFO_PRINTF1(_L("InitializeL was cancelled successfully"));
sl@0: 		StopTest(KErrNone);
sl@0: 		}
sl@0: 	else if (errConfig == KErrNone)
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("SetConfigL returned with KErrNone %d"), errConfig);
sl@0: 		INFO_PRINTF1(_L("InitializeL was not cancelled successfully"));
sl@0: 		StopTest(errConfig, EFail);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("SetConfigL returned with unexpected error %d"), errConfig);
sl@0: 		StopTest(errConfig, EFail);
sl@0: 		}
sl@0: 	}
sl@0: 	
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes Toneing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundCancelInitializeTone::Fsm(TDevSoundToneEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iState)
sl@0: 		{
sl@0: 		case EStateToneStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundCancelInitializeTone"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventToneStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for TonePlaying mode
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					INFO_PRINTF1(_L("State: EStateToneInitializing"));
sl@0: 					iState = EStateToneInitializing;					
sl@0: 					INFO_PRINTF1(_L("Calling CMMFDevSound::CancelInitialize()"));
sl@0: 					iMMFDevSound->CancelInitialize();
sl@0: 					INFO_PRINTF1(_L("Start timer to wait for InitializeComplete"));
sl@0: 					TCallBack callback (TimerCallback, this);
sl@0: 					iTimer->Start(KMicroSecsInTenSecs, 0, callback);
sl@0: 					}
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventToneStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundEmptyBuffersInitializedForTone
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundInitializeWhileTonePlaying - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundEmptyBuffersInitializedForTone::RStepA3FDevSoundEmptyBuffersInitializedForTone(const TDesC& aTestName, const TDesC& aSectName)
sl@0: :RTestStepA3FDevSoundToneBase(aTestName, aSectName)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundEmptyBuffersInitializedForTone* RStepA3FDevSoundEmptyBuffersInitializedForTone::NewL(const TDesC& aTestName, const TDesC& aSectName)
sl@0: 	{
sl@0: 	RStepA3FDevSoundEmptyBuffersInitializedForTone* self = new (ELeave) RStepA3FDevSoundEmptyBuffersInitializedForTone(aTestName, aSectName);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoKickoffTestL
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundEmptyBuffersInitializedForTone::DoKickoffTestL()
sl@0: 	{
sl@0: 	}
sl@0: 	
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundEmptyBuffersInitializedForTone::Fsm(TDevSoundToneEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iState)
sl@0: 		{
sl@0: 		case EStateToneStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInitializeWhileTonePlaying"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventToneStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for tone play
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStateToneInitializing"));
sl@0: 				iState = EStateToneInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventToneStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 
sl@0: 			}
sl@0: 
sl@0: 		case EStateToneInitializing:
sl@0: 			{
sl@0: 			if (aDevSoundEvent == EEventInitCompleteTone && aError == KErrNone)
sl@0: 				{
sl@0: 				// Calling EmptyBuffers
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::EmptyBuffers()"));
sl@0: 				TInt err;
sl@0: 				err = iMMFDevSound->EmptyBuffers();
sl@0: 				if (err == KErrNotSupported)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() returned expected error = %d"), err);
sl@0: 					StopTest();
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() did not return KErrNotSupported as expected. Returned with unexpected error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					}
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventInitCompleteTone && aError != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0: 				StopTest(aError);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventInitCompleteTone not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 
sl@0: 			}
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundEmptyBuffersWhileTonePlaying
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundEmptyBuffersWhileTonePlaying - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundEmptyBuffersWhileTonePlaying::RStepA3FDevSoundEmptyBuffersWhileTonePlaying(const TDesC& aTestName)
sl@0: :RTestStepA3FDevSoundToneBase(aTestName)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundEmptyBuffersWhileTonePlaying* RStepA3FDevSoundEmptyBuffersWhileTonePlaying::NewL(const TDesC& aTestName)
sl@0: 	{
sl@0: 	RStepA3FDevSoundEmptyBuffersWhileTonePlaying* self = new (ELeave) RStepA3FDevSoundEmptyBuffersWhileTonePlaying(aTestName);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoKickoffTestL
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundEmptyBuffersWhileTonePlaying::DoKickoffTestL()
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundEmptyBuffersWhileTonePlaying::Fsm(TDevSoundToneEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iState)
sl@0: 		{
sl@0: 		case EStateToneStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundEmptyBuffersWhileTonePlaying"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventToneStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for tone play
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStateToneInitializing"));
sl@0: 				iState = EStateToneInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventToneStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 
sl@0: 			}
sl@0: 
sl@0: 		case EStateToneInitializing:
sl@0: 			{
sl@0: 			if (aDevSoundEvent == EEventInitCompleteTone && aError == KErrNone)
sl@0: 				{
sl@0: 				TTimeIntervalMicroSeconds duration(KMicroSecsInTenSecs);
sl@0: 				// Initialize the audio device and start playing a tone
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayToneL"));
sl@0: 				TRAPD(err, iMMFDevSound->PlayToneL(KFrequency1, duration));
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStateTonePlaying"));
sl@0: 				iState = EStateTonePlaying;
sl@0: 
sl@0: 				// Calling CMMFDevSound::EmptyBuffers while tone playing
sl@0: 				INFO_PRINTF1(_L("CMMFDevSound::EmptyBuffers called while tone playing"));
sl@0: 				err = iMMFDevSound->EmptyBuffers();
sl@0: 				if (err == KErrNotSupported)
sl@0: 					{
sl@0: 					INFO_PRINTF2(_L("CMMFDevSound::EmptyBuffers left as expected with error = %d"), err);
sl@0: 					StopTest(err,EPass);
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers did NOT leave with KErrNotSupported as expected. Error = %d"), err);
sl@0: 					StopTest(KErrUnknown);
sl@0: 					}
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventInitCompleteTone && aError != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0: 				StopTest(aError);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventInitCompleteTone not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 
sl@0: 			}
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}