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 CTestStepRecorderReopen.
|
|
57 |
*
|
|
58 |
*
|
|
59 |
* @return "CTestStepRecorderReopen*"
|
|
60 |
* The constructed CTestStepRecorderReopen
|
|
61 |
*
|
|
62 |
* @xxxx
|
|
63 |
*
|
|
64 |
*/
|
|
65 |
CTestStepRecorderReopen* CTestStepRecorderReopen::NewL()
|
|
66 |
{
|
|
67 |
CTestStepRecorderReopen* self = new(ELeave) CTestStepRecorderReopen;
|
|
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 |
CTestStepRecorderReopen::CTestStepRecorderReopen()
|
|
80 |
{
|
|
81 |
// store the name of this test case
|
|
82 |
// this is the name that is used by the script file
|
|
83 |
iTestStepName = _L("MM-MMF-ACLNT-U-0230-HP");
|
|
84 |
}
|
|
85 |
|
|
86 |
/**
|
|
87 |
*
|
|
88 |
* Test step destructor.
|
|
89 |
*
|
|
90 |
* @xxxx
|
|
91 |
*
|
|
92 |
*/
|
|
93 |
CTestStepRecorderReopen::~CTestStepRecorderReopen()
|
|
94 |
{
|
|
95 |
}
|
|
96 |
|
|
97 |
/**
|
|
98 |
*
|
|
99 |
* Test step Preamble.
|
|
100 |
*
|
|
101 |
* @xxxx
|
|
102 |
*
|
|
103 |
*/
|
|
104 |
enum TVerdict CTestStepRecorderReopen::DoTestStepPreambleL(void)
|
|
105 |
{
|
|
106 |
enum TVerdict verdict;
|
|
107 |
// this installs the scheduler
|
|
108 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
109 |
|
|
110 |
// Printing to the console and log file
|
|
111 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0230-HP"));
|
|
112 |
INFO_PRINTF1(_L("this is a test of CMdaAudioRecorderUtility::OpenL()-Close()-Open()"));
|
|
113 |
|
|
114 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName7"), iFileName)) // wav file
|
|
115 |
{
|
|
116 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
117 |
return EInconclusive;
|
|
118 |
}
|
|
119 |
|
|
120 |
// create the Recorder utility
|
|
121 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
122 |
verdict = EInconclusive;
|
|
123 |
|
|
124 |
return verdict;
|
|
125 |
|
|
126 |
}
|
|
127 |
|
|
128 |
/**
|
|
129 |
*
|
|
130 |
* Test step Postamble.
|
|
131 |
*
|
|
132 |
* @xxxx
|
|
133 |
*
|
|
134 |
*/
|
|
135 |
enum TVerdict CTestStepRecorderReopen::DoTestStepPostambleL(void)
|
|
136 |
{
|
|
137 |
delete iRecorder;
|
|
138 |
iRecorder = NULL;
|
|
139 |
//[ Destroy the scheduler ]
|
|
140 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
141 |
}
|
|
142 |
|
|
143 |
/**
|
|
144 |
*
|
|
145 |
* Callback Handle.
|
|
146 |
*
|
|
147 |
* @xxxx
|
|
148 |
*
|
|
149 |
*/
|
|
150 |
void CTestStepRecorderReopen::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
151 |
TInt /*aPreviousState*/,
|
|
152 |
TInt /*aCurrentState*/,
|
|
153 |
TInt aErrorcCode)
|
|
154 |
{
|
|
155 |
iError = aErrorcCode;
|
|
156 |
CActiveScheduler::Stop();
|
|
157 |
}
|
|
158 |
|
|
159 |
void CTestStepRecorderReopen::OpenAndStartSchedulerL()
|
|
160 |
{
|
|
161 |
iRecorder->OpenFileL( iFileName );
|
|
162 |
CActiveScheduler::Start();
|
|
163 |
}
|
|
164 |
|
|
165 |
/**
|
|
166 |
*
|
|
167 |
* Do the test step.
|
|
168 |
* Each test step must supply an implementation for DoTestStepL.
|
|
169 |
*
|
|
170 |
* @return "TVerdict"
|
|
171 |
* The result of the test step
|
|
172 |
*
|
|
173 |
* @xxxx
|
|
174 |
*
|
|
175 |
*/
|
|
176 |
TVerdict CTestStepRecorderReopen::DoTestStepL()
|
|
177 |
{
|
|
178 |
iTestStepResult = EPass;
|
|
179 |
TInt err = KErrNone;
|
|
180 |
|
|
181 |
TRAP( err, OpenAndStartSchedulerL() );
|
|
182 |
|
|
183 |
if (iRecorder == NULL ||
|
|
184 |
err != KErrNone ||
|
|
185 |
iError != KErrNone ||
|
|
186 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen )
|
|
187 |
return EFail;
|
|
188 |
|
|
189 |
iRecorder->Close();
|
|
190 |
User::After(200000);
|
|
191 |
|
|
192 |
// reopen the file
|
|
193 |
TRAP( err, OpenAndStartSchedulerL() );
|
|
194 |
|
|
195 |
if (iRecorder == NULL ||
|
|
196 |
err != KErrNone ||
|
|
197 |
iError != KErrNone ||
|
|
198 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen )
|
|
199 |
return EFail;
|
|
200 |
|
|
201 |
iRecorder->Close();
|
|
202 |
delete iRecorder;
|
|
203 |
iRecorder = NULL;
|
|
204 |
|
|
205 |
|
|
206 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
207 |
// test steps return a result
|
|
208 |
return iTestStepResult;
|
|
209 |
}
|
|
210 |
|
|
211 |
|
|
212 |
// new test for defect DEF022197 :
|
|
213 |
|
|
214 |
/**
|
|
215 |
*
|
|
216 |
* Static constructor for CTestStepRecorderPlayRecordPlay.
|
|
217 |
*
|
|
218 |
*
|
|
219 |
* @return "CTestStepRecorderPlayRecordPlay*"
|
|
220 |
* The constructed CTestStepRecorderPlayRecordPlay
|
|
221 |
*
|
|
222 |
* @xxxx
|
|
223 |
*
|
|
224 |
*/
|
|
225 |
CTestStepRecorderPlayRecordPlay* CTestStepRecorderPlayRecordPlay::NewL()
|
|
226 |
{
|
|
227 |
CTestStepRecorderPlayRecordPlay* self = new(ELeave) CTestStepRecorderPlayRecordPlay;
|
|
228 |
return self;
|
|
229 |
}
|
|
230 |
|
|
231 |
/**
|
|
232 |
*
|
|
233 |
* Test step constructor.
|
|
234 |
* Each test step initialises its own name.
|
|
235 |
*
|
|
236 |
* @xxxx
|
|
237 |
*
|
|
238 |
*/
|
|
239 |
CTestStepRecorderPlayRecordPlay::CTestStepRecorderPlayRecordPlay()
|
|
240 |
{
|
|
241 |
// store the name of this test case
|
|
242 |
// this is the name that is used by the script file
|
|
243 |
iTestStepName = _L("MM-MMF-ACLNT-U-0281-HP");
|
|
244 |
}
|
|
245 |
|
|
246 |
/**
|
|
247 |
*
|
|
248 |
* Test step destructor.
|
|
249 |
*
|
|
250 |
* @xxxx
|
|
251 |
*
|
|
252 |
*/
|
|
253 |
CTestStepRecorderPlayRecordPlay::~CTestStepRecorderPlayRecordPlay()
|
|
254 |
{
|
|
255 |
}
|
|
256 |
|
|
257 |
/**
|
|
258 |
*
|
|
259 |
* Test step Preamble.
|
|
260 |
*
|
|
261 |
* @xxxx
|
|
262 |
*
|
|
263 |
*/
|
|
264 |
enum TVerdict CTestStepRecorderPlayRecordPlay::DoTestStepPreambleL(void)
|
|
265 |
{
|
|
266 |
enum TVerdict verdict;
|
|
267 |
// this installs the scheduler
|
|
268 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
269 |
|
|
270 |
// Printing to the console and log file
|
|
271 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0281-HP"));
|
|
272 |
INFO_PRINTF1(_L("this is a test of playing a file, recording more data to it, then playing it again"));
|
|
273 |
|
|
274 |
// record_n_delete_after.wav
|
|
275 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioFNameToRecord4"), iFileNameWav))
|
|
276 |
return EInconclusive;
|
|
277 |
|
|
278 |
// record_n_delete_after.au
|
|
279 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioFNameToRecord5"), iFileNameAu))
|
|
280 |
return EInconclusive;
|
|
281 |
|
|
282 |
// we can't play raw files with the CMMFMdaAudioPlayerUtility API !
|
|
283 |
// record_n_delete_after.raw
|
|
284 |
//if(!GetStringFromConfig(_L("SectionOne"), _L("AudioFNameToRecord6"), iFileNameRaw))
|
|
285 |
// return EInconclusive;
|
|
286 |
|
|
287 |
// create the Recorder utility
|
|
288 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
289 |
verdict = EInconclusive;
|
|
290 |
|
|
291 |
// create the Player utility
|
|
292 |
if ( (iPlayer = CMMFMdaAudioPlayerUtility::NewL(*this)) == NULL )
|
|
293 |
verdict = EInconclusive;
|
|
294 |
|
|
295 |
|
|
296 |
return verdict;
|
|
297 |
|
|
298 |
}
|
|
299 |
|
|
300 |
void CTestStepRecorderPlayRecordPlay::DeleteFileL(TPtrC aFileName)
|
|
301 |
{
|
|
302 |
iFs.Connect();
|
|
303 |
iFileMan = CFileMan::NewL(iFs);
|
|
304 |
iFileMan->Delete(aFileName);
|
|
305 |
iFs.Close();
|
|
306 |
delete iFileMan;
|
|
307 |
iFileMan = NULL;
|
|
308 |
}
|
|
309 |
|
|
310 |
/**
|
|
311 |
*
|
|
312 |
* Test step Postamble.
|
|
313 |
*
|
|
314 |
* @xxxx
|
|
315 |
*
|
|
316 |
*/
|
|
317 |
enum TVerdict CTestStepRecorderPlayRecordPlay::DoTestStepPostambleL(void)
|
|
318 |
{
|
|
319 |
delete iPlayer;
|
|
320 |
iPlayer = NULL;
|
|
321 |
delete iRecorder;
|
|
322 |
iRecorder = NULL;
|
|
323 |
|
|
324 |
iFs.Connect();
|
|
325 |
iFileMan = CFileMan::NewL(iFs);
|
|
326 |
|
|
327 |
iFileMan->Delete(iFileNameWav);
|
|
328 |
iFileMan->Delete(iFileNameAu);
|
|
329 |
//iFileMan->Delete(iFileNameRaw);
|
|
330 |
|
|
331 |
iFs.Close();
|
|
332 |
delete iFileMan;
|
|
333 |
iFileMan = NULL;
|
|
334 |
|
|
335 |
//[ Destroy the scheduler ]
|
|
336 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
337 |
}
|
|
338 |
|
|
339 |
/**
|
|
340 |
*
|
|
341 |
* Callback Handle.
|
|
342 |
*
|
|
343 |
* @xxxx
|
|
344 |
*
|
|
345 |
*/
|
|
346 |
void CTestStepRecorderPlayRecordPlay::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
347 |
TInt /*aPreviousState*/,
|
|
348 |
TInt /*aCurrentState*/,
|
|
349 |
TInt aErrorcCode)
|
|
350 |
{
|
|
351 |
iError = aErrorcCode;
|
|
352 |
CActiveScheduler::Stop();
|
|
353 |
}
|
|
354 |
|
|
355 |
void CTestStepRecorderPlayRecordPlay::OpenAndStartSchedulerL(TPtrC aFileName)
|
|
356 |
{
|
|
357 |
iRecorder->OpenFileL( aFileName );
|
|
358 |
CActiveScheduler::Start();
|
|
359 |
}
|
|
360 |
|
|
361 |
|
|
362 |
void CTestStepRecorderPlayRecordPlay::RecordPlayRecordTestL(TPtrC aFileName)
|
|
363 |
{
|
|
364 |
TInt err = KErrNone;
|
|
365 |
|
|
366 |
INFO_PRINTF2(_L("Recording to file %S..."), &aFileName);
|
|
367 |
|
|
368 |
DeleteFileL(aFileName);
|
|
369 |
OpenAndStartSchedulerL(aFileName);
|
|
370 |
|
|
371 |
if (iRecorder == NULL ||
|
|
372 |
err != KErrNone ||
|
|
373 |
iError != KErrNone ||
|
|
374 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen )
|
|
375 |
{
|
|
376 |
iTestStepResult = EFail;
|
|
377 |
User::Leave(KErrGeneral);
|
|
378 |
}
|
|
379 |
iRecorder->SetPosition(TTimeIntervalMicroSeconds(0));
|
|
380 |
|
|
381 |
// record for 2 seconds,
|
|
382 |
iRecorder->RecordL();
|
|
383 |
User::After(1000000);
|
|
384 |
iRecorder->Stop();
|
|
385 |
CActiveScheduler::Start();
|
|
386 |
iRecorder->Close();
|
|
387 |
|
|
388 |
|
|
389 |
iPlayer->OpenFileL( aFileName );
|
|
390 |
CActiveScheduler::Start();
|
|
391 |
|
|
392 |
iPlayer->SetPosition(TTimeIntervalMicroSeconds(0));
|
|
393 |
iPlayer->Play();
|
|
394 |
CActiveScheduler::Start();
|
|
395 |
|
|
396 |
TTimeIntervalMicroSeconds durationPlay1;
|
|
397 |
durationPlay1 = iPlayer->Duration();
|
|
398 |
INFO_PRINTF2(_L("file play duration after first recording = %u"), durationPlay1.Int64());
|
|
399 |
|
|
400 |
|
|
401 |
// record another 2 seconds
|
|
402 |
OpenAndStartSchedulerL(aFileName);
|
|
403 |
if (iRecorder == NULL ||
|
|
404 |
err != KErrNone ||
|
|
405 |
iError != KErrNone ||
|
|
406 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen )
|
|
407 |
{
|
|
408 |
iTestStepResult = EFail;
|
|
409 |
User::Leave(KErrGeneral);
|
|
410 |
}
|
|
411 |
|
|
412 |
iRecorder->RecordL();
|
|
413 |
User::After(1000000);
|
|
414 |
iRecorder->Stop();
|
|
415 |
CActiveScheduler::Start();
|
|
416 |
iRecorder->Close();
|
|
417 |
|
|
418 |
|
|
419 |
// play the file again and get the new duration
|
|
420 |
iPlayer->SetPosition(TTimeIntervalMicroSeconds(0));
|
|
421 |
iPlayer->Play();
|
|
422 |
CActiveScheduler::Start();
|
|
423 |
|
|
424 |
TTimeIntervalMicroSeconds durationPlay2;
|
|
425 |
durationPlay2 = iPlayer->Duration();
|
|
426 |
INFO_PRINTF2(_L("file play duration after second recording = %u"), durationPlay2.Int64());
|
|
427 |
|
|
428 |
if (durationPlay2 <= durationPlay1)
|
|
429 |
{
|
|
430 |
INFO_PRINTF1(_L("Play duration not updated by record"));
|
|
431 |
iTestStepResult = EFail;
|
|
432 |
}
|
|
433 |
|
|
434 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
435 |
}
|
|
436 |
|
|
437 |
|
|
438 |
/**
|
|
439 |
*
|
|
440 |
* Do the test step.
|
|
441 |
* Each test step must supply an implementation for DoTestStepL.
|
|
442 |
*
|
|
443 |
* @return "TVerdict"
|
|
444 |
* The result of the test step
|
|
445 |
*
|
|
446 |
* @xxxx
|
|
447 |
*
|
|
448 |
*/
|
|
449 |
TVerdict CTestStepRecorderPlayRecordPlay::DoTestStepL()
|
|
450 |
{
|
|
451 |
iTestStepResult = EPass;
|
|
452 |
|
|
453 |
TInt err = KErrNone;
|
|
454 |
if (err == KErrNone)
|
|
455 |
TRAP(err, RecordPlayRecordTestL(iFileNameWav));
|
|
456 |
if (err != KErrNone)
|
|
457 |
iTestStepResult = EFail;
|
|
458 |
|
|
459 |
if (err == KErrNone)
|
|
460 |
TRAP(err, RecordPlayRecordTestL(iFileNameAu));
|
|
461 |
if (err != KErrNone)
|
|
462 |
iTestStepResult = EFail;
|
|
463 |
|
|
464 |
// test steps return a result
|
|
465 |
return iTestStepResult;
|
|
466 |
}
|
|
467 |
|
|
468 |
void CTestStepRecorderPlayRecordPlay::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
|
|
469 |
{
|
|
470 |
iError = aError;
|
|
471 |
CActiveScheduler::Stop();
|
|
472 |
}
|
|
473 |
|
|
474 |
void CTestStepRecorderPlayRecordPlay::MapcPlayComplete(TInt aError)
|
|
475 |
{
|
|
476 |
iError = aError;
|
|
477 |
CActiveScheduler::Stop();
|
|
478 |
}
|