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 |
|
|
30 |
// Test system includes
|
|
31 |
#include <testframework.h>
|
|
32 |
|
|
33 |
// Specific includes for this test suite
|
|
34 |
#include "TestStepUnitMMFAudClient.h"
|
|
35 |
#include "TestSuiteUnitMMFAudClient.h"
|
|
36 |
|
|
37 |
// Specific includes for these test steps
|
|
38 |
#include "TestStepAudInStream.h"
|
|
39 |
#include "mmfclientaudioinputstream.h"
|
|
40 |
#include <mda/common/audio.h>
|
|
41 |
|
|
42 |
//
|
|
43 |
// --------------------------------------------
|
|
44 |
//
|
|
45 |
// base class for some audio Input stream tests
|
|
46 |
//_LIT(KStreamRawFile,"c:\\mm\\mmf\\testfiles\\aclnt\\test.raw"); // EABI warning removal
|
|
47 |
//_LIT(KStreamIMADFile,"c:\\mm\\mmf\\testfiles\\aclnt\\test.raw"); // EABI warning removal
|
|
48 |
_LIT(KRecordStreamRawFile,"c:\\mm\\mmf\\testfiles\\aclnt\\streamrecorded.raw");
|
|
49 |
|
|
50 |
const TInt KMicroSecsInOneSec = 1000000;
|
|
51 |
//const TInt KBitsPerSample = 16; // EABI warning removal
|
|
52 |
const TInt KBytesPerSample = 2;
|
|
53 |
const TInt KSampleRate = 8000;
|
|
54 |
|
|
55 |
// constant table of parameters for tests
|
|
56 |
const TStreamInConvParameters KTestParameters[] =
|
|
57 |
{
|
|
58 |
// straight encode test
|
|
59 |
|
|
60 |
{ _S("MM-MMF-ACLNT-U-0740-CP"), KMMFFourCCCodePCMU8},
|
|
61 |
{ _S("MM-MMF-ACLNT-U-0741-CP"), KMMFFourCCCodePCM16},
|
|
62 |
{ _S("MM-MMF-ACLNT-U-0742-CP"), KMMFFourCCCodeALAW},
|
|
63 |
{ _S("MM-MMF-ACLNT-U-0743-CP"), KMMFFourCCCodeMuLAW},
|
|
64 |
{ _S("MM-MMF-ACLNT-U-0744-CP"), KMMFFourCCCodeIMAD},
|
|
65 |
{ _S("MM-MMF-ACLNT-U-0745-CP"), KMMFFourCCCodePCM16B},
|
|
66 |
{ _S("MM-MMF-ACLNT-U-0746-CP"), KMMFFourCCCodeGSM610}
|
|
67 |
};
|
|
68 |
|
|
69 |
CTestStepAudInStream* CTestStepAudInStream::NewL()
|
|
70 |
{
|
|
71 |
CTestStepAudInStream* s = new(ELeave) CTestStepAudInStream();
|
|
72 |
CleanupStack::PushL(s);
|
|
73 |
s->ConstructL();
|
|
74 |
CleanupStack::Pop();
|
|
75 |
return s;
|
|
76 |
}
|
|
77 |
|
|
78 |
CTestStepAudInStream::CTestStepAudInStream() : iError(KErrNone)
|
|
79 |
{
|
|
80 |
iTestStepName = _L("MM-MMF-ACLNT-U-0999-CP");
|
|
81 |
}
|
|
82 |
|
|
83 |
void CTestStepAudInStream::ConstructL()
|
|
84 |
{
|
|
85 |
// reset the buffer
|
|
86 |
for(TInt i=0; i<KRecNumBuffer; i++)
|
|
87 |
{
|
|
88 |
iBufferList[i] = KNullDesC8;
|
|
89 |
}
|
|
90 |
iStartBuf=iEndBuf=0;
|
|
91 |
}
|
|
92 |
|
|
93 |
CTestStepAudInStream::~CTestStepAudInStream()
|
|
94 |
{
|
|
95 |
}
|
|
96 |
|
|
97 |
void CTestStepAudInStream::MaiscOpenComplete(TInt aError)
|
|
98 |
{
|
|
99 |
iError = aError;
|
|
100 |
CActiveScheduler::Stop();
|
|
101 |
}
|
|
102 |
|
|
103 |
void CTestStepAudInStream::MaiscRecordComplete(TInt aError)
|
|
104 |
{
|
|
105 |
iError = aError;
|
|
106 |
|
|
107 |
iWriteBufferActive->Cancel();
|
|
108 |
TInt filePosition=0;
|
|
109 |
iFile.Seek(ESeekStart, filePosition);
|
|
110 |
iFile.Close();
|
|
111 |
CActiveScheduler::Stop();
|
|
112 |
}
|
|
113 |
|
|
114 |
void CTestStepAudInStream::MaiscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/)
|
|
115 |
{
|
|
116 |
iError = aError;
|
|
117 |
if(aError != KErrNone)
|
|
118 |
{
|
|
119 |
return;
|
|
120 |
}
|
|
121 |
// Assume aBuffer == iBufferList[iEndBuf]
|
|
122 |
|
|
123 |
// Increment iEndBuf
|
|
124 |
if(iEndBuf==KRecNumBuffer-1)
|
|
125 |
iEndBuf = 0;
|
|
126 |
else
|
|
127 |
iEndBuf++;
|
|
128 |
|
|
129 |
// Starting writing out the buffers if we're not already
|
|
130 |
if(!iWriteBufferActive->IsActive())
|
|
131 |
iWriteBufferActive->Write(iBufferList[iStartBuf]);
|
|
132 |
}
|
|
133 |
|
|
134 |
void CTestStepAudInStream::StartReadL()
|
|
135 |
{
|
|
136 |
// Issue reads on all available buffers
|
|
137 |
for (TInt ii=0; ii<KRecNumBuffer; ii++)
|
|
138 |
{
|
|
139 |
iAudInStream->ReadL(iBufferList[ii]);
|
|
140 |
}
|
|
141 |
}
|
|
142 |
|
|
143 |
CTestStepAudInStream::CWriteBufferActive::CWriteBufferActive() : CActive(0)
|
|
144 |
{
|
|
145 |
CActiveScheduler::Add(this);
|
|
146 |
}
|
|
147 |
|
|
148 |
CTestStepAudInStream::CWriteBufferActive::~CWriteBufferActive()
|
|
149 |
{
|
|
150 |
Cancel();
|
|
151 |
}
|
|
152 |
|
|
153 |
void CTestStepAudInStream::CWriteBufferActive::RunL()
|
|
154 |
{
|
|
155 |
//ASSERT it wrote OK
|
|
156 |
iParent->ProcessDataL();
|
|
157 |
}
|
|
158 |
|
|
159 |
void CTestStepAudInStream::CWriteBufferActive::DoCancel()
|
|
160 |
{
|
|
161 |
// do nothing
|
|
162 |
}
|
|
163 |
|
|
164 |
void CTestStepAudInStream::CWriteBufferActive::Write(const TDesC8& aBuffer)
|
|
165 |
{
|
|
166 |
iParent->iFile.Write(aBuffer, iStatus); // read the 1st data trunk
|
|
167 |
SetActive();
|
|
168 |
}
|
|
169 |
|
|
170 |
|
|
171 |
void CTestStepAudInStream::ProcessDataL()
|
|
172 |
{
|
|
173 |
// Set the next buffer to handle
|
|
174 |
iBufferList[iStartBuf] = KNullDesC8; // done with that one
|
|
175 |
// Issue another read to input stream
|
|
176 |
iAudInStream->ReadL(iBufferList[iStartBuf]);
|
|
177 |
|
|
178 |
// Increment iStartBuf
|
|
179 |
if(iStartBuf==KRecNumBuffer-1)
|
|
180 |
iStartBuf=0;
|
|
181 |
else
|
|
182 |
iStartBuf++;
|
|
183 |
|
|
184 |
if (iBufferList[iStartBuf] != KNullDesC8)
|
|
185 |
{
|
|
186 |
// Still more to write
|
|
187 |
iWriteBufferActive->Write(iBufferList[iStartBuf]);
|
|
188 |
}
|
|
189 |
// else just wait for more recorded data to come through
|
|
190 |
}
|
|
191 |
|
|
192 |
/**
|
|
193 |
*
|
|
194 |
* Test step Preamble.
|
|
195 |
*
|
|
196 |
* @xxxx
|
|
197 |
*
|
|
198 |
*/
|
|
199 |
enum TVerdict CTestStepAudInStream::DoTestStepPreambleL(void)
|
|
200 |
{
|
|
201 |
enum TVerdict verdict;
|
|
202 |
// this installs the scheduler
|
|
203 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
204 |
|
|
205 |
// create the active object
|
|
206 |
iWriteBufferActive = new(ELeave) CWriteBufferActive();
|
|
207 |
iWriteBufferActive->iParent = this;
|
|
208 |
iFs.Connect();
|
|
209 |
|
|
210 |
TRAPD(err, iAudInStream = CMMFMdaAudioInputStream::NewL(*this) );
|
|
211 |
|
|
212 |
|
|
213 |
if (err != KErrNone ||
|
|
214 |
iAudInStream == NULL )
|
|
215 |
return EInconclusive;
|
|
216 |
|
|
217 |
return verdict;
|
|
218 |
}
|
|
219 |
|
|
220 |
/**
|
|
221 |
*
|
|
222 |
* Test step Postamble.
|
|
223 |
*
|
|
224 |
* @xxxx
|
|
225 |
*
|
|
226 |
*/
|
|
227 |
enum TVerdict CTestStepAudInStream::DoTestStepPostambleL(void)
|
|
228 |
{
|
|
229 |
iFs.Close();
|
|
230 |
|
|
231 |
delete iAudInStream;
|
|
232 |
iAudInStream = NULL;
|
|
233 |
delete iWriteBufferActive;
|
|
234 |
//[ Destroy the scheduler ]
|
|
235 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
236 |
}
|
|
237 |
|
|
238 |
/**
|
|
239 |
*
|
|
240 |
* Do the test step.
|
|
241 |
* Each test step must supply an implementation for DoTestStepL.
|
|
242 |
*
|
|
243 |
* @return "TVerdict"
|
|
244 |
* The result of the test step
|
|
245 |
*
|
|
246 |
* @xxxx
|
|
247 |
*
|
|
248 |
*/
|
|
249 |
TVerdict CTestStepAudInStream::DoTestStepL()
|
|
250 |
{
|
|
251 |
iTestStepResult = EPass;
|
|
252 |
TInt err = KErrNone;
|
|
253 |
|
|
254 |
if (iError != KErrNone )
|
|
255 |
return EFail;
|
|
256 |
|
|
257 |
err = iFile.Replace( iFs, KRecordStreamRawFile, EFileWrite ) ;
|
|
258 |
if (err != KErrNone)
|
|
259 |
return EFail;
|
|
260 |
|
|
261 |
StartReadL();
|
|
262 |
CActiveScheduler::Start();
|
|
263 |
|
|
264 |
iFile.Close();
|
|
265 |
|
|
266 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
267 |
// test steps return a result
|
|
268 |
return iTestStepResult;
|
|
269 |
}
|
|
270 |
|
|
271 |
// --------------------------------------------
|
|
272 |
|
|
273 |
/**
|
|
274 |
*
|
|
275 |
* Static constructor for CTestStepAudInStreamNew.
|
|
276 |
*
|
|
277 |
*
|
|
278 |
* @return "CTestStepAudInStreamNew*"
|
|
279 |
* The constructed CTestStepAudInStreamNew
|
|
280 |
*
|
|
281 |
* @xxxx
|
|
282 |
*
|
|
283 |
*/
|
|
284 |
CTestStepAudInStreamNew* CTestStepAudInStreamNew::NewL()
|
|
285 |
{
|
|
286 |
CTestStepAudInStreamNew* self = new(ELeave) CTestStepAudInStreamNew;
|
|
287 |
return self;
|
|
288 |
}
|
|
289 |
|
|
290 |
/**
|
|
291 |
*
|
|
292 |
* Test step constructor.
|
|
293 |
* Each test step initialises its own name.
|
|
294 |
*
|
|
295 |
* @xxxx
|
|
296 |
*
|
|
297 |
*/
|
|
298 |
CTestStepAudInStreamNew::CTestStepAudInStreamNew()
|
|
299 |
{
|
|
300 |
iTestStepResult = EPass;
|
|
301 |
// store the name of this test case
|
|
302 |
// this is the name that is used by the script file
|
|
303 |
iTestStepName = _L("MM-MMF-ACLNT-U-0700-CP");
|
|
304 |
}
|
|
305 |
|
|
306 |
/**
|
|
307 |
*
|
|
308 |
* Test step destructor.
|
|
309 |
*
|
|
310 |
* @xxxx
|
|
311 |
*
|
|
312 |
*/
|
|
313 |
CTestStepAudInStreamNew::~CTestStepAudInStreamNew()
|
|
314 |
{
|
|
315 |
}
|
|
316 |
|
|
317 |
/**
|
|
318 |
* Implementation of the MMdaAudioOuputStreamCallback interface functions
|
|
319 |
**/
|
|
320 |
void CTestStepAudInStreamNew::MaiscOpenComplete(TInt /*aError*/)
|
|
321 |
{
|
|
322 |
}
|
|
323 |
void CTestStepAudInStreamNew::MaiscBufferCopied(TInt /*aError*/, const TDesC8& /*aBuffer*/)
|
|
324 |
{
|
|
325 |
}
|
|
326 |
void CTestStepAudInStreamNew::MaiscRecordComplete(TInt /*aError*/)
|
|
327 |
{
|
|
328 |
}
|
|
329 |
|
|
330 |
/**
|
|
331 |
*
|
|
332 |
* Test step Preamble.
|
|
333 |
*
|
|
334 |
* @xxxx
|
|
335 |
*
|
|
336 |
*/
|
|
337 |
enum TVerdict CTestStepAudInStreamNew::DoTestStepPreambleL(void)
|
|
338 |
{
|
|
339 |
enum TVerdict verdict;
|
|
340 |
// this installs the scheduler
|
|
341 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
342 |
return verdict;
|
|
343 |
}
|
|
344 |
|
|
345 |
/**
|
|
346 |
*
|
|
347 |
* Test step Postamble.
|
|
348 |
*
|
|
349 |
* @xxxx
|
|
350 |
*
|
|
351 |
*/
|
|
352 |
enum TVerdict CTestStepAudInStreamNew::DoTestStepPostambleL(void)
|
|
353 |
{
|
|
354 |
//[ Destroy the scheduler ]
|
|
355 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
356 |
}
|
|
357 |
|
|
358 |
/**
|
|
359 |
*
|
|
360 |
* Do the test step.
|
|
361 |
* Each test step must supply an implementation for DoTestStepL.
|
|
362 |
*
|
|
363 |
* @return "TVerdict"
|
|
364 |
* The result of the test step
|
|
365 |
*
|
|
366 |
* @xxxx
|
|
367 |
*
|
|
368 |
*/
|
|
369 |
TVerdict CTestStepAudInStreamNew::DoTestStepL()
|
|
370 |
{
|
|
371 |
__MM_HEAP_MARK;
|
|
372 |
// Printing to the console and log file
|
|
373 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0700-CP"));
|
|
374 |
INFO_PRINTF1(_L("this test is initialising an Audio Input Stream Utility Class"));
|
|
375 |
|
|
376 |
iAudInStream = CMMFMdaAudioInputStream::NewL(*this);
|
|
377 |
|
|
378 |
if ( iAudInStream == NULL )
|
|
379 |
iTestStepResult = EFail;
|
|
380 |
else
|
|
381 |
iTestStepResult = EPass;
|
|
382 |
|
|
383 |
delete iAudInStream;
|
|
384 |
iAudInStream = NULL;
|
|
385 |
__MM_HEAP_MARKEND;
|
|
386 |
|
|
387 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
388 |
// test steps return a result
|
|
389 |
return iTestStepResult;
|
|
390 |
}
|
|
391 |
|
|
392 |
//
|
|
393 |
// --------------------------------------------
|
|
394 |
//
|
|
395 |
/**
|
|
396 |
*
|
|
397 |
* Static constructor for CTestStepAudInStreamSetProp.
|
|
398 |
*
|
|
399 |
*
|
|
400 |
* @return "CTestStepAudInStreamSetProp*"
|
|
401 |
* The constructed CTestStepAudInStreamSetProp
|
|
402 |
*
|
|
403 |
* @xxxx
|
|
404 |
*
|
|
405 |
*/
|
|
406 |
CTestStepAudInStreamSetProp* CTestStepAudInStreamSetProp::NewL()
|
|
407 |
{
|
|
408 |
CTestStepAudInStreamSetProp* self = new(ELeave) CTestStepAudInStreamSetProp;
|
|
409 |
return self;
|
|
410 |
}
|
|
411 |
|
|
412 |
/**
|
|
413 |
*
|
|
414 |
* Test step constructor.
|
|
415 |
* Each test step initialises its own name.
|
|
416 |
*
|
|
417 |
* @xxxx
|
|
418 |
*
|
|
419 |
*/
|
|
420 |
CTestStepAudInStreamSetProp::CTestStepAudInStreamSetProp()
|
|
421 |
{
|
|
422 |
iTestStepResult = EPass;
|
|
423 |
// store the name of this test case
|
|
424 |
// this is the name that is used by the script file
|
|
425 |
iTestStepName = _L("MM-MMF-ACLNT-U-0701-CP");
|
|
426 |
}
|
|
427 |
|
|
428 |
/**
|
|
429 |
*
|
|
430 |
* Test step destructor.
|
|
431 |
*
|
|
432 |
* @xxxx
|
|
433 |
*
|
|
434 |
*/
|
|
435 |
CTestStepAudInStreamSetProp::~CTestStepAudInStreamSetProp()
|
|
436 |
{
|
|
437 |
}
|
|
438 |
|
|
439 |
/**
|
|
440 |
* Implementation of the MMdaAudioOuputStreamCallback interface functions
|
|
441 |
**/
|
|
442 |
void CTestStepAudInStreamSetProp::MaiscOpenComplete(TInt aError)
|
|
443 |
{
|
|
444 |
iError = aError;
|
|
445 |
CActiveScheduler::Stop();
|
|
446 |
}
|
|
447 |
void CTestStepAudInStreamSetProp::MaiscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/)
|
|
448 |
{
|
|
449 |
iError = aError;
|
|
450 |
}
|
|
451 |
void CTestStepAudInStreamSetProp::MaiscRecordComplete(TInt aError)
|
|
452 |
{
|
|
453 |
iError = aError;
|
|
454 |
}
|
|
455 |
|
|
456 |
/**
|
|
457 |
*
|
|
458 |
* Test step Preamble.
|
|
459 |
*
|
|
460 |
* @xxxx
|
|
461 |
*
|
|
462 |
*/
|
|
463 |
enum TVerdict CTestStepAudInStreamSetProp::DoTestStepPreambleL(void)
|
|
464 |
{
|
|
465 |
enum TVerdict verdict;
|
|
466 |
// this installs the scheduler
|
|
467 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
468 |
|
|
469 |
// Printing to the console and log file
|
|
470 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0701-CP"));
|
|
471 |
INFO_PRINTF1(_L("this test is setting the audio properties of an Audio Input Stream Utility Class"));
|
|
472 |
|
|
473 |
iAudInStream = CMMFMdaAudioInputStream::NewL(*this);
|
|
474 |
if (iAudInStream == NULL)
|
|
475 |
return EInconclusive;
|
|
476 |
|
|
477 |
iAudInStream->Open(NULL);
|
|
478 |
CActiveScheduler::Start();
|
|
479 |
|
|
480 |
return verdict;
|
|
481 |
}
|
|
482 |
|
|
483 |
/**
|
|
484 |
*
|
|
485 |
* Test step Postamble.
|
|
486 |
*
|
|
487 |
* @xxxx
|
|
488 |
*
|
|
489 |
*/
|
|
490 |
enum TVerdict CTestStepAudInStreamSetProp::DoTestStepPostambleL(void)
|
|
491 |
{
|
|
492 |
delete iAudInStream;
|
|
493 |
iAudInStream = NULL;
|
|
494 |
//CActiveScheduler::Stop();
|
|
495 |
//[ Destroy the scheduler ]
|
|
496 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
497 |
}
|
|
498 |
|
|
499 |
/**
|
|
500 |
*
|
|
501 |
* Do the test step.
|
|
502 |
* Each test step must supply an implementation for DoTestStepL.
|
|
503 |
*
|
|
504 |
* @return "TVerdict"
|
|
505 |
* The result of the test step
|
|
506 |
*
|
|
507 |
* @xxxx
|
|
508 |
*
|
|
509 |
*/
|
|
510 |
TVerdict CTestStepAudInStreamSetProp::DoTestStepL()
|
|
511 |
{
|
|
512 |
//TMdaAudioDataSettings settings;
|
|
513 |
// settings.Query();
|
|
514 |
// settings.iSampleRate = TMdaAudioDataSettings::ESampleRate8000Hz; // ESampleRateAnyInRange
|
|
515 |
// settings.iChannels = TMdaAudioDataSettings::EChannelsMono;
|
|
516 |
// settings.iFlags = TMdaAudioDataSettings::ENoNetworkRouting;
|
|
517 |
// settings.iVolume = 0;
|
|
518 |
|
|
519 |
|
|
520 |
|
|
521 |
iTestStepResult = EPass;
|
|
522 |
TInt err = KErrNone;
|
|
523 |
|
|
524 |
// test 1
|
|
525 |
TRAP(err, iAudInStream->SetAudioPropertiesL(TMdaAudioDataSettings::ESampleRate8000Hz,TMdaAudioDataSettings::EChannelsMono) );
|
|
526 |
|
|
527 |
if (!(err == KErrNone ||
|
|
528 |
err == KErrNotSupported) )
|
|
529 |
return EFail;
|
|
530 |
|
|
531 |
// test2
|
|
532 |
TRAP(err, iAudInStream->SetAudioPropertiesL(TMdaAudioDataSettings::ESampleRate44100Hz,TMdaAudioDataSettings::EChannelsStereo) );
|
|
533 |
|
|
534 |
if (!(err == KErrNone ||
|
|
535 |
err == KErrNotSupported) )
|
|
536 |
return EFail;
|
|
537 |
|
|
538 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
539 |
|
|
540 |
// test steps return a result
|
|
541 |
return iTestStepResult;
|
|
542 |
}
|
|
543 |
|
|
544 |
//
|
|
545 |
// --------------------------------------------
|
|
546 |
//
|
|
547 |
/**
|
|
548 |
*
|
|
549 |
* Static constructor for CTestStepAudInStreamOpen.
|
|
550 |
*
|
|
551 |
*
|
|
552 |
* @return "CTestStepAudInStreamOpen*"
|
|
553 |
* The constructed CTestStepAudInStreamOpen
|
|
554 |
*
|
|
555 |
* @xxxx
|
|
556 |
*
|
|
557 |
*/
|
|
558 |
CTestStepAudInStreamOpen* CTestStepAudInStreamOpen::NewL()
|
|
559 |
{
|
|
560 |
CTestStepAudInStreamOpen* self = new(ELeave) CTestStepAudInStreamOpen;
|
|
561 |
return self;
|
|
562 |
}
|
|
563 |
|
|
564 |
/**
|
|
565 |
*
|
|
566 |
* Test step constructor.
|
|
567 |
* Each test step initialises its own name.
|
|
568 |
*
|
|
569 |
* @xxxx
|
|
570 |
*
|
|
571 |
*/
|
|
572 |
CTestStepAudInStreamOpen::CTestStepAudInStreamOpen()
|
|
573 |
{
|
|
574 |
iTestStepResult = EPass;
|
|
575 |
// store the name of this test case
|
|
576 |
// this is the name that is used by the script file
|
|
577 |
iTestStepName = _L("MM-MMF-ACLNT-U-0702-CP");
|
|
578 |
}
|
|
579 |
|
|
580 |
/**
|
|
581 |
*
|
|
582 |
* Test step destructor.
|
|
583 |
*
|
|
584 |
* @xxxx
|
|
585 |
*
|
|
586 |
*/
|
|
587 |
CTestStepAudInStreamOpen::~CTestStepAudInStreamOpen()
|
|
588 |
{
|
|
589 |
}
|
|
590 |
|
|
591 |
/**
|
|
592 |
*
|
|
593 |
* Test step Preamble.
|
|
594 |
*
|
|
595 |
* @xxxx
|
|
596 |
*
|
|
597 |
*/
|
|
598 |
enum TVerdict CTestStepAudInStreamOpen::DoTestStepPreambleL(void)
|
|
599 |
{
|
|
600 |
enum TVerdict verdict;
|
|
601 |
// this installs the scheduler and NEWLs the CMMFMdaAudioInputStream
|
|
602 |
verdict = CTestStepAudInStream::DoTestStepPreambleL();
|
|
603 |
|
|
604 |
// Printing to the console and log file
|
|
605 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0702-CP"));
|
|
606 |
INFO_PRINTF1(_L("this test is openning an Audio Input Stream Utility Class"));
|
|
607 |
|
|
608 |
return verdict;
|
|
609 |
}
|
|
610 |
|
|
611 |
/**
|
|
612 |
*
|
|
613 |
* Test step Postamble.
|
|
614 |
*
|
|
615 |
* @xxxx
|
|
616 |
*
|
|
617 |
*/
|
|
618 |
enum TVerdict CTestStepAudInStreamOpen::DoTestStepPostambleL(void)
|
|
619 |
{
|
|
620 |
//[ Destroy the scheduler ]
|
|
621 |
return CTestStepAudInStream::DoTestStepPostambleL();
|
|
622 |
}
|
|
623 |
|
|
624 |
/**
|
|
625 |
*
|
|
626 |
* Do the test step.
|
|
627 |
* Each test step must supply an implementation for DoTestStepL.
|
|
628 |
*
|
|
629 |
* @return "TVerdict"
|
|
630 |
* The result of the test step
|
|
631 |
*
|
|
632 |
* @xxxx
|
|
633 |
*
|
|
634 |
*/
|
|
635 |
TVerdict CTestStepAudInStreamOpen::DoTestStepL()
|
|
636 |
{
|
|
637 |
TMdaAudioDataSettings settings;
|
|
638 |
settings.Query();
|
|
639 |
settings.iSampleRate = TMdaAudioDataSettings::ESampleRate8000Hz; // ESampleRateAnyInRange
|
|
640 |
settings.iChannels = TMdaAudioDataSettings::EChannelsStereo;
|
|
641 |
settings.iFlags = TMdaAudioDataSettings::ENoNetworkRouting;
|
|
642 |
settings.iVolume = 0;
|
|
643 |
|
|
644 |
//Test Open with audio settings
|
|
645 |
iAudInStream->Open(&settings);
|
|
646 |
CActiveScheduler::Start();
|
|
647 |
|
|
648 |
TBool stopped = EFalse;
|
|
649 |
TInt err = KErrNone;
|
|
650 |
err = GetAudInStreamStopped(iAudInStream, stopped);
|
|
651 |
|
|
652 |
if (iError != KErrNone || err != KErrNone || !stopped )
|
|
653 |
{
|
|
654 |
INFO_PRINTF1(_L("Open with audio settings failed"));
|
|
655 |
return EFail;
|
|
656 |
}
|
|
657 |
|
|
658 |
//Test Open with NULL
|
|
659 |
iAudInStream->Open(NULL);
|
|
660 |
CActiveScheduler::Start();
|
|
661 |
|
|
662 |
stopped = EFalse;
|
|
663 |
err = GetAudInStreamStopped(iAudInStream, stopped);
|
|
664 |
|
|
665 |
if (iError != KErrNone || err != KErrNone || !stopped )
|
|
666 |
{
|
|
667 |
INFO_PRINTF1(_L("Open without audio settings failed"));
|
|
668 |
return EFail;
|
|
669 |
}
|
|
670 |
else
|
|
671 |
{
|
|
672 |
return EPass;
|
|
673 |
}
|
|
674 |
}
|
|
675 |
|
|
676 |
//
|
|
677 |
// --------------------------------------------
|
|
678 |
//
|
|
679 |
/**
|
|
680 |
*
|
|
681 |
* Static constructor for CTestStepAudInStreamSetGain.
|
|
682 |
*
|
|
683 |
*
|
|
684 |
* @return "CTestStepAudInStreamSetGain*"
|
|
685 |
* The constructed CTestStepAudInStreamSetGain
|
|
686 |
*
|
|
687 |
* @xxxx
|
|
688 |
*
|
|
689 |
*/
|
|
690 |
CTestStepAudInStreamSetGain* CTestStepAudInStreamSetGain::NewL()
|
|
691 |
{
|
|
692 |
CTestStepAudInStreamSetGain* self = new(ELeave) CTestStepAudInStreamSetGain;
|
|
693 |
return self;
|
|
694 |
}
|
|
695 |
|
|
696 |
/**
|
|
697 |
*
|
|
698 |
* Test step constructor.
|
|
699 |
* Each test step initialises its own name.
|
|
700 |
*
|
|
701 |
* @xxxx
|
|
702 |
*
|
|
703 |
*/
|
|
704 |
CTestStepAudInStreamSetGain::CTestStepAudInStreamSetGain()
|
|
705 |
{
|
|
706 |
iTestStepResult = EPass;
|
|
707 |
// store the name of this test case
|
|
708 |
// this is the name that is used by the script file
|
|
709 |
iTestStepName = _L("MM-MMF-ACLNT-U-0703-CP");
|
|
710 |
}
|
|
711 |
|
|
712 |
/**
|
|
713 |
*
|
|
714 |
* Test step destructor.
|
|
715 |
*
|
|
716 |
* @xxxx
|
|
717 |
*
|
|
718 |
*/
|
|
719 |
CTestStepAudInStreamSetGain::~CTestStepAudInStreamSetGain()
|
|
720 |
{
|
|
721 |
}
|
|
722 |
|
|
723 |
/**
|
|
724 |
* Implementation of the MMdaAudioOuputStreamCallback interface functions
|
|
725 |
**/
|
|
726 |
void CTestStepAudInStreamSetGain::MaiscOpenComplete(TInt /*aError*/)
|
|
727 |
{
|
|
728 |
}
|
|
729 |
void CTestStepAudInStreamSetGain::MaiscBufferCopied(TInt /*aError*/, const TDesC8& /*aBuffer*/)
|
|
730 |
{
|
|
731 |
}
|
|
732 |
void CTestStepAudInStreamSetGain::MaiscRecordComplete(TInt /*aError*/)
|
|
733 |
{
|
|
734 |
}
|
|
735 |
|
|
736 |
/**
|
|
737 |
*
|
|
738 |
* Test step Preamble.
|
|
739 |
*
|
|
740 |
* @xxxx
|
|
741 |
*
|
|
742 |
*/
|
|
743 |
enum TVerdict CTestStepAudInStreamSetGain::DoTestStepPreambleL(void)
|
|
744 |
{
|
|
745 |
enum TVerdict verdict;
|
|
746 |
// this installs the scheduler
|
|
747 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
748 |
// Printing to the console and log file
|
|
749 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0703-CP"));
|
|
750 |
INFO_PRINTF1(_L("this test is setting/getting the Gain of an Audio Input Stream Utility Class"));
|
|
751 |
|
|
752 |
iAudInStream = CMMFMdaAudioInputStream::NewL(*this);
|
|
753 |
|
|
754 |
return verdict;
|
|
755 |
}
|
|
756 |
|
|
757 |
/**
|
|
758 |
*
|
|
759 |
* Test step Postamble.
|
|
760 |
*
|
|
761 |
* @xxxx
|
|
762 |
*
|
|
763 |
*/
|
|
764 |
enum TVerdict CTestStepAudInStreamSetGain::DoTestStepPostambleL(void)
|
|
765 |
{
|
|
766 |
delete iAudInStream;
|
|
767 |
iAudInStream = NULL;
|
|
768 |
//[ Destroy the scheduler ]
|
|
769 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
770 |
}
|
|
771 |
|
|
772 |
/**
|
|
773 |
*
|
|
774 |
* Do the test step.
|
|
775 |
* Each test step must supply an implementation for DoTestStepL.
|
|
776 |
*
|
|
777 |
* @return "TVerdict"
|
|
778 |
* The result of the test step
|
|
779 |
*
|
|
780 |
* @xxxx
|
|
781 |
*
|
|
782 |
*/
|
|
783 |
TVerdict CTestStepAudInStreamSetGain::DoTestStepL()
|
|
784 |
{
|
|
785 |
TInt gain = iAudInStream->MaxGain()/2;
|
|
786 |
if (gain < 0)
|
|
787 |
return EFail;
|
|
788 |
//set the volume
|
|
789 |
iAudInStream->SetGain(gain);
|
|
790 |
|
|
791 |
//get the volume
|
|
792 |
TInt rgain = iAudInStream->Gain();
|
|
793 |
if (gain != rgain )
|
|
794 |
return EFail;
|
|
795 |
|
|
796 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
797 |
// test steps return a result
|
|
798 |
return iTestStepResult;
|
|
799 |
}
|
|
800 |
|
|
801 |
//
|
|
802 |
// --------------------------------------------
|
|
803 |
//
|
|
804 |
/**
|
|
805 |
*
|
|
806 |
* Static constructor for CTestStepAudInStreamSetPrior.
|
|
807 |
*
|
|
808 |
*
|
|
809 |
* @return "CTestStepAudInStreamSetPrior*"
|
|
810 |
* The constructed CTestStepAudInStreamSetPrior
|
|
811 |
*
|
|
812 |
* @xxxx
|
|
813 |
*
|
|
814 |
*/
|
|
815 |
CTestStepAudInStreamSetPrior* CTestStepAudInStreamSetPrior::NewL()
|
|
816 |
{
|
|
817 |
CTestStepAudInStreamSetPrior* self = new(ELeave) CTestStepAudInStreamSetPrior;
|
|
818 |
return self;
|
|
819 |
}
|
|
820 |
|
|
821 |
/**
|
|
822 |
*
|
|
823 |
* Test step constructor.
|
|
824 |
* Each test step initialises its own name.
|
|
825 |
*
|
|
826 |
* @xxxx
|
|
827 |
*
|
|
828 |
*/
|
|
829 |
CTestStepAudInStreamSetPrior::CTestStepAudInStreamSetPrior()
|
|
830 |
{
|
|
831 |
iTestStepResult = EPass;
|
|
832 |
// store the name of this test case
|
|
833 |
// this is the name that is used by the script file
|
|
834 |
iTestStepName = _L("MM-MMF-ACLNT-U-0708-HP");
|
|
835 |
}
|
|
836 |
|
|
837 |
/**
|
|
838 |
*
|
|
839 |
* Test step destructor.
|
|
840 |
*
|
|
841 |
* @xxxx
|
|
842 |
*
|
|
843 |
*/
|
|
844 |
CTestStepAudInStreamSetPrior::~CTestStepAudInStreamSetPrior()
|
|
845 |
{
|
|
846 |
}
|
|
847 |
|
|
848 |
/**
|
|
849 |
* Implementation of the MMdaAudioOuputStreamCallback interface functions
|
|
850 |
**/
|
|
851 |
void CTestStepAudInStreamSetPrior::MaiscOpenComplete(TInt /*aError*/)
|
|
852 |
{
|
|
853 |
}
|
|
854 |
void CTestStepAudInStreamSetPrior::MaiscBufferCopied(TInt /*aError*/, const TDesC8& /*aBuffer*/)
|
|
855 |
{
|
|
856 |
}
|
|
857 |
void CTestStepAudInStreamSetPrior::MaiscRecordComplete(TInt /*aError*/)
|
|
858 |
{
|
|
859 |
}
|
|
860 |
|
|
861 |
/**
|
|
862 |
*
|
|
863 |
* Test step Preamble.
|
|
864 |
*
|
|
865 |
* @xxxx
|
|
866 |
*
|
|
867 |
*/
|
|
868 |
enum TVerdict CTestStepAudInStreamSetPrior::DoTestStepPreambleL(void)
|
|
869 |
{
|
|
870 |
enum TVerdict verdict;
|
|
871 |
// this installs the scheduler
|
|
872 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
873 |
|
|
874 |
// Printing to the console and log file
|
|
875 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0708-HP"));
|
|
876 |
INFO_PRINTF1(_L("this test is setting the audio priorities of an Audio Input Stream Utility Class"));
|
|
877 |
|
|
878 |
iAudInStream = CMMFMdaAudioInputStream::NewL(*this);
|
|
879 |
|
|
880 |
return verdict;
|
|
881 |
}
|
|
882 |
|
|
883 |
/**
|
|
884 |
*
|
|
885 |
* Test step Postamble.
|
|
886 |
*
|
|
887 |
* @xxxx
|
|
888 |
*
|
|
889 |
*/
|
|
890 |
enum TVerdict CTestStepAudInStreamSetPrior::DoTestStepPostambleL(void)
|
|
891 |
{
|
|
892 |
delete iAudInStream;
|
|
893 |
iAudInStream = NULL;
|
|
894 |
|
|
895 |
//[ Destroy the scheduler ]
|
|
896 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
897 |
}
|
|
898 |
|
|
899 |
/**
|
|
900 |
*
|
|
901 |
* Do the test step.
|
|
902 |
* Each test step must supply an implementation for DoTestStepL.
|
|
903 |
*
|
|
904 |
* @return "TVerdict"
|
|
905 |
* The result of the test step
|
|
906 |
*
|
|
907 |
* @xxxx
|
|
908 |
*
|
|
909 |
*/
|
|
910 |
TVerdict CTestStepAudInStreamSetPrior::DoTestStepL()
|
|
911 |
{
|
|
912 |
// TInt err = KErrNone;
|
|
913 |
|
|
914 |
// test 1
|
|
915 |
iAudInStream->SetPriority(EMdaPriorityMin, EMdaPriorityPreferenceTime);
|
|
916 |
|
|
917 |
/* TMMFPrioritySettings prior;
|
|
918 |
err = GetAudInStreamPrioritySettings(iAudInStream, prior);
|
|
919 |
if ( err != KErrNone ||
|
|
920 |
prior.iPriority != EMdaPriorityMin ||
|
|
921 |
prior.iPref != EMdaPriorityPreferenceTime)
|
|
922 |
return EFail;
|
|
923 |
*/
|
|
924 |
// test2
|
|
925 |
iAudInStream->SetPriority(EMdaPriorityMax, EMdaPriorityPreferenceQuality);
|
|
926 |
|
|
927 |
/* err = GetAudInStreamPrioritySettings(iAudInStream, prior);
|
|
928 |
if ( err != KErrNone ||
|
|
929 |
prior.iPriority != EMdaPriorityMax ||
|
|
930 |
prior.iPref != EMdaPriorityPreferenceQuality)
|
|
931 |
return EFail;
|
|
932 |
*/
|
|
933 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
934 |
// test steps return a result
|
|
935 |
return iTestStepResult;
|
|
936 |
}
|
|
937 |
|
|
938 |
//
|
|
939 |
// --------------------------------------------
|
|
940 |
//
|
|
941 |
/**
|
|
942 |
*
|
|
943 |
* Static constructor for CTestStepAudInStreamSetBalance.
|
|
944 |
*
|
|
945 |
*
|
|
946 |
* @return "CTestStepAudInStreamSetBalance*"
|
|
947 |
* The constructed CTestStepAudInStreamSetBalance
|
|
948 |
*
|
|
949 |
* @xxxx
|
|
950 |
*
|
|
951 |
*/
|
|
952 |
CTestStepAudInStreamSetBalance* CTestStepAudInStreamSetBalance::NewL()
|
|
953 |
{
|
|
954 |
CTestStepAudInStreamSetBalance* self = new(ELeave) CTestStepAudInStreamSetBalance;
|
|
955 |
return self;
|
|
956 |
}
|
|
957 |
|
|
958 |
/**
|
|
959 |
*
|
|
960 |
* Test step constructor.
|
|
961 |
* Each test step initialises its own name.
|
|
962 |
*
|
|
963 |
* @xxxx
|
|
964 |
*
|
|
965 |
*/
|
|
966 |
CTestStepAudInStreamSetBalance::CTestStepAudInStreamSetBalance()
|
|
967 |
{
|
|
968 |
iTestStepResult = EPass;
|
|
969 |
// store the name of this test case
|
|
970 |
// this is the name that is used by the script file
|
|
971 |
iTestStepName = _L("MM-MMF-ACLNT-U-0706-HP");
|
|
972 |
}
|
|
973 |
|
|
974 |
/**
|
|
975 |
*
|
|
976 |
* Test step destructor.
|
|
977 |
*
|
|
978 |
* @xxxx
|
|
979 |
*
|
|
980 |
*/
|
|
981 |
CTestStepAudInStreamSetBalance::~CTestStepAudInStreamSetBalance()
|
|
982 |
{
|
|
983 |
}
|
|
984 |
|
|
985 |
/**
|
|
986 |
* Implementation of the MMdaAudioOuputStreamCallback interface functions
|
|
987 |
**/
|
|
988 |
void CTestStepAudInStreamSetBalance::MaiscOpenComplete(TInt /*aError*/)
|
|
989 |
{
|
|
990 |
}
|
|
991 |
void CTestStepAudInStreamSetBalance::MaiscBufferCopied(TInt /*aError*/, const TDesC8& /*aBuffer*/)
|
|
992 |
{
|
|
993 |
}
|
|
994 |
void CTestStepAudInStreamSetBalance::MaiscRecordComplete(TInt /*aError*/)
|
|
995 |
{
|
|
996 |
}
|
|
997 |
|
|
998 |
/**
|
|
999 |
*
|
|
1000 |
* Test step Preamble.
|
|
1001 |
*
|
|
1002 |
* @xxxx
|
|
1003 |
*
|
|
1004 |
*/
|
|
1005 |
enum TVerdict CTestStepAudInStreamSetBalance::DoTestStepPreambleL(void)
|
|
1006 |
{
|
|
1007 |
enum TVerdict verdict;
|
|
1008 |
// this installs the scheduler
|
|
1009 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
1010 |
|
|
1011 |
TInt err = KErrNone;
|
|
1012 |
// Printing to the console and log file
|
|
1013 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0706-HP"));
|
|
1014 |
INFO_PRINTF1(_L("this test is setting and getting the balance of an Audio Input Stream Utility Class"));
|
|
1015 |
|
|
1016 |
TRAP(err, iAudInStream = CMMFMdaAudioInputStream::NewL(*this) );
|
|
1017 |
|
|
1018 |
if (err != KErrNone ||
|
|
1019 |
iAudInStream == NULL )
|
|
1020 |
return EInconclusive;
|
|
1021 |
|
|
1022 |
return verdict;
|
|
1023 |
}
|
|
1024 |
|
|
1025 |
/**
|
|
1026 |
*
|
|
1027 |
* Test step Postamble.
|
|
1028 |
*
|
|
1029 |
* @xxxx
|
|
1030 |
*
|
|
1031 |
*/
|
|
1032 |
enum TVerdict CTestStepAudInStreamSetBalance::DoTestStepPostambleL(void)
|
|
1033 |
{
|
|
1034 |
delete iAudInStream;
|
|
1035 |
iAudInStream = NULL;
|
|
1036 |
|
|
1037 |
//[ Destroy the scheduler ]
|
|
1038 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
1039 |
}
|
|
1040 |
|
|
1041 |
/**
|
|
1042 |
*
|
|
1043 |
* Do the test step.
|
|
1044 |
* Each test step must supply an implementation for DoTestStepL.
|
|
1045 |
*
|
|
1046 |
* @return "TVerdict"
|
|
1047 |
* The result of the test step
|
|
1048 |
*
|
|
1049 |
* @xxxx
|
|
1050 |
*
|
|
1051 |
*/
|
|
1052 |
TVerdict CTestStepAudInStreamSetBalance::DoTestStepL()
|
|
1053 |
{
|
|
1054 |
TInt bal = 0;
|
|
1055 |
|
|
1056 |
TRAPD(err, iAudInStream->SetBalanceL()); // default KMMFBalanceCenter
|
|
1057 |
if (err != KErrNone)
|
|
1058 |
return EFail; // we expect this _will_ be supported for Typhoon
|
|
1059 |
|
|
1060 |
//get the balance
|
|
1061 |
TRAP(err, bal = iAudInStream->GetBalanceL());
|
|
1062 |
if (err != KErrNone)
|
|
1063 |
return EFail; // we expect this _will_ be supported for Typhoon
|
|
1064 |
|
|
1065 |
if (bal != KMMFBalanceCenter )
|
|
1066 |
return EFail;
|
|
1067 |
|
|
1068 |
TRAP(err, iAudInStream->SetBalanceL(KMMFBalanceMaxRight));
|
|
1069 |
if (err != KErrNone)
|
|
1070 |
return EFail; // we expect this _will_ be supported for Typhoon
|
|
1071 |
|
|
1072 |
//get the balance
|
|
1073 |
TRAP(err, bal = iAudInStream->GetBalanceL());
|
|
1074 |
if (err != KErrNone)
|
|
1075 |
return EFail; // we expect this _will_ be supported for Typhoon
|
|
1076 |
|
|
1077 |
if (bal != KMMFBalanceMaxRight )
|
|
1078 |
return EFail;
|
|
1079 |
|
|
1080 |
TRAP(err, iAudInStream->SetBalanceL(KMMFBalanceMaxLeft));
|
|
1081 |
if (err != KErrNone)
|
|
1082 |
return EFail; // we expect this _will_ be supported for Typhoon
|
|
1083 |
|
|
1084 |
//get the balance
|
|
1085 |
TRAP(err, bal = iAudInStream->GetBalanceL());
|
|
1086 |
if (err != KErrNone)
|
|
1087 |
return EFail; // we expect this _will_ be supported for Typhoon
|
|
1088 |
|
|
1089 |
if (bal != KMMFBalanceMaxLeft )
|
|
1090 |
return EFail;
|
|
1091 |
|
|
1092 |
// In of bounds
|
|
1093 |
/*
|
|
1094 |
iAudInStream->SetBalance(KMMFBalanceMaxLeft+10);
|
|
1095 |
//check condition
|
|
1096 |
*/
|
|
1097 |
|
|
1098 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
1099 |
// test steps return a result
|
|
1100 |
return iTestStepResult;
|
|
1101 |
}
|
|
1102 |
|
|
1103 |
//
|
|
1104 |
// --------------------------------------------
|
|
1105 |
//
|
|
1106 |
/**
|
|
1107 |
*
|
|
1108 |
* Static constructor for CTestStepAudInStreamRead.
|
|
1109 |
*
|
|
1110 |
*
|
|
1111 |
* @return "CTestStepAudInStreamRead*"
|
|
1112 |
* The constructed CTestStepAudInStreamRead
|
|
1113 |
*
|
|
1114 |
* @xxxx
|
|
1115 |
*
|
|
1116 |
*/
|
|
1117 |
CTestStepAudInStreamRead* CTestStepAudInStreamRead::NewL(TUint aTestIndex)
|
|
1118 |
{
|
|
1119 |
CTestStepAudInStreamRead* self = new(ELeave) CTestStepAudInStreamRead(aTestIndex);
|
|
1120 |
return self;
|
|
1121 |
}
|
|
1122 |
|
|
1123 |
/**
|
|
1124 |
*
|
|
1125 |
* Test step constructor.
|
|
1126 |
* Each test step initialises its own name.
|
|
1127 |
*
|
|
1128 |
* @xxxx
|
|
1129 |
*
|
|
1130 |
*/
|
|
1131 |
CTestStepAudInStreamRead::CTestStepAudInStreamRead(TUint aTestIndex)
|
|
1132 |
{
|
|
1133 |
iTestStepResult = EPass;
|
|
1134 |
// store a pointer to the test parameters
|
|
1135 |
iTestParameters = &(KTestParameters[aTestIndex]);
|
|
1136 |
// store the name of this test case
|
|
1137 |
// this is the name that is used by the script file
|
|
1138 |
iTestStepName = iTestParameters->iTestName;
|
|
1139 |
iHeapSize = 131072; // ~128k
|
|
1140 |
}
|
|
1141 |
|
|
1142 |
/**
|
|
1143 |
*
|
|
1144 |
* Test step destructor.
|
|
1145 |
*
|
|
1146 |
* @xxxx
|
|
1147 |
*
|
|
1148 |
*/
|
|
1149 |
CTestStepAudInStreamRead::~CTestStepAudInStreamRead()
|
|
1150 |
{
|
|
1151 |
}
|
|
1152 |
|
|
1153 |
/**
|
|
1154 |
*
|
|
1155 |
* Test step Preamble.
|
|
1156 |
*
|
|
1157 |
* @xxxx
|
|
1158 |
*
|
|
1159 |
*/
|
|
1160 |
enum TVerdict CTestStepAudInStreamRead::DoTestStepPreambleL(void)
|
|
1161 |
{
|
|
1162 |
enum TVerdict verdict;
|
|
1163 |
// this installs the scheduler, and NEWLs the input stream object
|
|
1164 |
verdict = CTestStepAudInStream::DoTestStepPreambleL();
|
|
1165 |
|
|
1166 |
// Printing to the console and log file
|
|
1167 |
INFO_PRINTF1(_L("this test is reading data from an Audio Input Stream Utility Class. ReadL()"));
|
|
1168 |
|
|
1169 |
TInt err = KErrNone;
|
|
1170 |
TRAP(err, iAudInStream->SetDataTypeL(iTestParameters->iEncoding));
|
|
1171 |
|
|
1172 |
if (err != KErrNone)
|
|
1173 |
return EInconclusive;
|
|
1174 |
|
|
1175 |
iAudInStream->Open(NULL);
|
|
1176 |
|
|
1177 |
CActiveScheduler::Start();
|
|
1178 |
|
|
1179 |
if (iError != KErrNone)
|
|
1180 |
return EInconclusive;
|
|
1181 |
|
|
1182 |
err = iFile.Replace( iFs, KRecordStreamRawFile, EFileWrite ) ;
|
|
1183 |
if (err != KErrNone)
|
|
1184 |
return EInconclusive;
|
|
1185 |
|
|
1186 |
return verdict;
|
|
1187 |
}
|
|
1188 |
|
|
1189 |
/**
|
|
1190 |
*
|
|
1191 |
* Test step Postamble.
|
|
1192 |
*
|
|
1193 |
* @xxxx
|
|
1194 |
*
|
|
1195 |
*/
|
|
1196 |
enum TVerdict CTestStepAudInStreamRead::DoTestStepPostambleL(void)
|
|
1197 |
{
|
|
1198 |
iFile.Close();
|
|
1199 |
//[ Destroy the scheduler ]
|
|
1200 |
return CTestStepAudInStream::DoTestStepPostambleL();
|
|
1201 |
}
|
|
1202 |
|
|
1203 |
LOCAL_C TInt stopActiveScheduler(TAny*)
|
|
1204 |
{
|
|
1205 |
CActiveScheduler::Stop();
|
|
1206 |
return FALSE;
|
|
1207 |
}
|
|
1208 |
/**
|
|
1209 |
*
|
|
1210 |
* Do the test step.
|
|
1211 |
* Each test step must supply an implementation for DoTestStepL.
|
|
1212 |
*
|
|
1213 |
* @return "TVerdict"
|
|
1214 |
* The result of the test step
|
|
1215 |
*
|
|
1216 |
* @xxxx
|
|
1217 |
*
|
|
1218 |
*/
|
|
1219 |
TVerdict CTestStepAudInStreamRead::DoTestStepL()
|
|
1220 |
{
|
|
1221 |
StartReadL();
|
|
1222 |
|
|
1223 |
CCallBackTimer* timer = CCallBackTimer::NewL(TCallBack(stopActiveScheduler));
|
|
1224 |
timer->After(5000000); // 5s
|
|
1225 |
CActiveScheduler::Start();
|
|
1226 |
delete timer;
|
|
1227 |
if (iError != KErrNone)
|
|
1228 |
{
|
|
1229 |
INFO_PRINTF2(_L("Test failed (iError=%d)"), iError);
|
|
1230 |
return EFail;
|
|
1231 |
}
|
|
1232 |
|
|
1233 |
iAudInStream->Stop();
|
|
1234 |
// Now playback what we've recorded
|
|
1235 |
|
|
1236 |
CMdaAudioOutputStream* outputStream = CMdaAudioOutputStream::NewL(*this);
|
|
1237 |
CleanupStack::PushL(outputStream);
|
|
1238 |
TRAPD(err, outputStream->SetDataTypeL(iTestParameters->iEncoding));
|
|
1239 |
|
|
1240 |
if (err != KErrNone)
|
|
1241 |
{
|
|
1242 |
CleanupStack::PopAndDestroy(1, outputStream);
|
|
1243 |
return EInconclusive;
|
|
1244 |
}
|
|
1245 |
outputStream->Open(NULL);
|
|
1246 |
outputStream->SetVolume(outputStream->MaxVolume());
|
|
1247 |
|
|
1248 |
CActiveScheduler::Start(); // wait for open to complete
|
|
1249 |
TInt size = 0;
|
|
1250 |
|
|
1251 |
User::LeaveIfError(iFile.Size(size));
|
|
1252 |
|
|
1253 |
// Read the entire file into a buffer - bit naughty but OK for test code
|
|
1254 |
INFO_PRINTF2(_L("HBufC8:NewLC(size): size=%d"), size);
|
|
1255 |
HBufC8* buffer = HBufC8::NewLC(size);
|
|
1256 |
|
|
1257 |
INFO_PRINTF1(_L("Buffer created"));
|
|
1258 |
|
|
1259 |
TInt pos = 0;
|
|
1260 |
User::LeaveIfError(iFile.Seek(ESeekStart, pos));
|
|
1261 |
TPtr8 bufPtr = buffer->Des();
|
|
1262 |
User::LeaveIfError(iFile.Read(bufPtr, size));
|
|
1263 |
outputStream->WriteL(bufPtr);
|
|
1264 |
iIsPlaying = ETrue;
|
|
1265 |
CActiveScheduler::Start(); // wait for the play to complete
|
|
1266 |
CleanupStack::PopAndDestroy(2); // buffer, outputStream
|
|
1267 |
if (iError != KErrNone && iError != KErrUnderflow)
|
|
1268 |
return EInconclusive; // There may be a problem with the output stream rather than the input stream
|
|
1269 |
|
|
1270 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
1271 |
// test steps return a result
|
|
1272 |
return iTestStepResult;
|
|
1273 |
}
|
|
1274 |
|
|
1275 |
void CTestStepAudInStreamRead::MaoscOpenComplete(TInt aError)
|
|
1276 |
{
|
|
1277 |
iError = aError;
|
|
1278 |
CActiveScheduler::Stop();
|
|
1279 |
}
|
|
1280 |
|
|
1281 |
void CTestStepAudInStreamRead::MaoscBufferCopied(TInt /*aError*/, const TDesC8& /*aBuffer*/)
|
|
1282 |
{
|
|
1283 |
// Don't care
|
|
1284 |
}
|
|
1285 |
|
|
1286 |
void CTestStepAudInStreamRead::MaoscPlayComplete(TInt aError)
|
|
1287 |
{
|
|
1288 |
iError = aError;
|
|
1289 |
if (iIsPlaying)
|
|
1290 |
{
|
|
1291 |
CActiveScheduler::Stop();
|
|
1292 |
iIsPlaying = EFalse;
|
|
1293 |
}
|
|
1294 |
}
|
|
1295 |
|
|
1296 |
void CTestStepAudInStreamRead::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
|
|
1297 |
{
|
|
1298 |
iError = aError;
|
|
1299 |
CActiveScheduler::Stop();
|
|
1300 |
}
|
|
1301 |
|
|
1302 |
void CTestStepAudInStreamRead::MapcPlayComplete(TInt aError)
|
|
1303 |
{
|
|
1304 |
iError = aError;
|
|
1305 |
CActiveScheduler::Stop();
|
|
1306 |
}
|
|
1307 |
|
|
1308 |
//
|
|
1309 |
// --------------------------------------------
|
|
1310 |
//
|
|
1311 |
/**
|
|
1312 |
*
|
|
1313 |
* Static constructor for CTestStepAudInStreamStop.
|
|
1314 |
*
|
|
1315 |
*
|
|
1316 |
* @return "CTestStepAudInStreamStop*"
|
|
1317 |
* The constructed CTestStepAudInStreamStop
|
|
1318 |
*
|
|
1319 |
* @xxxx
|
|
1320 |
*
|
|
1321 |
*/
|
|
1322 |
CTestStepAudInStreamStop* CTestStepAudInStreamStop::NewL()
|
|
1323 |
{
|
|
1324 |
CTestStepAudInStreamStop* self = new(ELeave) CTestStepAudInStreamStop;
|
|
1325 |
return self;
|
|
1326 |
}
|
|
1327 |
|
|
1328 |
/**
|
|
1329 |
*
|
|
1330 |
* Test step constructor.
|
|
1331 |
* Each test step initialises its own name.
|
|
1332 |
*
|
|
1333 |
* @xxxx
|
|
1334 |
*
|
|
1335 |
*/
|
|
1336 |
CTestStepAudInStreamStop::CTestStepAudInStreamStop()
|
|
1337 |
{
|
|
1338 |
iTestStepResult = EPass;
|
|
1339 |
// store the name of this test case
|
|
1340 |
// this is the name that is used by the script file
|
|
1341 |
iTestStepName = _L("MM-MMF-ACLNT-U-0710-CP");
|
|
1342 |
}
|
|
1343 |
|
|
1344 |
/**
|
|
1345 |
*
|
|
1346 |
* Test step destructor.
|
|
1347 |
*
|
|
1348 |
* @xxxx
|
|
1349 |
*
|
|
1350 |
*/
|
|
1351 |
CTestStepAudInStreamStop::~CTestStepAudInStreamStop()
|
|
1352 |
{
|
|
1353 |
}
|
|
1354 |
|
|
1355 |
/**
|
|
1356 |
*
|
|
1357 |
* Test step Preamble.
|
|
1358 |
*
|
|
1359 |
* @xxxx
|
|
1360 |
*
|
|
1361 |
*/
|
|
1362 |
enum TVerdict CTestStepAudInStreamStop::DoTestStepPreambleL(void)
|
|
1363 |
{
|
|
1364 |
iTestStepResult = EPass;
|
|
1365 |
enum TVerdict verdict;
|
|
1366 |
// this installs the scheduler, and NEWLs the input stream object
|
|
1367 |
verdict = CTestStepAudInStream::DoTestStepPreambleL();
|
|
1368 |
|
|
1369 |
// Printing to the console and log file
|
|
1370 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0710-CP"));
|
|
1371 |
INFO_PRINTF1(_L("this test is stopping a playing Audio Input Stream Utility Class: Stop()"));
|
|
1372 |
|
|
1373 |
iAudInStream->Open(NULL);
|
|
1374 |
CActiveScheduler::Start();
|
|
1375 |
|
|
1376 |
if (iError != KErrNone)
|
|
1377 |
return EInconclusive;
|
|
1378 |
|
|
1379 |
TInt err = KErrNone;
|
|
1380 |
err = iFile.Replace( iFs, KRecordStreamRawFile, EFileWrite ) ;
|
|
1381 |
if (err != KErrNone)
|
|
1382 |
return EInconclusive;
|
|
1383 |
|
|
1384 |
// start feeding the input stream
|
|
1385 |
StartReadL();
|
|
1386 |
CCallBackTimer* timer = CCallBackTimer::NewL(TCallBack(stopActiveScheduler, iAudInStream));
|
|
1387 |
timer->After(1000000); // 1s
|
|
1388 |
CActiveScheduler::Start();
|
|
1389 |
delete timer;
|
|
1390 |
if (iError != KErrNone)
|
|
1391 |
return EInconclusive;
|
|
1392 |
|
|
1393 |
return verdict;
|
|
1394 |
}
|
|
1395 |
|
|
1396 |
/**
|
|
1397 |
*
|
|
1398 |
* Test step Postamble.
|
|
1399 |
*
|
|
1400 |
* @xxxx
|
|
1401 |
*
|
|
1402 |
*/
|
|
1403 |
enum TVerdict CTestStepAudInStreamStop::DoTestStepPostambleL(void)
|
|
1404 |
{
|
|
1405 |
iFile.Close();
|
|
1406 |
//[ Destroy the scheduler ]
|
|
1407 |
return CTestStepAudInStream::DoTestStepPostambleL();
|
|
1408 |
}
|
|
1409 |
|
|
1410 |
/**
|
|
1411 |
*
|
|
1412 |
* Do the test step.
|
|
1413 |
* Each test step must supply an implementation for DoTestStepL.
|
|
1414 |
*
|
|
1415 |
* @return "TVerdict"
|
|
1416 |
* The result of the test step
|
|
1417 |
*
|
|
1418 |
* @xxxx
|
|
1419 |
*
|
|
1420 |
*/
|
|
1421 |
TVerdict CTestStepAudInStreamStop::DoTestStepL()
|
|
1422 |
{
|
|
1423 |
iAudInStream->Stop();
|
|
1424 |
|
|
1425 |
TInt err = KErrNone;
|
|
1426 |
TBool stopped = EFalse;
|
|
1427 |
err = GetAudInStreamStopped(iAudInStream, stopped);
|
|
1428 |
if (err != KErrNone ||
|
|
1429 |
!stopped )
|
|
1430 |
return EFail;
|
|
1431 |
|
|
1432 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
1433 |
// test steps return a result
|
|
1434 |
return iTestStepResult;
|
|
1435 |
}
|
|
1436 |
|
|
1437 |
//
|
|
1438 |
// --------------------------------------------
|
|
1439 |
//
|
|
1440 |
/**
|
|
1441 |
*
|
|
1442 |
* Static constructor for CTestStepAudInStreamPosition.
|
|
1443 |
*
|
|
1444 |
*
|
|
1445 |
* @return "CTestStepAudInStreamPosition*"
|
|
1446 |
* The constructed CTestStepAudInStreamPosition
|
|
1447 |
*
|
|
1448 |
* @xxxx
|
|
1449 |
*
|
|
1450 |
*/
|
|
1451 |
CTestStepAudInStreamPosition* CTestStepAudInStreamPosition::NewL()
|
|
1452 |
{
|
|
1453 |
CTestStepAudInStreamPosition* self = new(ELeave) CTestStepAudInStreamPosition;
|
|
1454 |
return self;
|
|
1455 |
}
|
|
1456 |
|
|
1457 |
/**
|
|
1458 |
*
|
|
1459 |
* Test step constructor.
|
|
1460 |
* Each test step initialises its own name.
|
|
1461 |
*
|
|
1462 |
* @xxxx
|
|
1463 |
*
|
|
1464 |
*/
|
|
1465 |
CTestStepAudInStreamPosition::CTestStepAudInStreamPosition()
|
|
1466 |
{
|
|
1467 |
iTestStepResult = EPass;
|
|
1468 |
// store the name of this test case
|
|
1469 |
// this is the name that is used by the script file
|
|
1470 |
iTestStepName = _L("MM-MMF-ACLNT-U-0711-CP");
|
|
1471 |
}
|
|
1472 |
|
|
1473 |
/**
|
|
1474 |
*
|
|
1475 |
* Test step destructor.
|
|
1476 |
*
|
|
1477 |
* @xxxx
|
|
1478 |
*
|
|
1479 |
*/
|
|
1480 |
CTestStepAudInStreamPosition::~CTestStepAudInStreamPosition()
|
|
1481 |
{
|
|
1482 |
}
|
|
1483 |
|
|
1484 |
/**
|
|
1485 |
*
|
|
1486 |
* Test step Preamble.
|
|
1487 |
*
|
|
1488 |
* @xxxx
|
|
1489 |
*
|
|
1490 |
*/
|
|
1491 |
enum TVerdict CTestStepAudInStreamPosition::DoTestStepPreambleL(void)
|
|
1492 |
{
|
|
1493 |
iTestStepResult = EPass;
|
|
1494 |
enum TVerdict verdict;
|
|
1495 |
// this installs the scheduler, and NEWLs the input stream object
|
|
1496 |
verdict = CTestStepAudInStream::DoTestStepPreambleL();
|
|
1497 |
|
|
1498 |
// Printing to the console and log file
|
|
1499 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0711-CP"));
|
|
1500 |
INFO_PRINTF1(_L("this test is gettig the position of a playing Audio Input Stream Utility Class: Position()"));
|
|
1501 |
|
|
1502 |
iAudInStream->Open(NULL);
|
|
1503 |
CActiveScheduler::Start();
|
|
1504 |
|
|
1505 |
if (iError != KErrNone)
|
|
1506 |
return EInconclusive;
|
|
1507 |
|
|
1508 |
TInt err = KErrNone;
|
|
1509 |
err = iFile.Replace( iFs, KRecordStreamRawFile, EFileWrite ) ;
|
|
1510 |
if (err != KErrNone)
|
|
1511 |
return EInconclusive;
|
|
1512 |
|
|
1513 |
// start feeding the input stream
|
|
1514 |
StartReadL();
|
|
1515 |
CIdle* idleStopper = CIdle::NewL(CActive::EPriorityStandard);
|
|
1516 |
idleStopper->Start(TCallBack(stopActiveScheduler));
|
|
1517 |
CActiveScheduler::Start();
|
|
1518 |
delete idleStopper;
|
|
1519 |
if (iError != KErrNone)
|
|
1520 |
return EInconclusive;
|
|
1521 |
|
|
1522 |
TBool isRecording = EFalse;
|
|
1523 |
err = GetAudInStreamRecording(iAudInStream, isRecording);
|
|
1524 |
if (err != KErrNone ||
|
|
1525 |
!isRecording)
|
|
1526 |
return EInconclusive;
|
|
1527 |
|
|
1528 |
return verdict;
|
|
1529 |
}
|
|
1530 |
|
|
1531 |
/**
|
|
1532 |
*
|
|
1533 |
* Test step Postamble.
|
|
1534 |
*
|
|
1535 |
* @xxxx
|
|
1536 |
*
|
|
1537 |
*/
|
|
1538 |
enum TVerdict CTestStepAudInStreamPosition::DoTestStepPostambleL(void)
|
|
1539 |
{
|
|
1540 |
iFile.Close();
|
|
1541 |
//[ Destroy the scheduler ]
|
|
1542 |
return CTestStepAudInStream::DoTestStepPostambleL();
|
|
1543 |
}
|
|
1544 |
|
|
1545 |
/**
|
|
1546 |
*
|
|
1547 |
* Do the test step.
|
|
1548 |
* Each test step must supply an implementation for DoTestStepL.
|
|
1549 |
*
|
|
1550 |
* @return "TVerdict"
|
|
1551 |
* The result of the test step
|
|
1552 |
*
|
|
1553 |
* @xxxx
|
|
1554 |
*
|
|
1555 |
*/
|
|
1556 |
TVerdict CTestStepAudInStreamPosition::DoTestStepL()
|
|
1557 |
{
|
|
1558 |
TInt err = KErrNone;
|
|
1559 |
TInt bytes = 0;
|
|
1560 |
|
|
1561 |
// here the purpose is to test if the Position() function returns the
|
|
1562 |
// correct position with respect to the clip byte-stream position, i.e.
|
|
1563 |
// the bytes that have been recorded so far, expressed in time (via sample rate)
|
|
1564 |
// and not the actual real-time time difference between the beginning of the
|
|
1565 |
// recording and the moment we apply Position().
|
|
1566 |
// The stream might take longer actual time to be recorded, e.g. start delay, breaks, etc.
|
|
1567 |
// however in this case streaming from AudioInput(microphone) should be consistent
|
|
1568 |
// but it's not the purpose of this unit test to check that it records fine and within
|
|
1569 |
// certain time limits.
|
|
1570 |
|
|
1571 |
// get the position
|
|
1572 |
TTimeIntervalMicroSeconds pos1 = iAudInStream->Position();
|
|
1573 |
bytes = iAudInStream->GetBytes();
|
|
1574 |
TInt64 estimPos = (TInt64(bytes) * KMicroSecsInOneSec) / (TInt64(KSampleRate) * TInt64(KBytesPerSample));
|
|
1575 |
CCallBackTimer* callBackTimer = CCallBackTimer::NewL(TCallBack(stopActiveScheduler));
|
|
1576 |
const TInt KWaitTime = 1000000;
|
|
1577 |
//const TInt KTolerence = 300000; // Should be able to do better than this!
|
|
1578 |
callBackTimer->After(KWaitTime);
|
|
1579 |
// wait a bit
|
|
1580 |
CActiveScheduler::Start();
|
|
1581 |
delete callBackTimer;
|
|
1582 |
if (iError != KErrNone)
|
|
1583 |
return EInconclusive;
|
|
1584 |
|
|
1585 |
bytes = iAudInStream->GetBytes();
|
|
1586 |
estimPos = (TInt64(bytes) * KMicroSecsInOneSec) / (TInt64(KSampleRate) * TInt64(KBytesPerSample));
|
|
1587 |
// get the new position
|
|
1588 |
TTimeIntervalMicroSeconds pos2 = iAudInStream->Position();
|
|
1589 |
if (pos2 != estimPos)
|
|
1590 |
return EFail;
|
|
1591 |
TInt64 diff = pos2.Int64()-pos1.Int64();
|
|
1592 |
INFO_PRINTF2(_L("position diff: %d"), diff);
|
|
1593 |
//if (diff < (KWaitTime-KTolerence) || diff > (KWaitTime+KTolerence))
|
|
1594 |
// return EFail;
|
|
1595 |
// stop the input stream
|
|
1596 |
iAudInStream->Stop();
|
|
1597 |
TBool isStopped;
|
|
1598 |
err = GetAudInStreamStopped(iAudInStream, isStopped);
|
|
1599 |
if (err != KErrNone ||
|
|
1600 |
!isStopped )
|
|
1601 |
return EFail;
|
|
1602 |
|
|
1603 |
// get the new position
|
|
1604 |
TTimeIntervalMicroSeconds pos = iAudInStream->Position();
|
|
1605 |
if (pos.Int64() != 0)
|
|
1606 |
return EFail;
|
|
1607 |
|
|
1608 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
1609 |
// test steps return a result
|
|
1610 |
return iTestStepResult;
|
|
1611 |
}
|
|
1612 |
|
|
1613 |
//
|
|
1614 |
// --------------------------------------------
|
|
1615 |
//
|
|
1616 |
/**
|
|
1617 |
*
|
|
1618 |
* Static constructor for CTestStepAudInStreamGetBytes.
|
|
1619 |
*
|
|
1620 |
*
|
|
1621 |
* @return "CTestStepAudInStreamGetBytes*"
|
|
1622 |
* The constructed CTestStepAudInStreamGetBytes
|
|
1623 |
*
|
|
1624 |
* @xxxx
|
|
1625 |
*
|
|
1626 |
*/
|
|
1627 |
CTestStepAudInStreamGetBytes* CTestStepAudInStreamGetBytes::NewL()
|
|
1628 |
{
|
|
1629 |
CTestStepAudInStreamGetBytes* self = new(ELeave) CTestStepAudInStreamGetBytes;
|
|
1630 |
return self;
|
|
1631 |
}
|
|
1632 |
|
|
1633 |
/**
|
|
1634 |
*
|
|
1635 |
* Test step constructor.
|
|
1636 |
* Each test step initialises its own name.
|
|
1637 |
*
|
|
1638 |
* @xxxx
|
|
1639 |
*
|
|
1640 |
*/
|
|
1641 |
CTestStepAudInStreamGetBytes::CTestStepAudInStreamGetBytes()
|
|
1642 |
{
|
|
1643 |
iTestStepResult = EPass;
|
|
1644 |
// store the name of this test case
|
|
1645 |
// this is the name that is used by the script file
|
|
1646 |
iTestStepName = _L("MM-MMF-ACLNT-U-0712-CP");
|
|
1647 |
}
|
|
1648 |
|
|
1649 |
/**
|
|
1650 |
*
|
|
1651 |
* Test step destructor.
|
|
1652 |
*
|
|
1653 |
* @xxxx
|
|
1654 |
*
|
|
1655 |
*/
|
|
1656 |
CTestStepAudInStreamGetBytes::~CTestStepAudInStreamGetBytes()
|
|
1657 |
{
|
|
1658 |
}
|
|
1659 |
|
|
1660 |
/**
|
|
1661 |
*
|
|
1662 |
* Test step Preamble.
|
|
1663 |
*
|
|
1664 |
* @xxxx
|
|
1665 |
*
|
|
1666 |
*/
|
|
1667 |
enum TVerdict CTestStepAudInStreamGetBytes::DoTestStepPreambleL(void)
|
|
1668 |
{
|
|
1669 |
iTestStepResult = EPass;
|
|
1670 |
enum TVerdict verdict;
|
|
1671 |
// this installs the scheduler, and NEWLs the input stream object
|
|
1672 |
verdict = CTestStepAudInStream::DoTestStepPreambleL();
|
|
1673 |
|
|
1674 |
// Printing to the console and log file
|
|
1675 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0712-CP"));
|
|
1676 |
INFO_PRINTF1(_L("this test gets the bytes rendered by the H/W until this moment: GetBytes()"));
|
|
1677 |
|
|
1678 |
iAudInStream->Open(NULL);
|
|
1679 |
CActiveScheduler::Start();
|
|
1680 |
|
|
1681 |
if (iError != KErrNone)
|
|
1682 |
return EInconclusive;
|
|
1683 |
|
|
1684 |
TInt err = KErrNone;
|
|
1685 |
err = iFile.Replace( iFs, KRecordStreamRawFile, EFileWrite ) ;
|
|
1686 |
if (err != KErrNone)
|
|
1687 |
return EInconclusive;
|
|
1688 |
|
|
1689 |
// start feeding the input stream
|
|
1690 |
StartReadL();
|
|
1691 |
CIdle* idleStopper = CIdle::NewL(CActive::EPriorityStandard);
|
|
1692 |
idleStopper->Start(TCallBack(stopActiveScheduler));
|
|
1693 |
CActiveScheduler::Start();
|
|
1694 |
delete idleStopper;
|
|
1695 |
if (iError != KErrNone)
|
|
1696 |
return EInconclusive;
|
|
1697 |
|
|
1698 |
TBool isRecording = EFalse;
|
|
1699 |
err = GetAudInStreamRecording(iAudInStream, isRecording);
|
|
1700 |
if (err != KErrNone ||
|
|
1701 |
!isRecording)
|
|
1702 |
return EInconclusive;
|
|
1703 |
|
|
1704 |
return verdict;
|
|
1705 |
}
|
|
1706 |
|
|
1707 |
/**
|
|
1708 |
*
|
|
1709 |
* Test step Postamble.
|
|
1710 |
*
|
|
1711 |
* @xxxx
|
|
1712 |
*
|
|
1713 |
*/
|
|
1714 |
enum TVerdict CTestStepAudInStreamGetBytes::DoTestStepPostambleL(void)
|
|
1715 |
{
|
|
1716 |
iFile.Close();
|
|
1717 |
//[ Destroy the scheduler ]
|
|
1718 |
return CTestStepAudInStream::DoTestStepPostambleL();
|
|
1719 |
}
|
|
1720 |
|
|
1721 |
/**
|
|
1722 |
*
|
|
1723 |
* Do the test step.
|
|
1724 |
* Each test step must supply an implementation for DoTestStepL.
|
|
1725 |
*
|
|
1726 |
* @return "TVerdict"
|
|
1727 |
* The result of the test step
|
|
1728 |
*
|
|
1729 |
* @xxxx
|
|
1730 |
*
|
|
1731 |
*/
|
|
1732 |
TVerdict CTestStepAudInStreamGetBytes::DoTestStepL()
|
|
1733 |
{
|
|
1734 |
TInt bytes1 = iAudInStream->GetBytes();
|
|
1735 |
CCallBackTimer* callBackTimer = CCallBackTimer::NewL(TCallBack(stopActiveScheduler));
|
|
1736 |
callBackTimer->After(2000000);
|
|
1737 |
CActiveScheduler::Start();
|
|
1738 |
callBackTimer->Cancel(); // in case something else stopped the AS
|
|
1739 |
if (iError != KErrNone)
|
|
1740 |
return EInconclusive;
|
|
1741 |
|
|
1742 |
TInt bytes2 = iAudInStream->GetBytes();
|
|
1743 |
callBackTimer->After(1000000);
|
|
1744 |
CActiveScheduler::Start();
|
|
1745 |
delete callBackTimer;
|
|
1746 |
if (iError != KErrNone)
|
|
1747 |
return EInconclusive;
|
|
1748 |
|
|
1749 |
iAudInStream->Stop();
|
|
1750 |
TInt bytes3 = iAudInStream->GetBytes();
|
|
1751 |
TInt fileSize;
|
|
1752 |
User::LeaveIfError(iFile.Size(fileSize));
|
|
1753 |
|
|
1754 |
if (bytes1 >= bytes2 || bytes2 >= bytes3)
|
|
1755 |
return EFail;
|
|
1756 |
|
|
1757 |
if (bytes3 != fileSize)
|
|
1758 |
return EFail;
|
|
1759 |
|
|
1760 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
1761 |
// test steps return a result
|
|
1762 |
return iTestStepResult;
|
|
1763 |
}
|
|
1764 |
|
|
1765 |
//
|
|
1766 |
|
|
1767 |
//
|
|
1768 |
// --------------------------------------------
|
|
1769 |
//
|
|
1770 |
/**
|
|
1771 |
*
|
|
1772 |
* Static constructor for CTestStepAudInStreamDataType.
|
|
1773 |
*
|
|
1774 |
*
|
|
1775 |
* @return "CTestStepAudInStreamGetSetDataType*"
|
|
1776 |
* The constructed CTestStepAudInStreamDataType
|
|
1777 |
*
|
|
1778 |
* @xxxx
|
|
1779 |
*
|
|
1780 |
*/
|
|
1781 |
CTestStepAudInStreamDataType* CTestStepAudInStreamDataType::NewL()
|
|
1782 |
{
|
|
1783 |
CTestStepAudInStreamDataType* self = new(ELeave) CTestStepAudInStreamDataType;
|
|
1784 |
return self;
|
|
1785 |
}
|
|
1786 |
|
|
1787 |
/**
|
|
1788 |
*
|
|
1789 |
* Test step constructor.
|
|
1790 |
* Each test step initialises its own name.
|
|
1791 |
*
|
|
1792 |
* @xxxx
|
|
1793 |
*
|
|
1794 |
*/
|
|
1795 |
CTestStepAudInStreamDataType::CTestStepAudInStreamDataType()
|
|
1796 |
{
|
|
1797 |
iTestStepResult = EPass;
|
|
1798 |
// store the name of this test case
|
|
1799 |
// this is the name that is used by the script file
|
|
1800 |
iTestStepName = _L("MM-MMF-ACLNT-U-0730-CP");
|
|
1801 |
}
|
|
1802 |
|
|
1803 |
/**
|
|
1804 |
*
|
|
1805 |
* Test step destructor.
|
|
1806 |
*
|
|
1807 |
* @xxxx
|
|
1808 |
*
|
|
1809 |
*/
|
|
1810 |
CTestStepAudInStreamDataType::~CTestStepAudInStreamDataType()
|
|
1811 |
{
|
|
1812 |
}
|
|
1813 |
|
|
1814 |
/**
|
|
1815 |
*
|
|
1816 |
* Test step Preamble.
|
|
1817 |
*
|
|
1818 |
* @xxxx
|
|
1819 |
*
|
|
1820 |
*/
|
|
1821 |
enum TVerdict CTestStepAudInStreamDataType::DoTestStepPreambleL(void)
|
|
1822 |
{
|
|
1823 |
iTestStepResult = EPass;
|
|
1824 |
|
|
1825 |
CTestStepAudInStream::DoTestStepPreambleL();
|
|
1826 |
|
|
1827 |
return iTestStepResult;
|
|
1828 |
}
|
|
1829 |
|
|
1830 |
/**
|
|
1831 |
*
|
|
1832 |
* Test step Postamble.
|
|
1833 |
*
|
|
1834 |
* @xxxx
|
|
1835 |
*
|
|
1836 |
*/
|
|
1837 |
enum TVerdict CTestStepAudInStreamDataType::DoTestStepPostambleL(void)
|
|
1838 |
{
|
|
1839 |
return CTestStepAudInStream::DoTestStepPostambleL();
|
|
1840 |
}
|
|
1841 |
|
|
1842 |
/**
|
|
1843 |
*
|
|
1844 |
* Do the test step.
|
|
1845 |
* Each test step must supply an implementation for DoTestStepL.
|
|
1846 |
*
|
|
1847 |
* @return "TVerdict"
|
|
1848 |
* The result of the test step
|
|
1849 |
*
|
|
1850 |
* @xxxx
|
|
1851 |
*
|
|
1852 |
*/
|
|
1853 |
TVerdict CTestStepAudInStreamDataType::DoTestStepL()
|
|
1854 |
{
|
|
1855 |
iTestStepResult = EPass;
|
|
1856 |
|
|
1857 |
RArray<TFourCC> codecs;
|
|
1858 |
codecs.Append(KMMFFourCCCodePCMU8);
|
|
1859 |
codecs.Append(KMMFFourCCCodePCM16);
|
|
1860 |
codecs.Append(KMMFFourCCCodeALAW);
|
|
1861 |
codecs.Append(KMMFFourCCCodeMuLAW);
|
|
1862 |
codecs.Append(KMMFFourCCCodeIMAD);
|
|
1863 |
codecs.Append(KMMFFourCCCodePCM16B);
|
|
1864 |
codecs.Append(KMMFFourCCCodeGSM610);
|
|
1865 |
|
|
1866 |
CMdaAudioInputStream* inStream = CMdaAudioInputStream::NewL(*this);
|
|
1867 |
|
|
1868 |
TInt numCodecs = codecs.Count();
|
|
1869 |
for(TInt i=0; i<numCodecs; i++)
|
|
1870 |
{
|
|
1871 |
TRAPD(err, inStream->SetDataTypeL(codecs[i]));
|
|
1872 |
if (err != KErrNone)
|
|
1873 |
{
|
|
1874 |
iTestStepResult = EFail;
|
|
1875 |
break;
|
|
1876 |
}
|
|
1877 |
TFourCC fourCCReceived = inStream->DataType();
|
|
1878 |
if (codecs[i] != fourCCReceived)
|
|
1879 |
{
|
|
1880 |
iTestStepResult = EFail;
|
|
1881 |
break;
|
|
1882 |
}
|
|
1883 |
}
|
|
1884 |
delete inStream;
|
|
1885 |
codecs.Close();
|
|
1886 |
return iTestStepResult;
|
|
1887 |
}
|
|
1888 |
|
|
1889 |
// --------------------------------------------
|
|
1890 |
|
|
1891 |
/**
|
|
1892 |
*
|
|
1893 |
* Static constructor for CTestStepAudInStreamMemLeak.
|
|
1894 |
*
|
|
1895 |
*
|
|
1896 |
* @return "CTestStepAudInStreamMemLeak*"
|
|
1897 |
* The constructed CTestStepAudInStreamMemLeak
|
|
1898 |
*
|
|
1899 |
* @xxxx
|
|
1900 |
*
|
|
1901 |
*/
|
|
1902 |
CTestStepAudInStreamMemLeak* CTestStepAudInStreamMemLeak::NewL()
|
|
1903 |
{
|
|
1904 |
CTestStepAudInStreamMemLeak* self = new(ELeave) CTestStepAudInStreamMemLeak;
|
|
1905 |
return self;
|
|
1906 |
}
|
|
1907 |
|
|
1908 |
/**
|
|
1909 |
*
|
|
1910 |
* Test step constructor.
|
|
1911 |
* Each test step initialises its own name.
|
|
1912 |
*
|
|
1913 |
* @xxxx
|
|
1914 |
*
|
|
1915 |
*/
|
|
1916 |
CTestStepAudInStreamMemLeak::CTestStepAudInStreamMemLeak()
|
|
1917 |
{
|
|
1918 |
iTestStepResult = EPass;
|
|
1919 |
// store the name of this test case
|
|
1920 |
// this is the name that is used by the script file
|
|
1921 |
iTestStepName = _L("MM-MMF-ACLNT-U-0510-HP");
|
|
1922 |
}
|
|
1923 |
|
|
1924 |
/**
|
|
1925 |
*
|
|
1926 |
* Test step destructor.
|
|
1927 |
*
|
|
1928 |
* @xxxx
|
|
1929 |
*
|
|
1930 |
*/
|
|
1931 |
CTestStepAudInStreamMemLeak::~CTestStepAudInStreamMemLeak()
|
|
1932 |
{
|
|
1933 |
}
|
|
1934 |
|
|
1935 |
/**
|
|
1936 |
* Implementation of the MMdaAudioOuputStreamCallback interface functions
|
|
1937 |
**/
|
|
1938 |
void CTestStepAudInStreamMemLeak::MaiscOpenComplete(TInt /*aError*/)
|
|
1939 |
{
|
|
1940 |
}
|
|
1941 |
void CTestStepAudInStreamMemLeak::MaiscBufferCopied(TInt /*aError*/, const TDesC8& /*aBuffer*/)
|
|
1942 |
{
|
|
1943 |
}
|
|
1944 |
void CTestStepAudInStreamMemLeak::MaiscRecordComplete(TInt /*aError*/)
|
|
1945 |
{
|
|
1946 |
}
|
|
1947 |
|
|
1948 |
/**
|
|
1949 |
*
|
|
1950 |
* Test step Preamble.
|
|
1951 |
*
|
|
1952 |
* @xxxx
|
|
1953 |
*
|
|
1954 |
*/
|
|
1955 |
enum TVerdict CTestStepAudInStreamMemLeak::DoTestStepPreambleL(void)
|
|
1956 |
{
|
|
1957 |
enum TVerdict verdict;
|
|
1958 |
// this installs the scheduler
|
|
1959 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
1960 |
return verdict;
|
|
1961 |
}
|
|
1962 |
|
|
1963 |
/**
|
|
1964 |
*
|
|
1965 |
* Test step Postamble.
|
|
1966 |
*
|
|
1967 |
* @xxxx
|
|
1968 |
*
|
|
1969 |
*/
|
|
1970 |
enum TVerdict CTestStepAudInStreamMemLeak::DoTestStepPostambleL(void)
|
|
1971 |
{
|
|
1972 |
//[ Destroy the scheduler ]
|
|
1973 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
1974 |
}
|
|
1975 |
|
|
1976 |
/**
|
|
1977 |
*
|
|
1978 |
* Do the test step.
|
|
1979 |
* Each test step must supply an implementation for DoTestStepL.
|
|
1980 |
*
|
|
1981 |
* @return "TVerdict"
|
|
1982 |
* The result of the test step
|
|
1983 |
*
|
|
1984 |
* @xxxx
|
|
1985 |
*
|
|
1986 |
*/
|
|
1987 |
TVerdict CTestStepAudInStreamMemLeak::DoTestStepL()
|
|
1988 |
{
|
|
1989 |
__MM_HEAP_MARK;
|
|
1990 |
|
|
1991 |
INFO_PRINTF2(_L("%S"), &iTestStepName);
|
|
1992 |
INFO_PRINTF1(_L("this test creates & then deletes an Audio Input Stream Utility Class"));
|
|
1993 |
INFO_PRINTF1(_L("and then checks for any memory leak"));
|
|
1994 |
|
|
1995 |
iAudInStream = CMdaAudioInputStream::NewL(*this);
|
|
1996 |
|
|
1997 |
if ( iAudInStream == NULL )
|
|
1998 |
iTestStepResult = EFail;
|
|
1999 |
else
|
|
2000 |
iTestStepResult = EPass;
|
|
2001 |
|
|
2002 |
delete iAudInStream;
|
|
2003 |
iAudInStream = NULL;
|
|
2004 |
__MM_HEAP_MARKEND;
|
|
2005 |
|
|
2006 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
2007 |
// test steps return a result
|
|
2008 |
return iTestStepResult;
|
|
2009 |
|
|
2010 |
}
|
|
2011 |
|
|
2012 |
// --------------------------------------------
|
|
2013 |
|
|
2014 |
/**
|
|
2015 |
*
|
|
2016 |
* Test step constructor.
|
|
2017 |
* Each test step initialises its own name.
|
|
2018 |
*
|
|
2019 |
* @xxxx
|
|
2020 |
*
|
|
2021 |
*/
|
|
2022 |
RTestStepAudInStreamBitRate::RTestStepAudInStreamBitRate()
|
|
2023 |
{
|
|
2024 |
iTestVerdictSet = EFalse;
|
|
2025 |
// store the name of this test case
|
|
2026 |
// this is the name that is used by the script file
|
|
2027 |
iTestStepName = _L("MM-MMF-ACLNT-U-0511-HP");
|
|
2028 |
}
|
|
2029 |
|
|
2030 |
/**
|
|
2031 |
* Implementation of the MMdaAudioOuputStreamCallback interface functions
|
|
2032 |
**/
|
|
2033 |
void RTestStepAudInStreamBitRate::MaiscOpenComplete(TInt aError)
|
|
2034 |
{
|
|
2035 |
TBuf<256> message;
|
|
2036 |
if (aError != KErrNone)
|
|
2037 |
{
|
|
2038 |
message.Format(_L("Open failed unexpectedly with error %d - aborting test"), aError);
|
|
2039 |
SetSectionFailed(message);
|
|
2040 |
CActiveScheduler::Stop();
|
|
2041 |
}
|
|
2042 |
else
|
|
2043 |
{
|
|
2044 |
TestBitRates();
|
|
2045 |
}
|
|
2046 |
}
|
|
2047 |
void RTestStepAudInStreamBitRate::MaiscBufferCopied(TInt /*aError*/, const TDesC8& /*aBuffer*/)
|
|
2048 |
{
|
|
2049 |
}
|
|
2050 |
void RTestStepAudInStreamBitRate::MaiscRecordComplete(TInt /*aError*/)
|
|
2051 |
{
|
|
2052 |
}
|
|
2053 |
|
|
2054 |
TVerdict RTestStepAudInStreamBitRate::OpenL()
|
|
2055 |
{
|
|
2056 |
// create and install the active scheduler
|
|
2057 |
CActiveScheduler* sched = new (ELeave) CActiveScheduler;
|
|
2058 |
CActiveScheduler::Install(sched);
|
|
2059 |
return EPass;
|
|
2060 |
}
|
|
2061 |
|
|
2062 |
TVerdict RTestStepAudInStreamBitRate::DoTestStepL()
|
|
2063 |
{
|
|
2064 |
iAudInStream = CMdaAudioInputStream::NewL(*this);
|
|
2065 |
iAudInStream->Open(NULL);
|
|
2066 |
CActiveScheduler::Start();
|
|
2067 |
__ASSERT_ALWAYS(iTestVerdictSet, User::Panic(_L("Test verdict not set"),0));
|
|
2068 |
return iTestStepResult;
|
|
2069 |
}
|
|
2070 |
|
|
2071 |
const TInt KTestBitRate = 48000 * 16;
|
|
2072 |
_LIT(KMessageNotReadyPass, "Received KErrNotReady (As Expected: H/W device has not yet been fully initialised)");
|
|
2073 |
_LIT(KMessageUnexpectedErrorFail, "Unexpected error: %d");
|
|
2074 |
|
|
2075 |
void RTestStepAudInStreamBitRate::TestBitRates()
|
|
2076 |
{
|
|
2077 |
TBuf<256> message;
|
|
2078 |
TInt err = KErrNone;
|
|
2079 |
|
|
2080 |
// this will invoke the bitrate plugin but will not have
|
|
2081 |
// initialised the datapath therefore we expect a KErrNotReady
|
|
2082 |
// error from each call
|
|
2083 |
|
|
2084 |
TRAP(err, iAudInStream->BitRateL());
|
|
2085 |
|
|
2086 |
if (err != KErrNotReady)
|
|
2087 |
{
|
|
2088 |
message.Format(KMessageUnexpectedErrorFail,err);
|
|
2089 |
SetSectionFailed(message);
|
|
2090 |
}
|
|
2091 |
else
|
|
2092 |
{
|
|
2093 |
message.Format(KMessageNotReadyPass);
|
|
2094 |
SetSectionPassed(message);
|
|
2095 |
}
|
|
2096 |
|
|
2097 |
RArray<TInt> array;
|
|
2098 |
array.AppendL(KTestBitRate); // set a dummy value
|
|
2099 |
TRAP(err, iAudInStream->GetSupportedBitRatesL(array));
|
|
2100 |
if (array.Count() != 0)
|
|
2101 |
{
|
|
2102 |
SetSectionFailed(_L("array not reset after call to GetSupportedBitRates"));
|
|
2103 |
}
|
|
2104 |
array.Close();
|
|
2105 |
|
|
2106 |
if (err != KErrNotReady)
|
|
2107 |
{
|
|
2108 |
message.Format(KMessageUnexpectedErrorFail,err);
|
|
2109 |
SetSectionFailed(message);
|
|
2110 |
}
|
|
2111 |
else
|
|
2112 |
{
|
|
2113 |
message.Format(KMessageNotReadyPass);
|
|
2114 |
SetSectionPassed(message);
|
|
2115 |
}
|
|
2116 |
|
|
2117 |
TRAP(err, iAudInStream->SetBitRateL(KTestBitRate));
|
|
2118 |
if (err != KErrNotReady)
|
|
2119 |
{
|
|
2120 |
message.Format(KMessageUnexpectedErrorFail,err);
|
|
2121 |
SetSectionFailed(message);
|
|
2122 |
}
|
|
2123 |
else
|
|
2124 |
{
|
|
2125 |
message.Format(KMessageNotReadyPass);
|
|
2126 |
SetSectionPassed(message);
|
|
2127 |
}
|
|
2128 |
// finished with test
|
|
2129 |
CActiveScheduler::Stop();
|
|
2130 |
}
|
|
2131 |
|
|
2132 |
|
|
2133 |
void RTestStepAudInStreamBitRate::SetSectionPassed(const TDesC& aMessage)
|
|
2134 |
{
|
|
2135 |
INFO_PRINTF2(_L("%S"),&aMessage);
|
|
2136 |
|
|
2137 |
if (!iTestVerdictSet)
|
|
2138 |
{
|
|
2139 |
iTestStepResult = EPass;
|
|
2140 |
iTestVerdictSet = ETrue;
|
|
2141 |
}
|
|
2142 |
if (iTestStepResult == EPass)
|
|
2143 |
{
|
|
2144 |
INFO_PRINTF1(_L("Section Passed - Overall Verdict PASS"));
|
|
2145 |
}
|
|
2146 |
else
|
|
2147 |
{
|
|
2148 |
INFO_PRINTF1(_L("Section Passed - Overall Verdict FAIL"));
|
|
2149 |
}
|
|
2150 |
}
|
|
2151 |
|
|
2152 |
void RTestStepAudInStreamBitRate::SetSectionFailed(const TDesC& aMessage)
|
|
2153 |
{
|
|
2154 |
// A fail will always cause the whole test to fail
|
|
2155 |
iTestStepResult = EFail;
|
|
2156 |
INFO_PRINTF2(_L("%S"),&aMessage);
|
|
2157 |
INFO_PRINTF1(_L("Section Failed - Overall Verdict FAIL"));
|
|
2158 |
iTestVerdictSet = ETrue;
|
|
2159 |
}
|
|
2160 |
|
|
2161 |
|
|
2162 |
void RTestStepAudInStreamBitRate::Close()
|
|
2163 |
{
|
|
2164 |
delete iAudInStream;
|
|
2165 |
iAudInStream = NULL;
|
|
2166 |
}
|
|
2167 |
|
|
2168 |
|
|
2169 |
|
|
2170 |
//
|
|
2171 |
// --------------------------------------------
|
|
2172 |
//
|
|
2173 |
/**
|
|
2174 |
*
|
|
2175 |
* Static constructor for CTestStepAudInStreamTestBitrate.
|
|
2176 |
*
|
|
2177 |
*
|
|
2178 |
* @return "CTestStepAudInStreamTestBitrate*"
|
|
2179 |
* The constructed CTestStepAudInStreamTestBitrate
|
|
2180 |
*
|
|
2181 |
* @xxxx
|
|
2182 |
*
|
|
2183 |
*/
|
|
2184 |
CTestStepAudInStreamTestBitrate* CTestStepAudInStreamTestBitrate::NewL()
|
|
2185 |
{
|
|
2186 |
CTestStepAudInStreamTestBitrate* self = new(ELeave) CTestStepAudInStreamTestBitrate;
|
|
2187 |
return self;
|
|
2188 |
}
|
|
2189 |
|
|
2190 |
/**
|
|
2191 |
*
|
|
2192 |
* Test step constructor.
|
|
2193 |
* Each test step initialises its own name.
|
|
2194 |
*
|
|
2195 |
* @xxxx
|
|
2196 |
*
|
|
2197 |
*/
|
|
2198 |
CTestStepAudInStreamTestBitrate::CTestStepAudInStreamTestBitrate()
|
|
2199 |
{
|
|
2200 |
iTestStepResult = EPass;
|
|
2201 |
// store the name of this test case
|
|
2202 |
// this is the name that is used by the script file
|
|
2203 |
iTestStepName = _L("MM-MMF-ACLNT-U-0747-CP");
|
|
2204 |
}
|
|
2205 |
|
|
2206 |
/**
|
|
2207 |
*
|
|
2208 |
* Test step destructor.
|
|
2209 |
*
|
|
2210 |
* @xxxx
|
|
2211 |
*
|
|
2212 |
*/
|
|
2213 |
CTestStepAudInStreamTestBitrate::~CTestStepAudInStreamTestBitrate()
|
|
2214 |
{
|
|
2215 |
}
|
|
2216 |
|
|
2217 |
/**
|
|
2218 |
*
|
|
2219 |
* Test step Preamble.
|
|
2220 |
*
|
|
2221 |
* @xxxx
|
|
2222 |
*
|
|
2223 |
*/
|
|
2224 |
enum TVerdict CTestStepAudInStreamTestBitrate::DoTestStepPreambleL(void)
|
|
2225 |
{
|
|
2226 |
iTestStepResult = EPass;
|
|
2227 |
enum TVerdict verdict;
|
|
2228 |
// this installs the scheduler, and NEWLs the input stream object
|
|
2229 |
verdict = CTestStepAudInStream::DoTestStepPreambleL();
|
|
2230 |
|
|
2231 |
// Printing to the console and log file
|
|
2232 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0747-CP"));
|
|
2233 |
INFO_PRINTF1(_L("this tests the bitrate custom interface implemented in DevSound"));
|
|
2234 |
|
|
2235 |
iAudInStream->Open(NULL);
|
|
2236 |
CActiveScheduler::Start();
|
|
2237 |
|
|
2238 |
if (iError != KErrNone)
|
|
2239 |
{
|
|
2240 |
return EInconclusive;
|
|
2241 |
}
|
|
2242 |
|
|
2243 |
TInt err = KErrNone;
|
|
2244 |
err = iFile.Replace( iFs, KRecordStreamRawFile, EFileWrite ) ;
|
|
2245 |
if (err != KErrNone)
|
|
2246 |
{
|
|
2247 |
return EInconclusive;
|
|
2248 |
}
|
|
2249 |
|
|
2250 |
// start feeding the input stream
|
|
2251 |
StartReadL();
|
|
2252 |
CIdle* idleStopper = CIdle::NewL(CActive::EPriorityStandard);
|
|
2253 |
idleStopper->Start(TCallBack(stopActiveScheduler));
|
|
2254 |
CActiveScheduler::Start();
|
|
2255 |
delete idleStopper;
|
|
2256 |
if (iError != KErrNone)
|
|
2257 |
{
|
|
2258 |
return EInconclusive;
|
|
2259 |
}
|
|
2260 |
|
|
2261 |
TBool isRecording = EFalse;
|
|
2262 |
err = GetAudInStreamRecording(iAudInStream, isRecording);
|
|
2263 |
if (err != KErrNone || !isRecording)
|
|
2264 |
{
|
|
2265 |
return EInconclusive;
|
|
2266 |
}
|
|
2267 |
|
|
2268 |
User::After(1000000);
|
|
2269 |
|
|
2270 |
return verdict;
|
|
2271 |
}
|
|
2272 |
|
|
2273 |
/**
|
|
2274 |
*
|
|
2275 |
* Test step Postamble.
|
|
2276 |
*
|
|
2277 |
* @xxxx
|
|
2278 |
*
|
|
2279 |
*/
|
|
2280 |
enum TVerdict CTestStepAudInStreamTestBitrate::DoTestStepPostambleL(void)
|
|
2281 |
{
|
|
2282 |
iFile.Close();
|
|
2283 |
//[ Destroy the scheduler ]
|
|
2284 |
return CTestStepAudInStream::DoTestStepPostambleL();
|
|
2285 |
}
|
|
2286 |
|
|
2287 |
/**
|
|
2288 |
*
|
|
2289 |
* Do the test step.
|
|
2290 |
* Each test step must supply an implementation for DoTestStepL.
|
|
2291 |
*
|
|
2292 |
* @return "TVerdict"
|
|
2293 |
* The result of the test step
|
|
2294 |
*
|
|
2295 |
* @xxxx
|
|
2296 |
*
|
|
2297 |
*/
|
|
2298 |
TVerdict CTestStepAudInStreamTestBitrate::DoTestStepL()
|
|
2299 |
{
|
|
2300 |
TBool test1 = EFalse;
|
|
2301 |
TBool test2 = EFalse;
|
|
2302 |
TBool test3 = EFalse;
|
|
2303 |
|
|
2304 |
// fetch the bitrate
|
|
2305 |
TInt bitRate = 0;
|
|
2306 |
TRAPD(err, bitRate = iAudInStream->BitRateL());
|
|
2307 |
|
|
2308 |
if (err == KErrNone)
|
|
2309 |
{
|
|
2310 |
INFO_PRINTF2(_L("BitRateL() returned %d"), bitRate);
|
|
2311 |
test1 = ETrue;
|
|
2312 |
}
|
|
2313 |
else
|
|
2314 |
{
|
|
2315 |
INFO_PRINTF2(_L("BitRateL() failed with error %d"), err);
|
|
2316 |
}
|
|
2317 |
|
|
2318 |
// even if test is fail we keep going so as to test APIs
|
|
2319 |
// get the supported bitrates from the sound device
|
|
2320 |
RArray<TInt> array;
|
|
2321 |
TRAP(err, iAudInStream->GetSupportedBitRatesL(array));
|
|
2322 |
|
|
2323 |
if ((err == KErrNone) && (array.Count() > 0))
|
|
2324 |
{
|
|
2325 |
INFO_PRINTF2(_L("GetSupportedBitRatesL() returned %d result"), array.Count());
|
|
2326 |
test2 = ETrue;
|
|
2327 |
}
|
|
2328 |
else if (err != KErrNone)
|
|
2329 |
{
|
|
2330 |
INFO_PRINTF2(_L("GetSupportedBitRatesL() failed with error %d"), err);
|
|
2331 |
}
|
|
2332 |
else if (array.Count() == 0)
|
|
2333 |
{
|
|
2334 |
INFO_PRINTF2(_L("GetSupportedBitRatesL() returned no supported bitrates!"), err);
|
|
2335 |
}
|
|
2336 |
|
|
2337 |
// set a required bitrate - we assume num of channels
|
|
2338 |
// has already been set as mono (1)
|
|
2339 |
TRAP(err, iAudInStream->SetBitRateL(KTestBitRate));
|
|
2340 |
|
|
2341 |
if (err == KErrNone)
|
|
2342 |
{
|
|
2343 |
INFO_PRINTF2(_L("SetBitRateL() set successfully at %d"), KTestBitRate);
|
|
2344 |
test3 = ETrue;
|
|
2345 |
}
|
|
2346 |
else
|
|
2347 |
{
|
|
2348 |
INFO_PRINTF2(_L("SetBitRateL() failed with error %d"), err);
|
|
2349 |
}
|
|
2350 |
|
|
2351 |
iTestStepResult = EFail;
|
|
2352 |
|
|
2353 |
if (test1 && test2 && test3)
|
|
2354 |
{
|
|
2355 |
iTestStepResult = EPass;
|
|
2356 |
}
|
|
2357 |
|
|
2358 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
2359 |
// test steps return a result
|
|
2360 |
return iTestStepResult;
|
|
2361 |
}
|
|
2362 |
|
|
2363 |
//
|
|
2364 |
|
|
2365 |
RTestStepAudInStreamBitRateOOM* RTestStepAudInStreamBitRateOOM::NewL()
|
|
2366 |
{
|
|
2367 |
RTestStepAudInStreamBitRateOOM* self = new(ELeave) RTestStepAudInStreamBitRateOOM;
|
|
2368 |
return self;
|
|
2369 |
}
|
|
2370 |
|
|
2371 |
RTestStepAudInStreamBitRateOOM::RTestStepAudInStreamBitRateOOM()
|
|
2372 |
{
|
|
2373 |
iTestStepResult = EPass;
|
|
2374 |
// store the name of this test case
|
|
2375 |
// this is the name that is used by the script file
|
|
2376 |
iTestStepName = _L("MM-MMF-ACLNT-U-0748-CP");
|
|
2377 |
}
|
|
2378 |
|
|
2379 |
RTestStepAudInStreamBitRateOOM::~RTestStepAudInStreamBitRateOOM()
|
|
2380 |
{
|
|
2381 |
}
|
|
2382 |
|
|
2383 |
/**
|
|
2384 |
* Implementation of the MMdaAudioOuputStreamCallback interface functions
|
|
2385 |
**/
|
|
2386 |
void RTestStepAudInStreamBitRateOOM::MaiscOpenComplete(TInt aError)
|
|
2387 |
{
|
|
2388 |
if (aError != KErrNone)
|
|
2389 |
{
|
|
2390 |
INFO_PRINTF2(_L("Open failed unexpectedly with error %d - aborting test"), aError);
|
|
2391 |
iTestStepResult = EFail;
|
|
2392 |
}
|
|
2393 |
CActiveScheduler::Stop();
|
|
2394 |
}
|
|
2395 |
void RTestStepAudInStreamBitRateOOM::MaiscBufferCopied(TInt /*aError*/, const TDesC8& /*aBuffer*/)
|
|
2396 |
{
|
|
2397 |
}
|
|
2398 |
void RTestStepAudInStreamBitRateOOM::MaiscRecordComplete(TInt /*aError*/)
|
|
2399 |
{
|
|
2400 |
}
|
|
2401 |
|
|
2402 |
|
|
2403 |
TVerdict RTestStepAudInStreamBitRateOOM::TestBitRateInterfaceL()
|
|
2404 |
{
|
|
2405 |
// create the stream
|
|
2406 |
CMMFMdaAudioInputStream* inStream = CMMFMdaAudioInputStream::NewL(*this);
|
|
2407 |
CleanupStack::PushL(inStream);
|
|
2408 |
|
|
2409 |
// open it and start the scheduler
|
|
2410 |
inStream->Open(NULL);
|
|
2411 |
CActiveScheduler::Start();
|
|
2412 |
|
|
2413 |
|
|
2414 |
// we trap all calls to catch the KErrNotReady error
|
|
2415 |
// now fetch the bitrate
|
|
2416 |
TRAPD(err, inStream->BitRateL());
|
|
2417 |
if (err != KErrNone && err != KErrNotReady)
|
|
2418 |
{
|
|
2419 |
User::Leave(err);
|
|
2420 |
}
|
|
2421 |
|
|
2422 |
// fetch a list of bitrates
|
|
2423 |
RArray<TInt> array;
|
|
2424 |
TRAP(err, inStream->GetSupportedBitRatesL(array));
|
|
2425 |
if (err != KErrNone && err != KErrNotReady)
|
|
2426 |
{
|
|
2427 |
User::Leave(err);
|
|
2428 |
}
|
|
2429 |
|
|
2430 |
// set a required bitrate - we assume num of channels
|
|
2431 |
// has already been set as mono (1)
|
|
2432 |
TRAP(err, inStream->SetBitRateL(KTestBitRate))
|
|
2433 |
if (err != KErrNone && err != KErrNotReady)
|
|
2434 |
{
|
|
2435 |
User::Leave(err);
|
|
2436 |
}
|
|
2437 |
|
|
2438 |
// clean up
|
|
2439 |
CleanupStack::PopAndDestroy(inStream);
|
|
2440 |
inStream = NULL;
|
|
2441 |
|
|
2442 |
return EPass;
|
|
2443 |
}
|
|
2444 |
|
|
2445 |
|
|
2446 |
|
|
2447 |
TVerdict RTestStepAudInStreamBitRateOOM::DoTestStepL()
|
|
2448 |
{
|
|
2449 |
iTestStepResult = EPass;
|
|
2450 |
TInt err = KErrNone;
|
|
2451 |
|
|
2452 |
CActiveScheduler* sched = new (ELeave) CActiveScheduler;
|
|
2453 |
CActiveScheduler::Install(sched);
|
|
2454 |
|
|
2455 |
// Printing to the console and log file
|
|
2456 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0748-CP"));
|
|
2457 |
INFO_PRINTF1(_L("this tests the bitrate custom interface implemented in DevSound for OOM"));
|
|
2458 |
|
|
2459 |
//__MM_HEAP_MARK;
|
|
2460 |
TVerdict testRes = EFail;
|
|
2461 |
TRAP( err, testRes = TestBitRateInterfaceL());
|
|
2462 |
//__MM_HEAP_MARKEND;
|
|
2463 |
|
|
2464 |
if (err != KErrNone || testRes == EFail)
|
|
2465 |
return EFail;
|
|
2466 |
|
|
2467 |
TInt failCount = 1;
|
|
2468 |
TBool completed = EFalse;
|
|
2469 |
TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
|
|
2470 |
for(;;)
|
|
2471 |
{
|
|
2472 |
__UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
|
|
2473 |
//__MM_HEAP_MARK;
|
|
2474 |
|
|
2475 |
testRes = EFail;
|
|
2476 |
TRAP( err, testRes = TestBitRateInterfaceL());
|
|
2477 |
|
|
2478 |
completed = EFalse;
|
|
2479 |
if (err == KErrNone)
|
|
2480 |
{
|
|
2481 |
if (testRes == EPass)
|
|
2482 |
{
|
|
2483 |
TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
|
|
2484 |
if (testAlloc==NULL)
|
|
2485 |
{
|
|
2486 |
reachedEnd = ETrue;
|
|
2487 |
failCount--; // -= 1;
|
|
2488 |
}
|
|
2489 |
else
|
|
2490 |
{
|
|
2491 |
User::Free(testAlloc);
|
|
2492 |
}
|
|
2493 |
completed = reachedEnd;
|
|
2494 |
}
|
|
2495 |
else
|
|
2496 |
{
|
|
2497 |
// the test failed but we have already proved above
|
|
2498 |
// that the required plugins are present
|
|
2499 |
// therefore we assume that the interface returned
|
|
2500 |
// a NULL pointer and so we can continue to test
|
|
2501 |
// until the timeout or the fail count exceeds
|
|
2502 |
completed = EFalse;
|
|
2503 |
}
|
|
2504 |
}
|
|
2505 |
else if (err == KErrNotSupported)
|
|
2506 |
{
|
|
2507 |
// the test has returned not supported but we already
|
|
2508 |
// know that the interface *is* supported so we assume
|
|
2509 |
// that the interface creation failed due to lack of
|
|
2510 |
// memory and so we continue to test until the timeout
|
|
2511 |
// or we exceed the fail count
|
|
2512 |
completed = EFalse;
|
|
2513 |
}
|
|
2514 |
else if (err != KErrNoMemory) // bad error code
|
|
2515 |
{
|
|
2516 |
completed = ETrue;
|
|
2517 |
}
|
|
2518 |
|
|
2519 |
//__MM_HEAP_MARKEND;
|
|
2520 |
__UHEAP_SETFAIL(RHeap::ENone ,0);
|
|
2521 |
|
|
2522 |
// if we have completed successfully or we have exceeded
|
|
2523 |
// a 1000 failed ALLOC attempts then quit
|
|
2524 |
if (completed || failCount > 1000)
|
|
2525 |
break; // exit loop
|
|
2526 |
|
|
2527 |
failCount++;
|
|
2528 |
}
|
|
2529 |
|
|
2530 |
// finished with test
|
|
2531 |
|
|
2532 |
if (err != KErrNone)
|
|
2533 |
{
|
|
2534 |
INFO_PRINTF3(_L(" Error(%d) with %d memory allocations tested"), err, failCount);
|
|
2535 |
iTestStepResult = EFail;
|
|
2536 |
}
|
|
2537 |
else
|
|
2538 |
{
|
|
2539 |
INFO_PRINTF2(_L(" Completed OK with %d memory allocations tested"), failCount);
|
|
2540 |
iTestStepResult = EPass;
|
|
2541 |
}
|
|
2542 |
|
|
2543 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
2544 |
// test steps return a result
|
|
2545 |
return iTestStepResult;
|
|
2546 |
}
|
|
2547 |
|
|
2548 |
|
|
2549 |
|
|
2550 |
//
|
|
2551 |
// RAsyncTestStep Tests
|
|
2552 |
//
|
|
2553 |
|
|
2554 |
/**
|
|
2555 |
* Base class common implementation
|
|
2556 |
**/
|
|
2557 |
|
|
2558 |
CTestStepAudInStreamAsyncTestStep::CTestStepAudInStreamAsyncTestStep(CTestSuite* aSuite)
|
|
2559 |
// Using zero initialisation
|
|
2560 |
// iTestState (EStateOpen)
|
|
2561 |
// iBufferList
|
|
2562 |
// iBufferCount
|
|
2563 |
// iAudInStream
|
|
2564 |
// iTrigger
|
|
2565 |
{
|
|
2566 |
iSuite = aSuite;
|
|
2567 |
//Default heap size is 64K. Increased to 128K to avoid the KErrNoMemory for this test step.
|
|
2568 |
iHeapSize = 1024*128;
|
|
2569 |
}
|
|
2570 |
|
|
2571 |
void CTestStepAudInStreamAsyncTestStep::KickoffTestL()
|
|
2572 |
{
|
|
2573 |
iTrigger = CFsmTrigger::NewL(*this);
|
|
2574 |
iAudInStream = CMdaAudioInputStream::NewL(*this);
|
|
2575 |
|
|
2576 |
// Reset the buffer.
|
|
2577 |
// We need them empty as could test whether data has been placed into them to obtain some stats.
|
|
2578 |
for(TInt i=0; i<KNumBuffers; i++)
|
|
2579 |
{
|
|
2580 |
iBufferList[i] = KNullDesC8;
|
|
2581 |
}
|
|
2582 |
|
|
2583 |
// start the timer
|
|
2584 |
iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
|
|
2585 |
iTrigger->StartTimer(500000);
|
|
2586 |
}
|
|
2587 |
|
|
2588 |
// cleanup at end
|
|
2589 |
void CTestStepAudInStreamAsyncTestStep::CloseTest()
|
|
2590 |
{
|
|
2591 |
if (iTrigger)
|
|
2592 |
{
|
|
2593 |
iTrigger->Cancel();
|
|
2594 |
delete iTrigger;
|
|
2595 |
}
|
|
2596 |
|
|
2597 |
if (iAudInStream)
|
|
2598 |
{
|
|
2599 |
delete iAudInStream;
|
|
2600 |
}
|
|
2601 |
}
|
|
2602 |
|
|
2603 |
void CTestStepAudInStreamAsyncTestStep::MaiscOpenComplete(TInt aError)
|
|
2604 |
{
|
|
2605 |
if (aError != KErrNone)
|
|
2606 |
{
|
|
2607 |
INFO_PRINTF2(_L("*MaiscOpenComplete* Error: %d."), aError);
|
|
2608 |
StopTest(aError, EFail);
|
|
2609 |
}
|
|
2610 |
}
|
|
2611 |
|
|
2612 |
void CTestStepAudInStreamAsyncTestStep::MaiscBufferCopied(TInt aError, const TDesC8& aBuffer)
|
|
2613 |
{
|
|
2614 |
if (aBuffer.Length())
|
|
2615 |
{
|
|
2616 |
++iBufferCount;
|
|
2617 |
}
|
|
2618 |
|
|
2619 |
if (aError != KErrNone)
|
|
2620 |
{
|
|
2621 |
INFO_PRINTF2(_L("*MaiscBufferCopied* Error: %d."), aError);
|
|
2622 |
|
|
2623 |
// KErrAbort when we Stop the device, so valid
|
|
2624 |
if (aError != KErrAbort)
|
|
2625 |
{
|
|
2626 |
StopTest(aError, EFail);
|
|
2627 |
}
|
|
2628 |
}
|
|
2629 |
}
|
|
2630 |
|
|
2631 |
void CTestStepAudInStreamAsyncTestStep::MaiscRecordComplete(TInt aError)
|
|
2632 |
{
|
|
2633 |
INFO_PRINTF2(_L("*MaiscRecordComplete* GetBytes reports %d bytes recorded."), iAudInStream->GetBytes());
|
|
2634 |
|
|
2635 |
if (aError != KErrNone)
|
|
2636 |
{
|
|
2637 |
INFO_PRINTF2(_L("*MaiscRecordComplete* Error: %d."), aError);
|
|
2638 |
StopTest(aError, EFail);
|
|
2639 |
}
|
|
2640 |
}
|
|
2641 |
|
|
2642 |
//
|
|
2643 |
/**
|
|
2644 |
* Implementation of AO timer used to invoke test processing at desired intervals (i.e. State Machine)
|
|
2645 |
**/
|
|
2646 |
|
|
2647 |
CFsmTrigger* CFsmTrigger::NewL(CTestStepAudInStreamAsyncTestStep& aObserver)
|
|
2648 |
{
|
|
2649 |
CFsmTrigger* self = new (ELeave) CFsmTrigger(aObserver);
|
|
2650 |
CleanupStack::PushL(self);
|
|
2651 |
self->ConstructL();
|
|
2652 |
CleanupStack::Pop(self);
|
|
2653 |
return self;
|
|
2654 |
}
|
|
2655 |
|
|
2656 |
CFsmTrigger::CFsmTrigger(CTestStepAudInStreamAsyncTestStep& aObserver)
|
|
2657 |
: CActive(CActive::EPriorityStandard),
|
|
2658 |
iObserver (aObserver)
|
|
2659 |
{
|
|
2660 |
// nothing to do
|
|
2661 |
}
|
|
2662 |
|
|
2663 |
void CFsmTrigger::ConstructL()
|
|
2664 |
{
|
|
2665 |
User::LeaveIfError (iTimer.CreateLocal());
|
|
2666 |
CActiveScheduler::Add (this);
|
|
2667 |
}
|
|
2668 |
|
|
2669 |
CFsmTrigger::~CFsmTrigger()
|
|
2670 |
{
|
|
2671 |
Cancel();
|
|
2672 |
iTimer.Close();
|
|
2673 |
}
|
|
2674 |
|
|
2675 |
void CFsmTrigger::RunL()
|
|
2676 |
{
|
|
2677 |
// need to call Fsm
|
|
2678 |
iObserver.Fsm();
|
|
2679 |
}
|
|
2680 |
|
|
2681 |
void CFsmTrigger::DoCancel()
|
|
2682 |
{
|
|
2683 |
iTimer.Cancel();
|
|
2684 |
}
|
|
2685 |
|
|
2686 |
void CFsmTrigger::StartTimer(TTimeIntervalMicroSeconds32 aDelay)
|
|
2687 |
{
|
|
2688 |
__ASSERT_ALWAYS(!IsActive(), User::Panic(_L("CFsmTrigger"), 1));
|
|
2689 |
iTimer.After(iStatus, aDelay);
|
|
2690 |
SetActive();
|
|
2691 |
}
|
|
2692 |
|
|
2693 |
//
|
|
2694 |
/**
|
|
2695 |
* Implementation of RAsyncTestStep used to test the RequestStop() api
|
|
2696 |
**/
|
|
2697 |
|
|
2698 |
CTestStepAudInStreamTestReqStop* CTestStepAudInStreamTestReqStop::NewL(CTestSuite* aSuite)
|
|
2699 |
{
|
|
2700 |
return new (ELeave) CTestStepAudInStreamTestReqStop(aSuite);
|
|
2701 |
}
|
|
2702 |
|
|
2703 |
CTestStepAudInStreamTestReqStop::CTestStepAudInStreamTestReqStop(CTestSuite* aSuite)
|
|
2704 |
: CTestStepAudInStreamAsyncTestStep(aSuite)
|
|
2705 |
{
|
|
2706 |
iTestStepName = _L("MM-MMF-ACLNT-U-0749-CP");
|
|
2707 |
}
|
|
2708 |
|
|
2709 |
void CTestStepAudInStreamTestReqStop::KickoffTestL()
|
|
2710 |
{
|
|
2711 |
INFO_PRINTF1(_L("DEF095804 CMdaAudioInputStream loses not complete buffers from DevSound"));
|
|
2712 |
INFO_PRINTF1(_L("Calls RequestStop to ensure no data is lost."));
|
|
2713 |
|
|
2714 |
CTestStepAudInStreamAsyncTestStep::KickoffTestL();
|
|
2715 |
}
|
|
2716 |
|
|
2717 |
// cleanup at end
|
|
2718 |
void CTestStepAudInStreamTestReqStop::CloseTest()
|
|
2719 |
{
|
|
2720 |
CTestStepAudInStreamAsyncTestStep::CloseTest();
|
|
2721 |
}
|
|
2722 |
|
|
2723 |
void CTestStepAudInStreamTestReqStop::MaiscOpenComplete(TInt aError)
|
|
2724 |
{
|
|
2725 |
CTestStepAudInStreamAsyncTestStep::MaiscOpenComplete(aError);
|
|
2726 |
}
|
|
2727 |
|
|
2728 |
void CTestStepAudInStreamTestReqStop::MaiscBufferCopied(TInt aError, const TDesC8& aBuffer)
|
|
2729 |
{
|
|
2730 |
CTestStepAudInStreamAsyncTestStep::MaiscBufferCopied(aError, aBuffer);
|
|
2731 |
|
|
2732 |
if (aError == KErrAbort)
|
|
2733 |
{
|
|
2734 |
INFO_PRINTF2(_L("*MaiscBufferCopied* Error EXPECTED. We have been Stopped."), aError);
|
|
2735 |
INFO_PRINTF2(_L("*MaiscBufferCopied* Data in this buffer: %d bytes."), aBuffer.Length());
|
|
2736 |
INFO_PRINTF2(_L("*MaiscBufferCopied* GetBytes reports %d bytes recorded."), iAudInStream->GetBytes());
|
|
2737 |
}
|
|
2738 |
}
|
|
2739 |
|
|
2740 |
void CTestStepAudInStreamTestReqStop::MaiscRecordComplete(TInt aError)
|
|
2741 |
{
|
|
2742 |
CTestStepAudInStreamAsyncTestStep::MaiscRecordComplete(aError);
|
|
2743 |
}
|
|
2744 |
|
|
2745 |
void CTestStepAudInStreamTestReqStop::Fsm()
|
|
2746 |
{
|
|
2747 |
switch (iTestState)
|
|
2748 |
{
|
|
2749 |
case EStateOpen:
|
|
2750 |
{
|
|
2751 |
iAudInStream->Open(NULL);
|
|
2752 |
iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
|
|
2753 |
iTrigger->StartTimer(500000);
|
|
2754 |
iTestState = EStateRecordInit;
|
|
2755 |
break;
|
|
2756 |
}
|
|
2757 |
case EStateRecordInit:
|
|
2758 |
{
|
|
2759 |
// start the recording process
|
|
2760 |
for (TInt i=0; i<KNumBuffers; i++)
|
|
2761 |
{
|
|
2762 |
iAudInStream->ReadL(iBufferList[i]);
|
|
2763 |
}
|
|
2764 |
|
|
2765 |
// start the timer
|
|
2766 |
iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
|
|
2767 |
iTrigger->StartTimer(500000);
|
|
2768 |
iTestState = EStateRecord;
|
|
2769 |
break;
|
|
2770 |
}
|
|
2771 |
case EStateRecord:
|
|
2772 |
{
|
|
2773 |
// Just wating time here...for the record process to continue
|
|
2774 |
// start the timer
|
|
2775 |
iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
|
|
2776 |
iTrigger->StartTimer(500000);
|
|
2777 |
iTestState = EStateRequestStop;
|
|
2778 |
break;
|
|
2779 |
}
|
|
2780 |
case EStateRequestStop:
|
|
2781 |
{
|
|
2782 |
// stop the recording process
|
|
2783 |
iAudInStream->RequestStop();
|
|
2784 |
|
|
2785 |
// start the timer
|
|
2786 |
iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
|
|
2787 |
iTrigger->StartTimer(500000);
|
|
2788 |
|
|
2789 |
// report the number of bytes read
|
|
2790 |
INFO_PRINTF2(_L("State: EStateRequestStop - GetBytes reports %d bytes recorded."), iAudInStream->GetBytes());
|
|
2791 |
iTestState = EStateStopTest;
|
|
2792 |
break;
|
|
2793 |
}
|
|
2794 |
case EStateStopTest:
|
|
2795 |
{
|
|
2796 |
INFO_PRINTF3(_L("Used %d buffers of %d."), iBufferCount, KNumBuffers);
|
|
2797 |
StopTest(); // success
|
|
2798 |
break;
|
|
2799 |
}
|
|
2800 |
default:
|
|
2801 |
INFO_PRINTF1(_L("State machine error"));
|
|
2802 |
StopTest(KErrGeneral, EFail);
|
|
2803 |
break;
|
|
2804 |
}
|
|
2805 |
}
|
|
2806 |
|
|
2807 |
//
|
|
2808 |
/**
|
|
2809 |
* Implementation of RAsyncTestStep used to test the RequestStop() then Stop() apis
|
|
2810 |
**/
|
|
2811 |
|
|
2812 |
CTestStepAudInStreamTestReqStopThenStop* CTestStepAudInStreamTestReqStopThenStop::NewL(CTestSuite* aSuite)
|
|
2813 |
{
|
|
2814 |
return new (ELeave) CTestStepAudInStreamTestReqStopThenStop(aSuite);
|
|
2815 |
}
|
|
2816 |
|
|
2817 |
CTestStepAudInStreamTestReqStopThenStop::CTestStepAudInStreamTestReqStopThenStop(CTestSuite* aSuite)
|
|
2818 |
: CTestStepAudInStreamAsyncTestStep(aSuite)
|
|
2819 |
{
|
|
2820 |
iTestStepName = _L("MM-MMF-ACLNT-U-0750-CP");
|
|
2821 |
}
|
|
2822 |
|
|
2823 |
void CTestStepAudInStreamTestReqStopThenStop::KickoffTestL()
|
|
2824 |
{
|
|
2825 |
INFO_PRINTF1(_L("DEF095804 CMdaAudioInputStream loses not complete buffers from DevSound"));
|
|
2826 |
INFO_PRINTF1(_L("Calls RequestStop then Stop to ensure correct operation."));
|
|
2827 |
|
|
2828 |
CTestStepAudInStreamAsyncTestStep::KickoffTestL();
|
|
2829 |
}
|
|
2830 |
|
|
2831 |
// cleanup at end
|
|
2832 |
void CTestStepAudInStreamTestReqStopThenStop::CloseTest()
|
|
2833 |
{
|
|
2834 |
CTestStepAudInStreamAsyncTestStep::CloseTest();
|
|
2835 |
}
|
|
2836 |
|
|
2837 |
void CTestStepAudInStreamTestReqStopThenStop::MaiscOpenComplete(TInt aError)
|
|
2838 |
{
|
|
2839 |
CTestStepAudInStreamAsyncTestStep::MaiscOpenComplete(aError);
|
|
2840 |
}
|
|
2841 |
|
|
2842 |
void CTestStepAudInStreamTestReqStopThenStop::MaiscBufferCopied(TInt aError, const TDesC8& aBuffer)
|
|
2843 |
{
|
|
2844 |
CTestStepAudInStreamAsyncTestStep::MaiscBufferCopied(aError, aBuffer);
|
|
2845 |
|
|
2846 |
if (aError == KErrAbort)
|
|
2847 |
{
|
|
2848 |
INFO_PRINTF2(_L("*MaiscBufferCopied* Error EXPECTED. We have been Stopped."), aError);
|
|
2849 |
INFO_PRINTF2(_L("*MaiscBufferCopied* Data in this buffer: %d bytes."), aBuffer.Length());
|
|
2850 |
INFO_PRINTF2(_L("*MaiscBufferCopied* GetBytes reports %d bytes recorded."), iAudInStream->GetBytes());
|
|
2851 |
}
|
|
2852 |
}
|
|
2853 |
|
|
2854 |
void CTestStepAudInStreamTestReqStopThenStop::MaiscRecordComplete(TInt aError)
|
|
2855 |
{
|
|
2856 |
CTestStepAudInStreamAsyncTestStep::MaiscRecordComplete(aError);
|
|
2857 |
}
|
|
2858 |
|
|
2859 |
void CTestStepAudInStreamTestReqStopThenStop::Fsm()
|
|
2860 |
{
|
|
2861 |
switch (iTestState)
|
|
2862 |
{
|
|
2863 |
case EStateOpen:
|
|
2864 |
{
|
|
2865 |
iAudInStream->Open(NULL);
|
|
2866 |
iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
|
|
2867 |
iTrigger->StartTimer(500000);
|
|
2868 |
iTestState = EStateRecordInit;
|
|
2869 |
break;
|
|
2870 |
}
|
|
2871 |
case EStateRecordInit:
|
|
2872 |
{
|
|
2873 |
// start the recording process
|
|
2874 |
for (TInt i=0; i<KNumBuffers; i++)
|
|
2875 |
{
|
|
2876 |
iAudInStream->ReadL(iBufferList[i]);
|
|
2877 |
}
|
|
2878 |
|
|
2879 |
// start the timer
|
|
2880 |
iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
|
|
2881 |
iTrigger->StartTimer(500000);
|
|
2882 |
iTestState = EStateRecord;
|
|
2883 |
break;
|
|
2884 |
}
|
|
2885 |
case EStateRecord:
|
|
2886 |
{
|
|
2887 |
// Just wating time here...for the record process to continue
|
|
2888 |
// start the timer
|
|
2889 |
iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
|
|
2890 |
iTrigger->StartTimer(500000);
|
|
2891 |
iTestState = EStateRequestStop;
|
|
2892 |
break;
|
|
2893 |
}
|
|
2894 |
case EStateRequestStop:
|
|
2895 |
{
|
|
2896 |
// stop the recording process
|
|
2897 |
iAudInStream->RequestStop();
|
|
2898 |
iAudInStream->Stop();
|
|
2899 |
|
|
2900 |
// start the timer
|
|
2901 |
iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
|
|
2902 |
iTrigger->StartTimer(500000);
|
|
2903 |
|
|
2904 |
// report the number of bytes read
|
|
2905 |
INFO_PRINTF2(_L("State: EStateRequestStop - GetBytes reports %d bytes recorded."), iAudInStream->GetBytes());
|
|
2906 |
iTestState = EStateStopTest;
|
|
2907 |
break;
|
|
2908 |
}
|
|
2909 |
case EStateStopTest:
|
|
2910 |
{
|
|
2911 |
INFO_PRINTF3(_L("Used %d buffers of %d."), iBufferCount, KNumBuffers);
|
|
2912 |
StopTest(); // success
|
|
2913 |
break;
|
|
2914 |
}
|
|
2915 |
default:
|
|
2916 |
INFO_PRINTF1(_L("State machine error"));
|
|
2917 |
StopTest(KErrGeneral, EFail);
|
|
2918 |
break;
|
|
2919 |
}
|
|
2920 |
}
|
|
2921 |
|
|
2922 |
//
|
|
2923 |
|
|
2924 |
/**
|
|
2925 |
* Implementation of RAsyncTestStep used to test the RequestStop() then Stop() apis
|
|
2926 |
**/
|
|
2927 |
|
|
2928 |
CTestStepAudInStreamTestStopFromBufferCopied* CTestStepAudInStreamTestStopFromBufferCopied::NewL(CTestSuite* aSuite)
|
|
2929 |
{
|
|
2930 |
return new (ELeave) CTestStepAudInStreamTestStopFromBufferCopied(aSuite);
|
|
2931 |
}
|
|
2932 |
|
|
2933 |
CTestStepAudInStreamTestStopFromBufferCopied::CTestStepAudInStreamTestStopFromBufferCopied(CTestSuite* aSuite)
|
|
2934 |
: CTestStepAudInStreamAsyncTestStep(aSuite)
|
|
2935 |
{
|
|
2936 |
iTestStepName = _L("MM-MMF-ACLNT-U-0751-CP");
|
|
2937 |
}
|
|
2938 |
|
|
2939 |
void CTestStepAudInStreamTestStopFromBufferCopied::MaiscBufferCopied(TInt aError, const TDesC8& aBuffer)
|
|
2940 |
{
|
|
2941 |
CTestStepAudInStreamAsyncTestStep::MaiscBufferCopied(aError, aBuffer);
|
|
2942 |
if(iTestState == EStateRequestStop)
|
|
2943 |
{
|
|
2944 |
iTestState = EStateStopping;
|
|
2945 |
iAudInStream->Stop();
|
|
2946 |
iTestState = EStateStopTest;
|
|
2947 |
Fsm();
|
|
2948 |
}
|
|
2949 |
}
|
|
2950 |
|
|
2951 |
void CTestStepAudInStreamTestStopFromBufferCopied::Fsm()
|
|
2952 |
{
|
|
2953 |
switch (iTestState)
|
|
2954 |
{
|
|
2955 |
case EStateOpen:
|
|
2956 |
{
|
|
2957 |
iAudInStream->Open(NULL);
|
|
2958 |
iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
|
|
2959 |
iTrigger->StartTimer(500000);
|
|
2960 |
iTestState = EStateRecordInit;
|
|
2961 |
break;
|
|
2962 |
}
|
|
2963 |
case EStateRecordInit:
|
|
2964 |
{
|
|
2965 |
// start the recording process
|
|
2966 |
for (TInt i=0; i<KNumBuffers; i++)
|
|
2967 |
{
|
|
2968 |
TRAPD(err, iAudInStream->ReadL(iBufferList[i]));
|
|
2969 |
if(err)
|
|
2970 |
{
|
|
2971 |
INFO_PRINTF2(_L("ReadL failed with error[%d]."), err);
|
|
2972 |
StopTest(err, EFail);
|
|
2973 |
return;
|
|
2974 |
}
|
|
2975 |
}
|
|
2976 |
|
|
2977 |
// start the timer
|
|
2978 |
iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
|
|
2979 |
iTrigger->StartTimer(500000);
|
|
2980 |
iTestState = EStateRecord;
|
|
2981 |
break;
|
|
2982 |
}
|
|
2983 |
case EStateRecord:
|
|
2984 |
{
|
|
2985 |
// Just wating time here...for the record process to continue
|
|
2986 |
// start the timer
|
|
2987 |
iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
|
|
2988 |
iTestState = EStateRequestStop;
|
|
2989 |
break;
|
|
2990 |
}
|
|
2991 |
case EStateStopTest:
|
|
2992 |
{
|
|
2993 |
INFO_PRINTF3(_L("Used %d buffers of %d."), iBufferCount, KRecNumBuffer);
|
|
2994 |
StopTest(); // success
|
|
2995 |
break;
|
|
2996 |
}
|
|
2997 |
default:
|
|
2998 |
INFO_PRINTF1(_L("State machine error"));
|
|
2999 |
StopTest(KErrGeneral, EFail);
|
|
3000 |
break;
|
|
3001 |
}
|
|
3002 |
}
|
|
3003 |
|
|
3004 |
|
|
3005 |
//
|
|
3006 |
|
|
3007 |
/**
|
|
3008 |
*
|
|
3009 |
**/
|
|
3010 |
|
|
3011 |
CTestStepAudInStreamDestroy* CTestStepAudInStreamDestroy::NewL(CTestSuite* aSuite)
|
|
3012 |
{
|
|
3013 |
return new (ELeave) CTestStepAudInStreamDestroy(aSuite);
|
|
3014 |
}
|
|
3015 |
|
|
3016 |
CTestStepAudInStreamDestroy::CTestStepAudInStreamDestroy(CTestSuite* aSuite)
|
|
3017 |
: CTestStepAudInStreamAsyncTestStep(aSuite)
|
|
3018 |
{
|
|
3019 |
iTestStepName = _L("MM-MMF-ACLNT-U-0985-CP");
|
|
3020 |
}
|
|
3021 |
|
|
3022 |
void CTestStepAudInStreamDestroy::MaiscBufferCopied(TInt aError, const TDesC8& aBuffer)
|
|
3023 |
{
|
|
3024 |
INFO_PRINTF2(_L("*MaiscBufferCopied* Error: %d."), aError);
|
|
3025 |
if (aError==KErrNone && aBuffer.Length())
|
|
3026 |
{
|
|
3027 |
++iBufferCount;
|
|
3028 |
}
|
|
3029 |
|
|
3030 |
else
|
|
3031 |
{
|
|
3032 |
if (aError == KErrAbort)
|
|
3033 |
{
|
|
3034 |
INFO_PRINTF1(_L("Unexpected call back Received when input stream has been deleted"));
|
|
3035 |
}
|
|
3036 |
StopTest(aError, EFail);
|
|
3037 |
|
|
3038 |
}
|
|
3039 |
}
|
|
3040 |
|
|
3041 |
void CTestStepAudInStreamDestroy::Fsm()
|
|
3042 |
{
|
|
3043 |
switch (iTestState)
|
|
3044 |
{
|
|
3045 |
case EStateOpen:
|
|
3046 |
{
|
|
3047 |
iAudInStream->Open(NULL);
|
|
3048 |
iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
|
|
3049 |
iTrigger->StartTimer(500000);
|
|
3050 |
iTestState = EStateRecordInit;
|
|
3051 |
break;
|
|
3052 |
}
|
|
3053 |
case EStateRecordInit:
|
|
3054 |
{
|
|
3055 |
// start the recording process
|
|
3056 |
for (TInt i=0; i<KNumBuffers; i++)
|
|
3057 |
{
|
|
3058 |
TRAPD(err, iAudInStream->ReadL(iBufferList[i]));
|
|
3059 |
if(err)
|
|
3060 |
{
|
|
3061 |
INFO_PRINTF2(_L("ReadL failed with error[%d]."), err);
|
|
3062 |
StopTest(err, EFail);
|
|
3063 |
return;
|
|
3064 |
}
|
|
3065 |
}
|
|
3066 |
|
|
3067 |
// start the timer
|
|
3068 |
iTrigger->Cancel(); // ensure assert in StartTimer always succeeds
|
|
3069 |
iTrigger->StartTimer(1000000);
|
|
3070 |
iTestState = EStateStopTest;
|
|
3071 |
break;
|
|
3072 |
}
|
|
3073 |
|
|
3074 |
case EStateStopTest:
|
|
3075 |
{
|
|
3076 |
//Now call delete to invoke the destructor
|
|
3077 |
INFO_PRINTF1(_L("Deleting Input Stream"));
|
|
3078 |
delete iAudInStream;
|
|
3079 |
iAudInStream=NULL;
|
|
3080 |
INFO_PRINTF3(_L("Used %d buffers of %d."), iBufferCount, KNumBuffers);
|
|
3081 |
StopTest(); // success
|
|
3082 |
break;
|
|
3083 |
}
|
|
3084 |
default:
|
|
3085 |
INFO_PRINTF1(_L("State machine error"));
|
|
3086 |
StopTest(KErrGeneral, EFail);
|
|
3087 |
break;
|
|
3088 |
}
|
|
3089 |
}
|