|
1 // Copyright (c) 2005-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 program is designed the test of the MMF_ACLNT. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file TestRecorder.cpp |
|
20 */ |
|
21 |
|
22 #include "mmfwavformat.h" |
|
23 #include <hal.h> |
|
24 #include "TestRecorder.h" |
|
25 |
|
26 //copy util |
|
27 TInt CopyFile(TPtrC aFileNameSrc, TPtrC aFileNameDst) |
|
28 { |
|
29 TInt theErr = KErrNone; |
|
30 |
|
31 RFs fs; |
|
32 fs.Connect(); |
|
33 RFile theFileNew; |
|
34 RFile theFile; |
|
35 |
|
36 fs.MkDirAll(aFileNameDst); |
|
37 theFile.Open(fs, aFileNameSrc, EFileShareReadersOnly); |
|
38 TInt theSize; |
|
39 theFile.Size(theSize); |
|
40 |
|
41 TBuf8<KSizeBuf> theBuf; |
|
42 TInt theStep = KSizeBuf; |
|
43 if(theStep > theSize) |
|
44 { |
|
45 theStep = theSize; |
|
46 } |
|
47 |
|
48 TInt theRes = theFileNew.Create(fs, aFileNameDst, EFileShareAny); |
|
49 if(theRes == KErrAlreadyExists) |
|
50 { |
|
51 theRes = theFileNew.Replace(fs, aFileNameDst, EFileShareAny); |
|
52 } |
|
53 |
|
54 |
|
55 if(theRes != KErrNone) |
|
56 { |
|
57 return theRes; |
|
58 } |
|
59 |
|
60 |
|
61 TInt theCurLength = 0; |
|
62 while(theCurLength < theSize) |
|
63 { |
|
64 theFile.Read(theBuf, theStep); |
|
65 theFileNew.Write(theBuf, theStep); |
|
66 theCurLength += theStep; |
|
67 |
|
68 if(theCurLength + theStep > theSize ) |
|
69 { |
|
70 theStep = theSize - theCurLength; |
|
71 } |
|
72 } |
|
73 |
|
74 theFileNew.Close(); |
|
75 theFile.Close(); |
|
76 fs.Close(); |
|
77 |
|
78 return theErr; |
|
79 } |
|
80 |
|
81 |
|
82 CTestMmfAclntRecord::CTestMmfAclntRecord(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) : |
|
83 iNegative(aNegative) |
|
84 { |
|
85 // store the name of this test case |
|
86 // this is the name that is used by the script file |
|
87 // Each test step initialises it's own name |
|
88 iTestStepName = aTestName; |
|
89 iSectName = aSectName; |
|
90 } |
|
91 |
|
92 void CTestMmfAclntRecord::MoscoStateChangeEvent(CBase* aObject, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode) |
|
93 { |
|
94 iError = aErrorCode; |
|
95 iObject = aObject; |
|
96 iPreviousState = aPreviousState; |
|
97 iCurrentState = aCurrentState; |
|
98 INFO_PRINTF1( _L("CTestMmfAclntRecord : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete")); |
|
99 INFO_PRINTF4( _L("iError %d iPreviousState %d iCurrentState %d"), iError, iPreviousState, iCurrentState); |
|
100 CActiveScheduler::Stop(); |
|
101 } |
|
102 |
|
103 TVerdict CTestMmfAclntRecord::DoTestStepL( void ) |
|
104 { |
|
105 INFO_PRINTF1( _L("TestRecorder")); |
|
106 TVerdict ret = EFail; |
|
107 |
|
108 iError = KErrTimedOut; |
|
109 |
|
110 TBuf<KSizeBuf> filename; |
|
111 TPtrC filename1; |
|
112 TPtrC filename2; |
|
113 |
|
114 if(!GetStringFromConfig(iSectName, _L("cropAudioFile"), filename1)) |
|
115 { |
|
116 return EInconclusive; |
|
117 } |
|
118 |
|
119 |
|
120 if(!GetStringFromConfig(iSectName, _L("playerAudioFile"), filename2)) |
|
121 { |
|
122 return EInconclusive; |
|
123 } |
|
124 |
|
125 |
|
126 |
|
127 GetDriveName(filename); |
|
128 filename.Append(filename1); |
|
129 |
|
130 CopyFile(filename2, filename); |
|
131 |
|
132 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
133 CleanupStack::PushL(recUtil); |
|
134 recUtil->OpenFileL(filename); |
|
135 // wait |
|
136 INFO_PRINTF1(_L("Initialise CMdaAudioRecorderUtility")); |
|
137 CActiveScheduler::Start(); |
|
138 |
|
139 |
|
140 if(iError == KErrNone) |
|
141 { |
|
142 INFO_PRINTF2(_L("CMdaAudioRecorderUtility->OpenFileL(%S)"), &filename); |
|
143 ret = DoTestL(recUtil); |
|
144 } |
|
145 |
|
146 CleanupStack::PopAndDestroy(recUtil); |
|
147 User::After(KTwoSeconds); |
|
148 ERR_PRINTF2( _L("CMdaAudioRecorderUtility completed with error %d"),iError ); |
|
149 return ret; |
|
150 } |
|
151 |
|
152 CTestMmfAclntRecGain::CTestMmfAclntRecGain(const TDesC& aTestName, const TDesC& aSectName, const TInt aGain, TBool aNegative) |
|
153 :CTestMmfAclntRecord(aTestName, aSectName, aNegative) |
|
154 , iGain (aGain) |
|
155 {} |
|
156 |
|
157 CTestMmfAclntRecGain* CTestMmfAclntRecGain::NewL(const TDesC& aTestName, const TDesC& aSectName,const TInt aGain, TBool aNegative) |
|
158 { |
|
159 CTestMmfAclntRecGain* self = new (ELeave) CTestMmfAclntRecGain(aTestName, aSectName, aGain, aNegative); |
|
160 return self; |
|
161 } |
|
162 |
|
163 /** |
|
164 * RecordUtils test: Set gain to maximum and enquire gain. |
|
165 */ |
|
166 TVerdict CTestMmfAclntRecGain::DoTestL(CMdaAudioRecorderUtility* aRecUtil) |
|
167 { |
|
168 INFO_PRINTF2( _L("TestRecorder : Gain - (%d)"), iGain); |
|
169 |
|
170 TVerdict ret = EFail; |
|
171 |
|
172 // Set up a file to record to |
|
173 TPtrC filename; |
|
174 if (!GetStringFromConfig(iSectName, _L("outputAudioFile"), filename)) |
|
175 { |
|
176 INFO_PRINTF1(_L("Error getting filename from INI file")); |
|
177 return EInconclusive; |
|
178 } |
|
179 |
|
180 RFs fs; |
|
181 TInt err = fs.Connect(); |
|
182 if (err != KErrNone) |
|
183 { |
|
184 INFO_PRINTF2(_L("Error connecting file session"), err); |
|
185 fs.Close(); |
|
186 return EInconclusive; |
|
187 } |
|
188 |
|
189 err = fs.Delete(filename); |
|
190 |
|
191 if (!((err == KErrNone) || (err == KErrNotFound))) |
|
192 { |
|
193 INFO_PRINTF2(_L("Error deleting output file"), err); |
|
194 return EInconclusive; |
|
195 } |
|
196 |
|
197 // Add create file for Ogg-tests |
|
198 if(iSectName == _L("SectionOggRec")) |
|
199 { |
|
200 RFs fs; |
|
201 User::LeaveIfError(fs.Connect()); |
|
202 RFile file; |
|
203 User::LeaveIfError(file.Replace(fs,filename,EFileWrite)); |
|
204 file.Close(); |
|
205 fs.Close(); |
|
206 } |
|
207 |
|
208 aRecUtil->OpenFileL(filename); |
|
209 INFO_PRINTF2(_L("CMdaAudioRecorderUtility->OpenFileL(%S)"), &filename); |
|
210 CActiveScheduler::Start(); |
|
211 |
|
212 if (iError != KErrNone) |
|
213 { |
|
214 INFO_PRINTF2(_L("Error opening file for recording"), iError); |
|
215 return EInconclusive; |
|
216 } |
|
217 |
|
218 // Set gain |
|
219 if(iGain == 0) |
|
220 { |
|
221 iGain = aRecUtil->MaxGain(); |
|
222 } |
|
223 |
|
224 aRecUtil->SetGain(iGain); |
|
225 |
|
226 // Set expected value |
|
227 TInt expectedGain = 0; |
|
228 if (iGain > aRecUtil->MaxGain()) |
|
229 { |
|
230 expectedGain = aRecUtil->MaxGain(); |
|
231 } |
|
232 |
|
233 else if (iGain < 0) |
|
234 { |
|
235 expectedGain = 0; |
|
236 } |
|
237 |
|
238 else |
|
239 { |
|
240 expectedGain = iGain; |
|
241 } |
|
242 |
|
243 |
|
244 aRecUtil->SetDestinationSampleRateL(8000); |
|
245 |
|
246 // Start recording |
|
247 aRecUtil->RecordL(); |
|
248 CActiveScheduler::Start(); |
|
249 User::After(1000000); |
|
250 |
|
251 // Get gain |
|
252 TInt gain; |
|
253 aRecUtil->GetGain(gain); |
|
254 |
|
255 // The gain should be not be more than max gain |
|
256 if (gain > aRecUtil->MaxGain()) |
|
257 { |
|
258 INFO_PRINTF3(_L("ERROR: GetGain value greater than MaxGain (%d > %d)"), gain, aRecUtil->MaxGain()); |
|
259 ret = EFail; |
|
260 } |
|
261 // The gain should not be less than 0 |
|
262 else if (gain < 0) |
|
263 { |
|
264 INFO_PRINTF3(_L("ERROR: GetGain value less than minimum gain (%d < %d)"), gain, 0); |
|
265 ret = EFail; |
|
266 } |
|
267 else if (gain != expectedGain) |
|
268 { |
|
269 ERR_PRINTF3(_L("ERROR: GetGain value not equal to expected value (%d != %d)"), gain, expectedGain); |
|
270 ret = EFail; |
|
271 } |
|
272 else |
|
273 { |
|
274 ret = EPass; |
|
275 } |
|
276 |
|
277 // stop the recording - only necessary if anyone wanted to look at the output file |
|
278 aRecUtil->Stop(); |
|
279 |
|
280 return ret; |
|
281 } |
|
282 |
|
283 //------------------------------------------------------------------ |
|
284 |
|
285 CTestMmfAclntRecStateTran::CTestMmfAclntRecStateTran(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
286 :CTestMmfAclntRecord(aTestName, aSectName, aNegative) |
|
287 {} |
|
288 |
|
289 CTestMmfAclntRecStateTran* CTestMmfAclntRecStateTran::NewL(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
290 { |
|
291 CTestMmfAclntRecStateTran* self = new (ELeave) CTestMmfAclntRecStateTran(aTestName, aSectName, aNegative); |
|
292 return self; |
|
293 } |
|
294 |
|
295 TVerdict CTestMmfAclntRecStateTran::DoTestStepL() |
|
296 { |
|
297 INFO_PRINTF1( _L("TestRecorder : Transition")); |
|
298 TVerdict ret = EFail; |
|
299 |
|
300 iError = KErrTimedOut; |
|
301 |
|
302 TPtrC filename; |
|
303 |
|
304 |
|
305 if(!GetStringFromConfig(iSectName, _L("outputAudioFile"), filename)) |
|
306 { |
|
307 return EInconclusive; |
|
308 } |
|
309 |
|
310 RFs fs; |
|
311 fs.Connect(); |
|
312 fs.Delete(filename); |
|
313 fs.Close(); |
|
314 |
|
315 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
316 CleanupStack::PushL(recUtil); |
|
317 |
|
318 // Add create file for Ogg-tests |
|
319 if(iSectName == _L("SectionOggRecState")) |
|
320 { |
|
321 RFs fs; |
|
322 User::LeaveIfError(fs.Connect()); |
|
323 RFile file; |
|
324 User::LeaveIfError(file.Replace(fs,filename,EFileWrite)); |
|
325 file.Close(); |
|
326 fs.Close(); |
|
327 } |
|
328 |
|
329 INFO_PRINTF2(_L("CMdaAudioRecorderUtility->OpenFileL(%S)"), &filename); |
|
330 recUtil->OpenFileL(filename); |
|
331 // wait |
|
332 INFO_PRINTF1(_L("Initialise CMdaAudioRecorderUtility")); |
|
333 CActiveScheduler::Start(); |
|
334 |
|
335 if(iError == KErrNone) |
|
336 { |
|
337 ret = DoTestL(recUtil); |
|
338 } |
|
339 |
|
340 |
|
341 CleanupStack::PopAndDestroy(recUtil); |
|
342 User::After(KTwoSeconds); |
|
343 ERR_PRINTF2( _L("CMdaAudioRecorderUtility completed with error %d"),iError ); |
|
344 return ret; |
|
345 } |
|
346 |
|
347 /** |
|
348 * Enquire state at each state transition. |
|
349 */ |
|
350 TVerdict CTestMmfAclntRecStateTran::DoTestL(CMdaAudioRecorderUtility* aRecUtil) |
|
351 { |
|
352 INFO_PRINTF1( _L("TestRecorder : State Transition")); |
|
353 |
|
354 TVerdict ret= EFail; |
|
355 |
|
356 iReportedState = aRecUtil->State(); |
|
357 if( iReportedState == CMdaAudioClipUtility::EOpen ) |
|
358 { |
|
359 INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility")); |
|
360 aRecUtil->RecordL(); |
|
361 CActiveScheduler::Start(); // wait for open -> record |
|
362 if (iError != KErrNone) |
|
363 { |
|
364 return EFail; |
|
365 } |
|
366 |
|
367 iReportedState = aRecUtil->State(); |
|
368 if(iReportedState == CMdaAudioClipUtility::ERecording ) |
|
369 { |
|
370 ret = EPass; |
|
371 } |
|
372 |
|
373 User::After(KTwoSeconds); |
|
374 aRecUtil->Stop(); |
|
375 |
|
376 iReportedState = aRecUtil->State(); |
|
377 if(iReportedState != CMdaAudioClipUtility::EOpen ) |
|
378 { |
|
379 return EFail; |
|
380 } |
|
381 |
|
382 aRecUtil->PlayL(); |
|
383 CActiveScheduler::Start(); // wait for open -> play |
|
384 if (iError != KErrNone) |
|
385 { |
|
386 return EFail; |
|
387 } |
|
388 |
|
389 iReportedState = aRecUtil->State(); |
|
390 if( iReportedState == CMdaAudioClipUtility::EPlaying ) |
|
391 { |
|
392 // Wait for play to complete |
|
393 CActiveScheduler::Start(); |
|
394 if (iError != KErrNone) |
|
395 { |
|
396 return EFail; |
|
397 } |
|
398 |
|
399 //copy file |
|
400 } |
|
401 } |
|
402 return ret; |
|
403 } |
|
404 |
|
405 //--------------------------------------------------------------------------------- |
|
406 |
|
407 CTestMmfFormatRead::CTestMmfFormatRead(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
408 :CTestMmfAclntRecord(aTestName, aSectName, aNegative) |
|
409 { |
|
410 } |
|
411 |
|
412 CTestMmfFormatRead* CTestMmfFormatRead::NewL(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
413 { |
|
414 CTestMmfFormatRead* self = new (ELeave) CTestMmfFormatRead(aTestName, aSectName, aNegative); |
|
415 return self; |
|
416 } |
|
417 |
|
418 _LIT(KFileXyz, "\\AclntITestData\\Test.xyz"); |
|
419 _LIT(KFileAbc, "\\AclntITestData\\Test.abc"); |
|
420 |
|
421 TVerdict CTestMmfFormatRead::DoTestStepL() |
|
422 { |
|
423 INFO_PRINTF1( _L("CTestMmfFormatRead : Opening the test files")); |
|
424 TVerdict ret = EPass; |
|
425 |
|
426 INFO_PRINTF1( _L("Opening the test file test.xyz")); |
|
427 |
|
428 TPtrC fileXyz(KFileXyz); |
|
429 |
|
430 // File with extension .xyz does not have a plugin and hence opening this file should fail. |
|
431 CMdaAudioRecorderUtility* recUtilXyz = CMdaAudioRecorderUtility::NewL(*this); |
|
432 CleanupStack::PushL(recUtilXyz); |
|
433 TRAP_IGNORE(recUtilXyz->OpenFileL(fileXyz)); |
|
434 CActiveScheduler::Start(); |
|
435 |
|
436 if (recUtilXyz->State() == CMdaAudioClipUtility::EOpen) |
|
437 { |
|
438 INFO_PRINTF1( _L("Opening the test file test.xyz failed")); |
|
439 ret = EFail; |
|
440 } |
|
441 |
|
442 CleanupStack::PopAndDestroy(recUtilXyz); |
|
443 |
|
444 INFO_PRINTF1( _L("Opening the test file test.abc")); |
|
445 TPtrC fileAbc(KFileAbc); |
|
446 |
|
447 // File with extension .abc does have a plugin and hence opening this file should pass. |
|
448 CMdaAudioRecorderUtility* recUtilAbc = CMdaAudioRecorderUtility::NewL(*this); |
|
449 CleanupStack::PushL(recUtilAbc); |
|
450 TRAP_IGNORE(recUtilAbc->OpenFileL(fileAbc)); |
|
451 CActiveScheduler::Start(); |
|
452 |
|
453 if (recUtilAbc->State() != CMdaAudioClipUtility::EOpen) |
|
454 { |
|
455 INFO_PRINTF1( _L("Opening the test file test.abc failed")); |
|
456 ret = EFail; |
|
457 } |
|
458 |
|
459 CleanupStack::PopAndDestroy(recUtilAbc); |
|
460 |
|
461 return ret; |
|
462 } |
|
463 |
|
464 /** |
|
465 * Enquire state at each state transition. |
|
466 */ |
|
467 |
|
468 TVerdict CTestMmfFormatRead::DoTestL(CMdaAudioRecorderUtility* /*aRecUtil*/) |
|
469 { |
|
470 INFO_PRINTF1( _L("CTestMmfFormatRead::DoTestL")); |
|
471 return (TVerdict(EPass)); |
|
472 } |
|
473 |
|
474 //------------------------------------------------------------------ |
|
475 |
|
476 /** |
|
477 * Constructor |
|
478 */ |
|
479 CTestMmfAclntCrop::CTestMmfAclntCrop(const TDesC& aTestName, const TDesC& aSectName, const TBool aCropToEnd, TBool aNegative) |
|
480 :CTestMmfAclntRecord(aTestName, aSectName, aNegative) |
|
481 { |
|
482 iCropToEnd = aCropToEnd; |
|
483 } |
|
484 |
|
485 CTestMmfAclntCrop* CTestMmfAclntCrop::NewL(const TDesC& aTestName, const TDesC& aSectName, const TBool aCropToEnd, TBool aNegative) |
|
486 { |
|
487 CTestMmfAclntCrop* self = new (ELeave) CTestMmfAclntCrop(aTestName, aSectName, aCropToEnd, aNegative); |
|
488 return self; |
|
489 } |
|
490 |
|
491 |
|
492 |
|
493 /** |
|
494 * Audio croping. |
|
495 */ |
|
496 TVerdict CTestMmfAclntCrop::DoTestL(CMdaAudioRecorderUtility* aRecUtil) |
|
497 { |
|
498 TTimeIntervalMicroSeconds expectedDuration(KPcm16FrameInterval * 5), duration; |
|
499 |
|
500 duration = aRecUtil->Duration(); |
|
501 INFO_PRINTF3(_L("Duration of Original file, expected = %f, actual: %f"), |
|
502 I64REAL(expectedDuration.Int64()), I64REAL(duration.Int64())); |
|
503 |
|
504 if(expectedDuration == duration) |
|
505 { |
|
506 return EInconclusive; |
|
507 } |
|
508 |
|
509 if(duration > expectedDuration) |
|
510 { |
|
511 aRecUtil->SetPosition(expectedDuration); |
|
512 |
|
513 if(iCropToEnd) |
|
514 { |
|
515 TRAP(iError, aRecUtil->CropL()); |
|
516 } |
|
517 else |
|
518 { |
|
519 TRAP(iError, aRecUtil->CropFromBeginningL()); |
|
520 } |
|
521 if(iError != KErrNone) |
|
522 { |
|
523 ERR_PRINTF2(_L("Crop left with error = %d"),iError); |
|
524 return EFail; |
|
525 } |
|
526 if(iCropToEnd) |
|
527 { |
|
528 TTimeIntervalMicroSeconds actualDuration = aRecUtil->Duration(); |
|
529 if (TimeComparison(I64INT(actualDuration.Int64()), I64INT(expectedDuration.Int64()), KExpectedDurationDeviation)) |
|
530 { |
|
531 INFO_PRINTF1(_L("Duration within expected deviation")); |
|
532 return EPass; |
|
533 } |
|
534 else |
|
535 { |
|
536 ERR_PRINTF3(_L("Duration cropped file, expected = %f, actual: %f"), |
|
537 I64REAL(expectedDuration.Int64()), I64REAL(actualDuration.Int64())); |
|
538 } |
|
539 } |
|
540 if(!iCropToEnd) |
|
541 { |
|
542 TInt64 theDelta = duration.Int64() - expectedDuration.Int64(); |
|
543 |
|
544 TTimeIntervalMicroSeconds actualDuration = aRecUtil->Duration(); |
|
545 if (TimeComparison(I64INT(actualDuration.Int64()), I64INT(theDelta), KExpectedDurationDeviation)) |
|
546 { |
|
547 INFO_PRINTF1(_L("Duration within expected deviation")); |
|
548 return EPass; |
|
549 } |
|
550 else |
|
551 { |
|
552 ERR_PRINTF3(_L("Duration cropped file, expected = %f, actual: %f"), |
|
553 I64REAL(theDelta), |
|
554 I64REAL(aRecUtil->Duration().Int64())); |
|
555 } |
|
556 } |
|
557 } |
|
558 return EFail ; |
|
559 } |
|
560 |
|
561 |
|
562 //------------------------------------------------------------------ |
|
563 |
|
564 CTestMmfAclntRecCloseOpen::CTestMmfAclntRecCloseOpen(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
565 :CTestMmfAclntRecord(aTestName, aSectName, aNegative) |
|
566 { |
|
567 } |
|
568 |
|
569 CTestMmfAclntRecCloseOpen* CTestMmfAclntRecCloseOpen::NewL(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
570 { |
|
571 CTestMmfAclntRecCloseOpen* self = new (ELeave) CTestMmfAclntRecCloseOpen(aTestName, aSectName, aNegative); |
|
572 return self; |
|
573 } |
|
574 |
|
575 TVerdict CTestMmfAclntRecCloseOpen::DoTestL(CMdaAudioRecorderUtility* aRecUtil) |
|
576 /** |
|
577 * Open, Close and open a new audio clip. |
|
578 */ |
|
579 { |
|
580 INFO_PRINTF1( _L("TestRecorder : Close/Open")); |
|
581 |
|
582 TBuf<KSizeBuf> filename; |
|
583 TPtrC filename1; |
|
584 |
|
585 if(!GetStringFromConfig(iSectName, _L("playerAudioFile"), filename1)) |
|
586 { |
|
587 return EInconclusive; |
|
588 } |
|
589 |
|
590 GetDriveName(filename); |
|
591 filename.Append(filename1); |
|
592 |
|
593 iError = KErrTimedOut; |
|
594 |
|
595 |
|
596 aRecUtil->Close(); |
|
597 aRecUtil->OpenFileL(filename); |
|
598 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
599 //wait |
|
600 CActiveScheduler::Start(); |
|
601 if(iError == KErrNone) |
|
602 { |
|
603 return EPass; |
|
604 } |
|
605 |
|
606 return EFail ; |
|
607 } |
|
608 |
|
609 |
|
610 //------------------------------------------------------------------ |
|
611 |
|
612 /** |
|
613 * Constructor |
|
614 */ |
|
615 CTestMmfAclntRecFile::CTestMmfAclntRecFile(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateFile) |
|
616 |
|
617 { |
|
618 iTestStepName = aTestName; |
|
619 iHeapSize = 200000; // playback part of test loads whole sound file into buffer, so need large heap |
|
620 iSectName = aSectName; |
|
621 iKeyName = aKeyName; |
|
622 iTestFormat = aFormat; |
|
623 iCreateFile = aCreateFile; |
|
624 } |
|
625 |
|
626 CTestMmfAclntRecFile* CTestMmfAclntRecFile::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateFile) |
|
627 { |
|
628 CTestMmfAclntRecFile* self = new (ELeave) CTestMmfAclntRecFile(aTestName,aSectName,aKeyName,aFormat,aCreateFile); |
|
629 return self; |
|
630 } |
|
631 |
|
632 CTestMmfAclntRecFile* CTestMmfAclntRecFile::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateFile) |
|
633 { |
|
634 CTestMmfAclntRecFile* self = CTestMmfAclntRecFile::NewLC(aTestName,aSectName,aKeyName,aFormat,aCreateFile); |
|
635 CleanupStack::PushL(self); |
|
636 return self; |
|
637 } |
|
638 |
|
639 void CTestMmfAclntRecFile::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt aCurrentState, TInt aErrorCode) |
|
640 { |
|
641 iError = aErrorCode; |
|
642 INFO_PRINTF1( _L("CTestMmfAclntRecFile : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete")); |
|
643 INFO_PRINTF2( _L("iError %d "), iError); |
|
644 |
|
645 if(aCurrentState == CMdaAudioClipUtility::ERecording) |
|
646 { |
|
647 User::After(KFiveSeconds); |
|
648 } |
|
649 CActiveScheduler::Stop(); |
|
650 } |
|
651 |
|
652 // Audio utility callbacks |
|
653 void CTestMmfAclntRecFile::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/) |
|
654 { |
|
655 iError = aError; |
|
656 CActiveScheduler::Stop(); |
|
657 } |
|
658 |
|
659 void CTestMmfAclntRecFile::MapcPlayComplete(TInt aError) |
|
660 { |
|
661 iError = aError; |
|
662 CActiveScheduler::Stop(); |
|
663 } |
|
664 |
|
665 // Audio output stream callbacks |
|
666 void CTestMmfAclntRecFile::MaoscOpenComplete(TInt aError) |
|
667 { |
|
668 iError = aError; |
|
669 CActiveScheduler::Stop(); |
|
670 } |
|
671 |
|
672 void CTestMmfAclntRecFile::MaoscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/) |
|
673 { |
|
674 iError = aError; |
|
675 CActiveScheduler::Stop(); |
|
676 } |
|
677 |
|
678 void CTestMmfAclntRecFile::MaoscPlayComplete(TInt aError) |
|
679 { |
|
680 iError = aError; |
|
681 CActiveScheduler::Stop(); |
|
682 } |
|
683 |
|
684 |
|
685 TVerdict CTestMmfAclntRecFile::DoTestStepPreambleL() |
|
686 { |
|
687 TVerdict ret = EPass; |
|
688 |
|
689 SetupFormatL(iTestFormat); |
|
690 |
|
691 if(iCreateFile) |
|
692 { |
|
693 // Make sure file doesn't exist (maybe from a previous test) |
|
694 TParse fullFileName; |
|
695 TBuf<KSizeBuf> filename; |
|
696 TPtrC filename1; |
|
697 |
|
698 if(!GetStringFromConfig(iSectName, iKeyName, filename1)) |
|
699 { |
|
700 return EInconclusive; |
|
701 } |
|
702 |
|
703 GetDriveName(filename); |
|
704 filename.Append(filename1); |
|
705 |
|
706 |
|
707 // parse the filenames |
|
708 if(!fullFileName.Set(filename, &KDefault, NULL)) |
|
709 { |
|
710 RFs fs; |
|
711 User::LeaveIfError(fs.Connect()); |
|
712 fs.SetAtt(fullFileName.FullName(), 0, KEntryAttReadOnly); |
|
713 TInt error = fs.Delete(fullFileName.FullName()); |
|
714 |
|
715 if(error == KErrPathNotFound) |
|
716 { |
|
717 error = fs.MkDirAll(fullFileName.DriveAndPath()); |
|
718 INFO_PRINTF2(_L("Path for file %S was been created"), &fullFileName.FullName()); |
|
719 } |
|
720 else if(error == KErrNotFound) |
|
721 INFO_PRINTF2(_L("No need to delete %S"), &fullFileName.FullName()); |
|
722 else if(error==KErrNone) |
|
723 INFO_PRINTF2(_L("Deleted %S"), &fullFileName.FullName()); |
|
724 else |
|
725 { |
|
726 ret = EInconclusive; |
|
727 } |
|
728 fs.Close(); |
|
729 } |
|
730 |
|
731 } |
|
732 |
|
733 if((ret == EInconclusive) || (ret == EFail)) |
|
734 { |
|
735 return ret; |
|
736 } |
|
737 |
|
738 return CTestMmfAclntStep::DoTestStepPreambleL(); |
|
739 } |
|
740 |
|
741 /** |
|
742 * Open a file based clip and record |
|
743 */ |
|
744 TVerdict CTestMmfAclntRecFile::DoTestStepL() |
|
745 { |
|
746 INFO_PRINTF1( _L("TestRecorder : Record File")); |
|
747 TVerdict ret = EFail; |
|
748 iError = KErrTimedOut; |
|
749 |
|
750 TPtrC filename; |
|
751 if(!GetStringFromConfig(iSectName, iKeyName, filename)) |
|
752 { |
|
753 return EInconclusive; |
|
754 } |
|
755 |
|
756 |
|
757 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
758 CleanupStack::PushL(recUtil); |
|
759 |
|
760 TMdaFileClipLocation location(filename); |
|
761 |
|
762 INFO_PRINTF2(_L("CMdaAudioRecorderUtility->OpenFileL(%S)"), &filename); |
|
763 if(!iCreateFile) |
|
764 { |
|
765 if(iSectName == _L("SectionOggRec")) // - Added to use OpenFileL only as OpenL parameters are deprected. |
|
766 { |
|
767 TPtrC filename2; |
|
768 |
|
769 if(!GetStringFromConfig(iSectName, _L("playerAudioFile"), filename2)) |
|
770 { |
|
771 return EInconclusive; |
|
772 } |
|
773 |
|
774 CopyFile(filename2, filename); |
|
775 } |
|
776 recUtil->OpenFileL(filename); |
|
777 } |
|
778 else |
|
779 { |
|
780 RFs fs; |
|
781 fs.Connect(); |
|
782 fs.Delete(filename); |
|
783 fs.Close(); |
|
784 if(iSectName == _L("SectionOggRec")) // - Added to use OpenFileL only as OpenL parameters are deprected. |
|
785 { |
|
786 recUtil->OpenFileL(filename); // - Should create the file internally |
|
787 } |
|
788 else |
|
789 { |
|
790 recUtil->OpenL(&location,iFormat,iCodec,&iAudioSettings); |
|
791 } |
|
792 } |
|
793 |
|
794 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
795 CActiveScheduler::Start(); |
|
796 |
|
797 if(iError == KErrNone) |
|
798 { |
|
799 iError = KErrTimedOut; |
|
800 recUtil->RecordL(); |
|
801 INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility")); |
|
802 CActiveScheduler::Start(); // open -> record |
|
803 |
|
804 recUtil->Stop(); |
|
805 } |
|
806 |
|
807 |
|
808 CleanupStack::PopAndDestroy(recUtil); |
|
809 recUtil = NULL; |
|
810 |
|
811 // Playback the file |
|
812 if (iError == KErrNone) |
|
813 { |
|
814 if (filename.Right(4).Compare(_L(".raw"))==0) |
|
815 { |
|
816 // Raw file playback |
|
817 CMdaAudioOutputStream* outputStream = CMdaAudioOutputStream::NewL(*this); |
|
818 CleanupStack::PushL(outputStream); |
|
819 |
|
820 outputStream->Open(NULL); |
|
821 CActiveScheduler::Start(); |
|
822 if (iError != KErrNone) |
|
823 { |
|
824 INFO_PRINTF2(_L("Error opening output stream for playback = %d"), iError); |
|
825 CleanupStack::PopAndDestroy(outputStream); |
|
826 return EFail; |
|
827 } |
|
828 |
|
829 // Connect file session |
|
830 RFs fs; |
|
831 TInt err = fs.Connect(); |
|
832 if (err != KErrNone) |
|
833 { |
|
834 INFO_PRINTF2(_L("Error connecting to file session = %d"), err); |
|
835 return EFail; |
|
836 } |
|
837 CleanupClosePushL(fs); |
|
838 |
|
839 // Open file |
|
840 RFile file; |
|
841 err = file.Open(fs, filename, EFileRead); |
|
842 if (err != KErrNone) |
|
843 { |
|
844 INFO_PRINTF2(_L("Error opening file = %d"), err); |
|
845 CleanupStack::PopAndDestroy(2, outputStream); // fs, outputStream |
|
846 return EFail; |
|
847 } |
|
848 CleanupClosePushL(file); |
|
849 |
|
850 // Get size of file |
|
851 TInt fileSize = 0; |
|
852 err = file.Size(fileSize); |
|
853 if (err != KErrNone) |
|
854 { |
|
855 INFO_PRINTF2(_L("Error getting size of file = %d"), err); |
|
856 CleanupStack::PopAndDestroy(3, outputStream); // file, fs, outputStream |
|
857 return EFail; |
|
858 } |
|
859 |
|
860 // Read file |
|
861 HBufC8* buf = HBufC8::NewLC(fileSize); |
|
862 TPtr8 ptr(buf->Des()); |
|
863 err = file.Read(ptr); |
|
864 if (err != KErrNone) |
|
865 { |
|
866 INFO_PRINTF2(_L("Error reading file %d"), err); |
|
867 } |
|
868 else |
|
869 { |
|
870 outputStream->WriteL(ptr); |
|
871 CActiveScheduler::Start(); |
|
872 if (iError != KErrNone) |
|
873 INFO_PRINTF2(_L("Error writing file on audio output stream %d"), iError); |
|
874 } |
|
875 |
|
876 CleanupStack::PopAndDestroy(4, outputStream); // buf, file, fs, outputStream |
|
877 } |
|
878 else |
|
879 { |
|
880 // Wav file playback |
|
881 CMdaAudioPlayerUtility* playUtil = CMdaAudioPlayerUtility::NewL(*this); |
|
882 CleanupStack::PushL(playUtil); |
|
883 TRAPD(err, playUtil->OpenFileL(filename)); |
|
884 if (err != KErrNone) |
|
885 { |
|
886 INFO_PRINTF2(_L("Error opening file for playback err = %d"), err); |
|
887 CleanupStack::PopAndDestroy(playUtil); |
|
888 return EFail; |
|
889 } |
|
890 CActiveScheduler::Start(); |
|
891 if (iError != KErrNone) |
|
892 { |
|
893 INFO_PRINTF2(_L("Error opening file for playback iError = %d"), iError); |
|
894 CleanupStack::PopAndDestroy(playUtil); |
|
895 return EFail; |
|
896 } |
|
897 playUtil->Play(); |
|
898 CActiveScheduler::Start(); |
|
899 CleanupStack::PopAndDestroy(playUtil); |
|
900 if (iError != KErrNone) |
|
901 { |
|
902 INFO_PRINTF2(_L("Error during playback of recorded file iError=%d"), iError); |
|
903 return EFail; |
|
904 } |
|
905 } |
|
906 } |
|
907 // DEF127335 |
|
908 // OggRecordController does not support recording into an already existing file. |
|
909 // This is due to unavailability of APIs at the level of Ogg Vorbis C libraries. |
|
910 else if (iTestStepName == _L("MM-MMF-ACLNTOGG-I-0102-CP") && iError == KErrNotSupported) |
|
911 { |
|
912 INFO_PRINTF1(_L("Expected Result: OggRecordController returned KErrNotSupported(-5)")); |
|
913 return EPass; |
|
914 } |
|
915 |
|
916 if( iError == KErrNone ) |
|
917 { |
|
918 RFs fs; |
|
919 RFile file; |
|
920 TInt size = 0; |
|
921 User::LeaveIfError(fs.Connect()); |
|
922 User::LeaveIfError(file.Open(fs,filename,EFileRead)); |
|
923 CleanupClosePushL(file); |
|
924 User::LeaveIfError(file.Size(size)); |
|
925 |
|
926 if(size > 0) |
|
927 { |
|
928 ret = EPass; |
|
929 } |
|
930 |
|
931 CleanupStack::PopAndDestroy(); //file |
|
932 } |
|
933 |
|
934 ERR_PRINTF2( _L("CMdaAudioRecorderUtility completed with error %d"),iError ); |
|
935 User::After(KOneSecond); |
|
936 return ret; |
|
937 } |
|
938 |
|
939 |
|
940 |
|
941 //------------------------------------------------------------------ |
|
942 |
|
943 /** |
|
944 * Constructor |
|
945 */ |
|
946 CTestMmfAclntRecFileForceFormat::CTestMmfAclntRecFileForceFormat(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TMdaClipFormat& aFormat) |
|
947 { |
|
948 // store the name of this test case |
|
949 // this is the name that is used by the script file |
|
950 // Each test step initialises it's own name |
|
951 iTestStepName = aTestName; |
|
952 iSectName = aSectName; |
|
953 iKeyName = aKeyName; |
|
954 iFormat = aFormat; |
|
955 } |
|
956 |
|
957 CTestMmfAclntRecFileForceFormat* CTestMmfAclntRecFileForceFormat::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TMdaClipFormat& aFormat) |
|
958 { |
|
959 CTestMmfAclntRecFileForceFormat* self = new (ELeave) CTestMmfAclntRecFileForceFormat(aTestName,aSectName,aKeyName,aFormat); |
|
960 return self; |
|
961 } |
|
962 |
|
963 CTestMmfAclntRecFileForceFormat* CTestMmfAclntRecFileForceFormat::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TMdaClipFormat& aFormat) |
|
964 { |
|
965 CTestMmfAclntRecFileForceFormat* self = CTestMmfAclntRecFileForceFormat::NewLC(aTestName,aSectName,aKeyName,aFormat); |
|
966 CleanupStack::PushL(self); |
|
967 return self; |
|
968 } |
|
969 |
|
970 void CTestMmfAclntRecFileForceFormat::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt aCurrentState, TInt aErrorCode) |
|
971 { |
|
972 iError = aErrorCode; |
|
973 INFO_PRINTF1( _L("CTestMmfAclntRecFile : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete")); |
|
974 INFO_PRINTF2( _L("iError %d "), iError); |
|
975 |
|
976 //dont stop the playing track |
|
977 if (aCurrentState != CMdaAudioClipUtility::EPlaying || iError != KErrNone) |
|
978 { |
|
979 CActiveScheduler::Stop(); |
|
980 } |
|
981 } |
|
982 |
|
983 |
|
984 TVerdict CTestMmfAclntRecFileForceFormat::DoTestStepPreambleL() |
|
985 { |
|
986 TVerdict ret = EPass; |
|
987 |
|
988 // Make sure file doesn't exist (maybe from a previous test) |
|
989 TParse fullFileName; |
|
990 TBuf<KSizeBuf> filename; |
|
991 TPtrC filename1; |
|
992 |
|
993 if(!GetStringFromConfig(iSectName, iKeyName, filename1)) |
|
994 { |
|
995 return EInconclusive; |
|
996 } |
|
997 |
|
998 |
|
999 GetDriveName(filename); |
|
1000 filename.Append(filename1); |
|
1001 |
|
1002 |
|
1003 // parse the filenames |
|
1004 if(!fullFileName.Set(filename, &KDefault, NULL)) |
|
1005 { |
|
1006 RFs fs; |
|
1007 User::LeaveIfError(fs.Connect()); |
|
1008 fs.SetAtt(fullFileName.FullName(), 0, KEntryAttReadOnly); |
|
1009 TInt error = fs.Delete(fullFileName.FullName()); |
|
1010 |
|
1011 if(error == KErrPathNotFound) |
|
1012 { |
|
1013 error = fs.MkDirAll(fullFileName.DriveAndPath()); |
|
1014 INFO_PRINTF2(_L("Path for file %S was been created"), &fullFileName.FullName()); |
|
1015 } |
|
1016 else if(error == KErrNotFound) |
|
1017 INFO_PRINTF2(_L("No need to delete %S"), &fullFileName.FullName()); |
|
1018 else if(error==KErrNone) |
|
1019 INFO_PRINTF2(_L("Deleted %S"), &fullFileName.FullName()); |
|
1020 else |
|
1021 { |
|
1022 ret = EInconclusive; |
|
1023 } |
|
1024 fs.Close(); |
|
1025 } |
|
1026 |
|
1027 if((ret == EInconclusive) || (ret == EFail)) |
|
1028 { |
|
1029 return ret; |
|
1030 } |
|
1031 |
|
1032 return CTestMmfAclntStep::DoTestStepPreambleL(); |
|
1033 } |
|
1034 |
|
1035 /** |
|
1036 * Open a file based clip and record |
|
1037 */ |
|
1038 |
|
1039 |
|
1040 TVerdict CTestMmfAclntRecFileForceFormat::DoTestStepL() |
|
1041 { |
|
1042 INFO_PRINTF1( _L("TestRecorder : Record File")); |
|
1043 TVerdict ret = EFail; |
|
1044 iError = KErrTimedOut; |
|
1045 |
|
1046 TPtrC filename; |
|
1047 if(!GetStringFromConfig(iSectName, iKeyName, filename)) |
|
1048 { |
|
1049 return EInconclusive; |
|
1050 } |
|
1051 |
|
1052 |
|
1053 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
1054 CleanupStack::PushL(recUtil); |
|
1055 |
|
1056 TMdaFileClipLocation location(filename); |
|
1057 |
|
1058 RFs fs; |
|
1059 fs.Connect(); |
|
1060 fs.Delete(filename); |
|
1061 fs.Close(); |
|
1062 |
|
1063 recUtil->OpenL(&location,&iFormat); |
|
1064 |
|
1065 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
1066 CActiveScheduler::Start(); |
|
1067 |
|
1068 if(iError == KErrNone) |
|
1069 { |
|
1070 iError = KErrTimedOut; |
|
1071 recUtil->RecordL(); |
|
1072 INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility")); |
|
1073 CActiveScheduler::Start(); // open -> record |
|
1074 |
|
1075 User::After(KTwoSeconds); |
|
1076 recUtil->Stop(); |
|
1077 |
|
1078 //now try to play the file as a check that it recorded correctly |
|
1079 recUtil->PlayL(); |
|
1080 CActiveScheduler::Start(); |
|
1081 |
|
1082 recUtil->Close(); |
|
1083 |
|
1084 |
|
1085 if(iError == KErrNone) |
|
1086 { |
|
1087 RFs fs; |
|
1088 RFile file; |
|
1089 TInt size = 0; |
|
1090 |
|
1091 User::LeaveIfError(fs.Connect()); |
|
1092 User::LeaveIfError(file.Open(fs,filename,EFileRead)); |
|
1093 CleanupClosePushL(file); |
|
1094 User::LeaveIfError(file.Size(size)); |
|
1095 |
|
1096 if(size > 0) |
|
1097 { |
|
1098 ret = EPass; |
|
1099 } |
|
1100 |
|
1101 CleanupStack::PopAndDestroy(); //file |
|
1102 } |
|
1103 } |
|
1104 ERR_PRINTF2( _L("CMdaAudioRecorderUtility completed with error %d"),iError ); |
|
1105 CleanupStack::PopAndDestroy(recUtil); |
|
1106 User::After(KOneSecond); |
|
1107 return ret; |
|
1108 } |
|
1109 |
|
1110 |
|
1111 //------------------------------------------------------------------ |
|
1112 |
|
1113 /** |
|
1114 * Constructor |
|
1115 */ |
|
1116 CTestMmfAclntRecDes::CTestMmfAclntRecDes(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateDes): |
|
1117 iAudioPtr(NULL,0,0) |
|
1118 { |
|
1119 // store the name of this test case |
|
1120 // this is the name that is used by the script file |
|
1121 // Each test step initialises it's own name |
|
1122 iTestStepName = aTestName; |
|
1123 iSectName = aSectName; |
|
1124 iKeyName = aKeyName; |
|
1125 iTestFormat = aFormat; |
|
1126 iCreateDes = aCreateDes; |
|
1127 iSize = 0; |
|
1128 iAudio = NULL; |
|
1129 iHeapSize = 100000; |
|
1130 } |
|
1131 |
|
1132 CTestMmfAclntRecDes* CTestMmfAclntRecDes::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat,const TBool aCreateDes) |
|
1133 { |
|
1134 CTestMmfAclntRecDes* self = new (ELeave) CTestMmfAclntRecDes(aTestName,aSectName,aKeyName,aFormat,aCreateDes); |
|
1135 return self; |
|
1136 } |
|
1137 |
|
1138 CTestMmfAclntRecDes* CTestMmfAclntRecDes::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateDes) |
|
1139 { |
|
1140 CTestMmfAclntRecDes* self = CTestMmfAclntRecDes::NewLC(aTestName,aSectName,aKeyName,aFormat,aCreateDes); |
|
1141 CleanupStack::PushL(self); |
|
1142 return self; |
|
1143 } |
|
1144 |
|
1145 void CTestMmfAclntRecDes::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode) |
|
1146 { |
|
1147 iError = aErrorCode; |
|
1148 INFO_PRINTF4( _L("MMdaObjectStateChangeObserver: previous state: %d current state: %d error: %d"),aPreviousState, aCurrentState, aErrorCode); |
|
1149 CActiveScheduler::Stop(); |
|
1150 } |
|
1151 |
|
1152 TVerdict CTestMmfAclntRecDes::DoTestStepPreambleL() |
|
1153 { |
|
1154 SetupFormatL(iTestFormat); |
|
1155 |
|
1156 switch (iTestFormat) |
|
1157 { |
|
1158 case EPcm16Wav: |
|
1159 case EAlawWav: |
|
1160 case EPcm8: |
|
1161 iHeaderSize = KWavFileUncompressedDataHeaderSize; //(see mmfwavformat.cpp, CreateSinkBufferOfSizeL()) |
|
1162 iFrameSize = 4096; |
|
1163 break; |
|
1164 case EImaAdpcmWav: |
|
1165 case EImasPcmWav: |
|
1166 iHeaderSize = KWavFileCompressedDataHeaderSize + KImaAdpcmFactChunkSize; |
|
1167 iFrameSize = 4096; |
|
1168 break; |
|
1169 case EMulawRaw: |
|
1170 case EPcmU8: |
|
1171 case EPcmU16: |
|
1172 iHeaderSize = 0; |
|
1173 iFrameSize = 4096; |
|
1174 break; |
|
1175 case EGsmWav: |
|
1176 iHeaderSize = KWavFileCompressedDataHeaderSize + KGSMFactChunkSize; |
|
1177 iFrameSize = 4095; |
|
1178 break; |
|
1179 default: |
|
1180 /*skip*/ ; |
|
1181 } |
|
1182 |
|
1183 if(!iCreateDes) |
|
1184 { |
|
1185 RFs fs; |
|
1186 RFile file; |
|
1187 |
|
1188 TBuf<KSizeBuf> filename; |
|
1189 TPtrC filename1; |
|
1190 if(!GetStringFromConfig(iSectName, iKeyName, filename1)) |
|
1191 { |
|
1192 return EInconclusive; |
|
1193 } |
|
1194 |
|
1195 GetDriveName(filename); |
|
1196 filename.Append(filename1); |
|
1197 INFO_PRINTF2(_L("File for test - %S"), &filename); |
|
1198 |
|
1199 User::LeaveIfError(fs.Connect()); |
|
1200 User::LeaveIfError(file.Open(fs,filename,EFileRead)); |
|
1201 CleanupClosePushL(file); |
|
1202 |
|
1203 User::LeaveIfError(file.Size(iSize)); |
|
1204 INFO_PRINTF2(_L("size of file = %d\n"),iSize);//Statement Changed under DEF105143 |
|
1205 iAudio = HBufC8::NewMaxL(iSize); |
|
1206 |
|
1207 // Read a file into a descriptor |
|
1208 iAudioPtr.Set(iAudio->Des()); |
|
1209 User::LeaveIfError(file.Read(iAudioPtr)); |
|
1210 |
|
1211 CleanupStack::PopAndDestroy(); //file |
|
1212 } |
|
1213 else |
|
1214 { |
|
1215 INFO_PRINTF1(_L("Recording to New Descriptor for test")); |
|
1216 iSize = KRecSize; // value is not been set yet. |
|
1217 iAudio = HBufC8::NewMaxL(iSize); |
|
1218 iAudioPtr.Set(iAudio->Des()); |
|
1219 iAudioPtr.SetLength(0); |
|
1220 } |
|
1221 |
|
1222 return CTestMmfAclntStep::DoTestStepPreambleL(); |
|
1223 } |
|
1224 |
|
1225 TVerdict CTestMmfAclntRecDes::DoTestStepPostambleL() |
|
1226 { |
|
1227 delete iAudio; |
|
1228 return CTestMmfAclntCodecTest::DoTestStepPostambleL(); |
|
1229 } |
|
1230 |
|
1231 /** |
|
1232 * Open a descriptor and record |
|
1233 */ |
|
1234 TVerdict CTestMmfAclntRecDes::DoTestStepL( void ) |
|
1235 { |
|
1236 INFO_PRINTF1( _L("TestRecorder : Record Des")); |
|
1237 TVerdict ret = EFail; |
|
1238 TMdaDesClipLocation* location = NULL; |
|
1239 |
|
1240 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
1241 CleanupStack::PushL(recUtil); |
|
1242 |
|
1243 if(!iCreateDes) |
|
1244 { |
|
1245 recUtil->OpenDesL(iAudioPtr); |
|
1246 } |
|
1247 else |
|
1248 { |
|
1249 location = new (ELeave) TMdaDesClipLocation(iAudioPtr); |
|
1250 CleanupStack::PushL(location); |
|
1251 recUtil->OpenL(location,iFormat,iCodec,&iAudioSettings); |
|
1252 CleanupStack::PopAndDestroy(location); |
|
1253 } |
|
1254 |
|
1255 iError = KErrTimedOut; |
|
1256 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
1257 CActiveScheduler::Start(); |
|
1258 |
|
1259 if(iError == KErrNone) |
|
1260 { |
|
1261 // set the sample rate to 8K, otherwise the default value of 44.1Kh will be used |
|
1262 // resulting in very large buffers (11K) |
|
1263 recUtil->SetDestinationSampleRateL(8000); |
|
1264 |
|
1265 iError = KErrTimedOut; |
|
1266 recUtil->RecordL(); |
|
1267 INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility")); |
|
1268 CActiveScheduler::Start(); // open->record |
|
1269 if (iError != KErrNone) |
|
1270 { |
|
1271 // DEF127335 |
|
1272 // OggRecordController does not support recording into an already existing descriptor. |
|
1273 // This is due to unavailability of APIs at the level of Ogg Vorbis C libraries. |
|
1274 if (iTestStepName == _L("MM-MMF-ACLNTOGG-I-0103-CP") && iError == KErrNotSupported) |
|
1275 { |
|
1276 INFO_PRINTF1(_L("Expected Result: OggRecordController returned KErrNotSupported(-5)")); |
|
1277 ret = EPass; |
|
1278 } |
|
1279 ERR_PRINTF2( _L("CMdaAudioRecorderUtility failed with error %d"),iError ); |
|
1280 CleanupStack::PopAndDestroy(recUtil); |
|
1281 User::After(KOneSecond); |
|
1282 return ret; |
|
1283 } |
|
1284 // wait to run out of space recording |
|
1285 CActiveScheduler::Start(); // record -> open |
|
1286 |
|
1287 if (iError != KErrOverflow) |
|
1288 { |
|
1289 ERR_PRINTF2( _L("CMdaAudioRecorderUtility failed with error %d"),iError ); |
|
1290 CleanupStack::PopAndDestroy(recUtil); |
|
1291 User::After(KOneSecond); |
|
1292 return ret; |
|
1293 } |
|
1294 |
|
1295 TInt expectedLength=0; |
|
1296 TInt actualLength = iAudio->Length(); |
|
1297 if(iCreateDes) |
|
1298 { |
|
1299 // Calculuate the frame size which is now dynamic. |
|
1300 // This is more or less a duplicate of the calculation in |
|
1301 // CMMFAudioInput::NegotiateSourceL() |
|
1302 expectedLength = iSize; |
|
1303 TUint sampleRate = recUtil->DestinationSampleRateL(); |
|
1304 TUint bitRate = recUtil->DestinationBitRateL(); |
|
1305 |
|
1306 //xxx work around for GSM which returns zero as the bit rate because internally |
|
1307 // BitsPerSample is zero |
|
1308 if (bitRate==0) |
|
1309 { |
|
1310 bitRate = sampleRate * 8; |
|
1311 } |
|
1312 |
|
1313 TUint numberOfChannels = recUtil->DestinationNumberOfChannelsL(); |
|
1314 iFrameSize = (bitRate * numberOfChannels / 8) / 4; |
|
1315 iFrameSize = (iFrameSize + (KAudioInputDeltaFrameSize-1)) &~ (KAudioInputDeltaFrameSize-1); |
|
1316 if(iFrameSize < KAudioInputMinFrameSize) |
|
1317 { |
|
1318 iFrameSize = KAudioInputMinFrameSize; |
|
1319 } |
|
1320 |
|
1321 else if(iFrameSize > KAudioInputMaxFrameSize) |
|
1322 { |
|
1323 iFrameSize = KAudioInputMaxFrameSize; |
|
1324 } |
|
1325 |
|
1326 // GSM will onlt write out an integral number of GSM frames |
|
1327 // which are 65 bytes long.. |
|
1328 if (iTestFormat == EGsmWav) |
|
1329 { |
|
1330 iFrameSize = (iFrameSize / KGsmEncodedFrameSize) * KGsmEncodedFrameSize; |
|
1331 } |
|
1332 |
|
1333 |
|
1334 expectedLength = ((iSize-iHeaderSize) / iFrameSize)* iFrameSize + iHeaderSize; |
|
1335 |
|
1336 INFO_PRINTF2(_L("sampleRate = %d"), sampleRate); |
|
1337 INFO_PRINTF2(_L("bitRate = %d"), bitRate); |
|
1338 INFO_PRINTF2(_L("numberOfChannels = %d"), numberOfChannels); |
|
1339 INFO_PRINTF2(_L("iFrameSize = %d"), iFrameSize); |
|
1340 INFO_PRINTF2(_L("Duration = %d"), I64LOW(recUtil->Duration().Int64())); |
|
1341 INFO_PRINTF3(_L("Expected length %d, actual length %d"), expectedLength, actualLength); |
|
1342 |
|
1343 |
|
1344 #if defined __WRITE_CONVERSION_TO_FILE |
|
1345 { |
|
1346 _LIT(KFileOut, "\\TEST.WAV"); |
|
1347 RFs fs; |
|
1348 |
|
1349 fs.Connect(); |
|
1350 RFile file; |
|
1351 file.Replace(fs, KFileOut(), EFileWrite); |
|
1352 file.Write(iAudio->Des()); |
|
1353 TInt len = iAudio->Length(); |
|
1354 file.Size(len); |
|
1355 file.Close(); |
|
1356 fs.Close(); |
|
1357 } |
|
1358 #endif |
|
1359 |
|
1360 // a more forgiving test would be : |
|
1361 //if ((actualLength <= expectedLength) && |
|
1362 // (actualLength >= (expectedLength - iFrameSize))) |
|
1363 |
|
1364 // if test is GSM then we expect it to be between |
|
1365 // expected Length and (iSize - iHeaderSize) |
|
1366 if ((iTestFormat == EGsmWav) && |
|
1367 (actualLength <= (iSize - iHeaderSize)) && |
|
1368 (actualLength >= expectedLength) ) |
|
1369 { |
|
1370 ret = EPass; |
|
1371 } |
|
1372 else if (iAudio->Length() == expectedLength) |
|
1373 { |
|
1374 ret = EPass; |
|
1375 } |
|
1376 else |
|
1377 { |
|
1378 INFO_PRINTF3(_L("Expected length %d, actual length %d"), expectedLength, actualLength); |
|
1379 |
|
1380 TInt machineType; |
|
1381 TInt err = HAL::Get(HALData::EMachineUid, machineType); |
|
1382 if (err) |
|
1383 { |
|
1384 ERR_PRINTF1(_L("Error Getting Device information")); |
|
1385 iTestStepResult = EFail; |
|
1386 CActiveScheduler::Stop(); |
|
1387 } |
|
1388 else |
|
1389 { |
|
1390 if ((machineType == 0x102864F7) && (sampleRate == 8000)) |
|
1391 { |
|
1392 // If test is running on a NaviEngine and uses 8K sample rate |
|
1393 // then apply a tollerance when checking duration as we will |
|
1394 // have applied conversion function. |
|
1395 if ((iAudio->Length() >= expectedLength - 1000) && |
|
1396 (iAudio->Length() <= expectedLength + 1000)) |
|
1397 { |
|
1398 ret = EPass; |
|
1399 } |
|
1400 } |
|
1401 } |
|
1402 } |
|
1403 } |
|
1404 else |
|
1405 { |
|
1406 expectedLength = iSize; |
|
1407 |
|
1408 if(iAudio->Length() == expectedLength) |
|
1409 { |
|
1410 ret = EPass; |
|
1411 } |
|
1412 |
|
1413 else |
|
1414 { |
|
1415 INFO_PRINTF3(_L("Expected length %d, actual length %d"), expectedLength, actualLength); |
|
1416 } |
|
1417 |
|
1418 } |
|
1419 } |
|
1420 |
|
1421 |
|
1422 if (ret != EPass) |
|
1423 { |
|
1424 ERR_PRINTF2( _L("CMdaAudioRecorderUtility failed with error %d"),iError ); |
|
1425 } |
|
1426 |
|
1427 |
|
1428 CleanupStack::PopAndDestroy(recUtil); |
|
1429 User::After(KOneSecond); |
|
1430 return ret; |
|
1431 } |
|
1432 |
|
1433 //------------------------------------------------------------------ |
|
1434 |
|
1435 /** |
|
1436 * Constructor |
|
1437 */ |
|
1438 CTestMmfAclntRecUrl::CTestMmfAclntRecUrl(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName) |
|
1439 { |
|
1440 // store the name of this test case |
|
1441 // this is the name that is used by the script file |
|
1442 // Each test step initialises it's own name |
|
1443 iTestStepName = aTestName; |
|
1444 iSectName = aSectName; |
|
1445 iKeyName = aKeyName; |
|
1446 } |
|
1447 |
|
1448 CTestMmfAclntRecUrl* CTestMmfAclntRecUrl::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName) |
|
1449 { |
|
1450 CTestMmfAclntRecUrl* self = new (ELeave) CTestMmfAclntRecUrl(aTestName,aSectName,aKeyName); |
|
1451 return self; |
|
1452 } |
|
1453 |
|
1454 CTestMmfAclntRecUrl* CTestMmfAclntRecUrl::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName) |
|
1455 { |
|
1456 CTestMmfAclntRecUrl* self = CTestMmfAclntRecUrl::NewLC(aTestName,aSectName,aKeyName); |
|
1457 CleanupStack::PushL(self); |
|
1458 return self; |
|
1459 }; |
|
1460 |
|
1461 void CTestMmfAclntRecUrl::MoscoStateChangeEvent(CBase* /*aObject*/, |
|
1462 TInt /*aPreviousState*/, |
|
1463 TInt /*aCurrentState*/, |
|
1464 TInt aErrorCode) |
|
1465 { |
|
1466 iError = aErrorCode; |
|
1467 INFO_PRINTF1( _L("CTestMmfAclntRecUrl : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete")); |
|
1468 INFO_PRINTF2( _L("iError %d"), iError); |
|
1469 CActiveScheduler::Stop(); |
|
1470 } |
|
1471 |
|
1472 /** |
|
1473 * Open a URL |
|
1474 */ |
|
1475 TVerdict CTestMmfAclntRecUrl::DoTestStepL( void ) |
|
1476 { |
|
1477 INFO_PRINTF1( _L("TestRecorder : Record URL")); |
|
1478 TPtrC url; |
|
1479 if(!GetStringFromConfig(iSectName, iKeyName, url)) |
|
1480 { |
|
1481 return EInconclusive; |
|
1482 } |
|
1483 |
|
1484 |
|
1485 TVerdict ret = EFail; |
|
1486 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
1487 CleanupStack::PushL(recUtil); |
|
1488 |
|
1489 TRAP_IGNORE(recUtil->OpenUrlL(url, KUseDefaultIap, _L8("Audio/Wav"))); |
|
1490 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
1491 CActiveScheduler::Start(); |
|
1492 |
|
1493 if(iError == KErrNotSupported) |
|
1494 { |
|
1495 ret = EPass; |
|
1496 } |
|
1497 |
|
1498 ERR_PRINTF2( _L("CMdaAudioRecorderUtility completed with error %d"),iError ); |
|
1499 CleanupStack::PopAndDestroy(recUtil); |
|
1500 return ret; |
|
1501 } |
|
1502 |
|
1503 //------------------------------------------------------------------ |
|
1504 |
|
1505 CTestMmfAclntRecPosition::CTestMmfAclntRecPosition(const TDesC& aTestName, const TDesC& aSectName, const TTimeIntervalMicroSeconds& aPosition, TBool aNegative) |
|
1506 :CTestMmfAclntRecord(aTestName, aSectName, aNegative), iPosition(aPosition) |
|
1507 { |
|
1508 } |
|
1509 |
|
1510 CTestMmfAclntRecPosition* CTestMmfAclntRecPosition::NewL(const TDesC& aTestName, const TDesC& aSectName, const TTimeIntervalMicroSeconds& aPosition, TBool aNegative) |
|
1511 { |
|
1512 CTestMmfAclntRecPosition* self = new (ELeave) CTestMmfAclntRecPosition(aTestName, aSectName, aPosition, aNegative); |
|
1513 return self; |
|
1514 } |
|
1515 |
|
1516 TVerdict CTestMmfAclntRecPosition::DoTestL(CMdaAudioRecorderUtility* aRecUtil) |
|
1517 { |
|
1518 INFO_PRINTF1( _L("TestRecorder : Position")); |
|
1519 TVerdict ret = EFail; |
|
1520 TBool validPosition = EFalse; |
|
1521 |
|
1522 // Set position: middle of clip. |
|
1523 if (I64INT(iPosition.Int64()) == 0) |
|
1524 { |
|
1525 iPosition = I64INT(aRecUtil->Duration().Int64())/2; |
|
1526 } |
|
1527 |
|
1528 // Set position: end of clip. |
|
1529 if (I64INT(iPosition.Int64()) == -1) |
|
1530 { |
|
1531 iPosition = aRecUtil->Duration(); |
|
1532 } |
|
1533 |
|
1534 aRecUtil->PlayL(); //Begin to Play otherwise position can not be set. |
|
1535 // Position is beyond the end of the clips duration. |
|
1536 // so check that the value is clipped. |
|
1537 if(aRecUtil->Duration() < iPosition) |
|
1538 { |
|
1539 aRecUtil->SetPosition(iPosition); |
|
1540 |
|
1541 TInt64 temp = (aRecUtil->Duration().Int64() / KPcm16FrameInterval) - 1; // -1 for DevSound |
|
1542 if(aRecUtil->Position().Int64() == (temp * KPcm16FrameInterval)) |
|
1543 { |
|
1544 validPosition = ETrue; |
|
1545 } |
|
1546 |
|
1547 } |
|
1548 else |
|
1549 { |
|
1550 aRecUtil->SetPosition(iPosition); |
|
1551 //CActiveScheduler::Start(); |
|
1552 |
|
1553 TInt64 temp = (iPosition.Int64() / KPcm16FrameInterval) - 1; // -1 for DevSound |
|
1554 TInt64 thePosActual = aRecUtil->Position().Int64(); |
|
1555 TInt64 thePosExpected = temp * KPcm16FrameInterval; |
|
1556 aRecUtil->Stop(); |
|
1557 |
|
1558 if (TimeComparison(I64INT(thePosActual), I64INT(thePosExpected), KExpectedDeviation)) |
|
1559 { |
|
1560 validPosition = ETrue; |
|
1561 } |
|
1562 } |
|
1563 |
|
1564 if ((iNegative) && (!validPosition)) |
|
1565 { |
|
1566 ret = EPass; |
|
1567 } |
|
1568 |
|
1569 // Postion was set to a valid value. |
|
1570 if(validPosition) |
|
1571 { |
|
1572 ret = EPass; |
|
1573 } |
|
1574 return ret; |
|
1575 } |
|
1576 |
|
1577 //------------------------------------------------------------------ |
|
1578 |
|
1579 CTestMmfAclntRecDuration::CTestMmfAclntRecDuration(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
1580 :CTestMmfAclntRecord(aTestName, aSectName, aNegative) |
|
1581 { |
|
1582 } |
|
1583 |
|
1584 CTestMmfAclntRecDuration* CTestMmfAclntRecDuration::NewL(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
1585 { |
|
1586 CTestMmfAclntRecDuration* self = new (ELeave) CTestMmfAclntRecDuration(aTestName, aSectName, aNegative); |
|
1587 return self; |
|
1588 } |
|
1589 |
|
1590 TVerdict CTestMmfAclntRecDuration::DoTestL(CMdaAudioRecorderUtility* aRecUtil) |
|
1591 { |
|
1592 INFO_PRINTF1( _L("TestRecorder : Duration")); |
|
1593 TVerdict ret = EFail; |
|
1594 |
|
1595 if(iSectName == _L("SectionOggRec")) |
|
1596 { |
|
1597 if (I64INT(aRecUtil->Duration().Int64()) == KSoundFileLength) |
|
1598 ret = EPass; |
|
1599 } |
|
1600 else if (TimeComparison(I64INT(aRecUtil->Duration().Int64()), KSoundFileLength, KExpectedDeviation)) |
|
1601 { |
|
1602 ret = EPass; |
|
1603 } |
|
1604 |
|
1605 else |
|
1606 INFO_PRINTF3(_L("unexpected duration = %u, expected = %u"), I64INT(aRecUtil->Duration().Int64()), KSoundFileLength); |
|
1607 return ret; |
|
1608 } |
|
1609 |
|
1610 //------------------------------------------------------------------ |
|
1611 |
|
1612 CTestMmfAclntRecSetMeta::CTestMmfAclntRecSetMeta(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
1613 :CTestMmfAclntRecord(aTestName, aSectName, aNegative) |
|
1614 { |
|
1615 } |
|
1616 |
|
1617 CTestMmfAclntRecSetMeta* CTestMmfAclntRecSetMeta::NewL(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
1618 { |
|
1619 CTestMmfAclntRecSetMeta* self = new (ELeave) CTestMmfAclntRecSetMeta(aTestName, aSectName, aNegative); |
|
1620 return self; |
|
1621 } |
|
1622 |
|
1623 _LIT(name,"<Copyright>"); |
|
1624 _LIT(data,"<Symbian (c) 2002>"); |
|
1625 _LIT(name2,"Artist"); |
|
1626 _LIT(data2,"Test"); |
|
1627 /** |
|
1628 * Set meta-information |
|
1629 */ |
|
1630 TVerdict CTestMmfAclntRecSetMeta::DoTestL(CMdaAudioRecorderUtility* aRecUtil) |
|
1631 { |
|
1632 INFO_PRINTF1( _L("TestRecorder : Set Metadata")); |
|
1633 TVerdict ret = EFail; |
|
1634 |
|
1635 // build a meta daat object |
|
1636 CMMFMetaDataEntry* metaData[2]; |
|
1637 metaData[0] = CMMFMetaDataEntry::NewL(name,data); |
|
1638 CleanupStack::PushL(metaData[0]); |
|
1639 metaData[1] = CMMFMetaDataEntry::NewL(name2,data2); |
|
1640 CleanupStack::PushL(metaData[1]); |
|
1641 |
|
1642 TInt numEntries; |
|
1643 TInt err = aRecUtil->GetNumberOfMetaDataEntries(numEntries); |
|
1644 if(err != KErrNone) |
|
1645 { |
|
1646 INFO_PRINTF2(_L("GetNumberOfMetaDataEntries() returned error %d"), err); |
|
1647 numEntries = 0; // so we don't try and remove anything |
|
1648 } |
|
1649 |
|
1650 // *** JW adapted test - remove any existing metadata |
|
1651 // this means that a modified test file will not cause inconclusive |
|
1652 if(numEntries != 0) |
|
1653 { |
|
1654 INFO_PRINTF2(_L("Removing %d existing entries..."), numEntries); |
|
1655 for(TInt i = numEntries - 1; i >= 0; i--) |
|
1656 { |
|
1657 err = aRecUtil->RemoveMetaDataEntry(i); |
|
1658 if(err != KErrNone) |
|
1659 { |
|
1660 INFO_PRINTF3(_L("RemoveMetaDataEntry(%d) returned error %d"), i, err); |
|
1661 } |
|
1662 } |
|
1663 aRecUtil->GetNumberOfMetaDataEntries(numEntries); |
|
1664 } |
|
1665 |
|
1666 if(numEntries == 0) |
|
1667 { |
|
1668 TRAPD(err, aRecUtil->AddMetaDataEntryL(*metaData[0])); |
|
1669 if(err != KErrNone) |
|
1670 { |
|
1671 INFO_PRINTF2(_L("AddMetaDataEntryL(*metaData[0]) left with error %d"), err); |
|
1672 } |
|
1673 |
|
1674 |
|
1675 TRAP(err, aRecUtil->AddMetaDataEntryL(*metaData[1])); |
|
1676 if(err != KErrNone) |
|
1677 { |
|
1678 INFO_PRINTF2(_L("AddMetaDataEntryL(*metaData[1]) left with error %d"), err); |
|
1679 } |
|
1680 |
|
1681 CleanupStack::PopAndDestroy(metaData[1]); |
|
1682 CleanupStack::PopAndDestroy(metaData[0]); |
|
1683 |
|
1684 if(err) |
|
1685 { |
|
1686 if(err == KErrNotSupported) // Audio Controller doesn't support - this is ok |
|
1687 { |
|
1688 // |
|
1689 // C-COVER Reports the following methods are not being called |
|
1690 // Remove when metaData is supported |
|
1691 TRAP(err,aRecUtil->GetNumberOfMetaDataEntries(numEntries)); |
|
1692 CMMFMetaDataEntry* testData=NULL; |
|
1693 for(TInt i=0;i<numEntries;i++) |
|
1694 { |
|
1695 TRAP(err,testData = aRecUtil->GetMetaDataEntryL(0)); |
|
1696 //REPLACE WITH ITSELF?? |
|
1697 TRAP(err,aRecUtil->ReplaceMetaDataEntryL(i,*testData)); |
|
1698 TRAP(err,aRecUtil->RemoveMetaDataEntry(i));//@@@ |
|
1699 } |
|
1700 |
|
1701 // |
|
1702 |
|
1703 INFO_PRINTF1(_L("Note : Audio Controller does not support metadata")); |
|
1704 return EPass; |
|
1705 } |
|
1706 else |
|
1707 { |
|
1708 ERR_PRINTF1(_L("Unexpected error (expected KErrNotSupported)")); |
|
1709 return EFail; |
|
1710 } |
|
1711 } |
|
1712 |
|
1713 aRecUtil->GetNumberOfMetaDataEntries(numEntries); |
|
1714 |
|
1715 if(numEntries == 2) |
|
1716 { |
|
1717 CMMFMetaDataEntry* testData; |
|
1718 |
|
1719 testData = aRecUtil->GetMetaDataEntryL(0); |
|
1720 |
|
1721 if((testData->Name() == name) && (testData->Value() == data)) |
|
1722 { |
|
1723 ret = EPass; |
|
1724 } |
|
1725 |
|
1726 testData = aRecUtil->GetMetaDataEntryL(1); |
|
1727 |
|
1728 if(!((testData->Name() == name2) && (testData->Value() == data2))) |
|
1729 { |
|
1730 ret = EFail; |
|
1731 } |
|
1732 } |
|
1733 return ret; |
|
1734 } |
|
1735 |
|
1736 // Audio file already contains meta data, and we couldn't remove it. |
|
1737 ERR_PRINTF1(_L("Audio file still contains metadata")); |
|
1738 CleanupStack::PopAndDestroy(metaData[1]); |
|
1739 CleanupStack::PopAndDestroy(metaData[0]); |
|
1740 return EInconclusive; |
|
1741 } |
|
1742 |
|
1743 //------------------------------------------------------------------ |
|
1744 |
|
1745 /** |
|
1746 * Constructor |
|
1747 */ |
|
1748 CTestMmfAclntRecPriority::CTestMmfAclntRecPriority(const TDesC& aTestName,const TDesC& aSectName) |
|
1749 |
|
1750 { |
|
1751 // store the name of this test case |
|
1752 // this is the name that is used by the script file |
|
1753 // Each test step initialises it's own name |
|
1754 iTestStepName = aTestName; |
|
1755 iSectName = aSectName; |
|
1756 } |
|
1757 |
|
1758 void CTestMmfAclntRecPriority::MchoComplete(TInt aID, TInt aError) |
|
1759 { |
|
1760 INFO_PRINTF1( _L("CTestMmfAclntRecPriority : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility called")); |
|
1761 if (iError != KErrNone) |
|
1762 { |
|
1763 iError = aError; |
|
1764 } |
|
1765 |
|
1766 INFO_PRINTF3( _L("iError %d ID %d"), iError, aID); |
|
1767 |
|
1768 if(iFirstCallback == -1) |
|
1769 { |
|
1770 iFirstCallback = aID; |
|
1771 } |
|
1772 |
|
1773 |
|
1774 if((--iCallbackCount) == 0) |
|
1775 { |
|
1776 CActiveScheduler::Stop(); |
|
1777 } |
|
1778 } |
|
1779 |
|
1780 //------------------------------------------------------------------ |
|
1781 |
|
1782 /** |
|
1783 * Set Record priority |
|
1784 */ |
|
1785 TVerdict CTestMmfAclntRecPriority::DoTestStepL( void ) |
|
1786 { |
|
1787 INFO_PRINTF1( _L("TestRecorder : Priority")); |
|
1788 iError = KErrTimedOut; |
|
1789 |
|
1790 TBuf<KSizeBuf> filename; |
|
1791 TPtrC filename1; |
|
1792 if(!GetStringFromConfig(iSectName, _L("playerAudioFile"), filename1)) |
|
1793 { |
|
1794 return EInconclusive; |
|
1795 } |
|
1796 |
|
1797 GetDriveName(filename); |
|
1798 filename.Append(filename1); |
|
1799 |
|
1800 |
|
1801 CMdaAudioRecorderUtility* recUtil[2]; |
|
1802 CStateCallbackHandler* callback[2]; |
|
1803 |
|
1804 for(TInt i=0; i<2; i++) |
|
1805 { |
|
1806 callback[i] = new (ELeave) CStateCallbackHandler(i,this); |
|
1807 CleanupStack::PushL(callback[i]); |
|
1808 } |
|
1809 |
|
1810 recUtil[0] = CMdaAudioRecorderUtility::NewL(*callback[0],NULL,EMdaPriorityNormal,EMdaPriorityPreferenceTimeAndQuality); |
|
1811 CleanupStack::PushL(recUtil[0]); |
|
1812 recUtil[1] = CMdaAudioRecorderUtility::NewL(*callback[1],NULL,EMdaPriorityMin,EMdaPriorityPreferenceNone); |
|
1813 CleanupStack::PushL(recUtil[1]); |
|
1814 |
|
1815 INFO_PRINTF2(_L("CMdaAudioRecorderUtility[0]->OpenFileL(%S)"), &filename); |
|
1816 recUtil[0]->OpenFileL(filename); |
|
1817 // wait for initilisation callback #1 |
|
1818 iCallbackCount = 1; |
|
1819 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility #1")); |
|
1820 CActiveScheduler::Start(); |
|
1821 |
|
1822 INFO_PRINTF2(_L("CMdaAudioRecorderUtility[1]->OpenFileL(%S)"), &filename); |
|
1823 recUtil[1]->OpenFileL(filename); |
|
1824 // wait for initilisation callback #2 |
|
1825 iCallbackCount = 1; |
|
1826 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility #2")); |
|
1827 CActiveScheduler::Start(); |
|
1828 |
|
1829 |
|
1830 if(iError == KErrNone) |
|
1831 { |
|
1832 iError = KErrTimedOut; |
|
1833 |
|
1834 recUtil[0]->PlayL(); |
|
1835 recUtil[1]->PlayL(); |
|
1836 |
|
1837 INFO_PRINTF1( _L("Play CMdaAudioRecorderUtility")); |
|
1838 INFO_PRINTF1( _L("Play CMdaAudioRecorderUtility")); |
|
1839 // wait for play to complete |
|
1840 iCallbackCount = 2; |
|
1841 iFirstCallback = -1; |
|
1842 CActiveScheduler::Start(); |
|
1843 |
|
1844 if((iError == KErrNone) && (iFirstCallback == 0)) |
|
1845 { |
|
1846 CleanupStack::PopAndDestroy(4); // recUtil, callback |
|
1847 return EPass; |
|
1848 } |
|
1849 } |
|
1850 |
|
1851 ERR_PRINTF2( _L("CMdaAudioRecorderUtility completed with error %d"),iError ); |
|
1852 |
|
1853 CleanupStack::PopAndDestroy(4); |
|
1854 return EFail; |
|
1855 } |
|
1856 |
|
1857 //------------------------------------------------------------------ |
|
1858 |
|
1859 CTestMmfAclntRecBalance::CTestMmfAclntRecBalance(const TDesC& aTestName, const TDesC& aSectName, const TInt aBalance, TBool aNegative) |
|
1860 :CTestMmfAclntRecord(aTestName, aSectName, aNegative), iBalance(aBalance) |
|
1861 { |
|
1862 } |
|
1863 |
|
1864 CTestMmfAclntRecBalance* CTestMmfAclntRecBalance::NewL(const TDesC& aTestName, const TDesC& aSectName,const TInt aBalance, TBool aNegative) |
|
1865 { |
|
1866 CTestMmfAclntRecBalance* self = new (ELeave) CTestMmfAclntRecBalance(aTestName, aSectName, aBalance, aNegative); |
|
1867 return self; |
|
1868 } |
|
1869 |
|
1870 /** |
|
1871 * Set recorder balance |
|
1872 */ |
|
1873 TVerdict CTestMmfAclntRecBalance::DoTestL(CMdaAudioRecorderUtility* aRecUtil) |
|
1874 { |
|
1875 INFO_PRINTF2(_L("TestRecorder : Balance - (%d)"), iBalance); |
|
1876 |
|
1877 TInt savedBalance = iBalance; |
|
1878 if (CheckPlaybackBalance(aRecUtil) == EPass) |
|
1879 { |
|
1880 iBalance = savedBalance; |
|
1881 if (CheckRecordBalance(aRecUtil) == EPass) |
|
1882 return EPass; |
|
1883 } |
|
1884 |
|
1885 return EFail; |
|
1886 } |
|
1887 |
|
1888 TVerdict CTestMmfAclntRecBalance::CheckPlaybackBalance(CMdaAudioRecorderUtility* aRecUtil) |
|
1889 { |
|
1890 TInt err = 0; |
|
1891 TUint theNumChanel = 0; |
|
1892 TRAP(err, theNumChanel = aRecUtil->DestinationNumberOfChannelsL()); |
|
1893 if(err != KErrNone) |
|
1894 { |
|
1895 return EFail; |
|
1896 } |
|
1897 |
|
1898 |
|
1899 TInt balance; |
|
1900 |
|
1901 if (iBalance < KMinBalance) |
|
1902 { |
|
1903 err = aRecUtil->SetPlaybackBalance(iBalance); |
|
1904 |
|
1905 if ((err == KErrArgument) && (iNegative)) |
|
1906 { |
|
1907 return EPass; |
|
1908 } |
|
1909 else if ((err == KErrArgument) && (!iNegative)) |
|
1910 { |
|
1911 return EFail; |
|
1912 } |
|
1913 |
|
1914 aRecUtil->GetPlaybackBalance(iBalance); |
|
1915 if(iBalance == KMinBalance) |
|
1916 { |
|
1917 return EPass; |
|
1918 } |
|
1919 } |
|
1920 else if (iBalance > KMaxBalance) |
|
1921 { |
|
1922 err = aRecUtil->SetPlaybackBalance(iBalance); |
|
1923 |
|
1924 if ((err == KErrArgument) && (iNegative)) |
|
1925 { |
|
1926 return EPass; |
|
1927 } |
|
1928 else if ((err == KErrArgument) && (!iNegative)) |
|
1929 { |
|
1930 return EFail; |
|
1931 } |
|
1932 |
|
1933 aRecUtil->GetPlaybackBalance(iBalance); |
|
1934 if(iBalance == KMaxBalance) |
|
1935 { |
|
1936 return EPass; |
|
1937 } |
|
1938 |
|
1939 } |
|
1940 else |
|
1941 { |
|
1942 err = aRecUtil->SetPlaybackBalance(iBalance); |
|
1943 if(theNumChanel <= 1) |
|
1944 { |
|
1945 if(err != KErrNone) // this is now supported |
|
1946 return EFail; |
|
1947 } |
|
1948 if ((err == KErrArgument) && (iNegative)) |
|
1949 { |
|
1950 return EPass; |
|
1951 } |
|
1952 else if ((err == KErrArgument) && (!iNegative)) |
|
1953 { |
|
1954 return EFail; |
|
1955 } |
|
1956 else if(err != KErrNone) |
|
1957 { |
|
1958 return EFail; |
|
1959 } |
|
1960 |
|
1961 |
|
1962 TInt theRes = aRecUtil->GetPlaybackBalance(balance); |
|
1963 if((theRes == KErrNone) && (balance == iBalance)) |
|
1964 { |
|
1965 return EPass; |
|
1966 } |
|
1967 } |
|
1968 |
|
1969 return EFail; |
|
1970 } |
|
1971 |
|
1972 TVerdict CTestMmfAclntRecBalance::CheckRecordBalance(CMdaAudioRecorderUtility* aRecUtil) |
|
1973 { |
|
1974 TInt err = 0; |
|
1975 TUint theNumChanel = 0; |
|
1976 TRAP(err, theNumChanel = aRecUtil->DestinationNumberOfChannelsL()); |
|
1977 if(err != KErrNone) |
|
1978 { |
|
1979 return EFail; |
|
1980 } |
|
1981 |
|
1982 if (iBalance < KMinBalance) |
|
1983 { |
|
1984 err = aRecUtil->SetRecordBalance(iBalance); |
|
1985 |
|
1986 if ((err == KErrArgument) && (iNegative)) |
|
1987 { |
|
1988 return EPass; |
|
1989 } |
|
1990 else if ((err == KErrArgument) && (!iNegative)) |
|
1991 { |
|
1992 return EFail; |
|
1993 } |
|
1994 |
|
1995 aRecUtil->GetRecordBalance(iBalance); |
|
1996 if(iBalance == KMinBalance) |
|
1997 { |
|
1998 return EPass; |
|
1999 } |
|
2000 |
|
2001 } |
|
2002 else if (iBalance > KMaxBalance) |
|
2003 { |
|
2004 err = aRecUtil->SetRecordBalance(iBalance); |
|
2005 |
|
2006 if ((err == KErrArgument) && (iNegative)) |
|
2007 { |
|
2008 return EPass; |
|
2009 } |
|
2010 else if ((err == KErrArgument) && (!iNegative)) |
|
2011 { |
|
2012 return EFail; |
|
2013 } |
|
2014 |
|
2015 aRecUtil->GetRecordBalance(iBalance); |
|
2016 if(iBalance == KMaxBalance) |
|
2017 { |
|
2018 return EPass; |
|
2019 } |
|
2020 |
|
2021 } |
|
2022 else |
|
2023 { |
|
2024 TInt balance; |
|
2025 err = aRecUtil->SetRecordBalance(iBalance); |
|
2026 if(theNumChanel <= 1) |
|
2027 { |
|
2028 if(err != KErrNone) // this is now supported |
|
2029 return EFail; |
|
2030 } |
|
2031 |
|
2032 if ((err == KErrArgument) && (iNegative)) |
|
2033 { |
|
2034 return EPass; |
|
2035 } |
|
2036 else if ((err == KErrArgument) && (!iNegative)) |
|
2037 { |
|
2038 return EFail; |
|
2039 } |
|
2040 |
|
2041 aRecUtil->GetRecordBalance(balance); |
|
2042 if(balance == iBalance) |
|
2043 { |
|
2044 return EPass; |
|
2045 } |
|
2046 } |
|
2047 |
|
2048 return EFail; |
|
2049 } |
|
2050 |
|
2051 //------------------------------------------------------------------ |
|
2052 |
|
2053 CTestMmfAclntRecLength::CTestMmfAclntRecLength(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
2054 :CTestMmfAclntRecord(aTestName, aSectName, aNegative) |
|
2055 { |
|
2056 } |
|
2057 |
|
2058 CTestMmfAclntRecLength* CTestMmfAclntRecLength::NewL(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
2059 { |
|
2060 CTestMmfAclntRecLength* self = new (ELeave) CTestMmfAclntRecLength(aTestName, aSectName, aNegative); |
|
2061 return self; |
|
2062 } |
|
2063 |
|
2064 /** |
|
2065 *Set maximum length of file in bytes and record |
|
2066 */ |
|
2067 TVerdict CTestMmfAclntRecLength::DoTestL(CMdaAudioRecorderUtility* aRecUtil) |
|
2068 { |
|
2069 INFO_PRINTF1( _L("TestRecorder : SetMaxWriteLength")); |
|
2070 |
|
2071 TVerdict ret = EFail; |
|
2072 TTimeIntervalMicroSeconds recTime(aRecUtil->RecordTimeAvailable()); |
|
2073 |
|
2074 aRecUtil->SetMaxWriteLength(800); |
|
2075 |
|
2076 if(aRecUtil->RecordTimeAvailable() != recTime) |
|
2077 { |
|
2078 ret = EPass; |
|
2079 } |
|
2080 |
|
2081 return ret; |
|
2082 } |
|
2083 |
|
2084 //------------------------------------------------------------------ |
|
2085 |
|
2086 CTestMmfAclntRecFormats::CTestMmfAclntRecFormats(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
2087 :CTestMmfAclntRecord(aTestName, aSectName, aNegative) |
|
2088 { |
|
2089 } |
|
2090 |
|
2091 CTestMmfAclntRecFormats* CTestMmfAclntRecFormats::NewL(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
2092 { |
|
2093 CTestMmfAclntRecFormats* self = new (ELeave) CTestMmfAclntRecFormats(aTestName, aSectName, aNegative); |
|
2094 return self; |
|
2095 } |
|
2096 |
|
2097 /** |
|
2098 * Get recordable formats.Test for supported mimetypes. |
|
2099 */ |
|
2100 TVerdict CTestMmfAclntRecFormats::DoTestL(CMdaAudioRecorderUtility* aRecUtil) |
|
2101 { |
|
2102 INFO_PRINTF1( _L("TestRecorder : Formats")); |
|
2103 |
|
2104 TVerdict ret = EPass; |
|
2105 |
|
2106 TInt recauMatches = 0; |
|
2107 TInt playauMatches = 0; |
|
2108 TInt recwavMatches = 0; |
|
2109 TInt playwavMathces = 0; |
|
2110 |
|
2111 const TInt KControllerAudioRecAuMatches = 4; |
|
2112 const TInt KControllerAudioPlayAuMatches = 4; |
|
2113 const TInt KControllerAudioRecWavMatches = 2; |
|
2114 // there are 2 .wav play plugins - the standard .WAV plugin and |
|
2115 // the test MmfMp3Format plugin with 2 mime types each : |
|
2116 const TInt KControllerAudioPlayWavMatches = 2; |
|
2117 |
|
2118 RArray<TFourCC> codecs; |
|
2119 aRecUtil->GetSupportedDestinationDataTypesL(codecs); |
|
2120 TInt numCodecs = codecs.Count(); |
|
2121 |
|
2122 INFO_PRINTF2(_L("GetSupportedDestinationDataTypesL found %d codecs"), numCodecs); |
|
2123 |
|
2124 // enhanced - to use CMMFControllerPluginSelectionParameters |
|
2125 |
|
2126 INFO_PRINTF1(_L("Querying record formats...")); |
|
2127 |
|
2128 CMMFControllerPluginSelectionParameters* cSelect = CMMFControllerPluginSelectionParameters::NewLC(); |
|
2129 CMMFFormatSelectionParameters* recFSelect = CMMFFormatSelectionParameters::NewLC(); |
|
2130 CMMFFormatSelectionParameters* playFSelect = CMMFFormatSelectionParameters::NewLC(); |
|
2131 |
|
2132 RArray<TUid> mediaIds; |
|
2133 mediaIds.Append(KUidMediaTypeAudio); |
|
2134 cSelect->SetMediaIdsL(mediaIds, CMMFPluginSelectionParameters::EAllowOtherMediaIds); |
|
2135 cSelect->SetRequiredRecordFormatSupportL(*recFSelect); |
|
2136 cSelect->SetRequiredPlayFormatSupportL(*playFSelect); |
|
2137 |
|
2138 RMMFControllerImplInfoArray controllers; // Array to hold all the controllers support the match data |
|
2139 CleanupResetAndDestroyPushL(controllers); |
|
2140 cSelect->ListImplementationsL(controllers); // Populates the array with all the suitable controllers |
|
2141 TInt numControllers = controllers.Count(); |
|
2142 if(!numControllers) |
|
2143 { |
|
2144 ERR_PRINTF1(_L("Could not find any controllers")); |
|
2145 } |
|
2146 else |
|
2147 { |
|
2148 INFO_PRINTF2(_L("Found %d controllers"), numControllers); |
|
2149 for(int i = 0; i < numControllers; i++) |
|
2150 { |
|
2151 INFO_PRINTF4(_L("- Controller: %d Uid: 0x%X %S"),i, controllers[i]->Uid(), &controllers[i]->DisplayName()); |
|
2152 const RMMFFormatImplInfoArray& recFormats = controllers[i]->RecordFormats(); |
|
2153 const RMMFFormatImplInfoArray& playFormats = controllers[i]->PlayFormats(); |
|
2154 |
|
2155 const CDesC8Array* fileExtensions = NULL; |
|
2156 const CDesC8Array* mimeTypes = NULL; |
|
2157 |
|
2158 _LIT(KMimeTypeAudioBasic, "audio/basic"); |
|
2159 _LIT(KMimeTypeAudioXAu, "audio/x-au"); |
|
2160 _LIT(KMimeTypeAudioAu, "audio/au"); |
|
2161 _LIT(KMimeTypeAudioXBasic, "audio/x-basic"); |
|
2162 _LIT(KMimeTypeAudioWav, "audio/wav"); |
|
2163 _LIT(KMimeTypeAudioXWav, "audio/x-wav"); |
|
2164 |
|
2165 _LIT(KWavFileExtension, ".wav"); |
|
2166 _LIT(KAuFileExtension, ".au"); |
|
2167 |
|
2168 |
|
2169 for(int recFormat = 0; recFormat < recFormats.Count(); recFormat++) |
|
2170 { |
|
2171 INFO_PRINTF2(_L("Record Format 0x%x"), recFormats[recFormat]->Uid()); |
|
2172 fileExtensions = &recFormats[recFormat]->SupportedFileExtensions(); |
|
2173 INFO_PRINTF2(_L("File Extensions %d"), (fileExtensions ? fileExtensions->MdcaCount() : 0)); |
|
2174 TBuf<24> fileType; |
|
2175 for(int fileExtn = 0; fileExtn < (fileExtensions ? fileExtensions->MdcaCount() : 0); fileExtn++) |
|
2176 { |
|
2177 fileType.Copy(fileExtensions->MdcaPoint(fileExtn)); |
|
2178 INFO_PRINTF2(_L("-- %S"), &fileType); |
|
2179 } |
|
2180 |
|
2181 mimeTypes = &recFormats[recFormat]->SupportedMimeTypes(); |
|
2182 INFO_PRINTF2(_L("Mime Types: %d"), (mimeTypes ? mimeTypes->MdcaCount() : 0)); |
|
2183 for(int mimeType = 0; mimeType < (mimeTypes ? mimeTypes->MdcaCount() : 0); mimeType++) |
|
2184 { |
|
2185 TBuf<24> ext16; |
|
2186 ext16.Copy(mimeTypes->MdcaPoint(mimeType)); |
|
2187 if(fileType.Compare(KAuFileExtension)== KErrNone) |
|
2188 { |
|
2189 switch (mimeType) |
|
2190 { |
|
2191 case 0: |
|
2192 if (ext16 == KMimeTypeAudioBasic) |
|
2193 { |
|
2194 recauMatches++; |
|
2195 } |
|
2196 |
|
2197 else |
|
2198 { |
|
2199 ret = EFail; |
|
2200 } |
|
2201 |
|
2202 break; |
|
2203 case 1: |
|
2204 if (ext16 == KMimeTypeAudioXAu) |
|
2205 { |
|
2206 recauMatches++; |
|
2207 } |
|
2208 |
|
2209 else |
|
2210 { |
|
2211 ret = EFail; |
|
2212 } |
|
2213 |
|
2214 break; |
|
2215 case 2: |
|
2216 if(ext16 == KMimeTypeAudioAu) |
|
2217 { |
|
2218 recauMatches++; |
|
2219 } |
|
2220 |
|
2221 else |
|
2222 { |
|
2223 ret = EFail; |
|
2224 } |
|
2225 break; |
|
2226 |
|
2227 case 3: |
|
2228 if(ext16 == KMimeTypeAudioXBasic) |
|
2229 { |
|
2230 recauMatches++; |
|
2231 } |
|
2232 |
|
2233 else |
|
2234 { |
|
2235 ret = EFail; |
|
2236 } |
|
2237 |
|
2238 break; |
|
2239 default: |
|
2240 break; |
|
2241 } |
|
2242 INFO_PRINTF2(_L("-- %S"), &ext16); |
|
2243 } |
|
2244 if(fileType.Compare(KWavFileExtension) == KErrNone) |
|
2245 { |
|
2246 switch (mimeType) |
|
2247 { |
|
2248 case 0: |
|
2249 if(ext16 == KMimeTypeAudioWav) |
|
2250 { |
|
2251 recwavMatches++; |
|
2252 } |
|
2253 |
|
2254 else |
|
2255 { |
|
2256 ret = EFail; |
|
2257 } |
|
2258 |
|
2259 break; |
|
2260 case 1: |
|
2261 if(ext16 == KMimeTypeAudioXWav) |
|
2262 { |
|
2263 recwavMatches++; |
|
2264 } |
|
2265 |
|
2266 else |
|
2267 { |
|
2268 ret = EFail; |
|
2269 } |
|
2270 |
|
2271 break; |
|
2272 |
|
2273 default: |
|
2274 break; |
|
2275 } |
|
2276 INFO_PRINTF2(_L("-- %S"), &ext16); |
|
2277 } |
|
2278 } //mimetype |
|
2279 } //recFormat |
|
2280 |
|
2281 for(int playFormat = 0; playFormat < playFormats.Count(); playFormat++) |
|
2282 { |
|
2283 INFO_PRINTF2(_L("Play Format 0x%x"), playFormats[playFormat]->Uid()); |
|
2284 fileExtensions = &playFormats[playFormat]->SupportedFileExtensions(); |
|
2285 INFO_PRINTF2(_L("File Extensions %d"), (fileExtensions ? fileExtensions->MdcaCount() : 0)); |
|
2286 TBuf<24> fileType; |
|
2287 for(int fileExtn = 0; fileExtn < (fileExtensions ? fileExtensions->MdcaCount() : 0); fileExtn++) |
|
2288 { |
|
2289 fileType.Copy(fileExtensions->MdcaPoint(fileExtn)); |
|
2290 INFO_PRINTF2(_L("-- %S"), &fileType); |
|
2291 } |
|
2292 mimeTypes = &playFormats[playFormat]->SupportedMimeTypes(); |
|
2293 INFO_PRINTF2(_L("Mime Types: %d"), (mimeTypes ? mimeTypes->MdcaCount() : 0)); |
|
2294 for(int mimeType = 0; mimeType < (mimeTypes ? mimeTypes->MdcaCount() : 0); mimeType++) |
|
2295 { |
|
2296 TBuf<24> ext16; |
|
2297 ext16.Copy(mimeTypes->MdcaPoint(mimeType)); |
|
2298 if(fileType.Compare(KAuFileExtension) == KErrNone) |
|
2299 { |
|
2300 switch (mimeType) |
|
2301 { |
|
2302 case 0: |
|
2303 if (ext16 == KMimeTypeAudioBasic) |
|
2304 { |
|
2305 playauMatches++; |
|
2306 } |
|
2307 |
|
2308 else |
|
2309 { |
|
2310 ret = EFail; |
|
2311 } |
|
2312 |
|
2313 break; |
|
2314 case 1: |
|
2315 if (ext16 == KMimeTypeAudioXAu) |
|
2316 { |
|
2317 playauMatches++; |
|
2318 } |
|
2319 |
|
2320 else |
|
2321 ret = EFail; |
|
2322 break; |
|
2323 case 2: |
|
2324 if(ext16 == KMimeTypeAudioAu) |
|
2325 playauMatches++; |
|
2326 else |
|
2327 ret = EFail; |
|
2328 break; |
|
2329 case 3: |
|
2330 if(ext16 == KMimeTypeAudioXBasic) |
|
2331 { |
|
2332 playauMatches++; |
|
2333 } |
|
2334 else |
|
2335 ret = EFail; |
|
2336 break; |
|
2337 default: |
|
2338 break; |
|
2339 } |
|
2340 INFO_PRINTF2(_L("-- %S"), &ext16); |
|
2341 } |
|
2342 if(fileType.Compare(KWavFileExtension)== KErrNone) |
|
2343 { |
|
2344 switch (mimeType) |
|
2345 { |
|
2346 case 0: |
|
2347 if(ext16 == KMimeTypeAudioWav) |
|
2348 { |
|
2349 playwavMathces++; |
|
2350 } |
|
2351 |
|
2352 else |
|
2353 ret = EFail; |
|
2354 break; |
|
2355 case 1: |
|
2356 if(ext16 == KMimeTypeAudioXWav) |
|
2357 { |
|
2358 playwavMathces++; |
|
2359 } |
|
2360 |
|
2361 else |
|
2362 ret = EFail; |
|
2363 break; |
|
2364 default: |
|
2365 break; |
|
2366 } |
|
2367 INFO_PRINTF2(_L("-- %S"), &ext16); |
|
2368 } |
|
2369 }//mimetype |
|
2370 } //playFormat |
|
2371 } //controllers |
|
2372 }//else condition |
|
2373 |
|
2374 CleanupStack::PopAndDestroy(4);//controllers, recFSelect, playFSelect cSelect |
|
2375 |
|
2376 if((recauMatches != KControllerAudioRecAuMatches || playauMatches != KControllerAudioPlayAuMatches) || |
|
2377 (recwavMatches != KControllerAudioRecWavMatches || playwavMathces != KControllerAudioPlayWavMatches)) |
|
2378 { |
|
2379 ret = EFail; |
|
2380 } |
|
2381 |
|
2382 else |
|
2383 ret = EPass; |
|
2384 |
|
2385 return ret; |
|
2386 } //end of function |
|
2387 |
|
2388 |
|
2389 //------------------------------------------------------------------ |
|
2390 |
|
2391 // Negative tests |
|
2392 |
|
2393 //------------------------------------------------------------------ |
|
2394 |
|
2395 /** |
|
2396 * Constructor |
|
2397 */ |
|
2398 CTestMmfAclntRecDelete::CTestMmfAclntRecDelete(const TDesC& aTestName, const TDesC& aSectName) |
|
2399 { |
|
2400 // store the name of this test case |
|
2401 // this is the name that is used by the script file |
|
2402 // Each test step initialises it's own name |
|
2403 iTestStepName = aTestName; |
|
2404 iSectName = aSectName; |
|
2405 } |
|
2406 |
|
2407 void CTestMmfAclntRecDelete::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt /*aCurrentState*/, TInt aErrorCode) |
|
2408 { |
|
2409 iError = aErrorCode; |
|
2410 INFO_PRINTF1( _L("CTestMmfAclntRecDelete : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete")); |
|
2411 INFO_PRINTF2( _L("iError %d "), iError); |
|
2412 CActiveScheduler::Stop(); |
|
2413 } |
|
2414 |
|
2415 TVerdict CTestMmfAclntRecDelete::DoTestStepPreambleL() |
|
2416 { |
|
2417 TVerdict verdict = EPass; |
|
2418 |
|
2419 // Delete the output file (will probably have been used by other tests) |
|
2420 RFs fs; |
|
2421 TInt err = fs.Connect(); |
|
2422 if (err != KErrNone) |
|
2423 { |
|
2424 verdict = EFail; |
|
2425 } |
|
2426 else |
|
2427 { |
|
2428 TBuf<KSizeBuf> filename; |
|
2429 TPtrC filename1; |
|
2430 if (!GetStringFromConfig(iSectName, _L("outputAudioFile"), filename1)) |
|
2431 { |
|
2432 verdict = EInconclusive; |
|
2433 } |
|
2434 else |
|
2435 { |
|
2436 GetDriveName(filename); |
|
2437 filename.Append(filename1); |
|
2438 err = fs.Delete(filename); |
|
2439 if (!((err == KErrNone) || (err == KErrNotFound))) |
|
2440 { |
|
2441 verdict = EInconclusive; |
|
2442 } |
|
2443 |
|
2444 } |
|
2445 fs.Close(); |
|
2446 } |
|
2447 |
|
2448 if (verdict == EPass) |
|
2449 { |
|
2450 verdict = CTestMmfAclntStep::DoTestStepPreambleL(); |
|
2451 } |
|
2452 |
|
2453 |
|
2454 return verdict; |
|
2455 } |
|
2456 |
|
2457 /** |
|
2458 * Record utility - Delete object before record operation has completed. |
|
2459 */ |
|
2460 TVerdict CTestMmfAclntRecDelete::DoTestStepL( void ) |
|
2461 { |
|
2462 INFO_PRINTF1( _L("TestRecorder : Delete")); |
|
2463 iError = KErrTimedOut; |
|
2464 |
|
2465 TBuf<KSizeBuf> filename; |
|
2466 TPtrC filename1; |
|
2467 if(!GetStringFromConfig(iSectName, _L("outputAudioFile"), filename1)) |
|
2468 { |
|
2469 return EInconclusive; |
|
2470 } |
|
2471 |
|
2472 GetDriveName(filename); |
|
2473 filename.Append(filename1); |
|
2474 |
|
2475 __MM_HEAP_MARK; |
|
2476 |
|
2477 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
2478 CleanupStack::PushL(recUtil); |
|
2479 |
|
2480 // Add create file for Ogg-tests |
|
2481 if(iSectName == _L("SectionOggRec")) |
|
2482 { |
|
2483 RFs fs; |
|
2484 User::LeaveIfError(fs.Connect()); |
|
2485 RFile file; |
|
2486 User::LeaveIfError(file.Replace(fs,filename,EFileWrite)); |
|
2487 file.Close(); |
|
2488 fs.Close(); |
|
2489 } |
|
2490 |
|
2491 INFO_PRINTF2(_L("CMdaAudioRecorderUtility->OpenFileL(%S)"), &filename); |
|
2492 recUtil->OpenFileL(filename); |
|
2493 // wait |
|
2494 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
2495 CActiveScheduler::Start(); |
|
2496 |
|
2497 if (iError == KErrNone) |
|
2498 { |
|
2499 TVerdict ret = EPass; |
|
2500 INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility")); |
|
2501 recUtil->RecordL(); |
|
2502 INFO_PRINTF1( _L("Destroy CMdaAudioRecorderUtility")); |
|
2503 CleanupStack::PopAndDestroy(recUtil); |
|
2504 |
|
2505 // Check that the file no longer exists |
|
2506 RFs fs; |
|
2507 TInt err = fs.Connect(); |
|
2508 if (err != KErrNone) |
|
2509 { |
|
2510 INFO_PRINTF2(_L("Error connecting to file server %d"), err); |
|
2511 ret = EInconclusive; |
|
2512 } |
|
2513 else |
|
2514 { |
|
2515 TEntry entry; |
|
2516 if ((fs.Entry(filename, entry) == KErrNone) && (entry.iSize > 0)) |
|
2517 { |
|
2518 ERR_PRINTF1(_L("ERROR: File exists and size is greater than ZERO")); |
|
2519 ret = EFail; // file exists - test fails |
|
2520 } |
|
2521 else |
|
2522 { |
|
2523 ret = EPass; |
|
2524 } |
|
2525 fs.Close(); |
|
2526 } |
|
2527 |
|
2528 __MM_HEAP_MARKEND; |
|
2529 User::Heap().Check(); |
|
2530 |
|
2531 return ret; |
|
2532 } |
|
2533 CleanupStack::PopAndDestroy(recUtil); |
|
2534 return EFail; |
|
2535 } |
|
2536 |
|
2537 |
|
2538 //------------------------------------------------------------------ |
|
2539 |
|
2540 CTestMmfAclntAudioRecordVolume::CTestMmfAclntAudioRecordVolume(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative, const TInt aVolume) |
|
2541 : CTestMmfAclntRecord(aTestName, aSectName,aNegative), iVolume(aVolume) |
|
2542 {} |
|
2543 |
|
2544 CTestMmfAclntAudioRecordVolume* CTestMmfAclntAudioRecordVolume::NewL(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative, const TInt aVolume) |
|
2545 { |
|
2546 CTestMmfAclntAudioRecordVolume* self = new (ELeave) CTestMmfAclntAudioRecordVolume(aTestName, aSectName,aNegative,aVolume); |
|
2547 return self; |
|
2548 } |
|
2549 |
|
2550 |
|
2551 TVerdict CTestMmfAclntAudioRecordVolume::DoTestL(CMdaAudioRecorderUtility* aRecUtil) |
|
2552 { |
|
2553 INFO_PRINTF1( _L("TestRecordUtils : Audio Record Volume")); |
|
2554 TVerdict ret = EFail; |
|
2555 |
|
2556 |
|
2557 // Check maxvolume function |
|
2558 if(iVolume == -1) |
|
2559 { |
|
2560 iVolume = aRecUtil->MaxVolume(); |
|
2561 } |
|
2562 // Volume is truncated to maxvolume |
|
2563 if(iVolume > aRecUtil->MaxVolume()) |
|
2564 { |
|
2565 TInt volume; |
|
2566 aRecUtil->SetVolume(iVolume); |
|
2567 aRecUtil->GetVolume(volume); |
|
2568 if(volume == aRecUtil->MaxVolume()) |
|
2569 { |
|
2570 ret = EPass; |
|
2571 } |
|
2572 } |
|
2573 // Volume is truncated to 0 |
|
2574 else if(iVolume < 0) |
|
2575 { |
|
2576 TInt volume; |
|
2577 |
|
2578 aRecUtil->SetVolume(iVolume); |
|
2579 aRecUtil->GetVolume(volume); |
|
2580 if(volume == 0) |
|
2581 { |
|
2582 ret = EPass; |
|
2583 } |
|
2584 } |
|
2585 // Set volume and check |
|
2586 else |
|
2587 { |
|
2588 TInt volume; |
|
2589 aRecUtil->SetVolume(iVolume); |
|
2590 aRecUtil->GetVolume(volume); |
|
2591 if(volume == iVolume) |
|
2592 { |
|
2593 ret = EPass; |
|
2594 } |
|
2595 |
|
2596 else |
|
2597 { |
|
2598 INFO_PRINTF3( _L("Expected volume: %d, received volume : %d"), iVolume, volume); |
|
2599 } |
|
2600 } |
|
2601 |
|
2602 return ret; |
|
2603 } |
|
2604 |
|
2605 |
|
2606 CTestMmfAclntAudioRecordRamp::CTestMmfAclntAudioRecordRamp(const TDesC& aTestName, const TDesC& aSectName,TBool aNegative) |
|
2607 : CTestMmfAclntRecord(aTestName, aSectName,aNegative) |
|
2608 {} |
|
2609 |
|
2610 CTestMmfAclntAudioRecordRamp* CTestMmfAclntAudioRecordRamp::NewL(const TDesC& aTestName, const TDesC& aSectName,TBool aNegative) |
|
2611 { |
|
2612 CTestMmfAclntAudioRecordRamp* self = new (ELeave) CTestMmfAclntAudioRecordRamp(aTestName, aSectName,aNegative); |
|
2613 return self; |
|
2614 } |
|
2615 |
|
2616 TVerdict CTestMmfAclntAudioRecordRamp::DoTestL(CMdaAudioRecorderUtility* aRecUtil) |
|
2617 { |
|
2618 INFO_PRINTF1( _L("TestRecordUtils : Audio Ramp")); |
|
2619 TVerdict ret = EFail; |
|
2620 TTimeIntervalMicroSeconds ramp(100); |
|
2621 aRecUtil->SetVolumeRamp(ramp); |
|
2622 |
|
2623 aRecUtil->RecordL(); |
|
2624 CActiveScheduler::Start(); // wait for open -> record |
|
2625 if (iError != KErrNone) |
|
2626 { |
|
2627 // DEF127335 |
|
2628 // OggRecordController does not support recording into an already existing file. |
|
2629 // This is due to unavailability of APIs at the level of Ogg Vorbis C libraries. |
|
2630 if (iTestStepName == _L("MM-MMF-ACLNTOGG-I-0123-HP") && iError == KErrNotSupported) |
|
2631 { |
|
2632 INFO_PRINTF1(_L("Expected Result: OggRecordController returned KErrNotSupported(-5)")); |
|
2633 return EPass; |
|
2634 } |
|
2635 else |
|
2636 { |
|
2637 return EFail; |
|
2638 } |
|
2639 } |
|
2640 |
|
2641 iReportedState = aRecUtil->State(); |
|
2642 if(iReportedState == CMdaAudioClipUtility::ERecording ) |
|
2643 { |
|
2644 ret = EPass; |
|
2645 } |
|
2646 |
|
2647 User::After(KOneSecond); |
|
2648 aRecUtil->Stop(); |
|
2649 |
|
2650 return ret; |
|
2651 } |
|
2652 |
|
2653 |
|
2654 //------------------------------------------------------------------ |
|
2655 |
|
2656 |
|
2657 CTestMmfAclntRecordDestChannels::CTestMmfAclntRecordDestChannels(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aNumberOfChannels,const TTestFormat aFormat, const TBool aCreateDes) |
|
2658 { |
|
2659 // store the name of this test case |
|
2660 // this is the name that is used by the script file |
|
2661 // Each test step initialises it's own name |
|
2662 iTestStepName = aTestName; |
|
2663 iSectName = aSectName; |
|
2664 iKeyName = aKeyName; |
|
2665 iTestFormat = aFormat; |
|
2666 iCreateDes = aCreateDes; |
|
2667 iNumberOfChannels=aNumberOfChannels; |
|
2668 |
|
2669 iSize = 0; |
|
2670 iAudio = NULL; |
|
2671 } |
|
2672 |
|
2673 CTestMmfAclntRecordDestChannels* CTestMmfAclntRecordDestChannels::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aNumberOfChannels, const TTestFormat aFormat,const TBool aCreateDes) |
|
2674 { |
|
2675 CTestMmfAclntRecordDestChannels* self = new (ELeave) CTestMmfAclntRecordDestChannels(aTestName,aSectName,aKeyName,aNumberOfChannels,aFormat,aCreateDes); |
|
2676 return self; |
|
2677 } |
|
2678 |
|
2679 CTestMmfAclntRecordDestChannels* CTestMmfAclntRecordDestChannels::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TInt aNumberOfChannels, const TTestFormat aFormat, const TBool aCreateDes) |
|
2680 { |
|
2681 CTestMmfAclntRecordDestChannels* self = CTestMmfAclntRecordDestChannels::NewLC(aTestName,aSectName,aKeyName,aNumberOfChannels,aFormat,aCreateDes); |
|
2682 CleanupStack::PushL(self); |
|
2683 return self; |
|
2684 } |
|
2685 |
|
2686 void CTestMmfAclntRecordDestChannels::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode) |
|
2687 { |
|
2688 iError = aErrorCode; |
|
2689 INFO_PRINTF4( _L("MMdaObjectStateChangeObserver: previous state: %d current state: %d error: %d"),aPreviousState, aCurrentState, aErrorCode); |
|
2690 CActiveScheduler::Stop(); |
|
2691 } |
|
2692 |
|
2693 TVerdict CTestMmfAclntRecordDestChannels::DoTestStepPreambleL() |
|
2694 { |
|
2695 SetupFormatL(iTestFormat); |
|
2696 |
|
2697 switch (iTestFormat) |
|
2698 { |
|
2699 case EPcm16Wav: |
|
2700 case EAlawWav: |
|
2701 case EPcm8: |
|
2702 iHeaderSize = KWavFileUncompressedDataHeaderSize; //(see mmfwavformat.cpp, CreateSinkBufferOfSizeL()) |
|
2703 iFrameSize = 4096; |
|
2704 break; |
|
2705 case EImaAdpcmWav: |
|
2706 case EImasPcmWav: |
|
2707 iHeaderSize = KWavFileCompressedDataHeaderSize + KImaAdpcmFactChunkSize; |
|
2708 iFrameSize = 4096; |
|
2709 break; |
|
2710 case EMulawRaw: |
|
2711 case EPcmU8: |
|
2712 case EPcmU16: |
|
2713 iHeaderSize = 0; |
|
2714 iFrameSize = 4096; |
|
2715 break; |
|
2716 case EGsmWav: |
|
2717 iHeaderSize = KWavFileCompressedDataHeaderSize + KGSMFactChunkSize; |
|
2718 iFrameSize = 4096; |
|
2719 break; |
|
2720 default: |
|
2721 /*skip*/ ; |
|
2722 } |
|
2723 |
|
2724 if(!iCreateDes) |
|
2725 { |
|
2726 RFs fs; |
|
2727 RFile file; |
|
2728 |
|
2729 TBuf<KSizeBuf> filename; |
|
2730 TPtrC filename1; |
|
2731 if(!GetStringFromConfig(iSectName, iKeyName, filename1)) |
|
2732 return EInconclusive; |
|
2733 GetDriveName(filename); |
|
2734 filename.Append(filename1); |
|
2735 INFO_PRINTF2(_L("File for test - %S"), &filename); |
|
2736 |
|
2737 User::LeaveIfError(fs.Connect()); |
|
2738 User::LeaveIfError(file.Open(fs,filename,EFileRead)); |
|
2739 CleanupClosePushL(file); |
|
2740 |
|
2741 User::LeaveIfError(file.Size(iSize)); |
|
2742 INFO_PRINTF2(_L("size of file = %d\n"),iSize);//Statement Changed under DEF105143 |
|
2743 iAudio = HBufC8::NewMaxL(iSize); |
|
2744 |
|
2745 // Read a file into a descriptor |
|
2746 TPtr8 bufferDes(iAudio->Des()); |
|
2747 User::LeaveIfError(file.Read(bufferDes)); |
|
2748 |
|
2749 CleanupStack::PopAndDestroy(); //file |
|
2750 } |
|
2751 return CTestMmfAclntStep::DoTestStepPreambleL(); |
|
2752 } |
|
2753 |
|
2754 TVerdict CTestMmfAclntRecordDestChannels::DoTestStepPostambleL() |
|
2755 { |
|
2756 delete iAudio; |
|
2757 return CTestMmfAclntStep::DoTestStepPostambleL(); |
|
2758 } |
|
2759 |
|
2760 /** |
|
2761 * Open a descriptor and record |
|
2762 */ |
|
2763 TVerdict CTestMmfAclntRecordDestChannels::DoTestStepL( void ) |
|
2764 { |
|
2765 INFO_PRINTF1( _L("TestRecorder : Record Des")); |
|
2766 TVerdict ret = EFail; |
|
2767 HBufC8* audio = NULL; |
|
2768 TMdaDesClipLocation* location = NULL; |
|
2769 TInt err = KErrNone; |
|
2770 RArray<TUint> channels; |
|
2771 |
|
2772 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
2773 CleanupStack::PushL(recUtil); |
|
2774 |
|
2775 // Add create file for Ogg-tests |
|
2776 if(iSectName == _L("SectionOggRec")) |
|
2777 { |
|
2778 TBuf<KSizeBuf> filename; |
|
2779 TPtrC filename1; |
|
2780 if(!GetStringFromConfig(iSectName, iKeyName, filename1)) |
|
2781 { |
|
2782 return EInconclusive; |
|
2783 } |
|
2784 |
|
2785 GetDriveName(filename); |
|
2786 filename.Append(filename1); |
|
2787 |
|
2788 RFs fs; |
|
2789 User::LeaveIfError(fs.Connect()); |
|
2790 RFile file; |
|
2791 User::LeaveIfError(file.Replace(fs,filename,EFileWrite)); |
|
2792 file.Close(); |
|
2793 fs.Close(); |
|
2794 recUtil->OpenFileL(filename); |
|
2795 } |
|
2796 else if(!iCreateDes) |
|
2797 { |
|
2798 audio=iAudio; |
|
2799 TPtr8 bufferDes(iAudio->Des()); |
|
2800 recUtil->OpenDesL(bufferDes); |
|
2801 } |
|
2802 else |
|
2803 { |
|
2804 iSize = KRecSize; // value is not been set yet. |
|
2805 audio = HBufC8::NewMaxLC(iSize); |
|
2806 TPtr8 bufferDes(audio->Des()); |
|
2807 bufferDes.SetLength(0); |
|
2808 location = new (ELeave) TMdaDesClipLocation(bufferDes); |
|
2809 recUtil->OpenL(location,iFormat,iCodec,&iAudioSettings); |
|
2810 |
|
2811 delete location; |
|
2812 } |
|
2813 |
|
2814 iError = KErrTimedOut; |
|
2815 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
2816 CActiveScheduler::Start(); |
|
2817 TInt numChannels=-1; |
|
2818 if(iError == KErrNone) |
|
2819 { |
|
2820 TRAP(err,recUtil->GetSupportedNumberOfChannelsL(channels)); |
|
2821 if(err!=KErrNone) |
|
2822 { |
|
2823 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::GetSupportedNumberOfChannelsL leave with error %d"),err); |
|
2824 if(iCreateDes) |
|
2825 { |
|
2826 CleanupStack::PopAndDestroy(audio); |
|
2827 } |
|
2828 |
|
2829 CleanupStack::PopAndDestroy(recUtil); |
|
2830 User::After(KOneSecond); |
|
2831 return ret; |
|
2832 } |
|
2833 TRAP(err,recUtil->SetDestinationNumberOfChannelsL(1));//@@@ |
|
2834 if(err!=KErrNone) |
|
2835 { |
|
2836 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::SetDestinationNumberOfChannelsL leave with error %d"),err); |
|
2837 if(iCreateDes) |
|
2838 { |
|
2839 CleanupStack::PopAndDestroy(audio); |
|
2840 } |
|
2841 |
|
2842 CleanupStack::PopAndDestroy(recUtil); |
|
2843 User::After(KOneSecond); |
|
2844 return ret; |
|
2845 } |
|
2846 TRAP(err,numChannels = recUtil->DestinationNumberOfChannelsL()); |
|
2847 if(err!=KErrNone) |
|
2848 { |
|
2849 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::DestinationNumberOfChannelsL leave with error %d"),err); |
|
2850 if(iCreateDes) |
|
2851 { |
|
2852 CleanupStack::PopAndDestroy(audio); |
|
2853 } |
|
2854 |
|
2855 CleanupStack::PopAndDestroy(recUtil); |
|
2856 User::After(KOneSecond); |
|
2857 return ret; |
|
2858 } |
|
2859 } |
|
2860 |
|
2861 if(numChannels==iNumberOfChannels) |
|
2862 { |
|
2863 ret = EPass; |
|
2864 } |
|
2865 |
|
2866 |
|
2867 if (ret != EPass) |
|
2868 { |
|
2869 ERR_PRINTF2( _L("CMdaAudioRecorderUtility failed with error %d"),iError ); |
|
2870 } |
|
2871 |
|
2872 if(iCreateDes) |
|
2873 { |
|
2874 CleanupStack::PopAndDestroy(audio); |
|
2875 } |
|
2876 |
|
2877 CleanupStack::PopAndDestroy(recUtil); |
|
2878 User::After(KOneSecond); |
|
2879 return ret; |
|
2880 } |
|
2881 |
|
2882 |
|
2883 |
|
2884 //------------------------------------------------------------------ |
|
2885 |
|
2886 CTestMmfAclntRecordSetPriority::CTestMmfAclntRecordSetPriority(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
2887 : CTestMmfAclntRecord(aTestName, aSectName,aNegative) |
|
2888 {} |
|
2889 |
|
2890 CTestMmfAclntRecordSetPriority* CTestMmfAclntRecordSetPriority::NewL(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
2891 { |
|
2892 CTestMmfAclntRecordSetPriority* self = new (ELeave) CTestMmfAclntRecordSetPriority(aTestName, aSectName,aNegative); |
|
2893 return self; |
|
2894 } |
|
2895 |
|
2896 |
|
2897 TVerdict CTestMmfAclntRecordSetPriority::DoTestL(CMdaAudioRecorderUtility* aRecUtil) |
|
2898 { |
|
2899 INFO_PRINTF1( _L("TestRecordUtils : SetPriority")); |
|
2900 TVerdict ret = EPass; |
|
2901 TInt err = KErrNone; |
|
2902 TRAP(err,aRecUtil->SetPriority(EMdaPriorityMin,EMdaPriorityPreferenceNone)); |
|
2903 if(err!=KErrNone) |
|
2904 { |
|
2905 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::SetPriority (1st call) leave with error %d"),err); |
|
2906 ret = EFail; |
|
2907 } |
|
2908 |
|
2909 TRAP(err,aRecUtil->SetPriority(EMdaPriorityNormal,EMdaPriorityPreferenceTime)); |
|
2910 if(err!=KErrNone) |
|
2911 { |
|
2912 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::SetPriority (2nd call) leave with error %d"),err); |
|
2913 ret = EFail; |
|
2914 } |
|
2915 |
|
2916 TRAP(err,aRecUtil->SetPriority(EMdaPriorityMax,EMdaPriorityPreferenceTimeAndQuality)); |
|
2917 if(err!=KErrNone) |
|
2918 { |
|
2919 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::SetPriority (3rd call) leave with error %d"),err); |
|
2920 ret = EFail; |
|
2921 } |
|
2922 return ret; |
|
2923 } |
|
2924 |
|
2925 |
|
2926 //------------------------------------------------------------------ |
|
2927 |
|
2928 CTestMmfAclntRecordDestSampleRate::CTestMmfAclntRecordDestSampleRate(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName,const TTestFormat aFormat, const TBool aCreateDes) |
|
2929 { |
|
2930 // store the name of this test case |
|
2931 // this is the name that is used by the script file |
|
2932 // Each test step initialises it's own name |
|
2933 iTestStepName = aTestName; |
|
2934 iSectName = aSectName; |
|
2935 iKeyName = aKeyName; |
|
2936 iTestFormat = aFormat; |
|
2937 iCreateDes = aCreateDes; |
|
2938 |
|
2939 iSize = 0; |
|
2940 iAudio = NULL; |
|
2941 } |
|
2942 |
|
2943 CTestMmfAclntRecordDestSampleRate* CTestMmfAclntRecordDestSampleRate::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat,const TBool aCreateDes) |
|
2944 { |
|
2945 CTestMmfAclntRecordDestSampleRate* self = new (ELeave) CTestMmfAclntRecordDestSampleRate(aTestName,aSectName,aKeyName,aFormat,aCreateDes); |
|
2946 return self; |
|
2947 } |
|
2948 |
|
2949 CTestMmfAclntRecordDestSampleRate* CTestMmfAclntRecordDestSampleRate::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateDes) |
|
2950 { |
|
2951 CTestMmfAclntRecordDestSampleRate* self = CTestMmfAclntRecordDestSampleRate::NewLC(aTestName,aSectName,aKeyName,aFormat,aCreateDes); |
|
2952 CleanupStack::PushL(self); |
|
2953 return self; |
|
2954 } |
|
2955 |
|
2956 void CTestMmfAclntRecordDestSampleRate::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode) |
|
2957 { |
|
2958 iError = aErrorCode; |
|
2959 INFO_PRINTF4( _L("MMdaObjectStateChangeObserver: previous state: %d current state: %d error: %d"),aPreviousState, aCurrentState, aErrorCode); |
|
2960 CActiveScheduler::Stop(); |
|
2961 } |
|
2962 |
|
2963 TVerdict CTestMmfAclntRecordDestSampleRate::DoTestStepPreambleL() |
|
2964 { |
|
2965 SetupFormatL(iTestFormat); |
|
2966 |
|
2967 switch (iTestFormat) |
|
2968 { |
|
2969 case EPcm16Wav: |
|
2970 case EAlawWav: |
|
2971 case EPcm8: |
|
2972 iHeaderSize = KWavFileUncompressedDataHeaderSize; //(see mmfwavformat.cpp, CreateSinkBufferOfSizeL()) |
|
2973 iFrameSize = 4096; |
|
2974 break; |
|
2975 case EImaAdpcmWav: |
|
2976 case EImasPcmWav: |
|
2977 iHeaderSize = KWavFileCompressedDataHeaderSize + KImaAdpcmFactChunkSize; |
|
2978 iFrameSize = 4096; |
|
2979 break; |
|
2980 case EMulawRaw: |
|
2981 case EPcmU8: |
|
2982 case EPcmU16: |
|
2983 iHeaderSize = 0; |
|
2984 iFrameSize = 4096; |
|
2985 break; |
|
2986 case EGsmWav: |
|
2987 iHeaderSize = KWavFileCompressedDataHeaderSize + KGSMFactChunkSize; |
|
2988 iFrameSize = 4096; |
|
2989 break; |
|
2990 default: |
|
2991 /*skip*/ ; |
|
2992 } |
|
2993 |
|
2994 if(!iCreateDes) |
|
2995 { |
|
2996 RFs fs; |
|
2997 RFile file; |
|
2998 |
|
2999 TBuf<KSizeBuf> filename; |
|
3000 TPtrC filename1; |
|
3001 if(!GetStringFromConfig(iSectName, iKeyName, filename1)) |
|
3002 return EInconclusive; |
|
3003 GetDriveName(filename); |
|
3004 filename.Append(filename1); |
|
3005 INFO_PRINTF2(_L("File for test - %S"), &filename); |
|
3006 |
|
3007 User::LeaveIfError(fs.Connect()); |
|
3008 User::LeaveIfError(file.Open(fs,filename,EFileRead)); |
|
3009 CleanupClosePushL(file); |
|
3010 |
|
3011 User::LeaveIfError(file.Size(iSize)); |
|
3012 INFO_PRINTF2(_L("size of file = %d\n"),iSize);//Statement Changed under DEF105143 |
|
3013 iAudio = HBufC8::NewMaxL(iSize); |
|
3014 |
|
3015 // Read a file into a descriptor |
|
3016 TPtr8 bufferDes(iAudio->Des()); |
|
3017 User::LeaveIfError(file.Read(bufferDes)); |
|
3018 |
|
3019 CleanupStack::PopAndDestroy(); //file |
|
3020 } |
|
3021 return CTestMmfAclntStep::DoTestStepPreambleL(); |
|
3022 } |
|
3023 |
|
3024 TVerdict CTestMmfAclntRecordDestSampleRate::DoTestStepPostambleL() |
|
3025 { |
|
3026 delete iAudio; |
|
3027 return CTestMmfAclntStep::DoTestStepPostambleL(); |
|
3028 } |
|
3029 |
|
3030 /** |
|
3031 * Open a descriptor and record |
|
3032 */ |
|
3033 TVerdict CTestMmfAclntRecordDestSampleRate::DoTestStepL( void ) |
|
3034 { |
|
3035 INFO_PRINTF1( _L("TestRecorder : Destination SampleRate")); |
|
3036 TVerdict ret = EPass; |
|
3037 HBufC8* audio = NULL; |
|
3038 TMdaDesClipLocation* location = NULL; |
|
3039 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
3040 CleanupStack::PushL(recUtil); |
|
3041 |
|
3042 // Add create file for Ogg-tests |
|
3043 if(iSectName == _L("SectionOggRec")) |
|
3044 { |
|
3045 TBuf<KSizeBuf> filename; |
|
3046 TPtrC filename1; |
|
3047 if(!GetStringFromConfig(iSectName, iKeyName, filename1)) |
|
3048 return EInconclusive; |
|
3049 GetDriveName(filename); |
|
3050 filename.Append(filename1); |
|
3051 |
|
3052 RFs fs; |
|
3053 User::LeaveIfError(fs.Connect()); |
|
3054 RFile file; |
|
3055 User::LeaveIfError(file.Replace(fs,filename,EFileWrite)); |
|
3056 file.Close(); |
|
3057 fs.Close(); |
|
3058 recUtil->OpenFileL(filename); |
|
3059 } |
|
3060 else if(!iCreateDes) |
|
3061 { |
|
3062 audio=iAudio; |
|
3063 TPtr8 bufferDes(iAudio->Des()); |
|
3064 recUtil->OpenDesL(bufferDes); |
|
3065 } |
|
3066 else |
|
3067 { |
|
3068 iSize = KRecSize; // value is not been set yet. |
|
3069 audio = HBufC8::NewMaxLC(iSize); |
|
3070 TPtr8 bufferDes(audio->Des()); |
|
3071 bufferDes.SetLength(0); |
|
3072 location = new (ELeave) TMdaDesClipLocation(bufferDes); |
|
3073 recUtil->OpenL(location,iFormat,iCodec,&iAudioSettings); |
|
3074 |
|
3075 delete location; |
|
3076 } |
|
3077 CActiveScheduler::Start(); |
|
3078 |
|
3079 iError = KErrTimedOut; |
|
3080 TInt err = KErrNone; |
|
3081 RArray<TUint> rates; |
|
3082 TRAP(err,recUtil->GetSupportedSampleRatesL(rates)); |
|
3083 if(err!=KErrNone) |
|
3084 { |
|
3085 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::GetSupportedSampleRatesL leave with error %d"),err); |
|
3086 ret = EFail; |
|
3087 if(iCreateDes) |
|
3088 CleanupStack::PopAndDestroy(audio); |
|
3089 CleanupStack::PopAndDestroy(recUtil); |
|
3090 User::After(KOneSecond); |
|
3091 return ret; |
|
3092 } |
|
3093 |
|
3094 TInt numRates = rates.Count(); |
|
3095 for(TInt i=0;i<numRates;i++) |
|
3096 { |
|
3097 |
|
3098 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::SetDestinationSampleRateL(%d)"),rates[i]); |
|
3099 TUint sr = rates[i]; |
|
3100 TRAP(err,recUtil->SetDestinationSampleRateL(sr)); |
|
3101 if(err!=KErrNone) |
|
3102 { |
|
3103 INFO_PRINTF3(_L("CMdaAudioRecorderUtility::SetDestinationSampleRateL(%d) leave with error : %d"),sr,err); |
|
3104 ret = EFail; |
|
3105 break; |
|
3106 } |
|
3107 |
|
3108 TUint rate=0; |
|
3109 TRAP(err,rate = recUtil->DestinationSampleRateL()); |
|
3110 if(err!=KErrNone) |
|
3111 { |
|
3112 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::DestinationSampleRateL leave with error %d"),err); |
|
3113 ret = EFail; |
|
3114 } |
|
3115 else |
|
3116 { |
|
3117 if(rate!=rates[i]) |
|
3118 { |
|
3119 ret = EFail; |
|
3120 INFO_PRINTF1(_L("Rate mismatch")); |
|
3121 } |
|
3122 else |
|
3123 { |
|
3124 INFO_PRINTF1(_L("Rates match")); |
|
3125 } |
|
3126 } |
|
3127 |
|
3128 } |
|
3129 if(iCreateDes) |
|
3130 CleanupStack::PopAndDestroy(audio); |
|
3131 CleanupStack::PopAndDestroy(recUtil); |
|
3132 User::After(KOneSecond); |
|
3133 return ret; |
|
3134 } |
|
3135 //------------------------------------------------------------------ |
|
3136 |
|
3137 CTestMmfAclntRecordDestBitRate::CTestMmfAclntRecordDestBitRate(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
3138 : CTestMmfAclntRecord(aTestName, aSectName, aNegative) |
|
3139 {} |
|
3140 |
|
3141 CTestMmfAclntRecordDestBitRate* CTestMmfAclntRecordDestBitRate::NewL(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
3142 { |
|
3143 CTestMmfAclntRecordDestBitRate* self = new (ELeave) CTestMmfAclntRecordDestBitRate(aTestName, aSectName, aNegative); |
|
3144 return self; |
|
3145 } |
|
3146 |
|
3147 |
|
3148 TVerdict CTestMmfAclntRecordDestBitRate::DoTestL(CMdaAudioRecorderUtility* aRecUtil) |
|
3149 { |
|
3150 INFO_PRINTF1( _L("TestRecordUtils : Destination Bit Rate")); |
|
3151 TVerdict ret = EPass; |
|
3152 TInt err = KErrNone; |
|
3153 |
|
3154 // Add create file for Ogg-tests |
|
3155 if(iSectName == _L("SectionOggRec")) |
|
3156 { |
|
3157 TPtrC filename; |
|
3158 if (!GetStringFromConfig(iSectName, _L("outputAudioFile"), filename)) |
|
3159 { |
|
3160 INFO_PRINTF1(_L("Error getting filename from INI file")); |
|
3161 return EInconclusive; |
|
3162 } |
|
3163 RFs fs; |
|
3164 User::LeaveIfError(fs.Connect()); |
|
3165 RFile file; |
|
3166 User::LeaveIfError(file.Replace(fs,filename,EFileWrite)); |
|
3167 file.Close(); |
|
3168 fs.Close(); |
|
3169 // Open the file |
|
3170 aRecUtil->OpenFileL(filename); |
|
3171 INFO_PRINTF2(_L("CMdaAudioRecorderUtility->OpenFileL(%S)"), &filename); |
|
3172 CActiveScheduler::Start(); |
|
3173 if (iError != KErrNone) |
|
3174 { |
|
3175 INFO_PRINTF2(_L("Error opening file for recording"), iError); |
|
3176 return EInconclusive; |
|
3177 } |
|
3178 } |
|
3179 |
|
3180 RArray<TUint> rates; |
|
3181 TRAP(err,aRecUtil->GetSupportedBitRatesL(rates)); |
|
3182 // in Typhoon KErrNotSupported is expected |
|
3183 if(err==KErrNotSupported) |
|
3184 { |
|
3185 //test the other bitrate functions for code coverage (and behaviour) |
|
3186 TRAP(err,aRecUtil->SetDestinationBitRateL(100)); // arbitrary value since KErrNotSupported is expected anyway |
|
3187 if (err != KErrNotSupported) |
|
3188 { |
|
3189 return EFail; |
|
3190 } |
|
3191 |
|
3192 TInt rate=0; |
|
3193 TRAP(err, rate=aRecUtil->DestinationBitRateL()); |
|
3194 if (err != KErrNone) |
|
3195 { |
|
3196 return EFail; |
|
3197 } |
|
3198 |
|
3199 INFO_PRINTF3(_L("CMdaAudioRecorderUtility::GetSupportedBitRatesL() leave with error %d bitrate of %d"),err, rate); |
|
3200 ret = EPass; |
|
3201 return ret; |
|
3202 } |
|
3203 if(err!=KErrNone) |
|
3204 { |
|
3205 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::GetSupportedBitRatesL leave with error %d"),err); |
|
3206 ret = EFail; |
|
3207 return ret; |
|
3208 } |
|
3209 |
|
3210 TInt numRates = rates.Count(); |
|
3211 for(TInt i=0;i<numRates;i++) |
|
3212 { |
|
3213 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::SetDestinationBitRateL (%d)"),rates[i]); |
|
3214 TRAP(err,aRecUtil->SetDestinationBitRateL(rates[i])); |
|
3215 if(err!=KErrNone) |
|
3216 { |
|
3217 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::SetDestinationBitRateL leave with error %d"),err); |
|
3218 ret = EFail; |
|
3219 } |
|
3220 else// no error, get rate |
|
3221 { |
|
3222 TUint rate=0; |
|
3223 TRAP(err,rate = aRecUtil->DestinationBitRateL()); |
|
3224 if(err!=KErrNone) |
|
3225 { |
|
3226 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::DestinationBitRateL leave with error %d"),err); |
|
3227 ret = EFail; |
|
3228 } |
|
3229 else |
|
3230 { |
|
3231 if(rate!=rates[i]) |
|
3232 { |
|
3233 ret = EFail; |
|
3234 INFO_PRINTF1(_L("Rate mismatch")); |
|
3235 } |
|
3236 else |
|
3237 { |
|
3238 INFO_PRINTF1(_L("Rates match")); |
|
3239 } |
|
3240 } |
|
3241 } |
|
3242 } |
|
3243 return ret; |
|
3244 } |
|
3245 |
|
3246 |
|
3247 //------------------------------------------------------------------ |
|
3248 |
|
3249 |
|
3250 |
|
3251 CTestMmfAclntRecordDestDataType::CTestMmfAclntRecordDestDataType(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateDes) |
|
3252 { |
|
3253 // store the name of this test case |
|
3254 // this is the name that is used by the script file |
|
3255 // Each test step initialises it's own name |
|
3256 iTestStepName = aTestName; |
|
3257 iSectName = aSectName; |
|
3258 iKeyName = aKeyName; |
|
3259 iTestFormat = aFormat; |
|
3260 iCreateDes = aCreateDes; |
|
3261 iSize = 0; |
|
3262 iAudio = NULL; |
|
3263 } |
|
3264 |
|
3265 CTestMmfAclntRecordDestDataType* CTestMmfAclntRecordDestDataType::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat,const TBool aCreateDes) |
|
3266 { |
|
3267 CTestMmfAclntRecordDestDataType* self = new (ELeave) CTestMmfAclntRecordDestDataType(aTestName,aSectName,aKeyName,aFormat,aCreateDes); |
|
3268 return self; |
|
3269 } |
|
3270 |
|
3271 CTestMmfAclntRecordDestDataType* CTestMmfAclntRecordDestDataType::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateDes) |
|
3272 { |
|
3273 CTestMmfAclntRecordDestDataType* self = CTestMmfAclntRecordDestDataType::NewLC(aTestName,aSectName,aKeyName,aFormat,aCreateDes); |
|
3274 CleanupStack::PushL(self); |
|
3275 return self; |
|
3276 } |
|
3277 |
|
3278 void CTestMmfAclntRecordDestDataType::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode) |
|
3279 { |
|
3280 iError = aErrorCode; |
|
3281 INFO_PRINTF4( _L("MMdaObjectStateChangeObserver: previous state: %d current state: %d error: %d"),aPreviousState, aCurrentState, aErrorCode); |
|
3282 CActiveScheduler::Stop(); |
|
3283 } |
|
3284 |
|
3285 TVerdict CTestMmfAclntRecordDestDataType::DoTestStepPreambleL() |
|
3286 { |
|
3287 SetupFormatL(iTestFormat); |
|
3288 |
|
3289 switch (iTestFormat) |
|
3290 { |
|
3291 case EPcm16Wav: |
|
3292 case EAlawWav: |
|
3293 case EPcm8: |
|
3294 iHeaderSize = KWavFileUncompressedDataHeaderSize; //(see mmfwavformat.cpp, CreateSinkBufferOfSizeL()) |
|
3295 iFrameSize = 4096; |
|
3296 break; |
|
3297 case EImaAdpcmWav: |
|
3298 case EImasPcmWav: |
|
3299 iHeaderSize = KWavFileCompressedDataHeaderSize + KImaAdpcmFactChunkSize; |
|
3300 iFrameSize = 4096; |
|
3301 break; |
|
3302 case EMulawRaw: |
|
3303 case EPcmU8: |
|
3304 case EPcmU16: |
|
3305 iHeaderSize = 0; |
|
3306 iFrameSize = 4096; |
|
3307 break; |
|
3308 case EGsmWav: |
|
3309 iHeaderSize = KWavFileCompressedDataHeaderSize + KGSMFactChunkSize; |
|
3310 iFrameSize = 4096; |
|
3311 break; |
|
3312 default: |
|
3313 /*skip*/ ; |
|
3314 } |
|
3315 |
|
3316 if(!iCreateDes) |
|
3317 { |
|
3318 RFs fs; |
|
3319 RFile file; |
|
3320 |
|
3321 TBuf<KSizeBuf> filename; |
|
3322 TPtrC filename1; |
|
3323 if(!GetStringFromConfig(iSectName, iKeyName, filename1)) |
|
3324 { |
|
3325 return EInconclusive; |
|
3326 } |
|
3327 |
|
3328 GetDriveName(filename); |
|
3329 filename.Append(filename1); |
|
3330 INFO_PRINTF2(_L("File for test - %S"), &filename); |
|
3331 |
|
3332 User::LeaveIfError(fs.Connect()); |
|
3333 User::LeaveIfError(file.Open(fs,filename,EFileRead)); |
|
3334 CleanupClosePushL(file); |
|
3335 |
|
3336 User::LeaveIfError(file.Size(iSize)); |
|
3337 INFO_PRINTF2(_L("size of file = %d\n"),iSize);//Statement Changed under DEF105143 |
|
3338 iAudio = HBufC8::NewMaxL(iSize); |
|
3339 |
|
3340 // Read a file into a descriptor |
|
3341 TPtr8 bufferDes(iAudio->Des()); |
|
3342 User::LeaveIfError(file.Read(bufferDes)); |
|
3343 |
|
3344 CleanupStack::PopAndDestroy(); //file |
|
3345 } |
|
3346 return CTestMmfAclntStep::DoTestStepPreambleL(); |
|
3347 } |
|
3348 |
|
3349 TVerdict CTestMmfAclntRecordDestDataType::DoTestStepPostambleL() |
|
3350 { |
|
3351 delete iAudio; |
|
3352 return CTestMmfAclntStep::DoTestStepPostambleL(); |
|
3353 } |
|
3354 |
|
3355 /** |
|
3356 * Open a descriptor and record |
|
3357 */ |
|
3358 TVerdict CTestMmfAclntRecordDestDataType::DoTestStepL( void ) |
|
3359 { |
|
3360 HBufC8* audio = NULL; |
|
3361 TMdaDesClipLocation* location = NULL; |
|
3362 TInt err = KErrNone; |
|
3363 |
|
3364 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
3365 CleanupStack::PushL(recUtil); |
|
3366 |
|
3367 // Add create file for Ogg-tests |
|
3368 if(iSectName == _L("SectionOggRec")) |
|
3369 { |
|
3370 TBuf<KSizeBuf> filename; |
|
3371 TPtrC filename1; |
|
3372 if(!GetStringFromConfig(iSectName, iKeyName, filename1)) |
|
3373 { |
|
3374 return EInconclusive; |
|
3375 } |
|
3376 |
|
3377 GetDriveName(filename); |
|
3378 filename.Append(filename1); |
|
3379 |
|
3380 RFs fs; |
|
3381 User::LeaveIfError(fs.Connect()); |
|
3382 RFile file; |
|
3383 User::LeaveIfError(file.Replace(fs,filename,EFileWrite)); |
|
3384 file.Close(); |
|
3385 fs.Close(); |
|
3386 recUtil->OpenFileL(filename); |
|
3387 } |
|
3388 else if(!iCreateDes) |
|
3389 { |
|
3390 audio=iAudio; |
|
3391 TPtr8 bufferDes(iAudio->Des()); |
|
3392 recUtil->OpenDesL(bufferDes); |
|
3393 } |
|
3394 else |
|
3395 { |
|
3396 iSize = KRecSize; // value is not been set yet. |
|
3397 audio = HBufC8::NewMaxLC(iSize); |
|
3398 TPtr8 bufferDes(audio->Des()); |
|
3399 bufferDes.SetLength(0); |
|
3400 location = new (ELeave) TMdaDesClipLocation(bufferDes); |
|
3401 recUtil->OpenL(location,iFormat,iCodec,&iAudioSettings); |
|
3402 |
|
3403 delete location; |
|
3404 } |
|
3405 CActiveScheduler::Start(); |
|
3406 |
|
3407 iError = KErrTimedOut; |
|
3408 INFO_PRINTF1( _L("TestRecordUtils : Destination data type")); |
|
3409 |
|
3410 RArray<TFourCC> codecs; |
|
3411 recUtil->GetSupportedDestinationDataTypesL(codecs); |
|
3412 TInt numCodecs = codecs.Count(); |
|
3413 TVerdict ret = EPass; |
|
3414 for(TInt i=0;i<numCodecs;i++) |
|
3415 { |
|
3416 TRAP(err,recUtil->SetDestinationDataTypeL(codecs[i])); |
|
3417 if(err!=KErrNone) |
|
3418 { |
|
3419 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::SetDestinationDataTypeL leave with error %d"),err); |
|
3420 if(iCreateDes) |
|
3421 CleanupStack::PopAndDestroy(audio); |
|
3422 CleanupStack::PopAndDestroy(recUtil); |
|
3423 User::After(KOneSecond); |
|
3424 return ret; |
|
3425 } |
|
3426 TFourCC dataType; |
|
3427 TRAP(err,dataType = recUtil->DestinationDataTypeL()); |
|
3428 if(err!=KErrNone) |
|
3429 { |
|
3430 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::DestinationDataTypeL leave with error %d"),err); |
|
3431 if(iCreateDes) |
|
3432 CleanupStack::PopAndDestroy(audio); |
|
3433 CleanupStack::PopAndDestroy(recUtil); |
|
3434 User::After(KOneSecond); |
|
3435 return ret; |
|
3436 } |
|
3437 if(dataType!=codecs[i]) |
|
3438 { |
|
3439 ret = EFail; |
|
3440 } |
|
3441 else |
|
3442 { |
|
3443 INFO_PRINTF1(_L("CMdaAudioRecorderUtility::DestinationDataType set-get OK")); |
|
3444 } |
|
3445 } |
|
3446 if(iCreateDes) |
|
3447 { |
|
3448 CleanupStack::PopAndDestroy(audio); |
|
3449 } |
|
3450 |
|
3451 CleanupStack::PopAndDestroy(recUtil); |
|
3452 User::After(KOneSecond); |
|
3453 return ret; |
|
3454 } |
|
3455 |
|
3456 |
|
3457 |
|
3458 |
|
3459 //------------------------------------------------------------------ |
|
3460 |
|
3461 CTestMmfAclntRecordDestFormat::CTestMmfAclntRecordDestFormat(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative, const TUid aFormat) |
|
3462 : CTestMmfAclntRecord(aTestName, aSectName, aNegative), iFormat(aFormat) |
|
3463 {} |
|
3464 |
|
3465 CTestMmfAclntRecordDestFormat* CTestMmfAclntRecordDestFormat::NewL(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative, const TUid aFormat) |
|
3466 { |
|
3467 CTestMmfAclntRecordDestFormat* self = new (ELeave) CTestMmfAclntRecordDestFormat(aTestName, aSectName, aNegative, aFormat); |
|
3468 return self; |
|
3469 } |
|
3470 |
|
3471 |
|
3472 TVerdict CTestMmfAclntRecordDestFormat::DoTestL(CMdaAudioRecorderUtility* aRecUtil) |
|
3473 { |
|
3474 // GET --> SET --> GET |
|
3475 INFO_PRINTF1( _L("TestRecordUtils : Destination format")); |
|
3476 TVerdict ret = EFail; |
|
3477 TInt err = KErrNone; |
|
3478 TRAP(err,iFormat = aRecUtil->DestinationFormatL()); |
|
3479 if(err!=KErrNone) |
|
3480 { |
|
3481 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::DestinationFormatL leave with error %d"),err); |
|
3482 return ret; |
|
3483 } |
|
3484 TRAP(err,aRecUtil->SetDestinationFormatL(iFormat)); |
|
3485 if(err!=KErrNone) |
|
3486 { |
|
3487 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::SetDestinationFormatL leave with error %d"),err); |
|
3488 return ret; |
|
3489 } |
|
3490 TUid format; |
|
3491 TRAP(err,format = aRecUtil->DestinationFormatL()); |
|
3492 if(err!=KErrNone) |
|
3493 { |
|
3494 INFO_PRINTF2(_L("CMdaAudioRecorderUtility::DestinationFormatL leave with error %d"),err); |
|
3495 return ret; |
|
3496 } |
|
3497 if(format==iFormat) |
|
3498 { |
|
3499 ret = EPass; |
|
3500 } |
|
3501 |
|
3502 return ret; |
|
3503 } |
|
3504 |
|
3505 |
|
3506 //------------------------------------------------------------------ |
|
3507 |
|
3508 CTestMmfAclntRecordAudioDeviceMode::CTestMmfAclntRecordAudioDeviceMode(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
3509 : CTestMmfAclntRecord(aTestName, aSectName, aNegative) |
|
3510 {} |
|
3511 |
|
3512 CTestMmfAclntRecordAudioDeviceMode* CTestMmfAclntRecordAudioDeviceMode::NewL(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
3513 { |
|
3514 CTestMmfAclntRecordAudioDeviceMode* self = new (ELeave) CTestMmfAclntRecordAudioDeviceMode(aTestName, aSectName, aNegative); |
|
3515 return self; |
|
3516 } |
|
3517 |
|
3518 |
|
3519 TVerdict CTestMmfAclntRecordAudioDeviceMode::DoTestL(CMdaAudioRecorderUtility* aRecUtil) |
|
3520 { |
|
3521 INFO_PRINTF1( _L("TestRecordUtils : SetAudioDeviceMode")); |
|
3522 INFO_PRINTF1( _L("This function is provided for binary compatibility, but does not have any effect from 7.0s")); |
|
3523 |
|
3524 // Set the audio device mode. This function is provided for binary compatibility, but |
|
3525 // does not have any effect from 7.0s |
|
3526 aRecUtil->SetAudioDeviceMode(CMdaAudioRecorderUtility::EDefault); |
|
3527 aRecUtil->SetAudioDeviceMode(CMdaAudioRecorderUtility::ETelephonyOrLocal); |
|
3528 aRecUtil->SetAudioDeviceMode(CMdaAudioRecorderUtility::ETelephonyMixed); |
|
3529 aRecUtil->SetAudioDeviceMode(CMdaAudioRecorderUtility::ETelephonyNonMixed); |
|
3530 aRecUtil->SetAudioDeviceMode(CMdaAudioRecorderUtility::ELocal); |
|
3531 TVerdict ret = EPass; |
|
3532 return ret; |
|
3533 } |
|
3534 |
|
3535 |
|
3536 |
|
3537 |
|
3538 |
|
3539 |
|
3540 |
|
3541 |
|
3542 // |
|
3543 // |
|
3544 // CMdaAudioInputStream Integration Tests // |
|
3545 // |
|
3546 // |
|
3547 |
|
3548 /** |
|
3549 * Standard static NewL() taking a callback function |
|
3550 */ |
|
3551 CCallBackTimer* CCallBackTimer::NewL(TCallBack aCallBack, TPriority aPriority) |
|
3552 { |
|
3553 CCallBackTimer* self = new(ELeave) CCallBackTimer(aCallBack, aPriority); |
|
3554 CleanupStack::PushL(self); |
|
3555 self->ConstructL(); |
|
3556 CleanupStack::Pop(); // self |
|
3557 return self; |
|
3558 } |
|
3559 |
|
3560 /** |
|
3561 * Private c'tor |
|
3562 */ |
|
3563 CCallBackTimer::CCallBackTimer(TCallBack aCallBack, TPriority aPriority) |
|
3564 : CTimer(aPriority), |
|
3565 iCallBack(aCallBack) |
|
3566 { |
|
3567 CActiveScheduler::Add(this); |
|
3568 } |
|
3569 |
|
3570 /* |
|
3571 * Callback on timer complete |
|
3572 */ |
|
3573 void CCallBackTimer::RunL() |
|
3574 { |
|
3575 iCallBack.CallBack(); |
|
3576 } |
|
3577 |
|
3578 |
|
3579 _LIT(KStreamRawFile,"c:\\AclntITestData\\test.raw"); |
|
3580 _LIT(KRecordStreamRawFile,"c:\\AclntITestData\\streamrecorded.raw"); |
|
3581 CTestStepAudInStream* CTestStepAudInStream::NewL() |
|
3582 { |
|
3583 CTestStepAudInStream* s = new(ELeave) CTestStepAudInStream(); |
|
3584 CleanupStack::PushL(s); |
|
3585 s->ConstructL(); |
|
3586 CleanupStack::Pop(); |
|
3587 return s; |
|
3588 } |
|
3589 |
|
3590 CTestStepAudInStream::CTestStepAudInStream() : iError(KErrNone), iState(EStopped) |
|
3591 { |
|
3592 |
|
3593 } |
|
3594 |
|
3595 void CTestStepAudInStream::ConstructL() |
|
3596 { |
|
3597 // reset the buffer |
|
3598 for(TInt i=0; i<KRecNumBuffer; i++) |
|
3599 { |
|
3600 iBufferList[i] = KNullDesC8; |
|
3601 } |
|
3602 iStartBuf=iEndBuf=0; |
|
3603 } |
|
3604 |
|
3605 CTestStepAudInStream::~CTestStepAudInStream() |
|
3606 { |
|
3607 } |
|
3608 |
|
3609 void CTestStepAudInStream::MaiscOpenComplete(TInt aError) |
|
3610 { |
|
3611 iError = aError; |
|
3612 CActiveScheduler::Stop(); |
|
3613 } |
|
3614 |
|
3615 void CTestStepAudInStream::MaiscRecordComplete(TInt aError) |
|
3616 { |
|
3617 iError = aError; |
|
3618 |
|
3619 iWriteBufferActive->Cancel(); |
|
3620 TInt filePosition=0; |
|
3621 iFile.Seek(ESeekStart, filePosition); |
|
3622 iFile.Close(); |
|
3623 CActiveScheduler::Stop(); |
|
3624 } |
|
3625 |
|
3626 void CTestStepAudInStream::MaiscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/) |
|
3627 { |
|
3628 iError = aError; |
|
3629 if(aError != KErrNone) |
|
3630 { |
|
3631 return; |
|
3632 } |
|
3633 // Assume aBuffer == iBufferList[iEndBuf] |
|
3634 |
|
3635 // Increment iEndBuf |
|
3636 if(iEndBuf==KRecNumBuffer-1) |
|
3637 { |
|
3638 iEndBuf = 0; |
|
3639 } |
|
3640 |
|
3641 else |
|
3642 iEndBuf++; |
|
3643 |
|
3644 // Starting writing out the buffers if we're not already |
|
3645 if(!iWriteBufferActive->IsActive()) |
|
3646 { |
|
3647 iWriteBufferActive->Write(iBufferList[iStartBuf]); |
|
3648 } |
|
3649 } |
|
3650 |
|
3651 void CTestStepAudInStream::StartReadL() |
|
3652 { |
|
3653 // Issue reads on all available buffers |
|
3654 for (TInt ii=0; ii<KRecNumBuffer; ii++) |
|
3655 { |
|
3656 iAudInStream->ReadL(iBufferList[ii]); |
|
3657 } |
|
3658 } |
|
3659 |
|
3660 void CTestStepAudInStream::Read1BufL() |
|
3661 { |
|
3662 // Issue reads on 1 available buffer |
|
3663 iAudInStream->ReadL(iBufferList[0]); |
|
3664 } |
|
3665 |
|
3666 |
|
3667 CTestStepAudInStream::CWriteBufferActive::CWriteBufferActive() : CActive(0) |
|
3668 { |
|
3669 CActiveScheduler::Add(this); |
|
3670 } |
|
3671 |
|
3672 CTestStepAudInStream::CWriteBufferActive::~CWriteBufferActive() |
|
3673 { |
|
3674 Cancel(); |
|
3675 } |
|
3676 |
|
3677 void CTestStepAudInStream::CWriteBufferActive::RunL() |
|
3678 { |
|
3679 //ASSERT it wrote OK |
|
3680 iParent->ProcessDataL(); |
|
3681 } |
|
3682 |
|
3683 TInt CTestStepAudInStream::CWriteBufferActive::RunError(TInt aError) |
|
3684 { |
|
3685 iParent->iError = aError; |
|
3686 CActiveScheduler::Stop(); |
|
3687 |
|
3688 return KErrNone; |
|
3689 } |
|
3690 |
|
3691 |
|
3692 void CTestStepAudInStream::CWriteBufferActive::DoCancel() |
|
3693 { |
|
3694 // do nothing |
|
3695 } |
|
3696 |
|
3697 void CTestStepAudInStream::CWriteBufferActive::Write(const TDesC8& aBuffer) |
|
3698 { |
|
3699 iParent->iFile.Write(aBuffer, iStatus); // read the 1st data trunk |
|
3700 SetActive(); |
|
3701 } |
|
3702 |
|
3703 |
|
3704 void CTestStepAudInStream::ProcessDataL() |
|
3705 { |
|
3706 // Set the next buffer to handle |
|
3707 iBufferList[iStartBuf] = KNullDesC8; // done with that one |
|
3708 // Issue another read to input stream |
|
3709 iAudInStream->ReadL(iBufferList[iStartBuf]); |
|
3710 |
|
3711 // Increment iStartBuf |
|
3712 if(iStartBuf==KRecNumBuffer-1) |
|
3713 { |
|
3714 iStartBuf=0; |
|
3715 } |
|
3716 |
|
3717 else |
|
3718 iStartBuf++; |
|
3719 |
|
3720 if (iBufferList[iStartBuf] != KNullDesC8) |
|
3721 { |
|
3722 // Still more to write |
|
3723 iWriteBufferActive->Write(iBufferList[iStartBuf]); |
|
3724 } |
|
3725 else |
|
3726 CActiveScheduler::Stop(); |
|
3727 |
|
3728 // else just wait for more recorded data to come through |
|
3729 } |
|
3730 |
|
3731 /** |
|
3732 * |
|
3733 * Test step Preamble. |
|
3734 * |
|
3735 * @xxxx |
|
3736 * |
|
3737 */ |
|
3738 enum TVerdict CTestStepAudInStream::DoTestStepPreambleL(void) |
|
3739 { |
|
3740 enum TVerdict verdict; |
|
3741 |
|
3742 // reset the buffer [in case new test reuses previous object] |
|
3743 for(TInt i=0; i<KRecNumBuffer; i++) |
|
3744 { |
|
3745 iBufferList[i] = KNullDesC8; |
|
3746 } |
|
3747 iStartBuf=iEndBuf=0; |
|
3748 |
|
3749 // this installs the scheduler |
|
3750 verdict = CTestMmfAclntStep::DoTestStepPreambleL(); |
|
3751 |
|
3752 // create the active object |
|
3753 iWriteBufferActive = new(ELeave) CWriteBufferActive(); |
|
3754 iWriteBufferActive->iParent = this; |
|
3755 iFs.Connect(); |
|
3756 |
|
3757 TRAPD(err, iAudInStream = CMdaAudioInputStream::NewL(*this) ); |
|
3758 |
|
3759 if (err != KErrNone || |
|
3760 iAudInStream == NULL ) |
|
3761 { |
|
3762 return EInconclusive; |
|
3763 } |
|
3764 |
|
3765 |
|
3766 return verdict; |
|
3767 } |
|
3768 |
|
3769 /** |
|
3770 * |
|
3771 * Test step Postamble. |
|
3772 * |
|
3773 * @xxxx |
|
3774 * |
|
3775 */ |
|
3776 enum TVerdict CTestStepAudInStream::DoTestStepPostambleL(void) |
|
3777 { |
|
3778 iFs.Close(); |
|
3779 |
|
3780 delete iAudInStream; |
|
3781 iAudInStream = NULL; |
|
3782 delete iWriteBufferActive; |
|
3783 iWriteBufferActive = NULL; |
|
3784 //[ Destroy the scheduler ] |
|
3785 return CTestMmfAclntStep::DoTestStepPostambleL(); |
|
3786 } |
|
3787 |
|
3788 /** |
|
3789 * |
|
3790 * Do the test step. |
|
3791 * Each test step must supply an implementation for DoTestStepL. |
|
3792 * |
|
3793 * @return "TVerdict" |
|
3794 * The result of the test step |
|
3795 * |
|
3796 * @xxxx |
|
3797 * |
|
3798 */ |
|
3799 TVerdict CTestStepAudInStream::DoTestStepL() |
|
3800 { |
|
3801 iTestStepResult = EPass; |
|
3802 TInt err = KErrNone; |
|
3803 |
|
3804 if (iError != KErrNone ) |
|
3805 return EFail; |
|
3806 |
|
3807 err = iFile.Replace( iFs, KRecordStreamRawFile, EFileWrite ) ; |
|
3808 if (err != KErrNone) |
|
3809 return EFail; |
|
3810 |
|
3811 StartReadL(); |
|
3812 CActiveScheduler::Start(); |
|
3813 |
|
3814 iFile.Close(); |
|
3815 |
|
3816 INFO_PRINTF1(_L("finished with this test step")); |
|
3817 // test steps return a result |
|
3818 return iTestStepResult; |
|
3819 } |
|
3820 |
|
3821 |
|
3822 |
|
3823 CTestStepAudInStreamNoUECap* CTestStepAudInStreamNoUECap::NewL(const TDesC& aTestName) |
|
3824 { |
|
3825 CTestStepAudInStreamNoUECap* self = new(ELeave) CTestStepAudInStreamNoUECap(aTestName); |
|
3826 return self; |
|
3827 } |
|
3828 |
|
3829 |
|
3830 CTestStepAudInStreamNoUECap::CTestStepAudInStreamNoUECap(const TDesC& aTestName) |
|
3831 { |
|
3832 iTestStepResult = EFail; |
|
3833 // store the name of this test case |
|
3834 // this is the name that is used by the script file |
|
3835 iTestStepName = aTestName; |
|
3836 } |
|
3837 |
|
3838 |
|
3839 |
|
3840 CTestStepAudInStreamNoUECap::~CTestStepAudInStreamNoUECap() |
|
3841 { |
|
3842 } |
|
3843 |
|
3844 |
|
3845 void CTestStepAudInStreamNoUECap::MaiscOpenComplete(TInt aError) |
|
3846 { |
|
3847 iError = aError; |
|
3848 CActiveScheduler::Stop(); |
|
3849 } |
|
3850 |
|
3851 void CTestStepAudInStreamNoUECap::MaiscBufferCopied(TInt /*aError*/, const TDesC8& /*aBuffer*/) |
|
3852 { |
|
3853 INFO_PRINTF1(_L("MMdaAudioInputStreamCallback::MaiscBufferCopied was not supposed to be called")); |
|
3854 iTestStepResult = EFail; |
|
3855 CActiveScheduler::Stop(); |
|
3856 } |
|
3857 void CTestStepAudInStreamNoUECap::MaiscRecordComplete(TInt aError) |
|
3858 { |
|
3859 INFO_PRINTF2(_L("MMdaAudioInputStreamCallback::MaiscRecordComplete was called with aError = %d"),aError); |
|
3860 iMaiscRecordCompleteError = aError; |
|
3861 CActiveScheduler::Stop(); |
|
3862 } |
|
3863 |
|
3864 TVerdict CTestStepAudInStreamNoUECap::DoTestStepL() |
|
3865 { |
|
3866 TInt err = KErrNone; |
|
3867 iTestStepResult = EFail; |
|
3868 |
|
3869 // Printing to the console and log file |
|
3870 INFO_PRINTF1(_L("this test calls MediaAudioClientInputStream::ReadL func with NO UserEnvironment capability")); |
|
3871 |
|
3872 iAudInStream->Open(NULL); |
|
3873 CActiveScheduler::Start(); |
|
3874 |
|
3875 if (iError != KErrNone) |
|
3876 { |
|
3877 INFO_PRINTF2(_L("DEBUG LEAVE 1: error = %d"),iError); |
|
3878 return EInconclusive; |
|
3879 } |
|
3880 |
|
3881 iFile.Replace( iFs, KRecordStreamRawFile, EFileWrite ) ; |
|
3882 if (err != KErrNone) |
|
3883 { |
|
3884 INFO_PRINTF2(_L("DEBUG LEAVE 2: error = %d"),err); |
|
3885 return EInconclusive; |
|
3886 } |
|
3887 |
|
3888 iState=ERecording; |
|
3889 |
|
3890 // start feeding the input stream |
|
3891 TRAP(err, Read1BufL()); |
|
3892 CActiveScheduler::Start(); |
|
3893 if ( (err == KErrNone && iMaiscRecordCompleteError == KErrPermissionDenied) || err == KErrPermissionDenied ) |
|
3894 { |
|
3895 INFO_PRINTF2(_L("Feeding input stream without UserEnvironent cap left with expected error = %d"),err); |
|
3896 iTestStepResult = EPass; |
|
3897 } |
|
3898 else |
|
3899 { |
|
3900 INFO_PRINTF1(_L("Failed this test step with error %d")); |
|
3901 INFO_PRINTF2(_L("Expected error = %d"),KErrPermissionDenied); |
|
3902 INFO_PRINTF1(_L("The requesting client should not have the UserEnvironment cap in this test")); |
|
3903 iTestStepResult = EFail; |
|
3904 } |
|
3905 // test steps return a result |
|
3906 |
|
3907 return iTestStepResult; |
|
3908 } |
|
3909 |
|
3910 CTestStepAudInStreamWithUECap* CTestStepAudInStreamWithUECap::NewL(const TDesC& aTestName) |
|
3911 { |
|
3912 CTestStepAudInStreamWithUECap* self = new(ELeave) CTestStepAudInStreamWithUECap(aTestName); |
|
3913 return self; |
|
3914 } |
|
3915 |
|
3916 |
|
3917 CTestStepAudInStreamWithUECap::CTestStepAudInStreamWithUECap(const TDesC& aTestName) |
|
3918 { |
|
3919 iTestStepResult = EFail; |
|
3920 // store the name of this test case |
|
3921 // this is the name that is used by the script file |
|
3922 iTestStepName = aTestName; |
|
3923 } |
|
3924 |
|
3925 |
|
3926 |
|
3927 CTestStepAudInStreamWithUECap::~CTestStepAudInStreamWithUECap() |
|
3928 { |
|
3929 } |
|
3930 |
|
3931 |
|
3932 void CTestStepAudInStreamWithUECap::MaiscOpenComplete(TInt aError) |
|
3933 { |
|
3934 iError = aError; |
|
3935 CActiveScheduler::Stop(); |
|
3936 } |
|
3937 |
|
3938 |
|
3939 void CTestStepAudInStreamWithUECap::MaiscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/) |
|
3940 { |
|
3941 //if weve stopped recording, each unused buffer will be returned with KErrAbort |
|
3942 if(iState == EStopped && aError == KErrAbort) |
|
3943 { |
|
3944 return; |
|
3945 } |
|
3946 |
|
3947 iError = aError; |
|
3948 } |
|
3949 |
|
3950 void CTestStepAudInStreamWithUECap::MaiscRecordComplete(TInt aError) |
|
3951 { |
|
3952 iError = aError; |
|
3953 CActiveScheduler::Stop(); |
|
3954 } |
|
3955 |
|
3956 TVerdict CTestStepAudInStreamWithUECap::DoTestStepL() |
|
3957 { |
|
3958 // Printing to the console and log file |
|
3959 INFO_PRINTF1(_L("This test calls MediaAudioClientInputStream::ReadL func with at list the UserEnvironment capability")); |
|
3960 |
|
3961 iAudInStream->Open(NULL); |
|
3962 CActiveScheduler::Start(); |
|
3963 |
|
3964 if (iError != KErrNone) |
|
3965 { |
|
3966 INFO_PRINTF2(_L("DEBUG LEAVE 1: error = %d"),iError); |
|
3967 return EInconclusive; |
|
3968 } |
|
3969 |
|
3970 TInt err = iFile.Replace( iFs, KRecordStreamRawFile, EFileWrite ) ; |
|
3971 if (err != KErrNone) |
|
3972 { |
|
3973 INFO_PRINTF2(_L("DEBUG LEAVE 2: error = %d"),err); |
|
3974 return EInconclusive; |
|
3975 } |
|
3976 |
|
3977 |
|
3978 iState=ERecording; |
|
3979 |
|
3980 // start feeding the input stream |
|
3981 TRAP(err, Read1BufL()); |
|
3982 CActiveScheduler::Start(); |
|
3983 |
|
3984 if (err != KErrNone) |
|
3985 { |
|
3986 INFO_PRINTF2(_L("Test Failed with: error = %d"),iError); |
|
3987 return EFail; |
|
3988 } |
|
3989 |
|
3990 return EPass; |
|
3991 } |
|
3992 |
|
3993 |
|
3994 CTestStepAudInStreamSetGain* CTestStepAudInStreamSetGain::NewL(const TDesC& aTestName) |
|
3995 { |
|
3996 CTestStepAudInStreamSetGain* self = new(ELeave) CTestStepAudInStreamSetGain(aTestName); |
|
3997 return self; |
|
3998 } |
|
3999 |
|
4000 CTestStepAudInStreamSetGain::CTestStepAudInStreamSetGain(const TDesC& aTestName) |
|
4001 { |
|
4002 iTestStepResult = EPass; |
|
4003 // store the name of this test case |
|
4004 // this is the name that is used by the script file |
|
4005 iTestStepName = aTestName; |
|
4006 } |
|
4007 |
|
4008 CTestStepAudInStreamSetGain::~CTestStepAudInStreamSetGain() |
|
4009 { |
|
4010 } |
|
4011 |
|
4012 void CTestStepAudInStreamSetGain::MaiscOpenComplete(TInt /*aError*/) |
|
4013 { |
|
4014 } |
|
4015 void CTestStepAudInStreamSetGain::MaiscBufferCopied(TInt /*aError*/, const TDesC8& /*aBuffer*/) |
|
4016 { |
|
4017 } |
|
4018 void CTestStepAudInStreamSetGain::MaiscRecordComplete(TInt /*aError*/) |
|
4019 { |
|
4020 } |
|
4021 |
|
4022 enum TVerdict CTestStepAudInStreamSetGain::DoTestStepPreambleL(void) |
|
4023 { |
|
4024 enum TVerdict verdict; |
|
4025 // this installs the scheduler |
|
4026 verdict = CTestMmfAclntStep::DoTestStepPreambleL(); |
|
4027 INFO_PRINTF2(_L("Test step %S DoTestStepPreambleL"),&iTestStepName); |
|
4028 TInt err = KErrNone; |
|
4029 TRAP(err, iAudInStream = CMdaAudioInputStream::NewL(*this)); |
|
4030 if (err != KErrNone || iAudInStream == NULL ) |
|
4031 { |
|
4032 return EInconclusive; |
|
4033 } |
|
4034 |
|
4035 return verdict; |
|
4036 } |
|
4037 |
|
4038 enum TVerdict CTestStepAudInStreamSetGain::DoTestStepPostambleL(void) |
|
4039 { |
|
4040 delete iAudInStream; |
|
4041 iAudInStream = NULL; |
|
4042 //[ Destroy the scheduler ] |
|
4043 INFO_PRINTF2(_L("Test step %S DoTestStepPostambleL"),&iTestStepName); |
|
4044 return CTestMmfAclntStep::DoTestStepPostambleL(); |
|
4045 } |
|
4046 |
|
4047 TVerdict CTestStepAudInStreamSetGain::DoTestStepL() |
|
4048 { |
|
4049 INFO_PRINTF1( _L("TestAudioInputStream : Gain")); |
|
4050 INFO_PRINTF2( _L("TestAudioInputStream : MaxGain()(%d)"),iAudInStream->MaxGain()); |
|
4051 TInt gain = iAudInStream->MaxGain()/2; |
|
4052 if (gain < 0) |
|
4053 { |
|
4054 return EFail; |
|
4055 } |
|
4056 |
|
4057 //set the volume |
|
4058 INFO_PRINTF2( _L("TestAudioInputStream : SetGain(%d)"),gain); |
|
4059 iAudInStream->SetGain(gain); |
|
4060 |
|
4061 //get the volume |
|
4062 TInt rgain = iAudInStream->Gain(); |
|
4063 if (gain != rgain ) |
|
4064 { |
|
4065 return EFail; |
|
4066 } |
|
4067 |
|
4068 INFO_PRINTF2( _L("TestAudioInputStream : Gain() returned %d"),rgain); |
|
4069 INFO_PRINTF1(_L("finished with this test step")); |
|
4070 // test steps return a result |
|
4071 return iTestStepResult; |
|
4072 } |
|
4073 |
|
4074 |
|
4075 // |
|
4076 // |
|
4077 // |
|
4078 CTestStepAudInStreamSetPriority* CTestStepAudInStreamSetPriority::NewL(const TDesC& aTestName) |
|
4079 { |
|
4080 CTestStepAudInStreamSetPriority* self = new(ELeave) CTestStepAudInStreamSetPriority(aTestName); |
|
4081 return self; |
|
4082 } |
|
4083 |
|
4084 CTestStepAudInStreamSetPriority::CTestStepAudInStreamSetPriority(const TDesC& aTestName) |
|
4085 { |
|
4086 iTestStepResult = EPass; |
|
4087 // store the name of this test case |
|
4088 // this is the name that is used by the script file |
|
4089 iTestStepName = aTestName; |
|
4090 } |
|
4091 |
|
4092 CTestStepAudInStreamSetPriority::~CTestStepAudInStreamSetPriority() |
|
4093 { |
|
4094 } |
|
4095 |
|
4096 void CTestStepAudInStreamSetPriority::MaiscOpenComplete(TInt aError) |
|
4097 { |
|
4098 iError = aError; |
|
4099 } |
|
4100 void CTestStepAudInStreamSetPriority::MaiscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/) |
|
4101 { |
|
4102 iError = aError; |
|
4103 } |
|
4104 void CTestStepAudInStreamSetPriority::MaiscRecordComplete(TInt aError) |
|
4105 { |
|
4106 iError = aError; |
|
4107 } |
|
4108 |
|
4109 enum TVerdict CTestStepAudInStreamSetPriority::DoTestStepPreambleL(void) |
|
4110 { |
|
4111 enum TVerdict verdict; |
|
4112 // this installs the scheduler |
|
4113 verdict = CTestMmfAclntStep::DoTestStepPreambleL(); |
|
4114 |
|
4115 TInt err = KErrNone; |
|
4116 TRAP(err, iAudInStream = CMdaAudioInputStream::NewL(*this)); |
|
4117 if (err != KErrNone || iAudInStream == NULL ) |
|
4118 { |
|
4119 return EInconclusive; |
|
4120 } |
|
4121 |
|
4122 return verdict; |
|
4123 } |
|
4124 |
|
4125 enum TVerdict CTestStepAudInStreamSetPriority::DoTestStepPostambleL(void) |
|
4126 { |
|
4127 delete iAudInStream; |
|
4128 iAudInStream = NULL; |
|
4129 //[ Destroy the scheduler ] |
|
4130 return CTestMmfAclntStep::DoTestStepPostambleL(); |
|
4131 } |
|
4132 |
|
4133 TVerdict CTestStepAudInStreamSetPriority::DoTestStepL() |
|
4134 { |
|
4135 INFO_PRINTF1( _L("TestAudioInputStream : Priority")); |
|
4136 iAudInStream->SetPriority(EMdaPriorityMin, EMdaPriorityPreferenceTime); |
|
4137 iAudInStream->SetPriority(EMdaPriorityMax, EMdaPriorityPreferenceQuality); |
|
4138 INFO_PRINTF1(_L("finished with this test step")); |
|
4139 // test steps return a result |
|
4140 return iTestStepResult; |
|
4141 } |
|
4142 |
|
4143 |
|
4144 // |
|
4145 // |
|
4146 // |
|
4147 CTestStepAudInStreamSetBalance* CTestStepAudInStreamSetBalance::NewL(const TDesC& aTestName) |
|
4148 { |
|
4149 CTestStepAudInStreamSetBalance* self = new(ELeave) CTestStepAudInStreamSetBalance(aTestName); |
|
4150 return self; |
|
4151 } |
|
4152 |
|
4153 CTestStepAudInStreamSetBalance::CTestStepAudInStreamSetBalance(const TDesC& aTestName) |
|
4154 { |
|
4155 iTestStepResult = EPass; |
|
4156 // store the name of this test case |
|
4157 // this is the name that is used by the script file |
|
4158 iTestStepName = aTestName; |
|
4159 } |
|
4160 |
|
4161 CTestStepAudInStreamSetBalance::~CTestStepAudInStreamSetBalance() |
|
4162 { |
|
4163 } |
|
4164 |
|
4165 void CTestStepAudInStreamSetBalance::MaiscOpenComplete(TInt /*aError*/) |
|
4166 { |
|
4167 } |
|
4168 void CTestStepAudInStreamSetBalance::MaiscBufferCopied(TInt /*aError*/, const TDesC8& /*aBuffer*/) |
|
4169 { |
|
4170 } |
|
4171 void CTestStepAudInStreamSetBalance::MaiscRecordComplete(TInt /*aError*/) |
|
4172 { |
|
4173 } |
|
4174 |
|
4175 enum TVerdict CTestStepAudInStreamSetBalance::DoTestStepPreambleL(void) |
|
4176 { |
|
4177 enum TVerdict verdict; |
|
4178 // this installs the scheduler |
|
4179 verdict = CTestMmfAclntStep::DoTestStepPreambleL(); |
|
4180 |
|
4181 TInt err = KErrNone; |
|
4182 TRAP(err, iAudInStream = CMdaAudioInputStream::NewL(*this)); |
|
4183 if (err != KErrNone || iAudInStream == NULL ) |
|
4184 { |
|
4185 return EInconclusive; |
|
4186 } |
|
4187 |
|
4188 return verdict; |
|
4189 } |
|
4190 |
|
4191 enum TVerdict CTestStepAudInStreamSetBalance::DoTestStepPostambleL(void) |
|
4192 { |
|
4193 delete iAudInStream; |
|
4194 iAudInStream = NULL; |
|
4195 //[ Destroy the scheduler ] |
|
4196 return CTestMmfAclntStep::DoTestStepPostambleL(); |
|
4197 } |
|
4198 |
|
4199 TVerdict CTestStepAudInStreamSetBalance::DoTestStepL() |
|
4200 { |
|
4201 TInt bal=0; |
|
4202 |
|
4203 TRAPD(err, iAudInStream->SetBalanceL()); // default KMMFBalanceCenter |
|
4204 if (err != KErrNone) |
|
4205 { |
|
4206 return EFail; // we expect this _will_ be supported for Typhoon |
|
4207 } |
|
4208 |
|
4209 //get the balance |
|
4210 TRAP(err, bal = iAudInStream->GetBalanceL()); |
|
4211 if (err != KErrNone) |
|
4212 { |
|
4213 return EFail; // we expect this _will_ be supported for Typhoon |
|
4214 } |
|
4215 |
|
4216 if (bal != KMMFBalanceCenter ) |
|
4217 { |
|
4218 return EFail; |
|
4219 } |
|
4220 |
|
4221 TRAP(err, iAudInStream->SetBalanceL(KMMFBalanceMaxRight)); |
|
4222 if (err != KErrNone) |
|
4223 { |
|
4224 return EFail; // we expect this _will_ be supported for Typhoon |
|
4225 } |
|
4226 |
|
4227 //get the balance |
|
4228 TRAP(err, bal = iAudInStream->GetBalanceL()); |
|
4229 if (err != KErrNone) |
|
4230 { |
|
4231 return EFail; // we expect this _will_ be supported for Typhoon |
|
4232 } |
|
4233 |
|
4234 |
|
4235 if (bal != KMMFBalanceMaxRight) |
|
4236 { |
|
4237 return EFail; |
|
4238 } |
|
4239 |
|
4240 TRAP(err, iAudInStream->SetBalanceL(KMMFBalanceMaxLeft)); |
|
4241 if (err != KErrNone) |
|
4242 { |
|
4243 return EFail; // we expect this _will_ be supported for Typhoon |
|
4244 } |
|
4245 |
|
4246 //get the balance |
|
4247 TRAP(err, bal = iAudInStream->GetBalanceL()); |
|
4248 if (err != KErrNone) |
|
4249 { |
|
4250 return EFail; // we expect this _will_ be supported for Typhoon |
|
4251 } |
|
4252 |
|
4253 if (bal != KMMFBalanceMaxLeft ) |
|
4254 { |
|
4255 return EFail; |
|
4256 } |
|
4257 |
|
4258 // In of bounds |
|
4259 /* |
|
4260 iAudInStream->SetBalance(KMMFBalanceMaxLeft+10); |
|
4261 //check condition |
|
4262 */ |
|
4263 |
|
4264 INFO_PRINTF1(_L("finished with this test step")); |
|
4265 // test steps return a result |
|
4266 return iTestStepResult; |
|
4267 } |
|
4268 |
|
4269 // |
|
4270 // |
|
4271 // |
|
4272 |
|
4273 LOCAL_C TInt stopActiveScheduler(TAny*) |
|
4274 { |
|
4275 CActiveScheduler::Stop(); |
|
4276 return FALSE; |
|
4277 } |
|
4278 |
|
4279 CTestStepAudInStreamGetBytes* CTestStepAudInStreamGetBytes::NewL(const TDesC& aTestName) |
|
4280 { |
|
4281 CTestStepAudInStreamGetBytes* self = new(ELeave) CTestStepAudInStreamGetBytes(aTestName); |
|
4282 return self; |
|
4283 } |
|
4284 |
|
4285 CTestStepAudInStreamGetBytes::CTestStepAudInStreamGetBytes(const TDesC& aTestName) |
|
4286 { |
|
4287 iTestStepResult = EPass; |
|
4288 // store the name of this test case |
|
4289 // this is the name that is used by the script file |
|
4290 iTestStepName = aTestName; |
|
4291 } |
|
4292 |
|
4293 CTestStepAudInStreamGetBytes::~CTestStepAudInStreamGetBytes() |
|
4294 { |
|
4295 } |
|
4296 |
|
4297 void CTestStepAudInStreamGetBytes::MaiscOpenComplete(TInt aError) |
|
4298 { |
|
4299 iError = aError; |
|
4300 CActiveScheduler::Stop(); |
|
4301 } |
|
4302 void CTestStepAudInStreamGetBytes::MaiscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/) |
|
4303 { |
|
4304 //if weve stopped recording, each unused buffer will be returned with KErrAbort |
|
4305 if(iState == EStopped && aError == KErrAbort) |
|
4306 { |
|
4307 return; |
|
4308 } |
|
4309 |
|
4310 iError = aError; |
|
4311 ++iBuffersUsed; |
|
4312 } |
|
4313 |
|
4314 void CTestStepAudInStreamGetBytes::MaiscRecordComplete(TInt aError) |
|
4315 { |
|
4316 |
|
4317 if(aError != KErrNone) |
|
4318 { |
|
4319 iError = aError; |
|
4320 CActiveScheduler::Stop(); |
|
4321 return; |
|
4322 } |
|
4323 // Assume aBuffer == iBufferList[iEndBuf] |
|
4324 |
|
4325 // Increment iEndBuf |
|
4326 if(iEndBuf==KRecNumBuffer-1) |
|
4327 { |
|
4328 iEndBuf = 0; |
|
4329 } |
|
4330 |
|
4331 else |
|
4332 iEndBuf++; |
|
4333 |
|
4334 // Starting writing out the buffers if we're not already |
|
4335 if(!iWriteBufferActive->IsActive()) |
|
4336 iWriteBufferActive->Write(iBufferList[iStartBuf]); |
|
4337 } |
|
4338 |
|
4339 enum TVerdict CTestStepAudInStreamGetBytes::DoTestStepPreambleL(void) |
|
4340 { |
|
4341 iTestStepResult = EPass; |
|
4342 enum TVerdict verdict; |
|
4343 // this installs the scheduler |
|
4344 verdict = CTestStepAudInStream::DoTestStepPreambleL(); |
|
4345 |
|
4346 // Printing to the console and log file |
|
4347 INFO_PRINTF1(_L("this test gets the bytes rendered by the H/W until this moment: GetBytes()")); |
|
4348 |
|
4349 iAudInStream->Open(NULL); |
|
4350 CActiveScheduler::Start(); |
|
4351 |
|
4352 if (iError != KErrNone) |
|
4353 { |
|
4354 INFO_PRINTF2(_L("DEBUG LEAVE 1: error = %d"),iError); |
|
4355 return EInconclusive; |
|
4356 } |
|
4357 |
|
4358 TInt err = iFile.Replace( iFs, KRecordStreamRawFile, EFileWrite ) ; |
|
4359 if (err != KErrNone) |
|
4360 { |
|
4361 INFO_PRINTF2(_L("DEBUG LEAVE 2: error = %d"),err); |
|
4362 return EInconclusive; |
|
4363 } |
|
4364 |
|
4365 |
|
4366 iState=ERecording; |
|
4367 |
|
4368 // start feeding the input stream |
|
4369 StartReadL(); |
|
4370 CIdle* idleStopper = CIdle::NewL(CActive::EPriorityStandard); |
|
4371 idleStopper->Start(TCallBack(stopActiveScheduler)); |
|
4372 CActiveScheduler::Start(); |
|
4373 delete idleStopper; |
|
4374 if (iError != KErrNone) |
|
4375 { |
|
4376 INFO_PRINTF2(_L("DEBUG LEAVE 3: error = %d"),iError); |
|
4377 return EInconclusive; |
|
4378 } |
|
4379 |
|
4380 return verdict; |
|
4381 } |
|
4382 |
|
4383 enum TVerdict CTestStepAudInStreamGetBytes::DoTestStepPostambleL(void) |
|
4384 { |
|
4385 iFile.Close(); |
|
4386 delete iAudInStream; |
|
4387 iAudInStream = NULL; |
|
4388 //[ Destroy the scheduler ] |
|
4389 return CTestMmfAclntStep::DoTestStepPostambleL(); |
|
4390 } |
|
4391 |
|
4392 TVerdict CTestStepAudInStreamGetBytes::DoTestStepL() |
|
4393 { |
|
4394 TInt bytes1 = iAudInStream->GetBytes(); |
|
4395 INFO_PRINTF2(_L("bytes1 = %d"), bytes1); |
|
4396 |
|
4397 CCallBackTimer* callBackTimer = CCallBackTimer::NewL(TCallBack(stopActiveScheduler)); |
|
4398 callBackTimer->After(1000000); |
|
4399 CActiveScheduler::Start(); |
|
4400 callBackTimer->Cancel(); // in case something else stopped the AS |
|
4401 |
|
4402 if (iError != KErrNone) |
|
4403 { |
|
4404 ERR_PRINTF2(_L("First call to GetBytes() returned error %d"), iError); |
|
4405 delete callBackTimer; |
|
4406 return EFail; |
|
4407 } |
|
4408 |
|
4409 TInt bytes2 = iAudInStream->GetBytes(); |
|
4410 INFO_PRINTF2(_L("bytes2 = %d"), bytes2); |
|
4411 |
|
4412 callBackTimer->After(1000000); |
|
4413 CActiveScheduler::Start(); |
|
4414 callBackTimer->Cancel(); |
|
4415 |
|
4416 if (iError != KErrNone) |
|
4417 { |
|
4418 ERR_PRINTF2(_L("Second call to GetBytes() returned error %d"), iError); |
|
4419 delete callBackTimer; |
|
4420 return EFail; |
|
4421 } |
|
4422 |
|
4423 delete callBackTimer; |
|
4424 |
|
4425 //Stop will kick off the write of the data to file through CWriteBufferActive, which will stop |
|
4426 //ActiveSheduler when written |
|
4427 iState=EStopped; //required so that acceptable KErrAbort in MaiscBufferCopied are handled properly |
|
4428 iAudInStream->Stop(); |
|
4429 |
|
4430 // Starting writing out the buffers if we're not already |
|
4431 if(!iWriteBufferActive->IsActive()) |
|
4432 { |
|
4433 iWriteBufferActive->Write(iBufferList[iStartBuf]); |
|
4434 } |
|
4435 |
|
4436 CActiveScheduler::Start(); |
|
4437 |
|
4438 TInt bytes3 = iAudInStream->GetBytes(); |
|
4439 INFO_PRINTF2(_L("bytes3 = %d"), bytes3); |
|
4440 if (iError != KErrNone) |
|
4441 { |
|
4442 ERR_PRINTF2(_L("Third call to GetBytes() returned error %d"), iError); |
|
4443 return EFail; |
|
4444 } |
|
4445 |
|
4446 TInt fileSize; |
|
4447 User::LeaveIfError(iFile.Size(fileSize)); |
|
4448 ERR_PRINTF2(_L("filesize %d"), fileSize); |
|
4449 INFO_PRINTF4(_L("GetBytes returned sizes %d, %d, %d"), bytes1, bytes2, bytes3); |
|
4450 |
|
4451 INFO_PRINTF3(_L("Recording Complete used %d of the %d buffers available"),iBuffersUsed,KRecNumBuffer); |
|
4452 |
|
4453 if (bytes1 > bytes2 || bytes2 > bytes3) |
|
4454 { |
|
4455 return EFail; |
|
4456 } |
|
4457 |
|
4458 |
|
4459 if (bytes3 != fileSize) |
|
4460 { |
|
4461 ERR_PRINTF3(_L("Error : bytes3 %d != filesize %d"), bytes3, fileSize); |
|
4462 return EFail; |
|
4463 } |
|
4464 |
|
4465 INFO_PRINTF1(_L("finished with this test step")); |
|
4466 // test steps return a result |
|
4467 return iTestStepResult; |
|
4468 } |
|
4469 |
|
4470 // |
|
4471 // |
|
4472 // |
|
4473 |
|
4474 CTestStepAudInStreamSglBuf* CTestStepAudInStreamSglBuf::NewL(const TDesC& aTestName) |
|
4475 { |
|
4476 CTestStepAudInStreamSglBuf* self = new(ELeave) CTestStepAudInStreamSglBuf(aTestName); |
|
4477 return self; |
|
4478 } |
|
4479 |
|
4480 CTestStepAudInStreamSglBuf::CTestStepAudInStreamSglBuf(const TDesC& aTestName) |
|
4481 : CTestStepAudInStreamGetBytes(aTestName), |
|
4482 iBufferPtr(NULL, 0) |
|
4483 { |
|
4484 iTestStepResult = EFail; |
|
4485 // store the name of this test case |
|
4486 // this is the name that is used by the script file |
|
4487 iTestStepName = aTestName; |
|
4488 } |
|
4489 |
|
4490 CTestStepAudInStreamSglBuf::~CTestStepAudInStreamSglBuf() |
|
4491 { |
|
4492 } |
|
4493 |
|
4494 /** |
|
4495 * |
|
4496 * Test step Preamble. |
|
4497 * |
|
4498 * @xxxx |
|
4499 * |
|
4500 */ |
|
4501 enum TVerdict CTestStepAudInStreamSglBuf::DoTestStepPreambleL(void) |
|
4502 { |
|
4503 iTestStepResult = EPass; |
|
4504 |
|
4505 // this installs the scheduler |
|
4506 iTestStepResult = CTestStepAudInStream::DoTestStepPreambleL(); |
|
4507 |
|
4508 // Printing to the console and log file |
|
4509 INFO_PRINTF1(_L("this test gets the bytes rendered by the H/W until this moment: GetBytes()")); |
|
4510 |
|
4511 iAudInStream->SetSingleBufferMode(ETrue); |
|
4512 iAudInStream->Open(NULL); |
|
4513 CActiveScheduler::Start(); |
|
4514 |
|
4515 if (iError != KErrNone) |
|
4516 { |
|
4517 INFO_PRINTF2(_L("DEBUG LEAVE 1: error = %d"),iError); |
|
4518 return EInconclusive; |
|
4519 } |
|
4520 |
|
4521 iError = iFile.Replace( iFs, KRecordStreamRawFile, EFileWrite ) ; |
|
4522 if (iError != KErrNone) |
|
4523 { |
|
4524 INFO_PRINTF2(_L("DEBUG LEAVE 2: error = %d"),iError); |
|
4525 return EInconclusive; |
|
4526 } |
|
4527 |
|
4528 iState=ERecording; |
|
4529 |
|
4530 // start feeding the input stream |
|
4531 Read1BufL(); // single buffer |
|
4532 CIdle* idleStopper = CIdle::NewL(CActive::EPriorityStandard); |
|
4533 idleStopper->Start(TCallBack(stopActiveScheduler)); |
|
4534 CActiveScheduler::Start(); |
|
4535 delete idleStopper; |
|
4536 if (iError != KErrNone) |
|
4537 { |
|
4538 INFO_PRINTF2(_L("DEBUG LEAVE 3: error = %d"),iError); |
|
4539 return EInconclusive; |
|
4540 } |
|
4541 |
|
4542 return iTestStepResult; |
|
4543 } |
|
4544 |
|
4545 |
|
4546 void CTestStepAudInStreamSglBuf::Read1BufL() |
|
4547 { |
|
4548 // Issue reads on 1 available buffer |
|
4549 iBufferPtr.Set(const_cast<TUint8*>(iSingleBuffer.Ptr()), 0, iSingleBuffer.MaxLength()); |
|
4550 iAudInStream->ReadL(iBufferPtr); |
|
4551 } |
|
4552 |
|
4553 |
|
4554 void CTestStepAudInStreamSglBuf::MaiscBufferCopied(TInt aError, const TDesC8& aBuffer) |
|
4555 { |
|
4556 CTestStepAudInStreamGetBytes::MaiscBufferCopied(aError, aBuffer); |
|
4557 |
|
4558 TInt lengthRecorded = iSingleBuffer.Length()+aBuffer.Length(); |
|
4559 iSingleBuffer.SetLength(lengthRecorded); |
|
4560 } |
|
4561 |
|
4562 |
|
4563 void CTestStepAudInStreamSglBuf::MaiscRecordComplete(TInt aError) |
|
4564 { |
|
4565 // Starting writing out the buffer if we're not already |
|
4566 if(!iWriteBufferActive->IsActive()) |
|
4567 { |
|
4568 iWriteBufferActive->Write(iSingleBuffer); |
|
4569 } |
|
4570 |
|
4571 CTestStepAudInStreamGetBytes::MaiscRecordComplete(aError); |
|
4572 } |
|
4573 |
|
4574 |
|
4575 TVerdict CTestStepAudInStreamSglBuf::DoTestStepL() |
|
4576 { |
|
4577 TInt bytes1 = iAudInStream->GetBytes(); |
|
4578 INFO_PRINTF2(_L("bytes1 = %d"), bytes1); |
|
4579 |
|
4580 CCallBackTimer* callBackTimer = CCallBackTimer::NewL(TCallBack(stopActiveScheduler)); |
|
4581 callBackTimer->After(1000000); |
|
4582 CActiveScheduler::Start(); |
|
4583 callBackTimer->Cancel(); // in case something else stopped the AS |
|
4584 |
|
4585 if (iError != KErrNone) |
|
4586 { |
|
4587 ERR_PRINTF2(_L("First call to GetBytes() returned error %d"), iError); |
|
4588 delete callBackTimer; |
|
4589 return EFail; |
|
4590 } |
|
4591 |
|
4592 TInt bytes2 = iAudInStream->GetBytes(); |
|
4593 INFO_PRINTF2(_L("bytes2 = %d"), bytes2); |
|
4594 |
|
4595 callBackTimer->After(1000000); |
|
4596 CActiveScheduler::Start(); |
|
4597 callBackTimer->Cancel(); |
|
4598 |
|
4599 if (iError != KErrNone) |
|
4600 { |
|
4601 ERR_PRINTF2(_L("Second call to GetBytes() returned error %d"), iError); |
|
4602 delete callBackTimer; |
|
4603 return EFail; |
|
4604 } |
|
4605 |
|
4606 delete callBackTimer; |
|
4607 |
|
4608 //Stop will kick off the write of the data to file through CWriteBufferActive, which will stop |
|
4609 //ActiveSheduler when written |
|
4610 iState=EStopped; //required so that acceptable KErrAbort in MaiscBufferCopied are handled properly |
|
4611 iAudInStream->Stop(); |
|
4612 |
|
4613 // Starting writing out the buffers if we're not already |
|
4614 if(!iWriteBufferActive->IsActive()) |
|
4615 { |
|
4616 iWriteBufferActive->Write(iSingleBuffer); |
|
4617 } |
|
4618 |
|
4619 CActiveScheduler::Start(); |
|
4620 |
|
4621 TInt bytes3 = iAudInStream->GetBytes(); |
|
4622 INFO_PRINTF2(_L("bytes3 = %d"), bytes3); |
|
4623 if (iError != KErrNone) |
|
4624 { |
|
4625 ERR_PRINTF2(_L("Third call to GetBytes() returned error %d"), iError); |
|
4626 return EFail; |
|
4627 } |
|
4628 |
|
4629 TInt fileSize; |
|
4630 User::LeaveIfError(iFile.Size(fileSize)); |
|
4631 ERR_PRINTF2(_L("filesize %d"), fileSize); |
|
4632 INFO_PRINTF4(_L("GetBytes returned sizes %d, %d, %d"), bytes1, bytes2, bytes3); |
|
4633 |
|
4634 INFO_PRINTF2(_L("Recording Complete using a single buffer of size %d bytes"), KRecBufferSglBufSize); |
|
4635 |
|
4636 if (bytes1 > bytes2 || bytes2 > bytes3) |
|
4637 { |
|
4638 return EFail; |
|
4639 } |
|
4640 |
|
4641 if (bytes3 != fileSize) |
|
4642 { |
|
4643 ERR_PRINTF3(_L("Error : bytes3 %d != filesize %d"), bytes3, fileSize); |
|
4644 return EFail; |
|
4645 } |
|
4646 |
|
4647 INFO_PRINTF1(_L("finished with this test step")); |
|
4648 // test steps return a result |
|
4649 return iTestStepResult; |
|
4650 } |
|
4651 |
|
4652 |
|
4653 void CTestStepAudInStreamSglBuf::ProcessDataL() |
|
4654 { |
|
4655 // wait for more recorded data to come through |
|
4656 CActiveScheduler::Stop(); |
|
4657 } |
|
4658 |
|
4659 // |
|
4660 // |
|
4661 // |
|
4662 |
|
4663 CTestStepAudInStreamSetProp* CTestStepAudInStreamSetProp::NewL(const TDesC& aTestName) |
|
4664 { |
|
4665 CTestStepAudInStreamSetProp* self = new(ELeave) CTestStepAudInStreamSetProp(aTestName); |
|
4666 return self; |
|
4667 } |
|
4668 |
|
4669 CTestStepAudInStreamSetProp::CTestStepAudInStreamSetProp(const TDesC& aTestName) |
|
4670 { |
|
4671 iTestStepResult = EPass; |
|
4672 // store the name of this test case |
|
4673 // this is the name that is used by the script file |
|
4674 iTestStepName = aTestName; |
|
4675 } |
|
4676 |
|
4677 CTestStepAudInStreamSetProp::~CTestStepAudInStreamSetProp() |
|
4678 { |
|
4679 } |
|
4680 |
|
4681 void CTestStepAudInStreamSetProp::MaiscOpenComplete(TInt aError) |
|
4682 { |
|
4683 iError = aError; |
|
4684 } |
|
4685 void CTestStepAudInStreamSetProp::MaiscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/) |
|
4686 { |
|
4687 iError = aError; |
|
4688 } |
|
4689 void CTestStepAudInStreamSetProp::MaiscRecordComplete(TInt aError) |
|
4690 { |
|
4691 iError = aError; |
|
4692 } |
|
4693 |
|
4694 enum TVerdict CTestStepAudInStreamSetProp::DoTestStepPreambleL(void) |
|
4695 { |
|
4696 enum TVerdict verdict; |
|
4697 // this installs the scheduler |
|
4698 verdict = CTestMmfAclntStep::DoTestStepPreambleL(); |
|
4699 |
|
4700 TInt err = KErrNone; |
|
4701 TRAP(err, iAudInStream = CMdaAudioInputStream::NewL(*this)); |
|
4702 if (err != KErrNone || iAudInStream == NULL ) |
|
4703 { |
|
4704 return EInconclusive; |
|
4705 } |
|
4706 |
|
4707 return verdict; |
|
4708 } |
|
4709 |
|
4710 enum TVerdict CTestStepAudInStreamSetProp::DoTestStepPostambleL(void) |
|
4711 { |
|
4712 delete iAudInStream; |
|
4713 iAudInStream = NULL; |
|
4714 //[ Destroy the scheduler ] |
|
4715 return CTestMmfAclntStep::DoTestStepPostambleL(); |
|
4716 } |
|
4717 |
|
4718 TVerdict CTestStepAudInStreamSetProp::DoTestStepL() |
|
4719 { |
|
4720 INFO_PRINTF1( _L("TestAudioInputStream : SetAudioProperties")); |
|
4721 iTestStepResult = EPass; |
|
4722 TInt err = KErrNone; |
|
4723 |
|
4724 // test 1 |
|
4725 TRAP(err, iAudInStream->SetAudioPropertiesL(TMdaAudioDataSettings::ESampleRate8000Hz,TMdaAudioDataSettings::EChannelsMono) ); |
|
4726 |
|
4727 if (!(err == KErrNone || |
|
4728 err == KErrNotSupported) ) |
|
4729 { |
|
4730 return EFail; |
|
4731 } |
|
4732 |
|
4733 |
|
4734 // test2 |
|
4735 TRAP(err, iAudInStream->SetAudioPropertiesL(TMdaAudioDataSettings::ESampleRate44100Hz,TMdaAudioDataSettings::EChannelsStereo) ); |
|
4736 |
|
4737 if (!(err == KErrNone || |
|
4738 err == KErrNotSupported) ) |
|
4739 { |
|
4740 return EFail; |
|
4741 } |
|
4742 |
|
4743 |
|
4744 INFO_PRINTF1(_L("finished with this test step")); |
|
4745 // test steps return a result |
|
4746 return iTestStepResult; |
|
4747 } |
|
4748 |
|
4749 |
|
4750 |
|
4751 // |
|
4752 // |
|
4753 // CMdaAudioOutputStream Integration Tests // |
|
4754 // |
|
4755 // |
|
4756 |
|
4757 // base class for some audio Ouput stream tests |
|
4758 CTestStepAudOutStream* CTestStepAudOutStream::NewL() |
|
4759 { |
|
4760 CTestStepAudOutStream* s = new(ELeave) CTestStepAudOutStream(); |
|
4761 CleanupStack::PushL(s); |
|
4762 s->ConstructL(); |
|
4763 CleanupStack::Pop(); |
|
4764 return s; |
|
4765 } |
|
4766 |
|
4767 CTestStepAudOutStream::CTestStepAudOutStream() : iError(KErrNone) |
|
4768 { |
|
4769 iIsAllDataRead = EFalse; |
|
4770 iIsAllDataWritten = EFalse; |
|
4771 } |
|
4772 |
|
4773 void CTestStepAudOutStream::ConstructL() |
|
4774 { |
|
4775 // reset the buffer |
|
4776 for(TInt i=0; i<KNumBuffer; i++) |
|
4777 { |
|
4778 iBufferList[i] = KNullDesC8; |
|
4779 } |
|
4780 iStartBuf=iEndBuf=0; |
|
4781 } |
|
4782 |
|
4783 CTestStepAudOutStream::~CTestStepAudOutStream() |
|
4784 { |
|
4785 } |
|
4786 |
|
4787 void CTestStepAudOutStream::MaoscOpenComplete(TInt aError) |
|
4788 { |
|
4789 iError = aError; |
|
4790 CActiveScheduler::Stop(); |
|
4791 } |
|
4792 |
|
4793 void CTestStepAudOutStream::MaoscPlayComplete(TInt aError) |
|
4794 { |
|
4795 if (iIsAllDataWritten && (aError == KErrNone || aError == KErrUnderflow)) |
|
4796 { |
|
4797 iError = KErrNone; |
|
4798 } |
|
4799 |
|
4800 else |
|
4801 iError = aError; |
|
4802 |
|
4803 iReadBufferActive->Cancel(); |
|
4804 TInt filePosition=0; |
|
4805 iFile.Seek(ESeekStart, filePosition); |
|
4806 iFile.Close(); |
|
4807 CActiveScheduler::Stop(); |
|
4808 } |
|
4809 |
|
4810 void CTestStepAudOutStream::MaoscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/) |
|
4811 { |
|
4812 iError = aError; |
|
4813 if(aError) |
|
4814 { |
|
4815 //need add for deal with exception |
|
4816 return; |
|
4817 } |
|
4818 |
|
4819 |
|
4820 // adjust the buffer |
|
4821 iBufferList[iStartBuf] = KNullDesC8; |
|
4822 if(iStartBuf==KNumBuffer-1) |
|
4823 iStartBuf = 0; |
|
4824 else |
|
4825 iStartBuf++; |
|
4826 |
|
4827 if (iIsAllDataRead && iStartBuf == iEndBuf) |
|
4828 { |
|
4829 iIsAllDataWritten = ETrue; |
|
4830 } |
|
4831 else if(!iReadBufferActive->IsActive()) |
|
4832 iReadBufferActive->Read(); |
|
4833 } |
|
4834 |
|
4835 |
|
4836 CTestStepAudOutStream::CReadBufferActive::CReadBufferActive() : CActive(0) |
|
4837 { |
|
4838 CActiveScheduler::Add(this); |
|
4839 } |
|
4840 |
|
4841 CTestStepAudOutStream::CReadBufferActive::~CReadBufferActive() |
|
4842 { |
|
4843 Cancel(); |
|
4844 } |
|
4845 |
|
4846 void CTestStepAudOutStream::CReadBufferActive::RunL() |
|
4847 { |
|
4848 iParent->ProcessDataL(iBuffer); |
|
4849 } |
|
4850 |
|
4851 TInt CTestStepAudOutStream::CReadBufferActive::RunError(TInt aError) |
|
4852 { |
|
4853 iParent->iError = aError; |
|
4854 CActiveScheduler::Stop(); |
|
4855 |
|
4856 return KErrNone; |
|
4857 } |
|
4858 |
|
4859 void CTestStepAudOutStream::CReadBufferActive::DoCancel() |
|
4860 { |
|
4861 // do nothing |
|
4862 } |
|
4863 |
|
4864 void CTestStepAudOutStream::CReadBufferActive::Read() |
|
4865 { |
|
4866 iParent->iFile.Read(iBuffer, iStatus); // read the 1st data trunk |
|
4867 SetActive(); |
|
4868 } |
|
4869 |
|
4870 |
|
4871 void CTestStepAudOutStream::ProcessDataL(TBuf8<KBufferSize>& aData) |
|
4872 { |
|
4873 if(aData.Length()) |
|
4874 { |
|
4875 if(iBufferList[iEndBuf]==KNullDesC8) |
|
4876 { |
|
4877 iBufferList[iEndBuf] = aData; |
|
4878 iAudOutStream->WriteL(iBufferList[iEndBuf]); |
|
4879 |
|
4880 // adjust the buffer |
|
4881 if(iEndBuf==KNumBuffer-1) |
|
4882 { |
|
4883 iEndBuf=0; |
|
4884 } |
|
4885 |
|
4886 else |
|
4887 { |
|
4888 iEndBuf++; |
|
4889 } |
|
4890 } |
|
4891 |
|
4892 if(iBufferList[iEndBuf]==KNullDesC8) |
|
4893 { |
|
4894 iReadBufferActive->Read(); |
|
4895 } |
|
4896 // else all our buffers are full |
|
4897 } |
|
4898 else |
|
4899 iIsAllDataRead = ETrue; |
|
4900 } |
|
4901 |
|
4902 /** |
|
4903 * |
|
4904 * Test step Preamble. |
|
4905 * |
|
4906 * @xxxx |
|
4907 * |
|
4908 */ |
|
4909 enum TVerdict CTestStepAudOutStream::DoTestStepPreambleL(void) |
|
4910 { |
|
4911 enum TVerdict verdict; |
|
4912 |
|
4913 // reset the buffer [incase new test reuses previous object] |
|
4914 for(TInt i=0; i<KNumBuffer; i++) |
|
4915 { |
|
4916 iBufferList[i] = KNullDesC8; |
|
4917 } |
|
4918 iStartBuf=iEndBuf=0; |
|
4919 |
|
4920 // this installs the scheduler |
|
4921 verdict = CTestMmfAclntStep::DoTestStepPreambleL(); |
|
4922 |
|
4923 // create the active object |
|
4924 iReadBufferActive = new(ELeave) CReadBufferActive(); |
|
4925 iReadBufferActive->iParent = this; |
|
4926 iFs.Connect(); |
|
4927 |
|
4928 TRAPD(err, iAudOutStream = CMdaAudioOutputStream::NewL(*this) ); |
|
4929 |
|
4930 if (err != KErrNone || |
|
4931 iAudOutStream == NULL ) |
|
4932 { |
|
4933 return EInconclusive; |
|
4934 } |
|
4935 |
|
4936 return verdict; |
|
4937 } |
|
4938 |
|
4939 /** |
|
4940 * |
|
4941 * Test step Postamble. |
|
4942 * |
|
4943 * @xxxx |
|
4944 * |
|
4945 */ |
|
4946 enum TVerdict CTestStepAudOutStream::DoTestStepPostambleL(void) |
|
4947 { |
|
4948 iFs.Close(); |
|
4949 |
|
4950 delete iAudOutStream; |
|
4951 iAudOutStream = NULL; |
|
4952 delete iReadBufferActive; |
|
4953 iReadBufferActive = NULL; |
|
4954 //[ Destroy the scheduler ] |
|
4955 return CTestMmfAclntStep::DoTestStepPostambleL(); |
|
4956 } |
|
4957 |
|
4958 /** |
|
4959 * |
|
4960 * Do the test step. |
|
4961 * Each test step must supply an implementation for DoTestStepL. |
|
4962 * |
|
4963 * @return "TVerdict" |
|
4964 * The result of the test step |
|
4965 * |
|
4966 * @xxxx |
|
4967 * |
|
4968 */ |
|
4969 TVerdict CTestStepAudOutStream::DoTestStepL() |
|
4970 { |
|
4971 iTestStepResult = EPass; |
|
4972 //TInt err = KErrNone; |
|
4973 |
|
4974 iAudOutStream->Open(NULL); |
|
4975 CActiveScheduler::Start(); |
|
4976 iAudOutStream->SetVolume(iAudOutStream->MaxVolume()>>1); // half volume |
|
4977 |
|
4978 if (iError != KErrNone ) |
|
4979 { |
|
4980 return EFail; |
|
4981 } |
|
4982 |
|
4983 |
|
4984 TInt err = KErrNone; |
|
4985 err = iFile.Open(iFs, KStreamRawFile, EFileRead); |
|
4986 if (err != KErrNone) |
|
4987 { |
|
4988 return EFail; |
|
4989 } |
|
4990 |
|
4991 iReadBufferActive->Read(); |
|
4992 CActiveScheduler::Start(); |
|
4993 |
|
4994 // wait sometime to finish and then close the file |
|
4995 User::After(1200000); |
|
4996 iFile.Close(); |
|
4997 |
|
4998 INFO_PRINTF1(_L("finished with this test step")); |
|
4999 // test steps return a result |
|
5000 return iTestStepResult; |
|
5001 } |
|
5002 |
|
5003 |
|
5004 |
|
5005 |
|
5006 |
|
5007 |
|
5008 CTestStepAudOutStreamSetProp* CTestStepAudOutStreamSetProp::NewL(const TDesC& aTestName) |
|
5009 { |
|
5010 CTestStepAudOutStreamSetProp* self = new(ELeave) CTestStepAudOutStreamSetProp(aTestName); |
|
5011 return self; |
|
5012 } |
|
5013 |
|
5014 CTestStepAudOutStreamSetProp::CTestStepAudOutStreamSetProp(const TDesC& aTestName) |
|
5015 { |
|
5016 iTestStepResult = EPass; |
|
5017 // store the name of this test case |
|
5018 // this is the name that is used by the script file |
|
5019 iTestStepName = aTestName; |
|
5020 } |
|
5021 |
|
5022 CTestStepAudOutStreamSetProp::~CTestStepAudOutStreamSetProp() |
|
5023 { |
|
5024 } |
|
5025 |
|
5026 enum TVerdict CTestStepAudOutStreamSetProp::DoTestStepPreambleL(void) |
|
5027 { |
|
5028 enum TVerdict verdict; |
|
5029 // this installs the scheduler |
|
5030 verdict = CTestStepAudOutStream::DoTestStepPreambleL(); |
|
5031 |
|
5032 // if the parent preamble fails, we must fail too |
|
5033 if (verdict != EPass) |
|
5034 { |
|
5035 return verdict; |
|
5036 } |
|
5037 |
|
5038 // Printing to the console and log file |
|
5039 INFO_PRINTF1(_L("this test is setting the audio properties of an Audio Output Stream Utility Class")); |
|
5040 |
|
5041 iAudOutStream->Open(NULL); |
|
5042 CActiveScheduler::Start(); |
|
5043 |
|
5044 return verdict; |
|
5045 } |
|
5046 |
|
5047 TVerdict CTestStepAudOutStreamSetProp::DoTestStepL() |
|
5048 { |
|
5049 TInt err = KErrNone; |
|
5050 |
|
5051 // test 1 |
|
5052 TRAP(err, iAudOutStream->SetAudioPropertiesL(TMdaAudioDataSettings::ESampleRate8000Hz,TMdaAudioDataSettings::EChannelsMono) ); |
|
5053 if (!(err == KErrNone || |
|
5054 err == KErrNotSupported) ) |
|
5055 { |
|
5056 return EFail; |
|
5057 } |
|
5058 |
|
5059 |
|
5060 // test2 |
|
5061 // fails with the enum values, correct? |
|
5062 TRAP(err, iAudOutStream->SetAudioPropertiesL(TMdaAudioDataSettings::ESampleRate44100Hz,TMdaAudioDataSettings::EChannelsStereo) ); |
|
5063 |
|
5064 if (!(err == KErrNone || |
|
5065 err == KErrNotSupported) ) |
|
5066 { |
|
5067 return EFail; |
|
5068 } |
|
5069 |
|
5070 else |
|
5071 return EPass; |
|
5072 } |
|
5073 |
|
5074 |
|
5075 |
|
5076 |
|
5077 |
|
5078 |
|
5079 |
|
5080 CTestStepAudOutStreamOpen* CTestStepAudOutStreamOpen::NewL(const TDesC& aTestName) |
|
5081 { |
|
5082 CTestStepAudOutStreamOpen* self = new(ELeave) CTestStepAudOutStreamOpen(aTestName); |
|
5083 return self; |
|
5084 } |
|
5085 |
|
5086 CTestStepAudOutStreamOpen::CTestStepAudOutStreamOpen(const TDesC& aTestName) |
|
5087 { |
|
5088 iTestStepResult = EPass; |
|
5089 // store the name of this test case |
|
5090 // this is the name that is used by the script file |
|
5091 iTestStepName = aTestName; |
|
5092 } |
|
5093 |
|
5094 enum TVerdict CTestStepAudOutStreamOpen::DoTestStepPreambleL(void) |
|
5095 { |
|
5096 enum TVerdict verdict; |
|
5097 // this installs the scheduler and initialises the iAudOutStream |
|
5098 verdict = CTestStepAudOutStream::DoTestStepPreambleL(); |
|
5099 INFO_PRINTF1(_L("this test is openning an Audio Output Stream Utility Class")); |
|
5100 return verdict; |
|
5101 } |
|
5102 |
|
5103 TVerdict CTestStepAudOutStreamOpen::DoTestStepL() |
|
5104 { |
|
5105 TInt err = KErrNone; |
|
5106 |
|
5107 TMdaAudioDataSettings settings; |
|
5108 settings.Query(); |
|
5109 settings.iSampleRate = TMdaAudioDataSettings::ESampleRate8000Hz; // ESampleRateAnyInRange |
|
5110 settings.iChannels = TMdaAudioDataSettings::EChannelsStereo; |
|
5111 settings.iFlags = TMdaAudioDataSettings::ENoNetworkRouting; |
|
5112 settings.iVolume = 0; |
|
5113 |
|
5114 iAudOutStream->Open(&settings); |
|
5115 CActiveScheduler::Start(); |
|
5116 |
|
5117 if (iAudOutStream == NULL) |
|
5118 { |
|
5119 err = KErrNotReady; |
|
5120 } |
|
5121 |
|
5122 if (iError != KErrNone || |
|
5123 err != KErrNone) |
|
5124 { |
|
5125 return EFail; |
|
5126 } |
|
5127 |
|
5128 else |
|
5129 { |
|
5130 return EPass; |
|
5131 } |
|
5132 } |
|
5133 |
|
5134 |
|
5135 |
|
5136 CTestStepAudOutStreamSetVol* CTestStepAudOutStreamSetVol::NewL(const TDesC& aTestName) |
|
5137 { |
|
5138 CTestStepAudOutStreamSetVol* self = new(ELeave) CTestStepAudOutStreamSetVol(aTestName); |
|
5139 return self; |
|
5140 } |
|
5141 |
|
5142 CTestStepAudOutStreamSetVol::CTestStepAudOutStreamSetVol(const TDesC& aTestName) |
|
5143 { |
|
5144 iTestStepResult = EPass; |
|
5145 // store the name of this test case |
|
5146 // this is the name that is used by the script file |
|
5147 iTestStepName = aTestName; |
|
5148 } |
|
5149 |
|
5150 CTestStepAudOutStreamSetVol::~CTestStepAudOutStreamSetVol() |
|
5151 { |
|
5152 } |
|
5153 |
|
5154 /** |
|
5155 * Implementation of the MMdaAudioOuputStreamCallback interface functions |
|
5156 **/ |
|
5157 void CTestStepAudOutStreamSetVol::MaoscOpenComplete(TInt /*aError*/) |
|
5158 { |
|
5159 } |
|
5160 void CTestStepAudOutStreamSetVol::MaoscBufferCopied(TInt /*aError*/, const TDesC8& /*aBuffer*/) |
|
5161 { |
|
5162 } |
|
5163 void CTestStepAudOutStreamSetVol::MaoscPlayComplete(TInt /*aError*/) |
|
5164 { |
|
5165 } |
|
5166 |
|
5167 enum TVerdict CTestStepAudOutStreamSetVol::DoTestStepPreambleL(void) |
|
5168 { |
|
5169 enum TVerdict verdict; |
|
5170 // this installs the scheduler |
|
5171 verdict = CTestMmfAclntStep::DoTestStepPreambleL(); |
|
5172 // Printing to the console and log file |
|
5173 INFO_PRINTF1(_L("this test is setting the volume of an Audio Output Stream Utility Class")); |
|
5174 |
|
5175 TRAPD(err, iAudOutStream = CMdaAudioOutputStream::NewL(*this) ); |
|
5176 |
|
5177 if (err != KErrNone || |
|
5178 iAudOutStream == NULL) |
|
5179 { |
|
5180 return EInconclusive; |
|
5181 } |
|
5182 |
|
5183 return verdict; |
|
5184 } |
|
5185 |
|
5186 enum TVerdict CTestStepAudOutStreamSetVol::DoTestStepPostambleL(void) |
|
5187 { |
|
5188 delete iAudOutStream; |
|
5189 iAudOutStream = NULL; |
|
5190 //[ Destroy the scheduler ] |
|
5191 return CTestMmfAclntStep::DoTestStepPostambleL(); |
|
5192 } |
|
5193 |
|
5194 |
|
5195 TVerdict CTestStepAudOutStreamSetVol::DoTestStepL() |
|
5196 { |
|
5197 TInt vol = iAudOutStream->MaxVolume()/2; |
|
5198 if (vol < 0) |
|
5199 { |
|
5200 return EFail; |
|
5201 } |
|
5202 |
|
5203 //set the volume |
|
5204 iAudOutStream->SetVolume(vol); |
|
5205 |
|
5206 //get the volume |
|
5207 TInt rvol = iAudOutStream->Volume(); |
|
5208 if (vol != rvol ) |
|
5209 { |
|
5210 return EFail; |
|
5211 } |
|
5212 |
|
5213 else |
|
5214 { |
|
5215 iTestStepResult = EPass; |
|
5216 } |
|
5217 |
|
5218 INFO_PRINTF1(_L("finished with this test step")); |
|
5219 // test steps return a result |
|
5220 return iTestStepResult; |
|
5221 } |
|
5222 |
|
5223 |
|
5224 |
|
5225 |
|
5226 CTestStepAudOutStreamSetBalance* CTestStepAudOutStreamSetBalance::NewL(const TDesC& aTestName) |
|
5227 { |
|
5228 CTestStepAudOutStreamSetBalance* self = new(ELeave) CTestStepAudOutStreamSetBalance(aTestName); |
|
5229 return self; |
|
5230 } |
|
5231 |
|
5232 CTestStepAudOutStreamSetBalance::CTestStepAudOutStreamSetBalance(const TDesC& aTestName) |
|
5233 { |
|
5234 iTestStepResult = EPass; |
|
5235 // store the name of this test case |
|
5236 // this is the name that is used by the script file |
|
5237 iTestStepName = aTestName; |
|
5238 } |
|
5239 |
|
5240 |
|
5241 CTestStepAudOutStreamSetBalance::~CTestStepAudOutStreamSetBalance() |
|
5242 { |
|
5243 } |
|
5244 |
|
5245 void CTestStepAudOutStreamSetBalance::MaoscOpenComplete(TInt /*aError*/) |
|
5246 { |
|
5247 } |
|
5248 void CTestStepAudOutStreamSetBalance::MaoscBufferCopied(TInt /*aError*/, const TDesC8& /*aBuffer*/) |
|
5249 { |
|
5250 } |
|
5251 void CTestStepAudOutStreamSetBalance::MaoscPlayComplete(TInt /*aError*/) |
|
5252 { |
|
5253 } |
|
5254 |
|
5255 enum TVerdict CTestStepAudOutStreamSetBalance::DoTestStepPreambleL(void) |
|
5256 { |
|
5257 enum TVerdict verdict; |
|
5258 // this installs the scheduler |
|
5259 verdict = CTestMmfAclntStep::DoTestStepPreambleL(); |
|
5260 |
|
5261 // Printing to the console and log file |
|
5262 INFO_PRINTF1(_L("this test is setting and getting the balance of an Audio Output Stream Utility Class")); |
|
5263 |
|
5264 TRAPD(err, iAudOutStream = CMdaAudioOutputStream::NewL(*this) ); |
|
5265 |
|
5266 if (err != KErrNone || |
|
5267 iAudOutStream == NULL ) |
|
5268 { |
|
5269 return EInconclusive; |
|
5270 } |
|
5271 |
|
5272 |
|
5273 return verdict; |
|
5274 } |
|
5275 |
|
5276 enum TVerdict CTestStepAudOutStreamSetBalance::DoTestStepPostambleL(void) |
|
5277 { |
|
5278 delete iAudOutStream; |
|
5279 iAudOutStream = NULL; |
|
5280 |
|
5281 //[ Destroy the scheduler ] |
|
5282 return CTestMmfAclntStep::DoTestStepPostambleL(); |
|
5283 } |
|
5284 |
|
5285 |
|
5286 TVerdict CTestStepAudOutStreamSetBalance::DoTestStepL() |
|
5287 { |
|
5288 TInt bal = 0; |
|
5289 |
|
5290 TRAPD(err, iAudOutStream->SetBalanceL()); // default KMMFBalanceCenter |
|
5291 if (err != KErrNone) |
|
5292 { |
|
5293 return EFail; // we expect this _will_ be supported for Typhoon |
|
5294 } |
|
5295 |
|
5296 //get the balance |
|
5297 TRAP(err, bal = iAudOutStream->GetBalanceL()); |
|
5298 if (err != KErrNone) |
|
5299 { |
|
5300 return EFail; // we expect this _will_ be supported for Typhoon |
|
5301 } |
|
5302 |
|
5303 if (bal != KMMFBalanceCenter) |
|
5304 { |
|
5305 return EFail; |
|
5306 } |
|
5307 |
|
5308 TRAP(err, iAudOutStream->SetBalanceL(KMMFBalanceMaxRight)); |
|
5309 if (err != KErrNone) |
|
5310 { |
|
5311 return EFail; // we expect this _will_ be supported for Typhoon |
|
5312 } |
|
5313 |
|
5314 //get the balance |
|
5315 TRAP(err, bal = iAudOutStream->GetBalanceL()); |
|
5316 if (err != KErrNone) |
|
5317 { |
|
5318 return EFail; // we expect this _will_ be supported for Typhoon |
|
5319 } |
|
5320 |
|
5321 if (bal != KMMFBalanceMaxRight) |
|
5322 { |
|
5323 return EFail; |
|
5324 } |
|
5325 |
|
5326 TRAP(err, iAudOutStream->SetBalanceL(KMMFBalanceMaxLeft)); |
|
5327 if (err != KErrNone) |
|
5328 { |
|
5329 return EFail; // we expect this _will_ be supported for Typhoon |
|
5330 } |
|
5331 |
|
5332 //get the balance |
|
5333 TRAP(err, bal = iAudOutStream->GetBalanceL()); |
|
5334 if (err != KErrNone) |
|
5335 { |
|
5336 return EFail; // we expect this _will_ be supported for Typhoon |
|
5337 } |
|
5338 |
|
5339 if (bal != KMMFBalanceMaxLeft) |
|
5340 { |
|
5341 return EFail; |
|
5342 } |
|
5343 |
|
5344 INFO_PRINTF1(_L("finished with this test step")); |
|
5345 // test steps return a result |
|
5346 return iTestStepResult; |
|
5347 } |
|
5348 |
|
5349 |
|
5350 |
|
5351 |
|
5352 |
|
5353 |
|
5354 CTestStepAudOutStreamSetPrior* CTestStepAudOutStreamSetPrior::NewL(const TDesC& aTestName) |
|
5355 { |
|
5356 CTestStepAudOutStreamSetPrior* self = new(ELeave) CTestStepAudOutStreamSetPrior(aTestName); |
|
5357 return self; |
|
5358 } |
|
5359 |
|
5360 CTestStepAudOutStreamSetPrior::CTestStepAudOutStreamSetPrior(const TDesC& aTestName) |
|
5361 { |
|
5362 iTestStepResult = EPass; |
|
5363 // store the name of this test case |
|
5364 // this is the name that is used by the script file |
|
5365 iTestStepName = aTestName; |
|
5366 } |
|
5367 |
|
5368 CTestStepAudOutStreamSetPrior::~CTestStepAudOutStreamSetPrior() |
|
5369 { |
|
5370 } |
|
5371 |
|
5372 enum TVerdict CTestStepAudOutStreamSetPrior::DoTestStepPreambleL(void) |
|
5373 { |
|
5374 enum TVerdict verdict; |
|
5375 // this installs the scheduler |
|
5376 verdict = CTestStepAudOutStream::DoTestStepPreambleL(); |
|
5377 // Printing to the console and log file |
|
5378 INFO_PRINTF1(_L("this test is setting the audio priorities of an Audio Output Stream Utility Class")); |
|
5379 |
|
5380 // if the parent preamble fails, we must fail too |
|
5381 if (verdict != EPass) |
|
5382 { |
|
5383 return verdict; |
|
5384 } |
|
5385 |
|
5386 iAudOutStream->Open(NULL); |
|
5387 CActiveScheduler::Start(); |
|
5388 |
|
5389 TInt err = KErrNone; |
|
5390 if(iAudOutStream==NULL) |
|
5391 { |
|
5392 err = KErrNotReady; |
|
5393 } |
|
5394 |
|
5395 if (iError != KErrNone || |
|
5396 err != KErrNone) |
|
5397 { |
|
5398 return EInconclusive; |
|
5399 } |
|
5400 |
|
5401 |
|
5402 return verdict; |
|
5403 } |
|
5404 |
|
5405 enum TVerdict CTestStepAudOutStreamSetPrior::DoTestStepPostambleL(void) |
|
5406 { |
|
5407 //[ Destroy the scheduler ] |
|
5408 return CTestStepAudOutStream::DoTestStepPostambleL(); |
|
5409 } |
|
5410 |
|
5411 TVerdict CTestStepAudOutStreamSetPrior::DoTestStepL() |
|
5412 { |
|
5413 // test 1 |
|
5414 iAudOutStream->SetPriority(EMdaPriorityMin, EMdaPriorityPreferenceTime); |
|
5415 |
|
5416 // test2 |
|
5417 iAudOutStream->SetPriority(EMdaPriorityMax, EMdaPriorityPreferenceQuality); |
|
5418 |
|
5419 INFO_PRINTF1(_L("finished with this test step")); |
|
5420 // test steps return a result |
|
5421 return iTestStepResult; |
|
5422 } |
|
5423 |
|
5424 |
|
5425 |
|
5426 |
|
5427 |
|
5428 CTestStepAudOutStreamStop* CTestStepAudOutStreamStop::NewL(const TDesC& aTestName) |
|
5429 { |
|
5430 CTestStepAudOutStreamStop* self = new(ELeave) CTestStepAudOutStreamStop(aTestName); |
|
5431 return self; |
|
5432 } |
|
5433 |
|
5434 CTestStepAudOutStreamStop::CTestStepAudOutStreamStop(const TDesC& aTestName) |
|
5435 { |
|
5436 iTestStepResult = EPass; |
|
5437 // store the name of this test case |
|
5438 // this is the name that is used by the script file |
|
5439 iTestStepName = aTestName; |
|
5440 } |
|
5441 |
|
5442 CTestStepAudOutStreamStop::~CTestStepAudOutStreamStop() |
|
5443 { |
|
5444 } |
|
5445 |
|
5446 enum TVerdict CTestStepAudOutStreamStop::DoTestStepPreambleL(void) |
|
5447 { |
|
5448 iTestStepResult = EPass; |
|
5449 enum TVerdict verdict; |
|
5450 // this installs the scheduler |
|
5451 verdict = CTestStepAudOutStream::DoTestStepPreambleL(); |
|
5452 |
|
5453 // if the parent preamble fails, we must fail too |
|
5454 if (verdict != EPass) |
|
5455 { |
|
5456 return verdict; |
|
5457 } |
|
5458 |
|
5459 // Printing to the console and log file |
|
5460 INFO_PRINTF1(_L("this test is stopping a playing Audio Output Stream Utility Class: Stop()")); |
|
5461 |
|
5462 iAudOutStream->Open(NULL); |
|
5463 CActiveScheduler::Start(); |
|
5464 iAudOutStream->SetVolume(iAudOutStream->MaxVolume()>>1); // half volume |
|
5465 |
|
5466 |
|
5467 TInt err = KErrNone; |
|
5468 if(iAudOutStream==NULL) |
|
5469 { |
|
5470 err=KErrNotReady; |
|
5471 } |
|
5472 |
|
5473 if (iError != KErrNone || |
|
5474 err != KErrNone) |
|
5475 { |
|
5476 return EInconclusive; |
|
5477 } |
|
5478 |
|
5479 err = iFile.Open(iFs, KStreamRawFile, EFileRead); |
|
5480 if (err != KErrNone) |
|
5481 { |
|
5482 return EInconclusive; |
|
5483 } |
|
5484 |
|
5485 // start feeding the outputStream |
|
5486 iReadBufferActive->Read(); // finally calls CMdaAudioOutputStream::WriteL(...) |
|
5487 CIdle* idleStopper = CIdle::NewL(CActive::EPriorityStandard); |
|
5488 idleStopper->Start(TCallBack(stopActiveScheduler)); |
|
5489 CActiveScheduler::Start(); |
|
5490 delete idleStopper; |
|
5491 |
|
5492 if(iAudOutStream==NULL) |
|
5493 { |
|
5494 err = KErrNotReady; |
|
5495 } |
|
5496 |
|
5497 if (err != KErrNone) |
|
5498 { |
|
5499 return EInconclusive; |
|
5500 } |
|
5501 |
|
5502 return verdict; |
|
5503 } |
|
5504 |
|
5505 enum TVerdict CTestStepAudOutStreamStop::DoTestStepPostambleL(void) |
|
5506 { |
|
5507 iFile.Close(); |
|
5508 |
|
5509 //[ Destroy the scheduler, delete the iAudOutStream, close the file system |
|
5510 return CTestStepAudOutStream::DoTestStepPostambleL(); |
|
5511 } |
|
5512 |
|
5513 TInt StopAudOutStream(TAny* aAudOutStream) |
|
5514 { |
|
5515 REINTERPRET_CAST(CMdaAudioOutputStream*, aAudOutStream)->Stop(); |
|
5516 return FALSE; |
|
5517 } |
|
5518 |
|
5519 |
|
5520 TVerdict CTestStepAudOutStreamStop::DoTestStepL() |
|
5521 { |
|
5522 TInt err = KErrNone; |
|
5523 // stream is playing now from preamble |
|
5524 // wait a fraction of the stream duration before stopping |
|
5525 CCallBackTimer* callBackTimer = CCallBackTimer::NewL(TCallBack(StopAudOutStream, iAudOutStream)); |
|
5526 callBackTimer->After(1000000); |
|
5527 CActiveScheduler::Start(); |
|
5528 |
|
5529 if(iAudOutStream==NULL) |
|
5530 { |
|
5531 err=KErrNotReady; |
|
5532 } |
|
5533 |
|
5534 if (iError != KErrCancel || // KErrAbort(?KErrCancel seems to be what is returned) is supposed to be returned ny the MaoscBufferCopied |
|
5535 err != KErrNone) |
|
5536 { |
|
5537 INFO_PRINTF2(_L("Test failed with error %d"), iError); |
|
5538 return EFail; |
|
5539 } |
|
5540 |
|
5541 INFO_PRINTF1(_L("finished with this test step")); |
|
5542 // test steps return a result |
|
5543 return iTestStepResult; |
|
5544 } |
|
5545 |
|
5546 |
|
5547 |
|
5548 |
|
5549 |
|
5550 CTestStepAudOutStreamPosition* CTestStepAudOutStreamPosition::NewL(const TDesC& aTestName) |
|
5551 { |
|
5552 CTestStepAudOutStreamPosition* self = new(ELeave) CTestStepAudOutStreamPosition(aTestName); |
|
5553 return self; |
|
5554 } |
|
5555 |
|
5556 CTestStepAudOutStreamPosition::CTestStepAudOutStreamPosition(const TDesC& aTestName) |
|
5557 { |
|
5558 iTestStepResult = EPass; |
|
5559 // store the name of this test case |
|
5560 // this is the name that is used by the script file |
|
5561 iTestStepName = aTestName; |
|
5562 } |
|
5563 |
|
5564 CTestStepAudOutStreamPosition::~CTestStepAudOutStreamPosition() |
|
5565 { |
|
5566 } |
|
5567 |
|
5568 enum TVerdict CTestStepAudOutStreamPosition::DoTestStepPreambleL(void) |
|
5569 { |
|
5570 iTestStepResult = EPass; |
|
5571 enum TVerdict verdict; |
|
5572 // this installs the scheduler |
|
5573 verdict = CTestStepAudOutStream::DoTestStepPreambleL(); |
|
5574 |
|
5575 // if the parent preamble fails, we must fail too |
|
5576 if (verdict != EPass) |
|
5577 { |
|
5578 return verdict; |
|
5579 } |
|
5580 |
|
5581 |
|
5582 // Printing to the console and log file |
|
5583 INFO_PRINTF1(_L("this test is getting the position of a playing Audio Output Stream Utility Class: Position()")); |
|
5584 |
|
5585 iAudOutStream->Open(NULL); |
|
5586 CActiveScheduler::Start(); |
|
5587 iAudOutStream->SetVolume(iAudOutStream->MaxVolume()>>1); // half volume |
|
5588 TInt err = KErrNone; |
|
5589 if(iAudOutStream==NULL) |
|
5590 { |
|
5591 err = KErrNotReady; |
|
5592 } |
|
5593 |
|
5594 if (iError != KErrNone || |
|
5595 err != KErrNone ) |
|
5596 { |
|
5597 return EInconclusive; |
|
5598 } |
|
5599 |
|
5600 err = iFile.Open(iFs, KStreamRawFile, EFileRead); |
|
5601 if (err != KErrNone) |
|
5602 { |
|
5603 return EInconclusive; |
|
5604 } |
|
5605 |
|
5606 // start feeding the outputStream |
|
5607 iReadBufferActive->Read(); // finally calls CMdaAudioOutputStream::WriteL(...) |
|
5608 CIdle* idleStopper = CIdle::NewL(CActive::EPriorityStandard); |
|
5609 idleStopper->Start(TCallBack(stopActiveScheduler)); |
|
5610 CActiveScheduler::Start(); |
|
5611 delete idleStopper; |
|
5612 |
|
5613 if(iAudOutStream==NULL) |
|
5614 { |
|
5615 err = KErrNotReady; |
|
5616 } |
|
5617 |
|
5618 if (err != KErrNone) |
|
5619 { |
|
5620 return EInconclusive; |
|
5621 } |
|
5622 |
|
5623 return verdict; |
|
5624 } |
|
5625 |
|
5626 |
|
5627 enum TVerdict CTestStepAudOutStreamPosition::DoTestStepPostambleL(void) |
|
5628 { |
|
5629 iFile.Close(); |
|
5630 |
|
5631 //[ Destroy the scheduler, delete the iAudOutStream, close the file system |
|
5632 return CTestStepAudOutStream::DoTestStepPostambleL(); |
|
5633 } |
|
5634 |
|
5635 TVerdict CTestStepAudOutStreamPosition::DoTestStepL() |
|
5636 { |
|
5637 if(iAudOutStream==NULL) |
|
5638 { |
|
5639 return EFail; |
|
5640 } |
|
5641 |
|
5642 // Get the position before and after a 5s play; |
|
5643 // We are asking for a two seconds play window, but due to scheduling issues etc, |
|
5644 // we may not get exactly what we want. However we can more accurately find out |
|
5645 // what we got by asking for the elapsed clock ticks during that time. |
|
5646 // This test fails if waittime < 5 seconds, needs more wait time to calculate accuractely |
|
5647 const TInt KWaitTime = 5000000; // 5s |
|
5648 CCallBackTimer* callBackTimer = CCallBackTimer::NewL(TCallBack(stopActiveScheduler), CActive::EPriorityStandard); |
|
5649 callBackTimer->After(KWaitTime); |
|
5650 const TTimeIntervalMicroSeconds pos1 = iAudOutStream->Position(); |
|
5651 const TInt tick1 = User::TickCount(); |
|
5652 CActiveScheduler::Start(); |
|
5653 delete callBackTimer; |
|
5654 const TTimeIntervalMicroSeconds pos2 = iAudOutStream->Position(); |
|
5655 const TInt tick2 = User::TickCount(); |
|
5656 |
|
5657 // How much did the postion move by, and in how much time? |
|
5658 TInt tickPeriod = 0; |
|
5659 if (HAL::Get(HALData::ESystemTickPeriod, tickPeriod) != KErrNone) |
|
5660 { |
|
5661 return EInconclusive; |
|
5662 } |
|
5663 |
|
5664 const TInt64 KDiffPosition = pos2.Int64() - pos1.Int64(); |
|
5665 const TInt KElapsedTime = (tick2 - tick1) * tickPeriod; |
|
5666 |
|
5667 // Is the position diff inside an acceptable range? |
|
5668 const TReal KTolerance = 0.2; // 20% |
|
5669 const TInt KDelta = static_cast<TInt>(static_cast<TReal>(KElapsedTime) * KTolerance); // yuk |
|
5670 const TInt KMin = KElapsedTime - KDelta; |
|
5671 const TInt KMax = KElapsedTime + KDelta; |
|
5672 INFO_PRINTF5 (_L("Step One:\tActual: %ld, Expected: %d, Min: %d, Max: %d"), KDiffPosition, KElapsedTime, KMin, KMax); |
|
5673 if ((KDiffPosition < KMin) || (KDiffPosition > KMax)) |
|
5674 { |
|
5675 return EFail; |
|
5676 } |
|
5677 |
|
5678 |
|
5679 CIdle* idleStopper = CIdle::NewL(CActive::EPriorityStandard); |
|
5680 idleStopper->Start(TCallBack(StopAudOutStream, iAudOutStream)); |
|
5681 CActiveScheduler::Start(); |
|
5682 delete idleStopper; |
|
5683 |
|
5684 if (iError != KErrCancel) |
|
5685 { |
|
5686 // KErrCancel (KErrAbort is supposed to be returned ny the MaoscBufferCopied??) |
|
5687 INFO_PRINTF2(_L("Test failed with error %d"), iError); |
|
5688 return EFail; |
|
5689 } |
|
5690 |
|
5691 |
|
5692 // Get the position. For a stopped stream, this should always be zero. |
|
5693 TTimeIntervalMicroSeconds pos = iAudOutStream->Position(); |
|
5694 INFO_PRINTF2(_L("Step Two:\tActual: %ld, Expected: 0"), pos.Int64()); |
|
5695 if (pos.Int64() != 0) |
|
5696 { |
|
5697 return EFail; |
|
5698 } |
|
5699 |
|
5700 |
|
5701 //xxx try cotinuing playing and get positions while playing if there is more time. |
|
5702 |
|
5703 INFO_PRINTF1(_L("finished with this test step")); |
|
5704 // test steps return a result |
|
5705 return EPass; |
|
5706 } |
|
5707 |
|
5708 |
|
5709 |
|
5710 CTestStepAudOutStreamGetBytes* CTestStepAudOutStreamGetBytes::NewL(const TDesC& aTestName) |
|
5711 { |
|
5712 CTestStepAudOutStreamGetBytes* self = new(ELeave) CTestStepAudOutStreamGetBytes(aTestName); |
|
5713 return self; |
|
5714 } |
|
5715 |
|
5716 CTestStepAudOutStreamGetBytes::CTestStepAudOutStreamGetBytes(const TDesC& aTestName) |
|
5717 { |
|
5718 iTestStepResult = EPass; |
|
5719 // store the name of this test case |
|
5720 // this is the name that is used by the script file |
|
5721 iTestStepName = aTestName; |
|
5722 } |
|
5723 |
|
5724 CTestStepAudOutStreamGetBytes::~CTestStepAudOutStreamGetBytes() |
|
5725 { |
|
5726 } |
|
5727 |
|
5728 enum TVerdict CTestStepAudOutStreamGetBytes::DoTestStepPreambleL(void) |
|
5729 { |
|
5730 iTestStepResult = EPass; |
|
5731 enum TVerdict verdict; |
|
5732 // this installs the scheduler |
|
5733 verdict = CTestStepAudOutStream::DoTestStepPreambleL(); |
|
5734 |
|
5735 // if the parent preamble fails, we must fail too |
|
5736 if (verdict != EPass) |
|
5737 { |
|
5738 return verdict; |
|
5739 } |
|
5740 |
|
5741 |
|
5742 // Printing to the console and log file |
|
5743 INFO_PRINTF1(_L("this test gets the bytes rendered by the H/W until this moment: GetBytes()")); |
|
5744 |
|
5745 iAudOutStream->Open(NULL); |
|
5746 CActiveScheduler::Start(); |
|
5747 iAudOutStream->SetVolume(iAudOutStream->MaxVolume()>>1); // half volume |
|
5748 |
|
5749 TInt err = KErrNone; |
|
5750 if(iAudOutStream==NULL) |
|
5751 { |
|
5752 err = KErrNotReady; |
|
5753 } |
|
5754 |
|
5755 if (iError != KErrNone || |
|
5756 err != KErrNone) |
|
5757 { |
|
5758 return EInconclusive; |
|
5759 } |
|
5760 |
|
5761 err = iFile.Open(iFs, KStreamRawFile, EFileRead); |
|
5762 if (err != KErrNone) |
|
5763 { |
|
5764 return EInconclusive; |
|
5765 } |
|
5766 |
|
5767 |
|
5768 // start feeding the outputStream |
|
5769 iReadBufferActive->Read(); // finally calls CMdaAudioOutputStream::WriteL(...) |
|
5770 CIdle* idleStopper = CIdle::NewL(CActive::EPriorityStandard); |
|
5771 idleStopper->Start(TCallBack(stopActiveScheduler)); |
|
5772 CActiveScheduler::Start(); |
|
5773 delete idleStopper; |
|
5774 |
|
5775 if(iAudOutStream==NULL) |
|
5776 { |
|
5777 err = KErrNotReady; |
|
5778 } |
|
5779 |
|
5780 if (err != KErrNone) |
|
5781 { |
|
5782 return EInconclusive; |
|
5783 } |
|
5784 |
|
5785 return verdict; |
|
5786 } |
|
5787 |
|
5788 enum TVerdict CTestStepAudOutStreamGetBytes::DoTestStepPostambleL(void) |
|
5789 { |
|
5790 iFile.Close(); |
|
5791 |
|
5792 //[ Destroy the scheduler, delete the iAudOutStream, close the file system |
|
5793 return CTestStepAudOutStream::DoTestStepPostambleL(); |
|
5794 } |
|
5795 |
|
5796 TVerdict CTestStepAudOutStreamGetBytes::DoTestStepL() |
|
5797 { |
|
5798 TInt bytes1 = iAudOutStream->GetBytes(); |
|
5799 CCallBackTimer* callBackTimer = CCallBackTimer::NewL(TCallBack(stopActiveScheduler)); |
|
5800 callBackTimer->After(2000000); |
|
5801 CActiveScheduler::Start(); |
|
5802 if (iError != KErrNone) |
|
5803 { |
|
5804 INFO_PRINTF2(_L("Test failed with error %d"), iError); |
|
5805 return EFail; |
|
5806 } |
|
5807 callBackTimer->Cancel(); // in case something else stopped the AS |
|
5808 TInt bytes2 = iAudOutStream->GetBytes(); |
|
5809 callBackTimer->After(2000000); |
|
5810 CActiveScheduler::Start(); |
|
5811 if (iError != KErrNone) |
|
5812 { |
|
5813 INFO_PRINTF2(_L("Test failed with error %d"), iError); |
|
5814 return EFail; |
|
5815 } |
|
5816 delete callBackTimer; |
|
5817 TInt bytes3 = iAudOutStream->GetBytes(); |
|
5818 |
|
5819 TInt fileSize; |
|
5820 User::LeaveIfError(iFile.Size(fileSize)); |
|
5821 CActiveScheduler::Start(); // wait for sample to finish |
|
5822 TInt bytes4 = iAudOutStream->GetBytes(); |
|
5823 if (bytes1 >= bytes2 || bytes2 >= bytes3 || bytes3 >= bytes4) |
|
5824 { |
|
5825 return EFail; |
|
5826 } |
|
5827 |
|
5828 if (bytes4 != fileSize) |
|
5829 { |
|
5830 return EFail; |
|
5831 } |
|
5832 |
|
5833 |
|
5834 INFO_PRINTF1(_L("finished with this test step")); |
|
5835 // test steps return a result |
|
5836 return iTestStepResult; |
|
5837 } |
|
5838 |
|
5839 |
|
5840 |
|
5841 |
|
5842 |
|
5843 //------------------------------------------------------------------ |
|
5844 |
|
5845 /** |
|
5846 * Constructor baseclass |
|
5847 */ |
|
5848 CTestMmfAclntRecNoPlayback::CTestMmfAclntRecNoPlayback(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName) |
|
5849 { |
|
5850 // store the name of this test case |
|
5851 // this is the name that is used by the script file |
|
5852 // Each test step initialises it's own name |
|
5853 iTestStepName = aTestName; |
|
5854 iSectName = aSectName; |
|
5855 iKeyName = aKeyName; |
|
5856 } |
|
5857 |
|
5858 void CTestMmfAclntRecNoPlayback::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt aCurrentState, TInt aErrorCode) |
|
5859 { |
|
5860 iError = aErrorCode; |
|
5861 INFO_PRINTF1( _L("CTestMmfAclntRecNoPlayback : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete")); |
|
5862 INFO_PRINTF2( _L("iError %d "), iError); |
|
5863 |
|
5864 //dont stop the playing track |
|
5865 if (aCurrentState != CMdaAudioClipUtility::EPlaying || iError != KErrNone) |
|
5866 { |
|
5867 CActiveScheduler::Stop(); |
|
5868 } |
|
5869 |
|
5870 } |
|
5871 |
|
5872 |
|
5873 TVerdict CTestMmfAclntRecNoPlayback::DoTestStepPreambleL() |
|
5874 { |
|
5875 TVerdict ret = EPass; |
|
5876 |
|
5877 // Make sure file doesn't exist (maybe from a previous test) |
|
5878 TParse fullFileName; |
|
5879 TBuf<KSizeBuf> filename; |
|
5880 TPtrC filename1; |
|
5881 |
|
5882 if(!GetStringFromConfig(iSectName, iKeyName, filename1)) |
|
5883 { |
|
5884 return EInconclusive; |
|
5885 } |
|
5886 |
|
5887 GetDriveName(filename); |
|
5888 filename.Append(filename1); |
|
5889 |
|
5890 |
|
5891 // parse the filenames |
|
5892 if(!fullFileName.Set(filename, &KDefault, NULL)) |
|
5893 { |
|
5894 RFs fs; |
|
5895 User::LeaveIfError(fs.Connect()); |
|
5896 fs.SetAtt(fullFileName.FullName(), 0, KEntryAttReadOnly); |
|
5897 TInt error = fs.Delete(fullFileName.FullName()); |
|
5898 |
|
5899 if(error == KErrPathNotFound) |
|
5900 { |
|
5901 error = fs.MkDirAll(fullFileName.DriveAndPath()); |
|
5902 INFO_PRINTF2(_L("Path for file %S was been created"), &fullFileName.FullName()); |
|
5903 } |
|
5904 else if(error == KErrNotFound) |
|
5905 INFO_PRINTF2(_L("No need to delete %S"), &fullFileName.FullName()); |
|
5906 else if(error==KErrNone) |
|
5907 INFO_PRINTF2(_L("Deleted %S"), &fullFileName.FullName()); |
|
5908 else |
|
5909 { |
|
5910 ret = EInconclusive; |
|
5911 } |
|
5912 fs.Close(); |
|
5913 } |
|
5914 |
|
5915 if((ret == EInconclusive) || (ret == EFail)) |
|
5916 { |
|
5917 return ret; |
|
5918 } |
|
5919 |
|
5920 |
|
5921 return CTestMmfAclntStep::DoTestStepPreambleL(); |
|
5922 } |
|
5923 |
|
5924 |
|
5925 TVerdict CTestMmfAclntRecNoPlayback::DoTestStepPostambleL() |
|
5926 { |
|
5927 if(IsFileTest()) |
|
5928 { |
|
5929 // Cleanup after the test |
|
5930 TParse fullFileName; |
|
5931 TBuf<KSizeBuf> filename; |
|
5932 TPtrC filename1; |
|
5933 |
|
5934 if(!GetStringFromConfig(iSectName, iKeyName, filename1)) |
|
5935 { |
|
5936 return EInconclusive; |
|
5937 } |
|
5938 |
|
5939 |
|
5940 GetDriveName(filename); |
|
5941 filename.Append(filename1); |
|
5942 |
|
5943 |
|
5944 // parse the filenames |
|
5945 if(!fullFileName.Set(filename, &KDefault, NULL)) |
|
5946 { |
|
5947 RFs fs; |
|
5948 User::LeaveIfError(fs.Connect()); |
|
5949 fs.SetAtt(fullFileName.FullName(), 0, KEntryAttReadOnly); |
|
5950 TInt error = fs.Delete(fullFileName.FullName()); |
|
5951 |
|
5952 if(error != KErrNone) |
|
5953 { |
|
5954 INFO_PRINTF2(_L("Failed to delete %S"), &fullFileName.FullName()); |
|
5955 } |
|
5956 } |
|
5957 } |
|
5958 |
|
5959 return CTestMmfAclntStep::DoTestStepPostambleL(); |
|
5960 } |
|
5961 |
|
5962 |
|
5963 |
|
5964 |
|
5965 TVerdict CTestMmfAclntRecNoPlayback::DoTestStepL() |
|
5966 { |
|
5967 TVerdict testStatus = EPass; |
|
5968 TInt trapRet = KErrNone; |
|
5969 TInt ret = KErrNone; |
|
5970 |
|
5971 const TInt durError = 2000000; //2 second |
|
5972 const TInt posnError = 250000; //1/4 second |
|
5973 const TInt cropError = 250000; //1/4 second |
|
5974 |
|
5975 iRecorder = CMdaAudioRecorderUtilityLC(); |
|
5976 |
|
5977 if(!iRecorder) |
|
5978 { |
|
5979 testStatus = EFail; |
|
5980 } |
|
5981 |
|
5982 //Should always work, must be done before play or record to ensure in EPrimed state |
|
5983 if(testStatus == EPass) |
|
5984 { |
|
5985 TRAP(trapRet,iRecorder->SetPriority(EMdaPriorityMin,EMdaPriorityPreferenceNone)); |
|
5986 if(trapRet != KErrNone) |
|
5987 { |
|
5988 INFO_PRINTF2(_L("SetPriority leave with error %d"),trapRet); |
|
5989 testStatus = EFail; |
|
5990 } |
|
5991 } |
|
5992 |
|
5993 |
|
5994 |
|
5995 if(testStatus == EPass) |
|
5996 { |
|
5997 iError = KErrTimedOut; |
|
5998 iRecorder->RecordL(); |
|
5999 INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility")); |
|
6000 CActiveScheduler::Start(); // open -> record |
|
6001 |
|
6002 User::After(KTenSeconds); |
|
6003 iRecorder->Stop(); |
|
6004 |
|
6005 testStatus = RecordSuccessfull(); |
|
6006 } |
|
6007 |
|
6008 |
|
6009 //Can't detect difference in these interfaces with no play controller |
|
6010 //void ClearPlayWindow(); |
|
6011 //void SetRepeats(....); |
|
6012 //void Pause(); |
|
6013 //void SetMaxWriteLength(TInt aMaxWriteLength /*= KMdaClipLocationMaxWriteLengthNone*/); |
|
6014 //void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration); |
|
6015 //void SetPlayWindow(const TTimeIntervalMicroSeconds& aStart, const TTimeIntervalMicroSeconds& aEnd); |
|
6016 |
|
6017 |
|
6018 |
|
6019 |
|
6020 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
6021 //These interfaces should always WORK if there is a record or playback controller |
|
6022 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
6023 |
|
6024 if(testStatus == EPass) |
|
6025 { |
|
6026 TTimeIntervalMicroSeconds setPosn(KTwoSeconds); |
|
6027 |
|
6028 iRecorder->SetPosition(setPosn); |
|
6029 TTimeIntervalMicroSeconds getPosn = iRecorder->Position(); |
|
6030 INFO_PRINTF3(_L("got position %d should be %d"),I64LOW(getPosn.Int64()), KTwoSeconds); |
|
6031 |
|
6032 if((getPosn.Int64() < setPosn.Int64()-posnError) && |
|
6033 (getPosn.Int64() > setPosn.Int64()+posnError)) |
|
6034 { |
|
6035 INFO_PRINTF1(_L("Position fail")); |
|
6036 testStatus = EFail; |
|
6037 } |
|
6038 } |
|
6039 |
|
6040 if(testStatus == EPass) |
|
6041 { |
|
6042 TTimeIntervalMicroSeconds duration = iRecorder->Duration(); |
|
6043 INFO_PRINTF3(_L("got duration %d should be %d"),I64LOW(duration.Int64()), KTenSeconds); |
|
6044 |
|
6045 if((duration.Int64() > KTenSeconds+durError) || |
|
6046 (duration.Int64() < KTenSeconds-durError)) |
|
6047 { |
|
6048 INFO_PRINTF1(_L("Duration fail")); |
|
6049 } |
|
6050 } |
|
6051 |
|
6052 |
|
6053 |
|
6054 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
6055 //These interfaces should WORK if there is a record controller but no playback controller |
|
6056 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
6057 |
|
6058 if(testStatus == EPass) |
|
6059 { |
|
6060 TInt gain; |
|
6061 iRecorder->SetGain(2); |
|
6062 |
|
6063 ret = iRecorder->GetGain(gain); |
|
6064 if((ret != KErrNone) || (gain != 2)) |
|
6065 { |
|
6066 INFO_PRINTF1(_L("Gain fail")); |
|
6067 testStatus = EFail; |
|
6068 } |
|
6069 } |
|
6070 if(testStatus == EPass) |
|
6071 { |
|
6072 TTimeIntervalMicroSeconds croppedDuration; |
|
6073 TTimeIntervalMicroSeconds originalDuration; |
|
6074 TTimeIntervalMicroSeconds setPosn(KTwoSeconds); |
|
6075 iRecorder->SetPosition(setPosn); |
|
6076 |
|
6077 originalDuration = iRecorder->Duration(); |
|
6078 |
|
6079 if((originalDuration.Int64() > KTenSeconds+durError) || |
|
6080 (originalDuration.Int64() < KTenSeconds-durError)) |
|
6081 { |
|
6082 INFO_PRINTF1(_L("getting Duration for CropL fail")); |
|
6083 testStatus = EFail; |
|
6084 } |
|
6085 else |
|
6086 { |
|
6087 TRAP(trapRet, iRecorder->CropFromBeginningL()); |
|
6088 if(trapRet == KErrNone) |
|
6089 { |
|
6090 croppedDuration = iRecorder->Duration(); |
|
6091 INFO_PRINTF3(_L("got duration %d should be %d"),I64LOW(croppedDuration.Int64()), originalDuration.Int64()-KTwoSeconds); |
|
6092 } |
|
6093 if((trapRet != KErrNone) || |
|
6094 ((croppedDuration.Int64() > originalDuration.Int64()-KTwoSeconds+cropError) || |
|
6095 (croppedDuration.Int64() < originalDuration.Int64()-KTwoSeconds-cropError))) |
|
6096 { |
|
6097 INFO_PRINTF1(_L("Crop fail")); |
|
6098 testStatus = EFail; |
|
6099 } |
|
6100 } |
|
6101 } |
|
6102 |
|
6103 if(testStatus == EPass) |
|
6104 { |
|
6105 TTimeIntervalMicroSeconds zero(0); |
|
6106 |
|
6107 TTimeIntervalMicroSeconds recTimeAvail = iRecorder->RecordTimeAvailable(); |
|
6108 if(recTimeAvail == zero) |
|
6109 { |
|
6110 INFO_PRINTF1(_L("RecordTimeAvailable fail")); |
|
6111 testStatus = EFail; |
|
6112 } |
|
6113 } |
|
6114 |
|
6115 |
|
6116 if(testStatus == EPass) |
|
6117 { |
|
6118 TInt bal = KMMFBalanceMaxRight; |
|
6119 ret = iRecorder->SetRecordBalance(KMMFBalanceMaxLeft); |
|
6120 if(ret == KErrNone) |
|
6121 { |
|
6122 bal = KMMFBalanceMaxRight; |
|
6123 ret = iRecorder->GetRecordBalance(bal); |
|
6124 } |
|
6125 if((bal != KMMFBalanceMaxLeft) || (ret != KErrNone)) |
|
6126 { |
|
6127 INFO_PRINTF1(_L("Balance tests fail")); |
|
6128 testStatus = EFail; |
|
6129 } |
|
6130 } |
|
6131 |
|
6132 //Haven't got a format that supports these - trace into code. |
|
6133 /* |
|
6134 if(testStatus == EPass) |
|
6135 { |
|
6136 TInt metaEntries; |
|
6137 CMMFMetaDataEntry* metaEntry = NULL; |
|
6138 CMMFMetaDataEntry* newMetaEntry = CMMFMetaDataEntry::NewL(_L("dummy meta"), _L("dummy val")); |
|
6139 |
|
6140 iRecorder->GetNumberOfMetaDataEntries(metaEntries); |
|
6141 TRAP(trapRet, metaEntry = iRecorder->GetMetaDataEntryL(1)); |
|
6142 TRAP(trapRet, iRecorder->AddMetaDataEntryL(*newMetaEntry)); |
|
6143 TRAP(trapRet, iRecorder->ReplaceMetaDataEntryL(1, *newMetaEntry)); |
|
6144 iRecorder->RemoveMetaDataEntry(1); |
|
6145 } |
|
6146 */ |
|
6147 |
|
6148 |
|
6149 if(testStatus == EPass) |
|
6150 { |
|
6151 RArray<TFourCC> codecs; |
|
6152 TRAP(trapRet, iRecorder->GetSupportedDestinationDataTypesL(codecs)); |
|
6153 if((trapRet == KErrNone) && (codecs.Count() > 0) && IsFileTest()) |
|
6154 { |
|
6155 TRAP(trapRet, iRecorder->SetDestinationDataTypeL(codecs[0])); |
|
6156 } |
|
6157 |
|
6158 if((trapRet == KErrNone) && (codecs.Count() > 0)) |
|
6159 { |
|
6160 TFourCC dataType; |
|
6161 TRAP(trapRet, dataType = iRecorder->DestinationDataTypeL()); |
|
6162 if((trapRet != KErrNone) || (IsFileTest() && (dataType != codecs[0]))) |
|
6163 testStatus = EFail; |
|
6164 } |
|
6165 |
|
6166 if((trapRet != KErrNone) || (testStatus == EFail)) |
|
6167 { |
|
6168 INFO_PRINTF1(_L("DestinationDataTypes fail")); |
|
6169 testStatus = EFail; |
|
6170 } |
|
6171 } |
|
6172 |
|
6173 |
|
6174 //These methods are not available for our formats and will therefore always fail - trace into code |
|
6175 /* |
|
6176 if(testStatus == EPass) |
|
6177 { |
|
6178 RArray<TUint> bitRates; |
|
6179 TUint bitRate = 0; |
|
6180 |
|
6181 TRAP(trapRet, iRecorder->GetSupportedBitRatesL(bitRates)); |
|
6182 if((trapRet == KErrNone) && (bitRates.Count() >0)) |
|
6183 TRAP(trapRet, iRecorder->SetDestinationBitRateL(bitRates[0])); |
|
6184 if((trapRet == KErrNone) && (bitRates.Count() >0)) |
|
6185 TRAP(trapRet, bitRate = iRecorder->DestinationBitRateL()); |
|
6186 |
|
6187 if((trapRet != KErrNone) || (bitRate != bitRates[0])) |
|
6188 { |
|
6189 INFO_PRINTF1(_L("BitRates fail")); |
|
6190 testStatus = EFail; |
|
6191 } |
|
6192 } |
|
6193 */ |
|
6194 |
|
6195 if(testStatus == EPass) |
|
6196 { |
|
6197 RArray<TUint> sampleRates; |
|
6198 TUint sampleRate = 0; |
|
6199 |
|
6200 TRAP(trapRet, iRecorder->GetSupportedSampleRatesL(sampleRates)); |
|
6201 if((trapRet == KErrNone) && (sampleRates.Count() >0)) |
|
6202 { |
|
6203 TRAP(trapRet, iRecorder->SetDestinationSampleRateL(sampleRates[0])); |
|
6204 } |
|
6205 |
|
6206 if((trapRet == KErrNone) && (sampleRates.Count() >0)) |
|
6207 { |
|
6208 TRAP(trapRet, sampleRate = iRecorder->DestinationSampleRateL()); |
|
6209 } |
|
6210 |
|
6211 if((trapRet != KErrNone) || (sampleRate != sampleRates[0])) |
|
6212 { |
|
6213 INFO_PRINTF1(_L("SampleRates fail")); |
|
6214 testStatus = EFail; |
|
6215 } |
|
6216 } |
|
6217 |
|
6218 |
|
6219 |
|
6220 if(testStatus == EPass) |
|
6221 { |
|
6222 RArray<TUint> channels; |
|
6223 TUint channel = 0; |
|
6224 |
|
6225 TRAP(trapRet, iRecorder->GetSupportedNumberOfChannelsL(channels)); |
|
6226 if((trapRet == KErrNone) && (channels.Count() >0)) |
|
6227 { |
|
6228 TRAP(trapRet, iRecorder->SetDestinationNumberOfChannelsL(channels[0])); |
|
6229 } |
|
6230 |
|
6231 if((trapRet == KErrNone) && (channels.Count() >0)) |
|
6232 { |
|
6233 TRAP(trapRet, channel = iRecorder->DestinationNumberOfChannelsL()); |
|
6234 } |
|
6235 |
|
6236 if((trapRet != KErrNone) || (channel != channels[0])) |
|
6237 { |
|
6238 INFO_PRINTF1(_L("channels fail")); |
|
6239 testStatus = EFail; |
|
6240 } |
|
6241 } |
|
6242 |
|
6243 |
|
6244 if(testStatus == EPass) |
|
6245 { |
|
6246 TUid currentFormat = KNullUid; |
|
6247 |
|
6248 TRAP(trapRet, currentFormat = iRecorder->DestinationFormatL()); |
|
6249 |
|
6250 /*can't do this, causes segmentation violation - trace into code |
|
6251 TUid newFormat = {KMmfUidFormatRAWWrite}; |
|
6252 if(trapRet == KErrNone) |
|
6253 TRAP(trapRet, iRecorder->SetDestinationFormatL(newFormat)); |
|
6254 if(trapRet == KErrNone) |
|
6255 TRAP(trapRet, iRecorder->SetDestinationFormatL(currentFormat)); |
|
6256 */ |
|
6257 |
|
6258 if(trapRet != KErrNone) |
|
6259 { |
|
6260 INFO_PRINTF1(_L("format fail")); |
|
6261 testStatus = EFail; |
|
6262 } |
|
6263 } |
|
6264 |
|
6265 |
|
6266 // These would pass when a record controller is present, also need test controller - trace into code |
|
6267 // TInt RecordControllerCustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom); |
|
6268 // TInt RecordControllerCustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2); |
|
6269 // void RecordControllerCustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus); |
|
6270 // void RecordControllerCustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus); |
|
6271 |
|
6272 |
|
6273 |
|
6274 |
|
6275 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
6276 //These interfaces should FAIL if there is a record controller but no playback controller |
|
6277 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
6278 |
|
6279 if(testStatus == EPass) |
|
6280 { |
|
6281 TRAP(trapRet, iRecorder->PlayL()) |
|
6282 if(trapRet != KErrNotSupported) |
|
6283 { |
|
6284 INFO_PRINTF1(_L("Play fail")); |
|
6285 testStatus = EFail; |
|
6286 } |
|
6287 } |
|
6288 |
|
6289 |
|
6290 if(testStatus == EPass) |
|
6291 { |
|
6292 TInt maxVol = iRecorder->MaxVolume(); |
|
6293 if(maxVol != 0) |
|
6294 { |
|
6295 INFO_PRINTF1(_L("MaxVolume fail")); |
|
6296 testStatus = EFail; |
|
6297 } |
|
6298 } |
|
6299 |
|
6300 |
|
6301 if(testStatus == EPass) |
|
6302 { |
|
6303 iRecorder->SetVolume(1); |
|
6304 |
|
6305 TInt vol; |
|
6306 ret = iRecorder->GetVolume(vol); |
|
6307 if(ret != KErrNotSupported) |
|
6308 { |
|
6309 INFO_PRINTF1(_L("GetVolume fail")); |
|
6310 testStatus = EFail; |
|
6311 } |
|
6312 } |
|
6313 |
|
6314 if(testStatus == EPass) |
|
6315 { |
|
6316 TInt bal; |
|
6317 TInt ret = iRecorder->SetPlaybackBalance(KMMFBalanceMaxRight); |
|
6318 if(ret != KErrNotSupported) |
|
6319 { |
|
6320 INFO_PRINTF1(_L("SetPlaybackBalance fail")); |
|
6321 testStatus = EFail; |
|
6322 } |
|
6323 |
|
6324 ret = iRecorder->GetPlaybackBalance(bal); |
|
6325 if(ret != KErrNotSupported) |
|
6326 { |
|
6327 INFO_PRINTF1(_L("GetPlaybackBalance fail")); |
|
6328 testStatus = EFail; |
|
6329 } |
|
6330 } |
|
6331 |
|
6332 |
|
6333 |
|
6334 if(testStatus == EPass) |
|
6335 { |
|
6336 TMMFMessageDestinationPckg dummyPckg; |
|
6337 TInt dummyFunc = 100; |
|
6338 TBuf8<8> dummyBuff; |
|
6339 |
|
6340 ret = iRecorder->PlayControllerCustomCommandSync(dummyPckg, dummyFunc, dummyBuff, dummyBuff, dummyBuff); |
|
6341 if(ret != KErrNotSupported) |
|
6342 { |
|
6343 INFO_PRINTF1(_L("PlayControllerCustomCommandSync - 1 fail")); |
|
6344 testStatus = EFail; |
|
6345 } |
|
6346 |
|
6347 ret = iRecorder->PlayControllerCustomCommandSync(dummyPckg, dummyFunc, dummyBuff, dummyBuff); |
|
6348 if(ret != KErrNotSupported) |
|
6349 { |
|
6350 INFO_PRINTF1(_L("PlayControllerCustomCommandSync -2 fail")); |
|
6351 testStatus = EFail; |
|
6352 } |
|
6353 |
|
6354 CTestMmfAclntAOCallback* aoCallback = new CTestMmfAclntAOCallback(this); |
|
6355 CleanupStack::PushL(aoCallback); |
|
6356 aoCallback->PublicSetActive(); |
|
6357 |
|
6358 |
|
6359 iRecorder->PlayControllerCustomCommandAsync(dummyPckg, dummyFunc, dummyBuff, dummyBuff, dummyBuff, aoCallback->iStatus); |
|
6360 CActiveScheduler::Start(); |
|
6361 |
|
6362 if(iError != KErrNotSupported) |
|
6363 { |
|
6364 INFO_PRINTF1(_L("PlayControllerCustomCommandAsync -1 fail")); |
|
6365 testStatus = EFail; |
|
6366 } |
|
6367 |
|
6368 aoCallback->PublicSetActive(); |
|
6369 iRecorder->PlayControllerCustomCommandAsync(dummyPckg, dummyFunc, dummyBuff, dummyBuff, aoCallback->iStatus); |
|
6370 CActiveScheduler::Start(); |
|
6371 |
|
6372 if(iError != KErrNotSupported) |
|
6373 { |
|
6374 INFO_PRINTF1(_L("PlayControllerCustomCommandAsync -2 fail")); |
|
6375 testStatus = EFail; |
|
6376 } |
|
6377 |
|
6378 CleanupStack::Pop(aoCallback); |
|
6379 } |
|
6380 |
|
6381 |
|
6382 |
|
6383 |
|
6384 CleanupStack::PopAndDestroy(iRecorder); |
|
6385 User::After(KOneSecond); |
|
6386 return testStatus; |
|
6387 } |
|
6388 |
|
6389 |
|
6390 |
|
6391 |
|
6392 |
|
6393 |
|
6394 |
|
6395 |
|
6396 |
|
6397 |
|
6398 |
|
6399 |
|
6400 |
|
6401 |
|
6402 |
|
6403 //------------------------------------------------------------------ |
|
6404 |
|
6405 /** |
|
6406 * Constructor |
|
6407 */ |
|
6408 CTestMmfAclntRecNoPlaybackForceFormat::CTestMmfAclntRecNoPlaybackForceFormat(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TMdaClipFormat& aFormat) |
|
6409 : CTestMmfAclntRecNoPlayback(aTestName, aSectName, aKeyName) |
|
6410 { |
|
6411 iFormat = aFormat; |
|
6412 } |
|
6413 |
|
6414 CTestMmfAclntRecNoPlaybackForceFormat* CTestMmfAclntRecNoPlaybackForceFormat::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TMdaClipFormat& aFormat) |
|
6415 { |
|
6416 CTestMmfAclntRecNoPlaybackForceFormat* self = new (ELeave) CTestMmfAclntRecNoPlaybackForceFormat(aTestName,aSectName,aKeyName,aFormat); |
|
6417 return self; |
|
6418 } |
|
6419 |
|
6420 CTestMmfAclntRecNoPlaybackForceFormat* CTestMmfAclntRecNoPlaybackForceFormat::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TMdaClipFormat& aFormat) |
|
6421 { |
|
6422 CTestMmfAclntRecNoPlaybackForceFormat* self = CTestMmfAclntRecNoPlaybackForceFormat::NewLC(aTestName,aSectName,aKeyName,aFormat); |
|
6423 CleanupStack::PushL(self); |
|
6424 return self; |
|
6425 } |
|
6426 |
|
6427 |
|
6428 CMdaAudioRecorderUtility* CTestMmfAclntRecNoPlaybackForceFormat::CMdaAudioRecorderUtilityLC() |
|
6429 { |
|
6430 INFO_PRINTF1( _L("Create CMdaAudioRecorderUtility with a file and forcing format")); |
|
6431 |
|
6432 if(!GetStringFromConfig(iSectName, iKeyName, iFilename)) |
|
6433 return NULL; |
|
6434 |
|
6435 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
6436 CleanupStack::PushL(recUtil); |
|
6437 |
|
6438 TMdaFileClipLocation location(iFilename); |
|
6439 |
|
6440 recUtil->OpenL(&location,&iFormat); |
|
6441 |
|
6442 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
6443 CActiveScheduler::Start(); |
|
6444 |
|
6445 if(iError != KErrNone) |
|
6446 { |
|
6447 CleanupStack::PopAndDestroy(recUtil); |
|
6448 recUtil = NULL; |
|
6449 } |
|
6450 |
|
6451 return recUtil; |
|
6452 } |
|
6453 |
|
6454 TVerdict CTestMmfAclntRecNoPlaybackForceFormat::RecordSuccessfull() |
|
6455 { |
|
6456 TVerdict testStatus = EPass; |
|
6457 |
|
6458 if(iError == KErrNone) |
|
6459 { |
|
6460 RFs fs; |
|
6461 RFile file; |
|
6462 TInt size = 0; |
|
6463 |
|
6464 iError = fs.Connect(); |
|
6465 if (iError == KErrNone) |
|
6466 { |
|
6467 iError = file.Open(fs,iFilename,EFileRead); |
|
6468 |
|
6469 if (iError == KErrNone) |
|
6470 { |
|
6471 iError = file.Size(size); |
|
6472 |
|
6473 if (iError != KErrNone) |
|
6474 { |
|
6475 INFO_PRINTF1(_L("Unable to get size of file!")); |
|
6476 } |
|
6477 } |
|
6478 else |
|
6479 { |
|
6480 INFO_PRINTF1(_L("Unable to open file.")); |
|
6481 return EInconclusive; |
|
6482 } |
|
6483 |
|
6484 } |
|
6485 else |
|
6486 { |
|
6487 INFO_PRINTF1(_L("Unable to connect to file system.")); |
|
6488 return EInconclusive; |
|
6489 } |
|
6490 |
|
6491 if(size == 0) |
|
6492 { |
|
6493 testStatus = EFail; |
|
6494 } |
|
6495 |
|
6496 |
|
6497 file.Close(); |
|
6498 fs.Close(); |
|
6499 CleanupStack::PopAndDestroy(); //file |
|
6500 } |
|
6501 else |
|
6502 testStatus = EFail; |
|
6503 |
|
6504 return testStatus; |
|
6505 } |
|
6506 |
|
6507 |
|
6508 |
|
6509 CTestMmfAclntRecNoPlaybackForceFormatDesc* CTestMmfAclntRecNoPlaybackForceFormatDesc::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TMdaClipFormat& aFormat) |
|
6510 { |
|
6511 CTestMmfAclntRecNoPlaybackForceFormatDesc* self = new (ELeave) CTestMmfAclntRecNoPlaybackForceFormatDesc(aTestName,aSectName,aKeyName,aFormat); |
|
6512 return self; |
|
6513 } |
|
6514 |
|
6515 CTestMmfAclntRecNoPlaybackForceFormatDesc* CTestMmfAclntRecNoPlaybackForceFormatDesc::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TMdaClipFormat& aFormat) |
|
6516 { |
|
6517 CTestMmfAclntRecNoPlaybackForceFormatDesc* self = CTestMmfAclntRecNoPlaybackForceFormatDesc::NewLC(aTestName,aSectName,aKeyName,aFormat); |
|
6518 CleanupStack::PushL(self); |
|
6519 return self; |
|
6520 } |
|
6521 |
|
6522 |
|
6523 CMdaAudioRecorderUtility* CTestMmfAclntRecNoPlaybackForceFormatDesc::CMdaAudioRecorderUtilityLC() |
|
6524 { |
|
6525 const TInt KMaxFileSize = 200000; |
|
6526 INFO_PRINTF1( _L("Create CMdaAudioRecorderUtility with a descriptor and forcing format")); |
|
6527 |
|
6528 if(!GetStringFromConfig(iSectName, iKeyName, iFilename)) |
|
6529 User::Leave(KErrNotFound); |
|
6530 |
|
6531 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
6532 CleanupStack::PushL(recUtil); |
|
6533 |
|
6534 |
|
6535 HBufC8* iBuf = HBufC8::NewL( KMaxFileSize ); |
|
6536 CleanupStack::PushL(iBuf); |
|
6537 |
|
6538 iFileDesc = new (ELeave) TPtr8( NULL, 0 ); |
|
6539 CleanupStack::PushL(iFileDesc); |
|
6540 |
|
6541 iFileDesc->Set( iBuf->Des()); |
|
6542 |
|
6543 |
|
6544 TMdaDesClipLocation location(*iFileDesc); |
|
6545 |
|
6546 recUtil->OpenL(&location,&iFormat); |
|
6547 |
|
6548 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
6549 CActiveScheduler::Start(); |
|
6550 |
|
6551 if(iError != KErrNone) |
|
6552 { |
|
6553 User::Leave(KErrNotFound); |
|
6554 } |
|
6555 |
|
6556 CleanupStack::Pop(iFileDesc); |
|
6557 CleanupStack::Pop(iBuf); |
|
6558 return recUtil; |
|
6559 } |
|
6560 |
|
6561 TVerdict CTestMmfAclntRecNoPlaybackForceFormatDesc::RecordSuccessfull() |
|
6562 { |
|
6563 TVerdict testStatus = EPass; |
|
6564 |
|
6565 TInt len = iFileDesc->Length(); |
|
6566 |
|
6567 if(len == 0) |
|
6568 { |
|
6569 testStatus = EFail; |
|
6570 } |
|
6571 |
|
6572 return testStatus; |
|
6573 } |
|
6574 |
|
6575 |
|
6576 |
|
6577 |
|
6578 //------------------------------------------------------------------ |
|
6579 |
|
6580 |
|
6581 CTestMmfAclntRecNoPlaybackFile* CTestMmfAclntRecNoPlaybackFile::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName) |
|
6582 { |
|
6583 CTestMmfAclntRecNoPlaybackFile* self = new (ELeave) CTestMmfAclntRecNoPlaybackFile(aTestName,aSectName,aKeyName); |
|
6584 return self; |
|
6585 } |
|
6586 |
|
6587 CTestMmfAclntRecNoPlaybackFile* CTestMmfAclntRecNoPlaybackFile::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName) |
|
6588 { |
|
6589 CTestMmfAclntRecNoPlaybackFile* self = CTestMmfAclntRecNoPlaybackFile::NewLC(aTestName,aSectName,aKeyName); |
|
6590 CleanupStack::PushL(self); |
|
6591 return self; |
|
6592 } |
|
6593 |
|
6594 |
|
6595 CMdaAudioRecorderUtility* CTestMmfAclntRecNoPlaybackFile::CMdaAudioRecorderUtilityLC() |
|
6596 { |
|
6597 INFO_PRINTF1( _L("Create CMdaAudioRecorderUtility with a file")); |
|
6598 |
|
6599 if(!GetStringFromConfig(iSectName, iKeyName, iFilename)) |
|
6600 { |
|
6601 return NULL; |
|
6602 } |
|
6603 |
|
6604 |
|
6605 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
6606 CleanupStack::PushL(recUtil); |
|
6607 |
|
6608 recUtil->OpenFileL(iFilename); |
|
6609 |
|
6610 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
6611 CActiveScheduler::Start(); |
|
6612 |
|
6613 if(iError != KErrNone) |
|
6614 { |
|
6615 CleanupStack::PopAndDestroy(recUtil); |
|
6616 recUtil = NULL; |
|
6617 } |
|
6618 |
|
6619 return recUtil; |
|
6620 } |
|
6621 |
|
6622 TVerdict CTestMmfAclntRecNoPlaybackFile::RecordSuccessfull() |
|
6623 { |
|
6624 TVerdict testStatus = EPass; |
|
6625 |
|
6626 if(iError == KErrNone) |
|
6627 { |
|
6628 RFs fs; |
|
6629 RFile file; |
|
6630 TInt size = 0; |
|
6631 |
|
6632 iError = fs.Connect(); |
|
6633 if (iError == KErrNone) |
|
6634 { |
|
6635 iError = file.Open(fs,iFilename,EFileRead); |
|
6636 |
|
6637 if (iError == KErrNone) |
|
6638 { |
|
6639 iError = file.Size(size); |
|
6640 |
|
6641 if (iError != KErrNone) |
|
6642 { |
|
6643 INFO_PRINTF1(_L("Unable to get size of file!")); |
|
6644 } |
|
6645 } |
|
6646 else |
|
6647 { |
|
6648 INFO_PRINTF1(_L("Unable to open file.")); |
|
6649 return EInconclusive; |
|
6650 } |
|
6651 |
|
6652 } |
|
6653 else |
|
6654 { |
|
6655 INFO_PRINTF1(_L("Unable to connect to file system.")); |
|
6656 return EInconclusive; |
|
6657 } |
|
6658 |
|
6659 if(size == 0) |
|
6660 { |
|
6661 testStatus = EFail; |
|
6662 } |
|
6663 |
|
6664 |
|
6665 file.Close(); |
|
6666 fs.Close(); |
|
6667 CleanupStack::PopAndDestroy(); //file |
|
6668 } |
|
6669 |
|
6670 else |
|
6671 testStatus = EFail; |
|
6672 |
|
6673 return testStatus; |
|
6674 } |
|
6675 |
|
6676 |
|
6677 |
|
6678 |
|
6679 CTestMmfAclntRecNoPlaybackDesc* CTestMmfAclntRecNoPlaybackDesc::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName) |
|
6680 { |
|
6681 CTestMmfAclntRecNoPlaybackDesc* self = new (ELeave) CTestMmfAclntRecNoPlaybackDesc(aTestName,aSectName,aKeyName); |
|
6682 return self; |
|
6683 } |
|
6684 |
|
6685 CTestMmfAclntRecNoPlaybackDesc* CTestMmfAclntRecNoPlaybackDesc::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName) |
|
6686 { |
|
6687 CTestMmfAclntRecNoPlaybackDesc* self = CTestMmfAclntRecNoPlaybackDesc::NewLC(aTestName,aSectName,aKeyName); |
|
6688 CleanupStack::PushL(self); |
|
6689 return self; |
|
6690 } |
|
6691 |
|
6692 |
|
6693 CMdaAudioRecorderUtility* CTestMmfAclntRecNoPlaybackDesc::CMdaAudioRecorderUtilityLC() |
|
6694 { |
|
6695 const TInt KMaxFileSize = 200000; |
|
6696 INFO_PRINTF1( _L("Create CMdaAudioRecorderUtility with a descriptor")); |
|
6697 |
|
6698 if(!GetStringFromConfig(iSectName, iKeyName, iFilename)) |
|
6699 { |
|
6700 User::Leave(KErrNotFound); |
|
6701 } |
|
6702 |
|
6703 |
|
6704 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
6705 CleanupStack::PushL(recUtil); |
|
6706 |
|
6707 |
|
6708 HBufC8* iBuf = HBufC8::NewL( KMaxFileSize ); |
|
6709 CleanupStack::PushL(iBuf); |
|
6710 |
|
6711 iFileDesc = new (ELeave) TPtr8( NULL, 0 ); |
|
6712 CleanupStack::PushL(iFileDesc); |
|
6713 |
|
6714 iFileDesc->Set( iBuf->Des()); |
|
6715 |
|
6716 //Put some contents (one sample wav file) into the descriptor |
|
6717 TPtrC oneSampleFileName; |
|
6718 if(!GetStringFromConfig(iSectName, _L("OneSampleFile"), oneSampleFileName)) |
|
6719 { |
|
6720 User::Leave(KErrNotFound); |
|
6721 } |
|
6722 |
|
6723 RFs fs; |
|
6724 RFile file; |
|
6725 User::LeaveIfError(fs.Connect()); |
|
6726 User::LeaveIfError(file.Open(fs,oneSampleFileName,EFileRead)); |
|
6727 CleanupClosePushL(file); |
|
6728 if(file.Read(*iFileDesc) != KErrNone) |
|
6729 { |
|
6730 User::Leave(KErrNotFound); |
|
6731 } |
|
6732 CleanupStack::PopAndDestroy(&file); |
|
6733 |
|
6734 |
|
6735 recUtil->OpenDesL(*iFileDesc); |
|
6736 |
|
6737 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
6738 CActiveScheduler::Start(); |
|
6739 |
|
6740 if(iError != KErrNone) |
|
6741 { |
|
6742 User::Leave(KErrNotFound); |
|
6743 } |
|
6744 |
|
6745 CleanupStack::Pop(iFileDesc); |
|
6746 CleanupStack::Pop(iBuf); |
|
6747 return recUtil; |
|
6748 } |
|
6749 |
|
6750 TVerdict CTestMmfAclntRecNoPlaybackDesc::RecordSuccessfull() |
|
6751 { |
|
6752 TVerdict testStatus = EPass; |
|
6753 |
|
6754 TInt len = iFileDesc->Length(); |
|
6755 |
|
6756 if(len == 0) |
|
6757 { |
|
6758 testStatus = EFail; |
|
6759 } |
|
6760 |
|
6761 return testStatus; |
|
6762 } |
|
6763 |
|
6764 |
|
6765 |
|
6766 |
|
6767 CTestMmfAclntRecNoPlaybackFileForceController* CTestMmfAclntRecNoPlaybackFileForceController::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TUid aController) |
|
6768 { |
|
6769 CTestMmfAclntRecNoPlaybackFileForceController* self = new (ELeave) CTestMmfAclntRecNoPlaybackFileForceController(aTestName,aSectName,aKeyName, aController); |
|
6770 return self; |
|
6771 } |
|
6772 |
|
6773 CTestMmfAclntRecNoPlaybackFileForceController* CTestMmfAclntRecNoPlaybackFileForceController::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TUid aController) |
|
6774 { |
|
6775 CTestMmfAclntRecNoPlaybackFileForceController* self = CTestMmfAclntRecNoPlaybackFileForceController::NewLC(aTestName,aSectName,aKeyName,aController); |
|
6776 CleanupStack::PushL(self); |
|
6777 return self; |
|
6778 } |
|
6779 |
|
6780 |
|
6781 CMdaAudioRecorderUtility* CTestMmfAclntRecNoPlaybackFileForceController::CMdaAudioRecorderUtilityLC() |
|
6782 { |
|
6783 INFO_PRINTF1( _L("Create CMdaAudioRecorderUtility with a file, forcing record controller")); |
|
6784 |
|
6785 if(!GetStringFromConfig(iSectName, iKeyName, iFilename)) |
|
6786 { |
|
6787 return NULL; |
|
6788 } |
|
6789 |
|
6790 |
|
6791 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
6792 CleanupStack::PushL(recUtil); |
|
6793 |
|
6794 recUtil->OpenFileL(iFilename,iController); |
|
6795 |
|
6796 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
6797 CActiveScheduler::Start(); |
|
6798 |
|
6799 if(iError != KErrNone) |
|
6800 { |
|
6801 CleanupStack::PopAndDestroy(recUtil); |
|
6802 recUtil = NULL; |
|
6803 } |
|
6804 |
|
6805 return recUtil; |
|
6806 } |
|
6807 |
|
6808 TVerdict CTestMmfAclntRecNoPlaybackFileForceController::RecordSuccessfull() |
|
6809 { |
|
6810 TVerdict testStatus = EPass; |
|
6811 |
|
6812 if(iError == KErrNone) |
|
6813 { |
|
6814 RFs fs; |
|
6815 RFile file; |
|
6816 TInt size = 0; |
|
6817 |
|
6818 iError = fs.Connect(); |
|
6819 if (iError == KErrNone) |
|
6820 { |
|
6821 iError = file.Open(fs,iFilename,EFileRead); |
|
6822 |
|
6823 if (iError == KErrNone) |
|
6824 { |
|
6825 iError = file.Size(size); |
|
6826 |
|
6827 if (iError != KErrNone) |
|
6828 { |
|
6829 INFO_PRINTF1(_L("Unable to get size of file!")); |
|
6830 } |
|
6831 } |
|
6832 else |
|
6833 { |
|
6834 INFO_PRINTF1(_L("Unable to open file.")); |
|
6835 return EInconclusive; |
|
6836 } |
|
6837 |
|
6838 } |
|
6839 else |
|
6840 { |
|
6841 INFO_PRINTF1(_L("Unable to connect to file system.")); |
|
6842 return EInconclusive; |
|
6843 } |
|
6844 |
|
6845 if(size == 0) |
|
6846 { |
|
6847 testStatus = EFail; |
|
6848 } |
|
6849 |
|
6850 file.Close(); |
|
6851 fs.Close(); |
|
6852 CleanupStack::PopAndDestroy(); //file |
|
6853 } |
|
6854 else |
|
6855 testStatus = EFail; |
|
6856 |
|
6857 return testStatus; |
|
6858 } |
|
6859 |
|
6860 |
|
6861 |
|
6862 |
|
6863 CTestMmfAclntRecNoPlaybackDescForceController* CTestMmfAclntRecNoPlaybackDescForceController::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TUid aController) |
|
6864 { |
|
6865 CTestMmfAclntRecNoPlaybackDescForceController* self = new (ELeave) CTestMmfAclntRecNoPlaybackDescForceController(aTestName,aSectName,aKeyName,aController); |
|
6866 return self; |
|
6867 } |
|
6868 |
|
6869 CTestMmfAclntRecNoPlaybackDescForceController* CTestMmfAclntRecNoPlaybackDescForceController::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TUid aController) |
|
6870 { |
|
6871 CTestMmfAclntRecNoPlaybackDescForceController* self = CTestMmfAclntRecNoPlaybackDescForceController::NewLC(aTestName,aSectName,aKeyName,aController); |
|
6872 CleanupStack::PushL(self); |
|
6873 return self; |
|
6874 } |
|
6875 |
|
6876 |
|
6877 CMdaAudioRecorderUtility* CTestMmfAclntRecNoPlaybackDescForceController::CMdaAudioRecorderUtilityLC() |
|
6878 { |
|
6879 const TInt KMaxFileSize = 200000; |
|
6880 |
|
6881 INFO_PRINTF1( _L("Create CMdaAudioRecorderUtility with a descriptor, forcing record controller")); |
|
6882 |
|
6883 if(!GetStringFromConfig(iSectName, iKeyName, iFilename)) |
|
6884 { |
|
6885 User::Leave(KErrNotFound); |
|
6886 } |
|
6887 |
|
6888 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
6889 CleanupStack::PushL(recUtil); |
|
6890 |
|
6891 |
|
6892 HBufC8* iBuf = HBufC8::NewL( KMaxFileSize ); |
|
6893 CleanupStack::PushL(iBuf); |
|
6894 |
|
6895 iFileDesc = new (ELeave) TPtr8( NULL, 0 ); |
|
6896 CleanupStack::PushL(iFileDesc); |
|
6897 |
|
6898 iFileDesc->Set( iBuf->Des()); |
|
6899 |
|
6900 |
|
6901 //Put some contents (one sample wav file) into the descriptor |
|
6902 TPtrC oneSampleFileName; |
|
6903 if(!GetStringFromConfig(iSectName, _L("OneSampleFile"), oneSampleFileName)) |
|
6904 { |
|
6905 User::Leave(KErrNotFound); |
|
6906 } |
|
6907 |
|
6908 RFs fs; |
|
6909 RFile file; |
|
6910 User::LeaveIfError(fs.Connect()); |
|
6911 User::LeaveIfError(file.Open(fs,oneSampleFileName,EFileRead)); |
|
6912 CleanupClosePushL(file); |
|
6913 if(file.Read(*iFileDesc) != KErrNone) |
|
6914 { |
|
6915 User::Leave(KErrNotFound); |
|
6916 } |
|
6917 CleanupStack::PopAndDestroy(&file); |
|
6918 |
|
6919 |
|
6920 recUtil->OpenDesL(*iFileDesc, iController); |
|
6921 |
|
6922 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
6923 CActiveScheduler::Start(); |
|
6924 |
|
6925 if(iError != KErrNone) |
|
6926 { |
|
6927 User::Leave(KErrNotFound); |
|
6928 } |
|
6929 |
|
6930 CleanupStack::Pop(iFileDesc); |
|
6931 CleanupStack::Pop(iBuf); |
|
6932 return recUtil; |
|
6933 } |
|
6934 |
|
6935 TVerdict CTestMmfAclntRecNoPlaybackDescForceController::RecordSuccessfull() |
|
6936 { |
|
6937 TVerdict testStatus = EPass; |
|
6938 |
|
6939 TInt len = iFileDesc->Length(); |
|
6940 |
|
6941 if(len == 0) |
|
6942 { |
|
6943 testStatus = EFail; |
|
6944 } |
|
6945 |
|
6946 return testStatus; |
|
6947 } |
|
6948 |
|
6949 |
|
6950 |
|
6951 |
|
6952 |
|
6953 |
|
6954 |
|
6955 |
|
6956 //------------------------------------------------------------------ |
|
6957 /** |
|
6958 * Constructor baseclass |
|
6959 */ |
|
6960 CTestMmfAclntRecNoRecord::CTestMmfAclntRecNoRecord(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName) |
|
6961 { |
|
6962 // store the name of this test case |
|
6963 // this is the name that is used by the script file |
|
6964 // Each test step initialises it's own name |
|
6965 iTestStepName = aTestName; |
|
6966 iSectName = aSectName; |
|
6967 iKeyName = aKeyName; |
|
6968 } |
|
6969 |
|
6970 void CTestMmfAclntRecNoRecord::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt aCurrentState, TInt aErrorCode) |
|
6971 { |
|
6972 iError = aErrorCode; |
|
6973 INFO_PRINTF1( _L("CTestMmfAclntRecNoRecord : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete")); |
|
6974 INFO_PRINTF2( _L("iError %d "), iError); |
|
6975 |
|
6976 //dont stop the playing track |
|
6977 if (aCurrentState != CMdaAudioClipUtility::EPlaying || iError != KErrNone) |
|
6978 { |
|
6979 CActiveScheduler::Stop(); |
|
6980 } |
|
6981 } |
|
6982 |
|
6983 TVerdict CTestMmfAclntRecNoRecord::DoTestStepPreambleL() |
|
6984 { |
|
6985 // Make sure file exists |
|
6986 TParse fullFileName; |
|
6987 TBuf<KSizeBuf> filename; |
|
6988 TPtrC filename1; |
|
6989 |
|
6990 if(!GetStringFromConfig(iSectName, iKeyName, filename1)) |
|
6991 { |
|
6992 return EInconclusive; |
|
6993 } |
|
6994 |
|
6995 GetDriveName(filename); |
|
6996 filename.Append(filename1); |
|
6997 |
|
6998 |
|
6999 // parse the filenames |
|
7000 if(!fullFileName.Set(filename, &KDefault, NULL)) |
|
7001 { |
|
7002 RFs fs; |
|
7003 User::LeaveIfError(fs.Connect()); |
|
7004 RFile file; |
|
7005 User::LeaveIfError(file.Open(fs,filename1,EFileRead)); |
|
7006 file.Close(); |
|
7007 fs.Close(); |
|
7008 } |
|
7009 |
|
7010 return CTestMmfAclntStep::DoTestStepPreambleL(); |
|
7011 } |
|
7012 |
|
7013 |
|
7014 |
|
7015 |
|
7016 TVerdict CTestMmfAclntRecNoRecord::DoTestStepL() |
|
7017 { |
|
7018 TVerdict testStatus = EPass; |
|
7019 TInt trapRet = KErrNone; |
|
7020 TInt ret = KErrNone; |
|
7021 |
|
7022 const TInt durError = 2500; //As best as could be read from Goldwave |
|
7023 const TInt posError = 250; |
|
7024 const TInt MainTst_KDur = 8359100; //MainTst.wav = 8.3591 sec from GoldWave |
|
7025 |
|
7026 iRecorder = CMdaAudioRecorderUtilityLC(); |
|
7027 |
|
7028 if(!iRecorder) |
|
7029 { |
|
7030 testStatus = EFail; |
|
7031 } |
|
7032 |
|
7033 |
|
7034 //Should always work, must be done before play or record to ensure in EPrimed state |
|
7035 if(testStatus == EPass) |
|
7036 { |
|
7037 TRAP(trapRet,iRecorder->SetPriority(EMdaPriorityMin,EMdaPriorityPreferenceNone)); |
|
7038 if(trapRet != KErrNone) |
|
7039 { |
|
7040 INFO_PRINTF2(_L("SetPriority leave with error %d"),trapRet); |
|
7041 testStatus = EFail; |
|
7042 } |
|
7043 } |
|
7044 |
|
7045 |
|
7046 |
|
7047 if(testStatus == EPass) |
|
7048 { |
|
7049 iError = KErrTimedOut; |
|
7050 iRecorder->PlayL(); |
|
7051 INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility")); |
|
7052 CActiveScheduler::Start(); // open -> record |
|
7053 |
|
7054 testStatus = PlaySuccessfull(); |
|
7055 } |
|
7056 |
|
7057 |
|
7058 //Can't detect difference in these interfaces |
|
7059 //void ClearPlayWindow(); |
|
7060 //void SetRepeats(....); |
|
7061 //void Pause(); |
|
7062 //void SetMaxWriteLength(TInt aMaxWriteLength /*= KMdaClipLocationMaxWriteLengthNone*/); |
|
7063 //void SetVolume(TInt aVolume); |
|
7064 //void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration); |
|
7065 |
|
7066 |
|
7067 |
|
7068 |
|
7069 |
|
7070 |
|
7071 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
7072 //These interfaces should always WORK if there is a record or playback controller |
|
7073 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
7074 |
|
7075 |
|
7076 //if no rec controller, report playback duration. |
|
7077 if(testStatus == EPass) |
|
7078 { |
|
7079 TTimeIntervalMicroSeconds duration = iRecorder->Duration(); |
|
7080 |
|
7081 if((duration.Int64() > MainTst_KDur + durError) || |
|
7082 (duration.Int64() < MainTst_KDur - durError)) |
|
7083 { |
|
7084 INFO_PRINTF1(_L("Duration fail")); |
|
7085 testStatus = EFail; |
|
7086 } |
|
7087 } |
|
7088 |
|
7089 |
|
7090 //returns rec values if rec controller, else playback values |
|
7091 if(testStatus == EPass) |
|
7092 { |
|
7093 TTimeIntervalMicroSeconds setPosn(KTwoSeconds); |
|
7094 |
|
7095 iRecorder->SetPosition(setPosn); |
|
7096 TTimeIntervalMicroSeconds getPosn = iRecorder->Position(); |
|
7097 INFO_PRINTF3(_L("got position %d should be %d"),I64LOW(getPosn.Int64()), KTwoSeconds); |
|
7098 |
|
7099 if((getPosn.Int64() > KTwoSeconds+posError) || |
|
7100 (getPosn.Int64() < KTwoSeconds-posError)) |
|
7101 { |
|
7102 INFO_PRINTF1(_L("Position fail")); |
|
7103 testStatus = EFail; |
|
7104 } |
|
7105 } |
|
7106 |
|
7107 |
|
7108 |
|
7109 |
|
7110 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
7111 //These interfaces should FAIL if there is a playback controller, but no record controller |
|
7112 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
7113 |
|
7114 |
|
7115 if(testStatus == EPass) |
|
7116 { |
|
7117 TInt gain; |
|
7118 iRecorder->SetGain(1); |
|
7119 |
|
7120 ret = iRecorder->GetGain(gain); |
|
7121 if(ret != KErrNotSupported) |
|
7122 { |
|
7123 INFO_PRINTF1(_L("Gain fail")); |
|
7124 testStatus = EFail; |
|
7125 } |
|
7126 } |
|
7127 |
|
7128 if(testStatus == EPass) |
|
7129 { |
|
7130 TTimeIntervalMicroSeconds setPosn(KTwoSeconds); |
|
7131 iRecorder->SetPosition(setPosn); |
|
7132 |
|
7133 TRAP(trapRet, iRecorder->CropFromBeginningL()); |
|
7134 if(trapRet != KErrNotSupported) |
|
7135 { |
|
7136 INFO_PRINTF1(_L("Crop fail")); |
|
7137 testStatus = EFail; |
|
7138 } |
|
7139 } |
|
7140 |
|
7141 if(testStatus == EPass) |
|
7142 { |
|
7143 TTimeIntervalMicroSeconds zero(0); |
|
7144 |
|
7145 TTimeIntervalMicroSeconds recTimeAvail = iRecorder->RecordTimeAvailable(); |
|
7146 if(recTimeAvail != zero) |
|
7147 { |
|
7148 INFO_PRINTF1(_L("RecordTimeAvailable fail")); |
|
7149 testStatus = EFail; |
|
7150 } |
|
7151 } |
|
7152 |
|
7153 |
|
7154 if(testStatus == EPass) |
|
7155 { |
|
7156 TInt bal = KMMFBalanceMaxRight; |
|
7157 ret = iRecorder->SetRecordBalance(KMMFBalanceMaxLeft); |
|
7158 if(ret != KErrNotSupported) |
|
7159 { |
|
7160 INFO_PRINTF1(_L("SetRecordBalance test failed")); |
|
7161 testStatus = EFail; |
|
7162 } |
|
7163 |
|
7164 ret = iRecorder->GetRecordBalance(bal); |
|
7165 if(ret != KErrNotSupported) |
|
7166 { |
|
7167 INFO_PRINTF1(_L("GetRecordBalance test failed")); |
|
7168 testStatus = EFail; |
|
7169 } |
|
7170 } |
|
7171 |
|
7172 |
|
7173 //Haven't got a format that supports these - trace into code. |
|
7174 /* |
|
7175 if(testStatus == EPass) |
|
7176 { |
|
7177 TInt metaEntries; |
|
7178 CMMFMetaDataEntry* metaEntry = NULL; |
|
7179 CMMFMetaDataEntry* newMetaEntry = CMMFMetaDataEntry::NewL(_L("dummy meta"), _L("dummy val")); |
|
7180 |
|
7181 iRecorder->GetNumberOfMetaDataEntries(metaEntries); |
|
7182 TRAP(trapRet, metaEntry = iRecorder->GetMetaDataEntryL(1)); |
|
7183 TRAP(trapRet, iRecorder->AddMetaDataEntryL(*newMetaEntry)); |
|
7184 TRAP(trapRet, iRecorder->ReplaceMetaDataEntryL(1, *newMetaEntry)); |
|
7185 iRecorder->RemoveMetaDataEntry(1); |
|
7186 } |
|
7187 */ |
|
7188 |
|
7189 |
|
7190 if(testStatus == EPass) |
|
7191 { |
|
7192 RArray<TFourCC> codecs; |
|
7193 TRAP(trapRet, iRecorder->GetSupportedDestinationDataTypesL(codecs)); |
|
7194 if(trapRet != KErrNotSupported) |
|
7195 { |
|
7196 INFO_PRINTF1(_L("GetSupportedDestinationDataTypesL test failed")); |
|
7197 testStatus = EFail; |
|
7198 } |
|
7199 |
|
7200 TFourCC dataType; |
|
7201 TRAP(trapRet, iRecorder->SetDestinationDataTypeL(dataType)); |
|
7202 if(trapRet != KErrNotSupported) |
|
7203 { |
|
7204 INFO_PRINTF1(_L("SetDestinationDataTypeL test failed")); |
|
7205 testStatus = EFail; |
|
7206 } |
|
7207 |
|
7208 TRAP(trapRet, dataType = iRecorder->DestinationDataTypeL()); |
|
7209 if(trapRet != KErrNotSupported) |
|
7210 { |
|
7211 INFO_PRINTF1(_L("DestinationDataTypeL test failed")); |
|
7212 testStatus = EFail; |
|
7213 } |
|
7214 } |
|
7215 |
|
7216 |
|
7217 //These methods are not available for our formats and will therefore always fail - trace into code. |
|
7218 /* |
|
7219 if(testStatus == EPass) |
|
7220 { |
|
7221 RArray<TUint> bitRates; |
|
7222 TUint bitRate = 0; |
|
7223 |
|
7224 TRAP(trapRet, iRecorder->GetSupportedBitRatesL(bitRates)); |
|
7225 if((trapRet == KErrNone) && (bitRates.Count() >0)) |
|
7226 TRAP(trapRet, iRecorder->SetDestinationBitRateL(bitRates[0])); |
|
7227 if((trapRet == KErrNone) && (bitRates.Count() >0)) |
|
7228 TRAP(trapRet, bitRate = iRecorder->DestinationBitRateL()); |
|
7229 |
|
7230 if((trapRet != KErrNone) || (bitRate != bitRates[0])) |
|
7231 { |
|
7232 INFO_PRINTF1(_L("BitRates fail")); |
|
7233 testStatus = EFail; |
|
7234 } |
|
7235 } |
|
7236 */ |
|
7237 |
|
7238 if(testStatus == EPass) |
|
7239 { |
|
7240 RArray<TUint> sampleRates; |
|
7241 TUint sampleRate = 0; |
|
7242 |
|
7243 TRAP(trapRet, iRecorder->GetSupportedSampleRatesL(sampleRates)); |
|
7244 if(trapRet != KErrNotSupported) |
|
7245 { |
|
7246 INFO_PRINTF1(_L("GetSupportedSampleRatesL test failed")); |
|
7247 testStatus = EFail; |
|
7248 } |
|
7249 |
|
7250 sampleRate = 8000; |
|
7251 TRAP(trapRet, iRecorder->SetDestinationSampleRateL(sampleRate)); |
|
7252 if(trapRet != KErrNotSupported) |
|
7253 { |
|
7254 INFO_PRINTF1(_L("SetDestinationSampleRateL test failed")); |
|
7255 testStatus = EFail; |
|
7256 } |
|
7257 |
|
7258 TRAP(trapRet, sampleRate = iRecorder->DestinationSampleRateL()); |
|
7259 if(trapRet != KErrNotSupported) |
|
7260 { |
|
7261 INFO_PRINTF1(_L("DestinationSampleRateL test failed")); |
|
7262 testStatus = EFail; |
|
7263 } |
|
7264 } |
|
7265 |
|
7266 |
|
7267 |
|
7268 if(testStatus == EPass) |
|
7269 { |
|
7270 RArray<TUint> channels; |
|
7271 TUint channel = 0; |
|
7272 |
|
7273 TRAP(trapRet, iRecorder->GetSupportedNumberOfChannelsL(channels)); |
|
7274 if(trapRet != KErrNotSupported) |
|
7275 { |
|
7276 INFO_PRINTF1(_L("GetSupportedNumberOfChannelsL test failed")); |
|
7277 testStatus = EFail; |
|
7278 } |
|
7279 |
|
7280 |
|
7281 TRAP(trapRet, iRecorder->SetDestinationNumberOfChannelsL(1)); |
|
7282 if(trapRet != KErrNotSupported) |
|
7283 { |
|
7284 INFO_PRINTF1(_L("SetDestinationNumberOfChannelsL test failed")); |
|
7285 testStatus = EFail; |
|
7286 } |
|
7287 |
|
7288 TRAP(trapRet, channel=iRecorder->DestinationNumberOfChannelsL()); |
|
7289 if(trapRet != KErrNotSupported) |
|
7290 { |
|
7291 INFO_PRINTF2(_L("DestinationNumberOfChannelsL test failed with channel %d"), channel); |
|
7292 testStatus = EFail; |
|
7293 } |
|
7294 } |
|
7295 |
|
7296 |
|
7297 if(testStatus == EPass) |
|
7298 { |
|
7299 TUid currentFormat = KNullUid; |
|
7300 |
|
7301 TRAP(trapRet, currentFormat = iRecorder->DestinationFormatL()); |
|
7302 if(trapRet != KErrNotSupported) |
|
7303 { |
|
7304 INFO_PRINTF1(_L("DestinationFormatL test failed")); |
|
7305 testStatus = EFail; |
|
7306 } |
|
7307 |
|
7308 //NB: Can't do this test here, as it causes seg violation - trace into code |
|
7309 /* |
|
7310 TUid newFormat = {KMmfUidFormatRAWWrite}; |
|
7311 if(trapRet == KErrNone) |
|
7312 TRAP(trapRet, iRecorder->SetDestinationFormatL(newFormat)); |
|
7313 if(trapRet == KErrNone) |
|
7314 TRAP(trapRet, iRecorder->SetDestinationFormatL(currentFormat)); |
|
7315 */ |
|
7316 } |
|
7317 |
|
7318 |
|
7319 |
|
7320 if(testStatus == EPass) |
|
7321 { |
|
7322 TMMFMessageDestinationPckg dummyPckg; |
|
7323 TInt dummyFunc = 100; |
|
7324 TBuf8<8> dummyBuff; |
|
7325 |
|
7326 ret = iRecorder->RecordControllerCustomCommandSync(dummyPckg, dummyFunc, dummyBuff, dummyBuff, dummyBuff); |
|
7327 if(ret != KErrNotSupported) |
|
7328 { |
|
7329 INFO_PRINTF1(_L("RecordControllerCustomCommandSync - 1 fail")); |
|
7330 testStatus = EFail; |
|
7331 } |
|
7332 |
|
7333 ret = iRecorder->RecordControllerCustomCommandSync(dummyPckg, dummyFunc, dummyBuff, dummyBuff); |
|
7334 if(ret != KErrNotSupported) |
|
7335 { |
|
7336 INFO_PRINTF1(_L("RecordControllerCustomCommandSync -2 fail")); |
|
7337 testStatus = EFail; |
|
7338 } |
|
7339 |
|
7340 CTestMmfAclntAOCallback* aoCallback = new CTestMmfAclntAOCallback(this); |
|
7341 CleanupStack::PushL(aoCallback); |
|
7342 |
|
7343 aoCallback->PublicSetActive(); |
|
7344 iRecorder->RecordControllerCustomCommandAsync(dummyPckg, dummyFunc, dummyBuff, dummyBuff, dummyBuff, aoCallback->iStatus); |
|
7345 CActiveScheduler::Start(); |
|
7346 |
|
7347 if(iError != KErrNotSupported) |
|
7348 { |
|
7349 INFO_PRINTF1(_L("RecordControllerCustomCommandAsync -1 fail")); |
|
7350 testStatus = EFail; |
|
7351 } |
|
7352 |
|
7353 aoCallback->PublicSetActive(); |
|
7354 iRecorder->RecordControllerCustomCommandAsync(dummyPckg, dummyFunc, dummyBuff, dummyBuff, aoCallback->iStatus); |
|
7355 CActiveScheduler::Start(); |
|
7356 |
|
7357 if(iError != KErrNotSupported) |
|
7358 { |
|
7359 INFO_PRINTF1(_L("RecordControllerCustomCommandAsync -2 fail")); |
|
7360 testStatus = EFail; |
|
7361 } |
|
7362 |
|
7363 CleanupStack::Pop(aoCallback); |
|
7364 } |
|
7365 |
|
7366 |
|
7367 |
|
7368 |
|
7369 |
|
7370 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
7371 //These interfaces should PASS if there is a playback controller, but no record controller |
|
7372 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
7373 |
|
7374 |
|
7375 if(testStatus == EPass) |
|
7376 { |
|
7377 const TUint KPlayError = 500000; //1/2 second in play duration |
|
7378 |
|
7379 TTimeIntervalMicroSeconds duration = iRecorder->Duration(); |
|
7380 |
|
7381 iRecorder->SetPlayWindow(duration.Int64()/2, duration); |
|
7382 |
|
7383 iError = KErrTimedOut; |
|
7384 iRecorder->PlayL(); |
|
7385 |
|
7386 TTime startTime; startTime.UniversalTime(); |
|
7387 |
|
7388 CActiveScheduler::Start(); |
|
7389 |
|
7390 TTime endTime; endTime.UniversalTime(); |
|
7391 |
|
7392 TInt64 playTime = endTime.Int64() - startTime.Int64(); |
|
7393 |
|
7394 INFO_PRINTF3(_L("Expected to play for %d Usec, played for %d Usec"), I64LOW(duration.Int64()/2), I64LOW(playTime)); |
|
7395 |
|
7396 if((I64LOW(playTime) > I64LOW(duration.Int64()/2 + KPlayError)) || |
|
7397 (I64LOW(playTime) < I64LOW(duration.Int64()/2 - KPlayError))) |
|
7398 { |
|
7399 INFO_PRINTF1(_L("SetPlayWindow fail")); |
|
7400 testStatus = EFail; |
|
7401 } |
|
7402 else |
|
7403 { |
|
7404 testStatus = PlaySuccessfull(); |
|
7405 } |
|
7406 } |
|
7407 |
|
7408 if(testStatus == EPass) |
|
7409 { |
|
7410 TInt maxVol = iRecorder->MaxVolume(); |
|
7411 if(maxVol > 0) |
|
7412 { |
|
7413 iRecorder->SetVolume(maxVol/2); |
|
7414 TInt vol; |
|
7415 ret = iRecorder->GetVolume(vol); |
|
7416 if((ret != KErrNone) || (vol != maxVol/2)) |
|
7417 { |
|
7418 INFO_PRINTF1(_L("GetVolume fail")); |
|
7419 testStatus = EFail; |
|
7420 } |
|
7421 } |
|
7422 else |
|
7423 { |
|
7424 INFO_PRINTF1(_L("MaxVolume fail")); |
|
7425 testStatus = EFail; |
|
7426 } |
|
7427 |
|
7428 } |
|
7429 |
|
7430 if(testStatus == EPass) |
|
7431 { |
|
7432 TInt bal; |
|
7433 TInt ret = iRecorder->SetPlaybackBalance(KMMFBalanceMaxRight); |
|
7434 if(ret == KErrNone) |
|
7435 { |
|
7436 ret = iRecorder->GetPlaybackBalance(bal); |
|
7437 if((ret != KErrNone) || (bal != KMMFBalanceMaxRight)) |
|
7438 { |
|
7439 INFO_PRINTF1(_L("GetPlaybackBalance fail")); |
|
7440 testStatus = EFail; |
|
7441 } |
|
7442 } |
|
7443 else |
|
7444 { |
|
7445 INFO_PRINTF1(_L("SetPlaybackBalance fail")); |
|
7446 testStatus = EFail; |
|
7447 } |
|
7448 } |
|
7449 |
|
7450 |
|
7451 |
|
7452 // These would pass when a playback controller is present, also need test controller |
|
7453 // TInt PlayControllerCustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom); |
|
7454 // TInt PlayControllerCustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2); |
|
7455 // void PlayControllerCustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus); |
|
7456 // void PlayControllerCustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus); |
|
7457 |
|
7458 CleanupStack::PopAndDestroy(iRecorder); |
|
7459 User::After(KOneSecond); |
|
7460 return testStatus; |
|
7461 } |
|
7462 |
|
7463 |
|
7464 |
|
7465 |
|
7466 |
|
7467 |
|
7468 |
|
7469 |
|
7470 |
|
7471 |
|
7472 |
|
7473 |
|
7474 |
|
7475 |
|
7476 //------------------------------------------------------------------ |
|
7477 |
|
7478 /** |
|
7479 * Constructor |
|
7480 */ |
|
7481 |
|
7482 CTestMmfAclntRecNoRecordForceFormat::CTestMmfAclntRecNoRecordForceFormat(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TMdaClipFormat& aFormat) |
|
7483 : CTestMmfAclntRecNoRecord(aTestName, aSectName, aKeyName) |
|
7484 { |
|
7485 iFormat = aFormat; |
|
7486 } |
|
7487 |
|
7488 CTestMmfAclntRecNoRecordForceFormat* CTestMmfAclntRecNoRecordForceFormat::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TMdaClipFormat& aFormat) |
|
7489 { |
|
7490 CTestMmfAclntRecNoRecordForceFormat* self = new (ELeave) CTestMmfAclntRecNoRecordForceFormat(aTestName,aSectName,aKeyName,aFormat); |
|
7491 return self; |
|
7492 } |
|
7493 |
|
7494 CTestMmfAclntRecNoRecordForceFormat* CTestMmfAclntRecNoRecordForceFormat::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TMdaClipFormat& aFormat) |
|
7495 { |
|
7496 CTestMmfAclntRecNoRecordForceFormat* self = CTestMmfAclntRecNoRecordForceFormat::NewLC(aTestName,aSectName,aKeyName,aFormat); |
|
7497 CleanupStack::PushL(self); |
|
7498 return self; |
|
7499 } |
|
7500 |
|
7501 |
|
7502 |
|
7503 |
|
7504 CMdaAudioRecorderUtility* CTestMmfAclntRecNoRecordForceFormat::CMdaAudioRecorderUtilityLC() |
|
7505 { |
|
7506 if(!GetStringFromConfig(iSectName, iKeyName, iFilename)) |
|
7507 return NULL; |
|
7508 |
|
7509 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
7510 CleanupStack::PushL(recUtil); |
|
7511 |
|
7512 TMdaFileClipLocation location(iFilename); |
|
7513 |
|
7514 recUtil->OpenL(&location,&iFormat); |
|
7515 |
|
7516 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
7517 CActiveScheduler::Start(); |
|
7518 |
|
7519 if(iError != KErrNone) |
|
7520 { |
|
7521 CleanupStack::PopAndDestroy(recUtil); |
|
7522 recUtil = NULL; |
|
7523 } |
|
7524 |
|
7525 return recUtil; |
|
7526 } |
|
7527 |
|
7528 TVerdict CTestMmfAclntRecNoRecordForceFormat::PlaySuccessfull() |
|
7529 { |
|
7530 TVerdict testStatus = EPass; |
|
7531 |
|
7532 if(iError != KErrNone) |
|
7533 { |
|
7534 testStatus = EFail; |
|
7535 } |
|
7536 |
|
7537 return testStatus; |
|
7538 } |
|
7539 |
|
7540 |
|
7541 |
|
7542 |
|
7543 CTestMmfAclntRecNoRecordForceFormatDesc* CTestMmfAclntRecNoRecordForceFormatDesc::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TMdaClipFormat& aFormat) |
|
7544 { |
|
7545 CTestMmfAclntRecNoRecordForceFormatDesc* self = new (ELeave) CTestMmfAclntRecNoRecordForceFormatDesc(aTestName,aSectName,aKeyName,aFormat); |
|
7546 return self; |
|
7547 } |
|
7548 |
|
7549 CTestMmfAclntRecNoRecordForceFormatDesc* CTestMmfAclntRecNoRecordForceFormatDesc::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TMdaClipFormat& aFormat) |
|
7550 { |
|
7551 CTestMmfAclntRecNoRecordForceFormatDesc* self = CTestMmfAclntRecNoRecordForceFormatDesc::NewLC(aTestName,aSectName,aKeyName,aFormat); |
|
7552 CleanupStack::PushL(self); |
|
7553 return self; |
|
7554 } |
|
7555 |
|
7556 |
|
7557 CMdaAudioRecorderUtility* CTestMmfAclntRecNoRecordForceFormatDesc::CMdaAudioRecorderUtilityLC() |
|
7558 { |
|
7559 if(!GetStringFromConfig(iSectName, iKeyName, iFilename)) |
|
7560 { |
|
7561 User::Leave(KErrNotFound); |
|
7562 } |
|
7563 |
|
7564 |
|
7565 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
7566 CleanupStack::PushL(recUtil); |
|
7567 |
|
7568 |
|
7569 RFs fs; |
|
7570 RFile file; |
|
7571 TInt size = 0; |
|
7572 |
|
7573 User::LeaveIfError(fs.Connect()); |
|
7574 User::LeaveIfError(file.Open(fs,iFilename,EFileRead)); |
|
7575 CleanupClosePushL(file); |
|
7576 User::LeaveIfError(file.Size(size)); |
|
7577 |
|
7578 if(size == 0) |
|
7579 { |
|
7580 User::Leave(KErrNotFound); |
|
7581 } |
|
7582 |
|
7583 HBufC8* iBuf = HBufC8::NewL( size ); |
|
7584 CleanupStack::PushL(iBuf); |
|
7585 |
|
7586 iFileDesc = new (ELeave) TPtr8( NULL, 0 ); |
|
7587 CleanupStack::PushL(iFileDesc); |
|
7588 |
|
7589 iFileDesc->Set( iBuf->Des()); |
|
7590 |
|
7591 if(file.Read(*iFileDesc) != KErrNone) |
|
7592 { |
|
7593 User::Leave(KErrNotFound); |
|
7594 } |
|
7595 |
|
7596 TMdaDesClipLocation location(*iFileDesc); |
|
7597 |
|
7598 recUtil->OpenL(&location,&iFormat); |
|
7599 |
|
7600 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
7601 CActiveScheduler::Start(); |
|
7602 |
|
7603 if(iError != KErrNone) |
|
7604 { |
|
7605 User::Leave(KErrNotFound); |
|
7606 } |
|
7607 |
|
7608 CleanupStack::Pop(iFileDesc); |
|
7609 CleanupStack::Pop(iBuf); |
|
7610 CleanupStack::PopAndDestroy(&file); |
|
7611 return recUtil; |
|
7612 } |
|
7613 |
|
7614 |
|
7615 TVerdict CTestMmfAclntRecNoRecordForceFormatDesc::PlaySuccessfull() |
|
7616 { |
|
7617 TVerdict testStatus = EPass; |
|
7618 |
|
7619 if(iError != KErrNone) |
|
7620 { |
|
7621 testStatus = EFail; |
|
7622 } |
|
7623 |
|
7624 return testStatus; |
|
7625 } |
|
7626 |
|
7627 |
|
7628 //------------------------------------------------------------------ |
|
7629 |
|
7630 |
|
7631 CTestMmfAclntRecNoRecordFile* CTestMmfAclntRecNoRecordFile::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName) |
|
7632 { |
|
7633 CTestMmfAclntRecNoRecordFile* self = new (ELeave) CTestMmfAclntRecNoRecordFile(aTestName,aSectName,aKeyName); |
|
7634 return self; |
|
7635 } |
|
7636 |
|
7637 CTestMmfAclntRecNoRecordFile* CTestMmfAclntRecNoRecordFile::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName) |
|
7638 { |
|
7639 CTestMmfAclntRecNoRecordFile* self = CTestMmfAclntRecNoRecordFile::NewLC(aTestName,aSectName,aKeyName); |
|
7640 CleanupStack::PushL(self); |
|
7641 return self; |
|
7642 } |
|
7643 |
|
7644 |
|
7645 CMdaAudioRecorderUtility* CTestMmfAclntRecNoRecordFile::CMdaAudioRecorderUtilityLC() |
|
7646 { |
|
7647 INFO_PRINTF1( _L("Create CMdaAudioRecorderUtility with a file")); |
|
7648 |
|
7649 if(!GetStringFromConfig(iSectName, iKeyName, iFilename)) |
|
7650 { |
|
7651 return NULL; |
|
7652 } |
|
7653 |
|
7654 |
|
7655 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
7656 CleanupStack::PushL(recUtil); |
|
7657 |
|
7658 recUtil->OpenFileL(iFilename); |
|
7659 |
|
7660 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
7661 CActiveScheduler::Start(); |
|
7662 |
|
7663 if(iError != KErrNone) |
|
7664 { |
|
7665 CleanupStack::PopAndDestroy(recUtil); |
|
7666 recUtil = NULL; |
|
7667 } |
|
7668 |
|
7669 return recUtil; |
|
7670 } |
|
7671 |
|
7672 TVerdict CTestMmfAclntRecNoRecordFile::PlaySuccessfull() |
|
7673 { |
|
7674 TVerdict testStatus = EPass; |
|
7675 |
|
7676 if(iError != KErrNone) |
|
7677 { |
|
7678 testStatus = EFail; |
|
7679 } |
|
7680 |
|
7681 return testStatus; |
|
7682 } |
|
7683 |
|
7684 |
|
7685 |
|
7686 |
|
7687 CTestMmfAclntRecNoRecordDesc* CTestMmfAclntRecNoRecordDesc::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName) |
|
7688 { |
|
7689 CTestMmfAclntRecNoRecordDesc* self = new (ELeave) CTestMmfAclntRecNoRecordDesc(aTestName,aSectName,aKeyName); |
|
7690 return self; |
|
7691 } |
|
7692 |
|
7693 CTestMmfAclntRecNoRecordDesc* CTestMmfAclntRecNoRecordDesc::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName) |
|
7694 { |
|
7695 CTestMmfAclntRecNoRecordDesc* self = CTestMmfAclntRecNoRecordDesc::NewLC(aTestName,aSectName,aKeyName); |
|
7696 CleanupStack::PushL(self); |
|
7697 return self; |
|
7698 } |
|
7699 |
|
7700 |
|
7701 CMdaAudioRecorderUtility* CTestMmfAclntRecNoRecordDesc::CMdaAudioRecorderUtilityLC() |
|
7702 { |
|
7703 INFO_PRINTF1( _L("Create CMdaAudioRecorderUtility with a descriptor")); |
|
7704 |
|
7705 if(!GetStringFromConfig(iSectName, iKeyName, iFilename)) |
|
7706 { |
|
7707 User::Leave(KErrNotFound); |
|
7708 } |
|
7709 |
|
7710 |
|
7711 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
7712 CleanupStack::PushL(recUtil); |
|
7713 |
|
7714 |
|
7715 RFs fs; |
|
7716 RFile file; |
|
7717 User::LeaveIfError(fs.Connect()); |
|
7718 User::LeaveIfError(file.Open(fs,iFilename,EFileRead)); |
|
7719 CleanupClosePushL(file); |
|
7720 |
|
7721 TInt size; |
|
7722 User::LeaveIfError(file.Size(size)); |
|
7723 |
|
7724 if(size == 0) |
|
7725 { |
|
7726 User::Leave(KErrNotFound); |
|
7727 } |
|
7728 |
|
7729 |
|
7730 HBufC8* iBuf = HBufC8::NewL( size ); |
|
7731 CleanupStack::PushL(iBuf); |
|
7732 |
|
7733 iFileDesc = new (ELeave) TPtr8( NULL, 0 ); |
|
7734 CleanupStack::PushL(iFileDesc); |
|
7735 |
|
7736 iFileDesc->Set( iBuf->Des()); |
|
7737 |
|
7738 if(file.Read(*iFileDesc) != KErrNone) |
|
7739 { |
|
7740 User::Leave(KErrNotFound); |
|
7741 } |
|
7742 |
|
7743 |
|
7744 recUtil->OpenDesL(*iFileDesc); |
|
7745 |
|
7746 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
7747 CActiveScheduler::Start(); |
|
7748 |
|
7749 if(iError != KErrNone) |
|
7750 { |
|
7751 User::Leave(KErrNotFound); |
|
7752 } |
|
7753 |
|
7754 CleanupStack::Pop(iFileDesc); |
|
7755 CleanupStack::Pop(iBuf); |
|
7756 CleanupStack::PopAndDestroy(&file); |
|
7757 return recUtil; |
|
7758 } |
|
7759 |
|
7760 TVerdict CTestMmfAclntRecNoRecordDesc::PlaySuccessfull() |
|
7761 { |
|
7762 TVerdict testStatus = EPass; |
|
7763 |
|
7764 if(iError != KErrNone) |
|
7765 { |
|
7766 testStatus = EFail; |
|
7767 } |
|
7768 |
|
7769 return testStatus; |
|
7770 } |
|
7771 |
|
7772 |
|
7773 |
|
7774 |
|
7775 CTestMmfAclntRecNoRecordFileForceController* CTestMmfAclntRecNoRecordFileForceController::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TUid aController) |
|
7776 { |
|
7777 CTestMmfAclntRecNoRecordFileForceController* self = new (ELeave) CTestMmfAclntRecNoRecordFileForceController(aTestName,aSectName,aKeyName, aController); |
|
7778 return self; |
|
7779 } |
|
7780 |
|
7781 CTestMmfAclntRecNoRecordFileForceController* CTestMmfAclntRecNoRecordFileForceController::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TUid aController) |
|
7782 { |
|
7783 CTestMmfAclntRecNoRecordFileForceController* self = CTestMmfAclntRecNoRecordFileForceController::NewLC(aTestName,aSectName,aKeyName,aController); |
|
7784 CleanupStack::PushL(self); |
|
7785 return self; |
|
7786 } |
|
7787 |
|
7788 |
|
7789 CMdaAudioRecorderUtility* CTestMmfAclntRecNoRecordFileForceController::CMdaAudioRecorderUtilityLC() |
|
7790 { |
|
7791 INFO_PRINTF1( _L("Create CMdaAudioRecorderUtility with a file, forcing record controller")); |
|
7792 |
|
7793 if(!GetStringFromConfig(iSectName, iKeyName, iFilename)) |
|
7794 { |
|
7795 return NULL; |
|
7796 } |
|
7797 |
|
7798 |
|
7799 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
7800 CleanupStack::PushL(recUtil); |
|
7801 |
|
7802 recUtil->OpenFileL(iFilename, KNullUid, iController); |
|
7803 |
|
7804 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
7805 CActiveScheduler::Start(); |
|
7806 |
|
7807 if(iError != KErrNone) |
|
7808 { |
|
7809 CleanupStack::PopAndDestroy(recUtil); |
|
7810 recUtil = NULL; |
|
7811 } |
|
7812 |
|
7813 return recUtil; |
|
7814 } |
|
7815 |
|
7816 TVerdict CTestMmfAclntRecNoRecordFileForceController::PlaySuccessfull() |
|
7817 { |
|
7818 TVerdict testStatus = EPass; |
|
7819 |
|
7820 if(iError != KErrNone) |
|
7821 { |
|
7822 testStatus = EFail; |
|
7823 } |
|
7824 |
|
7825 |
|
7826 return testStatus; |
|
7827 } |
|
7828 |
|
7829 |
|
7830 CTestMmfAclntRecNoRecordDescForceController* CTestMmfAclntRecNoRecordDescForceController::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TUid aController) |
|
7831 { |
|
7832 CTestMmfAclntRecNoRecordDescForceController* self = new (ELeave) CTestMmfAclntRecNoRecordDescForceController(aTestName,aSectName,aKeyName,aController); |
|
7833 return self; |
|
7834 } |
|
7835 |
|
7836 CTestMmfAclntRecNoRecordDescForceController* CTestMmfAclntRecNoRecordDescForceController::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TUid aController) |
|
7837 { |
|
7838 CTestMmfAclntRecNoRecordDescForceController* self = CTestMmfAclntRecNoRecordDescForceController::NewLC(aTestName,aSectName,aKeyName,aController); |
|
7839 CleanupStack::PushL(self); |
|
7840 return self; |
|
7841 } |
|
7842 |
|
7843 |
|
7844 CMdaAudioRecorderUtility* CTestMmfAclntRecNoRecordDescForceController::CMdaAudioRecorderUtilityLC() |
|
7845 { |
|
7846 INFO_PRINTF1( _L("Create CMdaAudioRecorderUtility with a descriptor, forcing record controller")); |
|
7847 |
|
7848 if(!GetStringFromConfig(iSectName, iKeyName, iFilename)) |
|
7849 { |
|
7850 User::Leave(KErrNotFound); |
|
7851 } |
|
7852 |
|
7853 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
7854 CleanupStack::PushL(recUtil); |
|
7855 |
|
7856 |
|
7857 RFs fs; |
|
7858 RFile file; |
|
7859 User::LeaveIfError(fs.Connect()); |
|
7860 User::LeaveIfError(file.Open(fs,iFilename,EFileRead)); |
|
7861 CleanupClosePushL(file); |
|
7862 |
|
7863 TInt size; |
|
7864 User::LeaveIfError(file.Size(size)); |
|
7865 |
|
7866 if(size == 0) |
|
7867 { |
|
7868 User::Leave(KErrNotFound); |
|
7869 } |
|
7870 |
|
7871 |
|
7872 |
|
7873 HBufC8* iBuf = HBufC8::NewL( size ); |
|
7874 CleanupStack::PushL(iBuf); |
|
7875 |
|
7876 iFileDesc = new (ELeave) TPtr8( NULL, 0 ); |
|
7877 CleanupStack::PushL(iFileDesc); |
|
7878 |
|
7879 iFileDesc->Set( iBuf->Des()); |
|
7880 |
|
7881 if(file.Read(*iFileDesc) != KErrNone) |
|
7882 { |
|
7883 User::Leave(KErrNotFound); |
|
7884 } |
|
7885 |
|
7886 |
|
7887 recUtil->OpenDesL(*iFileDesc, KNullUid, iController); |
|
7888 |
|
7889 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
7890 CActiveScheduler::Start(); |
|
7891 |
|
7892 if(iError != KErrNone) |
|
7893 { |
|
7894 User::Leave(KErrNotFound); |
|
7895 } |
|
7896 |
|
7897 CleanupStack::Pop(iFileDesc); |
|
7898 CleanupStack::Pop(iBuf); |
|
7899 CleanupStack::PopAndDestroy(&file); |
|
7900 return recUtil; |
|
7901 } |
|
7902 |
|
7903 TVerdict CTestMmfAclntRecNoRecordDescForceController::PlaySuccessfull() |
|
7904 { |
|
7905 TVerdict testStatus = EPass; |
|
7906 |
|
7907 if(iError != KErrNone) |
|
7908 { |
|
7909 testStatus = EFail; |
|
7910 } |
|
7911 |
|
7912 return testStatus; |
|
7913 } |
|
7914 |
|
7915 |
|
7916 |
|
7917 //------------------------------------------------------------------ |
|
7918 |
|
7919 /** |
|
7920 * Constructor |
|
7921 */ |
|
7922 CTestMmfAclntRecFileAppend::CTestMmfAclntRecFileAppend(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TFormatType aFormatType, TCodecType aCodecType, TBool aDiffSampleRate) |
|
7923 { |
|
7924 // store the name of this test case |
|
7925 // this is the name that is used by the script file |
|
7926 // Each test step initialises it's own name |
|
7927 iTestStepName = aTestName; |
|
7928 iSectName = aSectName; |
|
7929 iKeyName = aKeyName; |
|
7930 iFormatType = aFormatType; |
|
7931 iCodecType = aCodecType; |
|
7932 iDiffSampleRate = aDiffSampleRate; |
|
7933 } |
|
7934 |
|
7935 CTestMmfAclntRecFileAppend* CTestMmfAclntRecFileAppend::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TFormatType aFormatType, TCodecType aCodecType, TBool aDiffSampleRate) |
|
7936 { |
|
7937 CTestMmfAclntRecFileAppend* self = new (ELeave) CTestMmfAclntRecFileAppend(aTestName, aSectName, aKeyName, aFormatType, aCodecType, aDiffSampleRate); |
|
7938 return self; |
|
7939 } |
|
7940 |
|
7941 void CTestMmfAclntRecFileAppend::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt aCurrentState, TInt aErrorCode) |
|
7942 { |
|
7943 iError = aErrorCode; |
|
7944 iCurrentState = aCurrentState; |
|
7945 INFO_PRINTF3( _L("MoscoStateChangeEvent: aCurrentState = %d, iError %d "), iCurrentState, iError); |
|
7946 |
|
7947 CActiveScheduler::Stop(); |
|
7948 } |
|
7949 |
|
7950 |
|
7951 TVerdict CTestMmfAclntRecFileAppend::DoTestStepPreambleL() |
|
7952 { |
|
7953 TVerdict ret = EPass; |
|
7954 |
|
7955 // Make sure file doesn't exist (maybe from a previous test) |
|
7956 TParse fullFileName; |
|
7957 TBuf<KSizeBuf> filename; |
|
7958 TPtrC filename1; |
|
7959 |
|
7960 if(!GetStringFromConfig(iSectName, iKeyName, filename1)) |
|
7961 { |
|
7962 return EInconclusive; |
|
7963 } |
|
7964 |
|
7965 |
|
7966 GetDriveName(filename); |
|
7967 filename.Append(filename1); |
|
7968 |
|
7969 |
|
7970 // parse the filenames |
|
7971 if(!fullFileName.Set(filename, &KDefault, NULL)) |
|
7972 { |
|
7973 RFs fs; |
|
7974 User::LeaveIfError(fs.Connect()); |
|
7975 fs.SetAtt(fullFileName.FullName(), 0, KEntryAttReadOnly); |
|
7976 TInt error = fs.Delete(fullFileName.FullName()); |
|
7977 |
|
7978 if(error == KErrPathNotFound) |
|
7979 { |
|
7980 error = fs.MkDirAll(fullFileName.DriveAndPath()); |
|
7981 INFO_PRINTF2(_L("Path for file %S was been created"), &fullFileName.FullName()); |
|
7982 } |
|
7983 else if(error == KErrNotFound) |
|
7984 INFO_PRINTF2(_L("No need to delete %S"), &fullFileName.FullName()); |
|
7985 else if(error==KErrNone) |
|
7986 INFO_PRINTF2(_L("Deleted %S"), &fullFileName.FullName()); |
|
7987 else |
|
7988 { |
|
7989 ret = EInconclusive; |
|
7990 } |
|
7991 fs.Close(); |
|
7992 } |
|
7993 |
|
7994 if((ret == EInconclusive) || (ret == EFail)) |
|
7995 return ret; |
|
7996 return CTestMmfAclntStep::DoTestStepPreambleL(); |
|
7997 } |
|
7998 |
|
7999 |
|
8000 const TInt KSeventyFive = 75; |
|
8001 const TInt KTwentyFive = 25; |
|
8002 const TInt KOneHundred = 100; |
|
8003 |
|
8004 /** |
|
8005 * Open a file based clip and record, stop & then record again |
|
8006 */ |
|
8007 |
|
8008 |
|
8009 TVerdict CTestMmfAclntRecFileAppend::DoTestStepL() |
|
8010 { |
|
8011 INFO_PRINTF1( _L("TestRecorder : Record File")); |
|
8012 TVerdict ret = EPass; |
|
8013 iError = KErrGeneral; // set error to ensure callback takes place |
|
8014 |
|
8015 TInt size1 = 0; // size of file after first record |
|
8016 TInt size2 = 0; // size of file after append |
|
8017 |
|
8018 TPtrC filename; |
|
8019 if(!GetStringFromConfig(iSectName, iKeyName, filename)) |
|
8020 return EInconclusive; |
|
8021 |
|
8022 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
8023 CleanupStack::PushL(recUtil); |
|
8024 |
|
8025 TMdaFileClipLocation location(filename); |
|
8026 |
|
8027 RFs fs; |
|
8028 fs.Connect(); |
|
8029 fs.Delete(filename); |
|
8030 fs.Close(); |
|
8031 |
|
8032 for (TInt index=0; index<2; index++) |
|
8033 { |
|
8034 if (index == 0) |
|
8035 INFO_PRINTF1(_L("Recording to file...")); |
|
8036 else |
|
8037 INFO_PRINTF1(_L("Appending to file...")); |
|
8038 |
|
8039 TMdaWavClipFormat mdaWavFormat; |
|
8040 TMdaAuClipFormat mdaAuFormat; |
|
8041 TMdaClipFormat* format = NULL; |
|
8042 |
|
8043 TMdaImaAdpcmWavCodec wavImadCodec; |
|
8044 TMdaPcmWavCodec wav8PcmCodec; |
|
8045 TMdaPcm8BitAuCodec au8PcmCodec; |
|
8046 |
|
8047 TMdaPackage* codec = NULL; |
|
8048 |
|
8049 switch (iFormatType) |
|
8050 { |
|
8051 case EWavFormat: |
|
8052 format = &mdaWavFormat; |
|
8053 switch (iCodecType) |
|
8054 { |
|
8055 case EAdpcmCodec: |
|
8056 codec = &wavImadCodec; |
|
8057 break; |
|
8058 case EPcmCodec: |
|
8059 codec = &wav8PcmCodec; |
|
8060 break; |
|
8061 } |
|
8062 break; |
|
8063 case EAuFormat: |
|
8064 format = &mdaAuFormat; |
|
8065 switch (iCodecType) |
|
8066 { |
|
8067 case EPcmCodec: |
|
8068 codec = &au8PcmCodec; |
|
8069 break; |
|
8070 default: |
|
8071 break; |
|
8072 } |
|
8073 break; |
|
8074 } |
|
8075 |
|
8076 if (format == NULL || codec == NULL) |
|
8077 { |
|
8078 ret = EInconclusive; |
|
8079 break; |
|
8080 } |
|
8081 |
|
8082 TMdaAudioDataSettings audioSettings; |
|
8083 audioSettings.iCaps = |
|
8084 TMdaAudioDataSettings::ESampleRateFixed | |
|
8085 TMdaAudioDataSettings::EChannelsMono | |
|
8086 TMdaAudioDataSettings::ESampleRate8000Hz | |
|
8087 TMdaAudioDataSettings::ESampleRate11025Hz; |
|
8088 |
|
8089 audioSettings.iSampleRate = KSampleRate8K; |
|
8090 audioSettings.iChannels = 1; |
|
8091 audioSettings.iFlags = TMdaAudioDataSettings::ENoNetworkRouting; |
|
8092 if (index == 1 && iDiffSampleRate) |
|
8093 { |
|
8094 audioSettings.iSampleRate = KSampleRate11K; |
|
8095 } |
|
8096 |
|
8097 |
|
8098 recUtil->OpenL(&location, format, codec, &audioSettings); |
|
8099 |
|
8100 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
8101 CActiveScheduler::Start(); // idle -> open |
|
8102 |
|
8103 if(iError != KErrNone) |
|
8104 { |
|
8105 break; |
|
8106 } |
|
8107 |
|
8108 iError = KErrTimedOut; |
|
8109 recUtil->RecordL(); |
|
8110 INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility")); |
|
8111 CActiveScheduler::Start(); // open -> record |
|
8112 |
|
8113 User::After(KTwoSeconds); |
|
8114 |
|
8115 if (iCurrentState != CMdaAudioClipUtility::ERecording) |
|
8116 { |
|
8117 INFO_PRINTF1( _L("CMdaAudioRecorderUtility is not recording")); |
|
8118 ret = EFail; |
|
8119 break; |
|
8120 } |
|
8121 |
|
8122 recUtil->Stop(); |
|
8123 |
|
8124 |
|
8125 if (index == 1) |
|
8126 { |
|
8127 TTimeIntervalMicroSeconds actualDuration; |
|
8128 TTimeIntervalMicroSeconds expectedDuration(KFourSeconds); |
|
8129 actualDuration = recUtil->Duration(); |
|
8130 INFO_PRINTF3(_L("Duration recorded file, expected = %f, actual: %f"), |
|
8131 I64REAL(expectedDuration.Int64()), I64REAL(actualDuration.Int64())); |
|
8132 // allow a deviation of 25% |
|
8133 if (actualDuration.Int64() < expectedDuration.Int64() * KSeventyFive / KOneHundred) |
|
8134 { |
|
8135 ERR_PRINTF1(_L("Appended duration is too short")); |
|
8136 ret = EFail; |
|
8137 } |
|
8138 else if (actualDuration.Int64() > expectedDuration.Int64() * (KOneHundred+KTwentyFive) / KOneHundred) |
|
8139 { |
|
8140 ERR_PRINTF1(_L("Appended duration is too long")); |
|
8141 ret = EFail; |
|
8142 } |
|
8143 } |
|
8144 |
|
8145 |
|
8146 |
|
8147 recUtil->Close(); |
|
8148 |
|
8149 if(iError == KErrNone) |
|
8150 { |
|
8151 RFs fs; |
|
8152 RFile file; |
|
8153 TInt size = 0; |
|
8154 |
|
8155 User::LeaveIfError(fs.Connect()); |
|
8156 User::LeaveIfError(file.Open(fs,filename,EFileRead)); |
|
8157 CleanupClosePushL(file); |
|
8158 User::LeaveIfError(file.Size(size)); |
|
8159 INFO_PRINTF2(_L("File size = %d"), size); |
|
8160 |
|
8161 if(size <= 0) |
|
8162 { |
|
8163 ret = EFail; |
|
8164 } |
|
8165 |
|
8166 CleanupStack::PopAndDestroy(&file); |
|
8167 |
|
8168 if (index == 0) |
|
8169 { |
|
8170 size1 = size; |
|
8171 } |
|
8172 |
|
8173 else |
|
8174 { |
|
8175 size2 = size; |
|
8176 } |
|
8177 |
|
8178 } |
|
8179 } |
|
8180 |
|
8181 if (iError != KErrNone) |
|
8182 { |
|
8183 ret = EFail; |
|
8184 } |
|
8185 |
|
8186 |
|
8187 // the appended size should be double the original size |
|
8188 // but to allow a little deviation, ensure it's at least 1.5 times bigger |
|
8189 if (ret == EPass) |
|
8190 { |
|
8191 if (size2 < (size1*(KOneHundred+KSeventyFive)/KOneHundred)) |
|
8192 { |
|
8193 ERR_PRINTF1(_L("Appended file size is too short")); |
|
8194 ret = EFail; |
|
8195 } |
|
8196 else if (size2 > (size1*(KOneHundred+KOneHundred+KTwentyFive)/KOneHundred)) |
|
8197 { |
|
8198 ERR_PRINTF1(_L("Appended file size is too long")); |
|
8199 ret = EFail; |
|
8200 } |
|
8201 } |
|
8202 |
|
8203 ERR_PRINTF2( _L("CMdaAudioRecorderUtility completed with error %d"),iError ); |
|
8204 CleanupStack::PopAndDestroy(recUtil); |
|
8205 User::After(KOneSecond); |
|
8206 return ret; |
|
8207 } |
|
8208 |
|
8209 |
|
8210 /** |
|
8211 * Constructor |
|
8212 */ |
|
8213 CTestMmfAclntRecFilePlay::CTestMmfAclntRecFilePlay(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TFormatType aFormatType, TCodecType aCodecType) |
|
8214 { |
|
8215 // store the name of this test case |
|
8216 // this is the name that is used by the script file |
|
8217 // Each test step initialises it's own name |
|
8218 iTestStepName = aTestName; |
|
8219 iSectName = aSectName; |
|
8220 iKeyName = aKeyName; |
|
8221 iFormatType = aFormatType; |
|
8222 iCodecType = aCodecType; |
|
8223 } |
|
8224 |
|
8225 CTestMmfAclntRecFilePlay* CTestMmfAclntRecFilePlay::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TFormatType aFormatType, TCodecType aCodecType) |
|
8226 { |
|
8227 CTestMmfAclntRecFilePlay* self = new (ELeave) CTestMmfAclntRecFilePlay(aTestName, aSectName, aKeyName, aFormatType, aCodecType); |
|
8228 return self; |
|
8229 } |
|
8230 |
|
8231 void CTestMmfAclntRecFilePlay::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt aCurrentState, TInt aErrorCode) |
|
8232 { |
|
8233 iError = aErrorCode; |
|
8234 iCurrentState = aCurrentState; |
|
8235 INFO_PRINTF3( _L("MoscoStateChangeEvent: aCurrentState = %d, iError %d "), iCurrentState, iError); |
|
8236 |
|
8237 CActiveScheduler::Stop(); |
|
8238 } |
|
8239 |
|
8240 |
|
8241 TVerdict CTestMmfAclntRecFilePlay::DoTestStepPreambleL() |
|
8242 { |
|
8243 TVerdict ret = EPass; |
|
8244 |
|
8245 // Make sure file doesn't exist (maybe from a previous test) |
|
8246 TParse fullFileName; |
|
8247 TBuf<KSizeBuf> filename; |
|
8248 TPtrC filename1; |
|
8249 |
|
8250 if(!GetStringFromConfig(iSectName, iKeyName, filename1)) |
|
8251 return EInconclusive; |
|
8252 |
|
8253 GetDriveName(filename); |
|
8254 filename.Append(filename1); |
|
8255 |
|
8256 |
|
8257 // parse the filenames |
|
8258 if(!fullFileName.Set(filename, &KDefault, NULL)) |
|
8259 { |
|
8260 RFs fs; |
|
8261 User::LeaveIfError(fs.Connect()); |
|
8262 fs.SetAtt(fullFileName.FullName(), 0, KEntryAttReadOnly); |
|
8263 TInt error = fs.Delete(fullFileName.FullName()); |
|
8264 |
|
8265 if(error == KErrPathNotFound) |
|
8266 { |
|
8267 error = fs.MkDirAll(fullFileName.DriveAndPath()); |
|
8268 INFO_PRINTF2(_L("Path for file %S was been created"), &fullFileName.FullName()); |
|
8269 } |
|
8270 else if(error == KErrNotFound) |
|
8271 INFO_PRINTF2(_L("No need to delete %S"), &fullFileName.FullName()); |
|
8272 else if(error==KErrNone) |
|
8273 INFO_PRINTF2(_L("Deleted %S"), &fullFileName.FullName()); |
|
8274 else |
|
8275 { |
|
8276 ret = EInconclusive; |
|
8277 } |
|
8278 fs.Close(); |
|
8279 } |
|
8280 |
|
8281 if((ret == EInconclusive) || (ret == EFail)) |
|
8282 return ret; |
|
8283 return CTestMmfAclntStep::DoTestStepPreambleL(); |
|
8284 } |
|
8285 |
|
8286 /** |
|
8287 * Open a file based clip and record, stop & then play |
|
8288 * specifying a different sample rate / number of channels |
|
8289 */ |
|
8290 |
|
8291 |
|
8292 TVerdict CTestMmfAclntRecFilePlay::DoTestStepL() |
|
8293 { |
|
8294 INFO_PRINTF1( _L("TestRecorder : Record File & play with diff sample rate/num of channels")); |
|
8295 TVerdict ret = EPass; |
|
8296 iError = KErrGeneral; // set error to ensure callback takes place |
|
8297 |
|
8298 TPtrC filename; |
|
8299 if(!GetStringFromConfig(iSectName, iKeyName, filename)) |
|
8300 return EInconclusive; |
|
8301 |
|
8302 CMdaAudioRecorderUtility* recUtil = NULL; |
|
8303 |
|
8304 TMdaFileClipLocation location(filename); |
|
8305 |
|
8306 RFs fs; |
|
8307 fs.Connect(); |
|
8308 fs.Delete(filename); |
|
8309 fs.Close(); |
|
8310 |
|
8311 for (TInt index=0; index<2; index++) |
|
8312 { |
|
8313 if (recUtil) |
|
8314 { |
|
8315 CleanupStack::PopAndDestroy(recUtil); |
|
8316 recUtil = NULL; |
|
8317 } |
|
8318 |
|
8319 recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
8320 CleanupStack::PushL(recUtil); |
|
8321 |
|
8322 if (index == 0) |
|
8323 INFO_PRINTF1(_L("Recording to file...")); |
|
8324 else |
|
8325 INFO_PRINTF1(_L("Playing recorded file")); |
|
8326 |
|
8327 TMdaWavClipFormat mdaWavFormat; |
|
8328 TMdaAuClipFormat mdaAuFormat; |
|
8329 TMdaClipFormat* format = NULL; |
|
8330 |
|
8331 TMdaImaAdpcmWavCodec wavImadCodec; |
|
8332 TMdaPcmWavCodec wav8PcmCodec; |
|
8333 TMdaPcm8BitAuCodec au8PcmCodec; |
|
8334 |
|
8335 TMdaPackage* codec = NULL; |
|
8336 |
|
8337 switch (iFormatType) |
|
8338 { |
|
8339 case EWavFormat: |
|
8340 format = &mdaWavFormat; |
|
8341 switch (iCodecType) |
|
8342 { |
|
8343 case EAdpcmCodec: |
|
8344 codec = &wavImadCodec; |
|
8345 break; |
|
8346 case EPcmCodec: |
|
8347 codec = &wav8PcmCodec; |
|
8348 break; |
|
8349 } |
|
8350 break; |
|
8351 case EAuFormat: |
|
8352 format = &mdaAuFormat; |
|
8353 switch (iCodecType) |
|
8354 { |
|
8355 case EPcmCodec: |
|
8356 codec = &au8PcmCodec; |
|
8357 break; |
|
8358 default: |
|
8359 break; |
|
8360 } |
|
8361 break; |
|
8362 } |
|
8363 |
|
8364 if (format == NULL || codec == NULL) |
|
8365 { |
|
8366 ret = EInconclusive; |
|
8367 break; |
|
8368 } |
|
8369 |
|
8370 TMdaAudioDataSettings audioSettings; |
|
8371 audioSettings.iCaps = |
|
8372 TMdaAudioDataSettings::ESampleRateFixed | |
|
8373 TMdaAudioDataSettings::EChannelsMono | |
|
8374 TMdaAudioDataSettings::EChannelsStereo | |
|
8375 TMdaAudioDataSettings::ESampleRate8000Hz | |
|
8376 TMdaAudioDataSettings::ESampleRate11025Hz; |
|
8377 |
|
8378 audioSettings.iFlags = TMdaAudioDataSettings::ENoNetworkRouting; |
|
8379 |
|
8380 // record in stereo at 8KHz, playback in mono at 11KHz |
|
8381 if (index == 0) // record |
|
8382 { |
|
8383 audioSettings.iSampleRate = KSampleRate8K; |
|
8384 audioSettings.iChannels = 2; |
|
8385 } |
|
8386 else // play |
|
8387 { |
|
8388 audioSettings.iSampleRate = KSampleRate11K; |
|
8389 audioSettings.iChannels = 1; |
|
8390 } |
|
8391 |
|
8392 |
|
8393 recUtil->OpenL(&location, format, codec, &audioSettings); |
|
8394 |
|
8395 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
8396 CActiveScheduler::Start(); // idle -> open |
|
8397 |
|
8398 if(iError != KErrNone) |
|
8399 break; |
|
8400 |
|
8401 iError = KErrTimedOut; |
|
8402 |
|
8403 if (index == 0) // record |
|
8404 { |
|
8405 recUtil->RecordL(); |
|
8406 INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility")); |
|
8407 CActiveScheduler::Start(); // open -> record |
|
8408 |
|
8409 User::After(KTwoSeconds); |
|
8410 |
|
8411 if (iCurrentState != CMdaAudioClipUtility::ERecording) |
|
8412 { |
|
8413 INFO_PRINTF1( _L("CMdaAudioRecorderUtility is not recording")); |
|
8414 ret = EFail; |
|
8415 break; |
|
8416 } |
|
8417 |
|
8418 recUtil->Stop(); |
|
8419 |
|
8420 } |
|
8421 else // play |
|
8422 { |
|
8423 recUtil->PlayL(); |
|
8424 INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility")); |
|
8425 CActiveScheduler::Start(); // open -> play |
|
8426 CActiveScheduler::Start(); // play -> open |
|
8427 } |
|
8428 |
|
8429 recUtil->Close(); |
|
8430 |
|
8431 |
|
8432 } |
|
8433 |
|
8434 if (iError != KErrNone) |
|
8435 ret = EFail; |
|
8436 |
|
8437 ERR_PRINTF2( _L("CMdaAudioRecorderUtility completed with error %d"),iError ); |
|
8438 if (recUtil) |
|
8439 { |
|
8440 CleanupStack::PopAndDestroy(recUtil); |
|
8441 recUtil = NULL; |
|
8442 } |
|
8443 |
|
8444 User::After(KOneSecond); |
|
8445 return ret; |
|
8446 } |
|
8447 |
|
8448 |
|
8449 /** |
|
8450 * DEF039893 |
|
8451 * Gets balance prior to setting balance |
|
8452 * @class CTestMmfAclntRecord |
|
8453 */ |
|
8454 CTestMmfAclntRecordGetBalance::CTestMmfAclntRecordGetBalance(const TDesC& aTestName) |
|
8455 { |
|
8456 // store the name of this test case |
|
8457 // this is the name that is used by the script file |
|
8458 // Each test step initialises it's own name |
|
8459 iTestStepName = aTestName; |
|
8460 } |
|
8461 |
|
8462 CTestMmfAclntRecordGetBalance* CTestMmfAclntRecordGetBalance::NewL(const TDesC& aTestName) |
|
8463 { |
|
8464 CTestMmfAclntRecordGetBalance* self = new (ELeave) CTestMmfAclntRecordGetBalance(aTestName); |
|
8465 return self; |
|
8466 } |
|
8467 |
|
8468 void CTestMmfAclntRecordGetBalance::MoscoStateChangeEvent(CBase* aObject,TInt aPreviousState,TInt aCurrentState, TInt aErrorCode) |
|
8469 { |
|
8470 iObject = aObject; |
|
8471 iPreviousState = aPreviousState; |
|
8472 iCurrentState = aCurrentState; |
|
8473 iError = aErrorCode; |
|
8474 CActiveScheduler::Stop(); |
|
8475 } |
|
8476 |
|
8477 TVerdict CTestMmfAclntRecordGetBalance::DoTestStepL() |
|
8478 { |
|
8479 // Set up a file to record to |
|
8480 TVerdict verdict = EPass; |
|
8481 |
|
8482 TPtrC filename; |
|
8483 if (!GetStringFromConfig(_L("SectionThree"), _L("outputAudioFile"), filename)) |
|
8484 { |
|
8485 INFO_PRINTF1(_L("Error getting filename from INI file")); |
|
8486 return EInconclusive; |
|
8487 } |
|
8488 |
|
8489 RFs fs; |
|
8490 TInt err = fs.Connect(); |
|
8491 if (err != KErrNone) |
|
8492 { |
|
8493 INFO_PRINTF2(_L("Error connecting file session"), err); |
|
8494 return EInconclusive; |
|
8495 } |
|
8496 |
|
8497 err = fs.Delete(filename); |
|
8498 if (!((err == KErrNone) || (err == KErrNotFound))) |
|
8499 { |
|
8500 INFO_PRINTF2(_L("Error deleting output file"), err); |
|
8501 return EInconclusive; |
|
8502 } |
|
8503 |
|
8504 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
8505 |
|
8506 TInt balance; |
|
8507 err = recUtil->GetPlaybackBalance(balance); |
|
8508 |
|
8509 if (err != KErrNotSupported) |
|
8510 {//would have thought KErrNotReady would be a more logical error |
|
8511 verdict = EFail; |
|
8512 } |
|
8513 |
|
8514 TRAP(err,recUtil->OpenFileL(filename)); |
|
8515 CActiveScheduler::Start(); |
|
8516 |
|
8517 if (err) |
|
8518 { |
|
8519 INFO_PRINTF2(_L("Error opening output file"), err); |
|
8520 verdict = EInconclusive; |
|
8521 } |
|
8522 else |
|
8523 { |
|
8524 err = recUtil->GetPlaybackBalance(balance); |
|
8525 |
|
8526 if ((err)||(balance)) |
|
8527 {//there should be no errors and balance should be 0 |
|
8528 verdict = EFail; |
|
8529 } |
|
8530 |
|
8531 recUtil->Close(); |
|
8532 |
|
8533 err = recUtil->GetPlaybackBalance(balance); |
|
8534 if (err != KErrNotSupported) |
|
8535 { |
|
8536 verdict = EFail; |
|
8537 } |
|
8538 } |
|
8539 |
|
8540 delete recUtil; |
|
8541 |
|
8542 return verdict; |
|
8543 } |
|
8544 /* |
|
8545 DEF039308 - No integration test to test playback of recorded raw file |
|
8546 The tmfad record test option b + 4 to record an alaw raw file and then play it back: this uncovered a defect that was not picked up by the integration tests suggesting there are no integration tests to record and playback a recorded raw file. |
|
8547 Not clear whether this applies to just recording raw alaw or recorded raw in general- this needs checking as part of the 'under investigation' phase. |
|
8548 */ |
|
8549 |
|
8550 /** |
|
8551 * Constructor |
|
8552 */ |
|
8553 CTestMmfAclntRecRawFilePlay::CTestMmfAclntRecRawFilePlay(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TFormatType aFormatType, TCodecType aCodecType) |
|
8554 { |
|
8555 // store the name of this test case |
|
8556 // this is the name that is used by the script file |
|
8557 // Each test step initialises it's own name |
|
8558 iTestStepName = aTestName; |
|
8559 iSectName = aSectName; |
|
8560 iKeyName = aKeyName; |
|
8561 iFormatType = aFormatType; |
|
8562 iCodecType = aCodecType; |
|
8563 } |
|
8564 |
|
8565 CTestMmfAclntRecRawFilePlay* CTestMmfAclntRecRawFilePlay::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, TFormatType aFormatType, TCodecType aCodecType) |
|
8566 { |
|
8567 CTestMmfAclntRecRawFilePlay* self = new (ELeave) CTestMmfAclntRecRawFilePlay(aTestName, aSectName, aKeyName, aFormatType, aCodecType); |
|
8568 return self; |
|
8569 } |
|
8570 |
|
8571 void CTestMmfAclntRecRawFilePlay::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt aCurrentState, TInt aErrorCode) |
|
8572 { |
|
8573 iError = aErrorCode; |
|
8574 iCurrentState = aCurrentState; |
|
8575 INFO_PRINTF3( _L("MoscoStateChangeEvent: aCurrentState = %d, iError %d "), iCurrentState, iError); |
|
8576 |
|
8577 CActiveScheduler::Stop(); |
|
8578 } |
|
8579 |
|
8580 |
|
8581 TVerdict CTestMmfAclntRecRawFilePlay::DoTestStepPreambleL() |
|
8582 { |
|
8583 TVerdict ret = EPass; |
|
8584 |
|
8585 // Make sure file doesn't exist (maybe from a previous test) |
|
8586 TParse fullFileName; |
|
8587 TBuf<KSizeBuf> filename; |
|
8588 TPtrC filename1; |
|
8589 |
|
8590 if(!GetStringFromConfig(iSectName, iKeyName, filename1)) |
|
8591 return EInconclusive; |
|
8592 |
|
8593 GetDriveName(filename); |
|
8594 filename.Append(filename1); |
|
8595 |
|
8596 |
|
8597 // parse the filenames |
|
8598 if(!fullFileName.Set(filename, &KDefault, NULL)) |
|
8599 { |
|
8600 RFs fs; |
|
8601 User::LeaveIfError(fs.Connect()); |
|
8602 fs.SetAtt(fullFileName.FullName(), 0, KEntryAttReadOnly); |
|
8603 TInt error = fs.Delete(fullFileName.FullName()); |
|
8604 |
|
8605 if(error == KErrPathNotFound) |
|
8606 { |
|
8607 error = fs.MkDirAll(fullFileName.DriveAndPath()); |
|
8608 INFO_PRINTF2(_L("Path for file %S was been created"), &fullFileName.FullName()); |
|
8609 } |
|
8610 else if(error == KErrNotFound) |
|
8611 INFO_PRINTF2(_L("No need to delete %S"), &fullFileName.FullName()); |
|
8612 else if(error==KErrNone) |
|
8613 INFO_PRINTF2(_L("Deleted %S"), &fullFileName.FullName()); |
|
8614 else |
|
8615 { |
|
8616 ret = EInconclusive; |
|
8617 } |
|
8618 fs.Close(); |
|
8619 } |
|
8620 |
|
8621 if((ret == EInconclusive) || (ret == EFail)) |
|
8622 return ret; |
|
8623 return CTestMmfAclntStep::DoTestStepPreambleL(); |
|
8624 } |
|
8625 |
|
8626 /** |
|
8627 * Open a file based clip and record, stop & then play |
|
8628 * specifying a different sample rate / number of channels |
|
8629 */ |
|
8630 |
|
8631 |
|
8632 TVerdict CTestMmfAclntRecRawFilePlay::DoTestStepL() |
|
8633 { |
|
8634 INFO_PRINTF1( _L("TestRecorder : Record RAW File & play with diff sample rate/num of channels")); |
|
8635 TVerdict ret = EPass; |
|
8636 iError = KErrGeneral; // set error to ensure callback takes place |
|
8637 |
|
8638 TPtrC filename; |
|
8639 if(!GetStringFromConfig(iSectName, iKeyName, filename)) |
|
8640 return EInconclusive; |
|
8641 |
|
8642 CMdaAudioRecorderUtility* recUtil = NULL; |
|
8643 |
|
8644 TMdaFileClipLocation location(filename); |
|
8645 |
|
8646 RFs fs; |
|
8647 fs.Connect(); |
|
8648 fs.Delete(filename); |
|
8649 fs.Close(); |
|
8650 |
|
8651 for (TInt index=0; index<2; index++) |
|
8652 { |
|
8653 if (recUtil) |
|
8654 { |
|
8655 CleanupStack::PopAndDestroy(recUtil); |
|
8656 recUtil = NULL; |
|
8657 } |
|
8658 |
|
8659 recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
8660 CleanupStack::PushL(recUtil); |
|
8661 |
|
8662 if (index == 0) |
|
8663 INFO_PRINTF1(_L("Recording to file...")); |
|
8664 else |
|
8665 INFO_PRINTF1(_L("Playing recorded file")); |
|
8666 |
|
8667 TMdaRawAudioClipFormat mdaRawFormat; |
|
8668 TMdaClipFormat* format = NULL; |
|
8669 |
|
8670 TMdaAlawRawAudioCodec rawAlawCodec; |
|
8671 |
|
8672 TMdaPackage* codec = NULL; |
|
8673 |
|
8674 switch (iFormatType) |
|
8675 { |
|
8676 case ERawFormat: |
|
8677 format = &mdaRawFormat; |
|
8678 switch (iCodecType) |
|
8679 { |
|
8680 case EAlawCodec: |
|
8681 codec = &rawAlawCodec; |
|
8682 break; |
|
8683 default: |
|
8684 break; |
|
8685 } |
|
8686 break; |
|
8687 } |
|
8688 |
|
8689 if (format == NULL || codec == NULL) |
|
8690 { |
|
8691 ret = EInconclusive; |
|
8692 break; |
|
8693 } |
|
8694 |
|
8695 TMdaAudioDataSettings audioSettings; |
|
8696 audioSettings.iCaps = |
|
8697 TMdaAudioDataSettings::ESampleRateFixed | |
|
8698 TMdaAudioDataSettings::EChannelsMono | |
|
8699 TMdaAudioDataSettings::EChannelsStereo | |
|
8700 TMdaAudioDataSettings::ESampleRate8000Hz | |
|
8701 TMdaAudioDataSettings::ESampleRate11025Hz; |
|
8702 |
|
8703 audioSettings.iFlags = TMdaAudioDataSettings::ENoNetworkRouting; |
|
8704 |
|
8705 // record in stereo at 8KHz, playback in mono at 11KHz |
|
8706 if (index == 0) // record |
|
8707 { |
|
8708 audioSettings.iSampleRate = KSampleRate8K; |
|
8709 audioSettings.iChannels = 2; |
|
8710 } |
|
8711 else // play |
|
8712 { |
|
8713 audioSettings.iSampleRate = KSampleRate11K; |
|
8714 audioSettings.iChannels = 1; |
|
8715 } |
|
8716 |
|
8717 |
|
8718 recUtil->OpenL(&location, format, codec, &audioSettings); |
|
8719 |
|
8720 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility")); |
|
8721 CActiveScheduler::Start(); // idle -> open |
|
8722 |
|
8723 if(iError != KErrNone) |
|
8724 break; |
|
8725 |
|
8726 iError = KErrTimedOut; |
|
8727 |
|
8728 if (index == 0) // record |
|
8729 { |
|
8730 recUtil->RecordL(); |
|
8731 INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility")); |
|
8732 CActiveScheduler::Start(); // open -> record |
|
8733 |
|
8734 User::After(KTwoSeconds); |
|
8735 |
|
8736 if (iCurrentState != CMdaAudioClipUtility::ERecording) |
|
8737 { |
|
8738 INFO_PRINTF1( _L("CMdaAudioRecorderUtility is not recording")); |
|
8739 ret = EFail; |
|
8740 break; |
|
8741 } |
|
8742 |
|
8743 recUtil->Stop(); |
|
8744 |
|
8745 } |
|
8746 else // play |
|
8747 { |
|
8748 recUtil->PlayL(); |
|
8749 INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility")); |
|
8750 CActiveScheduler::Start(); // open -> play |
|
8751 CActiveScheduler::Start(); // play -> open |
|
8752 } |
|
8753 |
|
8754 recUtil->Close(); |
|
8755 |
|
8756 |
|
8757 } |
|
8758 |
|
8759 if (iError != KErrNone) |
|
8760 ret = EFail; |
|
8761 |
|
8762 ERR_PRINTF2( _L("CMdaAudioRecorderUtility completed with error %d"),iError ); |
|
8763 if (recUtil) |
|
8764 { |
|
8765 CleanupStack::PopAndDestroy(recUtil); |
|
8766 recUtil = NULL; |
|
8767 } |
|
8768 |
|
8769 User::After(KOneSecond); |
|
8770 return ret; |
|
8771 } |
|
8772 |
|
8773 |
|
8774 /** |
|
8775 * REQ2870 |
|
8776 * Sierra: AudioRecorderUtility to get AudioBitrare |
|
8777 * @class CTestMmfAclntRecSrcAuBitrate |
|
8778 */ |
|
8779 CTestMmfAclntRecSrcAuBitrate::CTestMmfAclntRecSrcAuBitrate(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName1, const TDesC& aKeyName2) |
|
8780 { |
|
8781 // store the name of this test case |
|
8782 // this is the name that is used by the script file |
|
8783 // Each test step initialises it's own name |
|
8784 iTestStepName = aTestName; |
|
8785 iSectName = aSectName; |
|
8786 iKeyFileName = aKeyName1; |
|
8787 iKeyBitRateName = aKeyName2; |
|
8788 } |
|
8789 |
|
8790 CTestMmfAclntRecSrcAuBitrate* CTestMmfAclntRecSrcAuBitrate::NewL(const TDesC& aTestName, |
|
8791 const TDesC& aSectName, |
|
8792 const TDesC& aKeyName1, |
|
8793 const TDesC& aKeyName2) |
|
8794 { |
|
8795 CTestMmfAclntRecSrcAuBitrate* self = new (ELeave) CTestMmfAclntRecSrcAuBitrate(aTestName, |
|
8796 aSectName, |
|
8797 aKeyName1, |
|
8798 aKeyName2); |
|
8799 return self; |
|
8800 } |
|
8801 |
|
8802 void CTestMmfAclntRecSrcAuBitrate::MoscoStateChangeEvent(CBase* aObject, |
|
8803 TInt aPreviousState, |
|
8804 TInt aCurrentState, |
|
8805 TInt aErrorCode) |
|
8806 { |
|
8807 iError = aErrorCode; |
|
8808 iObject = aObject; |
|
8809 iPreviousState = aPreviousState; |
|
8810 iCurrentState = aCurrentState; |
|
8811 INFO_PRINTF1( _L("CTestMmfAclntRecSrcAuBitrate : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete")); |
|
8812 INFO_PRINTF4( _L("iError %d iPreviousState %d iCurrentState %d"), iError, iPreviousState, iCurrentState); |
|
8813 CActiveScheduler::Stop(); |
|
8814 } |
|
8815 |
|
8816 TVerdict CTestMmfAclntRecSrcAuBitrate::DoTestStepL() |
|
8817 { |
|
8818 INFO_PRINTF1( _L("TestRecorder : Audio Bit Rate")); |
|
8819 TVerdict verdict = EPass; |
|
8820 |
|
8821 TPtrC filename; |
|
8822 TInt bitRate = 0; |
|
8823 TInt err = 0; |
|
8824 |
|
8825 if(!GetStringFromConfig(iSectName,iKeyFileName,filename)) |
|
8826 { |
|
8827 INFO_PRINTF1(_L("Error getting filename from INI file")); |
|
8828 return EInconclusive; |
|
8829 } |
|
8830 if(!GetIntFromConfig(iSectName, iKeyBitRateName, iExpectedBitRate)) |
|
8831 { |
|
8832 INFO_PRINTF1(_L("Error getting bitrate from INI file")); |
|
8833 return EInconclusive; |
|
8834 } |
|
8835 |
|
8836 |
|
8837 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
8838 if (recUtil == NULL || |
|
8839 iError != KErrNone) |
|
8840 { |
|
8841 INFO_PRINTF1(_L("Error to create a recUtil object")); |
|
8842 return EFail; |
|
8843 } |
|
8844 CleanupStack::PushL(recUtil); |
|
8845 |
|
8846 |
|
8847 INFO_PRINTF2(_L("Opening file = %S"), &filename); |
|
8848 TRAP(err, recUtil->OpenFileL(filename)); |
|
8849 CActiveScheduler::Start(); |
|
8850 |
|
8851 if (err != KErrNone || |
|
8852 iError != KErrNone) |
|
8853 { |
|
8854 INFO_PRINTF2(_L("Opening file error: %d"), err); |
|
8855 CleanupStack::PopAndDestroy(recUtil); |
|
8856 verdict = EFail; |
|
8857 } |
|
8858 else |
|
8859 { |
|
8860 recUtil->PlayL(); |
|
8861 CActiveScheduler::Start(); // wait for open -> play |
|
8862 if (iError != KErrNone) |
|
8863 { |
|
8864 INFO_PRINTF2(_L("Error to play the file: %d"), iError); |
|
8865 verdict = EFail; |
|
8866 } |
|
8867 |
|
8868 TRAP(err, bitRate = recUtil->SourceBitRateL()); |
|
8869 if (err != KErrNone || |
|
8870 iError != KErrNone) |
|
8871 { |
|
8872 INFO_PRINTF2(_L("Error to query the bitrate: %d"), err); |
|
8873 verdict = EFail; |
|
8874 } |
|
8875 |
|
8876 if (bitRate != iExpectedBitRate) |
|
8877 { |
|
8878 verdict = EFail; |
|
8879 } |
|
8880 INFO_PRINTF2(_L("Expected bit rate: %d"), iExpectedBitRate); |
|
8881 INFO_PRINTF2(_L("Queried Bitrate: %d"), bitRate); |
|
8882 recUtil->Close(); |
|
8883 CleanupStack::PopAndDestroy(recUtil); |
|
8884 } |
|
8885 |
|
8886 return verdict; |
|
8887 } |
|
8888 |
|
8889 |
|
8890 /** |
|
8891 * REQ2870 |
|
8892 * Sierra: AudioRecorderUtility to get AudioBitrare from a recorded file |
|
8893 * @class CTestMmfAclntRecBitrateRecordedFile |
|
8894 */ |
|
8895 CTestMmfAclntRecBitrateRecordedFile::CTestMmfAclntRecBitrateRecordedFile(const TDesC& aTestName, |
|
8896 const TDesC& aSectName, |
|
8897 const TDesC& aKeyName, |
|
8898 const TTestFormat aFormat, |
|
8899 const TBool aCreateFile) |
|
8900 |
|
8901 { |
|
8902 // store the name of this test case |
|
8903 // this is the name that is used by the script file |
|
8904 // Each test step initialises it's own name |
|
8905 iTestStepName = aTestName; |
|
8906 iHeapSize = 200000; // playback part of test loads whole sound file into buffer, so need large heap |
|
8907 iSectName = aSectName; |
|
8908 iKeyName = aKeyName; |
|
8909 iTestFormat = aFormat; |
|
8910 iCreateFile = aCreateFile; |
|
8911 } |
|
8912 |
|
8913 CTestMmfAclntRecBitrateRecordedFile* CTestMmfAclntRecBitrateRecordedFile::NewL(const TDesC& aTestName, |
|
8914 const TDesC& aSectName, |
|
8915 const TDesC& aKeyName, |
|
8916 const TTestFormat aFormat, |
|
8917 const TBool aCreateFile) |
|
8918 { |
|
8919 CTestMmfAclntRecBitrateRecordedFile* self = new (ELeave) CTestMmfAclntRecBitrateRecordedFile(aTestName, |
|
8920 aSectName, |
|
8921 aKeyName, |
|
8922 aFormat, |
|
8923 aCreateFile); |
|
8924 return self; |
|
8925 } |
|
8926 |
|
8927 void CTestMmfAclntRecBitrateRecordedFile::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt /*aCurrentState*/, TInt aErrorCode) |
|
8928 { |
|
8929 iError = aErrorCode; |
|
8930 INFO_PRINTF1( _L("CTestMmfAclntRecBitrateRecordedFile : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete")); |
|
8931 INFO_PRINTF2( _L("iError %d "), iError); |
|
8932 |
|
8933 CActiveScheduler::Stop(); |
|
8934 } |
|
8935 |
|
8936 |
|
8937 TVerdict CTestMmfAclntRecBitrateRecordedFile::DoTestStepPreambleL() |
|
8938 { |
|
8939 TVerdict ret = EPass; |
|
8940 |
|
8941 //Setup codec and format to test (CTestMmfAclntCodecTest) |
|
8942 SetupFormatL(iTestFormat); |
|
8943 |
|
8944 if(iCreateFile) |
|
8945 { |
|
8946 // Make sure file doesn't exist (maybe from a previous test) |
|
8947 TParse fullFileName; |
|
8948 TBuf<KSizeBuf> filename; |
|
8949 TPtrC filename1; |
|
8950 |
|
8951 if(!GetStringFromConfig(iSectName, iKeyName, filename1)) |
|
8952 { |
|
8953 return EInconclusive; |
|
8954 } |
|
8955 GetDriveName(filename); |
|
8956 filename.Append(filename1); |
|
8957 |
|
8958 // parse the filenames |
|
8959 if(!fullFileName.Set(filename, &KDefault, NULL)) |
|
8960 { |
|
8961 RFs fs; |
|
8962 User::LeaveIfError(fs.Connect()); |
|
8963 fs.SetAtt(fullFileName.FullName(), 0, KEntryAttReadOnly); |
|
8964 TInt error = fs.Delete(fullFileName.FullName()); |
|
8965 |
|
8966 if(error == KErrPathNotFound) |
|
8967 { |
|
8968 error = fs.MkDirAll(fullFileName.DriveAndPath()); |
|
8969 INFO_PRINTF2(_L("Path for file %S was been created"), &fullFileName.FullName()); |
|
8970 } |
|
8971 else if(error == KErrNotFound) |
|
8972 { |
|
8973 INFO_PRINTF2(_L("No need to delete %S"), &fullFileName.FullName()); |
|
8974 } |
|
8975 else if(error==KErrNone) |
|
8976 { |
|
8977 INFO_PRINTF2(_L("Deleted %S"), &fullFileName.FullName()); |
|
8978 } |
|
8979 else |
|
8980 { |
|
8981 ret = EInconclusive; |
|
8982 } |
|
8983 fs.Close(); |
|
8984 } |
|
8985 } |
|
8986 |
|
8987 if(ret == EInconclusive) |
|
8988 { |
|
8989 return ret; |
|
8990 } |
|
8991 |
|
8992 return CTestMmfAclntStep::DoTestStepPreambleL(); |
|
8993 } |
|
8994 |
|
8995 |
|
8996 TVerdict CTestMmfAclntRecBitrateRecordedFile::DoTestStepL() |
|
8997 { |
|
8998 INFO_PRINTF1( _L("TestRecorder : Query bitrate from a recorded file")); |
|
8999 TVerdict verdict = EPass; |
|
9000 iError = KErrTimedOut; |
|
9001 |
|
9002 TPtrC filename; |
|
9003 if(!GetStringFromConfig(iSectName, iKeyName, filename)) |
|
9004 { |
|
9005 return EInconclusive; |
|
9006 } |
|
9007 |
|
9008 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
9009 CleanupStack::PushL(recUtil); |
|
9010 |
|
9011 TMdaFileClipLocation location(filename); |
|
9012 |
|
9013 recUtil->OpenL(&location,iFormat,iCodec,&iAudioSettings); |
|
9014 CActiveScheduler::Start(); |
|
9015 INFO_PRINTF1( _L("Open a new file for recording")); |
|
9016 |
|
9017 if (iError != KErrNone) |
|
9018 { |
|
9019 INFO_PRINTF2(_L("Error opening file for recording iError = %d"), iError); |
|
9020 CleanupStack::PopAndDestroy(recUtil); |
|
9021 return EFail; |
|
9022 } |
|
9023 |
|
9024 iError = KErrTimedOut; |
|
9025 recUtil->RecordL(); |
|
9026 CActiveScheduler::Start(); // open -> record |
|
9027 INFO_PRINTF1( _L("Recording")); |
|
9028 User::After(KFiveSeconds); |
|
9029 |
|
9030 if(iError != KErrNone) |
|
9031 { |
|
9032 INFO_PRINTF2( _L("Fail to do recording with error: %d"), iError); |
|
9033 verdict = EFail; |
|
9034 } |
|
9035 |
|
9036 recUtil->Stop(); |
|
9037 User::After(KOneSecond); |
|
9038 |
|
9039 |
|
9040 TRAPD(err, recUtil->OpenFileL(filename)); |
|
9041 CActiveScheduler::Start(); |
|
9042 INFO_PRINTF1( _L("Open the recorded file")); |
|
9043 |
|
9044 if (err != KErrNone) |
|
9045 { |
|
9046 INFO_PRINTF2(_L("Error opening file for playback err = %d"), err); |
|
9047 CleanupStack::PopAndDestroy(recUtil); |
|
9048 return EFail; |
|
9049 } |
|
9050 |
|
9051 if (iError != KErrNone) |
|
9052 { |
|
9053 INFO_PRINTF2(_L("Error opening file for playback iError = %d"), iError); |
|
9054 CleanupStack::PopAndDestroy(recUtil); |
|
9055 return EFail; |
|
9056 } |
|
9057 |
|
9058 recUtil->PlayL(); |
|
9059 CActiveScheduler::Start(); |
|
9060 INFO_PRINTF1( _L("Play the recorded file")); |
|
9061 |
|
9062 if (iError != KErrNone) |
|
9063 { |
|
9064 INFO_PRINTF2(_L("Error during playback of recorded file iError=%d"), iError); |
|
9065 verdict = EFail; |
|
9066 } |
|
9067 User::After(KFiveSeconds); |
|
9068 |
|
9069 TInt bitRate = 0; |
|
9070 |
|
9071 TRAP(err, bitRate = recUtil->SourceBitRateL()); |
|
9072 INFO_PRINTF1( _L("Query bitrate from the recorded file")); |
|
9073 |
|
9074 if (err != KErrNone || |
|
9075 iError != KErrNone) |
|
9076 { |
|
9077 INFO_PRINTF2(_L("Error to query the bitrate: %d"), err); |
|
9078 verdict = EFail; |
|
9079 } |
|
9080 |
|
9081 INFO_PRINTF2(_L("Queried Bitrate: %d"), bitRate); |
|
9082 |
|
9083 recUtil->Close(); |
|
9084 |
|
9085 CleanupStack::PopAndDestroy(recUtil); |
|
9086 recUtil = NULL; |
|
9087 |
|
9088 ERR_PRINTF2( _L("CMdaAudioRecorderUtility completed with error %d"),iError ); |
|
9089 User::After(KOneSecond); |
|
9090 return verdict; |
|
9091 } |
|
9092 |
|
9093 //Record-Stop-Record test. Added for CR1566 |
|
9094 |
|
9095 CTestMmfAclntRecStopRec::CTestMmfAclntRecStopRec(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
9096 :CTestMmfAclntRecord(aTestName, aSectName, aNegative) |
|
9097 {} |
|
9098 |
|
9099 CTestMmfAclntRecStopRec* CTestMmfAclntRecStopRec::NewL(const TDesC& aTestName, const TDesC& aSectName, TBool aNegative) |
|
9100 { |
|
9101 CTestMmfAclntRecStopRec* self = new (ELeave) CTestMmfAclntRecStopRec(aTestName, aSectName, aNegative); |
|
9102 return self; |
|
9103 } |
|
9104 |
|
9105 TVerdict CTestMmfAclntRecStopRec::DoTestStepL() |
|
9106 { |
|
9107 INFO_PRINTF1( _L("TestRecorder : Record-Stop-Record")); |
|
9108 TVerdict ret = EFail; |
|
9109 |
|
9110 iError = KErrTimedOut; |
|
9111 |
|
9112 TPtrC filename; |
|
9113 |
|
9114 |
|
9115 if(!GetStringFromConfig(iSectName, _L("outputAudioFile"), filename)) |
|
9116 { |
|
9117 return EInconclusive; |
|
9118 } |
|
9119 |
|
9120 RFs fs; |
|
9121 fs.Connect(); |
|
9122 fs.Delete(filename); |
|
9123 fs.Close(); |
|
9124 |
|
9125 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this); |
|
9126 CleanupStack::PushL(recUtil); |
|
9127 |
|
9128 // Add create file for Ogg-tests |
|
9129 if(iSectName == _L("SectionOggRecState")) |
|
9130 { |
|
9131 RFs fs; |
|
9132 User::LeaveIfError(fs.Connect()); |
|
9133 RFile file; |
|
9134 User::LeaveIfError(file.Replace(fs,filename,EFileWrite)); |
|
9135 file.Close(); |
|
9136 fs.Close(); |
|
9137 } |
|
9138 |
|
9139 INFO_PRINTF2(_L("CMdaAudioRecorderUtility->OpenFileL(%S)"), &filename); |
|
9140 recUtil->OpenFileL(filename); |
|
9141 // wait |
|
9142 INFO_PRINTF1(_L("Initialise CMdaAudioRecorderUtility")); |
|
9143 CActiveScheduler::Start(); |
|
9144 |
|
9145 if(iError == KErrNone) |
|
9146 { |
|
9147 ret = DoTestL(recUtil); |
|
9148 } |
|
9149 |
|
9150 |
|
9151 CleanupStack::PopAndDestroy(recUtil); |
|
9152 User::After(KTwoSeconds); |
|
9153 ERR_PRINTF2( _L("CMdaAudioRecorderUtility completed with error %d"),iError ); |
|
9154 return ret; |
|
9155 } |
|
9156 |
|
9157 /** |
|
9158 * Enquire state at each state transition. |
|
9159 */ |
|
9160 TVerdict CTestMmfAclntRecStopRec::DoTestL(CMdaAudioRecorderUtility* aRecUtil) |
|
9161 { |
|
9162 INFO_PRINTF1( _L("TestRecorder : State Transition")); |
|
9163 |
|
9164 TVerdict ret= EFail; |
|
9165 |
|
9166 iReportedState = aRecUtil->State(); |
|
9167 if( iReportedState == CMdaAudioClipUtility::EOpen ) |
|
9168 { |
|
9169 INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility")); |
|
9170 aRecUtil->RecordL(); |
|
9171 CActiveScheduler::Start(); // wait for open -> record |
|
9172 if (iError != KErrNone) |
|
9173 { |
|
9174 return EFail; |
|
9175 } |
|
9176 |
|
9177 iReportedState = aRecUtil->State(); |
|
9178 if(iReportedState == CMdaAudioClipUtility::ERecording ) |
|
9179 { |
|
9180 ret = EPass; |
|
9181 } |
|
9182 |
|
9183 User::After(KTwoSeconds); |
|
9184 aRecUtil->Stop(); |
|
9185 |
|
9186 iReportedState = aRecUtil->State(); |
|
9187 if(iReportedState != CMdaAudioClipUtility::EOpen ) //Check that record returns to open |
|
9188 { |
|
9189 return EFail; |
|
9190 } |
|
9191 |
|
9192 aRecUtil->RecordL(); |
|
9193 CActiveScheduler::Start(); // wait for open -> record again |
|
9194 if (iError != KErrNone) |
|
9195 { |
|
9196 return EFail; |
|
9197 } |
|
9198 |
|
9199 iReportedState = aRecUtil->State(); |
|
9200 if( iReportedState == CMdaAudioClipUtility::ERecording ) |
|
9201 { |
|
9202 aRecUtil->Close(); |
|
9203 ret = EPass; |
|
9204 } |
|
9205 } |
|
9206 return ret; |
|
9207 } |
|
9208 |