First public contribution.
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 // Test system includes
20 #include "TSU_MMF_DeviceSuite.h"
21 #include "TSU_MMF_Loop.h"
23 //[ actual codec includes ]
24 #include "MmfPcm16toAlawhwDevice.h"
25 #include "MmfALawToPcm16HwDevice.h"
27 #include "MmfImaAdpcmtopcm16hwdevice.h"
28 #include "MmfMuLawToPcm16hwDevice.h"
29 #include "mmfpcm16SwapEndianhwdevice.h"
30 #include "mmfpcm16ToImaAdpcm.h"
31 #include "mmfpcm16toMulawhwdevice.h"
32 #include "mmfpcm16topcmU16BEHwDevice.h"
33 #include "MMFpcm16ToPcmU8HwDevice.h"
34 #include "MMFpcm16ToPcmU8HwDevice.h"
35 #include "mmfpcmS16PcmS8HwDevice.h"
36 #include "mmfpcmS16topcmU16Codec.h"
37 #include "mmfpcmS8ToPcmS16HwDevice.h"
38 #include "mmfpcmU16BeToPcmS16HwDevice.h"
39 #include "mmfpcmU16TopcmS16HwDevice.h"
40 #include "MMFpcmU8ToPcm16HwDevice.h"
42 //[ Codec Unit tests structure
43 // The unit tests shall use text files
44 // for small portions of test data
45 // which should be stored are stored in a simple format
46 // containing the relevant parameters for the test
51 const TText* iTestName; // name of the test
54 // constant table of parameters for tests
55 const TLoopTestParams KLoopParameters[] =
57 {_S("MM-MMF-SWCODECDEVICES-U-0061-HP")},
58 {_S("MM-MMF-SWCODECDEVICES-U-0062-HP")},
59 {_S("MM-MMF-SWCODECDEVICES-U-0063-HP")},
60 {_S("MM-MMF-SWCODECDEVICES-U-0064-HP")},
61 {_S("MM-MMF-SWCODECDEVICES-U-0065-HP")},
62 {_S("MM-MMF-SWCODECDEVICES-U-0066-HP")},
63 {_S("MM-MMF-SWCODECDEVICES-U-0067-HP")},
64 {_S("MM-MMF-SWCODECDEVICES-U-0068-HP")},
65 {_S("MM-MMF-SWCODECDEVICES-U-0069-HP")},
66 {_S("MM-MMF-SWCODECDEVICES-U-0070-HP")},
67 {_S("MM-MMF-SWCODECDEVICES-U-0071-HP")},
68 {_S("MM-MMF-SWCODECDEVICES-U-0072-HP")},
69 {_S("MM-MMF-SWCODECDEVICES-U-0073-HP")},
70 {_S("MM-MMF-SWCODECDEVICES-U-0074-HP")},
71 {_S("MM-MMF-SWCODECDEVICES-U-0075-HP")},
72 {_S("MM-MMF-SWCODECDEVICES-U-0076-HP")}
80 template <class Codec>
81 CTestStepLoopTest<Codec>::CTestStepLoopTest( TUint aTestIndex )
83 // store the name of this test case
84 // this is the name that is used by the script file
85 iTestStepName = (&KLoopParameters[aTestIndex])->iTestName;
93 template <class Codec>
94 CTestStepLoopTest<Codec>::~CTestStepLoopTest()
101 * This method tests codec src & destination buffer size violations
102 * and position violations.
105 template <class Codec>
106 TVerdict CTestStepLoopTest<Codec>::DoTestStepL()
109 TVerdict result = EPass;
111 //[ Buffer size violation on the src ]
112 const TInt KSrcDataBufferSize = iCodecUnderTest->SourceBufferSize();
113 const TInt KSinkDataBufferSize = iCodecUnderTest->SinkBufferSize();
115 //[ create the data buffers and do not worry about filling them since
116 // this is simply a precondition test ]
117 TInt srcDataBufferSize = KSrcDataBufferSize*2;
118 TInt sinkDataBufferSize = KSinkDataBufferSize;
119 if( CodecPreconditionTestL( srcDataBufferSize, sinkDataBufferSize ) == KErrNone )
121 //[ info print here ]
122 INFO_PRINTF1(_L("Src Data Buffer precondition violation"));
126 //[ Buffer size violation on the Destination ]
127 srcDataBufferSize = KSrcDataBufferSize;
128 sinkDataBufferSize = KSinkDataBufferSize/4;
129 if( CodecPreconditionTestL( srcDataBufferSize, sinkDataBufferSize ) == KErrNone )
131 INFO_PRINTF1(_L("Sink Data Buffer precondition violation"));
135 //[ Position violation on the src ]
136 srcDataBufferSize = KSrcDataBufferSize;
137 sinkDataBufferSize = KSinkDataBufferSize;
138 if( CodecPreconditionTestL( srcDataBufferSize, sinkDataBufferSize, srcDataBufferSize/2, 0 ) == KErrNone )
140 INFO_PRINTF1(_L("Src Data Buffer position precondition violation"));
144 //[ Position violation on the Destination ]
145 srcDataBufferSize = KSrcDataBufferSize;
146 sinkDataBufferSize = KSinkDataBufferSize;
147 if( CodecPreconditionTestL( srcDataBufferSize, sinkDataBufferSize,0, sinkDataBufferSize/2 ) == KErrNone )
149 INFO_PRINTF1(_L("Sink Data Buffer position precondition violation"));
164 * CodecPreconditionTest
165 * @precondition 0<= aSrcPosition < aSrcDataBufferSize
166 * @precondition 0<= aSinkPosition < aSinkDataBufferSize
167 * @return TInt error code
169 template <class Codec>
170 TInt CTestStepLoopTest<Codec>::CodecPreconditionTestL( TInt aSrcDataBufferSize, TInt aSinkDataBufferSize, TInt aSrcPosition, TInt aSinkPosition )
172 TInt result = KErrNone;
173 //[ assert preconditions ]
174 ASSERT( (0 <= aSrcPosition ) && ( aSrcPosition < aSrcDataBufferSize ));
175 ASSERT( (0 <= aSinkPosition ) && ( aSinkPosition < aSinkDataBufferSize ));
181 iSourceData = CMMFDescriptorBuffer::NewL(aSrcDataBufferSize * sizeof(TUint8));
182 iCodedData = CMMFDescriptorBuffer::NewL(aSinkDataBufferSize * sizeof(TUint8));
183 //set the lengths of the buffers
184 iSourceData->Data().SetLength(aSrcDataBufferSize);
185 iCodedData->Data().SetLength(aSinkDataBufferSize);
187 //set the positions on the buffers
188 iSourceData->SetPosition(aSrcPosition);
189 iCodedData->SetPosition(aSinkPosition);
191 TRAP(result,iCodecUnderTest->ProcessL(*iSourceData, *iCodedData));
198 * DoTestStepPreambleL
201 template <class Codec>
202 TVerdict CTestStepLoopTest<Codec>::DoTestStepPreambleL(void)
204 iCodecUnderTest = new (ELeave) Codec;
210 * DoTestStepPostambleL
213 template <class Codec>
214 TVerdict CTestStepLoopTest<Codec>::DoTestStepPostambleL(void)
216 delete iCodecUnderTest;
217 iCodecUnderTest = NULL;
227 * This is used for template instantiation.
231 template class CTestStepLoopTest<CMMFPcm16ToALawCodec>;
232 template class CTestStepLoopTest<CMMFAlawToPcm16Codec>;
233 template class CTestStepLoopTest<CMMFGsm610ToPcm16Codec>;
234 template class CTestStepLoopTest<CMMFImaAdpcmToPcm16Codec>;
235 template class CTestStepLoopTest<CMMFMulawToPcm16Codec>;
236 template class CTestStepLoopTest<CMMFPcm16SwapEndianCodec>;
237 template class CTestStepLoopTest<CMMFPcm16ToImaAdpcmCodec>;
238 template class CTestStepLoopTest<CMMFPcm16ToMuLawCodec>;
239 template class CTestStepLoopTest<CMMFPcm16ToPcmU16BECodec>;
240 template class CTestStepLoopTest<CMMFPcm16ToPcmU8Codec>;
241 template class CTestStepLoopTest<CMMFPcmS16ToPcmS8Codec>;
242 template class CTestStepLoopTest<CMMFPcm16ToPcmU16CodecCodec>;
243 template class CTestStepLoopTest<CMMFPcm8ToPcm16Codec>;
244 template class CTestStepLoopTest<CMMFPcmU16BeToPcmS16Codec>;
245 template class CTestStepLoopTest<CMMFPcm16ToGsm610Codec>;