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 CTestStepRecorderVolRamp.
|
|
57 |
*
|
|
58 |
*
|
|
59 |
* @return "CTestStepRecorderVolRamp*"
|
|
60 |
* The constructed CTestStepRecorderVolRamp
|
|
61 |
*
|
|
62 |
* @xxxx
|
|
63 |
*
|
|
64 |
*/
|
|
65 |
CTestStepRecorderVolRamp* CTestStepRecorderVolRamp::NewL()
|
|
66 |
{
|
|
67 |
CTestStepRecorderVolRamp* self = new(ELeave) CTestStepRecorderVolRamp;
|
|
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 |
CTestStepRecorderVolRamp::CTestStepRecorderVolRamp()
|
|
80 |
{
|
|
81 |
iTestStepResult = EPass;
|
|
82 |
// store the name of this test case
|
|
83 |
// this is the name that is used by the script file
|
|
84 |
iTestStepName = _L("MM-MMF-ACLNT-U-0242-HP");
|
|
85 |
}
|
|
86 |
|
|
87 |
/**
|
|
88 |
*
|
|
89 |
* Test step destructor.
|
|
90 |
*
|
|
91 |
* @xxxx
|
|
92 |
*
|
|
93 |
*/
|
|
94 |
CTestStepRecorderVolRamp::~CTestStepRecorderVolRamp()
|
|
95 |
{
|
|
96 |
}
|
|
97 |
|
|
98 |
/**
|
|
99 |
*
|
|
100 |
* Test step Preamble.
|
|
101 |
*
|
|
102 |
* @xxxx
|
|
103 |
*
|
|
104 |
*/
|
|
105 |
enum TVerdict CTestStepRecorderVolRamp::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-0242-HP"));
|
|
113 |
INFO_PRINTF1(_L("this test is playing a sound from a Recorder with several Volume Ramp levels. SetVolumeRamp(...)"));
|
|
114 |
|
|
115 |
iError = KErrNone; //KErrTimedOut;
|
|
116 |
|
|
117 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName1"), iFileName))
|
|
118 |
{
|
|
119 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
120 |
return EInconclusive;
|
|
121 |
}
|
|
122 |
|
|
123 |
iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this);
|
|
124 |
iRecorder->OpenFileL(iFileName);
|
|
125 |
CActiveScheduler::Start();
|
|
126 |
User::After(100000);
|
|
127 |
if (iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
128 |
return EInconclusive;
|
|
129 |
|
|
130 |
return verdict;
|
|
131 |
}
|
|
132 |
|
|
133 |
/**
|
|
134 |
*
|
|
135 |
* Test step Postamble.
|
|
136 |
*
|
|
137 |
* @xxxx
|
|
138 |
*
|
|
139 |
*/
|
|
140 |
enum TVerdict CTestStepRecorderVolRamp::DoTestStepPostambleL(void)
|
|
141 |
{
|
|
142 |
delete iRecorder;
|
|
143 |
iRecorder = NULL;
|
|
144 |
|
|
145 |
//[ Destroy the scheduler ]
|
|
146 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
147 |
}
|
|
148 |
|
|
149 |
/**
|
|
150 |
*
|
|
151 |
* Callback Handle.
|
|
152 |
*
|
|
153 |
* @xxxx
|
|
154 |
*
|
|
155 |
*/
|
|
156 |
void CTestStepRecorderVolRamp::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
157 |
TInt aPreviousState,
|
|
158 |
TInt aCurrentState,
|
|
159 |
TInt aErrorcCode)
|
|
160 |
{
|
|
161 |
iError = aErrorcCode;
|
|
162 |
iHasStartedPlaying = EFalse;
|
|
163 |
iHasFinishedPlaying = EFalse;
|
|
164 |
if (aPreviousState == CMdaAudioRecorderUtility::EOpen &&
|
|
165 |
aCurrentState == CMdaAudioRecorderUtility::EPlaying)
|
|
166 |
iHasStartedPlaying = ETrue;
|
|
167 |
|
|
168 |
if (aPreviousState == CMdaAudioRecorderUtility::EPlaying &&
|
|
169 |
aCurrentState == CMdaAudioRecorderUtility::EOpen)
|
|
170 |
iHasFinishedPlaying = ETrue;
|
|
171 |
|
|
172 |
CActiveScheduler::Stop();
|
|
173 |
}
|
|
174 |
|
|
175 |
/**
|
|
176 |
*
|
|
177 |
* Do the test step.
|
|
178 |
* Each test step must supply an implementation for DoTestStepL.
|
|
179 |
*
|
|
180 |
* @return "TVerdict"
|
|
181 |
* The result of the test step
|
|
182 |
*
|
|
183 |
* @xxxx
|
|
184 |
*
|
|
185 |
*/
|
|
186 |
TVerdict CTestStepRecorderVolRamp::DoTestStepL()
|
|
187 |
{
|
|
188 |
//
|
|
189 |
// GETS STACK - callbacks NEED FIXING
|
|
190 |
//
|
|
191 |
TInt err;
|
|
192 |
// try zero ramp
|
|
193 |
iRecorder->SetVolumeRamp(TTimeIntervalMicroSeconds(0));
|
|
194 |
INFO_PRINTF1(_L("volume ramp: 0"));
|
|
195 |
TRAP(err, iRecorder->PlayL() );
|
|
196 |
if (err != KErrNone)
|
|
197 |
return EFail;
|
|
198 |
CActiveScheduler::Start(); // for start playing
|
|
199 |
if (iError != KErrNone || !iHasStartedPlaying)
|
|
200 |
return EFail;
|
|
201 |
CActiveScheduler::Start(); // for finishing playing
|
|
202 |
if( iError != KErrNone || !iHasFinishedPlaying)
|
|
203 |
return EFail;
|
|
204 |
iRecorder->SetPosition(TTimeIntervalMicroSeconds(0));
|
|
205 |
if (iRecorder->Position() != TTimeIntervalMicroSeconds(0))
|
|
206 |
return EInconclusive;
|
|
207 |
|
|
208 |
// try several volume values and play
|
|
209 |
for (TInt ramp=1 ; ramp<=1000000 ; ramp*=10 )
|
|
210 |
{
|
|
211 |
iRecorder->SetVolumeRamp(TTimeIntervalMicroSeconds(ramp));
|
|
212 |
iRecorder->PlayL();
|
|
213 |
|
|
214 |
CActiveScheduler::Start();
|
|
215 |
if (iError != KErrNone || !iHasStartedPlaying)
|
|
216 |
return EFail;
|
|
217 |
CActiveScheduler::Start();
|
|
218 |
if( iError != KErrNone || !iHasFinishedPlaying)
|
|
219 |
return EFail;
|
|
220 |
INFO_PRINTF2(_L("loop, volume ramp: %d"), ramp);
|
|
221 |
iRecorder->SetPosition(TTimeIntervalMicroSeconds(0));
|
|
222 |
if (iRecorder->Position() != TTimeIntervalMicroSeconds(0))
|
|
223 |
return EInconclusive;
|
|
224 |
} // end for ramp
|
|
225 |
|
|
226 |
// try ramp > sound Duration
|
|
227 |
//iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this);
|
|
228 |
//iRecorder->OpenFileL(iFileName);
|
|
229 |
//if (iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
230 |
// return EInconclusive;
|
|
231 |
iRecorder->SetVolumeRamp(TTimeIntervalMicroSeconds(2000000));
|
|
232 |
iRecorder->PlayL();
|
|
233 |
CActiveScheduler::Start();
|
|
234 |
if (iError != KErrNone || !iHasStartedPlaying)
|
|
235 |
return EFail;
|
|
236 |
CActiveScheduler::Start();
|
|
237 |
if( iError != KErrNone || !iHasFinishedPlaying)
|
|
238 |
return EFail;
|
|
239 |
|
|
240 |
delete iRecorder;
|
|
241 |
iRecorder = NULL;
|
|
242 |
|
|
243 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
244 |
// test steps return a result
|
|
245 |
return iTestStepResult;
|
|
246 |
}
|
|
247 |
|