Update contrib.
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.
18 #include <mmf/common/mmfpaniccodes.h>
20 // Test system includes
21 #include "TSU_MMF_DeviceSuite.h"
22 #include "TSU_MMF_Oom.h"
24 //[ actual codec includes ]
25 #include "MmfPcm16toAlawhwDevice.h"
26 #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 TOomTestParams KOomParameters[] =
57 {_S("MM-MMF-SWCODECDEVICES-U-0041-HP")},
58 {_S("MM-MMF-SWCODECDEVICES-U-0042-HP")},
59 {_S("MM-MMF-SWCODECDEVICES-U-0043-HP")},
60 {_S("MM-MMF-SWCODECDEVICES-U-0044-HP")},
61 {_S("MM-MMF-SWCODECDEVICES-U-0045-HP")},
62 {_S("MM-MMF-SWCODECDEVICES-U-0046-HP")},
63 {_S("MM-MMF-SWCODECDEVICES-U-0047-HP")},
64 {_S("MM-MMF-SWCODECDEVICES-U-0048-HP")},
65 {_S("MM-MMF-SWCODECDEVICES-U-0049-HP")},
66 {_S("MM-MMF-SWCODECDEVICES-U-0050-HP")},
67 {_S("MM-MMF-SWCODECDEVICES-U-0051-HP")},
68 {_S("MM-MMF-SWCODECDEVICES-U-0052-HP")},
69 {_S("MM-MMF-SWCODECDEVICES-U-0053-HP")},
70 {_S("MM-MMF-SWCODECDEVICES-U-0054-HP")},
71 {_S("MM-MMF-SWCODECDEVICES-U-0055-HP")},
72 {_S("MM-MMF-SWCODECDEVICES-U-0056-HP")}
80 template <class Codec>
81 CTestStepOomTest<Codec>::CTestStepOomTest( TUint aTestIndex )
83 // store the name of this test case
84 // this is the name that is used by the script file
85 // __ASSERT_DEBUG( (aTestIndex >= 0) && ( aTestIndex < sizeof(KOomParameters)/sizeof(TOomTestParams)),Panic(EBadInvariant));
86 __ASSERT_DEBUG( ( aTestIndex < sizeof(KOomParameters)/sizeof(TOomTestParams)),Panic(EBadInvariant)); // EABI warning removal
87 iTestStepName = (&KOomParameters[aTestIndex])->iTestName;
95 template <class Codec>
96 CTestStepOomTest<Codec>::~CTestStepOomTest()
105 template <class Codec>
106 TVerdict CTestStepOomTest<Codec>::DoTestStepL()
108 TVerdict result = EPass;
110 TBool testOK = ETrue;
112 TBool testComplete = EFalse;
114 while (!testComplete)
116 __UHEAP_FAILNEXT(failCount);
125 //attempt to allocate another cell. If this fails, we have tested all
126 //of the memory allocs carried out by ProcessL.
127 TAny *testAlloc = User::Alloc(1);
130 testComplete = ETrue;
134 User::Free(testAlloc);
140 testComplete = ETrue;
160 * Oom performs the oom test on the codec in question
163 * @return TInt error status
166 template <class Codec>
167 TInt CTestStepOomTest<Codec>::Oom()
169 //instantiate codec via a factory function which allows
170 //two phase construction if needed as in the case of gsm610
172 Codec* theCodec = GetCodecL();
173 CleanupStack::PushL(theCodec);
176 TInt srcBufferSize = theCodec->SourceBufferSize();
177 TInt sinkBufferSize = theCodec->SinkBufferSize();
178 CMMFDataBuffer *srcBuffer = CMMFDataBuffer::NewL(srcBufferSize);
179 srcBuffer->Data().SetLength( srcBufferSize);
180 CleanupStack::PushL(srcBuffer);
181 CMMFDataBuffer *dstBuffer = CMMFDataBuffer::NewL(sinkBufferSize);
182 dstBuffer->Data().SetLength( sinkBufferSize );
183 CleanupStack::PushL(dstBuffer);
185 //[perform the coding operation]
186 theCodec->ProcessL(*srcBuffer, *dstBuffer);
188 CleanupStack::PopAndDestroy(3,theCodec); //theCodec,dstBuffer, srcBuffer
195 * @return fully contrsucted codec pointer
196 * note the client of this function is responsible for deallocation
199 template <class Codec>
200 Codec* CTestStepOomTest<Codec>::GetCodecL()
202 return new(ELeave) Codec();
208 * DoTestStepPreambleL
211 template <class Codec>
212 TVerdict CTestStepOomTest<Codec>::DoTestStepPreambleL(void)
219 * DoTestStepPostambleL
222 template <class Codec>
223 TVerdict CTestStepOomTest<Codec>::DoTestStepPostambleL(void)
231 * @return CMMFGsm610ToPcm16Codec*
234 CMMFGsm610ToPcm16Codec* CTestStepGsm610ToPcm16OomTest::GetCodecL()
236 CMMFGsm610ToPcm16Codec* theCodec = new (ELeave) CMMFGsm610ToPcm16Codec;
237 CleanupStack::PushL(theCodec);
238 theCodec->ConstructL();
239 CleanupStack::Pop(1); // theCodec
245 * @return CMMFGsm610ToPcm16Codec*
248 CMMFGsm610ToPcm16Codec* CTestStepPcm16ToGsm610OomTest::GetCodecL()
250 CMMFGsm610ToPcm16Codec* theCodec = new (ELeave) CMMFGsm610ToPcm16Codec();
251 CleanupStack::PushL(theCodec);
252 theCodec->ConstructL();
253 CleanupStack::Pop(1); // theCodec
259 * This is used for template instantiation.
261 * Normally templated classes are defined in header files..
262 * Here we use them in *.cpp which requires an explicit instantiation.
263 * We know that any other reference to CTestStepOomTest<class> within
264 * this dll will instantiate the template and we do not want the compiler
265 * to remind us about that.
270 #pragma warning( disable : 4660 )
273 template class CTestStepOomTest<CMMFPcm16ToALawCodec>;
274 template class CTestStepOomTest<CMMFAlawToPcm16Codec>;
275 template class CTestStepOomTest<CMMFGsm610ToPcm16Codec>;
276 template class CTestStepOomTest<CMMFImaAdpcmToPcm16Codec>;
277 template class CTestStepOomTest<CMMFMulawToPcm16Codec>;
278 template class CTestStepOomTest<CMMFPcm16SwapEndianCodec>;
279 template class CTestStepOomTest<CMMFPcm16ToImaAdpcmCodec>;
280 template class CTestStepOomTest<CMMFPcm16ToMuLawCodec>;
281 template class CTestStepOomTest<CMMFPcm16ToPcmU16BECodec>;
282 template class CTestStepOomTest<CMMFPcm16ToPcmU8Codec>;
283 template class CTestStepOomTest<CMMFPcmS16ToPcmS8Codec>;
284 template class CTestStepOomTest<CMMFPcm16ToPcmU16CodecCodec>;
285 template class CTestStepOomTest<CMMFPcm8ToPcm16Codec>;
286 template class CTestStepOomTest<CMMFPcmU16BeToPcmS16Codec>;
289 #pragma warning( default : 4660 )