|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This file contains an example Test step implementation |
|
15 // This demonstrates the various functions provided |
|
16 // by the CTestStep base class which are available within |
|
17 // a test step |
|
18 // |
|
19 // |
|
20 |
|
21 // EPOC includes |
|
22 #include <e32base.h> |
|
23 #include <e32test.h> |
|
24 #include <e32keys.h> |
|
25 #include <c32comm.h> |
|
26 #include <f32file.h> |
|
27 #include <etel.h> |
|
28 #include <etelmm.h> |
|
29 #include <testframework.h> |
|
30 |
|
31 //#include <MdaAudioSamplePlayer.h> |
|
32 #include <mdaaudiosampleeditor.h> |
|
33 #include <mdaaudiotoneplayer.h> |
|
34 |
|
35 // Test system includes |
|
36 #include <testframework.h> |
|
37 |
|
38 // Specific includes for this test suite |
|
39 #include "TestStepUnitMMFAudClient.h" |
|
40 #include "TestSuiteUnitMMFAudClient.h" |
|
41 |
|
42 // Specific includes for these test steps |
|
43 #include "TestStepRecorder.h" |
|
44 |
|
45 |
|
46 #include "MmfAudioController.h" |
|
47 #include "mmfclientaudiorecorder.h" |
|
48 // -------------------------------------------- |
|
49 // -------------------------------------------- |
|
50 |
|
51 /** |
|
52 * |
|
53 * Static constructor for CTestStepRecorderSimultaneousPlay1. |
|
54 * |
|
55 * |
|
56 * @return "CTestStepRecorderSimultaneousPlay1*" |
|
57 * The constructed CTestStepRecorderSimultaneousPlay1 |
|
58 * |
|
59 * @xxxx |
|
60 * |
|
61 */ |
|
62 CTestStepRecorderSimultaneousPlay1* CTestStepRecorderSimultaneousPlay1::NewL() |
|
63 { |
|
64 CTestStepRecorderSimultaneousPlay1* self = new(ELeave) CTestStepRecorderSimultaneousPlay1; |
|
65 return self; |
|
66 } |
|
67 |
|
68 /** |
|
69 * |
|
70 * Test step constructor. |
|
71 * Each test step initialises its own name. |
|
72 * |
|
73 * @xxxx |
|
74 * |
|
75 */ |
|
76 CTestStepRecorderSimultaneousPlay1::CTestStepRecorderSimultaneousPlay1() |
|
77 { |
|
78 // store the name of this test case |
|
79 // this is the name that is used by the script file |
|
80 iTestStepName = _L("MM-MMF-ACLNT-U-0810-HP"); |
|
81 } |
|
82 |
|
83 /** |
|
84 * |
|
85 * Test step destructor. |
|
86 * |
|
87 * @xxxx |
|
88 * |
|
89 */ |
|
90 CTestStepRecorderSimultaneousPlay1::~CTestStepRecorderSimultaneousPlay1() |
|
91 { |
|
92 } |
|
93 |
|
94 /** |
|
95 * |
|
96 * Test step Close |
|
97 * handles all deletion |
|
98 * @xxxx |
|
99 * |
|
100 */ |
|
101 void CTestStepRecorderSimultaneousPlay1::Close() |
|
102 { |
|
103 } |
|
104 |
|
105 /** |
|
106 * |
|
107 * Test step Preamble. |
|
108 * |
|
109 * @xxxx |
|
110 * |
|
111 */ |
|
112 enum TVerdict CTestStepRecorderSimultaneousPlay1::DoTestStepPreambleL(void) |
|
113 { |
|
114 TVerdict verdict; |
|
115 // this installs the scheduler |
|
116 verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL(); |
|
117 |
|
118 // Printing to the console and log file |
|
119 INFO_PRINTF2(_L("%S"), &iTestStepName); |
|
120 INFO_PRINTF1(_L("this is a test of calling CMdaAudioRecorderUtility::PlayL() while a tone is playing")); |
|
121 |
|
122 if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName2"), iFileName)) // wav file |
|
123 { |
|
124 return EInconclusive; |
|
125 } |
|
126 |
|
127 return verdict; |
|
128 } |
|
129 |
|
130 /** |
|
131 * |
|
132 * Test step Postamble. |
|
133 * |
|
134 * @xxxx |
|
135 * |
|
136 */ |
|
137 enum TVerdict CTestStepRecorderSimultaneousPlay1::DoTestStepPostambleL(void) |
|
138 { |
|
139 //[ Destroy the scheduler ] |
|
140 return CTestStepUnitMMFAudClient::DoTestStepPostambleL(); |
|
141 } |
|
142 |
|
143 /** |
|
144 * |
|
145 * Callback Handle. |
|
146 * |
|
147 * @xxxx |
|
148 * |
|
149 */ |
|
150 void CTestStepRecorderSimultaneousPlay1::MoscoStateChangeEvent(CBase* aObject, |
|
151 TInt aPreviousState, |
|
152 TInt aCurrentState, |
|
153 TInt aErrorCode) |
|
154 { |
|
155 INFO_PRINTF5(_L("MoscoStateChangeEvent(object=0x%08x, ps=%d, cs=%d, error = %d)"), |
|
156 aObject, |
|
157 aPreviousState, |
|
158 aCurrentState, |
|
159 aErrorCode); |
|
160 iError = aErrorCode; |
|
161 iCurrentState = aCurrentState; |
|
162 CActiveScheduler::Stop(); |
|
163 } |
|
164 |
|
165 |
|
166 void CTestStepRecorderSimultaneousPlay1::MatoPrepareComplete(TInt aError) |
|
167 { |
|
168 INFO_PRINTF2(_L("MatoPrepareComplete(): error = %d"), aError); |
|
169 iErrorTone = aError; |
|
170 CActiveScheduler::Stop(); |
|
171 } |
|
172 |
|
173 void CTestStepRecorderSimultaneousPlay1::MatoPlayComplete(TInt aError) |
|
174 { |
|
175 INFO_PRINTF2(_L("MatoPlayComplete(): error = %d"), aError); |
|
176 iErrorTone = aError; |
|
177 CActiveScheduler::Stop(); |
|
178 } |
|
179 |
|
180 /** |
|
181 * |
|
182 * Do the test step. |
|
183 * Each test step must supply an implementation for DoTestStepL. |
|
184 * |
|
185 * @return "TVerdict" |
|
186 * The result of the test step |
|
187 * |
|
188 * @xxxx |
|
189 * |
|
190 */ |
|
191 TVerdict CTestStepRecorderSimultaneousPlay1::DoTestStepL() |
|
192 { |
|
193 iTestStepResult = EFail; |
|
194 |
|
195 iToneUtility = CMdaAudioToneUtility::NewL(*this); |
|
196 CleanupStack::PushL(iToneUtility); |
|
197 |
|
198 iRecorderUtility = CMdaAudioRecorderUtility::NewL(*this); |
|
199 CleanupStack::PushL(iRecorderUtility); |
|
200 |
|
201 do |
|
202 { |
|
203 // open the sound file |
|
204 INFO_PRINTF1( _L("Initialize CMdaAudioRecorderUtility")); |
|
205 iRecorderUtility->OpenFileL(iFileName); |
|
206 CActiveScheduler::Start(); |
|
207 if (iCurrentState != CMdaAudioRecorderUtility::EOpen) |
|
208 { |
|
209 break; |
|
210 } |
|
211 |
|
212 // prepare the tone |
|
213 INFO_PRINTF1( _L("Initialize CMdaAudioToneUtility")); |
|
214 iToneUtility->PrepareToPlayTone(KToneFrequency, TTimeIntervalMicroSeconds(KTwoSeconds)); |
|
215 // Wait for prepare |
|
216 iErrorTone = KErrGeneral; // set so we know callback has occurred |
|
217 CActiveScheduler::Start(); |
|
218 if (iErrorTone != KErrNone) |
|
219 { |
|
220 break; |
|
221 } |
|
222 |
|
223 // start playing the tone & wait 0.25 secs to make sure it gets started |
|
224 INFO_PRINTF1( _L("Playing tone...")); |
|
225 iToneUtility->Play(); |
|
226 User::After(KQuarterScond); |
|
227 |
|
228 // start playing the file |
|
229 INFO_PRINTF1( _L("Playing sound file...")); |
|
230 iRecorderUtility->PlayL(); |
|
231 // wait once for start of play |
|
232 // NB this "EPlaying" callback does not occur in 6.1 ! |
|
233 CActiveScheduler::Start(); |
|
234 if ((iError != KErrNone) || (iCurrentState != CMdaAudioRecorderUtility::EPlaying)) |
|
235 { |
|
236 break; |
|
237 } |
|
238 |
|
239 // wait once for end of play - this should produce KErrInUse |
|
240 INFO_PRINTF1( _L("Waiting for end of play...")); |
|
241 CActiveScheduler::Start(); |
|
242 if ((iError != KErrInUse) || (iCurrentState != CMdaAudioRecorderUtility::EOpen)) |
|
243 { |
|
244 break; |
|
245 } |
|
246 // wait once tone to finsh playing |
|
247 CActiveScheduler::Start(); |
|
248 |
|
249 // now that the tone player has finished, try playing |
|
250 // the sound file again (this should work now) |
|
251 |
|
252 INFO_PRINTF1( _L("Calling iRecorderUtility->PlayL...")); |
|
253 iRecorderUtility->PlayL(); |
|
254 // wait once for start of play |
|
255 CActiveScheduler::Start(); |
|
256 if ((iError != KErrNone) || (iCurrentState != CMdaAudioRecorderUtility::EPlaying)) |
|
257 { |
|
258 break; |
|
259 } |
|
260 |
|
261 // wait once for end of play - this should produce KErrNone |
|
262 CActiveScheduler::Start(); |
|
263 if ((iError != KErrNone) || (iCurrentState != CMdaAudioRecorderUtility::EOpen)) |
|
264 { |
|
265 break; |
|
266 } |
|
267 |
|
268 iTestStepResult = EPass; |
|
269 } |
|
270 while (EFalse); |
|
271 |
|
272 CleanupStack::PopAndDestroy(iRecorderUtility); |
|
273 CleanupStack::PopAndDestroy(iToneUtility); |
|
274 iRecorderUtility = NULL; |
|
275 iToneUtility = NULL; |
|
276 |
|
277 INFO_PRINTF1(_L("finished with this test step")); |
|
278 |
|
279 // test steps return a result |
|
280 return iTestStepResult; |
|
281 } |
|
282 |
|
283 // |
|
284 |
|
285 |
|
286 /** |
|
287 * |
|
288 * Static constructor for CTestStepRecorderSimultaneousPlay2. |
|
289 * |
|
290 * |
|
291 * @return "CTestStepRecorderSimultaneousPlay2*" |
|
292 * The constructed CTestStepRecorderSimultaneousPlay2 |
|
293 * |
|
294 * @xxxx |
|
295 * |
|
296 */ |
|
297 CTestStepRecorderSimultaneousPlay2* CTestStepRecorderSimultaneousPlay2::NewL() |
|
298 { |
|
299 CTestStepRecorderSimultaneousPlay2* self = new(ELeave) CTestStepRecorderSimultaneousPlay2; |
|
300 return self; |
|
301 } |
|
302 |
|
303 /** |
|
304 * |
|
305 * Test step constructor. |
|
306 * Each test step initialises its own name. |
|
307 * |
|
308 * @xxxx |
|
309 * |
|
310 */ |
|
311 CTestStepRecorderSimultaneousPlay2::CTestStepRecorderSimultaneousPlay2() |
|
312 { |
|
313 // store the name of this test case |
|
314 // this is the name that is used by the script file |
|
315 iTestStepName = _L("MM-MMF-ACLNT-U-0811-HP"); |
|
316 } |
|
317 |
|
318 /** |
|
319 * |
|
320 * Test step destructor. |
|
321 * |
|
322 * @xxxx |
|
323 * |
|
324 */ |
|
325 CTestStepRecorderSimultaneousPlay2::~CTestStepRecorderSimultaneousPlay2() |
|
326 { |
|
327 } |
|
328 |
|
329 /** |
|
330 * |
|
331 * Test step Close |
|
332 * handles all deletion |
|
333 * |
|
334 * @xxxx |
|
335 * |
|
336 */ |
|
337 void CTestStepRecorderSimultaneousPlay2::Close() |
|
338 { |
|
339 delete iToneUtility; |
|
340 delete iRecorderUtility; |
|
341 } |
|
342 |
|
343 |
|
344 /** |
|
345 * |
|
346 * Test step Preamble. |
|
347 * |
|
348 * @xxxx |
|
349 * |
|
350 */ |
|
351 enum TVerdict CTestStepRecorderSimultaneousPlay2::DoTestStepPreambleL(void) |
|
352 { |
|
353 TInt err; |
|
354 |
|
355 TVerdict verdict; |
|
356 // this installs the scheduler |
|
357 verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL(); |
|
358 |
|
359 // Printing to the console and log file |
|
360 INFO_PRINTF2(_L("%S"), &iTestStepName); |
|
361 INFO_PRINTF1(_L("this is a test of playing a high priority tone over a low priority .wav file")); |
|
362 |
|
363 if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName2"), iFileName)) // wav file |
|
364 { |
|
365 return EInconclusive; |
|
366 } |
|
367 |
|
368 // create a record utility |
|
369 TRAP(err, iRecorderUtility = CMdaAudioRecorderUtility::NewL(*this, NULL, EMdaPriorityMin)); |
|
370 if (err != KErrNone) |
|
371 return EInconclusive; |
|
372 // create a tone utility |
|
373 TRAP(err, iToneUtility = CMdaAudioToneUtility::NewL(*this, NULL, EMdaPriorityMax)); |
|
374 if (err != KErrNone) |
|
375 return EInconclusive; |
|
376 |
|
377 return verdict; |
|
378 |
|
379 } |
|
380 |
|
381 /** |
|
382 * |
|
383 * Test step Postamble. |
|
384 * |
|
385 * @xxxx |
|
386 * |
|
387 */ |
|
388 enum TVerdict CTestStepRecorderSimultaneousPlay2::DoTestStepPostambleL(void) |
|
389 { |
|
390 //[ Destroy the scheduler ] |
|
391 return CTestStepUnitMMFAudClient::DoTestStepPostambleL(); |
|
392 } |
|
393 |
|
394 /** |
|
395 * |
|
396 * Callback Handle. |
|
397 * |
|
398 * @xxxx |
|
399 * |
|
400 */ |
|
401 void CTestStepRecorderSimultaneousPlay2::MoscoStateChangeEvent(CBase* /*aObject*/, |
|
402 TInt aPreviousState, |
|
403 TInt aCurrentState, |
|
404 TInt aErrorCode) |
|
405 { |
|
406 INFO_PRINTF4(_L("MoscoStateChangeEvent(): Previous state = %d, current state = %d, error = %d"), |
|
407 aPreviousState, |
|
408 aCurrentState, |
|
409 aErrorCode); |
|
410 iError = aErrorCode; |
|
411 iCurrentState = aCurrentState; |
|
412 CActiveScheduler::Stop(); |
|
413 } |
|
414 |
|
415 |
|
416 void CTestStepRecorderSimultaneousPlay2::MatoPrepareComplete(TInt aError) |
|
417 { |
|
418 INFO_PRINTF2(_L("MatoPrepareComplete(): error = %d"), aError); |
|
419 iErrorTone = aError; |
|
420 CActiveScheduler::Stop(); |
|
421 } |
|
422 |
|
423 void CTestStepRecorderSimultaneousPlay2::MatoPlayComplete(TInt aError) |
|
424 { |
|
425 INFO_PRINTF2(_L("MatoPlayComplete(): error = %d"), aError); |
|
426 iErrorTone = aError; |
|
427 CActiveScheduler::Stop(); |
|
428 } |
|
429 |
|
430 /** |
|
431 * |
|
432 * Do the test step. |
|
433 * Each test step must supply an implementation for DoTestStepL. |
|
434 * |
|
435 * @return "TVerdict" |
|
436 * The result of the test step |
|
437 * |
|
438 * @xxxx |
|
439 * |
|
440 */ |
|
441 TVerdict CTestStepRecorderSimultaneousPlay2::DoTestStepL() |
|
442 { |
|
443 iTestStepResult = EPass; |
|
444 TInt err = KErrNone; |
|
445 |
|
446 // open the sound file |
|
447 INFO_PRINTF1( _L("Initialize CMdaAudioRecorderUtility")); |
|
448 TRAP(err, iRecorderUtility->OpenFileL(iFileName)); |
|
449 if (err != KErrNone) |
|
450 return EInconclusive; |
|
451 |
|
452 // wait for open to complete |
|
453 CActiveScheduler::Start(); |
|
454 if (!(iError == KErrNone && iCurrentState == CMdaAudioRecorderUtility::EOpen)) |
|
455 { |
|
456 iTestStepResult = EFail; |
|
457 return iTestStepResult; |
|
458 } |
|
459 |
|
460 // prepare the tone |
|
461 INFO_PRINTF1( _L("Initialize CMdaAudioToneUtility")); |
|
462 iToneUtility->PrepareToPlayTone(KToneFrequency,TTimeIntervalMicroSeconds(KTwoSeconds)); |
|
463 // Wait for prepare |
|
464 iErrorTone = KErrGeneral; // set so we know tone callback has occurred |
|
465 CActiveScheduler::Start(); |
|
466 if (iErrorTone != KErrNone) |
|
467 { |
|
468 iTestStepResult = EFail; |
|
469 return iTestStepResult; |
|
470 } |
|
471 |
|
472 // start playing the file and give it time to start |
|
473 INFO_PRINTF1( _L("Playing sound file (1)...low priority")); |
|
474 TRAP(err, iRecorderUtility->PlayL()); |
|
475 if (err != KErrNone) |
|
476 return EInconclusive; |
|
477 CActiveScheduler::Start(); |
|
478 if (!(iError == KErrNone && iCurrentState == CMdaAudioRecorderUtility::EPlaying)) |
|
479 { |
|
480 iTestStepResult = EFail; |
|
481 return iTestStepResult; |
|
482 } |
|
483 User::After(KQuarterScond); |
|
484 |
|
485 |
|
486 // start playing the tone and wait for completion |
|
487 // Two observer callbacks to catch here: |
|
488 // One is high priority tone starting playing, and the other is the low |
|
489 // priority recorder being kicked off. We are ignoring the order of these. |
|
490 INFO_PRINTF1( _L("Playing tone...high priority")); |
|
491 iToneUtility->Play(); |
|
492 iErrorTone = KErrGeneral; // set so we know tone callback has occurred |
|
493 CActiveScheduler::Start(); |
|
494 if (!(iError == KErrInUse && iCurrentState == CMdaAudioRecorderUtility::EOpen) && |
|
495 !(iErrorTone == KErrNone)) |
|
496 { |
|
497 iTestStepResult = EFail; |
|
498 return iTestStepResult; |
|
499 } |
|
500 iErrorTone = KErrGeneral; // set so we know tone callback has occurred |
|
501 CActiveScheduler::Start(); |
|
502 if (!(iError == KErrInUse && iCurrentState == CMdaAudioRecorderUtility::EOpen) && |
|
503 !(iErrorTone == KErrNone)) |
|
504 { |
|
505 iTestStepResult = EFail; |
|
506 return iTestStepResult; |
|
507 } |
|
508 |
|
509 |
|
510 // start playing the file again and wait for completion |
|
511 INFO_PRINTF1( _L("Playing sound file (2)...low priority")); |
|
512 TRAP(err, iRecorderUtility->PlayL()); |
|
513 if (err != KErrNone) |
|
514 return EInconclusive; |
|
515 CActiveScheduler::Start(); |
|
516 if (!(iError == KErrNone && iCurrentState == CMdaAudioRecorderUtility::EPlaying)) |
|
517 { |
|
518 iTestStepResult = EFail; |
|
519 return iTestStepResult; |
|
520 } |
|
521 |
|
522 // Wait for end of play |
|
523 CActiveScheduler::Start(); |
|
524 if (!(iError == KErrNone && iCurrentState == CMdaAudioRecorderUtility::EOpen)) |
|
525 { |
|
526 iTestStepResult = EFail; |
|
527 return iTestStepResult; |
|
528 } |
|
529 |
|
530 INFO_PRINTF1(_L("finished with this test step")); |
|
531 |
|
532 // test steps return a result |
|
533 return iTestStepResult; |
|
534 } |
|
535 |
|
536 |
|
537 // |
|
538 |
|
539 |
|
540 /** |
|
541 * |
|
542 * Static constructor for CTestStepRecorderSimultaneousPlay3. |
|
543 * |
|
544 * |
|
545 * @return "CTestStepRecorderSimultaneousPlay3*" |
|
546 * The constructed CTestStepRecorderSimultaneousPlay3 |
|
547 * |
|
548 * @xxxx |
|
549 * |
|
550 */ |
|
551 CTestStepRecorderSimultaneousPlay3* CTestStepRecorderSimultaneousPlay3::NewL() |
|
552 { |
|
553 CTestStepRecorderSimultaneousPlay3* self = new(ELeave) CTestStepRecorderSimultaneousPlay3; |
|
554 return self; |
|
555 } |
|
556 |
|
557 /** |
|
558 * |
|
559 * Test step constructor. |
|
560 * Each test step initialises its own name. |
|
561 * |
|
562 * @xxxx |
|
563 * |
|
564 */ |
|
565 CTestStepRecorderSimultaneousPlay3::CTestStepRecorderSimultaneousPlay3() |
|
566 { |
|
567 // store the name of this test case |
|
568 // this is the name that is used by the script file |
|
569 iTestStepName = _L("MM-MMF-ACLNT-U-0812-HP"); |
|
570 } |
|
571 |
|
572 /** |
|
573 * |
|
574 * Test step destructor. |
|
575 * |
|
576 * @xxxx |
|
577 * |
|
578 */ |
|
579 CTestStepRecorderSimultaneousPlay3::~CTestStepRecorderSimultaneousPlay3() |
|
580 { |
|
581 } |
|
582 |
|
583 /** |
|
584 * |
|
585 * Test step destructor. |
|
586 * |
|
587 * @xxxx |
|
588 * |
|
589 */ |
|
590 void CTestStepRecorderSimultaneousPlay3::Close() |
|
591 { |
|
592 delete iRecorderUtility1; |
|
593 delete iRecorderUtility2; |
|
594 } |
|
595 |
|
596 /** |
|
597 * |
|
598 * Test step Preamble. |
|
599 * |
|
600 * @xxxx |
|
601 * |
|
602 */ |
|
603 enum TVerdict CTestStepRecorderSimultaneousPlay3::DoTestStepPreambleL(void) |
|
604 { |
|
605 TInt err; |
|
606 |
|
607 TVerdict verdict; |
|
608 // this installs the scheduler |
|
609 verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL(); |
|
610 |
|
611 // Printing to the console and log file |
|
612 INFO_PRINTF2(_L("%S"), &iTestStepName); |
|
613 INFO_PRINTF1(_L("this is a test of playing a high priority .wav file over a low priority .wav file")); |
|
614 |
|
615 if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName2"), iFileName1)) // long wav file |
|
616 { |
|
617 return EInconclusive; |
|
618 } |
|
619 |
|
620 if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName1"), iFileName2)) // short wav file |
|
621 { |
|
622 return EInconclusive; |
|
623 } |
|
624 |
|
625 // create record utilities. A low priority and a high priority |
|
626 TRAP(err, iRecorderUtility1 = CMdaAudioRecorderUtility::NewL(*this, NULL, EMdaPriorityMin)); |
|
627 if (err != KErrNone) |
|
628 return EInconclusive; |
|
629 |
|
630 TRAP(err, iRecorderUtility2 = CMdaAudioRecorderUtility::NewL(*this, NULL, EMdaPriorityMax)); |
|
631 if (err != KErrNone) |
|
632 return EInconclusive; |
|
633 |
|
634 return verdict; |
|
635 |
|
636 } |
|
637 |
|
638 /** |
|
639 * |
|
640 * Test step Postamble. |
|
641 * |
|
642 * @xxxx |
|
643 * |
|
644 */ |
|
645 enum TVerdict CTestStepRecorderSimultaneousPlay3::DoTestStepPostambleL(void) |
|
646 { |
|
647 //[ Destroy the scheduler ] |
|
648 return CTestStepUnitMMFAudClient::DoTestStepPostambleL(); |
|
649 } |
|
650 |
|
651 /** |
|
652 * |
|
653 * Callback Handle. |
|
654 * |
|
655 * @xxxx |
|
656 * |
|
657 */ |
|
658 void CTestStepRecorderSimultaneousPlay3::MoscoStateChangeEvent(CBase* /*aObject*/, |
|
659 TInt aPreviousState, |
|
660 TInt aCurrentState, |
|
661 TInt aErrorCode) |
|
662 { |
|
663 INFO_PRINTF4(_L("MoscoStateChangeEvent(): Previous state = %d, current state = %d, error = %d"), |
|
664 aPreviousState, |
|
665 aCurrentState, |
|
666 aErrorCode); |
|
667 iError = aErrorCode; |
|
668 iCurrentState = aCurrentState; |
|
669 CActiveScheduler::Stop(); |
|
670 } |
|
671 |
|
672 |
|
673 /** |
|
674 * |
|
675 * Do the test step. |
|
676 * Each test step must supply an implementation for DoTestStepL. |
|
677 * |
|
678 * @return "TVerdict" |
|
679 * The result of the test step |
|
680 * |
|
681 * @xxxx |
|
682 * |
|
683 */ |
|
684 TVerdict CTestStepRecorderSimultaneousPlay3::DoTestStepL() |
|
685 { |
|
686 iTestStepResult = EPass; |
|
687 TInt err = KErrNone; |
|
688 |
|
689 // open the sound file |
|
690 INFO_PRINTF1( _L("Initialize CMdaAudioRecorderUtility1")); |
|
691 TRAP(err, iRecorderUtility1->OpenFileL(iFileName1)); |
|
692 if (err != KErrNone) |
|
693 return EInconclusive; |
|
694 // wait for open to complete |
|
695 CActiveScheduler::Start(); |
|
696 if (iCurrentState != CMdaAudioRecorderUtility::EOpen) |
|
697 return EFail; |
|
698 |
|
699 // open the sound file |
|
700 INFO_PRINTF1( _L("Initialize CMdaAudioRecorderUtility2")); |
|
701 TRAP(err, iRecorderUtility2->OpenFileL(iFileName2)); |
|
702 if (err != KErrNone) |
|
703 return EInconclusive; |
|
704 // wait for open to complete |
|
705 CActiveScheduler::Start(); |
|
706 if (iCurrentState != CMdaAudioRecorderUtility::EOpen) |
|
707 return EFail; |
|
708 |
|
709 // start playing the first file and give it time to start |
|
710 INFO_PRINTF1( _L("Playing sound file (1)...low priority")); |
|
711 TRAP(err, iRecorderUtility1->PlayL()); |
|
712 if (err != KErrNone) |
|
713 return EInconclusive; |
|
714 CActiveScheduler::Start(); |
|
715 if (!(iError == KErrNone && iCurrentState == CMdaAudioRecorderUtility::EPlaying)) |
|
716 { |
|
717 iTestStepResult = EFail; |
|
718 return iTestStepResult; |
|
719 } |
|
720 User::After(KQuarterScond); |
|
721 |
|
722 // start playing the second file and wait for completion |
|
723 // Two observer callbacks to catch here: |
|
724 // One is high priority recorder starting playing, and the other is the low |
|
725 // priority recorder being kicked off. We are ignoring the order of these. |
|
726 INFO_PRINTF1( _L("Playing sound file (2)...high priority")); |
|
727 TRAP(err, iRecorderUtility2->PlayL()); |
|
728 if (err != KErrNone) |
|
729 return EFail; |
|
730 CActiveScheduler::Start(); |
|
731 if (!(iError == KErrInUse && iCurrentState == CMdaAudioRecorderUtility::EOpen) && |
|
732 !(iError == KErrNone && iCurrentState == CMdaAudioRecorderUtility::EPlaying)) |
|
733 { |
|
734 iTestStepResult = EFail; |
|
735 return iTestStepResult; |
|
736 } |
|
737 CActiveScheduler::Start(); |
|
738 if (!(iError == KErrInUse && iCurrentState == CMdaAudioRecorderUtility::EOpen) && |
|
739 !(iError == KErrNone && iCurrentState == CMdaAudioRecorderUtility::EPlaying)) |
|
740 { |
|
741 iTestStepResult = EFail; |
|
742 return iTestStepResult; |
|
743 } |
|
744 |
|
745 // Wait for end of play for file 2 |
|
746 CActiveScheduler::Start(); |
|
747 if (!(iError == KErrNone && iCurrentState == CMdaAudioRecorderUtility::EOpen)) |
|
748 { |
|
749 iTestStepResult = EFail; |
|
750 return iTestStepResult; |
|
751 } |
|
752 |
|
753 // start playing the first file again and wait for completion |
|
754 INFO_PRINTF1( _L("Playing sound file (3)...low priority")); |
|
755 TRAP(err, iRecorderUtility1->PlayL()); |
|
756 if (err != KErrNone) |
|
757 return EFail; |
|
758 CActiveScheduler::Start(); |
|
759 if (!(iError == KErrNone && iCurrentState == CMdaAudioRecorderUtility::EPlaying)) |
|
760 { |
|
761 iTestStepResult = EFail; |
|
762 return iTestStepResult; |
|
763 } |
|
764 User::After(KQuarterScond); |
|
765 |
|
766 // Wait for end of play |
|
767 CActiveScheduler::Start(); |
|
768 if (!(iError == KErrNone && iCurrentState == CMdaAudioRecorderUtility::EOpen)) |
|
769 { |
|
770 iTestStepResult = EFail; |
|
771 return iTestStepResult; |
|
772 } |
|
773 |
|
774 INFO_PRINTF1(_L("finished with this test step")); |
|
775 |
|
776 // test steps return a result |
|
777 return iTestStepResult; |
|
778 } |
|
779 |
|
780 |
|
781 // |
|
782 |
|
783 |
|
784 /** |
|
785 * |
|
786 * Static constructor for CTestStepRecorderSimultaneousPlay4. |
|
787 * |
|
788 * |
|
789 * @return "CTestStepRecorderSimultaneousPlay4*" |
|
790 * The constructed CTestStepRecorderSimultaneousPlay4 |
|
791 * |
|
792 * @xxxx |
|
793 * |
|
794 */ |
|
795 CTestStepRecorderSimultaneousPlay4* CTestStepRecorderSimultaneousPlay4::NewL() |
|
796 { |
|
797 CTestStepRecorderSimultaneousPlay4* self = new(ELeave) CTestStepRecorderSimultaneousPlay4; |
|
798 return self; |
|
799 } |
|
800 |
|
801 /** |
|
802 * |
|
803 * Test step constructor. |
|
804 * Each test step initialises its own name. |
|
805 * |
|
806 * @xxxx |
|
807 * |
|
808 */ |
|
809 CTestStepRecorderSimultaneousPlay4::CTestStepRecorderSimultaneousPlay4() |
|
810 { |
|
811 // store the name of this test case |
|
812 // this is the name that is used by the script file |
|
813 iTestStepName = _L("MM-MMF-ACLNT-U-0813-HP"); |
|
814 } |
|
815 |
|
816 /** |
|
817 * |
|
818 * Test step destructor. |
|
819 * |
|
820 * @xxxx |
|
821 * |
|
822 */ |
|
823 CTestStepRecorderSimultaneousPlay4::~CTestStepRecorderSimultaneousPlay4() |
|
824 { |
|
825 } |
|
826 |
|
827 /** |
|
828 * |
|
829 * Test step Close |
|
830 * handles all deletion |
|
831 * @xxxx |
|
832 * |
|
833 */ |
|
834 void CTestStepRecorderSimultaneousPlay4::Close() |
|
835 { |
|
836 delete iRecorderUtility1; |
|
837 delete iRecorderUtility2; |
|
838 } |
|
839 |
|
840 /** |
|
841 * |
|
842 * Test step Preamble. |
|
843 * |
|
844 * @xxxx |
|
845 * |
|
846 */ |
|
847 enum TVerdict CTestStepRecorderSimultaneousPlay4::DoTestStepPreambleL(void) |
|
848 { |
|
849 TInt err; |
|
850 |
|
851 TVerdict verdict; |
|
852 // this installs the scheduler |
|
853 verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL(); |
|
854 |
|
855 // Printing to the console and log file |
|
856 INFO_PRINTF2(_L("%S"), &iTestStepName); |
|
857 INFO_PRINTF1(_L("this is a test of playing a high priority .wav file over the same low priority .wav file")); |
|
858 |
|
859 if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName2"), iFileName1)) // long wav file |
|
860 { |
|
861 return EInconclusive; |
|
862 } |
|
863 |
|
864 // create record utilities. A low priority and a high priority |
|
865 TRAP(err, iRecorderUtility1 = CMdaAudioRecorderUtility::NewL(*this, NULL, EMdaPriorityMin)); |
|
866 if (err != KErrNone) |
|
867 return EInconclusive; |
|
868 |
|
869 TRAP(err, iRecorderUtility2 = CMdaAudioRecorderUtility::NewL(*this, NULL, EMdaPriorityMax)); |
|
870 if (err != KErrNone) |
|
871 return EInconclusive; |
|
872 |
|
873 return verdict; |
|
874 |
|
875 } |
|
876 |
|
877 /** |
|
878 * |
|
879 * Test step Postamble. |
|
880 * |
|
881 * @xxxx |
|
882 * |
|
883 */ |
|
884 enum TVerdict CTestStepRecorderSimultaneousPlay4::DoTestStepPostambleL(void) |
|
885 { |
|
886 //[ Destroy the scheduler ] |
|
887 return CTestStepUnitMMFAudClient::DoTestStepPostambleL(); |
|
888 } |
|
889 |
|
890 /** |
|
891 * |
|
892 * Callback Handle. |
|
893 * |
|
894 * @xxxx |
|
895 * |
|
896 */ |
|
897 void CTestStepRecorderSimultaneousPlay4::MoscoStateChangeEvent(CBase* aObject, |
|
898 TInt aPreviousState, |
|
899 TInt aCurrentState, |
|
900 TInt aErrorCode) |
|
901 { |
|
902 _LIT(KRecordUtility1, "RecorderUtility1"); |
|
903 _LIT(KRecordUtility2, "RecorderUtility2"); |
|
904 INFO_PRINTF5(_L("MoscoStateChangeEvent(): %S : Previous state = %d, current state = %d, error = %d"), |
|
905 (aObject == iRecorderUtility1)?&KRecordUtility1:&KRecordUtility2, |
|
906 aPreviousState, |
|
907 aCurrentState, |
|
908 aErrorCode); |
|
909 iError = aErrorCode; |
|
910 |
|
911 if (aObject == iRecorderUtility1) |
|
912 iCurrentState1 = aCurrentState; |
|
913 else if (aObject == iRecorderUtility2) |
|
914 iCurrentState2 = aCurrentState; |
|
915 |
|
916 |
|
917 CActiveScheduler::Stop(); |
|
918 } |
|
919 |
|
920 |
|
921 /** |
|
922 * |
|
923 * Do the test step. |
|
924 * Each test step must supply an implementation for DoTestStepL. |
|
925 * |
|
926 * @return "TVerdict" |
|
927 * The result of the test step |
|
928 * |
|
929 * @xxxx |
|
930 * |
|
931 */ |
|
932 TVerdict CTestStepRecorderSimultaneousPlay4::DoTestStepL() |
|
933 { |
|
934 iTestStepResult = EPass; |
|
935 TInt err = KErrNone; |
|
936 |
|
937 INFO_PRINTF2(_L("File to play = %S"), &iFileName1); |
|
938 |
|
939 // Get the first recorder utility to open the sound file |
|
940 INFO_PRINTF1( _L("Initialize CMdaAudioRecorderUtility1")); |
|
941 TRAP(err, iRecorderUtility1->OpenFileL(iFileName1)); |
|
942 if (err != KErrNone) |
|
943 return EInconclusive; |
|
944 // wait for open to complete |
|
945 CActiveScheduler::Start(); |
|
946 if (iCurrentState1 != CMdaAudioRecorderUtility::EOpen) |
|
947 return EFail; |
|
948 |
|
949 // start playing the first file and give it time to start |
|
950 INFO_PRINTF1( _L("Playing sound file (Utililty #1)...low priority")); |
|
951 TRAP(err, iRecorderUtility1->PlayL()); |
|
952 if (err != KErrNone) |
|
953 return EInconclusive; |
|
954 CActiveScheduler::Start(); |
|
955 if (!(iError == KErrNone && iCurrentState1 == CMdaAudioRecorderUtility::EPlaying)) |
|
956 { |
|
957 iTestStepResult = EFail; |
|
958 return iTestStepResult; |
|
959 } |
|
960 User::After(KQuarterScond); |
|
961 |
|
962 // Get the second recorder utility to open the sound file |
|
963 INFO_PRINTF1( _L("Initialize CMdaAudioRecorderUtility2")); |
|
964 TRAP(err, iRecorderUtility2->OpenFileL(iFileName1)); |
|
965 if (err != KErrNone) |
|
966 return EInconclusive; |
|
967 // wait for open to complete |
|
968 CActiveScheduler::Start(); |
|
969 if (iCurrentState2 != CMdaAudioRecorderUtility::EOpen) |
|
970 return EFail; |
|
971 |
|
972 // start playing the second file and wait for completion |
|
973 // Two observer callbacks to catch here: |
|
974 // One is high priority recorder starting playing, and the other is the low |
|
975 // priority recorder being kicked off. We are ignoring the order of these. |
|
976 INFO_PRINTF1( _L("Playing sound file (Utililty #2)...high priority")); |
|
977 TRAP(err, iRecorderUtility2->PlayL()); |
|
978 if (err != KErrNone) |
|
979 return EFail; |
|
980 CActiveScheduler::Start(); |
|
981 if (!(iError == KErrInUse && iCurrentState1 == CMdaAudioRecorderUtility::EOpen) && |
|
982 !(iError == KErrNone && iCurrentState2 == CMdaAudioRecorderUtility::EPlaying)) |
|
983 { |
|
984 iTestStepResult = EFail; |
|
985 return iTestStepResult; |
|
986 } |
|
987 CActiveScheduler::Start(); |
|
988 if (!(iError == KErrInUse && iCurrentState1 == CMdaAudioRecorderUtility::EOpen) && |
|
989 !(iError == KErrNone && iCurrentState2 == CMdaAudioRecorderUtility::EPlaying)) |
|
990 { |
|
991 iTestStepResult = EFail; |
|
992 return iTestStepResult; |
|
993 } |
|
994 |
|
995 // Wait for end of play for second recorder utility |
|
996 CActiveScheduler::Start(); |
|
997 if (!(iError == KErrNone && iCurrentState2 == CMdaAudioRecorderUtility::EOpen)) |
|
998 { |
|
999 iTestStepResult = EFail; |
|
1000 return iTestStepResult; |
|
1001 } |
|
1002 |
|
1003 // start playing the first file again and wait for completion |
|
1004 INFO_PRINTF1( _L("Playing sound file (Utililty #1 again)...low priority")); |
|
1005 TRAP(err, iRecorderUtility1->PlayL()); |
|
1006 if (err != KErrNone) |
|
1007 return EFail; |
|
1008 CActiveScheduler::Start(); |
|
1009 if (!(iError == KErrNone && iCurrentState1 == CMdaAudioRecorderUtility::EPlaying)) |
|
1010 { |
|
1011 iTestStepResult = EFail; |
|
1012 return iTestStepResult; |
|
1013 } |
|
1014 |
|
1015 // Wait for end of play |
|
1016 CActiveScheduler::Start(); |
|
1017 if (!(iError == KErrNone && iCurrentState1 == CMdaAudioRecorderUtility::EOpen)) |
|
1018 { |
|
1019 iTestStepResult = EFail; |
|
1020 return iTestStepResult; |
|
1021 } |
|
1022 |
|
1023 INFO_PRINTF1(_L("finished with this test step")); |
|
1024 |
|
1025 // test steps return a result |
|
1026 return iTestStepResult; |
|
1027 } |
|
1028 |
|
1029 |
|
1030 // |
|
1031 |
|
1032 |
|
1033 /** |
|
1034 * |
|
1035 * Static constructor for CTestStepRecorderSimultaneousPlay5 |
|
1036 * |
|
1037 * |
|
1038 * @return "CTestStepRecorderSimultaneousPlay5*" |
|
1039 * The constructed CTestStepRecorderSimultaneousPlay5 |
|
1040 * |
|
1041 * @xxxx |
|
1042 * |
|
1043 */ |
|
1044 CTestStepRecorderSimultaneousPlay5* CTestStepRecorderSimultaneousPlay5::NewL() |
|
1045 { |
|
1046 CTestStepRecorderSimultaneousPlay5* self = new(ELeave) CTestStepRecorderSimultaneousPlay5; |
|
1047 return self; |
|
1048 } |
|
1049 |
|
1050 /** |
|
1051 * |
|
1052 * Test step constructor. |
|
1053 * Each test step initialises its own name. |
|
1054 * |
|
1055 * @xxxx |
|
1056 * |
|
1057 */ |
|
1058 CTestStepRecorderSimultaneousPlay5::CTestStepRecorderSimultaneousPlay5() |
|
1059 { |
|
1060 // store the name of this test case |
|
1061 // this is the name that is used by the script file |
|
1062 iTestStepName = _L("MM-MMF-ACLNT-U-0814-HP"); |
|
1063 } |
|
1064 |
|
1065 /** |
|
1066 * |
|
1067 * Test step destructor. |
|
1068 * |
|
1069 * @xxxx |
|
1070 * |
|
1071 */ |
|
1072 CTestStepRecorderSimultaneousPlay5::~CTestStepRecorderSimultaneousPlay5() |
|
1073 { |
|
1074 } |
|
1075 |
|
1076 /** |
|
1077 * |
|
1078 * Test step Close |
|
1079 * handles all deletion |
|
1080 * @xxxx |
|
1081 * |
|
1082 */ |
|
1083 void CTestStepRecorderSimultaneousPlay5::Close() |
|
1084 { |
|
1085 delete iRecorderUtility1; |
|
1086 delete iRecorderUtility2; |
|
1087 } |
|
1088 |
|
1089 /** |
|
1090 * |
|
1091 * Test step Preamble. |
|
1092 * |
|
1093 * @xxxx |
|
1094 * |
|
1095 */ |
|
1096 enum TVerdict CTestStepRecorderSimultaneousPlay5::DoTestStepPreambleL(void) |
|
1097 { |
|
1098 TInt err; |
|
1099 |
|
1100 TVerdict verdict; |
|
1101 // this installs the scheduler |
|
1102 verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL(); |
|
1103 |
|
1104 // Printing to the console and log file |
|
1105 INFO_PRINTF2(_L("%S"), &iTestStepName); |
|
1106 INFO_PRINTF1(_L("this is a test of Open a low priority recorder and a higher priority recorder with the same file & get the duration in each case")); |
|
1107 |
|
1108 if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName2"), iFileName1)) // long wav file |
|
1109 { |
|
1110 return EInconclusive; |
|
1111 } |
|
1112 |
|
1113 // create record utilities. A low priority and a high priority |
|
1114 TRAP(err, iRecorderUtility1 = CMdaAudioRecorderUtility::NewL(*this, NULL, EMdaPriorityMin)); |
|
1115 if (err != KErrNone) |
|
1116 return EInconclusive; |
|
1117 |
|
1118 TRAP(err, iRecorderUtility2 = CMdaAudioRecorderUtility::NewL(*this, NULL, EMdaPriorityMax)); |
|
1119 if (err != KErrNone) |
|
1120 return EInconclusive; |
|
1121 |
|
1122 return verdict; |
|
1123 |
|
1124 } |
|
1125 |
|
1126 /** |
|
1127 * |
|
1128 * Test step Postamble. |
|
1129 * |
|
1130 * @xxxx |
|
1131 * |
|
1132 */ |
|
1133 enum TVerdict CTestStepRecorderSimultaneousPlay5::DoTestStepPostambleL(void) |
|
1134 { |
|
1135 //[ Destroy the scheduler ] |
|
1136 return CTestStepUnitMMFAudClient::DoTestStepPostambleL(); |
|
1137 } |
|
1138 |
|
1139 /** |
|
1140 * |
|
1141 * Callback Handle. |
|
1142 * |
|
1143 * @xxxx |
|
1144 * |
|
1145 */ |
|
1146 void CTestStepRecorderSimultaneousPlay5::MoscoStateChangeEvent(CBase* aObject, |
|
1147 TInt aPreviousState, |
|
1148 TInt aCurrentState, |
|
1149 TInt aErrorCode) |
|
1150 { |
|
1151 INFO_PRINTF4(_L("MoscoStateChangeEvent(): Previous state = %d, current state = %d, error = %d"), |
|
1152 aPreviousState, |
|
1153 aCurrentState, |
|
1154 aErrorCode); |
|
1155 iError = aErrorCode; |
|
1156 |
|
1157 if (aObject == iRecorderUtility1) |
|
1158 iCurrentState1 = aCurrentState; |
|
1159 else if (aObject == iRecorderUtility2) |
|
1160 iCurrentState2 = aCurrentState; |
|
1161 |
|
1162 |
|
1163 CActiveScheduler::Stop(); |
|
1164 } |
|
1165 |
|
1166 |
|
1167 /** |
|
1168 * |
|
1169 * Do the test step. |
|
1170 * Each test step must supply an implementation for DoTestStepL. |
|
1171 * |
|
1172 * @return "TVerdict" |
|
1173 * The result of the test step |
|
1174 * |
|
1175 * @xxxx |
|
1176 * |
|
1177 */ |
|
1178 TVerdict CTestStepRecorderSimultaneousPlay5::DoTestStepL() |
|
1179 { |
|
1180 iTestStepResult = EPass; |
|
1181 TInt err = KErrNone; |
|
1182 |
|
1183 INFO_PRINTF2(_L("File to play = %S"), &iFileName1); |
|
1184 |
|
1185 // Get the first recorder utility to open the sound file |
|
1186 INFO_PRINTF1( _L("Initialize CMdaAudioRecorderUtility1")); |
|
1187 TRAP(err, iRecorderUtility1->OpenFileL(iFileName1)); |
|
1188 if (err != KErrNone) |
|
1189 return EInconclusive; |
|
1190 // wait for open to complete |
|
1191 CActiveScheduler::Start(); |
|
1192 if (iCurrentState1 != CMdaAudioRecorderUtility::EOpen) |
|
1193 return EFail; |
|
1194 |
|
1195 // start playing the first file and give it time to start |
|
1196 INFO_PRINTF1( _L("Playing sound file (Utililty #1)...low priority")); |
|
1197 TRAP(err, iRecorderUtility1->PlayL()); |
|
1198 if (err != KErrNone) |
|
1199 return EInconclusive; |
|
1200 CActiveScheduler::Start(); |
|
1201 if (!(iError == KErrNone && iCurrentState1 == CMdaAudioRecorderUtility::EPlaying)) |
|
1202 { |
|
1203 iTestStepResult = EFail; |
|
1204 return iTestStepResult; |
|
1205 } |
|
1206 User::After(KQuarterScond); |
|
1207 |
|
1208 // Get the second recorder utility to open the sound file |
|
1209 INFO_PRINTF1( _L("Initialize CMdaAudioRecorderUtility2")); |
|
1210 TRAP(err, iRecorderUtility2->OpenFileL(iFileName1)); |
|
1211 if (err != KErrNone) |
|
1212 return EInconclusive; |
|
1213 // wait for open to complete |
|
1214 CActiveScheduler::Start(); |
|
1215 if (iCurrentState2 != CMdaAudioRecorderUtility::EOpen) |
|
1216 return EFail; |
|
1217 |
|
1218 |
|
1219 // get the duration of each utility |
|
1220 TTimeIntervalMicroSeconds duration1, duration2; |
|
1221 |
|
1222 duration1 = iRecorderUtility1->Duration(); |
|
1223 duration2 = iRecorderUtility2->Duration(); |
|
1224 |
|
1225 INFO_PRINTF2( _L("CMdaAudioRecorderUtility1: reported duration = %d"), I64INT(duration1.Int64())); |
|
1226 INFO_PRINTF2( _L("CMdaAudioRecorderUtility1: reported duration = %d"), I64INT(duration2.Int64())); |
|
1227 |
|
1228 if (duration1 != duration2) |
|
1229 iTestStepResult = EFail; |
|
1230 |
|
1231 // stop playing |
|
1232 iRecorderUtility1->Stop(); |
|
1233 |
|
1234 INFO_PRINTF1(_L("finished with this test step")); |
|
1235 |
|
1236 // test steps return a result |
|
1237 return iTestStepResult; |
|
1238 } |
|
1239 |
|
1240 |
|
1241 // |
|
1242 |
|
1243 |
|
1244 /** |
|
1245 * |
|
1246 * Static constructor for CTestStepRecorderPlayTwice. |
|
1247 * |
|
1248 * |
|
1249 * @return "CTestStepRecorderPlayTwice*" |
|
1250 * The constructed CTestStepRecorderPlayTwice |
|
1251 * |
|
1252 * @xxxx |
|
1253 * |
|
1254 */ |
|
1255 CTestStepRecorderPlayTwice* CTestStepRecorderPlayTwice::NewL() |
|
1256 { |
|
1257 CTestStepRecorderPlayTwice* self = new(ELeave) CTestStepRecorderPlayTwice; |
|
1258 return self; |
|
1259 } |
|
1260 |
|
1261 /** |
|
1262 * |
|
1263 * Test step constructor. |
|
1264 * Each test step initialises its own name. |
|
1265 * |
|
1266 * @xxxx |
|
1267 * |
|
1268 */ |
|
1269 CTestStepRecorderPlayTwice::CTestStepRecorderPlayTwice() |
|
1270 { |
|
1271 // store the name of this test case |
|
1272 // this is the name that is used by the script file |
|
1273 iTestStepName = _L("MM-MMF-ACLNT-U-0820-HP"); |
|
1274 } |
|
1275 |
|
1276 /** |
|
1277 * |
|
1278 * Test step destructor. |
|
1279 * |
|
1280 * @xxxx |
|
1281 * |
|
1282 */ |
|
1283 CTestStepRecorderPlayTwice::~CTestStepRecorderPlayTwice() |
|
1284 { |
|
1285 } |
|
1286 |
|
1287 /** |
|
1288 * |
|
1289 * Test step Close |
|
1290 * handles all deletion |
|
1291 * @xxxx |
|
1292 * |
|
1293 */ |
|
1294 void CTestStepRecorderPlayTwice::Close() |
|
1295 { |
|
1296 delete iRecorderUtility; |
|
1297 } |
|
1298 |
|
1299 /** |
|
1300 * |
|
1301 * Test step Preamble. |
|
1302 * |
|
1303 * @xxxx |
|
1304 * |
|
1305 */ |
|
1306 enum TVerdict CTestStepRecorderPlayTwice::DoTestStepPreambleL(void) |
|
1307 { |
|
1308 TInt err; |
|
1309 |
|
1310 TVerdict verdict; |
|
1311 // this installs the scheduler |
|
1312 verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL(); |
|
1313 |
|
1314 // Printing to the console and log file |
|
1315 INFO_PRINTF2(_L("%S"), &iTestStepName); |
|
1316 INFO_PRINTF1(_L("this is a test of calling CMdaAudioRecorderUtility::PlayL() twice")); |
|
1317 |
|
1318 if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName2"), iFileName)) // wav file |
|
1319 { |
|
1320 return EInconclusive; |
|
1321 } |
|
1322 |
|
1323 // create a record utility |
|
1324 TRAP(err, iRecorderUtility = CMdaAudioRecorderUtility::NewL(*this)); |
|
1325 if (err != KErrNone) |
|
1326 return EInconclusive; |
|
1327 |
|
1328 return verdict; |
|
1329 |
|
1330 } |
|
1331 |
|
1332 /** |
|
1333 * |
|
1334 * Test step Postamble. |
|
1335 * |
|
1336 * @xxxx |
|
1337 * |
|
1338 */ |
|
1339 enum TVerdict CTestStepRecorderPlayTwice::DoTestStepPostambleL(void) |
|
1340 { |
|
1341 //[ Destroy the scheduler ] |
|
1342 return CTestStepUnitMMFAudClient::DoTestStepPostambleL(); |
|
1343 } |
|
1344 |
|
1345 /** |
|
1346 * |
|
1347 * Callback Handle. |
|
1348 * |
|
1349 * @xxxx |
|
1350 * |
|
1351 */ |
|
1352 void CTestStepRecorderPlayTwice::MoscoStateChangeEvent(CBase* /*aObject*/, |
|
1353 TInt aPreviousState, |
|
1354 TInt aCurrentState, |
|
1355 TInt aErrorCode) |
|
1356 { |
|
1357 INFO_PRINTF4(_L("MoscoStateChangeEvent(): Previous state = %d, current state = %d, error = %d"), |
|
1358 aPreviousState, |
|
1359 aCurrentState, |
|
1360 aErrorCode); |
|
1361 iError = aErrorCode; |
|
1362 iCurrentState = aCurrentState; |
|
1363 CActiveScheduler::Stop(); |
|
1364 } |
|
1365 |
|
1366 |
|
1367 void CTestStepRecorderPlayTwice::MatoPrepareComplete(TInt aError) |
|
1368 { |
|
1369 INFO_PRINTF2(_L("MatoPrepareComplete(): error = %d"), aError); |
|
1370 iErrorTone = aError; |
|
1371 CActiveScheduler::Stop(); |
|
1372 } |
|
1373 |
|
1374 void CTestStepRecorderPlayTwice::MatoPlayComplete(TInt aError) |
|
1375 { |
|
1376 INFO_PRINTF2(_L("MatoPlayComplete(): error = %d"), aError); |
|
1377 iErrorTone = aError; |
|
1378 CActiveScheduler::Stop(); |
|
1379 } |
|
1380 |
|
1381 |
|
1382 /** |
|
1383 * |
|
1384 * Do the test step. |
|
1385 * Each test step must supply an implementation for DoTestStepL. |
|
1386 * |
|
1387 * @return "TVerdict" |
|
1388 * The result of the test step |
|
1389 * |
|
1390 * @xxxx |
|
1391 * |
|
1392 */ |
|
1393 TVerdict CTestStepRecorderPlayTwice::DoTestStepL() |
|
1394 { |
|
1395 iTestStepResult = EPass; |
|
1396 TInt err = KErrNone; |
|
1397 |
|
1398 |
|
1399 // open the sound file |
|
1400 TRAP(err, iRecorderUtility->OpenFileL(iFileName)); |
|
1401 if (err != KErrNone) |
|
1402 return EInconclusive; |
|
1403 // wait for open to complete |
|
1404 CActiveScheduler::Start(); |
|
1405 if (iCurrentState != CMdaAudioRecorderUtility::EOpen) |
|
1406 return EFail; |
|
1407 |
|
1408 TTime timeStart; |
|
1409 TTime timeEnd; |
|
1410 TTimeIntervalMicroSeconds playDuration1; |
|
1411 TTimeIntervalMicroSeconds playDuration2; |
|
1412 TTimeIntervalMicroSeconds position; |
|
1413 const TInt KQuarterSecond = 250000; |
|
1414 const TInt KHalfSecond = 500000; |
|
1415 const TInt KTwoSeconds = 2000000; |
|
1416 |
|
1417 // Start playing the file and after two seconds get the position |
|
1418 INFO_PRINTF1( _L("Playing file for the first time...")); |
|
1419 timeStart.UniversalTime(); // start the timer |
|
1420 TRAP(err, iRecorderUtility->PlayL()); |
|
1421 if (err != KErrNone) |
|
1422 return EInconclusive; |
|
1423 // wait once for start of play |
|
1424 CActiveScheduler::Start(); |
|
1425 if (iError != KErrNone) |
|
1426 iTestStepResult = EFail; |
|
1427 if (iCurrentState != CMdaAudioRecorderUtility::EPlaying) |
|
1428 return EFail; |
|
1429 |
|
1430 // check the position is close to the start of the file |
|
1431 position = iRecorderUtility->Position(); |
|
1432 INFO_PRINTF2(_L("Start position = %d microseconds"), I64INT(position.Int64())); |
|
1433 if (position.Int64() > KHalfSecond) |
|
1434 { |
|
1435 INFO_PRINTF1(_L("Start position is too high")); |
|
1436 return EFail; |
|
1437 } |
|
1438 |
|
1439 User::After(KTwoSeconds); |
|
1440 // make sure we're still playing |
|
1441 if (iCurrentState != CMdaAudioRecorderUtility::EPlaying) |
|
1442 return EInconclusive; |
|
1443 position = iRecorderUtility->Position(); |
|
1444 |
|
1445 // wait once for end of play - this should produce KErrNone |
|
1446 CActiveScheduler::Start(); |
|
1447 if (iError != KErrNone) |
|
1448 iTestStepResult = EFail; |
|
1449 if (iCurrentState != CMdaAudioRecorderUtility::EOpen) |
|
1450 return EFail; |
|
1451 timeEnd.UniversalTime(); // stop the timer |
|
1452 |
|
1453 // save the first play's duration |
|
1454 playDuration1 = timeEnd.MicroSecondsFrom(timeStart); |
|
1455 |
|
1456 |
|
1457 // Play the file again |
|
1458 INFO_PRINTF1( _L("Playing file for the second time...")); |
|
1459 timeStart.UniversalTime(); // start the timer |
|
1460 TRAP(err, iRecorderUtility->PlayL()); |
|
1461 if (err != KErrNone) |
|
1462 return EInconclusive; |
|
1463 // wait once for start of play |
|
1464 CActiveScheduler::Start(); |
|
1465 if (iError != KErrNone) |
|
1466 iTestStepResult = EFail; |
|
1467 if (iCurrentState != CMdaAudioRecorderUtility::EPlaying) |
|
1468 return EFail; |
|
1469 |
|
1470 // check the position is close to the start of the file |
|
1471 // and much less than 2 seconds |
|
1472 position = iRecorderUtility->Position(); |
|
1473 INFO_PRINTF2(_L("Start position = %d microseconds"), I64INT(position.Int64())); |
|
1474 if (position.Int64() > KHalfSecond) |
|
1475 { |
|
1476 INFO_PRINTF1(_L("Start position is too high")); |
|
1477 return EFail; |
|
1478 } |
|
1479 |
|
1480 // wait once for end of play - this should produce KErrNone |
|
1481 CActiveScheduler::Start(); |
|
1482 if (iError != KErrNone) |
|
1483 iTestStepResult = EFail; |
|
1484 if (iCurrentState != CMdaAudioRecorderUtility::EOpen) |
|
1485 return EFail; |
|
1486 timeEnd.UniversalTime(); // stop the timer |
|
1487 |
|
1488 // save the second play's durarion |
|
1489 playDuration2 = timeEnd.MicroSecondsFrom(timeStart); |
|
1490 |
|
1491 // Now compare how long it took to play the file in both cases |
|
1492 // calculate the difference (hopefully pretty small) |
|
1493 TInt64 playDurationDiff = playDuration2.Int64() - playDuration1.Int64(); |
|
1494 // make sure it's a positive number |
|
1495 if (playDurationDiff < 0) |
|
1496 playDurationDiff = -playDurationDiff; |
|
1497 |
|
1498 INFO_PRINTF2(_L("Duration #1 = %d microseconds"), playDuration1.Int64()); |
|
1499 INFO_PRINTF2(_L("Duration #2 = %d microseconds"), playDuration2.Int64()); |
|
1500 INFO_PRINTF2(_L("Difference = %d microseconds"), playDurationDiff); |
|
1501 if (playDurationDiff > KQuarterSecond) |
|
1502 { |
|
1503 INFO_PRINTF1(_L("Difference is too high")); |
|
1504 iTestStepResult = EFail; |
|
1505 } |
|
1506 |
|
1507 |
|
1508 |
|
1509 |
|
1510 INFO_PRINTF1(_L("finished with this test step")); |
|
1511 |
|
1512 // test steps return a result |
|
1513 return iTestStepResult; |
|
1514 } |
|
1515 |
|
1516 |
|
1517 |
|
1518 // |
|
1519 |
|
1520 |
|
1521 /** |
|
1522 * |
|
1523 * Static constructor for CTestStepPlayerPlayAndClearWindow. |
|
1524 * |
|
1525 * |
|
1526 * @return "CTestStepPlayerPlayAndClearWindow*" |
|
1527 * The constructed CTestStepPlayerPlayAndClearWindow |
|
1528 * |
|
1529 * @xxxx |
|
1530 * |
|
1531 */ |
|
1532 CTestStepPlayerPlayAndClearWindow* CTestStepPlayerPlayAndClearWindow::NewL() |
|
1533 { |
|
1534 CTestStepPlayerPlayAndClearWindow* self = new(ELeave) CTestStepPlayerPlayAndClearWindow; |
|
1535 return self; |
|
1536 } |
|
1537 |
|
1538 /** |
|
1539 * |
|
1540 * Test step constructor. |
|
1541 * Each test step initialises its own name. |
|
1542 * |
|
1543 * @xxxx |
|
1544 * |
|
1545 */ |
|
1546 CTestStepPlayerPlayAndClearWindow::CTestStepPlayerPlayAndClearWindow() |
|
1547 { |
|
1548 // store the name of this test case |
|
1549 // this is the name that is used by the script file |
|
1550 iTestStepName = _L("MM-MMF-ACLNT-U-0824-HP"); |
|
1551 } |
|
1552 |
|
1553 /** |
|
1554 * |
|
1555 * Test step destructor. |
|
1556 * |
|
1557 * @xxxx |
|
1558 * |
|
1559 */ |
|
1560 CTestStepPlayerPlayAndClearWindow::~CTestStepPlayerPlayAndClearWindow() |
|
1561 { |
|
1562 } |
|
1563 |
|
1564 /** |
|
1565 * |
|
1566 * Test step Preamble. |
|
1567 * |
|
1568 * @xxxx |
|
1569 * |
|
1570 */ |
|
1571 enum TVerdict CTestStepPlayerPlayAndClearWindow::DoTestStepPreambleL(void) |
|
1572 { |
|
1573 TInt err; |
|
1574 |
|
1575 TVerdict verdict; |
|
1576 // this installs the scheduler |
|
1577 verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL(); |
|
1578 |
|
1579 // Printing to the console and log file |
|
1580 INFO_PRINTF2(_L("%S"), &iTestStepName); |
|
1581 INFO_PRINTF1(_L("this is a test of calling Play, clearing the play window")); |
|
1582 INFO_PRINTF1(_L("and then playing again & verifying the whole clip is played")); |
|
1583 |
|
1584 if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName2"), iFileName)) // wav file |
|
1585 { |
|
1586 return EInconclusive; |
|
1587 } |
|
1588 |
|
1589 // create a play utility |
|
1590 TRAP(err, iPlayerUtility = CMdaAudioPlayerUtility::NewL(*this)); |
|
1591 if (err != KErrNone) |
|
1592 return EInconclusive; |
|
1593 |
|
1594 // create a recorder utility |
|
1595 TRAP(err, iRecorderUtility = CMdaAudioRecorderUtility::NewL(*this)); |
|
1596 if (err != KErrNone) |
|
1597 return EInconclusive; |
|
1598 |
|
1599 return verdict; |
|
1600 |
|
1601 } |
|
1602 |
|
1603 /** |
|
1604 * |
|
1605 * Test step Postamble. |
|
1606 * |
|
1607 * @xxxx |
|
1608 * |
|
1609 */ |
|
1610 enum TVerdict CTestStepPlayerPlayAndClearWindow::DoTestStepPostambleL(void) |
|
1611 { |
|
1612 delete iPlayerUtility; |
|
1613 iPlayerUtility = NULL; |
|
1614 delete iRecorderUtility; |
|
1615 iRecorderUtility = NULL; |
|
1616 |
|
1617 //[ Destroy the scheduler ] |
|
1618 return CTestStepUnitMMFAudClient::DoTestStepPostambleL(); |
|
1619 } |
|
1620 |
|
1621 /** |
|
1622 * |
|
1623 * Callback Handle. |
|
1624 * |
|
1625 * @xxxx |
|
1626 * |
|
1627 */ |
|
1628 void CTestStepPlayerPlayAndClearWindow::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/) |
|
1629 { |
|
1630 INFO_PRINTF2(_L("MapcInitComplete(): error = %d"), aError); |
|
1631 iError = aError; |
|
1632 CActiveScheduler::Stop(); |
|
1633 } |
|
1634 |
|
1635 void CTestStepPlayerPlayAndClearWindow::MapcPlayComplete(TInt aError) |
|
1636 { |
|
1637 INFO_PRINTF2(_L("MapcPlayComplete(): error = %d"), aError); |
|
1638 iError = aError; |
|
1639 CActiveScheduler::Stop(); |
|
1640 } |
|
1641 |
|
1642 |
|
1643 void CTestStepPlayerPlayAndClearWindow::MoscoStateChangeEvent(CBase* /*aObject*/, |
|
1644 TInt aPreviousState, |
|
1645 TInt aCurrentState, |
|
1646 TInt aErrorCode) |
|
1647 { |
|
1648 INFO_PRINTF4(_L("MoscoStateChangeEvent(): Previous state = %d, current state = %d, error = %d"), |
|
1649 aPreviousState, |
|
1650 aCurrentState, |
|
1651 aErrorCode); |
|
1652 iError = aErrorCode; |
|
1653 iCurrentState = aCurrentState; |
|
1654 CActiveScheduler::Stop(); |
|
1655 } |
|
1656 |
|
1657 |
|
1658 TVerdict CTestStepPlayerPlayAndClearWindow::DoTestStepPlayerL() |
|
1659 { |
|
1660 iTestStepResult = EPass; |
|
1661 TInt err = KErrNone; |
|
1662 |
|
1663 const TInt KHalfSecond = 500000; |
|
1664 |
|
1665 INFO_PRINTF1(_L("Opening file using player utility...")); |
|
1666 |
|
1667 // open the sound file |
|
1668 TRAP(err, iPlayerUtility->OpenFileL(iFileName)); |
|
1669 if (err != KErrNone) |
|
1670 return EInconclusive; |
|
1671 // wait for open to complete |
|
1672 CActiveScheduler::Start(); |
|
1673 if (iError != KErrNone) |
|
1674 return EFail; |
|
1675 |
|
1676 TTimeIntervalMicroSeconds duration = iPlayerUtility->Duration(); |
|
1677 TTimeIntervalMicroSeconds position; |
|
1678 TTimeIntervalMicroSeconds playStart = duration.Int64()/2; |
|
1679 TTimeIntervalMicroSeconds playEnd = duration; |
|
1680 |
|
1681 // sequence #1A |
|
1682 // SetPlayWindow, Play & verify we play from start of window,stop |
|
1683 INFO_PRINTF1(_L("Sequence #1A...")); |
|
1684 INFO_PRINTF1(_L("calling SetPlayWindow...")); |
|
1685 iPlayerUtility->SetPlayWindow(playStart, playEnd); |
|
1686 INFO_PRINTF1(_L("calling play...")); |
|
1687 iPlayerUtility->Play(); |
|
1688 |
|
1689 INFO_PRINTF1(_L("calling GetPosition...")); |
|
1690 iPlayerUtility->GetPosition(position); |
|
1691 INFO_PRINTF2(_L("play position = %d"), position.Int64()); |
|
1692 if (position.Int64() < playStart.Int64()) |
|
1693 { |
|
1694 INFO_PRINTF2(_L("play position is not at start of play window - %d"), position.Int64()); |
|
1695 iTestStepResult = EFail; |
|
1696 return iTestStepResult; |
|
1697 } |
|
1698 INFO_PRINTF1(_L("calling stop...")); |
|
1699 iPlayerUtility->Stop(); |
|
1700 |
|
1701 // sequence #1B |
|
1702 // Play & verify we play from start of window,stop |
|
1703 INFO_PRINTF1(_L("Sequence #1B...")); |
|
1704 INFO_PRINTF1(_L("calling play...")); |
|
1705 iPlayerUtility->Play(); |
|
1706 iPlayerUtility->GetPosition(position); |
|
1707 INFO_PRINTF2(_L("play position = %d"), position.Int64()); |
|
1708 if (position.Int64() < playStart.Int64()) |
|
1709 { |
|
1710 INFO_PRINTF2(_L("play position is not at start of play window - %d"), position.Int64()); |
|
1711 iTestStepResult = EFail; |
|
1712 return iTestStepResult; |
|
1713 } |
|
1714 |
|
1715 // sequence #1C |
|
1716 // ClearPlayWindow, Stop, play & verify we play from start of clip,stop |
|
1717 INFO_PRINTF1(_L("Sequence #1C...")); |
|
1718 INFO_PRINTF1(_L("calling ClearPlayWindow...")); |
|
1719 iPlayerUtility->ClearPlayWindow(); |
|
1720 INFO_PRINTF1(_L("calling stop...")); |
|
1721 iPlayerUtility->Stop(); |
|
1722 INFO_PRINTF1(_L("calling play...")); |
|
1723 iPlayerUtility->Play(); |
|
1724 INFO_PRINTF1(_L("calling GetPosition...")); |
|
1725 iPlayerUtility->GetPosition(position); |
|
1726 INFO_PRINTF2(_L("play position = %d"), position.Int64()); |
|
1727 if (position.Int64() > KHalfSecond) |
|
1728 { |
|
1729 INFO_PRINTF2(_L("play position is not at start of clip - %d"), position.Int64()); |
|
1730 iTestStepResult = EFail; |
|
1731 return iTestStepResult; |
|
1732 } |
|
1733 INFO_PRINTF1(_L("calling stop...")); |
|
1734 iPlayerUtility->Stop(); |
|
1735 |
|
1736 // sequence #2 |
|
1737 // play, SetPlayWindow,stop,ClearPlayWindow,Play & verify we play from |
|
1738 // start of clip |
|
1739 INFO_PRINTF1(_L("Sequence #2...")); |
|
1740 INFO_PRINTF1(_L("calling play...")); |
|
1741 iPlayerUtility->Play(); |
|
1742 INFO_PRINTF1(_L("calling SetPlayWindow...")); |
|
1743 iPlayerUtility->SetPlayWindow(playStart, playEnd); |
|
1744 INFO_PRINTF1(_L("calling stop...")); |
|
1745 iPlayerUtility->Stop(); |
|
1746 INFO_PRINTF1(_L("calling ClearPlayWindow...")); |
|
1747 iPlayerUtility->ClearPlayWindow(); |
|
1748 INFO_PRINTF1(_L("calling play...")); |
|
1749 iPlayerUtility->Play(); |
|
1750 INFO_PRINTF1(_L("calling GetPosition...")); |
|
1751 iPlayerUtility->GetPosition(position); |
|
1752 INFO_PRINTF2(_L("play position = %d"), position.Int64()); |
|
1753 if (position.Int64() > KHalfSecond) |
|
1754 { |
|
1755 INFO_PRINTF2(_L("play position is not at start of clip - %d"), position.Int64()); |
|
1756 iTestStepResult = EFail; |
|
1757 return iTestStepResult; |
|
1758 } |
|
1759 INFO_PRINTF1(_L("calling stop...")); |
|
1760 iPlayerUtility->Stop(); |
|
1761 |
|
1762 |
|
1763 INFO_PRINTF1(_L("finished with this test step")); |
|
1764 |
|
1765 return iTestStepResult; |
|
1766 } |
|
1767 |
|
1768 TVerdict CTestStepPlayerPlayAndClearWindow::DoTestStepRecorderL() |
|
1769 { |
|
1770 iTestStepResult = EPass; |
|
1771 TInt err = KErrNone; |
|
1772 |
|
1773 const TInt KHalfSecond = 500000; |
|
1774 |
|
1775 INFO_PRINTF1(_L("Opening file using recorder utility...")); |
|
1776 |
|
1777 // open the sound file |
|
1778 TRAP(err, iRecorderUtility->OpenFileL(iFileName)); |
|
1779 if (err != KErrNone) |
|
1780 return EInconclusive; |
|
1781 // wait for open to complete |
|
1782 CActiveScheduler::Start(); |
|
1783 if (iError != KErrNone) |
|
1784 return EFail; |
|
1785 |
|
1786 TTimeIntervalMicroSeconds duration = iRecorderUtility->Duration(); |
|
1787 TTimeIntervalMicroSeconds position; |
|
1788 TTimeIntervalMicroSeconds playStart = duration.Int64()/2; |
|
1789 TTimeIntervalMicroSeconds playEnd = duration; |
|
1790 |
|
1791 // sequence #1A |
|
1792 // SetPlayWindow, Play & verify we play from start of window,stop |
|
1793 INFO_PRINTF1(_L("Sequence #1A...")); |
|
1794 INFO_PRINTF1(_L("calling SetPlayWindow...")); |
|
1795 iRecorderUtility->SetPlayWindow(playStart, playEnd); |
|
1796 INFO_PRINTF1(_L("calling play...")); |
|
1797 iRecorderUtility->PlayL(); |
|
1798 // wait for play to start |
|
1799 CActiveScheduler::Start(); |
|
1800 if (iError != KErrNone) |
|
1801 return EFail; |
|
1802 |
|
1803 INFO_PRINTF1(_L("calling GetPosition...")); |
|
1804 position = iRecorderUtility->Position(); |
|
1805 INFO_PRINTF2(_L("play position = %d"), position.Int64()); |
|
1806 if (position.Int64() < playStart.Int64()) |
|
1807 { |
|
1808 INFO_PRINTF2(_L("play position is not at start of play window - %d"), position.Int64()); |
|
1809 iTestStepResult = EFail; |
|
1810 return iTestStepResult; |
|
1811 } |
|
1812 INFO_PRINTF1(_L("calling stop...")); |
|
1813 iRecorderUtility->Stop(); |
|
1814 |
|
1815 // sequence #1B |
|
1816 // Play & verify we play from start of window,stop |
|
1817 INFO_PRINTF1(_L("Sequence #1B...")); |
|
1818 INFO_PRINTF1(_L("calling play...")); |
|
1819 iRecorderUtility->PlayL(); |
|
1820 // wait for play to start |
|
1821 CActiveScheduler::Start(); |
|
1822 if (iError != KErrNone) |
|
1823 return EFail; |
|
1824 position = iRecorderUtility->Position(); |
|
1825 INFO_PRINTF2(_L("play position = %d"), position.Int64()); |
|
1826 if (position.Int64() < playStart.Int64()) |
|
1827 { |
|
1828 INFO_PRINTF2(_L("play position is not at start of play window - %d"), position.Int64()); |
|
1829 iTestStepResult = EFail; |
|
1830 return iTestStepResult; |
|
1831 } |
|
1832 |
|
1833 // sequence #1C |
|
1834 // ClearPlayWindow, Stop, play & verify we play from start of clip,stop |
|
1835 INFO_PRINTF1(_L("Sequence #1C...")); |
|
1836 INFO_PRINTF1(_L("calling ClearPlayWindow...")); |
|
1837 iRecorderUtility->ClearPlayWindow(); |
|
1838 INFO_PRINTF1(_L("calling stop...")); |
|
1839 iRecorderUtility->Stop(); |
|
1840 INFO_PRINTF1(_L("calling play...")); |
|
1841 iRecorderUtility->PlayL(); |
|
1842 // wait for play to start |
|
1843 CActiveScheduler::Start(); |
|
1844 if (iError != KErrNone) |
|
1845 return EFail; |
|
1846 INFO_PRINTF1(_L("calling GetPosition...")); |
|
1847 position = iRecorderUtility->Position(); |
|
1848 INFO_PRINTF2(_L("play position = %d"), position.Int64()); |
|
1849 if (position.Int64() > KHalfSecond) |
|
1850 { |
|
1851 INFO_PRINTF2(_L("play position is not at start of clip - %d"), position.Int64()); |
|
1852 iTestStepResult = EFail; |
|
1853 return iTestStepResult; |
|
1854 } |
|
1855 INFO_PRINTF1(_L("calling stop...")); |
|
1856 iRecorderUtility->Stop(); |
|
1857 |
|
1858 // sequence #2 |
|
1859 // play, SetPlayWindow,stop,ClearPlayWindow,Play & verify we play from |
|
1860 // start of clip |
|
1861 INFO_PRINTF1(_L("Sequence #2...")); |
|
1862 INFO_PRINTF1(_L("calling play...")); |
|
1863 iRecorderUtility->PlayL(); |
|
1864 // wait for play to start |
|
1865 CActiveScheduler::Start(); |
|
1866 if (iError != KErrNone) |
|
1867 return EFail; |
|
1868 INFO_PRINTF1(_L("calling SetPlayWindow...")); |
|
1869 iRecorderUtility->SetPlayWindow(playStart, playEnd); |
|
1870 INFO_PRINTF1(_L("calling stop...")); |
|
1871 iRecorderUtility->Stop(); |
|
1872 INFO_PRINTF1(_L("calling ClearPlayWindow...")); |
|
1873 iRecorderUtility->ClearPlayWindow(); |
|
1874 INFO_PRINTF1(_L("calling play...")); |
|
1875 iRecorderUtility->PlayL(); |
|
1876 // wait for play to start |
|
1877 CActiveScheduler::Start(); |
|
1878 if (iError != KErrNone) |
|
1879 return EFail; |
|
1880 INFO_PRINTF1(_L("calling GetPosition...")); |
|
1881 position = iRecorderUtility->Position(); |
|
1882 INFO_PRINTF2(_L("play position = %d"), position.Int64()); |
|
1883 if (position.Int64() > KHalfSecond) |
|
1884 { |
|
1885 INFO_PRINTF2(_L("play position is not at start of clip - %d"), position.Int64()); |
|
1886 iTestStepResult = EFail; |
|
1887 return iTestStepResult; |
|
1888 } |
|
1889 INFO_PRINTF1(_L("calling stop...")); |
|
1890 iRecorderUtility->Stop(); |
|
1891 |
|
1892 |
|
1893 INFO_PRINTF1(_L("finished with this test step")); |
|
1894 |
|
1895 return iTestStepResult; |
|
1896 } |
|
1897 |
|
1898 /** |
|
1899 * |
|
1900 * Do the test step. |
|
1901 * Each test step must supply an implementation for DoTestStepL. |
|
1902 * |
|
1903 * @return "TVerdict" |
|
1904 * The result of the test step |
|
1905 * |
|
1906 * @xxxx |
|
1907 * |
|
1908 */ |
|
1909 TVerdict CTestStepPlayerPlayAndClearWindow::DoTestStepL() |
|
1910 { |
|
1911 |
|
1912 // run the same test with the player utility & then the recorded utility |
|
1913 iTestStepResult = DoTestStepPlayerL(); |
|
1914 |
|
1915 if (iTestStepResult == EPass) |
|
1916 iTestStepResult = DoTestStepRecorderL(); |
|
1917 |
|
1918 return iTestStepResult; |
|
1919 } |
|
1920 |
|
1921 |
|
1922 |
|
1923 // |
|
1924 |
|
1925 |
|
1926 /** |
|
1927 * |
|
1928 * Static constructor for CTestStepRecorderSetPosition. |
|
1929 * |
|
1930 * |
|
1931 * @return "CTestStepRecorderSetPosition*" |
|
1932 * The constructed CTestStepRecorderSetPosition |
|
1933 * |
|
1934 * @xxxx |
|
1935 * |
|
1936 */ |
|
1937 CTestStepRecorderSetPosition* CTestStepRecorderSetPosition::NewL() |
|
1938 { |
|
1939 CTestStepRecorderSetPosition* self = new(ELeave) CTestStepRecorderSetPosition; |
|
1940 return self; |
|
1941 } |
|
1942 |
|
1943 /** |
|
1944 * |
|
1945 * Test step constructor. |
|
1946 * Each test step initialises its own name. |
|
1947 * |
|
1948 * @xxxx |
|
1949 * |
|
1950 */ |
|
1951 CTestStepRecorderSetPosition::CTestStepRecorderSetPosition() |
|
1952 { |
|
1953 // store the name of this test case |
|
1954 // this is the name that is used by the script file |
|
1955 iTestStepName = _L("MM-MMF-ACLNT-U-0825-HP"); |
|
1956 } |
|
1957 |
|
1958 /** |
|
1959 * |
|
1960 * Test step destructor. |
|
1961 * |
|
1962 * @xxxx |
|
1963 * |
|
1964 */ |
|
1965 CTestStepRecorderSetPosition::~CTestStepRecorderSetPosition() |
|
1966 { |
|
1967 } |
|
1968 |
|
1969 /** |
|
1970 * |
|
1971 * Test step Preamble. |
|
1972 * |
|
1973 * @xxxx |
|
1974 * |
|
1975 */ |
|
1976 enum TVerdict CTestStepRecorderSetPosition::DoTestStepPreambleL(void) |
|
1977 { |
|
1978 TInt err; |
|
1979 |
|
1980 TVerdict verdict; |
|
1981 // this installs the scheduler |
|
1982 verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL(); |
|
1983 |
|
1984 // Printing to the console and log file |
|
1985 INFO_PRINTF2(_L("%S"), &iTestStepName); |
|
1986 INFO_PRINTF1(_L("this tests the responsiveness of CMdaAudioRecorderUtility Setposition()")); |
|
1987 |
|
1988 if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName2"), iFileName)) // wav file |
|
1989 { |
|
1990 return EInconclusive; |
|
1991 } |
|
1992 |
|
1993 // create a record utility |
|
1994 TRAP(err, iRecorderUtility = CMdaAudioRecorderUtility::NewL(*this)); |
|
1995 if (err != KErrNone) |
|
1996 return EInconclusive; |
|
1997 |
|
1998 return verdict; |
|
1999 |
|
2000 } |
|
2001 |
|
2002 /** |
|
2003 * |
|
2004 * Test step Postamble. |
|
2005 * |
|
2006 * @xxxx |
|
2007 * |
|
2008 */ |
|
2009 enum TVerdict CTestStepRecorderSetPosition::DoTestStepPostambleL(void) |
|
2010 { |
|
2011 delete iRecorderUtility; |
|
2012 iRecorderUtility = NULL; |
|
2013 //[ Destroy the scheduler ] |
|
2014 return CTestStepUnitMMFAudClient::DoTestStepPostambleL(); |
|
2015 } |
|
2016 |
|
2017 /** |
|
2018 * |
|
2019 * Callback Handle. |
|
2020 * |
|
2021 * @xxxx |
|
2022 * |
|
2023 */ |
|
2024 void CTestStepRecorderSetPosition::MoscoStateChangeEvent(CBase* /*aObject*/, |
|
2025 TInt /*aPreviousState*/, |
|
2026 TInt aCurrentState, |
|
2027 TInt aErrorCode) |
|
2028 { |
|
2029 iError = aErrorCode; |
|
2030 iCurrentState = aCurrentState; |
|
2031 CActiveScheduler::Stop(); |
|
2032 } |
|
2033 |
|
2034 |
|
2035 void CTestStepRecorderSetPosition::MatoPrepareComplete(TInt aError) |
|
2036 { |
|
2037 INFO_PRINTF2(_L("MatoPrepareComplete(): error = %d"), aError); |
|
2038 iErrorTone = aError; |
|
2039 CActiveScheduler::Stop(); |
|
2040 } |
|
2041 |
|
2042 void CTestStepRecorderSetPosition::MatoPlayComplete(TInt aError) |
|
2043 { |
|
2044 INFO_PRINTF2(_L("MatoPlayComplete(): error = %d"), aError); |
|
2045 iErrorTone = aError; |
|
2046 CActiveScheduler::Stop(); |
|
2047 } |
|
2048 |
|
2049 |
|
2050 /** |
|
2051 * |
|
2052 * Do the test step. |
|
2053 * Each test step must supply an implementation for DoTestStepL. |
|
2054 * |
|
2055 * @return "TVerdict" |
|
2056 * The result of the test step |
|
2057 * |
|
2058 * @xxxx |
|
2059 * |
|
2060 */ |
|
2061 TVerdict CTestStepRecorderSetPosition::DoTestStepL() |
|
2062 { |
|
2063 iTestStepResult = EPass; |
|
2064 TInt err = KErrNone; |
|
2065 |
|
2066 const TInt KFiveSeconds = 5000000; |
|
2067 const TInt KTwoSeconds = 2000000; |
|
2068 const TInt KReplayedTime = KFiveSeconds - KTwoSeconds; |
|
2069 |
|
2070 INFO_PRINTF2( _L("Playing file for %d microseconds..."), KFiveSeconds); |
|
2071 INFO_PRINTF2( _L("and then resetting position to %d microseconds from start of file..."), KTwoSeconds); |
|
2072 |
|
2073 // open the sound file |
|
2074 TRAP(err, iRecorderUtility->OpenFileL(iFileName)); |
|
2075 if (err != KErrNone) |
|
2076 return EInconclusive; |
|
2077 // wait for open to complete |
|
2078 CActiveScheduler::Start(); |
|
2079 if (iCurrentState != CMdaAudioRecorderUtility::EOpen) |
|
2080 return EFail; |
|
2081 |
|
2082 TTime timeStart; |
|
2083 TTime timeEnd; |
|
2084 TTimeIntervalMicroSeconds playDuration; |
|
2085 TTimeIntervalMicroSeconds position; |
|
2086 // usually the WINS emulator responds within 300 ms, but about 30% |
|
2087 // of the time it takes significantly longer. Have chosen to allow this |
|
2088 // for emulator only (presumably it's down to other processes on the |
|
2089 // PC slowing things down...) |
|
2090 #ifdef __WINS__ |
|
2091 const TInt KAllowedDeviation = 750000; |
|
2092 #else |
|
2093 const TInt KAllowedDeviation = 350000; |
|
2094 #endif |
|
2095 |
|
2096 // Start playing the file and after a while change the position |
|
2097 TRAP(err, iRecorderUtility->PlayL()); |
|
2098 if (err != KErrNone) |
|
2099 return EInconclusive; |
|
2100 // wait once for start of play |
|
2101 CActiveScheduler::Start(); |
|
2102 if (iError != KErrNone) |
|
2103 iTestStepResult = EFail; |
|
2104 if (iCurrentState != CMdaAudioRecorderUtility::EPlaying) |
|
2105 return EFail; |
|
2106 timeStart.UniversalTime(); // start the timer |
|
2107 User::After(KFiveSeconds); |
|
2108 // make sure we're still playing |
|
2109 if (iCurrentState != CMdaAudioRecorderUtility::EPlaying) |
|
2110 return EInconclusive; |
|
2111 position = iRecorderUtility->Position(); |
|
2112 iRecorderUtility->SetPosition(TTimeIntervalMicroSeconds(KTwoSeconds)); |
|
2113 |
|
2114 // wait once for end of play - this should produce KErrNone |
|
2115 CActiveScheduler::Start(); |
|
2116 if (iError != KErrNone) |
|
2117 iTestStepResult = EFail; |
|
2118 if (iCurrentState != CMdaAudioRecorderUtility::EOpen) |
|
2119 return EFail; |
|
2120 timeEnd.UniversalTime(); // stop the timer |
|
2121 |
|
2122 // save the first play's duration |
|
2123 playDuration = timeEnd.MicroSecondsFrom(timeStart); |
|
2124 |
|
2125 |
|
2126 TTimeIntervalMicroSeconds clipDuration = iRecorderUtility->Duration(); |
|
2127 TTimeIntervalMicroSeconds expectedDuration = |
|
2128 TTimeIntervalMicroSeconds(clipDuration.Int64() + KReplayedTime); |
|
2129 |
|
2130 // Now compare how long it took to play the file |
|
2131 TInt64 playDurationDiff = expectedDuration.Int64() - playDuration.Int64(); |
|
2132 // make sure it's a positive number |
|
2133 if (playDurationDiff < 0) |
|
2134 playDurationDiff = -playDurationDiff; |
|
2135 |
|
2136 INFO_PRINTF2(_L("Clip duration = %d microseconds"), I64LOW(clipDuration.Int64())); |
|
2137 INFO_PRINTF2(_L("Expected play duration = %d microseconds"), I64LOW(expectedDuration.Int64())); |
|
2138 INFO_PRINTF2(_L("Time to play = %d microseconds"), playDuration.Int64()); |
|
2139 |
|
2140 INFO_PRINTF2(_L("Difference = %d microseconds"), playDurationDiff); |
|
2141 if (playDurationDiff > KAllowedDeviation) |
|
2142 { |
|
2143 INFO_PRINTF1(_L("Difference is too high")); |
|
2144 iTestStepResult = EFail; |
|
2145 } |
|
2146 |
|
2147 INFO_PRINTF1(_L("finished with this test step")); |
|
2148 |
|
2149 // test steps return a result |
|
2150 return iTestStepResult; |
|
2151 } |
|
2152 |
|
2153 |
|
2154 |