sl@0: // Copyright (c) 2003-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: // EPOC includes sl@0: #include sl@0: sl@0: // Test system includes sl@0: #include "TSU_MMF_DeviceSuite.h" sl@0: #include "TSU_MMF_Loop.h" sl@0: sl@0: //[ actual codec includes ] sl@0: #include "MmfPcm16toAlawhwDevice.h" sl@0: #include "MmfALawToPcm16HwDevice.h" sl@0: #include "GSM610.H" sl@0: #include "MmfImaAdpcmtopcm16hwdevice.h" sl@0: #include "MmfMuLawToPcm16hwDevice.h" sl@0: #include "mmfpcm16SwapEndianhwdevice.h" sl@0: #include "mmfpcm16ToImaAdpcm.h" sl@0: #include "mmfpcm16toMulawhwdevice.h" sl@0: #include "mmfpcm16topcmU16BEHwDevice.h" sl@0: #include "MMFpcm16ToPcmU8HwDevice.h" sl@0: #include "MMFpcm16ToPcmU8HwDevice.h" sl@0: #include "mmfpcmS16PcmS8HwDevice.h" sl@0: #include "mmfpcmS16topcmU16Codec.h" sl@0: #include "mmfpcmS8ToPcmS16HwDevice.h" sl@0: #include "mmfpcmU16BeToPcmS16HwDevice.h" sl@0: #include "mmfpcmU16TopcmS16HwDevice.h" sl@0: #include "MMFpcmU8ToPcm16HwDevice.h" sl@0: sl@0: //[ Codec Unit tests structure sl@0: // The unit tests shall use text files sl@0: // for small portions of test data sl@0: // which should be stored are stored in a simple format sl@0: // containing the relevant parameters for the test sl@0: //] sl@0: class TLoopTestParams sl@0: { sl@0: public: sl@0: const TText* iTestName; // name of the test sl@0: }; sl@0: sl@0: // constant table of parameters for tests sl@0: const TLoopTestParams KLoopParameters[] = sl@0: { sl@0: {_S("MM-MMF-SWCODECDEVICES-U-0061-HP")}, sl@0: {_S("MM-MMF-SWCODECDEVICES-U-0062-HP")}, sl@0: {_S("MM-MMF-SWCODECDEVICES-U-0063-HP")}, sl@0: {_S("MM-MMF-SWCODECDEVICES-U-0064-HP")}, sl@0: {_S("MM-MMF-SWCODECDEVICES-U-0065-HP")}, sl@0: {_S("MM-MMF-SWCODECDEVICES-U-0066-HP")}, sl@0: {_S("MM-MMF-SWCODECDEVICES-U-0067-HP")}, sl@0: {_S("MM-MMF-SWCODECDEVICES-U-0068-HP")}, sl@0: {_S("MM-MMF-SWCODECDEVICES-U-0069-HP")}, sl@0: {_S("MM-MMF-SWCODECDEVICES-U-0070-HP")}, sl@0: {_S("MM-MMF-SWCODECDEVICES-U-0071-HP")}, sl@0: {_S("MM-MMF-SWCODECDEVICES-U-0072-HP")}, sl@0: {_S("MM-MMF-SWCODECDEVICES-U-0073-HP")}, sl@0: {_S("MM-MMF-SWCODECDEVICES-U-0074-HP")}, sl@0: {_S("MM-MMF-SWCODECDEVICES-U-0075-HP")}, sl@0: {_S("MM-MMF-SWCODECDEVICES-U-0076-HP")} sl@0: }; sl@0: sl@0: /** sl@0: * sl@0: * CTestStepLoopTest sl@0: * sl@0: */ sl@0: template sl@0: CTestStepLoopTest::CTestStepLoopTest( TUint aTestIndex ) sl@0: { sl@0: // store the name of this test case sl@0: // this is the name that is used by the script file sl@0: iTestStepName = (&KLoopParameters[aTestIndex])->iTestName; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * ~CTestStepLoopTest sl@0: * sl@0: */ sl@0: template sl@0: CTestStepLoopTest::~CTestStepLoopTest() sl@0: { sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * DoTestStepL sl@0: * This method tests codec src & destination buffer size violations sl@0: * and position violations. sl@0: * sl@0: **/ sl@0: template sl@0: TVerdict CTestStepLoopTest::DoTestStepL() sl@0: { sl@0: __MM_HEAP_MARK; sl@0: TVerdict result = EPass; sl@0: sl@0: //[ Buffer size violation on the src ] sl@0: const TInt KSrcDataBufferSize = iCodecUnderTest->SourceBufferSize(); sl@0: const TInt KSinkDataBufferSize = iCodecUnderTest->SinkBufferSize(); sl@0: sl@0: //[ create the data buffers and do not worry about filling them since sl@0: // this is simply a precondition test ] sl@0: TInt srcDataBufferSize = KSrcDataBufferSize*2; sl@0: TInt sinkDataBufferSize = KSinkDataBufferSize; sl@0: if( CodecPreconditionTestL( srcDataBufferSize, sinkDataBufferSize ) == KErrNone ) sl@0: { sl@0: //[ info print here ] sl@0: INFO_PRINTF1(_L("Src Data Buffer precondition violation")); sl@0: result = EFail; sl@0: } sl@0: sl@0: //[ Buffer size violation on the Destination ] sl@0: srcDataBufferSize = KSrcDataBufferSize; sl@0: sinkDataBufferSize = KSinkDataBufferSize/4; sl@0: if( CodecPreconditionTestL( srcDataBufferSize, sinkDataBufferSize ) == KErrNone ) sl@0: { sl@0: INFO_PRINTF1(_L("Sink Data Buffer precondition violation")); sl@0: result = EFail; sl@0: } sl@0: sl@0: //[ Position violation on the src ] sl@0: srcDataBufferSize = KSrcDataBufferSize; sl@0: sinkDataBufferSize = KSinkDataBufferSize; sl@0: if( CodecPreconditionTestL( srcDataBufferSize, sinkDataBufferSize, srcDataBufferSize/2, 0 ) == KErrNone ) sl@0: { sl@0: INFO_PRINTF1(_L("Src Data Buffer position precondition violation")); sl@0: result = EFail; sl@0: } sl@0: sl@0: //[ Position violation on the Destination ] sl@0: srcDataBufferSize = KSrcDataBufferSize; sl@0: sinkDataBufferSize = KSinkDataBufferSize; sl@0: if( CodecPreconditionTestL( srcDataBufferSize, sinkDataBufferSize,0, sinkDataBufferSize/2 ) == KErrNone ) sl@0: { sl@0: INFO_PRINTF1(_L("Sink Data Buffer position precondition violation")); sl@0: result = EFail; sl@0: } sl@0: sl@0: delete iSourceData; sl@0: delete iCodedData ; sl@0: iSourceData = NULL; sl@0: iCodedData = NULL; sl@0: sl@0: __MM_HEAP_MARKEND; sl@0: return result; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * CodecPreconditionTest sl@0: * @precondition 0<= aSrcPosition < aSrcDataBufferSize sl@0: * @precondition 0<= aSinkPosition < aSinkDataBufferSize sl@0: * @return TInt error code sl@0: **/ sl@0: template sl@0: TInt CTestStepLoopTest::CodecPreconditionTestL( TInt aSrcDataBufferSize, TInt aSinkDataBufferSize, TInt aSrcPosition, TInt aSinkPosition ) sl@0: { sl@0: TInt result = KErrNone; sl@0: //[ assert preconditions ] sl@0: ASSERT( (0 <= aSrcPosition ) && ( aSrcPosition < aSrcDataBufferSize )); sl@0: ASSERT( (0 <= aSinkPosition ) && ( aSinkPosition < aSinkDataBufferSize )); sl@0: sl@0: delete iSourceData; sl@0: delete iCodedData ; sl@0: iSourceData = NULL; sl@0: iCodedData = NULL; sl@0: iSourceData = CMMFDescriptorBuffer::NewL(aSrcDataBufferSize * sizeof(TUint8)); sl@0: iCodedData = CMMFDescriptorBuffer::NewL(aSinkDataBufferSize * sizeof(TUint8)); sl@0: //set the lengths of the buffers sl@0: iSourceData->Data().SetLength(aSrcDataBufferSize); sl@0: iCodedData->Data().SetLength(aSinkDataBufferSize); sl@0: sl@0: //set the positions on the buffers sl@0: iSourceData->SetPosition(aSrcPosition); sl@0: iCodedData->SetPosition(aSinkPosition); sl@0: sl@0: TRAP(result,iCodecUnderTest->ProcessL(*iSourceData, *iCodedData)); sl@0: sl@0: return result; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * DoTestStepPreambleL sl@0: * sl@0: **/ sl@0: template sl@0: TVerdict CTestStepLoopTest::DoTestStepPreambleL(void) sl@0: { sl@0: iCodecUnderTest = new (ELeave) Codec; sl@0: return EPass; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * DoTestStepPostambleL sl@0: * sl@0: */ sl@0: template sl@0: TVerdict CTestStepLoopTest::DoTestStepPostambleL(void) sl@0: { sl@0: delete iCodecUnderTest; sl@0: iCodecUnderTest = NULL; sl@0: delete iSourceData; sl@0: iSourceData = NULL; sl@0: delete iCodedData; sl@0: iCodedData = NULL; sl@0: return EPass; sl@0: } sl@0: sl@0: /** sl@0: * sl@0: * This is used for template instantiation. sl@0: * sl@0: **/ sl@0: sl@0: template class CTestStepLoopTest; sl@0: template class CTestStepLoopTest; sl@0: template class CTestStepLoopTest; sl@0: template class CTestStepLoopTest; sl@0: template class CTestStepLoopTest; sl@0: template class CTestStepLoopTest; sl@0: template class CTestStepLoopTest; sl@0: template class CTestStepLoopTest; sl@0: template class CTestStepLoopTest; sl@0: template class CTestStepLoopTest; sl@0: template class CTestStepLoopTest; sl@0: template class CTestStepLoopTest; sl@0: template class CTestStepLoopTest; sl@0: template class CTestStepLoopTest; sl@0: template class CTestStepLoopTest; sl@0: