sl@0: sl@0: // Copyright (c) 2002-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: // This program is designed to test the MMF_ACLNT. sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file TSI_MMFACLNT.cpp sl@0: */ sl@0: #include sl@0: #include sl@0: #include "TSI_MMFACLNT.h" sl@0: #include "TSI_MMFACLNT.inl" sl@0: #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS sl@0: #include sl@0: #endif sl@0: sl@0: void CPlayerCallbackHandler::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/) sl@0: { sl@0: iMchObserver->MchoComplete(ID(),aError); sl@0: } sl@0: sl@0: void CPlayerCallbackHandler::MapcPlayComplete(TInt aError) sl@0: { sl@0: iMchObserver->MchoComplete(ID(),aError); sl@0: } sl@0: sl@0: void CStateCallbackHandler::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt /*aCurrentState*/, TInt aErrorCode) sl@0: { sl@0: iMchObserver->MchoComplete(ID(),aErrorCode); sl@0: } sl@0: sl@0: void CToneCallbackHandler::MatoPrepareComplete(TInt aError) sl@0: { sl@0: iMchObserver->MchoComplete(ID(),aError); sl@0: } sl@0: sl@0: void CToneCallbackHandler::MatoPlayComplete(TInt aError) sl@0: { sl@0: iMchObserver->MchoComplete(ID(),aError); sl@0: } sl@0: sl@0: /** sl@0: * Timeout function sl@0: */ sl@0: void CTestMmfAclntStep::WaitWithTimeout(TRequestStatus& aStatus, TInt aNumberOfMicroSeconds) sl@0: { sl@0: TRequestStatus timerStatus; sl@0: RTimer timer ; sl@0: timer.CreateLocal() ; sl@0: timer.After(timerStatus,aNumberOfMicroSeconds); sl@0: sl@0: User::WaitForRequest(aStatus, timerStatus); sl@0: if (timerStatus == KRequestPending) sl@0: { sl@0: timer.Cancel(); sl@0: User::WaitForRequest(timerStatus); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Time is over!!!")) ; sl@0: } sl@0: timer.Close() ; sl@0: } sl@0: sl@0: /** sl@0: * Time comparison utility function sl@0: * sl@0: * @param "const TUint aActual" sl@0: * The actual timer value produced sl@0: * @param "const TUint aExpected" sl@0: * Expected timer value sl@0: * @param "const TUint aDeviation" sl@0: * Allowed deviation of the expected value sl@0: * from the actual value. sl@0: * @return "TBool" sl@0: * Did actual timed value fall within deviation limits sl@0: */ sl@0: TBool CTestMmfAclntStep::TimeComparison(const TUint aActual, const TUint aExpected, const TUint aDeviation) sl@0: { sl@0: // save unnessary conditions sl@0: if(aActual == aExpected) sl@0: return ETrue; sl@0: sl@0: // Prevent unsigned wrapping errors sl@0: TUint difference; sl@0: if(aActual > aExpected) sl@0: difference = aActual - aExpected; sl@0: else sl@0: difference = aExpected - aActual; sl@0: sl@0: // comapare sl@0: if(difference < aDeviation) sl@0: return ETrue; sl@0: return EFalse; sl@0: } sl@0: sl@0: /** sl@0: * Test Preample routines. sl@0: * sl@0: * Creates our own Active Scheduler. sl@0: * sl@0: * @return "TVerdict" sl@0: * Did Preamble complete. sl@0: */ sl@0: TVerdict CTestMmfAclntStep::DoTestStepPreambleL() sl@0: { sl@0: sl@0: iActiveScheduler = new(ELeave) CActiveScheduler; sl@0: CActiveScheduler::Install(iActiveScheduler); sl@0: sl@0: sl@0: return EPass; sl@0: } sl@0: sl@0: /** sl@0: * Test Postamble routines. sl@0: * sl@0: * Destroys our Active Scheduler. sl@0: * sl@0: * @return "TVerdict" sl@0: * Did Postamble complete. sl@0: */ sl@0: TVerdict CTestMmfAclntStep::DoTestStepPostambleL() sl@0: { sl@0: delete iActiveScheduler; sl@0: iActiveScheduler = NULL; sl@0: sl@0: return EPass; sl@0: } sl@0: sl@0: /** sl@0: * CTestMMFACLNTStep Implementation sl@0: * sl@0: * @parameter "const CTestSuite* aTestSuite" sl@0: * Sets test suite pointer sl@0: */ sl@0: void CTestMmfAclntStep::SetTestSuite(const CTestSuite* aTestSuite ) sl@0: { sl@0: iTestSuite = aTestSuite; sl@0: } sl@0: sl@0: /** sl@0: * CTestMMFACLNTStep Implementation sl@0: */ sl@0: CTestMmfAclntStep::CTestMmfAclntStep() sl@0: :iActiveScheduler( NULL ) sl@0: {} sl@0: sl@0: //------------------------------------------------------ sl@0: sl@0: /** sl@0: * Deconstructors destroys iFormat and iCodec sl@0: * sl@0: */ sl@0: TVerdict CTestMmfAclntCodecTest::DoTestStepPostambleL() sl@0: { sl@0: if(iFormat != NULL) sl@0: { sl@0: delete iFormat; sl@0: iFormat = NULL; sl@0: } sl@0: if(iCodec != NULL) sl@0: { sl@0: delete iCodec; sl@0: iCodec = NULL; sl@0: } sl@0: return CTestMmfAclntStep::DoTestStepPostambleL(); sl@0: } sl@0: sl@0: /** sl@0: * Setup codec and format to test sl@0: * sl@0: * @parameter "const TTestFormat aFormat" sl@0: * enum of format to use sl@0: */ sl@0: void CTestMmfAclntCodecTest::SetupFormatL(const TTestFormat aFormat) sl@0: { sl@0: if(iFormat) sl@0: delete iFormat; sl@0: if(iCodec) sl@0: delete iCodec; sl@0: iFormat = NULL; sl@0: iCodec = NULL; sl@0: sl@0: switch(aFormat) sl@0: { sl@0: case EPcm16Wav: sl@0: iFormat = new (ELeave) TMdaWavClipFormat; sl@0: CleanupStack::PushL(iFormat); sl@0: iCodec = new (ELeave) TMdaPcmWavCodec; sl@0: CleanupStack::PushL(iCodec); sl@0: break; sl@0: case EMulawRaw: sl@0: iFormat = new (ELeave) TMdaRawAudioClipFormat; sl@0: CleanupStack::PushL(iFormat); sl@0: iCodec = new (ELeave) TMdaAlawRawAudioCodec; sl@0: CleanupStack::PushL(iCodec); sl@0: break; sl@0: case E16BitAu: sl@0: iFormat = new (ELeave) TMdaAuClipFormat; sl@0: CleanupStack::PushL(iFormat); sl@0: iCodec = new (ELeave) TMdaAuCodec; sl@0: CleanupStack::PushL(iCodec); sl@0: break; sl@0: case EAlawAu: sl@0: iFormat = new (ELeave) TMdaAuClipFormat; sl@0: CleanupStack::PushL(iFormat); sl@0: iCodec = new (ELeave) TMdaAlawAuCodec; sl@0: CleanupStack::PushL(iCodec); sl@0: break; sl@0: case EPcm16Au: sl@0: iFormat = new (ELeave) TMdaAuClipFormat; sl@0: CleanupStack::PushL(iFormat); sl@0: iCodec = new (ELeave) TMdaPcm16BitAuCodec; sl@0: CleanupStack::PushL(iCodec); sl@0: break; sl@0: case EImaAdpcmWav: sl@0: iFormat = new (ELeave) TMdaWavClipFormat; sl@0: CleanupStack::PushL(iFormat); sl@0: iCodec = new (ELeave) TMdaImaAdpcmWavCodec; sl@0: CleanupStack::PushL(iCodec); sl@0: break; sl@0: case EAlawWav: sl@0: iFormat = new (ELeave) TMdaWavClipFormat; sl@0: CleanupStack::PushL(iFormat); sl@0: iCodec = new (ELeave) TMdaAlawWavCodec; sl@0: CleanupStack::PushL(iCodec); sl@0: break; sl@0: case EPcmU16: sl@0: iFormat = new (ELeave) TMdaRawAudioClipFormat(); sl@0: CleanupStack::PushL(iFormat); sl@0: iCodec = new (ELeave) TMdaUB16RawAudioCodec(); sl@0: CleanupStack::PushL(iCodec); sl@0: break; sl@0: case EPcmU8: sl@0: iFormat = new (ELeave) TMdaRawAudioClipFormat(); sl@0: CleanupStack::PushL(iFormat); sl@0: iCodec = new (ELeave) TMdaU8PcmRawAudioCodec(); sl@0: CleanupStack::PushL(iCodec); sl@0: break; sl@0: case EImasPcmWav: sl@0: iFormat = new (ELeave) TMdaWavClipFormat(); sl@0: CleanupStack::PushL(iFormat); sl@0: iCodec = new (ELeave) TMdaImaAdpcmWavCodec(); sl@0: CleanupStack::PushL(iCodec); sl@0: break; sl@0: case EPcm8: sl@0: iFormat = new (ELeave) TMdaWavClipFormat(); sl@0: CleanupStack::PushL(iFormat); sl@0: iCodec = new (ELeave) TMdaPcmWavCodec(TMdaPcmWavCodec::E8BitPcm); sl@0: CleanupStack::PushL(iCodec); sl@0: break; sl@0: case EGsmWav: sl@0: iFormat = new (ELeave) TMdaWavClipFormat; sl@0: CleanupStack::PushL(iFormat); sl@0: iCodec = new (ELeave) TMdaGsmWavCodec; sl@0: CleanupStack::PushL(iCodec); sl@0: break; sl@0: case EEpocWve: sl@0: case ENone: sl@0: default: sl@0: // will create an inconlusive result as preamble leaves. sl@0: iFormat = NULL; sl@0: iCodec = NULL; sl@0: break; sl@0: } sl@0: sl@0: if((iFormat != NULL) && (iCodec != NULL)) sl@0: { sl@0: CleanupStack::Pop(); // iFormat sl@0: CleanupStack::Pop(); // iCodec sl@0: } sl@0: } sl@0: