Update contrib.
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #include <mmf/common/mmfcontroller.h>
20 #include <mmf/server/mmffile.h>
21 #include <mmf/server/mmfdes.h>
22 #include <mmf/plugin/mmfcontrollerimplementationuids.hrh>
23 #include <mmf/common/mmfstandardcustomcommands.h>
25 #include "ActrlTestUids.h"
27 // Test system includes
28 #include <testframework.h>
30 // Specific includes for this test suite
31 #include "TS_MMF_ACTRL_TestStep.h"
32 #include "TS_MMF_ACTRL_TestSuite.h"
34 // Specific includes for these test steps
35 #include "TestStepActrlPlay.h"
38 //const TInt KPlayDelayNewMail = 100000000; //arbitrary delay // EABI warning removal
40 const TUint KSampleRate8000Hz = 8000;
41 const TUint KSampleRate11025Hz = 11025;
42 const TUint KSampleRate22050Hz = 22050;
43 const TUint KSampleRate44100Hz = 44100;
45 const TUint KNone = 0;
46 const TUint KMono = 1;
47 const TUint KStereo = 2;
49 //const TUint KFormatWAV = 0;
50 //const TUint KFormatAU = 1;
51 //const TUint KFormatRAW = 2;
53 // parameter structure for conversion tests
57 const TText* iTestName;
61 TUint32 iDestEncoding;
63 TUint iDestSampleRate;
66 const TText* iFromFilename;
67 const TText* iRefFilename;
72 // constant table of parameters for tests
73 const TConvParameters KTestParameters[] =
75 // straight encode test
76 { _S("MM-MMF-ACTRL-U-0040-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatAUWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodePCM16B, KSampleRate44100Hz, KSampleRate8000Hz, KStereo, KMono, _S("44KHzPCM16Stereo1KHzTone.wav"), _S("44KHzPCM16StereoWAVTo8KHzPCM16Mono.au"), KErrNone },
77 { _S("MM-MMF-ACTRL-U-0041-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCMU8, KMMFFourCCCodePCM16, KSampleRate22050Hz, KSampleRate11025Hz, KMono, KStereo, _S("22KHzPCM8Mono1KHzTone.wav"), _S("22KHzPCM8MonoWAVTo11KHzPCM16Stereo.wav"), KErrNone },
78 { _S("MM-MMF-ACTRL-U-0042-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatRAWWrite}, KMMFFourCCCodeIMAD, KMMFFourCCCodePCM16, KSampleRate11025Hz, KSampleRate8000Hz, KMono, KMono, _S("11KHzADPCMMono1KHzTone.wav"), _S("11KHzADPCMMonoWAVTo8KHzPCM16Mono.raw"), KErrNone },
79 { _S("MM-MMF-ACTRL-U-0043-HP"), {KMmfUidFormatAURead}, {KMmfUidFormatAUWrite}, KMMFFourCCCodePCM16B, KMMFFourCCCodePCM16B, KSampleRate8000Hz, KSampleRate8000Hz, KMono, KMono, _S("8KHzPCM16Mono1KHzTone.au"), _S("8KHzPCM16MonoAUTo8KHzPCM16Mono.au"), KErrNone },
80 { _S("MM-MMF-ACTRL-U-0044-HP"), {KMmfUidFormatAURead}, {KMmfUidFormatRAWWrite}, KMMFFourCCCodePCM16B, KMMFFourCCCodePCM16, KSampleRate44100Hz, KSampleRate22050Hz, KStereo, KMono, _S("44KHzPCM16Stereo1KHzTone.au"), _S("44KHzPCM16StereoAUTo22KHzPCM16Mono.raw"), KErrNone },
81 { _S("MM-MMF-ACTRL-U-0045-HP"), {KMmfUidFormatAURead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCM16B, KMMFFourCCCodePCM16, KSampleRate22050Hz, KSampleRate8000Hz, KMono, KMono, _S("22KHzPCM16Mono1KHzTone.au"), _S("22KHzPCM16MonoAUTo8KhzPCM16Mono.wav"), KErrNone },
82 { _S("MM-MMF-ACTRL-U-0046-HP"), {KMmfUidFormatRAWRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodeGSM610, KMMFFourCCCodePCM16, KSampleRate8000Hz, KSampleRate8000Hz, KMono, KMono, _S("8KHzGSM610Mono1KHzTone.raw"), _S("8KHzGSM610MonoRAWTo8KHzPCM16Mono.wav"), KErrNone },
83 { _S("MM-MMF-ACTRL-U-0047-HP"), {KMmfUidFormatRAWRead}, {KMmfUidFormatRAWWrite}, KMMFFourCCCodeALAW, KMMFFourCCCodePCM16, KSampleRate22050Hz, KSampleRate11025Hz, KStereo, KMono, _S("22KHzALAWStereo1KHzTone.raw"), _S("22KHzALAWStereoRAWTo11KHzPCM16Mono.raw"), KErrNone },
84 { _S("MM-MMF-ACTRL-U-0048-HP"), {KMmfUidFormatRAWRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodeGSM610, KSampleRate11025Hz, KSampleRate8000Hz, KMono, KMono, _S("11KHzPCM16Mono1KHzTone.raw"), _S("11KHzPCM16MonoRAWTo8KHzGSM610Mono.wav"), KErrNone },
85 { _S("MM-MMF-ACTRL-U-0049-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodeALAW, KMMFFourCCCodePCM16, KSampleRate22050Hz, KSampleRate8000Hz, KMono, KMono, _S("22KHzALAWMono1KHzTone.wav"), _S("22KHzALAWMonoWAVTo8KHzPCM16Mono.wav"), KErrNone },
86 { _S("MM-MMF-ACTRL-U-0050-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodeMuLAW, KSampleRate11025Hz, KSampleRate8000Hz, KStereo, KMono, _S("11KHzPCM16Stereo1KHzTone.wav"), _S("11KHzPCM16StereoWAVTo8KHzMuLAWMono.wav"), KErrNone },
87 { _S("MM-MMF-ACTRL-U-0051-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodeGSM610, KSampleRate8000Hz, KSampleRate8000Hz, KStereo, KMono, _S("8KHzPCM16Stereo1KHzTone.wav"), _S("8KHzPCM16StereoWAVTo8KHzGSM610Mono.wav"), KErrNone },
89 // test 52 not currently supported - should return -5
90 { _S("MM-MMF-ACTRL-U-0052-HP"), {KMmfUidFormatAURead}, {KMmfUidFormatAUWrite}, KMMFFourCCCodePCM16B, KMMFFourCCCodeIMAD, KSampleRate22050Hz, KSampleRate8000Hz, KMono, KMono, _S("22KHzPCM16Mono1KHzTone.au"), _S("NoReferenceFile"), KErrNotSupported },
92 { _S("MM-MMF-ACTRL-U-0053-HP"), {KMmfUidFormatRAWRead}, {KMmfUidFormatAUWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodePCM16B, KSampleRate44100Hz, KSampleRate8000Hz, KStereo, KStereo, _S("44KHzPCM16Stereo1KHzTone.raw"), _S("44KHzPCM16StereoRAWTo8KHzPCM16Stereo.au"), KErrNone },
94 // test below will return -5
95 { _S("MM-MMF-ACTRL-U-0054-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodePCM16, KSampleRate11025Hz, KSampleRate44100Hz, KStereo, KStereo, _S("11KHzPCM16Stereo1KHzTone.wav"), _S("NoReferenceFile"), KErrNotSupported },
96 { _S("MM-MMF-ACTRL-U-0055-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatAUWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodeIMAD, KSampleRate22050Hz, KSampleRate22050Hz, KStereo, KStereo, _S("22KHzPCM16Stereo1KHzTone.wav"), _S("NoReferenceFile"), KErrNotSupported },
98 // replacement for test 039 - see DEF017344
99 { _S("MM-MMF-ACTRL-U-0039-HP"), {KMmfUidFormatAURead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCM8, KMMFFourCCCodePCM16, KSampleRate11025Hz, KSampleRate8000Hz, KMono, KMono, _S("NewMail.au"), _S("11KHzPCMU8MonoAUTo8KHzPCM16Mono.wav"), KErrNone },
101 //DEF025783 - Convert Stereo PCM16 to IMA ADPCM
102 //Sink channels are not configured, we are testing if negotiation will do this
103 { _S("MM-MMF-ACTRL-U-0056-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodeIMAD, KSampleRate11025Hz, KSampleRate11025Hz, KStereo, KNone, _S("11KHzPCM16Stereo1KHzTone.wav"), _S("11KHzPCM16StereoWAVTo11KHzADPCMMono.wav"), KErrNone },
104 { _S("MM-MMF-ACTRL-U-0057-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatRAWWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodeIMAD, KSampleRate11025Hz, KSampleRate11025Hz, KStereo, KNone, _S("11KHzPCM16Stereo1KHzTone.wav"), _S("11KHzPCM16StereoWAVTo11KHzADPCMMono.raw"), KErrNone },
105 //Configure sink channels to stereo expect KErrNotSupported
106 { _S("MM-MMF-ACTRL-U-0058-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodeIMAD, KSampleRate11025Hz, KSampleRate11025Hz, KStereo, KStereo, _S("11KHzPCM16Stereo1KHzTone.wav"), _S("11KHzPCM16StereoWAVTo11KHzADPCMMono.wav"), KErrNotSupported },
107 { _S("MM-MMF-ACTRL-U-0059-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatRAWWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodeIMAD, KSampleRate11025Hz, KSampleRate11025Hz, KStereo, KStereo, _S("11KHzPCM16Stereo1KHzTone.wav"), _S("11KHzPCM16StereoWAVTo11KHzADPCMMono.raw"), KErrNotSupported }
114 * Test step constructor.
115 * Each test step initialises its own name.
118 CTestStepActrlPlay::CTestStepActrlPlay()
120 // store the name of this test case
121 // this is the name that is used by the script file
122 iTestStepName = _L("MM-MMF-ACTRL-U-0018-HP");
127 * Test step destructor.
130 CTestStepActrlPlay::~CTestStepActrlPlay()
138 * @return "TVerdict" the status of the test
139 * The result of the test step
141 TVerdict CTestStepActrlPlay::DoTestStepL( void )
143 TVerdict result = EPass;
145 _LIT( KTestPlay, "Play Test");
148 _LIT( KTestStepPlay, "This test checks playing an audio clip");
149 Log( KTestStepPlay );
151 // [ audio file to play ]
152 _LIT(KTestWavFile, "newmail.wav");
153 //[ configure the filename ]
154 SetReadFileNameL( KTestWavFile );
156 TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
157 User::LeaveIfError( errorCode );
159 //[ add data source and sink and prime the controller ]
160 errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
161 User::LeaveIfError( errorCode );
163 errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
164 User::LeaveIfError( errorCode );
166 errorCode = iController.Prime();
167 User::LeaveIfError( errorCode );
169 // [ wait for and process the return event from the audio output ]
171 TMMFEvent primeEvent( KPrimeTestId, KErrNone);
172 result = SearchForEvent( primeEvent );
173 if( result == EFail )
178 User::LeaveIfError( iController.Play() );
180 // note this test does not wait around
181 // to detect that the audio has been played
182 // [ now process the confirmation event that play has reached audio output
183 // this is the raison detre of the test ]
184 TMMFEvent playEvent( KPlayTestId, KErrNone );
186 result = SearchForEvent( playEvent );
188 //[ ensure the controller is unloaded so that it does
189 // not interfere with the following test ]
190 // There is error in this code and the stop followed by reset
191 // ensure the controller resources are released.
196 // test steps return a result
203 * @param aTimesToPlay
206 CTestStepPlayT::CTestStepPlayT( TInt aTimesToPlay )
207 : iTimesToPlay( aTimesToPlay )
209 // store the name of this test case
210 // this is the name that is used by the script file
211 iTestStepName = _L("MM-MMF-ACTRL-U-0004-HP");
218 CTestStepPlayT::~CTestStepPlayT()
224 * Each test step must supply an implementation for DoTestStepL.
225 * This Test step will play an audio clip n
227 * @return "TVerdict" the status of the test
228 * The result of the test step
230 TVerdict CTestStepPlayT::DoTestStepL()
233 TVerdict result = EPass;
235 _LIT( KTestPlay, "Play Test");
238 _LIT( KTestStepPlay, "This test checks playing an audio clip n times");
239 Log( KTestStepPlay );
241 // [ audio file to play ]
242 _LIT(KTestWavFile, "newmail.wav");
243 SetReadFileNameL( KTestWavFile );
245 TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
246 User::LeaveIfError( errorCode );
248 //[ add data source and sink and prime the controller ]
249 errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
250 User::LeaveIfError( errorCode );
252 errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
253 User::LeaveIfError( errorCode );
256 for( TInt iTimes = 0; iTimes < iTimesToPlay; iTimes++)
258 errorCode = iController.Prime();
259 User::LeaveIfError( errorCode );
261 // [ wait for and process the return event from the audio output ]
263 TMMFEvent primeEvent( KPrimeTestId, KErrNone);
264 TVerdict primeResult = SearchForEvent( primeEvent );
265 if( primeResult == EFail )
270 User::LeaveIfError( iController.Play() );
272 // note this test does not wait around
273 // to detect that the audio has been played
274 // [ now process the confirmation event that play has reached audio output
275 // this is the raison detre of the test ]
276 TMMFEvent playEvent( KPlayTestId, KErrNone );
278 TVerdict playResult = SearchForEvent( playEvent );
279 if( playResult == EFail )
284 // [ lets ensure we are stopped ]
285 User::LeaveIfError( iController.Stop() );
288 //[ ensure the controller is unloaded so that it does
289 // not interfere with the following test ]
290 // There is error in this code and the stop followed by reset
291 // ensure the controller resources are released.
297 // test steps return a result
306 CTestStepPause::CTestStepPause()
308 iTestStepName = _L("MM-MMF-ACTRL-U-0011-HP");
316 CTestStepPause::~CTestStepPause()
323 * This test checks the pause function
326 TVerdict CTestStepPause::DoTestStepL()
330 TVerdict result = EFail;
332 _LIT( KTestPlay, "Pause Test");
335 _LIT( KTestStepPlay, "This test checks the pause function");
336 Log( KTestStepPlay );
338 // [ audio file to play ]
339 _LIT(KTestWavFile, "newmail.wav");
340 SetReadFileNameL( KTestWavFile );
342 TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
343 User::LeaveIfError( errorCode );
345 //[ add data source and sink and prime the controller ]
346 errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
347 User::LeaveIfError( errorCode );
349 errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
350 User::LeaveIfError( errorCode );
352 // [ The controller is in the stopped state
353 // and should return an error if pause is called ]
355 TInt pauseError = iController.Pause();
356 if( pauseError == KErrNone )
358 // [ we should not be able to call pause while stopped ]
363 TMMFEvent pauseFailEvent( KPauseTestId, pauseError );
364 result = SearchForEvent( pauseFailEvent );
365 if( result == EFail )
370 // [ move the contoller to the primed state ]
371 errorCode = iController.Prime();
372 User::LeaveIfError( errorCode );
374 //[ call pause in the paused state
375 // should return no error ]
376 pauseError = iController.Pause();
377 if( pauseError == KErrNone )
379 //[calling paused while paused returns an error]
384 // [ wait for and process the return event from the audio output ]
385 TMMFEvent primeEvent( KPrimeTestId, KErrNone );
386 result = SearchForEvent( primeEvent );
387 if( result == EFail )
392 result = SearchForEvent( pauseFailEvent );
393 if( result == EFail )
398 User::LeaveIfError( iController.Play() );
400 // [ process the play event ]
401 TMMFEvent playEvent( KPlayTestId, KErrNone );
402 result = SearchForEvent( playEvent );
403 if( result == EFail )
408 // [ now call pause when playing ]
409 TMMFEvent pausePassEvent( KPauseTestId, KErrNone );
410 pauseError = iController.Pause();
411 if( pauseError != KErrNone )
413 //[calling paused while paused returns an error]
418 // note this test does not wait around
419 // to detect that the audio has been played
420 // [ now process the confirmation event that play has reached audio output
421 // this is the raison detre of the test ]
422 result = SearchForEvent( pausePassEvent );
423 if( result == EFail )
428 // [ we should now be in the paused state
430 User::LeaveIfError( iController.Play() );
431 result = SearchForEvent( playEvent );
432 if( result == EFail )
437 //[ ensure the controller is unloaded so that it does
438 // not interfere with the following test ]
439 // There is error in this code and the stop followed by reset
440 // ensure the controller resources are released.
455 CTestStepStop::CTestStepStop()
457 iTestStepName = _L("MM-MMF-ACTRL-U-0012-HP");
465 CTestStepStop::~CTestStepStop()
472 * This test checks the stop function on the controller
475 TVerdict CTestStepStop::DoTestStepL()
479 TVerdict result = EFail;
481 _LIT( KTestPlay, "Stop Test");
484 _LIT( KTestStepPlay, "This test checks the stop function");
485 Log( KTestStepPlay );
487 // [ audio file to play ]
488 _LIT(KTestWavFile, "newmail.wav");
489 SetReadFileNameL( KTestWavFile );
491 TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
492 User::LeaveIfError( errorCode );
494 //[ add data source and sink and prime the controller ]
495 errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
496 User::LeaveIfError( errorCode );
498 errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
499 User::LeaveIfError( errorCode );
501 //[ call stop while stopped ]
502 User::LeaveIfError( iController.Stop() );
505 // [ go to primed and call stop ]
506 errorCode = iController.Prime();
507 User::LeaveIfError( errorCode );
509 // [ wait for and process the return event from the audio output ]
511 TMMFEvent primeEvent( KPrimeTestId, KErrNone);
512 result = SearchForEvent( primeEvent );
513 if( result == EFail )
518 User::LeaveIfError( iController.Stop() );
520 // [ go to play and call stop ]
521 errorCode = iController.Prime();
522 User::LeaveIfError( errorCode );
524 // [ wait for and process the return event from the audio output ]
526 result = SearchForEvent( primeEvent );
527 if( result == EFail )
532 User::LeaveIfError( iController.Play() );
534 // note this test does not wait around
535 // to detect that the audio has been played
536 // [ now process the confirmation event that play has reached audio output
537 // this is the raison detre of the test ]
538 TMMFEvent playEvent( KPlayTestId, KErrNone );
539 result = SearchForEvent( playEvent );
540 if( result == EFail )
545 User::LeaveIfError( iController.Stop() );
548 // [ go to prime from stopped via playing ]
555 errorCode = iController.Prime();
556 User::LeaveIfError( errorCode );
558 // [ wait for and process the return event from the audio output ]
560 result = SearchForEvent( primeEvent );
561 if( result == EFail )
566 User::LeaveIfError( iController.Play() );
568 // note this test does not wait around
569 // to detect that the audio has been played
570 // [ now process the confirmation event that play has reached audio output
571 // this is the raison detre of the test ]
572 result = SearchForEvent( playEvent );
573 if( result == EFail )
578 // [ now call pause when playing ]
579 TMMFEvent pausePassEvent( KPauseTestId, KErrNone );
580 TInt pauseError = iController.Pause();
581 if( pauseError != KErrNone )
583 //[calling paused while paused returns an error]
588 // note this test does not wait around
589 // to detect that the audio has been played
590 // [ now process the confirmation event that play has reached audio output
591 // this is the raison detre of the test ]
592 result = SearchForEvent( pausePassEvent );
593 if( result == EFail )
598 // [ now stop from paused ]
599 User::LeaveIfError( iController.Stop() );
601 //[ ensure the controller is unloaded so that it does
602 // not interfere with the following test ]
603 // There is error in this code and the stop followed by reset
604 // ensure the controller resources are released.
615 * CTestStepConvertFormat
618 CTestStepConvertFormat::CTestStepConvertFormat( TUint aTestIndex )
620 // store a pointer to the test parameters
621 iTestParameters = &(KTestParameters[aTestIndex]);
623 // store the name of this test case
624 // this is the name that is used by the script file
625 iTestStepName = iTestParameters->iTestName;
630 * ~CTestStepConvertFormat
633 CTestStepConvertFormat::~CTestStepConvertFormat()
641 TVerdict CTestStepConvertFormat::DoTestStepPreambleL(void)
643 // connect to the file server
644 User::LeaveIfError(iFs.Connect());
646 // call the superclass
647 return CTestStepActrl::DoTestStepPreambleL();
651 TVerdict CTestStepConvertFormat::DoTestStepPostambleL(void)
653 // close connection with the file server
656 // call the superclass
657 return CTestStepActrl::DoTestStepPostambleL();
661 * Compare two binary files
663 * @param "const TDesC& aFile1"
664 * The first file to compare
665 * @param "const TDesC& aFile2"
666 * The second file to compare
668 * Will leave with appropriate system codes if a problem is encountered reading either file
670 * EPass if the files are identical
675 TVerdict CTestStepConvertFormat::CompareFilesL(const TDesC& aFile1,const TDesC& aFile2)
679 User::LeaveIfError(file1.Open(iFs, aFile1, EFileShareAny | EFileStream | EFileRead));
680 CleanupClosePushL(file1);
682 User::LeaveIfError(file2.Open(iFs, aFile2, EFileShareAny | EFileStream | EFileRead));
683 CleanupClosePushL(file2);
685 TInt fileSize1, fileSize2;
687 TVerdict result = EPass;
688 TInt blockSize = 1024;
690 User::LeaveIfError(file1.Size(fileSize1));
691 User::LeaveIfError(file2.Size(fileSize2));
693 if (fileSize1 == fileSize2)
695 HBufC8* buf1 = HBufC8::NewMaxLC(blockSize);
696 TPtr8 buf1Ptr(buf1->Des());
697 HBufC8* buf2 = HBufC8::NewMaxLC(blockSize);
698 TPtr8 buf2Ptr(buf2->Des());
702 while (length<fileSize1 && result == EPass)
706 if (fileSize1 - length > blockSize)
707 copySize = blockSize;
709 copySize = fileSize1 - length;
710 User::LeaveIfError(file1.Read(buf1Ptr,copySize));
711 User::LeaveIfError(file2.Read(buf2Ptr,copySize));
713 TInt comp_res = Mem::Compare(buf1Ptr.Ptr(),copySize,buf2Ptr.Ptr(),copySize);
717 INFO_PRINTF5(_L("Comparison Failed, comparison failed (%S, %S), result=%d at offset %d"),
718 &aFile1, &aFile2, comp_res, length);
725 CleanupStack::PopAndDestroy(2); // buf1, buf2
729 INFO_PRINTF5(_L("Comparison Failed, files are different sizes (%S, %S), (%d,%d)"),
730 &aFile1, &aFile2, fileSize1, fileSize2);
737 CleanupStack::PopAndDestroy(2); //file1, file2
744 * This test checks the stop function on the controller
747 TVerdict CTestStepConvertFormat::DoTestStepL( void )
749 TVerdict result = EPass;
752 // do the conversion step
753 TRAP(error, result = DoConvertStepL( ));
755 if (error != iTestParameters->iExpectedResult )
757 INFO_PRINTF2(_L("Error - Test step returned %d"), error);
761 //[ delete output file after comparison]
762 //[ here because DoTestStepL() can leave ]
763 TInt ret = iFs.Delete( WriteFileConfig()().iPath );
764 if (ret != KErrNone && ret != KErrNotFound)
766 INFO_PRINTF2(_L("Error deleting file - Delete returned %d"), ret);
769 //[ ensure the controller is unloaded so that it does
770 // not interfere with the following test ]
771 // There is error in this code and the stop followed by reset
772 // ensure the controller resources are released.
782 * Do the conversion of the files
783 * @return "TVerdict" the result of the convert operation
785 TVerdict CTestStepConvertFormat::DoConvertStepL( void )
787 TVerdict result = EPass;
789 _LIT( KTestConvertFormat, "Convert Formats Test");
790 Log( KTestConvertFormat );
792 _LIT( KTestStepPlay, "This test checks converting an audio clip");
793 Log( KTestStepPlay );
795 // get filename of input file
796 TInt strLen = User::StringLength(iTestParameters->iFromFilename);
797 TPtrC ptr( iTestParameters->iFromFilename, strLen );
799 //[ configure the filename ]
800 SetReadFileNameL( ptr );
802 //[ configure reference filename ]
803 strLen = User::StringLength(iTestParameters->iRefFilename);
804 ptr.Set( iTestParameters->iRefFilename, strLen );
806 SetRefFileNameL( ptr );
808 // [ converted audio file name ]
809 //_LIT(KTestOutFile, "ConvertedOutput");
810 TBuf<32> testFileName = _L("ConvertedOutput");
812 switch ( iTestParameters->iDestFormat.iUid )
814 case KMmfUidFormatRAWWrite:
815 testFileName.Append( _L(".raw") );
818 case KMmfUidFormatWAVWrite:
819 testFileName.Append( _L(".wav") );
822 case KMmfUidFormatAUWrite:
823 testFileName.Append( _L(".au") );
827 // not a recognised output format - use .tmp
828 testFileName.Append( _L(".tmp") );
832 //[ configure the filename ]
833 SetWriteFileNameL( testFileName );
835 // open the audio controller
836 TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
837 User::LeaveIfError( errorCode );
839 //[ add data source and sink and prime the controller ]
840 errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
841 User::LeaveIfError( errorCode );
843 errorCode = iController.AddDataSink(KUidMmfFileSink, WriteFileConfig());
844 User::LeaveIfError( errorCode );
846 //[ attempt to get the sink num channels ]
847 RMMFAudioControllerCustomCommands theCommander( iController );
849 // if source data is RAW then need to complete the source format
850 if ( iTestParameters->iSrcFormat.iUid == KMmfUidFormatRAWRead )
853 errorCode = theCommander.SetSourceFormat( iTestParameters->iSrcFormat );
854 User::LeaveIfError( errorCode );
856 errorCode = theCommander.SetSourceDataType( iTestParameters->iSrcEncoding );
857 User::LeaveIfError( errorCode );
859 errorCode = theCommander.SetSourceSampleRate( iTestParameters->iSrcSampleRate );
860 User::LeaveIfError( errorCode );
862 errorCode = theCommander.SetSourceNumChannels( iTestParameters->iSrcChannels );
863 User::LeaveIfError( errorCode );
866 // set sink sample rate
867 errorCode = theCommander.SetSinkSampleRate( iTestParameters->iDestSampleRate );
868 User::LeaveIfError( errorCode );
870 // set sink number of channels
871 if(iTestParameters->iDestChannels != KNone)
873 errorCode = theCommander.SetSinkNumChannels( iTestParameters->iDestChannels );
874 User::LeaveIfError( errorCode );
877 //[ ok lets try to set the sink format ]
878 errorCode = theCommander.SetSinkFormat( iTestParameters->iDestFormat );
879 User::LeaveIfError( errorCode );
881 //[ set the sink data type ]
882 errorCode = theCommander.SetSinkDataType( iTestParameters->iDestEncoding );
883 User::LeaveIfError( errorCode );
885 errorCode = iController.Prime();
886 User::LeaveIfError( errorCode );
888 // [ wait for and process the return event from the audio output ]
889 TMMFEvent primeEvent( KPrimeTestId, KErrNone);
890 result = SearchForEvent( primeEvent );
891 if( result == EFail )
896 errorCode = iController.Play();
897 User::LeaveIfError( errorCode );
899 // note this test does not wait around
900 // to detect that the audio has been played
901 // [ now process the confirmation event that play has reached audio output
902 // this is the raison detre of the test ]
903 TMMFEvent playEvent( KPlayTestId, KErrNone );
905 result = SearchForEvent( playEvent );
906 if( result == EFail )
911 //[ now wait for play complete event]
912 TMMFEvent playCompleteEvent( KPlayCompleteTestId, KErrNone);
913 result = SearchForEvent( playCompleteEvent );
914 if( result == EFail )
919 //[ now compare the file produced with a reference file ]
920 INFO_PRINTF1(_L("Comparing file to reference..."));
921 result = CompareFilesL( RefFileName()().iPath, WriteFileConfig()().iPath);
925 INFO_PRINTF1(_L("Comparison Failed - Files are not identical !"));
937 void CTestStepConvertFormat::SetRefFileNameL( const TDesC& aPathNameAndExtn )
939 //[ append the filename relative to the default path ]
940 TFileName fileName = GetSuite()->DefaultPath();
941 fileName.Append(aPathNameAndExtn);
942 iFileConfigRef().iPath = fileName ;
949 TMMFFileConfig& CTestStepConvertFormat::RefFileName()
951 return iFileConfigRef;
956 * CTestStepRampVolume
958 CTestStepRampVolume::CTestStepRampVolume()
960 iTestStepName = _L("MM-MMF-ACTRL-U-0064-HP");
965 * ~CTestStepRampVolume
967 CTestStepRampVolume::~CTestStepRampVolume()
973 * CTestStepRampVolume
975 TVerdict CTestStepRampVolume::DoTestStepL()
977 TVerdict result = EPass;
979 _LIT( KTestVolumeRamp, "Volume Ramp Test");
980 Log( KTestVolumeRamp );
982 _LIT( KTestStepPlay, "This test checks volume ramp");
983 Log( KTestStepPlay );
985 // [ audio file to play ]
986 _LIT(KTestWavFile, "RampVolume.wav");
987 //[ configure the filename ]
988 SetReadFileNameL( KTestWavFile );
990 TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
991 User::LeaveIfError( errorCode );
993 //[ add data source and sink and prime the controller ]
994 errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
995 User::LeaveIfError( errorCode );
997 errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
998 User::LeaveIfError( errorCode );
1000 errorCode = iController.Prime();
1001 User::LeaveIfError( errorCode );
1003 // [ wait for and process the return event from the audio output ]
1004 //[ attempt to get the sink num channels ]
1005 RMMFAudioPlayDeviceCustomCommands theCommander( iController );
1006 //[lets say 2 seconds for now ]
1007 TTimeIntervalMicroSeconds aRampDuration( 2000000);
1008 errorCode = theCommander.SetVolumeRamp( aRampDuration);
1009 User::LeaveIfError( errorCode );
1011 TMMFEvent primeEvent( KPrimeTestId, KErrNone);
1012 result = SearchForEvent( primeEvent );
1013 if( result == EFail )
1018 //[ lets set the volume ramp before we play ]
1021 User::LeaveIfError( iController.Play() );
1023 // note this test does not wait around
1024 // to detect that the audio has been played
1025 // [ now process the confirmation event that play has reached audio output
1026 // this is the raison detre of the test ]
1027 TMMFEvent playEvent( KPlayTestId, KErrNone );
1028 result = SearchForEvent( playEvent );
1029 if( result == EFail )
1034 //[ now wait for play complete event]
1035 TMMFEvent playCompleteEvent( KPlayCompleteTestId, KErrNone);
1036 result = SearchForEvent( playCompleteEvent );
1037 if( result == EFail )
1042 //[ ensure the controller is unloaded so that it does
1043 // not interfere with the following test ]
1044 // There is error in this code and the stop followed by reset
1045 // ensure the controller resources are released.
1047 iController.Reset();
1048 iController.Close();
1050 // test steps return a result
1056 * CTestStepRampVolume
1058 TVerdict CTestStepRampVolume::DoTestStepPreambleL(void)
1065 * CTestStepRampVolume
1067 TVerdict CTestStepRampVolume::DoTestStepPostambleL(void)
1069 return CTestStepActrl::DoTestStepPostambleL();