0
|
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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
// EPOC includes
|
|
17 |
#include <e32base.h>
|
|
18 |
#include <mmf/common/mmfpaniccodes.h>
|
|
19 |
|
|
20 |
// Test system includes
|
|
21 |
#include "TSU_MMF_DeviceSuite.h"
|
|
22 |
#include "TSU_MMF_Oom.h"
|
|
23 |
|
|
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"
|
|
41 |
|
|
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
|
|
47 |
//]
|
|
48 |
class TOomTestParams
|
|
49 |
{
|
|
50 |
public:
|
|
51 |
const TText* iTestName; // name of the test
|
|
52 |
};
|
|
53 |
|
|
54 |
// constant table of parameters for tests
|
|
55 |
const TOomTestParams KOomParameters[] =
|
|
56 |
{
|
|
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")}
|
|
73 |
};
|
|
74 |
|
|
75 |
/**
|
|
76 |
*
|
|
77 |
* CTestStepOomTest
|
|
78 |
*
|
|
79 |
*/
|
|
80 |
template <class Codec>
|
|
81 |
CTestStepOomTest<Codec>::CTestStepOomTest( TUint aTestIndex )
|
|
82 |
{
|
|
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;
|
|
88 |
}
|
|
89 |
|
|
90 |
/**
|
|
91 |
*
|
|
92 |
* ~CTestStepOomTest
|
|
93 |
*
|
|
94 |
*/
|
|
95 |
template <class Codec>
|
|
96 |
CTestStepOomTest<Codec>::~CTestStepOomTest()
|
|
97 |
{
|
|
98 |
}
|
|
99 |
|
|
100 |
/**
|
|
101 |
*
|
|
102 |
* DoTestStepL
|
|
103 |
*
|
|
104 |
**/
|
|
105 |
template <class Codec>
|
|
106 |
TVerdict CTestStepOomTest<Codec>::DoTestStepL()
|
|
107 |
{
|
|
108 |
TVerdict result = EPass;
|
|
109 |
|
|
110 |
TBool testOK = ETrue;
|
|
111 |
TUint failCount = 1;
|
|
112 |
TBool testComplete = EFalse;
|
|
113 |
|
|
114 |
while (!testComplete)
|
|
115 |
{
|
|
116 |
__UHEAP_FAILNEXT(failCount);
|
|
117 |
__MM_HEAP_MARK;
|
|
118 |
TRAPD(err, Oom());
|
|
119 |
switch (err)
|
|
120 |
{
|
|
121 |
case KErrNoMemory :
|
|
122 |
break;
|
|
123 |
case KErrNone :
|
|
124 |
{
|
|
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);
|
|
128 |
if (testAlloc==NULL)
|
|
129 |
{
|
|
130 |
testComplete = ETrue;
|
|
131 |
failCount --;
|
|
132 |
}
|
|
133 |
else
|
|
134 |
User::Free(testAlloc);
|
|
135 |
break;
|
|
136 |
}
|
|
137 |
default:
|
|
138 |
{
|
|
139 |
testOK = EFalse;
|
|
140 |
testComplete = ETrue;
|
|
141 |
break;
|
|
142 |
}
|
|
143 |
}
|
|
144 |
|
|
145 |
__MM_HEAP_MARKEND;
|
|
146 |
__UHEAP_RESET;
|
|
147 |
failCount++;
|
|
148 |
}
|
|
149 |
|
|
150 |
if(!testOK)
|
|
151 |
{
|
|
152 |
result = EFail;
|
|
153 |
}
|
|
154 |
|
|
155 |
return result;
|
|
156 |
}
|
|
157 |
|
|
158 |
/**
|
|
159 |
*
|
|
160 |
* Oom performs the oom test on the codec in question
|
|
161 |
* @param srcBuffer
|
|
162 |
* @param dstBuffer
|
|
163 |
* @return TInt error status
|
|
164 |
*
|
|
165 |
**/
|
|
166 |
template <class Codec>
|
|
167 |
TInt CTestStepOomTest<Codec>::Oom()
|
|
168 |
{
|
|
169 |
//instantiate codec via a factory function which allows
|
|
170 |
//two phase construction if needed as in the case of gsm610
|
|
171 |
// by derivation.
|
|
172 |
Codec* theCodec = GetCodecL();
|
|
173 |
CleanupStack::PushL(theCodec);
|
|
174 |
|
|
175 |
//create buffers
|
|
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);
|
|
184 |
|
|
185 |
//[perform the coding operation]
|
|
186 |
theCodec->ProcessL(*srcBuffer, *dstBuffer);
|
|
187 |
|
|
188 |
CleanupStack::PopAndDestroy(3,theCodec); //theCodec,dstBuffer, srcBuffer
|
|
189 |
return KErrNone;
|
|
190 |
}
|
|
191 |
|
|
192 |
/**
|
|
193 |
*
|
|
194 |
* GetCodec()
|
|
195 |
* @return fully contrsucted codec pointer
|
|
196 |
* note the client of this function is responsible for deallocation
|
|
197 |
*
|
|
198 |
**/
|
|
199 |
template <class Codec>
|
|
200 |
Codec* CTestStepOomTest<Codec>::GetCodecL()
|
|
201 |
{
|
|
202 |
return new(ELeave) Codec();
|
|
203 |
}
|
|
204 |
|
|
205 |
|
|
206 |
/**
|
|
207 |
*
|
|
208 |
* DoTestStepPreambleL
|
|
209 |
*
|
|
210 |
**/
|
|
211 |
template <class Codec>
|
|
212 |
TVerdict CTestStepOomTest<Codec>::DoTestStepPreambleL(void)
|
|
213 |
{
|
|
214 |
return EPass;
|
|
215 |
}
|
|
216 |
|
|
217 |
/**
|
|
218 |
*
|
|
219 |
* DoTestStepPostambleL
|
|
220 |
*
|
|
221 |
*/
|
|
222 |
template <class Codec>
|
|
223 |
TVerdict CTestStepOomTest<Codec>::DoTestStepPostambleL(void)
|
|
224 |
{
|
|
225 |
return EPass;
|
|
226 |
}
|
|
227 |
|
|
228 |
/**
|
|
229 |
*
|
|
230 |
* GetCodecL()
|
|
231 |
* @return CMMFGsm610ToPcm16Codec*
|
|
232 |
*
|
|
233 |
**/
|
|
234 |
CMMFGsm610ToPcm16Codec* CTestStepGsm610ToPcm16OomTest::GetCodecL()
|
|
235 |
{
|
|
236 |
CMMFGsm610ToPcm16Codec* theCodec = new (ELeave) CMMFGsm610ToPcm16Codec;
|
|
237 |
CleanupStack::PushL(theCodec);
|
|
238 |
theCodec->ConstructL();
|
|
239 |
CleanupStack::Pop(1); // theCodec
|
|
240 |
return theCodec;
|
|
241 |
}
|
|
242 |
/**
|
|
243 |
*
|
|
244 |
* GetCodecL
|
|
245 |
* @return CMMFGsm610ToPcm16Codec*
|
|
246 |
*
|
|
247 |
**/
|
|
248 |
CMMFGsm610ToPcm16Codec* CTestStepPcm16ToGsm610OomTest::GetCodecL()
|
|
249 |
{
|
|
250 |
CMMFGsm610ToPcm16Codec* theCodec = new (ELeave) CMMFGsm610ToPcm16Codec();
|
|
251 |
CleanupStack::PushL(theCodec);
|
|
252 |
theCodec->ConstructL();
|
|
253 |
CleanupStack::Pop(1); // theCodec
|
|
254 |
return theCodec;
|
|
255 |
}
|
|
256 |
|
|
257 |
/**
|
|
258 |
*
|
|
259 |
* This is used for template instantiation.
|
|
260 |
*
|
|
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.
|
|
266 |
*
|
|
267 |
**/
|
|
268 |
|
|
269 |
#ifdef __VC32__
|
|
270 |
#pragma warning( disable : 4660 )
|
|
271 |
#endif
|
|
272 |
|
|
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>;
|
|
287 |
|
|
288 |
#ifdef __VC32__
|
|
289 |
#pragma warning( default : 4660 )
|
|
290 |
#endif
|