0
|
1 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// This file contains an example Test step implementation
|
|
15 |
// This demonstrates the various functions provided
|
|
16 |
// by the CTestStep base class which are available within
|
|
17 |
// a test step
|
|
18 |
//
|
|
19 |
//
|
|
20 |
|
|
21 |
// EPOC includes
|
|
22 |
#include <e32base.h>
|
|
23 |
#include <e32test.h>
|
|
24 |
#include <e32keys.h>
|
|
25 |
#include <c32comm.h>
|
|
26 |
#include <f32file.h>
|
|
27 |
#include <etel.h>
|
|
28 |
#include <etelmm.h>
|
|
29 |
#include <testframework.h>
|
|
30 |
|
|
31 |
//#include <MdaAudioSamplePlayer.h>
|
|
32 |
#include <mdaaudiosampleeditor.h>
|
|
33 |
//#include <MdaAudioTonePlayer.h>
|
|
34 |
|
|
35 |
// Test system includes
|
|
36 |
#include <testframework.h>
|
|
37 |
|
|
38 |
// Specific includes for this test suite
|
|
39 |
#include "TestStepUnitMMFAudClient.h"
|
|
40 |
#include "TestSuiteUnitMMFAudClient.h"
|
|
41 |
|
|
42 |
// Specific includes for these test steps
|
|
43 |
#include "TestStepRecorder.h"
|
|
44 |
|
|
45 |
|
|
46 |
#include "MmfAudioController.h"
|
|
47 |
#include "mmfclientaudiorecorder.h"
|
|
48 |
//#include "MmfClientAudioPlayer.h"
|
|
49 |
//#include <mmffourcc.h>
|
|
50 |
//#include <mmfpaniccodes.h>
|
|
51 |
//#include <mmfFormatImplementationUIDs.hrh>
|
|
52 |
// --------------------------------------------
|
|
53 |
|
|
54 |
/**
|
|
55 |
*
|
|
56 |
* Static constructor for CTestStepRecorderDuration.
|
|
57 |
*
|
|
58 |
*
|
|
59 |
* @return "CTestStepRecorderDuration*"
|
|
60 |
* The constructed CTestStepRecorderDuration
|
|
61 |
*
|
|
62 |
* @xxxx
|
|
63 |
*
|
|
64 |
*/
|
|
65 |
CTestStepRecorderDuration* CTestStepRecorderDuration::NewL()
|
|
66 |
{
|
|
67 |
CTestStepRecorderDuration* self = new(ELeave) CTestStepRecorderDuration;
|
|
68 |
return self;
|
|
69 |
}
|
|
70 |
|
|
71 |
/**
|
|
72 |
*
|
|
73 |
* Test step constructor.
|
|
74 |
* Each test step initialises its own name.
|
|
75 |
*
|
|
76 |
* @xxxx
|
|
77 |
*
|
|
78 |
*/
|
|
79 |
CTestStepRecorderDuration::CTestStepRecorderDuration() : iError(KErrNone)
|
|
80 |
{
|
|
81 |
// store the name of this test case
|
|
82 |
// this is the name that is used by the script file
|
|
83 |
iTestStepName = _L("MM-MMF-ACLNT-U-0252-HP");
|
|
84 |
}
|
|
85 |
|
|
86 |
/**
|
|
87 |
*
|
|
88 |
* Test step destructor.
|
|
89 |
*
|
|
90 |
* @xxxx
|
|
91 |
*
|
|
92 |
*/
|
|
93 |
CTestStepRecorderDuration::~CTestStepRecorderDuration()
|
|
94 |
{
|
|
95 |
}
|
|
96 |
|
|
97 |
/**
|
|
98 |
*
|
|
99 |
* Test step Preamble.
|
|
100 |
*
|
|
101 |
* @xxxx
|
|
102 |
*
|
|
103 |
*/
|
|
104 |
enum TVerdict CTestStepRecorderDuration::DoTestStepPreambleL(void)
|
|
105 |
{
|
|
106 |
enum TVerdict verdict;
|
|
107 |
// this installs the scheduler
|
|
108 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
109 |
|
|
110 |
// Printing to the console and log file
|
|
111 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0252-HP"));
|
|
112 |
INFO_PRINTF1(_L("this is a test of CMdaAudioRecorderUtility::Duration()"));
|
|
113 |
|
|
114 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName1"), iFileNames[0])) // wav file
|
|
115 |
{
|
|
116 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
117 |
return EInconclusive;
|
|
118 |
}
|
|
119 |
/*
|
|
120 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName3"), iFileNames[1])) // au file
|
|
121 |
{
|
|
122 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
123 |
return EInconclusive;
|
|
124 |
}
|
|
125 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName5"), iFileNames[2])) // raw file
|
|
126 |
{
|
|
127 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
128 |
return EInconclusive;
|
|
129 |
}
|
|
130 |
*/
|
|
131 |
return verdict;
|
|
132 |
|
|
133 |
}
|
|
134 |
|
|
135 |
/**
|
|
136 |
*
|
|
137 |
* Test step Postamble.
|
|
138 |
*
|
|
139 |
* @xxxx
|
|
140 |
*
|
|
141 |
*/
|
|
142 |
enum TVerdict CTestStepRecorderDuration::DoTestStepPostambleL(void)
|
|
143 |
{
|
|
144 |
delete iRecorder;
|
|
145 |
iRecorder = NULL;
|
|
146 |
//[ Destroy the scheduler ]
|
|
147 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
148 |
}
|
|
149 |
|
|
150 |
/**
|
|
151 |
*
|
|
152 |
* Callback Handle.
|
|
153 |
*
|
|
154 |
* @xxxx
|
|
155 |
*
|
|
156 |
*/
|
|
157 |
void CTestStepRecorderDuration::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
158 |
TInt /*aPreviousState*/,
|
|
159 |
TInt /*aCurrentState*/,
|
|
160 |
TInt aErrorcCode)
|
|
161 |
{
|
|
162 |
iError = aErrorcCode;
|
|
163 |
CActiveScheduler::Stop();
|
|
164 |
}
|
|
165 |
|
|
166 |
void CTestStepRecorderDuration::OpenAndStartSchedulerL(TInt i)
|
|
167 |
{
|
|
168 |
iRecorder->OpenFileL( iFileNames[i] );
|
|
169 |
CActiveScheduler::Start();
|
|
170 |
User::LeaveIfError(iError);
|
|
171 |
}
|
|
172 |
|
|
173 |
/**
|
|
174 |
*
|
|
175 |
* Do the test step.
|
|
176 |
* Each test step must supply an implementation for DoTestStepL.
|
|
177 |
*
|
|
178 |
* @return "TVerdict"
|
|
179 |
* The result of the test step
|
|
180 |
*
|
|
181 |
* @xxxx
|
|
182 |
*
|
|
183 |
*/
|
|
184 |
TVerdict CTestStepRecorderDuration::DoTestStepL()
|
|
185 |
{
|
|
186 |
iTestStepResult = EPass;
|
|
187 |
TInt err = KErrNone;
|
|
188 |
|
|
189 |
//for (TInt type=0; type<3; type++)
|
|
190 |
// only one type at the moment
|
|
191 |
for (TInt type=0; type<1; type++)
|
|
192 |
{
|
|
193 |
// create the Recorder utility
|
|
194 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
195 |
return EInconclusive;
|
|
196 |
|
|
197 |
TRAP( err, OpenAndStartSchedulerL(type) );
|
|
198 |
|
|
199 |
if (iRecorder == NULL ||
|
|
200 |
err != KErrNone ||
|
|
201 |
iError != KErrNone ||
|
|
202 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
203 |
return EInconclusive;
|
|
204 |
|
|
205 |
INFO_PRINTF2(_L("FileName = %S"), &iFileNames[type]);
|
|
206 |
TTimeIntervalMicroSeconds theDuration = iRecorder->Duration();
|
|
207 |
TTimeIntervalMicroSeconds expectedDuration;
|
|
208 |
switch (type)
|
|
209 |
{
|
|
210 |
case 0:
|
|
211 |
expectedDuration = TTimeIntervalMicroSeconds(1000125);
|
|
212 |
break;
|
|
213 |
case 1:
|
|
214 |
expectedDuration = TTimeIntervalMicroSeconds(8359176);
|
|
215 |
break;
|
|
216 |
case 2:
|
|
217 |
expectedDuration = TTimeIntervalMicroSeconds(1000125);
|
|
218 |
break;
|
|
219 |
default:
|
|
220 |
break;
|
|
221 |
}
|
|
222 |
|
|
223 |
INFO_PRINTF3(_L("Duration = %d, expected = %d"), I64INT(theDuration.Int64()), I64INT(expectedDuration.Int64()));
|
|
224 |
|
|
225 |
delete iRecorder;
|
|
226 |
iRecorder = NULL;
|
|
227 |
|
|
228 |
if (theDuration != expectedDuration)
|
|
229 |
return EFail;
|
|
230 |
|
|
231 |
}
|
|
232 |
|
|
233 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
234 |
// test steps return a result
|
|
235 |
return iTestStepResult;
|
|
236 |
}
|
|
237 |
|
|
238 |
//
|
|
239 |
// class CTestStepRecorderDurationInformation
|
|
240 |
//
|
|
241 |
|
|
242 |
/**
|
|
243 |
*
|
|
244 |
* Static constructor for CTestStepRecorderDurationInformation.
|
|
245 |
*
|
|
246 |
*
|
|
247 |
* @return "CTestStepRecorderDurationInformation*"
|
|
248 |
* The constructed CTestStepRecorderDurationInformation
|
|
249 |
*
|
|
250 |
* @xxxx
|
|
251 |
*
|
|
252 |
*/
|
|
253 |
CTestStepRecorderDurationInformation* CTestStepRecorderDurationInformation::NewL()
|
|
254 |
{
|
|
255 |
CTestStepRecorderDurationInformation* self = new(ELeave) CTestStepRecorderDurationInformation;
|
|
256 |
return self;
|
|
257 |
}
|
|
258 |
|
|
259 |
/**
|
|
260 |
*
|
|
261 |
* Test step constructor.
|
|
262 |
* Each test step initialises its own name.
|
|
263 |
*
|
|
264 |
* @xxxx
|
|
265 |
*
|
|
266 |
*/
|
|
267 |
CTestStepRecorderDurationInformation::CTestStepRecorderDurationInformation()
|
|
268 |
{
|
|
269 |
iTestStepResult = EPass;
|
|
270 |
// store the name of this test case
|
|
271 |
// this is the name that is used by the script file
|
|
272 |
iTestStepName = _L("MM-MMF-ACLNT-U-0961-HP");
|
|
273 |
}
|
|
274 |
|
|
275 |
/**
|
|
276 |
*
|
|
277 |
* Test step destructor.
|
|
278 |
*
|
|
279 |
* @xxxx
|
|
280 |
*
|
|
281 |
*/
|
|
282 |
CTestStepRecorderDurationInformation::~CTestStepRecorderDurationInformation()
|
|
283 |
{
|
|
284 |
}
|
|
285 |
|
|
286 |
/**
|
|
287 |
* Implementation of the MMdaObjectStateChangeObserver interface functions
|
|
288 |
**/
|
|
289 |
void CTestStepRecorderDurationInformation::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
290 |
TInt /*aPreviousState*/,
|
|
291 |
TInt /*aCurrentState*/,
|
|
292 |
TInt aErrorCode)
|
|
293 |
{
|
|
294 |
iError = aErrorCode;
|
|
295 |
CActiveScheduler::Stop();
|
|
296 |
}
|
|
297 |
|
|
298 |
/**
|
|
299 |
|
|
300 |
*
|
|
301 |
* Test step Preamble.
|
|
302 |
*
|
|
303 |
* @xxxx
|
|
304 |
*
|
|
305 |
*/
|
|
306 |
enum TVerdict CTestStepRecorderDurationInformation::DoTestStepPreambleL(void)
|
|
307 |
{
|
|
308 |
enum TVerdict verdict;
|
|
309 |
// this installs the scheduler
|
|
310 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
311 |
|
|
312 |
// Printing to the console and log file
|
|
313 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0961-HP"));
|
|
314 |
|
|
315 |
INFO_PRINTF1(_L("This test checks that CMdaAudioRecorderUtility::Duration(TTimeIntervalMicroSeconds &) returns TMMFDurationInfo::EMMFDurationInfoValid"));
|
|
316 |
|
|
317 |
iError = KErrNone;
|
|
318 |
|
|
319 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioFNameMeta"), iFileName))
|
|
320 |
{
|
|
321 |
return EInconclusive;
|
|
322 |
}
|
|
323 |
|
|
324 |
//
|
|
325 |
// Setup player with dummy file
|
|
326 |
if ( (iRecorder = CMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
327 |
return EInconclusive;
|
|
328 |
|
|
329 |
iRecorder->OpenFileL(iFileName);
|
|
330 |
|
|
331 |
CActiveScheduler::Start();
|
|
332 |
User::After(1000000);
|
|
333 |
|
|
334 |
if (iRecorder == NULL || iError != KErrNone )
|
|
335 |
{
|
|
336 |
return EInconclusive;
|
|
337 |
}
|
|
338 |
|
|
339 |
|
|
340 |
return verdict;
|
|
341 |
}
|
|
342 |
|
|
343 |
/**
|
|
344 |
*
|
|
345 |
* Test step Postamble.
|
|
346 |
*
|
|
347 |
* @xxxx
|
|
348 |
*
|
|
349 |
*/
|
|
350 |
enum TVerdict CTestStepRecorderDurationInformation::DoTestStepPostambleL(void)
|
|
351 |
{
|
|
352 |
delete iRecorder;
|
|
353 |
iRecorder = NULL;
|
|
354 |
//[ Destroy the scheduler ]
|
|
355 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
356 |
}
|
|
357 |
|
|
358 |
/**
|
|
359 |
*
|
|
360 |
* Do the test step.
|
|
361 |
* Each test step must supply an implementation for DoTestStepL.
|
|
362 |
*
|
|
363 |
* @return "TVerdict"
|
|
364 |
* The result of the test step
|
|
365 |
*
|
|
366 |
* @xxxx
|
|
367 |
*
|
|
368 |
*/
|
|
369 |
TVerdict CTestStepRecorderDurationInformation::DoTestStepL()
|
|
370 |
{
|
|
371 |
iTestStepResult = EFail;
|
|
372 |
|
|
373 |
// Check that the duration state is TMMFDurationInfo::EMMFDurationInfoValid - known.
|
|
374 |
TTimeIntervalMicroSeconds result2 = 0;
|
|
375 |
TMMFDurationInfo result = iRecorder->Duration(result2);
|
|
376 |
|
|
377 |
if ( result == EMMFDurationInfoValid )
|
|
378 |
{
|
|
379 |
iTestStepResult = EPass;
|
|
380 |
}
|
|
381 |
else
|
|
382 |
{
|
|
383 |
iTestStepResult = EFail;
|
|
384 |
}
|
|
385 |
|
|
386 |
// test steps return a result
|
|
387 |
return iTestStepResult;
|
|
388 |
}
|