0
|
1 |
// Copyright (c) 2004-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 |
// This file contains an example Test step implementation
|
|
15 |
// This demonstrates the various functions provided
|
|
16 |
// by the CTestStep base class which are available within
|
|
17 |
// a test step
|
|
18 |
//
|
|
19 |
//
|
|
20 |
|
|
21 |
#include "TestStepRecorderBitRate.h"
|
|
22 |
|
|
23 |
// Path where the test files reside
|
|
24 |
_LIT(KFilePath, "C:\\mm\\mmf\\testfiles\\aclnt\\");
|
|
25 |
|
|
26 |
//----- Test for WAV files -----
|
|
27 |
/**
|
|
28 |
*
|
|
29 |
* Static constructor for CTestStepRecorderBitRateWav.
|
|
30 |
*
|
|
31 |
*
|
|
32 |
* @return "CTestStepRecorderBitRateWav*"
|
|
33 |
* The constructed CTestStepRecorderBitRateWav
|
|
34 |
*
|
|
35 |
* @xxxx
|
|
36 |
*
|
|
37 |
*/
|
|
38 |
CTestStepRecorderBitRateWav* CTestStepRecorderBitRateWav::NewL()
|
|
39 |
{
|
|
40 |
CTestStepRecorderBitRateWav* self = new(ELeave) CTestStepRecorderBitRateWav;
|
|
41 |
return self;
|
|
42 |
}
|
|
43 |
|
|
44 |
/**
|
|
45 |
*
|
|
46 |
* Test step constructor.
|
|
47 |
* Each test step initialises its own name.
|
|
48 |
*
|
|
49 |
* @xxxx
|
|
50 |
*
|
|
51 |
*/
|
|
52 |
CTestStepRecorderBitRateWav::CTestStepRecorderBitRateWav()
|
|
53 |
{
|
|
54 |
// store the name of this test case
|
|
55 |
// this is the name that is used by the script file
|
|
56 |
iTestStepName = _L("MM-MMF-ACLNT-U-0852-HP");
|
|
57 |
}
|
|
58 |
|
|
59 |
/**
|
|
60 |
*
|
|
61 |
* Test step destructor.
|
|
62 |
*
|
|
63 |
* @xxxx
|
|
64 |
*
|
|
65 |
*/
|
|
66 |
CTestStepRecorderBitRateWav::~CTestStepRecorderBitRateWav()
|
|
67 |
{
|
|
68 |
}
|
|
69 |
|
|
70 |
/**
|
|
71 |
*
|
|
72 |
* Callback Handle.
|
|
73 |
*
|
|
74 |
* @xxxx
|
|
75 |
*
|
|
76 |
*/
|
|
77 |
void CTestStepRecorderBitRateWav::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
78 |
TInt /*aPreviousState*/,
|
|
79 |
TInt /*aCurrentState*/,
|
|
80 |
TInt aErrorCode)
|
|
81 |
{
|
|
82 |
iError = aErrorCode;
|
|
83 |
CActiveScheduler::Stop();
|
|
84 |
}
|
|
85 |
|
|
86 |
/**
|
|
87 |
*
|
|
88 |
* Do the test step.
|
|
89 |
* Each test step must supply an implementation for DoTestStepL.
|
|
90 |
*
|
|
91 |
* @return "TVerdict"
|
|
92 |
* The result of the test step
|
|
93 |
*
|
|
94 |
* @xxxx
|
|
95 |
*
|
|
96 |
*/
|
|
97 |
TVerdict CTestStepRecorderBitRateWav::DoTestStepL()
|
|
98 |
{
|
|
99 |
// Printing to the console and log file
|
|
100 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0852-HP"));
|
|
101 |
INFO_PRINTF1(_L("This test will read the bit rate of different wav files"));
|
|
102 |
|
|
103 |
TInt err = KErrNone;
|
|
104 |
TVerdict result = EPass;
|
|
105 |
|
|
106 |
RArray<TPtrC> array;
|
|
107 |
array.Append(_L("PCM8BitStereo.wav"));
|
|
108 |
array.Append(_L("PCM 8-Bit,8000 Hz,128 Kbps,Stereo"));
|
|
109 |
array.Append(_L("PCM8BitMono.wav"));
|
|
110 |
array.Append(_L("PCM 8-Bit,8000 Hz,64 Kbps,Mono"));
|
|
111 |
array.Append(_L("PCM16BitStereo.wav"));
|
|
112 |
array.Append(_L("PCM 16-Bit,8000 Hz,256 Kbps,Stereo"));
|
|
113 |
array.Append(_L("PCM16BitMono.wav"));
|
|
114 |
array.Append(_L("PCM 16-Bit,8000 Hz,128 Kbps,Mono"));
|
|
115 |
|
|
116 |
CMMFMdaAudioRecorderUtility* recorder = CMMFMdaAudioRecorderUtility::NewL(*this);
|
|
117 |
|
|
118 |
if (recorder == NULL ||
|
|
119 |
iError != KErrNone)
|
|
120 |
{
|
|
121 |
return EInconclusive;
|
|
122 |
}
|
|
123 |
|
|
124 |
CleanupStack::PushL(recorder);
|
|
125 |
TInt count = array.Count();
|
|
126 |
for (TInt iter=0; iter<count; iter+=2)
|
|
127 |
{
|
|
128 |
TUint bitRate = 0;
|
|
129 |
TBuf<256> fileBuf;
|
|
130 |
|
|
131 |
// Append the test file path
|
|
132 |
fileBuf.Append(KFilePath);
|
|
133 |
// Append the test file name
|
|
134 |
fileBuf.Append(array[iter]);
|
|
135 |
|
|
136 |
INFO_PRINTF2(_L("Opening file = %S"), &fileBuf);
|
|
137 |
INFO_PRINTF2(_L("File info = %S"), &array[iter+1]);
|
|
138 |
|
|
139 |
TRAP(err,recorder->OpenFileL(fileBuf));
|
|
140 |
// If the opening fails, save the test result as fail and continue looping
|
|
141 |
if (err != KErrNone)
|
|
142 |
{
|
|
143 |
INFO_PRINTF2(_L("Opening file %S failed"), &fileBuf);
|
|
144 |
result = EFail;
|
|
145 |
continue;
|
|
146 |
}
|
|
147 |
CActiveScheduler::Start();
|
|
148 |
// Get the bit rate of the file.
|
|
149 |
TRAPD(error,bitRate = recorder->SourceBitRateL());
|
|
150 |
if (error != KErrNone)
|
|
151 |
{
|
|
152 |
INFO_PRINTF2(_L("Obtaining the bit rate for the file %S failed"), &fileBuf);
|
|
153 |
result = EFail;
|
|
154 |
}
|
|
155 |
else
|
|
156 |
{
|
|
157 |
INFO_PRINTF2(_L("Bit rate of the file = %d bps"), bitRate);
|
|
158 |
}
|
|
159 |
|
|
160 |
// Close the file.
|
|
161 |
recorder->Close();
|
|
162 |
|
|
163 |
if ( err != KErrNone ||
|
|
164 |
iError != KErrNone)
|
|
165 |
{
|
|
166 |
result = EFail;
|
|
167 |
}
|
|
168 |
}
|
|
169 |
CleanupStack::PopAndDestroy(recorder);
|
|
170 |
|
|
171 |
INFO_PRINTF1(_L("Finished with this test step"));
|
|
172 |
// test steps return a result
|
|
173 |
return result;
|
|
174 |
}
|
|
175 |
|
|
176 |
//----- Test for AU files -----
|
|
177 |
/**
|
|
178 |
*
|
|
179 |
* Static constructor for CTestStepRecorderBitRateAu.
|
|
180 |
*
|
|
181 |
*
|
|
182 |
* @return "CTestStepRecorderBitRateAu*"
|
|
183 |
* The constructed CTestStepRecorderBitRateAu
|
|
184 |
*
|
|
185 |
* @xxxx
|
|
186 |
*
|
|
187 |
*/
|
|
188 |
CTestStepRecorderBitRateAu* CTestStepRecorderBitRateAu::NewL()
|
|
189 |
{
|
|
190 |
CTestStepRecorderBitRateAu* self = new(ELeave) CTestStepRecorderBitRateAu;
|
|
191 |
return self;
|
|
192 |
}
|
|
193 |
|
|
194 |
/**
|
|
195 |
*
|
|
196 |
* Test step constructor.
|
|
197 |
* Each test step initialises its own name.
|
|
198 |
*
|
|
199 |
* @xxxx
|
|
200 |
*
|
|
201 |
*/
|
|
202 |
CTestStepRecorderBitRateAu::CTestStepRecorderBitRateAu()
|
|
203 |
{
|
|
204 |
// store the name of this test case
|
|
205 |
// this is the name that is used by the script file
|
|
206 |
iTestStepName = _L("MM-MMF-ACLNT-U-0853-HP");
|
|
207 |
}
|
|
208 |
|
|
209 |
/**
|
|
210 |
*
|
|
211 |
* Test step destructor.
|
|
212 |
*
|
|
213 |
* @xxxx
|
|
214 |
*
|
|
215 |
*/
|
|
216 |
CTestStepRecorderBitRateAu::~CTestStepRecorderBitRateAu()
|
|
217 |
{
|
|
218 |
}
|
|
219 |
|
|
220 |
/**
|
|
221 |
*
|
|
222 |
* Callback Handle.
|
|
223 |
*
|
|
224 |
* @xxxx
|
|
225 |
*
|
|
226 |
*/
|
|
227 |
void CTestStepRecorderBitRateAu::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
228 |
TInt /*aPreviousState*/,
|
|
229 |
TInt /*aCurrentState*/,
|
|
230 |
TInt aErrorCode)
|
|
231 |
{
|
|
232 |
iError = aErrorCode;
|
|
233 |
CActiveScheduler::Stop();
|
|
234 |
}
|
|
235 |
|
|
236 |
/**
|
|
237 |
*
|
|
238 |
* Do the test step.
|
|
239 |
* Each test step must supply an implementation for DoTestStepL.
|
|
240 |
*
|
|
241 |
* @return "TVerdict"
|
|
242 |
* The result of the test step
|
|
243 |
*
|
|
244 |
* @xxxx
|
|
245 |
*
|
|
246 |
*/
|
|
247 |
TVerdict CTestStepRecorderBitRateAu::DoTestStepL()
|
|
248 |
{
|
|
249 |
// Printing to the console and log file
|
|
250 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0853-HP"));
|
|
251 |
INFO_PRINTF1(_L("This test will read the bit rate of a different AU files"));
|
|
252 |
|
|
253 |
TInt err = KErrNone;
|
|
254 |
TVerdict result = EPass;
|
|
255 |
|
|
256 |
RArray<TPtrC> array;
|
|
257 |
array.Append(_L("PCM8BitStereo.au"));
|
|
258 |
array.Append(_L("PCM 8-Bit,8000 Hz,128 Kbps,Stereo"));
|
|
259 |
array.Append(_L("PCM8BitMono.au"));
|
|
260 |
array.Append(_L("PCM 8-Bit,8000 Hz,64 Kbps,Mono"));
|
|
261 |
array.Append(_L("PCM16BitStereo.au"));
|
|
262 |
array.Append(_L("PCM 16-Bit,8000 Hz,256 Kbps,Stereo"));
|
|
263 |
array.Append(_L("PCM16BitMono.au"));
|
|
264 |
array.Append(_L("PCM 16-Bit,8000 Hz,128 Kbps,Mono"));
|
|
265 |
|
|
266 |
CMMFMdaAudioRecorderUtility* recorder = CMMFMdaAudioRecorderUtility::NewL(*this);
|
|
267 |
|
|
268 |
if (recorder == NULL ||
|
|
269 |
iError != KErrNone)
|
|
270 |
{
|
|
271 |
return EInconclusive;
|
|
272 |
}
|
|
273 |
|
|
274 |
CleanupStack::PushL(recorder);
|
|
275 |
TInt count = array.Count();
|
|
276 |
for (TInt iter=0; iter<count; iter+=2)
|
|
277 |
{
|
|
278 |
TUint bitRate = 0;
|
|
279 |
TBuf<256> fileBuf;
|
|
280 |
|
|
281 |
// Append the test file path
|
|
282 |
fileBuf.Append(KFilePath);
|
|
283 |
// Append the test file name
|
|
284 |
fileBuf.Append(array[iter]);
|
|
285 |
|
|
286 |
INFO_PRINTF2(_L("Opening file = %S"), &fileBuf);
|
|
287 |
INFO_PRINTF2(_L("File info = %S"), &array[iter+1]);
|
|
288 |
|
|
289 |
TRAP(err,recorder->OpenFileL(fileBuf));
|
|
290 |
// If the opening fails, save the test result as fail and continue looping
|
|
291 |
if (err != KErrNone)
|
|
292 |
{
|
|
293 |
INFO_PRINTF2(_L("Opening file %S failed"), &fileBuf);
|
|
294 |
result = EFail;
|
|
295 |
continue;
|
|
296 |
}
|
|
297 |
CActiveScheduler::Start();
|
|
298 |
// Get the bit rate of the file.
|
|
299 |
TRAPD(error, bitRate = recorder->SourceBitRateL());
|
|
300 |
if (error != KErrNone)
|
|
301 |
{
|
|
302 |
INFO_PRINTF2(_L("Obtaining the bit rate for the file %S failed"), &fileBuf);
|
|
303 |
result = EFail;
|
|
304 |
}
|
|
305 |
else
|
|
306 |
{
|
|
307 |
INFO_PRINTF2(_L("Bit rate of the file = %d bps"), bitRate);
|
|
308 |
}
|
|
309 |
// Close the file.
|
|
310 |
recorder->Close();
|
|
311 |
|
|
312 |
if ( err != KErrNone ||
|
|
313 |
iError != KErrNone)
|
|
314 |
{
|
|
315 |
result = EFail;
|
|
316 |
}
|
|
317 |
}
|
|
318 |
CleanupStack::PopAndDestroy(recorder);
|
|
319 |
|
|
320 |
INFO_PRINTF1(_L("Finished with this test step"));
|
|
321 |
// test steps return a result
|
|
322 |
return result;
|
|
323 |
}
|