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 "TestStepPlayerManip.h"
|
|
44 |
|
|
45 |
#include "mmfclientaudioplayer.h"
|
|
46 |
|
|
47 |
// --------------------------------------------
|
|
48 |
|
|
49 |
/**
|
|
50 |
*
|
|
51 |
* Static constructor for CTestStepPlayerVolRamp.
|
|
52 |
*
|
|
53 |
*
|
|
54 |
* @return "CTestStepPlayerVolRamp*"
|
|
55 |
* The constructed CTestStepPlayerVolRamp
|
|
56 |
*
|
|
57 |
* @xxxx
|
|
58 |
*
|
|
59 |
*/
|
|
60 |
CTestStepPlayerVolRamp* CTestStepPlayerVolRamp::NewL()
|
|
61 |
{
|
|
62 |
CTestStepPlayerVolRamp* self = new(ELeave) CTestStepPlayerVolRamp;
|
|
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 |
CTestStepPlayerVolRamp::CTestStepPlayerVolRamp()
|
|
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-0037-HP");
|
|
80 |
}
|
|
81 |
|
|
82 |
/**
|
|
83 |
*
|
|
84 |
* Test step destructor.
|
|
85 |
*
|
|
86 |
* @xxxx
|
|
87 |
*
|
|
88 |
*/
|
|
89 |
CTestStepPlayerVolRamp::~CTestStepPlayerVolRamp()
|
|
90 |
{
|
|
91 |
}
|
|
92 |
/**
|
|
93 |
* Implementation of the MMdaAudioPlayerCallback interface functions
|
|
94 |
**/
|
|
95 |
void CTestStepPlayerVolRamp::MapcInitComplete(TInt aError,
|
|
96 |
const TTimeIntervalMicroSeconds &/*aDuration*/)
|
|
97 |
{
|
|
98 |
iError = aError;
|
|
99 |
CActiveScheduler::Stop();
|
|
100 |
}
|
|
101 |
|
|
102 |
void CTestStepPlayerVolRamp::MapcPlayComplete(TInt aError)
|
|
103 |
{
|
|
104 |
iError = aError;
|
|
105 |
CActiveScheduler::Stop();
|
|
106 |
}
|
|
107 |
|
|
108 |
/**
|
|
109 |
*
|
|
110 |
* Test step Preamble.
|
|
111 |
*
|
|
112 |
* @xxxx
|
|
113 |
*
|
|
114 |
*/
|
|
115 |
enum TVerdict CTestStepPlayerVolRamp::DoTestStepPreambleL(void)
|
|
116 |
{
|
|
117 |
enum TVerdict verdict;
|
|
118 |
// this installs the scheduler
|
|
119 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
120 |
|
|
121 |
// Printing to the console and log file
|
|
122 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0037-HP"));
|
|
123 |
INFO_PRINTF1(_L("this test is playing a sound with several Volume Ramp levels. SetVolumeRamp(...)"));
|
|
124 |
|
|
125 |
iError = KErrNone; //KErrTimedOut;
|
|
126 |
|
|
127 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName1"), iFileName))
|
|
128 |
{
|
|
129 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
130 |
return EInconclusive;
|
|
131 |
}
|
|
132 |
|
|
133 |
iPlayer = CMMFMdaAudioPlayerUtility::NewFilePlayerL(iFileName, *this);
|
|
134 |
CActiveScheduler::Start();
|
|
135 |
User::After(1000000);
|
|
136 |
TInt err1 = KErrNone;
|
|
137 |
TInt err2 = KErrNone;
|
|
138 |
TInt state = 0;
|
|
139 |
TMMFMessageDestination* srcHandle = NULL;
|
|
140 |
err1 = GetAudPlayerState(iPlayer, state);
|
|
141 |
err2 = GetAudPlayerSourceHandle(iPlayer, srcHandle);
|
|
142 |
if ( err1 != KErrNone ||
|
|
143 |
err2 != KErrNone ||
|
|
144 |
&srcHandle == NULL ||
|
|
145 |
state != CMMFMdaAudioPlayerUtility::EStopped ||
|
|
146 |
iPlayer->Duration() == TTimeIntervalMicroSeconds(0) || //we know the sound file has duration >0
|
|
147 |
iError != KErrNone)
|
|
148 |
return EInconclusive;
|
|
149 |
|
|
150 |
iDuration = new TTimeIntervalMicroSeconds(iPlayer->Duration());
|
|
151 |
|
|
152 |
return verdict;
|
|
153 |
}
|
|
154 |
|
|
155 |
/**
|
|
156 |
*
|
|
157 |
* Test step Postamble.
|
|
158 |
*
|
|
159 |
* @xxxx
|
|
160 |
*
|
|
161 |
*/
|
|
162 |
enum TVerdict CTestStepPlayerVolRamp::DoTestStepPostambleL(void)
|
|
163 |
{
|
|
164 |
delete iPlayer;
|
|
165 |
iPlayer = NULL;
|
|
166 |
//[ Destroy the scheduler ]
|
|
167 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
168 |
}
|
|
169 |
|
|
170 |
/**
|
|
171 |
*
|
|
172 |
* Do the test step.
|
|
173 |
* Each test step must supply an implementation for DoTestStepL.
|
|
174 |
*
|
|
175 |
* @return "TVerdict"
|
|
176 |
* The result of the test step
|
|
177 |
*
|
|
178 |
* @xxxx
|
|
179 |
*
|
|
180 |
*/
|
|
181 |
TVerdict CTestStepPlayerVolRamp::DoTestStepL()
|
|
182 |
{
|
|
183 |
iTestStepResult = EPass;
|
|
184 |
//__MM_HEAP_MARK;
|
|
185 |
// check if player openned the sound file successfully
|
|
186 |
TInt err1 = KErrNone;
|
|
187 |
TInt err2 = KErrNone;
|
|
188 |
TInt state = 0;
|
|
189 |
TMMFMessageDestination* srcHandle = NULL;
|
|
190 |
err1 = GetAudPlayerState(iPlayer, state);
|
|
191 |
err2 = GetAudPlayerSourceHandle(iPlayer, srcHandle);
|
|
192 |
if ( err1 != KErrNone ||
|
|
193 |
err2 != KErrNone ||
|
|
194 |
&srcHandle == NULL ||
|
|
195 |
state != CMMFMdaAudioPlayerUtility::EStopped ||
|
|
196 |
iError != KErrNone)
|
|
197 |
return EInconclusive;
|
|
198 |
|
|
199 |
// try zero ramp
|
|
200 |
iPlayer->SetVolumeRamp(TTimeIntervalMicroSeconds(0));
|
|
201 |
iPlayer->Play();
|
|
202 |
CActiveScheduler::Start();
|
|
203 |
User::After(1200000); // time enough to play it
|
|
204 |
err1 = GetAudPlayerState(iPlayer, state);
|
|
205 |
if ( err1 != KErrNone ||
|
|
206 |
state != CMMFMdaAudioPlayerUtility::EStopped ||
|
|
207 |
iError != KErrNone)
|
|
208 |
return EFail;
|
|
209 |
delete iPlayer;
|
|
210 |
iPlayer = NULL;
|
|
211 |
|
|
212 |
// problem of the Audio Clients to be fixed
|
|
213 |
// Cannot Play several TImes sound if the player object is not created again....
|
|
214 |
|
|
215 |
// try several volume values and play
|
|
216 |
for (TInt ramp=1 ; ramp<=1000000 ; ramp*=10 )
|
|
217 |
{
|
|
218 |
iPlayer = CMMFMdaAudioPlayerUtility::NewFilePlayerL(iFileName, *this);
|
|
219 |
CActiveScheduler::Start();
|
|
220 |
User::After(1000000);
|
|
221 |
err1 = GetAudPlayerState(iPlayer, state);
|
|
222 |
err2 = GetAudPlayerSourceHandle(iPlayer, srcHandle);
|
|
223 |
if ( err1 != KErrNone ||
|
|
224 |
err2 != KErrNone ||
|
|
225 |
&srcHandle == NULL ||
|
|
226 |
state != CMMFMdaAudioPlayerUtility::EStopped ||
|
|
227 |
iPlayer->Duration() == TTimeIntervalMicroSeconds(0) || //we know the sound file has duration >0
|
|
228 |
iError != KErrNone)
|
|
229 |
return EInconclusive;
|
|
230 |
|
|
231 |
iPlayer->SetVolumeRamp(TTimeIntervalMicroSeconds(ramp));
|
|
232 |
iPlayer->Play();
|
|
233 |
CActiveScheduler::Start();
|
|
234 |
User::After(1200000); // time enough to play it
|
|
235 |
INFO_PRINTF1(_L("loop"));
|
|
236 |
err1 = GetAudPlayerState(iPlayer, state);
|
|
237 |
if ( err1 != KErrNone ||
|
|
238 |
state != CMMFMdaAudioPlayerUtility::EStopped ||
|
|
239 |
iError != KErrNone)
|
|
240 |
return EFail;
|
|
241 |
delete iPlayer;
|
|
242 |
iPlayer = NULL;
|
|
243 |
} // end for repeats
|
|
244 |
|
|
245 |
// try ramp > sound Duration
|
|
246 |
iPlayer = CMMFMdaAudioPlayerUtility::NewFilePlayerL(iFileName, *this);
|
|
247 |
CActiveScheduler::Start();
|
|
248 |
User::After(1000000);
|
|
249 |
iPlayer->SetVolumeRamp(TTimeIntervalMicroSeconds(2000000));
|
|
250 |
iPlayer->Play();
|
|
251 |
CActiveScheduler::Start();
|
|
252 |
User::After(1200000); // time enough to play it
|
|
253 |
err1 = GetAudPlayerState(iPlayer, state);
|
|
254 |
if ( err1 != KErrNone ||
|
|
255 |
state != CMMFMdaAudioPlayerUtility::EStopped ||
|
|
256 |
iError != KErrNone)
|
|
257 |
return EFail;
|
|
258 |
delete iPlayer;
|
|
259 |
iPlayer = NULL;
|
|
260 |
|
|
261 |
|
|
262 |
//__MM_HEAP_MARKEND;
|
|
263 |
|
|
264 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
265 |
// test steps return a result
|
|
266 |
return iTestStepResult;
|
|
267 |
}
|
|
268 |
|