sl@0: // Copyright (c) 2005-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: // sl@0: sl@0: #include "teststepoggctrlplay.h" sl@0: sl@0: /** sl@0: * sl@0: * Test step constructor. sl@0: * It initialises its own name and the input filename sl@0: * sl@0: */ sl@0: RTestStepOggCtrlPlay::RTestStepOggCtrlPlay(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid) sl@0: :RTestStepOggCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid) sl@0: { sl@0: } sl@0: /** sl@0: * Do the test step. sl@0: * This test Primes the OggPlayController and Plays an Ogg file to its completion sl@0: * and checks for the proper play completion sl@0: */ sl@0: TVerdict RTestStepOggCtrlPlay::DoTestStepL( void ) sl@0: { sl@0: INFO_PRINTF1(_L("this step plays an Ogg file ")); sl@0: TInt errorCode = iController.Prime(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Prime is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.Play(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Play() is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: CActiveScheduler::Start(); sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Test step constructor. sl@0: * It initialises its own name and the input filename sl@0: * sl@0: */ sl@0: RTestStepOggCtrlVolume::RTestStepOggCtrlVolume(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid) sl@0: :RTestStepOggCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * Do the test step. sl@0: * This tests setting the volume on OggPlayController in Stopped, Primed and Playing sl@0: * states and checks if the volume set is same as the volume got. sl@0: */ sl@0: TVerdict RTestStepOggCtrlVolume::DoTestStepL( void ) sl@0: { sl@0: INFO_PRINTF1(_L("this step tests SetVolume/GetVolume() APIs of OggPlayController ")); sl@0: RMMFAudioPlayDeviceCustomCommands theCommander( iController ); sl@0: TInt maxVolume(0); sl@0: TInt errorCode =theCommander.GetMaxVolume( maxVolume ); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetMaxVolume() is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: sl@0: TInt theVolume = maxVolume /2; sl@0: //try setting volume in Stopped State sl@0: errorCode =theCommander.SetVolume(theVolume); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("SetVolume() during Stopped State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: TInt theNewVolume (0); sl@0: errorCode =theCommander.GetVolume(theNewVolume); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetVolume() during Stopped State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: if( theNewVolume != theVolume ) sl@0: { sl@0: INFO_PRINTF1(_L("Set and Get Volumes are different during Stopped State")); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.Prime(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Prime is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: //try setting volume in Primed State sl@0: errorCode =theCommander.SetVolume(theVolume); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("SetVolume() during Primed State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode =theCommander.GetVolume(theNewVolume); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetVolume() during Primed State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: if( theNewVolume != theVolume ) sl@0: { sl@0: INFO_PRINTF1(_L("Set and Get Volumes are different during Primed State")); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.Play(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Play() is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: //try setting volume in Playing State sl@0: errorCode =theCommander.SetVolume(theVolume); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("SetVolume() during Playing State is failed with %d "), errorCode); sl@0: iController.Stop(); sl@0: return EFail; sl@0: } sl@0: errorCode =theCommander.GetVolume(theNewVolume); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetVolume() during Playing State is failed with %d "), errorCode); sl@0: iController.Stop(); sl@0: return EFail; sl@0: } sl@0: if(theNewVolume != theVolume) sl@0: { sl@0: //stop the controller sl@0: INFO_PRINTF1(_L("Set and Get Volumes are different during Playing State")); sl@0: iController.Stop(); sl@0: return EFail; sl@0: } sl@0: //get the play completion event sl@0: CActiveScheduler::Start(); sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Test step constructor. sl@0: * It initialises its own name and the input filename sl@0: * sl@0: */ sl@0: RTestStepOggCtrlPlayBalance::RTestStepOggCtrlPlayBalance(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid) sl@0: :RTestStepOggCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * Do the test step. sl@0: * This tests setting the PlayBalance on OggPlayController in Stopped, Primed and Playing sl@0: * states and checks if the PlayBalance set is same as the PlayBalance got. sl@0: */ sl@0: TVerdict RTestStepOggCtrlPlayBalance::DoTestStepL( void ) sl@0: { sl@0: INFO_PRINTF1(_L("this step tests SetBalance/GetBalance() APIs of OggPlayController ")); sl@0: RMMFAudioPlayDeviceCustomCommands theCommander( iController ); sl@0: TInt theBalance = (30 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft; sl@0: TInt errorCode = theCommander.SetBalance( theBalance ); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("SetBalance() during Stopped State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: TInt theNewBalance (0); sl@0: errorCode =theCommander.GetBalance( theNewBalance ); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetVolume() during Stopped State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: if( theNewBalance != theBalance ) sl@0: { sl@0: INFO_PRINTF1(_L("Set and Get Balances are different during Stopped State")); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.Prime(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Prime is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: errorCode = theCommander.SetBalance( theBalance ); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("SetBalance() during Primed State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode =theCommander.GetBalance( theNewBalance ); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetBalance() during Primed State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: if( theNewBalance != theBalance ) sl@0: { sl@0: INFO_PRINTF1(_L("Set and Get Balances are different during Primed State")); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.Play(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Play() is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: errorCode =theCommander.SetBalance(theBalance); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("SetBalance() during Playing State is failed with %d "), errorCode); sl@0: iController.Stop(); sl@0: return EFail; sl@0: } sl@0: errorCode =theCommander.GetBalance(theNewBalance); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetBalance() during Playing State is failed with %d "), errorCode); sl@0: iController.Stop(); sl@0: return EFail; sl@0: } sl@0: if(theNewBalance != theBalance) sl@0: { sl@0: //stop the controller sl@0: INFO_PRINTF1(_L("Set and Get Balances are different during Playing State")); sl@0: iController.Stop(); sl@0: return EFail; sl@0: } sl@0: //get the play completion event sl@0: CActiveScheduler::Start(); sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Test step constructor. sl@0: * It initialises its own name and the input filename sl@0: * sl@0: */ sl@0: RTestStepOggCtrlPosition::RTestStepOggCtrlPosition(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid) sl@0: :RTestStepOggCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * Do the test step. sl@0: * This tests setting the Position on OggPlayController in Stopped, Primed and Playing sl@0: * states and checks if the Position set is same as the Position got. It expects KErrNotReady sl@0: * error during Stopped state. sl@0: */ sl@0: TVerdict RTestStepOggCtrlPosition::DoTestStepL(void) sl@0: { sl@0: INFO_PRINTF1(_L("this step tests SetPosition/GetPosition() APIs of OggPlayController ")); sl@0: TTimeIntervalMicroSeconds theDuration; sl@0: TInt errorCode = iController.GetDuration(theDuration); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("DurationL() is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: TInt64 duration = theDuration. Int64(); sl@0: TTimeIntervalMicroSeconds thePosition(duration/2); sl@0: errorCode = iController.SetPosition(thePosition); sl@0: if(errorCode != KErrNotReady) sl@0: { sl@0: INFO_PRINTF2(_L("SetPosition() during Stopped State is failed to return KErrNotReady but returned %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.Prime(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Prime is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: errorCode = iController.SetPosition(thePosition); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("SetPosition() during Primed State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: TTimeIntervalMicroSeconds theNewPosition; sl@0: errorCode = iController.GetPosition(theNewPosition); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetPosition() during Primed State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: /* There is a limitation in the repositioning in the vorbis stream. The position passed by the sl@0: client is converted into granulePos that is nearer to the positon passed. So when GetPosition is called sl@0: we may not get the exact position we have set using the setposition(). This is because granulePos sl@0: is same all through an oggPage and an oggPage will be of average size 6k. So the positioning is not that sl@0: precise. So the KDeviationInTime. sl@0: */ sl@0: if(!TimeComparison(theNewPosition.Int64(), thePosition.Int64(), KDeviationInTime)) sl@0: { sl@0: INFO_PRINTF1(_L("Set and Get Positions are different during Primed State")); sl@0: return EFail; sl@0: } sl@0: //Reset back to the beginning before play sl@0: iController.SetPosition(TTimeIntervalMicroSeconds(0)); sl@0: errorCode = iController.Play(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Play() is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: User::After(KTwoSeconds); sl@0: errorCode = iController.SetPosition(thePosition); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("SetPosition() during Playing State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.GetPosition(theNewPosition); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetPosition() during Playing State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: if(!TimeComparison(theNewPosition.Int64(), thePosition.Int64(), KDeviationInTime)) sl@0: { sl@0: //stop the controller sl@0: INFO_PRINTF1(_L("Current Position is lessthan the Postion Set in Playing State")); sl@0: iController.Stop(); sl@0: return EFail; sl@0: } sl@0: //get the play completion event sl@0: CActiveScheduler::Start(); sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Test step constructor. sl@0: * It initialises its own name and the input filename sl@0: * sl@0: */ sl@0: RTestStepOggCtrlDuration::RTestStepOggCtrlDuration(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid) sl@0: :RTestStepOggCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * Do the test step. sl@0: * This tests setting the Position on OggPlayController in Stopped, Primed and Playing sl@0: * states and checks if the Position set is same as the Postion got. It expects KErrNotReady sl@0: * error during Stopped state. sl@0: */ sl@0: TVerdict RTestStepOggCtrlDuration::DoTestStepL(void) sl@0: { sl@0: INFO_PRINTF1(_L("this step tests GetDuration() API of OggPlayController ")); sl@0: TTimeIntervalMicroSeconds expectedtheDuration(6002426); sl@0: TTimeIntervalMicroSeconds theDuration; sl@0: TInt errorCode = iController.GetDuration(theDuration); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("DurationL() is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: else if(theDuration != expectedtheDuration) sl@0: { sl@0: INFO_PRINTF2(_L("GetDuration() returned the wrong duration %d "), theDuration. Int64()); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.Prime(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Prime is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: errorCode = iController.GetDuration(theDuration); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("DurationL() is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: else if(theDuration != expectedtheDuration) sl@0: { sl@0: INFO_PRINTF2(_L("GetDuration() returned the wrong duration %d "), theDuration. Int64()); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.Play(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Play() is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: errorCode = iController.GetDuration(theDuration); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("DurationL() is failed with %d "), errorCode); sl@0: iController.Stop(); sl@0: return EFail; sl@0: } sl@0: else if(theDuration != expectedtheDuration) sl@0: { sl@0: INFO_PRINTF2(_L("GetDuration() returned the wrong duration %d "), theDuration. Int64()); sl@0: iController.Stop(); sl@0: return EFail; sl@0: } sl@0: return EPass; sl@0: } sl@0: /** sl@0: * sl@0: * Test step constructor. sl@0: * It initialises its own name and the input filename sl@0: * sl@0: */ sl@0: RTestStepOggCtrlPause::RTestStepOggCtrlPause(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid) sl@0: :RTestStepOggCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * Do the test step. sl@0: * This tests the Pause functionality of the OggPlayController in Stopped, Primed and Playing sl@0: * states and checks if the Play starts from the current position. It expects KErrNotReady sl@0: * error if Pause is called during Stopped and Primed states. sl@0: * sl@0: * This test may fail as the position after pause-play may vary due to granularity and recalculation of the buffer. sl@0: */ sl@0: TVerdict RTestStepOggCtrlPause::DoTestStepL(void) sl@0: { sl@0: INFO_PRINTF1(_L("this step tests Pause() API of OggPlayController ")); sl@0: TInt errorCode = iController.Pause(); sl@0: if(errorCode != KErrNotReady) sl@0: { sl@0: INFO_PRINTF2(_L("Pause() during Stopped State is failed to return KErrNotReady but returned %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.Prime(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Prime is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: errorCode = iController.Pause(); sl@0: if(errorCode != KErrNotReady) sl@0: { sl@0: INFO_PRINTF2(_L("Pause() during Primed State is failed to return KErrNotReady but returned %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: INFO_PRINTF1(_L("Play")); sl@0: errorCode = iController.Play(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Play() is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: INFO_PRINTF1(_L("Pause")); sl@0: errorCode = iController.Pause(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Pause() during Playing State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: INFO_PRINTF1(_L("GetPosition - thePosition")); sl@0: TTimeIntervalMicroSeconds thePosition; sl@0: errorCode = iController.GetPosition(thePosition); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetPosition() after Pause is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: INFO_PRINTF1(_L("Play")); sl@0: errorCode = iController.Play(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Play() after Pause() is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: INFO_PRINTF1(_L("GetPosition - theNewPosition")); sl@0: TTimeIntervalMicroSeconds theNewPosition; sl@0: errorCode = iController.GetPosition(theNewPosition); sl@0: INFO_PRINTF2(_L(" Paused: %d"), I64INT(thePosition.Int64())); sl@0: INFO_PRINTF2(_L(" Current: %d"), I64INT(theNewPosition.Int64())); sl@0: sl@0: if(theNewPosition < thePosition) sl@0: { sl@0: //stop the controller sl@0: INFO_PRINTF1(_L("Current Position is lessthan the Paused Postion")); sl@0: ERR_PRINTF2(_L(" Paused: %d"), I64INT(thePosition.Int64())); sl@0: ERR_PRINTF2(_L(" Current: %d"), I64INT(theNewPosition.Int64())); sl@0: iController.Stop(); sl@0: return EFail; sl@0: } sl@0: //get the play completion event sl@0: CActiveScheduler::Start(); sl@0: return iTestStepResult; sl@0: } sl@0: /** sl@0: * sl@0: * Test step constructor. sl@0: * It initialises its own name and the input filename sl@0: * sl@0: */ sl@0: RTestStepOggCtrlStop::RTestStepOggCtrlStop(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid) sl@0: :RTestStepOggCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * Do the test step. sl@0: * This tests the Stop functionality of the OggPlayController in Stopped, Primed and Playing sl@0: * states It expects KErrNotReady error if Stop is called during Stopped state. sl@0: */ sl@0: TVerdict RTestStepOggCtrlStop::DoTestStepL(void) sl@0: { sl@0: INFO_PRINTF1(_L("this step tests Stop() API of OggPlayController ")); sl@0: TInt errorCode = iController.Stop(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Stop() during Stopped State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.Prime(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Prime is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: errorCode = iController.Stop(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Stop() during Primed State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.Prime(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Prime is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: errorCode = iController.Play(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Play() is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: User::After(KTwoSeconds); sl@0: errorCode = iController.Stop(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Stop() during Playing State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.Prime(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Prime is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: errorCode = iController.Play(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Play() after Stop() is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: //get the play completion event sl@0: CActiveScheduler::Start(); sl@0: return iTestStepResult; sl@0: } sl@0: /** sl@0: * sl@0: * Test step constructor. sl@0: * It initialises its own name and the input filename sl@0: * sl@0: */ sl@0: RTestStepOggCtrlMetaData::RTestStepOggCtrlMetaData(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid) sl@0: :RTestStepOggCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * Do the test step. sl@0: * This test tries to fetch the metadata from the Ogg file. sl@0: * sl@0: */ sl@0: TVerdict RTestStepOggCtrlMetaData::DoTestStepL(void) sl@0: { sl@0: INFO_PRINTF1(_L("this step tests GetNumberOfMetaDataEntries/GetMetaDataEntryL() APIs of OggPlayController ")); sl@0: TInt numEntries = 0; sl@0: TInt errorCode = iController.GetNumberOfMetaDataEntries( numEntries ); sl@0: CMMFMetaDataEntry* metaEntry = NULL; sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetNumberOfMetaDataEntries() is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: if(numEntries == 0) sl@0: { sl@0: INFO_PRINTF1(_L("File does not have meta entries ")); sl@0: } sl@0: else sl@0: { sl@0: for(TInt counter = 0; counter < numEntries; ++counter) sl@0: { sl@0: TRAP(errorCode, metaEntry = iController.GetMetaDataEntryL(counter)); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetMetaDataEntryL is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: INFO_PRINTF3(_L("%S %S"), &metaEntry->Name(), &metaEntry->Value()); sl@0: } sl@0: } sl@0: return EPass; sl@0: } sl@0: /** sl@0: * sl@0: * Test step constructor. sl@0: * It initialises its own name and the input filename sl@0: * sl@0: */ sl@0: RTestStepOggCtrlPlayWindow::RTestStepOggCtrlPlayWindow(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid) sl@0: :RTestStepOggCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * Do the test step. sl@0: * This tests the PlayWindow functionality of the OggPlayController. sl@0: * Sequence : Prime -> SetPlayWindow -> Play(check if the current position > PlayStart) sl@0: * Stop -> Prime -> Play(check if the current position > PlayStart) sl@0: * Stop -> Prime -> DeletePlayWindow -> Play(check if the current position <= PlayStart) sl@0: */ sl@0: TVerdict RTestStepOggCtrlPlayWindow::DoTestStepL(void) sl@0: { sl@0: INFO_PRINTF1(_L("this step tests SetPlaybackWindow/DeletePlaybackWindow() API of OggPlayController ")); sl@0: TInt errorCode = iController.Prime(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Prime is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: TTimeIntervalMicroSeconds theDuration; sl@0: errorCode = iController.GetDuration(theDuration); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("DurationL() is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: TInt64 duration = theDuration. Int64(); sl@0: TTimeIntervalMicroSeconds thePlayStart(duration/2); sl@0: TTimeIntervalMicroSeconds thePlayEnd(duration); sl@0: RMMFAudioPlayControllerCustomCommands theCommander(iController); sl@0: errorCode = theCommander.SetPlaybackWindow(thePlayStart, thePlayEnd); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("SetPlaybackWindow() is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.Play(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Play() after SetPlayWindow() is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: TTimeIntervalMicroSeconds theNewPosition; sl@0: errorCode = iController.GetPosition(theNewPosition); sl@0: if(!TimeComparison(theNewPosition.Int64(), thePlayStart.Int64(), KDeviationInTime)) sl@0: { sl@0: //stop the controller sl@0: INFO_PRINTF1(_L("Current Position is lessthan the PlayWindowStart")); sl@0: iController.Stop(); sl@0: return EFail; sl@0: } sl@0: User::After(KTwoSeconds); sl@0: errorCode = iController.Stop(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Stop() with PlayWindow set is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.Prime(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Prime with PlayWindow set is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: errorCode = iController.Play(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Play() with PlayWindow is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: errorCode = iController.GetPosition(theNewPosition); sl@0: if(!TimeComparison(theNewPosition.Int64(), thePlayStart.Int64(), KDeviationInTime)) sl@0: { sl@0: //stop the controller sl@0: INFO_PRINTF1(_L("Current Position is lessthan the PlayWindowStart(Second Play)")); sl@0: iController.Stop(); sl@0: return EFail; sl@0: } sl@0: User::After(KTwoSeconds); sl@0: errorCode = iController.Stop(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Stop() with PlayWindow set is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.Prime(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Prime with PlayWindow set is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = theCommander.DeletePlaybackWindow(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("DeletePlaybackWindow() is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.Play(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Play() after DeletePlaybackWindow is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = iController.GetPosition(theNewPosition); sl@0: if(theNewPosition > thePlayStart) sl@0: { sl@0: //stop the controller sl@0: INFO_PRINTF1(_L("PlaybackWindow is not deleted properly")); sl@0: iController.Stop(); sl@0: return EFail; sl@0: } sl@0: //get the play completion event sl@0: CActiveScheduler::Start(); sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Test step constructor. sl@0: * It initialises its own name and the input filename sl@0: * sl@0: */ sl@0: RTestStepOggCtrlGetSetConfig::RTestStepOggCtrlGetSetConfig(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid) sl@0: :RTestStepOggCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * Do the test step. sl@0: * This test tries to fetch the audio configuration from the Ogg file sl@0: * and compares with the expected configuration. sl@0: */ sl@0: TVerdict RTestStepOggCtrlGetSetConfig::DoTestStepL(void) sl@0: { sl@0: INFO_PRINTF1(_L("this step tests setting and getting audio configuration on OggPlayController ")); sl@0: RMMFAudioControllerCustomCommands theCommander( iController ); sl@0: TUint theRate = 0; sl@0: const TUint KExpectedBitRate = 128000; sl@0: const TUint KExpectedSampleRate = 44100; sl@0: const TUint KExpectedSourceChannels = 2; sl@0: TInt errorCode = theCommander.GetSourceBitRate(theRate); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetSourceBitRate() is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: else if(theRate != KExpectedBitRate) sl@0: { sl@0: INFO_PRINTF2(_L("GetSourceBitRate() returned the wrong bitrate %d "), theRate); sl@0: return EFail; sl@0: } sl@0: errorCode = theCommander.GetSourceSampleRate(theRate); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetSourceSampleRate() is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: else if(theRate != KExpectedSampleRate) sl@0: { sl@0: INFO_PRINTF2(_L("GetSourceBitRate() returned the wrong samplerate %d "), theRate); sl@0: return EFail; sl@0: } sl@0: errorCode = theCommander.GetSourceNumChannels(theRate); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetSourceNumChannels() is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: else if(theRate != KExpectedSourceChannels) sl@0: { sl@0: INFO_PRINTF2(_L("GetSourceNumChannels() returned the wrong value %d "), theRate); sl@0: return EFail; sl@0: } sl@0: TUid formatUid; sl@0: errorCode = theCommander.GetSourceFormat(formatUid); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetSourceFormat(() during Stopped State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: if(formatUid != KOggDecodeUid) sl@0: { sl@0: INFO_PRINTF2(_L("GetSourceFormat() returned the wrong value %d "), formatUid.iUid); sl@0: return EFail; sl@0: } sl@0: TFourCC dataType(0); sl@0: errorCode =theCommander.GetSourceDataType(dataType); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetSourceDataType() during Stopped State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: if( dataType != TFourCC('V', 'O', 'R', 'B') ) sl@0: { sl@0: INFO_PRINTF1(_L("GetSourceDataType() returned datatype different from VORB ")); sl@0: return EFail; sl@0: } sl@0: /* sl@0: Setting configurations during playing is not possible because the file has to be played at a configuration sl@0: which is same as that of when it was recorded. However, if the client tries to set the configuration which sl@0: is same as the configutation of the file, all the SetXXX() custom commands will return KErrNone. We dont check sl@0: GetXXX() after SetXXX() here for this reason. sl@0: */ sl@0: errorCode = theCommander.SetSourceBitRate(KExpectedBitRate); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("SetSourceBitRate() is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = theCommander.SetSourceSampleRate(KExpectedSampleRate); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("SetSourceSampleRate() is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = theCommander.SetSourceNumChannels(KExpectedSourceChannels); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("SetSourceNumChannels() is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: TFourCC theCodec('V', 'O', 'R', 'B'); sl@0: errorCode = theCommander.SetSourceDataType(theCodec); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("SetSourceDataType() is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = theCommander.SetCodec(theCodec, theCodec); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("SetCodec() is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = theCommander.SetSourceFormat(KOggDecodeUid); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("SetSourceFormat() is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: return EPass; sl@0: } sl@0: sl@0: //Negative Tests sl@0: /** sl@0: * sl@0: * Test step constructor. sl@0: * It initialises its own name and the input filename sl@0: * sl@0: */ sl@0: RTestStepOggCtrlPlayInvalid::RTestStepOggCtrlPlayInvalid(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid) sl@0: :RTestStepOggCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid) sl@0: { sl@0: } sl@0: sl@0: TVerdict RTestStepOggCtrlPlayInvalid::DoTestStepPreambleL(void) sl@0: { sl@0: return EPass; sl@0: } sl@0: sl@0: /** sl@0: * Do the test step(Negative Test). sl@0: * This test tries to open an invalid file. Expects KErrCurrupt from OggPlayController sl@0: */ sl@0: TVerdict RTestStepOggCtrlPlayInvalid::DoTestStepL(void) sl@0: { sl@0: INFO_PRINTF1(_L("This test tries to open an invalid file using OggPlayController")); sl@0: iScheduler = new(ELeave)CActiveScheduler; sl@0: CleanupStack::PushL(iScheduler ); sl@0: CActiveScheduler::Install(iScheduler ); sl@0: CleanupStack::Pop(); sl@0: iPriority.iPriority = 11; // set the priority to some default value sl@0: iPriority.iPref = EMdaPriorityPreferenceQuality; sl@0: iControllerEventMonitor = CMMFControllerEventMonitor::NewL(*this, iController); sl@0: TInt errorCode = iController.Open(KOggPlayControllerUid, iPriority); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Failed to load the controller %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: iControllerEventMonitor->Start(); sl@0: SetupReadFileConfigL(); sl@0: errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig()); sl@0: if(errorCode != KErrCorrupt) sl@0: { sl@0: INFO_PRINTF2(_L("AddDataSource failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: return EPass; sl@0: } sl@0: /** sl@0: * sl@0: * Test step constructor. sl@0: * It initialises its own name and the input filename sl@0: * sl@0: */ sl@0: RTestStepOggCtrlSetInvalidConfig::RTestStepOggCtrlSetInvalidConfig(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid) sl@0: :RTestStepOggCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * Do the test step(Negative Test). sl@0: * This tests setting the an invalid SourceDataType on OggPlayController sl@0: * checks if the OggPlayController returns KErrNotSupported sl@0: */ sl@0: TVerdict RTestStepOggCtrlSetInvalidConfig::DoTestStepL( void ) sl@0: { sl@0: INFO_PRINTF1(_L("This tests setting an invalid SourceDataType on OggPlayController ")); sl@0: RMMFAudioControllerCustomCommands theCommander( iController ); sl@0: TFourCC theCodec(KMMFFourCCCodeIMAD); sl@0: TInt errorCode = theCommander.SetSourceDataType(theCodec); sl@0: if(errorCode != KErrNotSupported) sl@0: { sl@0: INFO_PRINTF2(_L("SetSourceDataType() with non vorbis failed to return KErrNotSupported but returned %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: TUint newBitRate = 224000; sl@0: TUint newSampleRate = 8000; sl@0: TUint newSourceChannels = 1; sl@0: errorCode = theCommander.SetSourceBitRate(newBitRate); sl@0: if(errorCode != KErrNotSupported) sl@0: { sl@0: INFO_PRINTF2(_L("SetSourceBitRate() returned wrong error %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = theCommander.SetSourceSampleRate(newSampleRate); sl@0: if(errorCode != KErrNotSupported) sl@0: { sl@0: INFO_PRINTF2(_L("SetSourceSampleRate() returned wrong error %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = theCommander.SetSourceNumChannels(newSourceChannels); sl@0: if(errorCode != KErrNotSupported) sl@0: { sl@0: INFO_PRINTF2(_L("SetSourceNumChannels() returned wrong error %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: errorCode = theCommander.SetSourceFormat(KOggEncodeUid); sl@0: if(errorCode != KErrNotSupported) sl@0: { sl@0: INFO_PRINTF2(_L("SetSourceFormat() returned wrong error %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: return EPass; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * Test step constructor. sl@0: * It initialises its own name and the input filename sl@0: * sl@0: */ sl@0: RTestStepOggCtrlPositionNegative::RTestStepOggCtrlPositionNegative(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName, TUid aControllerUid) sl@0: :RTestStepOggCtrlPlayBase(aTestName, aSectName, aKeyName, aControllerUid) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * Do the test step(Negative Test). sl@0: * This tests setting the Negative Position on OggPlayController sl@0: * checks if the Position set is to 0. sl@0: */ sl@0: TVerdict RTestStepOggCtrlPositionNegative::DoTestStepL(void) sl@0: { sl@0: INFO_PRINTF1(_L("This tests setting the Negative Position on OggPlayController")); sl@0: TInt errorCode = iController.Prime(); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("Prime is failed with %d "), errorCode); sl@0: return EInconclusive; sl@0: } sl@0: errorCode = iController.SetPosition(-1); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("SetPosition() during Primed State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: TTimeIntervalMicroSeconds theNewPosition; sl@0: errorCode = iController.GetPosition(theNewPosition); sl@0: if(errorCode) sl@0: { sl@0: INFO_PRINTF2(_L("GetPosition() during Primed State is failed with %d "), errorCode); sl@0: return EFail; sl@0: } sl@0: sl@0: if(theNewPosition != 0) sl@0: { sl@0: INFO_PRINTF1(_L("Get Position is failed to return 0 when the position is set to a negative value")); sl@0: return EFail; sl@0: } sl@0: return EPass; sl@0: }