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 CTestStepRecorderOpen.
|
|
57 |
*
|
|
58 |
*
|
|
59 |
* @return "CTestStepRecorderOpen*"
|
|
60 |
* The constructed CTestStepRecorderOpen
|
|
61 |
*
|
|
62 |
* @xxxx
|
|
63 |
*
|
|
64 |
*/
|
|
65 |
CTestStepRecorderOpen* CTestStepRecorderOpen::NewL()
|
|
66 |
{
|
|
67 |
CTestStepRecorderOpen* self = new(ELeave) CTestStepRecorderOpen;
|
|
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 |
CTestStepRecorderOpen::CTestStepRecorderOpen()
|
|
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-0205-CP");
|
|
84 |
iHeapSize = 120000;
|
|
85 |
}
|
|
86 |
|
|
87 |
/**
|
|
88 |
*
|
|
89 |
* Test step destructor.
|
|
90 |
*
|
|
91 |
* @xxxx
|
|
92 |
*
|
|
93 |
*/
|
|
94 |
CTestStepRecorderOpen::~CTestStepRecorderOpen()
|
|
95 |
{
|
|
96 |
}
|
|
97 |
|
|
98 |
/**
|
|
99 |
*
|
|
100 |
* Test step Preamble.
|
|
101 |
*
|
|
102 |
* @xxxx
|
|
103 |
*
|
|
104 |
*/
|
|
105 |
enum TVerdict CTestStepRecorderOpen::DoTestStepPreambleL(void)
|
|
106 |
{
|
|
107 |
enum TVerdict verdict;
|
|
108 |
// this installs the scheduler
|
|
109 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
110 |
|
|
111 |
// Printing to the console and log file
|
|
112 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0205-CP"));
|
|
113 |
INFO_PRINTF1(_L("this is a test of CMdaAudioRecorderUtility::OpenL(<location>)"));
|
|
114 |
|
|
115 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName7"), iFileName)) // wav file
|
|
116 |
{
|
|
117 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
118 |
return EInconclusive;
|
|
119 |
}
|
|
120 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName3"), iFileName2)) // au file
|
|
121 |
{
|
|
122 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
123 |
return EInconclusive;
|
|
124 |
}
|
|
125 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName4"), iFileName3)) // raw file
|
|
126 |
{
|
|
127 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
128 |
return EInconclusive;
|
|
129 |
}
|
|
130 |
|
|
131 |
// load the contents of an audio file to a Descriptor
|
|
132 |
TInt fSize;
|
|
133 |
|
|
134 |
iFs.Connect();
|
|
135 |
if ( iFile.Open(iFs, iFileName, EFileRead) != KErrNone )
|
|
136 |
return EInconclusive;
|
|
137 |
iFile.Size(fSize);
|
|
138 |
// load the sound from the file to a Descriptor
|
|
139 |
iBuf = HBufC8::NewL( fSize );
|
|
140 |
TPtr8 buf = iBuf->Des();
|
|
141 |
iFile.Read(buf);
|
|
142 |
|
|
143 |
iFile.Close();
|
|
144 |
iFs.Close();
|
|
145 |
|
|
146 |
// create the Recorder utility
|
|
147 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
148 |
verdict = EInconclusive;
|
|
149 |
|
|
150 |
iClipLocation = new TMdaFileClipLocation(iFileName);
|
|
151 |
iFormat = new TMdaWavClipFormat();
|
|
152 |
|
|
153 |
return verdict;
|
|
154 |
|
|
155 |
}
|
|
156 |
|
|
157 |
/**
|
|
158 |
*
|
|
159 |
* Test step Postamble.
|
|
160 |
*
|
|
161 |
* @xxxx
|
|
162 |
*
|
|
163 |
*/
|
|
164 |
enum TVerdict CTestStepRecorderOpen::DoTestStepPostambleL(void)
|
|
165 |
{
|
|
166 |
delete iRecorder;
|
|
167 |
iRecorder = NULL;
|
|
168 |
//[ Destroy the scheduler ]
|
|
169 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
170 |
}
|
|
171 |
|
|
172 |
/**
|
|
173 |
*
|
|
174 |
* Callback Handle.
|
|
175 |
*
|
|
176 |
* @xxxx
|
|
177 |
*
|
|
178 |
*/
|
|
179 |
void CTestStepRecorderOpen::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
180 |
TInt /*aPreviousState*/,
|
|
181 |
TInt /*aCurrentState*/,
|
|
182 |
TInt aErrorcCode)
|
|
183 |
{
|
|
184 |
iError = aErrorcCode;
|
|
185 |
CActiveScheduler::Stop();
|
|
186 |
}
|
|
187 |
|
|
188 |
void CTestStepRecorderOpen::OpenAndStartSchedulerL()
|
|
189 |
{
|
|
190 |
iRecorder->OpenL( iClipLocation, iFormat );
|
|
191 |
CActiveScheduler::Start();
|
|
192 |
}
|
|
193 |
|
|
194 |
/**
|
|
195 |
*
|
|
196 |
* Do the test step.
|
|
197 |
* Each test step must supply an implementation for DoTestStepL.
|
|
198 |
*
|
|
199 |
* @return "TVerdict"
|
|
200 |
* The result of the test step
|
|
201 |
*
|
|
202 |
* @xxxx
|
|
203 |
*
|
|
204 |
*/
|
|
205 |
TVerdict CTestStepRecorderOpen::DoTestStepL()
|
|
206 |
{
|
|
207 |
iTestStepResult = EPass;
|
|
208 |
TInt err = KErrNone;
|
|
209 |
|
|
210 |
// location: WAV file
|
|
211 |
TRAP( err, OpenAndStartSchedulerL() );
|
|
212 |
|
|
213 |
if (iRecorder == NULL ||
|
|
214 |
err != KErrNone ||
|
|
215 |
iError != KErrNone ||
|
|
216 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen )
|
|
217 |
{
|
|
218 |
INFO_PRINTF1(_L("WAV test failed"));
|
|
219 |
return EFail;
|
|
220 |
}
|
|
221 |
|
|
222 |
delete iRecorder;
|
|
223 |
iRecorder = NULL;
|
|
224 |
delete iClipLocation;
|
|
225 |
iClipLocation = NULL;
|
|
226 |
|
|
227 |
// location: Descriptor containg wav sound format
|
|
228 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
229 |
return EInconclusive;
|
|
230 |
TPtr8 buf = iBuf->Des();
|
|
231 |
iClipLocation = new TMdaDesClipLocation(buf);
|
|
232 |
TRAP( err, OpenAndStartSchedulerL() );
|
|
233 |
|
|
234 |
if (iRecorder == NULL ||
|
|
235 |
err != KErrNone ||
|
|
236 |
iError != KErrNone ||
|
|
237 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen )
|
|
238 |
{
|
|
239 |
INFO_PRINTF1(_L("Descriptor test failed"));
|
|
240 |
return EFail;
|
|
241 |
}
|
|
242 |
|
|
243 |
delete iRecorder;
|
|
244 |
iRecorder = NULL;
|
|
245 |
delete iClipLocation;
|
|
246 |
iClipLocation = NULL;
|
|
247 |
delete iFormat;
|
|
248 |
iFormat = NULL;
|
|
249 |
|
|
250 |
// location: File containg au sound format
|
|
251 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
252 |
return EInconclusive;
|
|
253 |
iClipLocation = new TMdaFileClipLocation(iFileName2);
|
|
254 |
iFormat = new TMdaAuClipFormat();
|
|
255 |
TRAP( err, OpenAndStartSchedulerL() );
|
|
256 |
|
|
257 |
if (iRecorder == NULL ||
|
|
258 |
err != KErrNone ||
|
|
259 |
iError != KErrNone ||
|
|
260 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen )
|
|
261 |
{
|
|
262 |
INFO_PRINTF1(_L("AU test failed"));
|
|
263 |
return EFail;
|
|
264 |
}
|
|
265 |
|
|
266 |
delete iRecorder;
|
|
267 |
iRecorder = NULL;
|
|
268 |
delete iClipLocation;
|
|
269 |
iClipLocation = NULL;
|
|
270 |
delete iFormat;
|
|
271 |
iFormat = NULL;
|
|
272 |
|
|
273 |
// location: File containg raw sound format
|
|
274 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
275 |
return EInconclusive;
|
|
276 |
iClipLocation = new TMdaFileClipLocation(iFileName3);
|
|
277 |
iFormat = new TMdaRawAudioClipFormat();
|
|
278 |
TRAP( err, OpenAndStartSchedulerL() );
|
|
279 |
|
|
280 |
if (iRecorder == NULL ||
|
|
281 |
err != KErrNone ||
|
|
282 |
iError != KErrNone ||
|
|
283 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen )
|
|
284 |
{
|
|
285 |
INFO_PRINTF1(_L("RAW test failed"));
|
|
286 |
return EFail;
|
|
287 |
}
|
|
288 |
|
|
289 |
delete iRecorder;
|
|
290 |
iRecorder = NULL;
|
|
291 |
delete iClipLocation;
|
|
292 |
iClipLocation = NULL;
|
|
293 |
delete iFormat;
|
|
294 |
iFormat = NULL;
|
|
295 |
|
|
296 |
|
|
297 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
298 |
// test steps return a result
|
|
299 |
return iTestStepResult;
|
|
300 |
}
|
|
301 |
|
|
302 |
/**
|
|
303 |
*
|
|
304 |
* Test step constructor.
|
|
305 |
* Each test step initialises its own name.
|
|
306 |
*
|
|
307 |
* @xxxx
|
|
308 |
*
|
|
309 |
*/
|
|
310 |
CTestMmfAclntRecFileInvDesForm::CTestMmfAclntRecFileInvDesForm()
|
|
311 |
{
|
|
312 |
iTestStepName = _L("MM-MMF-ACLNT-U-0969-HP");
|
|
313 |
iHeapSize = 200000; // playback part of test loads whole sound file into buffer, so need large heap
|
|
314 |
}
|
|
315 |
|
|
316 |
/**
|
|
317 |
*
|
|
318 |
* Static constructor for CTestMmfAclntRecFileInvDesForm.
|
|
319 |
*
|
|
320 |
* @return "CTestMmfAclntRecFileInvDesForm*"
|
|
321 |
* The constructed CTestMmfAclntRecFileInvDesForm
|
|
322 |
*
|
|
323 |
* @xxxx
|
|
324 |
*
|
|
325 |
*/
|
|
326 |
CTestMmfAclntRecFileInvDesForm* CTestMmfAclntRecFileInvDesForm::NewL()
|
|
327 |
{
|
|
328 |
CTestMmfAclntRecFileInvDesForm* self = new (ELeave) CTestMmfAclntRecFileInvDesForm();
|
|
329 |
return self;
|
|
330 |
}
|
|
331 |
|
|
332 |
/**
|
|
333 |
*
|
|
334 |
* Test step Preamble.
|
|
335 |
*
|
|
336 |
* @xxxx
|
|
337 |
*
|
|
338 |
*/
|
|
339 |
TVerdict CTestMmfAclntRecFileInvDesForm::DoTestStepPreambleL()
|
|
340 |
{
|
|
341 |
iTestStepResult = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
342 |
if(iTestStepResult != EPass)
|
|
343 |
{
|
|
344 |
return EInconclusive;
|
|
345 |
}
|
|
346 |
if( !GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName4"), iFileName) )
|
|
347 |
{
|
|
348 |
return EInconclusive;
|
|
349 |
}
|
|
350 |
if( (iRecUtil = CMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
351 |
{
|
|
352 |
return EInconclusive;
|
|
353 |
}
|
|
354 |
return EPass;
|
|
355 |
}
|
|
356 |
|
|
357 |
/**
|
|
358 |
*
|
|
359 |
* Test step Postamble.
|
|
360 |
*
|
|
361 |
* @xxxx
|
|
362 |
*
|
|
363 |
*/
|
|
364 |
TVerdict CTestMmfAclntRecFileInvDesForm::DoTestStepPostambleL()
|
|
365 |
{
|
|
366 |
delete iRecUtil;
|
|
367 |
iRecUtil = NULL;
|
|
368 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
369 |
}
|
|
370 |
|
|
371 |
void CTestMmfAclntRecFileInvDesForm::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
|
|
372 |
{
|
|
373 |
iError = aErrorCode;
|
|
374 |
INFO_PRINTF4( _L("MMdaObjectStateChangeObserver: previous state: %d current state: %d error: %d"),aPreviousState, aCurrentState, aErrorCode);
|
|
375 |
CActiveScheduler::Stop();
|
|
376 |
}
|
|
377 |
|
|
378 |
/**
|
|
379 |
*
|
|
380 |
* Do the test step.
|
|
381 |
* Each test step must supply an implementation for DoTestStepL.
|
|
382 |
*
|
|
383 |
* @return "TVerdict"
|
|
384 |
* The result of the test step
|
|
385 |
*
|
|
386 |
* @xxxx
|
|
387 |
*
|
|
388 |
*/
|
|
389 |
TVerdict CTestMmfAclntRecFileInvDesForm::DoTestStepL()
|
|
390 |
{
|
|
391 |
INFO_PRINTF1( _L("Test the SetDestinationFormatL API with passing wrong UID, so that it should return KErrNotSupported"));
|
|
392 |
INFO_PRINTF2(_L("CMdaAudioRecorderUtility->OpenFileL(%S)"), &iFileName);
|
|
393 |
iError = KErrTimedOut;
|
|
394 |
iTestStepResult = EFail;
|
|
395 |
iRecUtil->OpenFileL(iFileName);
|
|
396 |
CActiveScheduler::Start();
|
|
397 |
if ( iError == KErrNone )
|
|
398 |
{
|
|
399 |
// Get current format
|
|
400 |
TUid currentFormat = KNullUid;
|
|
401 |
TRAPD(err, currentFormat = iRecUtil->DestinationFormatL());
|
|
402 |
if ( err != KErrNone )
|
|
403 |
{
|
|
404 |
ERR_PRINTF2(_L("CMdaAudioRecorderUtility::DestinationFormatL failed with error %d."), err);
|
|
405 |
return EFail;
|
|
406 |
}
|
|
407 |
else
|
|
408 |
{
|
|
409 |
INFO_PRINTF2(_L("Current format %x."), currentFormat);
|
|
410 |
}
|
|
411 |
// Set invalid format
|
|
412 |
TUid newFormat;
|
|
413 |
newFormat.iUid = KMmfUidFormatRAWRead;
|
|
414 |
TRAP(err, iRecUtil->SetDestinationFormatL(newFormat));
|
|
415 |
if ( err != KErrNotSupported )
|
|
416 |
{
|
|
417 |
ERR_PRINTF2(_L("CMdaAudioRecorderUtility::SetDestinationFormatL failed with unexpected error %d."), err);
|
|
418 |
return EFail;
|
|
419 |
}
|
|
420 |
else
|
|
421 |
{
|
|
422 |
INFO_PRINTF2(_L("CMdaAudioRecorderUtility::SetDestinationFormatL failed with expected error %d."), err);
|
|
423 |
}
|
|
424 |
// Get current format
|
|
425 |
TRAP(err, currentFormat = iRecUtil->DestinationFormatL());
|
|
426 |
if ( err != KErrNotSupported )
|
|
427 |
{
|
|
428 |
ERR_PRINTF2(_L("Current format %x."), currentFormat);
|
|
429 |
return EFail;
|
|
430 |
}
|
|
431 |
else
|
|
432 |
{
|
|
433 |
INFO_PRINTF2(_L("CMdaAudioRecorderUtility::DestinationFormatL failed with expected error %d."), err);
|
|
434 |
iTestStepResult = EPass;
|
|
435 |
}
|
|
436 |
}
|
|
437 |
return iTestStepResult;
|
|
438 |
}
|
|
439 |
|