sl@0
|
1 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// TestStepActrlPlay
|
sl@0
|
15 |
//
|
sl@0
|
16 |
|
sl@0
|
17 |
#include <e32std.h>
|
sl@0
|
18 |
#include <e32base.h>
|
sl@0
|
19 |
#include <mmf/common/mmfcontroller.h>
|
sl@0
|
20 |
#include <mmf/server/mmffile.h>
|
sl@0
|
21 |
#include <mmf/server/mmfdes.h>
|
sl@0
|
22 |
#include <mmf/plugin/mmfcontrollerimplementationuids.hrh>
|
sl@0
|
23 |
#include <mmf/common/mmfstandardcustomcommands.h>
|
sl@0
|
24 |
|
sl@0
|
25 |
#include "ActrlTestUids.h"
|
sl@0
|
26 |
|
sl@0
|
27 |
// Test system includes
|
sl@0
|
28 |
#include <testframework.h>
|
sl@0
|
29 |
|
sl@0
|
30 |
// Specific includes for this test suite
|
sl@0
|
31 |
#include "TS_MMF_ACTRL_TestStep.h"
|
sl@0
|
32 |
#include "TS_MMF_ACTRL_TestSuite.h"
|
sl@0
|
33 |
|
sl@0
|
34 |
// Specific includes for these test steps
|
sl@0
|
35 |
#include "TestStepActrlPlay.h"
|
sl@0
|
36 |
|
sl@0
|
37 |
// CONSTANTS
|
sl@0
|
38 |
//const TInt KPlayDelayNewMail = 100000000; //arbitrary delay // EABI warning removal
|
sl@0
|
39 |
|
sl@0
|
40 |
const TUint KSampleRate8000Hz = 8000;
|
sl@0
|
41 |
const TUint KSampleRate11025Hz = 11025;
|
sl@0
|
42 |
const TUint KSampleRate22050Hz = 22050;
|
sl@0
|
43 |
const TUint KSampleRate44100Hz = 44100;
|
sl@0
|
44 |
|
sl@0
|
45 |
const TUint KNone = 0;
|
sl@0
|
46 |
const TUint KMono = 1;
|
sl@0
|
47 |
const TUint KStereo = 2;
|
sl@0
|
48 |
|
sl@0
|
49 |
//const TUint KFormatWAV = 0;
|
sl@0
|
50 |
//const TUint KFormatAU = 1;
|
sl@0
|
51 |
//const TUint KFormatRAW = 2;
|
sl@0
|
52 |
|
sl@0
|
53 |
// parameter structure for conversion tests
|
sl@0
|
54 |
class TConvParameters
|
sl@0
|
55 |
{
|
sl@0
|
56 |
public:
|
sl@0
|
57 |
const TText* iTestName;
|
sl@0
|
58 |
TUid iSrcFormat;
|
sl@0
|
59 |
TUid iDestFormat;
|
sl@0
|
60 |
TUint32 iSrcEncoding;
|
sl@0
|
61 |
TUint32 iDestEncoding;
|
sl@0
|
62 |
TUint iSrcSampleRate;
|
sl@0
|
63 |
TUint iDestSampleRate;
|
sl@0
|
64 |
TUint iSrcChannels;
|
sl@0
|
65 |
TUint iDestChannels;
|
sl@0
|
66 |
const TText* iFromFilename;
|
sl@0
|
67 |
const TText* iRefFilename;
|
sl@0
|
68 |
TInt iExpectedResult;
|
sl@0
|
69 |
};
|
sl@0
|
70 |
|
sl@0
|
71 |
|
sl@0
|
72 |
// constant table of parameters for tests
|
sl@0
|
73 |
const TConvParameters KTestParameters[] =
|
sl@0
|
74 |
{
|
sl@0
|
75 |
// straight encode test
|
sl@0
|
76 |
{ _S("MM-MMF-ACTRL-U-0040-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatAUWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodePCM16B, KSampleRate44100Hz, KSampleRate8000Hz, KStereo, KMono, _S("44KHzPCM16Stereo1KHzTone.wav"), _S("44KHzPCM16StereoWAVTo8KHzPCM16Mono.au"), KErrNone },
|
sl@0
|
77 |
{ _S("MM-MMF-ACTRL-U-0041-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCMU8, KMMFFourCCCodePCM16, KSampleRate22050Hz, KSampleRate11025Hz, KMono, KStereo, _S("22KHzPCM8Mono1KHzTone.wav"), _S("22KHzPCM8MonoWAVTo11KHzPCM16Stereo.wav"), KErrNone },
|
sl@0
|
78 |
{ _S("MM-MMF-ACTRL-U-0042-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatRAWWrite}, KMMFFourCCCodeIMAD, KMMFFourCCCodePCM16, KSampleRate11025Hz, KSampleRate8000Hz, KMono, KMono, _S("11KHzADPCMMono1KHzTone.wav"), _S("11KHzADPCMMonoWAVTo8KHzPCM16Mono.raw"), KErrNone },
|
sl@0
|
79 |
{ _S("MM-MMF-ACTRL-U-0043-HP"), {KMmfUidFormatAURead}, {KMmfUidFormatAUWrite}, KMMFFourCCCodePCM16B, KMMFFourCCCodePCM16B, KSampleRate8000Hz, KSampleRate8000Hz, KMono, KMono, _S("8KHzPCM16Mono1KHzTone.au"), _S("8KHzPCM16MonoAUTo8KHzPCM16Mono.au"), KErrNone },
|
sl@0
|
80 |
{ _S("MM-MMF-ACTRL-U-0044-HP"), {KMmfUidFormatAURead}, {KMmfUidFormatRAWWrite}, KMMFFourCCCodePCM16B, KMMFFourCCCodePCM16, KSampleRate44100Hz, KSampleRate22050Hz, KStereo, KMono, _S("44KHzPCM16Stereo1KHzTone.au"), _S("44KHzPCM16StereoAUTo22KHzPCM16Mono.raw"), KErrNone },
|
sl@0
|
81 |
{ _S("MM-MMF-ACTRL-U-0045-HP"), {KMmfUidFormatAURead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCM16B, KMMFFourCCCodePCM16, KSampleRate22050Hz, KSampleRate8000Hz, KMono, KMono, _S("22KHzPCM16Mono1KHzTone.au"), _S("22KHzPCM16MonoAUTo8KhzPCM16Mono.wav"), KErrNone },
|
sl@0
|
82 |
{ _S("MM-MMF-ACTRL-U-0046-HP"), {KMmfUidFormatRAWRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodeGSM610, KMMFFourCCCodePCM16, KSampleRate8000Hz, KSampleRate8000Hz, KMono, KMono, _S("8KHzGSM610Mono1KHzTone.raw"), _S("8KHzGSM610MonoRAWTo8KHzPCM16Mono.wav"), KErrNone },
|
sl@0
|
83 |
{ _S("MM-MMF-ACTRL-U-0047-HP"), {KMmfUidFormatRAWRead}, {KMmfUidFormatRAWWrite}, KMMFFourCCCodeALAW, KMMFFourCCCodePCM16, KSampleRate22050Hz, KSampleRate11025Hz, KStereo, KMono, _S("22KHzALAWStereo1KHzTone.raw"), _S("22KHzALAWStereoRAWTo11KHzPCM16Mono.raw"), KErrNone },
|
sl@0
|
84 |
{ _S("MM-MMF-ACTRL-U-0048-HP"), {KMmfUidFormatRAWRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodeGSM610, KSampleRate11025Hz, KSampleRate8000Hz, KMono, KMono, _S("11KHzPCM16Mono1KHzTone.raw"), _S("11KHzPCM16MonoRAWTo8KHzGSM610Mono.wav"), KErrNone },
|
sl@0
|
85 |
{ _S("MM-MMF-ACTRL-U-0049-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodeALAW, KMMFFourCCCodePCM16, KSampleRate22050Hz, KSampleRate8000Hz, KMono, KMono, _S("22KHzALAWMono1KHzTone.wav"), _S("22KHzALAWMonoWAVTo8KHzPCM16Mono.wav"), KErrNone },
|
sl@0
|
86 |
{ _S("MM-MMF-ACTRL-U-0050-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodeMuLAW, KSampleRate11025Hz, KSampleRate8000Hz, KStereo, KMono, _S("11KHzPCM16Stereo1KHzTone.wav"), _S("11KHzPCM16StereoWAVTo8KHzMuLAWMono.wav"), KErrNone },
|
sl@0
|
87 |
{ _S("MM-MMF-ACTRL-U-0051-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodeGSM610, KSampleRate8000Hz, KSampleRate8000Hz, KStereo, KMono, _S("8KHzPCM16Stereo1KHzTone.wav"), _S("8KHzPCM16StereoWAVTo8KHzGSM610Mono.wav"), KErrNone },
|
sl@0
|
88 |
|
sl@0
|
89 |
// test 52 not currently supported - should return -5
|
sl@0
|
90 |
{ _S("MM-MMF-ACTRL-U-0052-HP"), {KMmfUidFormatAURead}, {KMmfUidFormatAUWrite}, KMMFFourCCCodePCM16B, KMMFFourCCCodeIMAD, KSampleRate22050Hz, KSampleRate8000Hz, KMono, KMono, _S("22KHzPCM16Mono1KHzTone.au"), _S("NoReferenceFile"), KErrNotSupported },
|
sl@0
|
91 |
|
sl@0
|
92 |
{ _S("MM-MMF-ACTRL-U-0053-HP"), {KMmfUidFormatRAWRead}, {KMmfUidFormatAUWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodePCM16B, KSampleRate44100Hz, KSampleRate8000Hz, KStereo, KStereo, _S("44KHzPCM16Stereo1KHzTone.raw"), _S("44KHzPCM16StereoRAWTo8KHzPCM16Stereo.au"), KErrNone },
|
sl@0
|
93 |
|
sl@0
|
94 |
// test below will return -5
|
sl@0
|
95 |
{ _S("MM-MMF-ACTRL-U-0054-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodePCM16, KSampleRate11025Hz, KSampleRate44100Hz, KStereo, KStereo, _S("11KHzPCM16Stereo1KHzTone.wav"), _S("NoReferenceFile"), KErrNotSupported },
|
sl@0
|
96 |
{ _S("MM-MMF-ACTRL-U-0055-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatAUWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodeIMAD, KSampleRate22050Hz, KSampleRate22050Hz, KStereo, KStereo, _S("22KHzPCM16Stereo1KHzTone.wav"), _S("NoReferenceFile"), KErrNotSupported },
|
sl@0
|
97 |
|
sl@0
|
98 |
// replacement for test 039 - see DEF017344
|
sl@0
|
99 |
{ _S("MM-MMF-ACTRL-U-0039-HP"), {KMmfUidFormatAURead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCM8, KMMFFourCCCodePCM16, KSampleRate11025Hz, KSampleRate8000Hz, KMono, KMono, _S("NewMail.au"), _S("11KHzPCMU8MonoAUTo8KHzPCM16Mono.wav"), KErrNone },
|
sl@0
|
100 |
|
sl@0
|
101 |
//DEF025783 - Convert Stereo PCM16 to IMA ADPCM
|
sl@0
|
102 |
//Sink channels are not configured, we are testing if negotiation will do this
|
sl@0
|
103 |
{ _S("MM-MMF-ACTRL-U-0056-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodeIMAD, KSampleRate11025Hz, KSampleRate11025Hz, KStereo, KNone, _S("11KHzPCM16Stereo1KHzTone.wav"), _S("11KHzPCM16StereoWAVTo11KHzADPCMMono.wav"), KErrNone },
|
sl@0
|
104 |
{ _S("MM-MMF-ACTRL-U-0057-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatRAWWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodeIMAD, KSampleRate11025Hz, KSampleRate11025Hz, KStereo, KNone, _S("11KHzPCM16Stereo1KHzTone.wav"), _S("11KHzPCM16StereoWAVTo11KHzADPCMMono.raw"), KErrNone },
|
sl@0
|
105 |
//Configure sink channels to stereo expect KErrNotSupported
|
sl@0
|
106 |
{ _S("MM-MMF-ACTRL-U-0058-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatWAVWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodeIMAD, KSampleRate11025Hz, KSampleRate11025Hz, KStereo, KStereo, _S("11KHzPCM16Stereo1KHzTone.wav"), _S("11KHzPCM16StereoWAVTo11KHzADPCMMono.wav"), KErrNotSupported },
|
sl@0
|
107 |
{ _S("MM-MMF-ACTRL-U-0059-HP"), {KMmfUidFormatWAVRead}, {KMmfUidFormatRAWWrite}, KMMFFourCCCodePCM16, KMMFFourCCCodeIMAD, KSampleRate11025Hz, KSampleRate11025Hz, KStereo, KStereo, _S("11KHzPCM16Stereo1KHzTone.wav"), _S("11KHzPCM16StereoWAVTo11KHzADPCMMono.raw"), KErrNotSupported }
|
sl@0
|
108 |
|
sl@0
|
109 |
};
|
sl@0
|
110 |
|
sl@0
|
111 |
|
sl@0
|
112 |
/**
|
sl@0
|
113 |
*
|
sl@0
|
114 |
* Test step constructor.
|
sl@0
|
115 |
* Each test step initialises its own name.
|
sl@0
|
116 |
*
|
sl@0
|
117 |
*/
|
sl@0
|
118 |
CTestStepActrlPlay::CTestStepActrlPlay()
|
sl@0
|
119 |
{
|
sl@0
|
120 |
// store the name of this test case
|
sl@0
|
121 |
// this is the name that is used by the script file
|
sl@0
|
122 |
iTestStepName = _L("MM-MMF-ACTRL-U-0018-HP");
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
/**
|
sl@0
|
126 |
*
|
sl@0
|
127 |
* Test step destructor.
|
sl@0
|
128 |
*
|
sl@0
|
129 |
*/
|
sl@0
|
130 |
CTestStepActrlPlay::~CTestStepActrlPlay()
|
sl@0
|
131 |
{
|
sl@0
|
132 |
}
|
sl@0
|
133 |
|
sl@0
|
134 |
|
sl@0
|
135 |
/**
|
sl@0
|
136 |
* @xxxx
|
sl@0
|
137 |
* Do the test step.
|
sl@0
|
138 |
* @return "TVerdict" the status of the test
|
sl@0
|
139 |
* The result of the test step
|
sl@0
|
140 |
*/
|
sl@0
|
141 |
TVerdict CTestStepActrlPlay::DoTestStepL( void )
|
sl@0
|
142 |
{
|
sl@0
|
143 |
TVerdict result = EPass;
|
sl@0
|
144 |
|
sl@0
|
145 |
_LIT( KTestPlay, "Play Test");
|
sl@0
|
146 |
Log( KTestPlay );
|
sl@0
|
147 |
|
sl@0
|
148 |
_LIT( KTestStepPlay, "This test checks playing an audio clip");
|
sl@0
|
149 |
Log( KTestStepPlay );
|
sl@0
|
150 |
|
sl@0
|
151 |
// [ audio file to play ]
|
sl@0
|
152 |
_LIT(KTestWavFile, "newmail.wav");
|
sl@0
|
153 |
//[ configure the filename ]
|
sl@0
|
154 |
SetReadFileNameL( KTestWavFile );
|
sl@0
|
155 |
|
sl@0
|
156 |
TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
|
sl@0
|
157 |
User::LeaveIfError( errorCode );
|
sl@0
|
158 |
|
sl@0
|
159 |
//[ add data source and sink and prime the controller ]
|
sl@0
|
160 |
errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
|
sl@0
|
161 |
User::LeaveIfError( errorCode );
|
sl@0
|
162 |
|
sl@0
|
163 |
errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
|
sl@0
|
164 |
User::LeaveIfError( errorCode );
|
sl@0
|
165 |
|
sl@0
|
166 |
errorCode = iController.Prime();
|
sl@0
|
167 |
User::LeaveIfError( errorCode );
|
sl@0
|
168 |
|
sl@0
|
169 |
// [ wait for and process the return event from the audio output ]
|
sl@0
|
170 |
|
sl@0
|
171 |
TMMFEvent primeEvent( KPrimeTestId, KErrNone);
|
sl@0
|
172 |
result = SearchForEvent( primeEvent );
|
sl@0
|
173 |
if( result == EFail )
|
sl@0
|
174 |
{
|
sl@0
|
175 |
return result;
|
sl@0
|
176 |
}
|
sl@0
|
177 |
|
sl@0
|
178 |
User::LeaveIfError( iController.Play() );
|
sl@0
|
179 |
|
sl@0
|
180 |
// note this test does not wait around
|
sl@0
|
181 |
// to detect that the audio has been played
|
sl@0
|
182 |
// [ now process the confirmation event that play has reached audio output
|
sl@0
|
183 |
// this is the raison detre of the test ]
|
sl@0
|
184 |
TMMFEvent playEvent( KPlayTestId, KErrNone );
|
sl@0
|
185 |
|
sl@0
|
186 |
result = SearchForEvent( playEvent );
|
sl@0
|
187 |
|
sl@0
|
188 |
//[ ensure the controller is unloaded so that it does
|
sl@0
|
189 |
// not interfere with the following test ]
|
sl@0
|
190 |
// There is error in this code and the stop followed by reset
|
sl@0
|
191 |
// ensure the controller resources are released.
|
sl@0
|
192 |
iController.Stop();
|
sl@0
|
193 |
iController.Reset();
|
sl@0
|
194 |
iController.Close();
|
sl@0
|
195 |
|
sl@0
|
196 |
// test steps return a result
|
sl@0
|
197 |
return result;
|
sl@0
|
198 |
}
|
sl@0
|
199 |
|
sl@0
|
200 |
/**
|
sl@0
|
201 |
*
|
sl@0
|
202 |
* CTestStepPlayT
|
sl@0
|
203 |
* @param aTimesToPlay
|
sl@0
|
204 |
*
|
sl@0
|
205 |
*/
|
sl@0
|
206 |
CTestStepPlayT::CTestStepPlayT( TInt aTimesToPlay )
|
sl@0
|
207 |
: iTimesToPlay( aTimesToPlay )
|
sl@0
|
208 |
{
|
sl@0
|
209 |
// store the name of this test case
|
sl@0
|
210 |
// this is the name that is used by the script file
|
sl@0
|
211 |
iTestStepName = _L("MM-MMF-ACTRL-U-0004-HP");
|
sl@0
|
212 |
}
|
sl@0
|
213 |
|
sl@0
|
214 |
/**
|
sl@0
|
215 |
*
|
sl@0
|
216 |
* ~CTestStepPlayT
|
sl@0
|
217 |
*/
|
sl@0
|
218 |
CTestStepPlayT::~CTestStepPlayT()
|
sl@0
|
219 |
{
|
sl@0
|
220 |
}
|
sl@0
|
221 |
|
sl@0
|
222 |
/**
|
sl@0
|
223 |
* Do the test step.
|
sl@0
|
224 |
* Each test step must supply an implementation for DoTestStepL.
|
sl@0
|
225 |
* This Test step will play an audio clip n
|
sl@0
|
226 |
* times
|
sl@0
|
227 |
* @return "TVerdict" the status of the test
|
sl@0
|
228 |
* The result of the test step
|
sl@0
|
229 |
*/
|
sl@0
|
230 |
TVerdict CTestStepPlayT::DoTestStepL()
|
sl@0
|
231 |
{
|
sl@0
|
232 |
__MM_HEAP_MARK;
|
sl@0
|
233 |
TVerdict result = EPass;
|
sl@0
|
234 |
|
sl@0
|
235 |
_LIT( KTestPlay, "Play Test");
|
sl@0
|
236 |
Log( KTestPlay );
|
sl@0
|
237 |
|
sl@0
|
238 |
_LIT( KTestStepPlay, "This test checks playing an audio clip n times");
|
sl@0
|
239 |
Log( KTestStepPlay );
|
sl@0
|
240 |
|
sl@0
|
241 |
// [ audio file to play ]
|
sl@0
|
242 |
_LIT(KTestWavFile, "newmail.wav");
|
sl@0
|
243 |
SetReadFileNameL( KTestWavFile );
|
sl@0
|
244 |
|
sl@0
|
245 |
TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
|
sl@0
|
246 |
User::LeaveIfError( errorCode );
|
sl@0
|
247 |
|
sl@0
|
248 |
//[ add data source and sink and prime the controller ]
|
sl@0
|
249 |
errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
|
sl@0
|
250 |
User::LeaveIfError( errorCode );
|
sl@0
|
251 |
|
sl@0
|
252 |
errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
|
sl@0
|
253 |
User::LeaveIfError( errorCode );
|
sl@0
|
254 |
|
sl@0
|
255 |
|
sl@0
|
256 |
for( TInt iTimes = 0; iTimes < iTimesToPlay; iTimes++)
|
sl@0
|
257 |
{
|
sl@0
|
258 |
errorCode = iController.Prime();
|
sl@0
|
259 |
User::LeaveIfError( errorCode );
|
sl@0
|
260 |
|
sl@0
|
261 |
// [ wait for and process the return event from the audio output ]
|
sl@0
|
262 |
|
sl@0
|
263 |
TMMFEvent primeEvent( KPrimeTestId, KErrNone);
|
sl@0
|
264 |
TVerdict primeResult = SearchForEvent( primeEvent );
|
sl@0
|
265 |
if( primeResult == EFail )
|
sl@0
|
266 |
{
|
sl@0
|
267 |
return primeResult;
|
sl@0
|
268 |
}
|
sl@0
|
269 |
|
sl@0
|
270 |
User::LeaveIfError( iController.Play() );
|
sl@0
|
271 |
|
sl@0
|
272 |
// note this test does not wait around
|
sl@0
|
273 |
// to detect that the audio has been played
|
sl@0
|
274 |
// [ now process the confirmation event that play has reached audio output
|
sl@0
|
275 |
// this is the raison detre of the test ]
|
sl@0
|
276 |
TMMFEvent playEvent( KPlayTestId, KErrNone );
|
sl@0
|
277 |
|
sl@0
|
278 |
TVerdict playResult = SearchForEvent( playEvent );
|
sl@0
|
279 |
if( playResult == EFail )
|
sl@0
|
280 |
{
|
sl@0
|
281 |
return playResult ;
|
sl@0
|
282 |
}
|
sl@0
|
283 |
|
sl@0
|
284 |
// [ lets ensure we are stopped ]
|
sl@0
|
285 |
User::LeaveIfError( iController.Stop() );
|
sl@0
|
286 |
}
|
sl@0
|
287 |
|
sl@0
|
288 |
//[ ensure the controller is unloaded so that it does
|
sl@0
|
289 |
// not interfere with the following test ]
|
sl@0
|
290 |
// There is error in this code and the stop followed by reset
|
sl@0
|
291 |
// ensure the controller resources are released.
|
sl@0
|
292 |
iController.Stop();
|
sl@0
|
293 |
iController.Reset();
|
sl@0
|
294 |
iController.Close();
|
sl@0
|
295 |
|
sl@0
|
296 |
__MM_HEAP_MARKEND;
|
sl@0
|
297 |
// test steps return a result
|
sl@0
|
298 |
return result;
|
sl@0
|
299 |
}
|
sl@0
|
300 |
|
sl@0
|
301 |
/*
|
sl@0
|
302 |
*
|
sl@0
|
303 |
* CTestStepPause
|
sl@0
|
304 |
*
|
sl@0
|
305 |
*/
|
sl@0
|
306 |
CTestStepPause::CTestStepPause()
|
sl@0
|
307 |
{
|
sl@0
|
308 |
iTestStepName = _L("MM-MMF-ACTRL-U-0011-HP");
|
sl@0
|
309 |
}
|
sl@0
|
310 |
|
sl@0
|
311 |
/*
|
sl@0
|
312 |
*
|
sl@0
|
313 |
* ~CTestStepPause
|
sl@0
|
314 |
*
|
sl@0
|
315 |
*/
|
sl@0
|
316 |
CTestStepPause::~CTestStepPause()
|
sl@0
|
317 |
{
|
sl@0
|
318 |
}
|
sl@0
|
319 |
|
sl@0
|
320 |
/*
|
sl@0
|
321 |
*
|
sl@0
|
322 |
* DoTestStepL
|
sl@0
|
323 |
* This test checks the pause function
|
sl@0
|
324 |
*
|
sl@0
|
325 |
*/
|
sl@0
|
326 |
TVerdict CTestStepPause::DoTestStepL()
|
sl@0
|
327 |
{
|
sl@0
|
328 |
__MM_HEAP_MARK;
|
sl@0
|
329 |
|
sl@0
|
330 |
TVerdict result = EFail;
|
sl@0
|
331 |
|
sl@0
|
332 |
_LIT( KTestPlay, "Pause Test");
|
sl@0
|
333 |
Log( KTestPlay );
|
sl@0
|
334 |
|
sl@0
|
335 |
_LIT( KTestStepPlay, "This test checks the pause function");
|
sl@0
|
336 |
Log( KTestStepPlay );
|
sl@0
|
337 |
|
sl@0
|
338 |
// [ audio file to play ]
|
sl@0
|
339 |
_LIT(KTestWavFile, "newmail.wav");
|
sl@0
|
340 |
SetReadFileNameL( KTestWavFile );
|
sl@0
|
341 |
|
sl@0
|
342 |
TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
|
sl@0
|
343 |
User::LeaveIfError( errorCode );
|
sl@0
|
344 |
|
sl@0
|
345 |
//[ add data source and sink and prime the controller ]
|
sl@0
|
346 |
errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
|
sl@0
|
347 |
User::LeaveIfError( errorCode );
|
sl@0
|
348 |
|
sl@0
|
349 |
errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
|
sl@0
|
350 |
User::LeaveIfError( errorCode );
|
sl@0
|
351 |
|
sl@0
|
352 |
// [ The controller is in the stopped state
|
sl@0
|
353 |
// and should return an error if pause is called ]
|
sl@0
|
354 |
|
sl@0
|
355 |
TInt pauseError = iController.Pause();
|
sl@0
|
356 |
if( pauseError == KErrNone )
|
sl@0
|
357 |
{
|
sl@0
|
358 |
// [ we should not be able to call pause while stopped ]
|
sl@0
|
359 |
result = EFail;
|
sl@0
|
360 |
return result ;
|
sl@0
|
361 |
}
|
sl@0
|
362 |
|
sl@0
|
363 |
TMMFEvent pauseFailEvent( KPauseTestId, pauseError );
|
sl@0
|
364 |
result = SearchForEvent( pauseFailEvent );
|
sl@0
|
365 |
if( result == EFail )
|
sl@0
|
366 |
{
|
sl@0
|
367 |
return result;
|
sl@0
|
368 |
}
|
sl@0
|
369 |
|
sl@0
|
370 |
// [ move the contoller to the primed state ]
|
sl@0
|
371 |
errorCode = iController.Prime();
|
sl@0
|
372 |
User::LeaveIfError( errorCode );
|
sl@0
|
373 |
|
sl@0
|
374 |
//[ call pause in the paused state
|
sl@0
|
375 |
// should return no error ]
|
sl@0
|
376 |
pauseError = iController.Pause();
|
sl@0
|
377 |
if( pauseError == KErrNone )
|
sl@0
|
378 |
{
|
sl@0
|
379 |
//[calling paused while paused returns an error]
|
sl@0
|
380 |
result = EFail;
|
sl@0
|
381 |
return result ;
|
sl@0
|
382 |
}
|
sl@0
|
383 |
|
sl@0
|
384 |
// [ wait for and process the return event from the audio output ]
|
sl@0
|
385 |
TMMFEvent primeEvent( KPrimeTestId, KErrNone );
|
sl@0
|
386 |
result = SearchForEvent( primeEvent );
|
sl@0
|
387 |
if( result == EFail )
|
sl@0
|
388 |
{
|
sl@0
|
389 |
return result;
|
sl@0
|
390 |
}
|
sl@0
|
391 |
|
sl@0
|
392 |
result = SearchForEvent( pauseFailEvent );
|
sl@0
|
393 |
if( result == EFail )
|
sl@0
|
394 |
{
|
sl@0
|
395 |
return result;
|
sl@0
|
396 |
}
|
sl@0
|
397 |
|
sl@0
|
398 |
User::LeaveIfError( iController.Play() );
|
sl@0
|
399 |
|
sl@0
|
400 |
// [ process the play event ]
|
sl@0
|
401 |
TMMFEvent playEvent( KPlayTestId, KErrNone );
|
sl@0
|
402 |
result = SearchForEvent( playEvent );
|
sl@0
|
403 |
if( result == EFail )
|
sl@0
|
404 |
{
|
sl@0
|
405 |
return result;
|
sl@0
|
406 |
}
|
sl@0
|
407 |
|
sl@0
|
408 |
// [ now call pause when playing ]
|
sl@0
|
409 |
TMMFEvent pausePassEvent( KPauseTestId, KErrNone );
|
sl@0
|
410 |
pauseError = iController.Pause();
|
sl@0
|
411 |
if( pauseError != KErrNone )
|
sl@0
|
412 |
{
|
sl@0
|
413 |
//[calling paused while paused returns an error]
|
sl@0
|
414 |
result = EFail;
|
sl@0
|
415 |
return result ;
|
sl@0
|
416 |
}
|
sl@0
|
417 |
|
sl@0
|
418 |
// note this test does not wait around
|
sl@0
|
419 |
// to detect that the audio has been played
|
sl@0
|
420 |
// [ now process the confirmation event that play has reached audio output
|
sl@0
|
421 |
// this is the raison detre of the test ]
|
sl@0
|
422 |
result = SearchForEvent( pausePassEvent );
|
sl@0
|
423 |
if( result == EFail )
|
sl@0
|
424 |
{
|
sl@0
|
425 |
return result;
|
sl@0
|
426 |
}
|
sl@0
|
427 |
|
sl@0
|
428 |
// [ we should now be in the paused state
|
sl@0
|
429 |
// try playing ]
|
sl@0
|
430 |
User::LeaveIfError( iController.Play() );
|
sl@0
|
431 |
result = SearchForEvent( playEvent );
|
sl@0
|
432 |
if( result == EFail )
|
sl@0
|
433 |
{
|
sl@0
|
434 |
return result;
|
sl@0
|
435 |
}
|
sl@0
|
436 |
|
sl@0
|
437 |
//[ ensure the controller is unloaded so that it does
|
sl@0
|
438 |
// not interfere with the following test ]
|
sl@0
|
439 |
// There is error in this code and the stop followed by reset
|
sl@0
|
440 |
// ensure the controller resources are released.
|
sl@0
|
441 |
iController.Stop();
|
sl@0
|
442 |
iController.Reset();
|
sl@0
|
443 |
iController.Close();
|
sl@0
|
444 |
|
sl@0
|
445 |
__MM_HEAP_MARKEND;
|
sl@0
|
446 |
|
sl@0
|
447 |
return result;
|
sl@0
|
448 |
}
|
sl@0
|
449 |
|
sl@0
|
450 |
/**
|
sl@0
|
451 |
*
|
sl@0
|
452 |
* CTestStepStop
|
sl@0
|
453 |
*
|
sl@0
|
454 |
*/
|
sl@0
|
455 |
CTestStepStop::CTestStepStop()
|
sl@0
|
456 |
{
|
sl@0
|
457 |
iTestStepName = _L("MM-MMF-ACTRL-U-0012-HP");
|
sl@0
|
458 |
}
|
sl@0
|
459 |
|
sl@0
|
460 |
/**
|
sl@0
|
461 |
*
|
sl@0
|
462 |
* ~CTestStepStop
|
sl@0
|
463 |
*
|
sl@0
|
464 |
*/
|
sl@0
|
465 |
CTestStepStop::~CTestStepStop()
|
sl@0
|
466 |
{
|
sl@0
|
467 |
}
|
sl@0
|
468 |
|
sl@0
|
469 |
/*
|
sl@0
|
470 |
*
|
sl@0
|
471 |
* DoTestStepL
|
sl@0
|
472 |
* This test checks the stop function on the controller
|
sl@0
|
473 |
*
|
sl@0
|
474 |
*/
|
sl@0
|
475 |
TVerdict CTestStepStop::DoTestStepL()
|
sl@0
|
476 |
{
|
sl@0
|
477 |
__MM_HEAP_MARK;
|
sl@0
|
478 |
|
sl@0
|
479 |
TVerdict result = EFail;
|
sl@0
|
480 |
|
sl@0
|
481 |
_LIT( KTestPlay, "Stop Test");
|
sl@0
|
482 |
Log( KTestPlay );
|
sl@0
|
483 |
|
sl@0
|
484 |
_LIT( KTestStepPlay, "This test checks the stop function");
|
sl@0
|
485 |
Log( KTestStepPlay );
|
sl@0
|
486 |
|
sl@0
|
487 |
// [ audio file to play ]
|
sl@0
|
488 |
_LIT(KTestWavFile, "newmail.wav");
|
sl@0
|
489 |
SetReadFileNameL( KTestWavFile );
|
sl@0
|
490 |
|
sl@0
|
491 |
TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
|
sl@0
|
492 |
User::LeaveIfError( errorCode );
|
sl@0
|
493 |
|
sl@0
|
494 |
//[ add data source and sink and prime the controller ]
|
sl@0
|
495 |
errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
|
sl@0
|
496 |
User::LeaveIfError( errorCode );
|
sl@0
|
497 |
|
sl@0
|
498 |
errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
|
sl@0
|
499 |
User::LeaveIfError( errorCode );
|
sl@0
|
500 |
|
sl@0
|
501 |
//[ call stop while stopped ]
|
sl@0
|
502 |
User::LeaveIfError( iController.Stop() );
|
sl@0
|
503 |
|
sl@0
|
504 |
|
sl@0
|
505 |
// [ go to primed and call stop ]
|
sl@0
|
506 |
errorCode = iController.Prime();
|
sl@0
|
507 |
User::LeaveIfError( errorCode );
|
sl@0
|
508 |
|
sl@0
|
509 |
// [ wait for and process the return event from the audio output ]
|
sl@0
|
510 |
|
sl@0
|
511 |
TMMFEvent primeEvent( KPrimeTestId, KErrNone);
|
sl@0
|
512 |
result = SearchForEvent( primeEvent );
|
sl@0
|
513 |
if( result == EFail )
|
sl@0
|
514 |
{
|
sl@0
|
515 |
return result;
|
sl@0
|
516 |
}
|
sl@0
|
517 |
|
sl@0
|
518 |
User::LeaveIfError( iController.Stop() );
|
sl@0
|
519 |
|
sl@0
|
520 |
// [ go to play and call stop ]
|
sl@0
|
521 |
errorCode = iController.Prime();
|
sl@0
|
522 |
User::LeaveIfError( errorCode );
|
sl@0
|
523 |
|
sl@0
|
524 |
// [ wait for and process the return event from the audio output ]
|
sl@0
|
525 |
|
sl@0
|
526 |
result = SearchForEvent( primeEvent );
|
sl@0
|
527 |
if( result == EFail )
|
sl@0
|
528 |
{
|
sl@0
|
529 |
return result;
|
sl@0
|
530 |
}
|
sl@0
|
531 |
|
sl@0
|
532 |
User::LeaveIfError( iController.Play() );
|
sl@0
|
533 |
|
sl@0
|
534 |
// note this test does not wait around
|
sl@0
|
535 |
// to detect that the audio has been played
|
sl@0
|
536 |
// [ now process the confirmation event that play has reached audio output
|
sl@0
|
537 |
// this is the raison detre of the test ]
|
sl@0
|
538 |
TMMFEvent playEvent( KPlayTestId, KErrNone );
|
sl@0
|
539 |
result = SearchForEvent( playEvent );
|
sl@0
|
540 |
if( result == EFail )
|
sl@0
|
541 |
{
|
sl@0
|
542 |
return result;
|
sl@0
|
543 |
}
|
sl@0
|
544 |
|
sl@0
|
545 |
User::LeaveIfError( iController.Stop() );
|
sl@0
|
546 |
|
sl@0
|
547 |
|
sl@0
|
548 |
// [ go to prime from stopped via playing ]
|
sl@0
|
549 |
// [ stopped ]
|
sl@0
|
550 |
// [ prime ]
|
sl@0
|
551 |
// [ play ]
|
sl@0
|
552 |
// [ pause ]
|
sl@0
|
553 |
// [ stop ]
|
sl@0
|
554 |
|
sl@0
|
555 |
errorCode = iController.Prime();
|
sl@0
|
556 |
User::LeaveIfError( errorCode );
|
sl@0
|
557 |
|
sl@0
|
558 |
// [ wait for and process the return event from the audio output ]
|
sl@0
|
559 |
|
sl@0
|
560 |
result = SearchForEvent( primeEvent );
|
sl@0
|
561 |
if( result == EFail )
|
sl@0
|
562 |
{
|
sl@0
|
563 |
return result;
|
sl@0
|
564 |
}
|
sl@0
|
565 |
|
sl@0
|
566 |
User::LeaveIfError( iController.Play() );
|
sl@0
|
567 |
|
sl@0
|
568 |
// note this test does not wait around
|
sl@0
|
569 |
// to detect that the audio has been played
|
sl@0
|
570 |
// [ now process the confirmation event that play has reached audio output
|
sl@0
|
571 |
// this is the raison detre of the test ]
|
sl@0
|
572 |
result = SearchForEvent( playEvent );
|
sl@0
|
573 |
if( result == EFail )
|
sl@0
|
574 |
{
|
sl@0
|
575 |
return result;
|
sl@0
|
576 |
}
|
sl@0
|
577 |
|
sl@0
|
578 |
// [ now call pause when playing ]
|
sl@0
|
579 |
TMMFEvent pausePassEvent( KPauseTestId, KErrNone );
|
sl@0
|
580 |
TInt pauseError = iController.Pause();
|
sl@0
|
581 |
if( pauseError != KErrNone )
|
sl@0
|
582 |
{
|
sl@0
|
583 |
//[calling paused while paused returns an error]
|
sl@0
|
584 |
result = EFail;
|
sl@0
|
585 |
return result ;
|
sl@0
|
586 |
}
|
sl@0
|
587 |
|
sl@0
|
588 |
// note this test does not wait around
|
sl@0
|
589 |
// to detect that the audio has been played
|
sl@0
|
590 |
// [ now process the confirmation event that play has reached audio output
|
sl@0
|
591 |
// this is the raison detre of the test ]
|
sl@0
|
592 |
result = SearchForEvent( pausePassEvent );
|
sl@0
|
593 |
if( result == EFail )
|
sl@0
|
594 |
{
|
sl@0
|
595 |
return result;
|
sl@0
|
596 |
}
|
sl@0
|
597 |
|
sl@0
|
598 |
// [ now stop from paused ]
|
sl@0
|
599 |
User::LeaveIfError( iController.Stop() );
|
sl@0
|
600 |
|
sl@0
|
601 |
//[ ensure the controller is unloaded so that it does
|
sl@0
|
602 |
// not interfere with the following test ]
|
sl@0
|
603 |
// There is error in this code and the stop followed by reset
|
sl@0
|
604 |
// ensure the controller resources are released.
|
sl@0
|
605 |
iController.Stop();
|
sl@0
|
606 |
iController.Reset();
|
sl@0
|
607 |
iController.Close();
|
sl@0
|
608 |
|
sl@0
|
609 |
return result;
|
sl@0
|
610 |
}
|
sl@0
|
611 |
|
sl@0
|
612 |
|
sl@0
|
613 |
/*
|
sl@0
|
614 |
*
|
sl@0
|
615 |
* CTestStepConvertFormat
|
sl@0
|
616 |
*
|
sl@0
|
617 |
*/
|
sl@0
|
618 |
CTestStepConvertFormat::CTestStepConvertFormat( TUint aTestIndex )
|
sl@0
|
619 |
{
|
sl@0
|
620 |
// store a pointer to the test parameters
|
sl@0
|
621 |
iTestParameters = &(KTestParameters[aTestIndex]);
|
sl@0
|
622 |
|
sl@0
|
623 |
// store the name of this test case
|
sl@0
|
624 |
// this is the name that is used by the script file
|
sl@0
|
625 |
iTestStepName = iTestParameters->iTestName;
|
sl@0
|
626 |
}
|
sl@0
|
627 |
|
sl@0
|
628 |
/*
|
sl@0
|
629 |
*
|
sl@0
|
630 |
* ~CTestStepConvertFormat
|
sl@0
|
631 |
*
|
sl@0
|
632 |
*/
|
sl@0
|
633 |
CTestStepConvertFormat::~CTestStepConvertFormat()
|
sl@0
|
634 |
{
|
sl@0
|
635 |
|
sl@0
|
636 |
|
sl@0
|
637 |
}
|
sl@0
|
638 |
|
sl@0
|
639 |
|
sl@0
|
640 |
// test preamble
|
sl@0
|
641 |
TVerdict CTestStepConvertFormat::DoTestStepPreambleL(void)
|
sl@0
|
642 |
{
|
sl@0
|
643 |
// connect to the file server
|
sl@0
|
644 |
User::LeaveIfError(iFs.Connect());
|
sl@0
|
645 |
|
sl@0
|
646 |
// call the superclass
|
sl@0
|
647 |
return CTestStepActrl::DoTestStepPreambleL();
|
sl@0
|
648 |
}
|
sl@0
|
649 |
|
sl@0
|
650 |
//test postamble
|
sl@0
|
651 |
TVerdict CTestStepConvertFormat::DoTestStepPostambleL(void)
|
sl@0
|
652 |
{
|
sl@0
|
653 |
// close connection with the file server
|
sl@0
|
654 |
iFs.Close();
|
sl@0
|
655 |
|
sl@0
|
656 |
// call the superclass
|
sl@0
|
657 |
return CTestStepActrl::DoTestStepPostambleL();
|
sl@0
|
658 |
}
|
sl@0
|
659 |
/**
|
sl@0
|
660 |
*
|
sl@0
|
661 |
* Compare two binary files
|
sl@0
|
662 |
*
|
sl@0
|
663 |
* @param "const TDesC& aFile1"
|
sl@0
|
664 |
* The first file to compare
|
sl@0
|
665 |
* @param "const TDesC& aFile2"
|
sl@0
|
666 |
* The second file to compare
|
sl@0
|
667 |
* @leave ""
|
sl@0
|
668 |
* Will leave with appropriate system codes if a problem is encountered reading either file
|
sl@0
|
669 |
* @return "TVerdict"
|
sl@0
|
670 |
* EPass if the files are identical
|
sl@0
|
671 |
* EFail otherwise
|
sl@0
|
672 |
* @xxxx
|
sl@0
|
673 |
*
|
sl@0
|
674 |
*/
|
sl@0
|
675 |
TVerdict CTestStepConvertFormat::CompareFilesL(const TDesC& aFile1,const TDesC& aFile2)
|
sl@0
|
676 |
{
|
sl@0
|
677 |
RFile file1, file2;
|
sl@0
|
678 |
|
sl@0
|
679 |
User::LeaveIfError(file1.Open(iFs, aFile1, EFileShareAny | EFileStream | EFileRead));
|
sl@0
|
680 |
CleanupClosePushL(file1);
|
sl@0
|
681 |
|
sl@0
|
682 |
User::LeaveIfError(file2.Open(iFs, aFile2, EFileShareAny | EFileStream | EFileRead));
|
sl@0
|
683 |
CleanupClosePushL(file2);
|
sl@0
|
684 |
|
sl@0
|
685 |
TInt fileSize1, fileSize2;
|
sl@0
|
686 |
|
sl@0
|
687 |
TVerdict result = EPass;
|
sl@0
|
688 |
TInt blockSize = 1024;
|
sl@0
|
689 |
|
sl@0
|
690 |
User::LeaveIfError(file1.Size(fileSize1));
|
sl@0
|
691 |
User::LeaveIfError(file2.Size(fileSize2));
|
sl@0
|
692 |
|
sl@0
|
693 |
if (fileSize1 == fileSize2)
|
sl@0
|
694 |
{
|
sl@0
|
695 |
HBufC8* buf1 = HBufC8::NewMaxLC(blockSize);
|
sl@0
|
696 |
TPtr8 buf1Ptr(buf1->Des());
|
sl@0
|
697 |
HBufC8* buf2 = HBufC8::NewMaxLC(blockSize);
|
sl@0
|
698 |
TPtr8 buf2Ptr(buf2->Des());
|
sl@0
|
699 |
|
sl@0
|
700 |
TInt length = 0;
|
sl@0
|
701 |
|
sl@0
|
702 |
while (length<fileSize1 && result == EPass)
|
sl@0
|
703 |
{
|
sl@0
|
704 |
TInt copySize;
|
sl@0
|
705 |
|
sl@0
|
706 |
if (fileSize1 - length > blockSize)
|
sl@0
|
707 |
copySize = blockSize;
|
sl@0
|
708 |
else
|
sl@0
|
709 |
copySize = fileSize1 - length;
|
sl@0
|
710 |
User::LeaveIfError(file1.Read(buf1Ptr,copySize));
|
sl@0
|
711 |
User::LeaveIfError(file2.Read(buf2Ptr,copySize));
|
sl@0
|
712 |
|
sl@0
|
713 |
TInt comp_res = Mem::Compare(buf1Ptr.Ptr(),copySize,buf2Ptr.Ptr(),copySize);
|
sl@0
|
714 |
|
sl@0
|
715 |
if (comp_res!=0)
|
sl@0
|
716 |
{
|
sl@0
|
717 |
INFO_PRINTF5(_L("Comparison Failed, comparison failed (%S, %S), result=%d at offset %d"),
|
sl@0
|
718 |
&aFile1, &aFile2, comp_res, length);
|
sl@0
|
719 |
result = EFail;
|
sl@0
|
720 |
break;
|
sl@0
|
721 |
}
|
sl@0
|
722 |
|
sl@0
|
723 |
length += copySize;
|
sl@0
|
724 |
}
|
sl@0
|
725 |
CleanupStack::PopAndDestroy(2); // buf1, buf2
|
sl@0
|
726 |
}
|
sl@0
|
727 |
else
|
sl@0
|
728 |
{
|
sl@0
|
729 |
INFO_PRINTF5(_L("Comparison Failed, files are different sizes (%S, %S), (%d,%d)"),
|
sl@0
|
730 |
&aFile1, &aFile2, fileSize1, fileSize2);
|
sl@0
|
731 |
result = EFail;
|
sl@0
|
732 |
}
|
sl@0
|
733 |
|
sl@0
|
734 |
file1.Close();
|
sl@0
|
735 |
file2.Close();
|
sl@0
|
736 |
|
sl@0
|
737 |
CleanupStack::PopAndDestroy(2); //file1, file2
|
sl@0
|
738 |
|
sl@0
|
739 |
return result;
|
sl@0
|
740 |
}
|
sl@0
|
741 |
/*
|
sl@0
|
742 |
*
|
sl@0
|
743 |
* DoTestStepL
|
sl@0
|
744 |
* This test checks the stop function on the controller
|
sl@0
|
745 |
*
|
sl@0
|
746 |
*/
|
sl@0
|
747 |
TVerdict CTestStepConvertFormat::DoTestStepL( void )
|
sl@0
|
748 |
{
|
sl@0
|
749 |
TVerdict result = EPass;
|
sl@0
|
750 |
TInt error;
|
sl@0
|
751 |
|
sl@0
|
752 |
// do the conversion step
|
sl@0
|
753 |
TRAP(error, result = DoConvertStepL( ));
|
sl@0
|
754 |
|
sl@0
|
755 |
if (error != iTestParameters->iExpectedResult )
|
sl@0
|
756 |
{
|
sl@0
|
757 |
INFO_PRINTF2(_L("Error - Test step returned %d"), error);
|
sl@0
|
758 |
result = EFail;
|
sl@0
|
759 |
}
|
sl@0
|
760 |
|
sl@0
|
761 |
//[ delete output file after comparison]
|
sl@0
|
762 |
//[ here because DoTestStepL() can leave ]
|
sl@0
|
763 |
TInt ret = iFs.Delete( WriteFileConfig()().iPath );
|
sl@0
|
764 |
if (ret != KErrNone && ret != KErrNotFound)
|
sl@0
|
765 |
{
|
sl@0
|
766 |
INFO_PRINTF2(_L("Error deleting file - Delete returned %d"), ret);
|
sl@0
|
767 |
}
|
sl@0
|
768 |
|
sl@0
|
769 |
//[ ensure the controller is unloaded so that it does
|
sl@0
|
770 |
// not interfere with the following test ]
|
sl@0
|
771 |
// There is error in this code and the stop followed by reset
|
sl@0
|
772 |
// ensure the controller resources are released.
|
sl@0
|
773 |
iController.Stop();
|
sl@0
|
774 |
iController.Reset();
|
sl@0
|
775 |
iController.Close();
|
sl@0
|
776 |
|
sl@0
|
777 |
return result;
|
sl@0
|
778 |
}
|
sl@0
|
779 |
|
sl@0
|
780 |
/*
|
sl@0
|
781 |
* DoConvertL( void )
|
sl@0
|
782 |
* Do the conversion of the files
|
sl@0
|
783 |
* @return "TVerdict" the result of the convert operation
|
sl@0
|
784 |
*/
|
sl@0
|
785 |
TVerdict CTestStepConvertFormat::DoConvertStepL( void )
|
sl@0
|
786 |
{
|
sl@0
|
787 |
TVerdict result = EPass;
|
sl@0
|
788 |
|
sl@0
|
789 |
_LIT( KTestConvertFormat, "Convert Formats Test");
|
sl@0
|
790 |
Log( KTestConvertFormat );
|
sl@0
|
791 |
|
sl@0
|
792 |
_LIT( KTestStepPlay, "This test checks converting an audio clip");
|
sl@0
|
793 |
Log( KTestStepPlay );
|
sl@0
|
794 |
|
sl@0
|
795 |
// get filename of input file
|
sl@0
|
796 |
TInt strLen = User::StringLength(iTestParameters->iFromFilename);
|
sl@0
|
797 |
TPtrC ptr( iTestParameters->iFromFilename, strLen );
|
sl@0
|
798 |
|
sl@0
|
799 |
//[ configure the filename ]
|
sl@0
|
800 |
SetReadFileNameL( ptr );
|
sl@0
|
801 |
|
sl@0
|
802 |
//[ configure reference filename ]
|
sl@0
|
803 |
strLen = User::StringLength(iTestParameters->iRefFilename);
|
sl@0
|
804 |
ptr.Set( iTestParameters->iRefFilename, strLen );
|
sl@0
|
805 |
|
sl@0
|
806 |
SetRefFileNameL( ptr );
|
sl@0
|
807 |
|
sl@0
|
808 |
// [ converted audio file name ]
|
sl@0
|
809 |
//_LIT(KTestOutFile, "ConvertedOutput");
|
sl@0
|
810 |
TBuf<32> testFileName = _L("ConvertedOutput");
|
sl@0
|
811 |
|
sl@0
|
812 |
switch ( iTestParameters->iDestFormat.iUid )
|
sl@0
|
813 |
{
|
sl@0
|
814 |
case KMmfUidFormatRAWWrite:
|
sl@0
|
815 |
testFileName.Append( _L(".raw") );
|
sl@0
|
816 |
break;
|
sl@0
|
817 |
|
sl@0
|
818 |
case KMmfUidFormatWAVWrite:
|
sl@0
|
819 |
testFileName.Append( _L(".wav") );
|
sl@0
|
820 |
break;
|
sl@0
|
821 |
|
sl@0
|
822 |
case KMmfUidFormatAUWrite:
|
sl@0
|
823 |
testFileName.Append( _L(".au") );
|
sl@0
|
824 |
break;
|
sl@0
|
825 |
|
sl@0
|
826 |
default:
|
sl@0
|
827 |
// not a recognised output format - use .tmp
|
sl@0
|
828 |
testFileName.Append( _L(".tmp") );
|
sl@0
|
829 |
break;
|
sl@0
|
830 |
}
|
sl@0
|
831 |
|
sl@0
|
832 |
//[ configure the filename ]
|
sl@0
|
833 |
SetWriteFileNameL( testFileName );
|
sl@0
|
834 |
|
sl@0
|
835 |
// open the audio controller
|
sl@0
|
836 |
TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
|
sl@0
|
837 |
User::LeaveIfError( errorCode );
|
sl@0
|
838 |
|
sl@0
|
839 |
//[ add data source and sink and prime the controller ]
|
sl@0
|
840 |
errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
|
sl@0
|
841 |
User::LeaveIfError( errorCode );
|
sl@0
|
842 |
|
sl@0
|
843 |
errorCode = iController.AddDataSink(KUidMmfFileSink, WriteFileConfig());
|
sl@0
|
844 |
User::LeaveIfError( errorCode );
|
sl@0
|
845 |
|
sl@0
|
846 |
//[ attempt to get the sink num channels ]
|
sl@0
|
847 |
RMMFAudioControllerCustomCommands theCommander( iController );
|
sl@0
|
848 |
|
sl@0
|
849 |
// if source data is RAW then need to complete the source format
|
sl@0
|
850 |
if ( iTestParameters->iSrcFormat.iUid == KMmfUidFormatRAWRead )
|
sl@0
|
851 |
{
|
sl@0
|
852 |
|
sl@0
|
853 |
errorCode = theCommander.SetSourceFormat( iTestParameters->iSrcFormat );
|
sl@0
|
854 |
User::LeaveIfError( errorCode );
|
sl@0
|
855 |
|
sl@0
|
856 |
errorCode = theCommander.SetSourceDataType( iTestParameters->iSrcEncoding );
|
sl@0
|
857 |
User::LeaveIfError( errorCode );
|
sl@0
|
858 |
|
sl@0
|
859 |
errorCode = theCommander.SetSourceSampleRate( iTestParameters->iSrcSampleRate );
|
sl@0
|
860 |
User::LeaveIfError( errorCode );
|
sl@0
|
861 |
|
sl@0
|
862 |
errorCode = theCommander.SetSourceNumChannels( iTestParameters->iSrcChannels );
|
sl@0
|
863 |
User::LeaveIfError( errorCode );
|
sl@0
|
864 |
}
|
sl@0
|
865 |
|
sl@0
|
866 |
// set sink sample rate
|
sl@0
|
867 |
errorCode = theCommander.SetSinkSampleRate( iTestParameters->iDestSampleRate );
|
sl@0
|
868 |
User::LeaveIfError( errorCode );
|
sl@0
|
869 |
|
sl@0
|
870 |
// set sink number of channels
|
sl@0
|
871 |
if(iTestParameters->iDestChannels != KNone)
|
sl@0
|
872 |
{
|
sl@0
|
873 |
errorCode = theCommander.SetSinkNumChannels( iTestParameters->iDestChannels );
|
sl@0
|
874 |
User::LeaveIfError( errorCode );
|
sl@0
|
875 |
}
|
sl@0
|
876 |
|
sl@0
|
877 |
//[ ok lets try to set the sink format ]
|
sl@0
|
878 |
errorCode = theCommander.SetSinkFormat( iTestParameters->iDestFormat );
|
sl@0
|
879 |
User::LeaveIfError( errorCode );
|
sl@0
|
880 |
|
sl@0
|
881 |
//[ set the sink data type ]
|
sl@0
|
882 |
errorCode = theCommander.SetSinkDataType( iTestParameters->iDestEncoding );
|
sl@0
|
883 |
User::LeaveIfError( errorCode );
|
sl@0
|
884 |
|
sl@0
|
885 |
errorCode = iController.Prime();
|
sl@0
|
886 |
User::LeaveIfError( errorCode );
|
sl@0
|
887 |
|
sl@0
|
888 |
// [ wait for and process the return event from the audio output ]
|
sl@0
|
889 |
TMMFEvent primeEvent( KPrimeTestId, KErrNone);
|
sl@0
|
890 |
result = SearchForEvent( primeEvent );
|
sl@0
|
891 |
if( result == EFail )
|
sl@0
|
892 |
{
|
sl@0
|
893 |
return result;
|
sl@0
|
894 |
}
|
sl@0
|
895 |
|
sl@0
|
896 |
errorCode = iController.Play();
|
sl@0
|
897 |
User::LeaveIfError( errorCode );
|
sl@0
|
898 |
|
sl@0
|
899 |
// note this test does not wait around
|
sl@0
|
900 |
// to detect that the audio has been played
|
sl@0
|
901 |
// [ now process the confirmation event that play has reached audio output
|
sl@0
|
902 |
// this is the raison detre of the test ]
|
sl@0
|
903 |
TMMFEvent playEvent( KPlayTestId, KErrNone );
|
sl@0
|
904 |
|
sl@0
|
905 |
result = SearchForEvent( playEvent );
|
sl@0
|
906 |
if( result == EFail )
|
sl@0
|
907 |
{
|
sl@0
|
908 |
return result;
|
sl@0
|
909 |
}
|
sl@0
|
910 |
|
sl@0
|
911 |
//[ now wait for play complete event]
|
sl@0
|
912 |
TMMFEvent playCompleteEvent( KPlayCompleteTestId, KErrNone);
|
sl@0
|
913 |
result = SearchForEvent( playCompleteEvent );
|
sl@0
|
914 |
if( result == EFail )
|
sl@0
|
915 |
{
|
sl@0
|
916 |
return result;
|
sl@0
|
917 |
}
|
sl@0
|
918 |
|
sl@0
|
919 |
//[ now compare the file produced with a reference file ]
|
sl@0
|
920 |
INFO_PRINTF1(_L("Comparing file to reference..."));
|
sl@0
|
921 |
result = CompareFilesL( RefFileName()().iPath, WriteFileConfig()().iPath);
|
sl@0
|
922 |
|
sl@0
|
923 |
if (result == EFail)
|
sl@0
|
924 |
{
|
sl@0
|
925 |
INFO_PRINTF1(_L("Comparison Failed - Files are not identical !"));
|
sl@0
|
926 |
}
|
sl@0
|
927 |
|
sl@0
|
928 |
|
sl@0
|
929 |
return result;
|
sl@0
|
930 |
}
|
sl@0
|
931 |
|
sl@0
|
932 |
/*
|
sl@0
|
933 |
*
|
sl@0
|
934 |
* SetRefFileNameL
|
sl@0
|
935 |
*
|
sl@0
|
936 |
*/
|
sl@0
|
937 |
void CTestStepConvertFormat::SetRefFileNameL( const TDesC& aPathNameAndExtn )
|
sl@0
|
938 |
{
|
sl@0
|
939 |
//[ append the filename relative to the default path ]
|
sl@0
|
940 |
TFileName fileName = GetSuite()->DefaultPath();
|
sl@0
|
941 |
fileName.Append(aPathNameAndExtn);
|
sl@0
|
942 |
iFileConfigRef().iPath = fileName ;
|
sl@0
|
943 |
}
|
sl@0
|
944 |
/*
|
sl@0
|
945 |
*
|
sl@0
|
946 |
* RefFileName
|
sl@0
|
947 |
*
|
sl@0
|
948 |
*/
|
sl@0
|
949 |
TMMFFileConfig& CTestStepConvertFormat::RefFileName()
|
sl@0
|
950 |
{
|
sl@0
|
951 |
return iFileConfigRef;
|
sl@0
|
952 |
}
|
sl@0
|
953 |
|
sl@0
|
954 |
/*
|
sl@0
|
955 |
*
|
sl@0
|
956 |
* CTestStepRampVolume
|
sl@0
|
957 |
*/
|
sl@0
|
958 |
CTestStepRampVolume::CTestStepRampVolume()
|
sl@0
|
959 |
{
|
sl@0
|
960 |
iTestStepName = _L("MM-MMF-ACTRL-U-0064-HP");
|
sl@0
|
961 |
}
|
sl@0
|
962 |
|
sl@0
|
963 |
/*
|
sl@0
|
964 |
*
|
sl@0
|
965 |
* ~CTestStepRampVolume
|
sl@0
|
966 |
*/
|
sl@0
|
967 |
CTestStepRampVolume::~CTestStepRampVolume()
|
sl@0
|
968 |
{
|
sl@0
|
969 |
}
|
sl@0
|
970 |
|
sl@0
|
971 |
/*
|
sl@0
|
972 |
*
|
sl@0
|
973 |
* CTestStepRampVolume
|
sl@0
|
974 |
*/
|
sl@0
|
975 |
TVerdict CTestStepRampVolume::DoTestStepL()
|
sl@0
|
976 |
{
|
sl@0
|
977 |
TVerdict result = EPass;
|
sl@0
|
978 |
|
sl@0
|
979 |
_LIT( KTestVolumeRamp, "Volume Ramp Test");
|
sl@0
|
980 |
Log( KTestVolumeRamp );
|
sl@0
|
981 |
|
sl@0
|
982 |
_LIT( KTestStepPlay, "This test checks volume ramp");
|
sl@0
|
983 |
Log( KTestStepPlay );
|
sl@0
|
984 |
|
sl@0
|
985 |
// [ audio file to play ]
|
sl@0
|
986 |
_LIT(KTestWavFile, "RampVolume.wav");
|
sl@0
|
987 |
//[ configure the filename ]
|
sl@0
|
988 |
SetReadFileNameL( KTestWavFile );
|
sl@0
|
989 |
|
sl@0
|
990 |
TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
|
sl@0
|
991 |
User::LeaveIfError( errorCode );
|
sl@0
|
992 |
|
sl@0
|
993 |
//[ add data source and sink and prime the controller ]
|
sl@0
|
994 |
errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
|
sl@0
|
995 |
User::LeaveIfError( errorCode );
|
sl@0
|
996 |
|
sl@0
|
997 |
errorCode = iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
|
sl@0
|
998 |
User::LeaveIfError( errorCode );
|
sl@0
|
999 |
|
sl@0
|
1000 |
errorCode = iController.Prime();
|
sl@0
|
1001 |
User::LeaveIfError( errorCode );
|
sl@0
|
1002 |
|
sl@0
|
1003 |
// [ wait for and process the return event from the audio output ]
|
sl@0
|
1004 |
//[ attempt to get the sink num channels ]
|
sl@0
|
1005 |
RMMFAudioPlayDeviceCustomCommands theCommander( iController );
|
sl@0
|
1006 |
//[lets say 2 seconds for now ]
|
sl@0
|
1007 |
TTimeIntervalMicroSeconds aRampDuration( 2000000);
|
sl@0
|
1008 |
errorCode = theCommander.SetVolumeRamp( aRampDuration);
|
sl@0
|
1009 |
User::LeaveIfError( errorCode );
|
sl@0
|
1010 |
|
sl@0
|
1011 |
TMMFEvent primeEvent( KPrimeTestId, KErrNone);
|
sl@0
|
1012 |
result = SearchForEvent( primeEvent );
|
sl@0
|
1013 |
if( result == EFail )
|
sl@0
|
1014 |
{
|
sl@0
|
1015 |
return result;
|
sl@0
|
1016 |
}
|
sl@0
|
1017 |
|
sl@0
|
1018 |
//[ lets set the volume ramp before we play ]
|
sl@0
|
1019 |
|
sl@0
|
1020 |
|
sl@0
|
1021 |
User::LeaveIfError( iController.Play() );
|
sl@0
|
1022 |
|
sl@0
|
1023 |
// note this test does not wait around
|
sl@0
|
1024 |
// to detect that the audio has been played
|
sl@0
|
1025 |
// [ now process the confirmation event that play has reached audio output
|
sl@0
|
1026 |
// this is the raison detre of the test ]
|
sl@0
|
1027 |
TMMFEvent playEvent( KPlayTestId, KErrNone );
|
sl@0
|
1028 |
result = SearchForEvent( playEvent );
|
sl@0
|
1029 |
if( result == EFail )
|
sl@0
|
1030 |
{
|
sl@0
|
1031 |
return EFail;
|
sl@0
|
1032 |
}
|
sl@0
|
1033 |
|
sl@0
|
1034 |
//[ now wait for play complete event]
|
sl@0
|
1035 |
TMMFEvent playCompleteEvent( KPlayCompleteTestId, KErrNone);
|
sl@0
|
1036 |
result = SearchForEvent( playCompleteEvent );
|
sl@0
|
1037 |
if( result == EFail )
|
sl@0
|
1038 |
{
|
sl@0
|
1039 |
return EFail;
|
sl@0
|
1040 |
}
|
sl@0
|
1041 |
|
sl@0
|
1042 |
//[ ensure the controller is unloaded so that it does
|
sl@0
|
1043 |
// not interfere with the following test ]
|
sl@0
|
1044 |
// There is error in this code and the stop followed by reset
|
sl@0
|
1045 |
// ensure the controller resources are released.
|
sl@0
|
1046 |
iController.Stop();
|
sl@0
|
1047 |
iController.Reset();
|
sl@0
|
1048 |
iController.Close();
|
sl@0
|
1049 |
|
sl@0
|
1050 |
// test steps return a result
|
sl@0
|
1051 |
return result;
|
sl@0
|
1052 |
}
|
sl@0
|
1053 |
|
sl@0
|
1054 |
/*
|
sl@0
|
1055 |
*
|
sl@0
|
1056 |
* CTestStepRampVolume
|
sl@0
|
1057 |
*/
|
sl@0
|
1058 |
TVerdict CTestStepRampVolume::DoTestStepPreambleL(void)
|
sl@0
|
1059 |
{
|
sl@0
|
1060 |
return EPass;
|
sl@0
|
1061 |
}
|
sl@0
|
1062 |
|
sl@0
|
1063 |
/*
|
sl@0
|
1064 |
*
|
sl@0
|
1065 |
* CTestStepRampVolume
|
sl@0
|
1066 |
*/
|
sl@0
|
1067 |
TVerdict CTestStepRampVolume::DoTestStepPostambleL(void)
|
sl@0
|
1068 |
{
|
sl@0
|
1069 |
return CTestStepActrl::DoTestStepPostambleL();
|
sl@0
|
1070 |
}
|
sl@0
|
1071 |
|