0
|
1 |
// Copyright (c) 2002-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 |
// EPOC includes
|
|
22 |
#include <e32base.h>
|
|
23 |
#include <e32test.h>
|
|
24 |
#include <e32keys.h>
|
|
25 |
#include <c32comm.h>
|
|
26 |
#include <f32file.h>
|
|
27 |
#include <etel.h>
|
|
28 |
#include <etelmm.h>
|
|
29 |
#include <testframework.h>
|
|
30 |
|
|
31 |
//#include <MdaAudioSamplePlayer.h>
|
|
32 |
#include <mdaaudiosampleeditor.h>
|
|
33 |
//#include <MdaAudioTonePlayer.h>
|
|
34 |
|
|
35 |
// Test system includes
|
|
36 |
#include <testframework.h>
|
|
37 |
|
|
38 |
// Specific includes for this test suite
|
|
39 |
#include "TestStepUnitMMFAudClient.h"
|
|
40 |
#include "TestSuiteUnitMMFAudClient.h"
|
|
41 |
|
|
42 |
// Specific includes for these test steps
|
|
43 |
#include "TestStepRecorder.h"
|
|
44 |
|
|
45 |
|
|
46 |
#include "MmfAudioController.h"
|
|
47 |
#include "mmfclientaudiorecorder.h"
|
|
48 |
//#include "MmfClientAudioPlayer.h"
|
|
49 |
//#include <mmffourcc.h>
|
|
50 |
//#include <mmfpaniccodes.h>
|
|
51 |
//#include <mmfFormatImplementationUIDs.hrh>
|
|
52 |
// --------------------------------------------
|
|
53 |
|
|
54 |
/**
|
|
55 |
*
|
|
56 |
* Static constructor for CTestStepRecorderOpenFile.
|
|
57 |
*
|
|
58 |
*
|
|
59 |
* @return "CTestStepRecorderOpenFile*"
|
|
60 |
* The constructed CTestStepRecorderOpenFile
|
|
61 |
*
|
|
62 |
* @xxxx
|
|
63 |
*
|
|
64 |
*/
|
|
65 |
CTestStepRecorderOpenFile* CTestStepRecorderOpenFile::NewL(TBool aOpenFileTwice)
|
|
66 |
{
|
|
67 |
CTestStepRecorderOpenFile* self = new(ELeave) CTestStepRecorderOpenFile(aOpenFileTwice);
|
|
68 |
return self;
|
|
69 |
}
|
|
70 |
|
|
71 |
/**
|
|
72 |
*
|
|
73 |
* Test step constructor.
|
|
74 |
* Each test step initialises its own name.
|
|
75 |
*
|
|
76 |
* @xxxx
|
|
77 |
*
|
|
78 |
*/
|
|
79 |
CTestStepRecorderOpenFile::CTestStepRecorderOpenFile(TBool aOpenFileTwice)
|
|
80 |
{
|
|
81 |
iOpenFileTwice = aOpenFileTwice;
|
|
82 |
|
|
83 |
if (aOpenFileTwice)
|
|
84 |
{
|
|
85 |
iTestStepName = _L("MM-MMF-ACLNT-U-0202-CP");
|
|
86 |
}
|
|
87 |
else
|
|
88 |
{
|
|
89 |
// store the name of this test case
|
|
90 |
// this is the name that is used by the script file
|
|
91 |
iTestStepName = _L("MM-MMF-ACLNT-U-0203-CP");
|
|
92 |
}
|
|
93 |
}
|
|
94 |
|
|
95 |
/**
|
|
96 |
*
|
|
97 |
* Test step destructor.
|
|
98 |
*
|
|
99 |
* @xxxx
|
|
100 |
*
|
|
101 |
*/
|
|
102 |
CTestStepRecorderOpenFile::~CTestStepRecorderOpenFile()
|
|
103 |
{
|
|
104 |
}
|
|
105 |
|
|
106 |
/**
|
|
107 |
*
|
|
108 |
* Test step Preamble.
|
|
109 |
*
|
|
110 |
* @xxxx
|
|
111 |
*
|
|
112 |
*/
|
|
113 |
enum TVerdict CTestStepRecorderOpenFile::DoTestStepPreambleL(void)
|
|
114 |
{
|
|
115 |
enum TVerdict verdict;
|
|
116 |
// this installs the scheduler
|
|
117 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
118 |
|
|
119 |
// Printing to the console and log file
|
|
120 |
if (iOpenFileTwice)
|
|
121 |
{
|
|
122 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0202-CP"));
|
|
123 |
INFO_PRINTF1(_L("this is a test of CMdaAudioRecorderUtility::OpenFileL() twice without waiting for an Open complete event"));
|
|
124 |
}
|
|
125 |
else
|
|
126 |
{
|
|
127 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0203-CP"));
|
|
128 |
INFO_PRINTF1(_L("this is a test of CMdaAudioRecorderUtility::OpenFileL()"));
|
|
129 |
}
|
|
130 |
|
|
131 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName7"), iFileNames[0])) // wav file
|
|
132 |
{
|
|
133 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
134 |
return EInconclusive;
|
|
135 |
}
|
|
136 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName3"), iFileNames[1])) // au file
|
|
137 |
{
|
|
138 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
139 |
return EInconclusive;
|
|
140 |
}
|
|
141 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName5"), iFileNames[2])) // raw file
|
|
142 |
{
|
|
143 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
144 |
return EInconclusive;
|
|
145 |
}
|
|
146 |
|
|
147 |
return verdict;
|
|
148 |
|
|
149 |
}
|
|
150 |
|
|
151 |
/**
|
|
152 |
*
|
|
153 |
* Test step Postamble.
|
|
154 |
*
|
|
155 |
* @xxxx
|
|
156 |
*
|
|
157 |
*/
|
|
158 |
enum TVerdict CTestStepRecorderOpenFile::DoTestStepPostambleL(void)
|
|
159 |
{
|
|
160 |
delete iRecorder;
|
|
161 |
iRecorder = NULL;
|
|
162 |
//[ Destroy the scheduler ]
|
|
163 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
164 |
}
|
|
165 |
|
|
166 |
/**
|
|
167 |
*
|
|
168 |
* Callback Handle.
|
|
169 |
*
|
|
170 |
* @xxxx
|
|
171 |
*
|
|
172 |
*/
|
|
173 |
void CTestStepRecorderOpenFile::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
174 |
TInt /*aPreviousState*/,
|
|
175 |
TInt /*aCurrentState*/,
|
|
176 |
TInt aErrorcCode)
|
|
177 |
{
|
|
178 |
iError = aErrorcCode;
|
|
179 |
CActiveScheduler::Stop();
|
|
180 |
}
|
|
181 |
|
|
182 |
void CTestStepRecorderOpenFile::OpenAndStartSchedulerL(TInt i)
|
|
183 |
{
|
|
184 |
iRecorder->OpenFileL( iFileNames[i] );
|
|
185 |
|
|
186 |
if (iOpenFileTwice)
|
|
187 |
{
|
|
188 |
iRecorder->OpenFileL( iFileNames[i] );
|
|
189 |
}
|
|
190 |
|
|
191 |
CActiveScheduler::Start(); // wait for open to complete
|
|
192 |
User::LeaveIfError(iError);
|
|
193 |
iRecorder->PlayL();
|
|
194 |
CActiveScheduler::Start(); // wait once for start of play
|
|
195 |
User::LeaveIfError(iError);
|
|
196 |
CActiveScheduler::Start(); // and once for end of play
|
|
197 |
User::LeaveIfError(iError);
|
|
198 |
}
|
|
199 |
|
|
200 |
const TInt KRawTest = 2;
|
|
201 |
|
|
202 |
/**
|
|
203 |
*
|
|
204 |
* Do the test step.
|
|
205 |
* Each test step must supply an implementation for DoTestStepL.
|
|
206 |
*
|
|
207 |
* @return "TVerdict"
|
|
208 |
* The result of the test step
|
|
209 |
*
|
|
210 |
* @xxxx
|
|
211 |
*
|
|
212 |
*/
|
|
213 |
TVerdict CTestStepRecorderOpenFile::DoTestStepL()
|
|
214 |
{
|
|
215 |
iTestStepResult = EPass;
|
|
216 |
TInt err = KErrNone;
|
|
217 |
|
|
218 |
for (TInt type=0; type<3; type++)
|
|
219 |
{
|
|
220 |
// create the Recorder utility
|
|
221 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
222 |
return EInconclusive;
|
|
223 |
|
|
224 |
TRAP( err, OpenAndStartSchedulerL(type) );
|
|
225 |
|
|
226 |
// RAW files cannot be opened if no format is specified, so unsupported is the
|
|
227 |
// correct return code
|
|
228 |
if (type == KRawTest)
|
|
229 |
{
|
|
230 |
if (err != KErrNotSupported)
|
|
231 |
return EFail;
|
|
232 |
}
|
|
233 |
else
|
|
234 |
{
|
|
235 |
if (iRecorder == NULL ||
|
|
236 |
err != KErrNone ||
|
|
237 |
iError != KErrNone ||
|
|
238 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
239 |
return EFail;
|
|
240 |
}
|
|
241 |
|
|
242 |
delete iRecorder;
|
|
243 |
iRecorder = NULL;
|
|
244 |
}
|
|
245 |
|
|
246 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
247 |
// test steps return a result
|
|
248 |
return iTestStepResult;
|
|
249 |
}
|
|
250 |
|
|
251 |
|
|
252 |
/**
|
|
253 |
*
|
|
254 |
* Static constructor for CTestStepRecorderOpenMp3File.
|
|
255 |
*
|
|
256 |
*
|
|
257 |
* @return "CTestStepRecorderOpenMp3File*"
|
|
258 |
* The constructed CTestStepRecorderOpenMp3File
|
|
259 |
*
|
|
260 |
* @xxxx
|
|
261 |
*
|
|
262 |
*/
|
|
263 |
CTestStepRecorderOpenMp3File* CTestStepRecorderOpenMp3File::NewL()
|
|
264 |
{
|
|
265 |
CTestStepRecorderOpenMp3File* self = new(ELeave) CTestStepRecorderOpenMp3File;
|
|
266 |
return self;
|
|
267 |
}
|
|
268 |
|
|
269 |
/**
|
|
270 |
*
|
|
271 |
* Test step constructor.
|
|
272 |
* Each test step initialises its own name.
|
|
273 |
*
|
|
274 |
* @xxxx
|
|
275 |
*
|
|
276 |
*/
|
|
277 |
CTestStepRecorderOpenMp3File::CTestStepRecorderOpenMp3File()
|
|
278 |
{
|
|
279 |
// store the name of this test case
|
|
280 |
// this is the name that is used by the script file
|
|
281 |
iTestStepName = _L("MM-MMF-ACLNT-U-0823-HP");
|
|
282 |
}
|
|
283 |
|
|
284 |
/**
|
|
285 |
*
|
|
286 |
* Test step destructor.
|
|
287 |
*
|
|
288 |
* @xxxx
|
|
289 |
*
|
|
290 |
*/
|
|
291 |
CTestStepRecorderOpenMp3File::~CTestStepRecorderOpenMp3File()
|
|
292 |
{
|
|
293 |
}
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
/**
|
|
298 |
*
|
|
299 |
* Test step Preamble.
|
|
300 |
*
|
|
301 |
* @xxxx
|
|
302 |
*
|
|
303 |
*/
|
|
304 |
enum TVerdict CTestStepRecorderOpenMp3File::DoTestStepPreambleL(void)
|
|
305 |
{
|
|
306 |
enum TVerdict verdict;
|
|
307 |
// this installs the scheduler
|
|
308 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
309 |
|
|
310 |
// Printing to the console and log file
|
|
311 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0823-HP"));
|
|
312 |
INFO_PRINTF1(_L("this tests opening a clip by extension only"));
|
|
313 |
|
|
314 |
|
|
315 |
|
|
316 |
// raw mp3 file
|
|
317 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayMp3FName1"), iFileName))
|
|
318 |
{
|
|
319 |
INFO_PRINTF2(_L("file name %S not found..."), &iFileName);
|
|
320 |
return EInconclusive;
|
|
321 |
}
|
|
322 |
iFileInfo.Append(TMp3FileInfo(iFileName, EPass, KErrNone));
|
|
323 |
|
|
324 |
// id3 mp3 file
|
|
325 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayMp3FName2"), iFileName))
|
|
326 |
{
|
|
327 |
INFO_PRINTF2(_L("file name %S not found..."), &iFileName);
|
|
328 |
return EInconclusive;
|
|
329 |
}
|
|
330 |
iFileInfo.Append(TMp3FileInfo(iFileName, EPass, KErrNone));
|
|
331 |
|
|
332 |
// wav mp3 file
|
|
333 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayMp3FName3"), iFileName))
|
|
334 |
{
|
|
335 |
INFO_PRINTF2(_L("file name %S not found..."), &iFileName);
|
|
336 |
return EInconclusive;
|
|
337 |
}
|
|
338 |
iFileInfo.Append(TMp3FileInfo(iFileName, EPass, KErrNone));
|
|
339 |
|
|
340 |
// wav pcm file
|
|
341 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName1"), iFileName))
|
|
342 |
{
|
|
343 |
INFO_PRINTF2(_L("file name %S not found..."), &iFileName);
|
|
344 |
return EInconclusive;
|
|
345 |
}
|
|
346 |
iFileInfo.Append(TMp3FileInfo(iFileName, EPass, KErrNone));
|
|
347 |
|
|
348 |
// dummy mp3 file
|
|
349 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayMp3FName4"), iFileName))
|
|
350 |
{
|
|
351 |
INFO_PRINTF2(_L("file name %S not found..."), &iFileName);
|
|
352 |
return EInconclusive;
|
|
353 |
}
|
|
354 |
iFileInfo.Append(TMp3FileInfo(iFileName, EFail, KErrNotSupported));
|
|
355 |
|
|
356 |
return verdict;
|
|
357 |
|
|
358 |
}
|
|
359 |
|
|
360 |
/**
|
|
361 |
*
|
|
362 |
* Test step Postamble.
|
|
363 |
*
|
|
364 |
* @xxxx
|
|
365 |
*
|
|
366 |
*/
|
|
367 |
enum TVerdict CTestStepRecorderOpenMp3File::DoTestStepPostambleL(void)
|
|
368 |
{
|
|
369 |
iFileInfo.Close();
|
|
370 |
|
|
371 |
delete iRecorder;
|
|
372 |
iRecorder = NULL;
|
|
373 |
//[ Destroy the scheduler ]
|
|
374 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
375 |
}
|
|
376 |
|
|
377 |
/**
|
|
378 |
*
|
|
379 |
* Callback Handle.
|
|
380 |
*
|
|
381 |
* @xxxx
|
|
382 |
*
|
|
383 |
*/
|
|
384 |
void CTestStepRecorderOpenMp3File::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
385 |
TInt aPreviousState,
|
|
386 |
TInt aCurrentState,
|
|
387 |
TInt aErrorCode)
|
|
388 |
{
|
|
389 |
iError = aErrorCode;
|
|
390 |
iState = aCurrentState;
|
|
391 |
INFO_PRINTF4(_L("MoscoStateChangeEvent() : Prev state = %d, curr state = %d, error = %d"), aPreviousState, aCurrentState, aErrorCode);
|
|
392 |
CActiveScheduler::Stop();
|
|
393 |
}
|
|
394 |
|
|
395 |
void CTestStepRecorderOpenMp3File::OpenAndStartSchedulerL()
|
|
396 |
{
|
|
397 |
iRecorder->OpenFileL( iFileName );
|
|
398 |
CActiveScheduler::Start(); // wait for open to complete
|
|
399 |
User::LeaveIfError(iError);
|
|
400 |
|
|
401 |
|
|
402 |
iRecorder->PlayL();
|
|
403 |
CActiveScheduler::Start(); // wait once for start of play
|
|
404 |
User::LeaveIfError(iError);
|
|
405 |
CActiveScheduler::Start(); // and once for end of play
|
|
406 |
User::LeaveIfError(iError);
|
|
407 |
|
|
408 |
}
|
|
409 |
|
|
410 |
|
|
411 |
TVerdict CTestStepRecorderOpenMp3File::DoTestStepL()
|
|
412 |
{
|
|
413 |
TInt n;
|
|
414 |
|
|
415 |
TVerdict testVerdict = EPass;
|
|
416 |
|
|
417 |
for (n=0; n<iFileInfo.Count(); n++)
|
|
418 |
{
|
|
419 |
iFileName.Set(iFileInfo[n].iFileName);
|
|
420 |
INFO_PRINTF3(_L("Test #%d: Opening %S"), n, &iFileName);
|
|
421 |
TVerdict stepVerdict = DoNextTestStepL();
|
|
422 |
if (stepVerdict != iFileInfo[n].iExpectedVerdict)
|
|
423 |
{
|
|
424 |
testVerdict = stepVerdict;
|
|
425 |
INFO_PRINTF3(_L("Unexpected verdict = %d, error = %d"), stepVerdict, iError);
|
|
426 |
}
|
|
427 |
}
|
|
428 |
return testVerdict;
|
|
429 |
}
|
|
430 |
|
|
431 |
|
|
432 |
/**
|
|
433 |
*
|
|
434 |
* Do the test step.
|
|
435 |
* Each test step must supply an implementation for DoTestStepL.
|
|
436 |
*
|
|
437 |
* @return "TVerdict"
|
|
438 |
* The result of the test step
|
|
439 |
*
|
|
440 |
* @xxxx
|
|
441 |
*
|
|
442 |
*/
|
|
443 |
TVerdict CTestStepRecorderOpenMp3File::DoNextTestStepL()
|
|
444 |
{
|
|
445 |
TVerdict verdict = EPass;
|
|
446 |
TInt err = KErrNone;
|
|
447 |
iError = KErrNone;
|
|
448 |
|
|
449 |
// create the Recorder utility
|
|
450 |
if ((iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL)
|
|
451 |
return EInconclusive;
|
|
452 |
|
|
453 |
TRAP( err, OpenAndStartSchedulerL() );
|
|
454 |
|
|
455 |
if (iRecorder == NULL ||
|
|
456 |
err != KErrNone ||
|
|
457 |
iError != KErrNone ||
|
|
458 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
459 |
{
|
|
460 |
INFO_PRINTF4(_L("err = %d, iError = %d, state = iState"), err, iError, iState);
|
|
461 |
|
|
462 |
// "return" error to caller
|
|
463 |
if (iError == KErrNone)
|
|
464 |
iError = err;
|
|
465 |
|
|
466 |
verdict = EFail;
|
|
467 |
}
|
|
468 |
|
|
469 |
delete iRecorder;
|
|
470 |
iRecorder = NULL;
|
|
471 |
|
|
472 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
473 |
|
|
474 |
// test steps return a result
|
|
475 |
return verdict;
|
|
476 |
}
|
|
477 |
|
|
478 |
|