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 "TestStepPlayerNew.h"
|
|
44 |
|
|
45 |
#include "mmfclientaudioplayer.h"
|
|
46 |
|
|
47 |
// --------------------------------------------
|
|
48 |
|
|
49 |
/**
|
|
50 |
*
|
|
51 |
* Static constructor for CTestStepPlayerNewPriorPrefer.
|
|
52 |
*
|
|
53 |
*
|
|
54 |
* @return "CTestStepPlayerNewPriorPrefer*"
|
|
55 |
* The constructed CTestStepPlayerNewPriorPrefer
|
|
56 |
*
|
|
57 |
* @xxxx
|
|
58 |
*
|
|
59 |
*/
|
|
60 |
CTestStepPlayerNewPriorPrefer* CTestStepPlayerNewPriorPrefer::NewL()
|
|
61 |
{
|
|
62 |
CTestStepPlayerNewPriorPrefer* self = new(ELeave) CTestStepPlayerNewPriorPrefer;
|
|
63 |
return self;
|
|
64 |
}
|
|
65 |
|
|
66 |
/**
|
|
67 |
*
|
|
68 |
* Test step constructor.
|
|
69 |
* Each test step initialises its own name.
|
|
70 |
*
|
|
71 |
* @xxxx
|
|
72 |
*
|
|
73 |
*/
|
|
74 |
CTestStepPlayerNewPriorPrefer::CTestStepPlayerNewPriorPrefer() : iTestCase(0), iPlayer(NULL)
|
|
75 |
{
|
|
76 |
iTestStepResult = EPass;
|
|
77 |
// store the name of this test case
|
|
78 |
// this is the name that is used by the script file
|
|
79 |
iTestStepName = _L("MM-MMF-ACLNT-U-0003-HP");
|
|
80 |
}
|
|
81 |
|
|
82 |
/**
|
|
83 |
*
|
|
84 |
* Test step destructor.
|
|
85 |
*
|
|
86 |
* @xxxx
|
|
87 |
*
|
|
88 |
*/
|
|
89 |
CTestStepPlayerNewPriorPrefer::~CTestStepPlayerNewPriorPrefer()
|
|
90 |
{
|
|
91 |
}
|
|
92 |
/**
|
|
93 |
* Implementation of the MMdaAudioPlayerCallback interface functions
|
|
94 |
**/
|
|
95 |
void CTestStepPlayerNewPriorPrefer::MapcInitComplete(TInt aError,
|
|
96 |
const TTimeIntervalMicroSeconds &/*aDuration*/)
|
|
97 |
{
|
|
98 |
iError = aError;
|
|
99 |
CActiveScheduler::Stop();
|
|
100 |
|
|
101 |
TInt err1 = KErrNone;
|
|
102 |
TInt err2 = KErrNone;
|
|
103 |
TInt state = 0;
|
|
104 |
TMMFMessageDestination* srcHandle = NULL;
|
|
105 |
|
|
106 |
switch (iTestCase) {
|
|
107 |
case 1:
|
|
108 |
break;
|
|
109 |
case 2:
|
|
110 |
break;
|
|
111 |
case 3:
|
|
112 |
INFO_PRINTF1(_L("InitComplete3"));
|
|
113 |
err1 = GetAudPlayerState(iPlayer, state);
|
|
114 |
err2 = GetAudPlayerSourceHandle(iPlayer, srcHandle);
|
|
115 |
if ( err1 != KErrNone ||
|
|
116 |
err2 != KErrNone ||
|
|
117 |
&srcHandle == NULL ||
|
|
118 |
state != CMMFMdaAudioPlayerUtility::EStopped ||
|
|
119 |
iError != KErrNone)
|
|
120 |
iTestStepResult = EFail;
|
|
121 |
if (iPlayer != NULL)
|
|
122 |
{
|
|
123 |
delete iPlayer;
|
|
124 |
iPlayer = NULL;
|
|
125 |
}
|
|
126 |
break;
|
|
127 |
case 4:
|
|
128 |
INFO_PRINTF1(_L("InitComplete4"));
|
|
129 |
if ( err1 != KErrNone ||
|
|
130 |
err2 != KErrNone ||
|
|
131 |
&srcHandle == NULL ||
|
|
132 |
state != CMMFMdaAudioPlayerUtility::EStopped ||
|
|
133 |
iError != KErrNone)
|
|
134 |
iTestStepResult = EFail;
|
|
135 |
if (iPlayer != NULL)
|
|
136 |
{
|
|
137 |
delete iPlayer;
|
|
138 |
iPlayer = NULL;
|
|
139 |
}
|
|
140 |
break;
|
|
141 |
default:
|
|
142 |
break;
|
|
143 |
}
|
|
144 |
|
|
145 |
}
|
|
146 |
|
|
147 |
void CTestStepPlayerNewPriorPrefer::MapcPlayComplete(TInt /*aError*/)
|
|
148 |
{
|
|
149 |
// not used inthis test
|
|
150 |
}
|
|
151 |
|
|
152 |
/**
|
|
153 |
*
|
|
154 |
* Test step Postamble.
|
|
155 |
*
|
|
156 |
* @xxxx
|
|
157 |
*
|
|
158 |
*/
|
|
159 |
enum TVerdict CTestStepPlayerNewPriorPrefer::DoTestStepPostambleL(void)
|
|
160 |
{
|
|
161 |
delete iPlayer;
|
|
162 |
iPlayer = NULL;
|
|
163 |
//[ Destroy the scheduler ]
|
|
164 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
165 |
}
|
|
166 |
|
|
167 |
/**
|
|
168 |
*
|
|
169 |
* Do the test step.
|
|
170 |
* Each test step must supply an implementation for DoTestStepL.
|
|
171 |
*
|
|
172 |
* @return "TVerdict"
|
|
173 |
* The result of the test step
|
|
174 |
*
|
|
175 |
* @xxxx
|
|
176 |
*
|
|
177 |
*/
|
|
178 |
TVerdict CTestStepPlayerNewPriorPrefer::DoTestStepL()
|
|
179 |
{
|
|
180 |
__MM_HEAP_MARK;
|
|
181 |
// Printing to the console and log file
|
|
182 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0003-HP"));// iTestStepName.Ptr());
|
|
183 |
INFO_PRINTF1(_L("this test is iniatilising a CMdaAudioPlayerUtility object"));
|
|
184 |
|
|
185 |
iError = KErrNone; //KErrTimedOut;
|
|
186 |
|
|
187 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName1"), iFileName))
|
|
188 |
{
|
|
189 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
190 |
return EInconclusive;
|
|
191 |
}
|
|
192 |
|
|
193 |
// test 1 //
|
|
194 |
iTestCase = 1;
|
|
195 |
iPlayer = CMMFMdaAudioPlayerUtility::NewL(*this, EMdaPriorityMin);
|
|
196 |
INFO_PRINTF1(_L("InitComplete1"));
|
|
197 |
TInt err1 = KErrNone;
|
|
198 |
TInt err2 = KErrNone;
|
|
199 |
TInt state = 0;
|
|
200 |
TMMFMessageDestination* srcHandle = NULL;
|
|
201 |
err1 = GetAudPlayerState(iPlayer, state);
|
|
202 |
err2 = GetAudPlayerSourceHandle(iPlayer, srcHandle);
|
|
203 |
if ( err1 != KErrNone ||
|
|
204 |
err2 != KErrNone ||
|
|
205 |
&srcHandle == NULL ||
|
|
206 |
state != CMMFMdaAudioPlayerUtility::EStopped ||
|
|
207 |
iError != KErrNone)
|
|
208 |
return EFail;
|
|
209 |
delete iPlayer;
|
|
210 |
iPlayer = NULL;
|
|
211 |
|
|
212 |
// test 2 //
|
|
213 |
iTestCase = 2;
|
|
214 |
iPlayer = CMMFMdaAudioPlayerUtility::NewL(*this, EMdaPriorityMax);
|
|
215 |
INFO_PRINTF1(_L("InitComplete2"));
|
|
216 |
err1 = GetAudPlayerState(iPlayer, state);
|
|
217 |
err2 = GetAudPlayerSourceHandle(iPlayer, srcHandle);
|
|
218 |
if ( err1 != KErrNone ||
|
|
219 |
err2 != KErrNone ||
|
|
220 |
&srcHandle == NULL ||
|
|
221 |
state != CMMFMdaAudioPlayerUtility::EStopped ||
|
|
222 |
iError != KErrNone)
|
|
223 |
return EFail;
|
|
224 |
delete iPlayer;
|
|
225 |
iPlayer = NULL;
|
|
226 |
|
|
227 |
// test 3 //
|
|
228 |
iTestCase = 3;
|
|
229 |
iPlayer = CMMFMdaAudioPlayerUtility::NewFilePlayerL(iFileName, *this, EMdaPriorityMax);
|
|
230 |
CActiveScheduler::Start();
|
|
231 |
|
|
232 |
// test 4 //
|
|
233 |
iTestCase = 4;
|
|
234 |
iPlayer = CMMFMdaAudioPlayerUtility::NewFilePlayerL(iFileName, *this, EMdaPriorityMax);
|
|
235 |
CActiveScheduler::Start();
|
|
236 |
|
|
237 |
User::After(500000);
|
|
238 |
|
|
239 |
__MM_HEAP_MARKEND;
|
|
240 |
|
|
241 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
242 |
// test steps return a result
|
|
243 |
return iTestStepResult;
|
|
244 |
}
|
|
245 |
|
|
246 |
|
|
247 |
// --------------------------------------------
|
|
248 |
|
|
249 |
/**
|
|
250 |
*
|
|
251 |
* Static constructor for CTestStepPlayerNewPrefer.
|
|
252 |
*
|
|
253 |
*
|
|
254 |
* @return "CTestStepPlayerNewPrefer*"
|
|
255 |
* The constructed CTestStepPlayerNewPrefer
|
|
256 |
*
|
|
257 |
* @xxxx
|
|
258 |
*
|
|
259 |
*/
|
|
260 |
CTestStepPlayerNewPrefer* CTestStepPlayerNewPrefer::NewL()
|
|
261 |
{
|
|
262 |
CTestStepPlayerNewPrefer* self = new(ELeave) CTestStepPlayerNewPrefer;
|
|
263 |
return self;
|
|
264 |
}
|
|
265 |
|
|
266 |
/**
|
|
267 |
*
|
|
268 |
* Test step constructor.
|
|
269 |
* Each test step initialises its own name.
|
|
270 |
*
|
|
271 |
* @xxxx
|
|
272 |
*
|
|
273 |
*/
|
|
274 |
CTestStepPlayerNewPrefer::CTestStepPlayerNewPrefer()
|
|
275 |
{
|
|
276 |
// store the name of this test case
|
|
277 |
// this is the name that is used by the script file
|
|
278 |
iTestStepName = _L("MM-MMF-ACLNT-U-0004-HP");
|
|
279 |
}
|
|
280 |
|
|
281 |
/**
|
|
282 |
*
|
|
283 |
* Test step destructor.
|
|
284 |
*
|
|
285 |
* @xxxx
|
|
286 |
*
|
|
287 |
*/
|
|
288 |
CTestStepPlayerNewPrefer::~CTestStepPlayerNewPrefer()
|
|
289 |
{
|
|
290 |
}
|
|
291 |
/**
|
|
292 |
* Implementation of the MMdaAudioPlayerCallback interface functions
|
|
293 |
**/
|
|
294 |
void CTestStepPlayerNewPrefer::MapcInitComplete(TInt aError,
|
|
295 |
const TTimeIntervalMicroSeconds &/*aDuration*/)
|
|
296 |
{
|
|
297 |
iError = aError;
|
|
298 |
CActiveScheduler::Stop();
|
|
299 |
}
|
|
300 |
|
|
301 |
void CTestStepPlayerNewPrefer::MapcPlayComplete(TInt /*aError*/)
|
|
302 |
{
|
|
303 |
// not used inthis test
|
|
304 |
}
|
|
305 |
|
|
306 |
/**
|
|
307 |
*
|
|
308 |
* Test step Postamble.
|
|
309 |
*
|
|
310 |
* @xxxx
|
|
311 |
*
|
|
312 |
*/
|
|
313 |
enum TVerdict CTestStepPlayerNewPrefer::DoTestStepPostambleL(void)
|
|
314 |
{
|
|
315 |
delete iPlayer;
|
|
316 |
iPlayer = NULL;
|
|
317 |
//[ Destroy the scheduler ]
|
|
318 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
319 |
}
|
|
320 |
|
|
321 |
/**
|
|
322 |
*
|
|
323 |
* Do the test step.
|
|
324 |
* Each test step must supply an implementation for DoTestStepL.
|
|
325 |
*
|
|
326 |
* @return "TVerdict"
|
|
327 |
* The result of the test step
|
|
328 |
*
|
|
329 |
* @xxxx
|
|
330 |
*
|
|
331 |
*/
|
|
332 |
TVerdict CTestStepPlayerNewPrefer::DoTestStepL()
|
|
333 |
{
|
|
334 |
__MM_HEAP_MARK;
|
|
335 |
// Printing to the console and log file
|
|
336 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0004-HP"));// iTestStepName.Ptr());
|
|
337 |
INFO_PRINTF1(_L("this test is iniatilising a CMdaAudioPlayerUtility object with non-default preferences"));
|
|
338 |
|
|
339 |
iError = KErrNone; //KErrTimedOut;
|
|
340 |
|
|
341 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName1"), iFileName))
|
|
342 |
{
|
|
343 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
344 |
return EInconclusive;
|
|
345 |
}
|
|
346 |
|
|
347 |
// test 1 //
|
|
348 |
iPlayer = CMMFMdaAudioPlayerUtility::NewL(*this, EMdaPriorityNormal, EMdaPriorityPreferenceQuality);
|
|
349 |
// check for errors
|
|
350 |
TInt err1 = KErrNone;
|
|
351 |
TInt err2 = KErrNone;
|
|
352 |
TInt state = 0;
|
|
353 |
TMMFMessageDestination* srcHandle = NULL;
|
|
354 |
err1 = GetAudPlayerState(iPlayer, state);
|
|
355 |
err2 = GetAudPlayerSourceHandle(iPlayer, srcHandle);
|
|
356 |
if ( err1 != KErrNone ||
|
|
357 |
err2 != KErrNone ||
|
|
358 |
&srcHandle == NULL ||
|
|
359 |
state != CMMFMdaAudioPlayerUtility::EStopped ||
|
|
360 |
iError != KErrNone)
|
|
361 |
return EFail;
|
|
362 |
delete iPlayer;
|
|
363 |
iPlayer = NULL;
|
|
364 |
|
|
365 |
// test 2 //
|
|
366 |
iPlayer = CMMFMdaAudioPlayerUtility::NewL(*this, EMdaPriorityNormal, EMdaPriorityPreferenceTime);
|
|
367 |
// check for errors
|
|
368 |
err1 = GetAudPlayerState(iPlayer, state);
|
|
369 |
err2 = GetAudPlayerSourceHandle(iPlayer, srcHandle);
|
|
370 |
if ( err1 != KErrNone ||
|
|
371 |
err2 != KErrNone ||
|
|
372 |
&srcHandle == NULL ||
|
|
373 |
state != CMMFMdaAudioPlayerUtility::EStopped ||
|
|
374 |
iError != KErrNone)
|
|
375 |
return EFail;
|
|
376 |
delete iPlayer;
|
|
377 |
iPlayer = NULL;
|
|
378 |
|
|
379 |
// test 3 //
|
|
380 |
iPlayer = CMMFMdaAudioPlayerUtility::NewFilePlayerL(iFileName, *this, EMdaPriorityNormal, EMdaPriorityPreferenceQuality);
|
|
381 |
CActiveScheduler::Start();
|
|
382 |
User::After(500000);
|
|
383 |
// check for errors
|
|
384 |
err1 = GetAudPlayerState(iPlayer, state);
|
|
385 |
err2 = GetAudPlayerSourceHandle(iPlayer, srcHandle);
|
|
386 |
if ( err1 != KErrNone ||
|
|
387 |
err2 != KErrNone ||
|
|
388 |
&srcHandle == NULL ||
|
|
389 |
state != CMMFMdaAudioPlayerUtility::EStopped ||
|
|
390 |
iError != KErrNone)
|
|
391 |
return EFail;
|
|
392 |
delete iPlayer;
|
|
393 |
iPlayer = NULL;
|
|
394 |
|
|
395 |
// test 4 //
|
|
396 |
iPlayer = CMMFMdaAudioPlayerUtility::NewFilePlayerL(iFileName, *this, EMdaPriorityNormal, EMdaPriorityPreferenceTime);
|
|
397 |
CActiveScheduler::Start();
|
|
398 |
User::After(500000);
|
|
399 |
// check for errors
|
|
400 |
err1 = GetAudPlayerState(iPlayer, state);
|
|
401 |
err2 = GetAudPlayerSourceHandle(iPlayer, srcHandle);
|
|
402 |
if ( err1 != KErrNone ||
|
|
403 |
err2 != KErrNone ||
|
|
404 |
&srcHandle == NULL ||
|
|
405 |
state != CMMFMdaAudioPlayerUtility::EStopped ||
|
|
406 |
iError != KErrNone)
|
|
407 |
return EFail;
|
|
408 |
delete iPlayer;
|
|
409 |
iPlayer = NULL;
|
|
410 |
|
|
411 |
__MM_HEAP_MARKEND;
|
|
412 |
|
|
413 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
414 |
// test steps return a result
|
|
415 |
return iTestStepResult;
|
|
416 |
}
|
|
417 |
|