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 CTestStepRecorderClearWindowPlay.
|
|
57 |
*
|
|
58 |
*
|
|
59 |
* @return "CTestStepRecorderClearWindowPlay*"
|
|
60 |
* The constructed CTestStepRecorderClearWindowPlay
|
|
61 |
*
|
|
62 |
* @xxxx
|
|
63 |
*
|
|
64 |
*/
|
|
65 |
CTestStepRecorderClearWindowPlay* CTestStepRecorderClearWindowPlay::NewL()
|
|
66 |
{
|
|
67 |
CTestStepRecorderClearWindowPlay* self = new(ELeave) CTestStepRecorderClearWindowPlay;
|
|
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 |
CTestStepRecorderClearWindowPlay::CTestStepRecorderClearWindowPlay()
|
|
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-0247-HP");
|
|
84 |
}
|
|
85 |
|
|
86 |
/**
|
|
87 |
*
|
|
88 |
* Test step destructor.
|
|
89 |
*
|
|
90 |
* @xxxx
|
|
91 |
*
|
|
92 |
*/
|
|
93 |
CTestStepRecorderClearWindowPlay::~CTestStepRecorderClearWindowPlay()
|
|
94 |
{
|
|
95 |
}
|
|
96 |
|
|
97 |
/**
|
|
98 |
*
|
|
99 |
* Test step Preamble.
|
|
100 |
*
|
|
101 |
* @xxxx
|
|
102 |
*
|
|
103 |
*/
|
|
104 |
enum TVerdict CTestStepRecorderClearWindowPlay::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-0247-HP"));
|
|
112 |
INFO_PRINTF1(_L("this is a test of CMdaAudioRecorderUtility::ClearPlayWindow()-PlayL()"));
|
|
113 |
|
|
114 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName7"), iFileName)) // wav file
|
|
115 |
{
|
|
116 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
117 |
return EInconclusive;
|
|
118 |
}
|
|
119 |
|
|
120 |
// create the Recorder utility
|
|
121 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
122 |
return EInconclusive;
|
|
123 |
|
|
124 |
iRecorder->OpenFileL( iFileName );
|
|
125 |
CActiveScheduler::Start();
|
|
126 |
if (iRecorder == NULL ||
|
|
127 |
iError != KErrNone ||
|
|
128 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
129 |
return EInconclusive;
|
|
130 |
|
|
131 |
iBeginning = TTimeIntervalMicroSeconds( 0 );
|
|
132 |
iMiddle = TTimeIntervalMicroSeconds( iRecorder->Duration().Int64() / 2 );
|
|
133 |
iEnd = iRecorder->Duration();
|
|
134 |
|
|
135 |
return verdict;
|
|
136 |
}
|
|
137 |
|
|
138 |
/**
|
|
139 |
*
|
|
140 |
* Test step Postamble.
|
|
141 |
*
|
|
142 |
* @xxxx
|
|
143 |
*
|
|
144 |
*/
|
|
145 |
enum TVerdict CTestStepRecorderClearWindowPlay::DoTestStepPostambleL(void)
|
|
146 |
{
|
|
147 |
delete iRecorder;
|
|
148 |
iRecorder = NULL;
|
|
149 |
//[ Destroy the scheduler ]
|
|
150 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
151 |
}
|
|
152 |
|
|
153 |
/**
|
|
154 |
*
|
|
155 |
* Callback Handle.
|
|
156 |
*
|
|
157 |
* @xxxx
|
|
158 |
*
|
|
159 |
*/
|
|
160 |
void CTestStepRecorderClearWindowPlay::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
161 |
TInt aPreviousState,
|
|
162 |
TInt aCurrentState,
|
|
163 |
TInt aErrorcCode)
|
|
164 |
{
|
|
165 |
iError = aErrorcCode;
|
|
166 |
|
|
167 |
iHasStartedPlaying = EFalse;
|
|
168 |
iHasFinishedPlaying = EFalse;
|
|
169 |
|
|
170 |
if (aPreviousState == CMdaAudioRecorderUtility::EOpen &&
|
|
171 |
aCurrentState == CMdaAudioRecorderUtility::EPlaying)
|
|
172 |
iHasStartedPlaying = ETrue;
|
|
173 |
|
|
174 |
if (aPreviousState == CMdaAudioRecorderUtility::EPlaying &&
|
|
175 |
aCurrentState == CMdaAudioRecorderUtility::EOpen)
|
|
176 |
iHasFinishedPlaying = ETrue;
|
|
177 |
|
|
178 |
CActiveScheduler::Stop();
|
|
179 |
}
|
|
180 |
|
|
181 |
/**
|
|
182 |
*
|
|
183 |
* Do the test step.
|
|
184 |
* Each test step must supply an implementation for DoTestStepL.
|
|
185 |
*
|
|
186 |
* @return "TVerdict"
|
|
187 |
* The result of the test step
|
|
188 |
*
|
|
189 |
* @xxxx
|
|
190 |
*
|
|
191 |
*/
|
|
192 |
TVerdict CTestStepRecorderClearWindowPlay::DoTestStepL()
|
|
193 |
{
|
|
194 |
iTestStepResult = EPass;
|
|
195 |
|
|
196 |
// no easy or obvious way to check if command successful
|
|
197 |
//if it was a pure unit test it would only matter if the parameters are passed
|
|
198 |
// correctly, and the return error code is propagated.
|
|
199 |
//duration seems to be the original duration of the clip always.
|
|
200 |
TTime start;
|
|
201 |
TTime stop;
|
|
202 |
TInt64 totalDuration = iRecorder->Duration().Int64();
|
|
203 |
TInt64 windowDuration = iMiddle.Int64() - iBeginning.Int64();
|
|
204 |
TInt64 actualDuration;
|
|
205 |
TInt64 playDurationDiff;
|
|
206 |
const TInt KQuarterSecond = 250000;
|
|
207 |
const TInt KHalfSecond = 500000;
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
iRecorder->SetPlayWindow(iBeginning, iMiddle);
|
|
212 |
start.HomeTime();
|
|
213 |
iRecorder->PlayL();
|
|
214 |
CActiveScheduler::Start();
|
|
215 |
if (iError != KErrNone || !iHasStartedPlaying)
|
|
216 |
return EInconclusive;
|
|
217 |
CActiveScheduler::Start();
|
|
218 |
if (iError != KErrNone || !iHasFinishedPlaying)
|
|
219 |
return EInconclusive;
|
|
220 |
|
|
221 |
stop.HomeTime();
|
|
222 |
actualDuration = stop.MicroSecondsFrom(start).Int64();
|
|
223 |
INFO_PRINTF3(_L("actualDuration = %lu expectedDuration = %lu"), actualDuration, windowDuration);
|
|
224 |
playDurationDiff = actualDuration - windowDuration;
|
|
225 |
if (playDurationDiff < 0)
|
|
226 |
playDurationDiff = -playDurationDiff;
|
|
227 |
//the play window is to a resolution of 1 buffer which is 8k
|
|
228 |
//8K @ 8khz sample pcm16 is 0.5seconds + a margin of error for
|
|
229 |
//test completion means more then 0.5S is required.
|
|
230 |
if (playDurationDiff > (KHalfSecond+KQuarterSecond))
|
|
231 |
{
|
|
232 |
INFO_PRINTF1(_L("Difference is too high"));
|
|
233 |
return EFail;
|
|
234 |
}
|
|
235 |
|
|
236 |
iRecorder->ClearPlayWindow();
|
|
237 |
start.HomeTime();
|
|
238 |
iRecorder->PlayL();
|
|
239 |
CActiveScheduler::Start();
|
|
240 |
if (iError != KErrNone || !iHasStartedPlaying)
|
|
241 |
return EInconclusive;
|
|
242 |
CActiveScheduler::Start();
|
|
243 |
if (iError != KErrNone || !iHasFinishedPlaying)
|
|
244 |
return EInconclusive;
|
|
245 |
|
|
246 |
|
|
247 |
stop.HomeTime();
|
|
248 |
actualDuration = stop.MicroSecondsFrom(start).Int64();
|
|
249 |
INFO_PRINTF3(_L("actualDuration = %lu expectedDuration = %lu"), actualDuration, totalDuration);
|
|
250 |
playDurationDiff = actualDuration - totalDuration;
|
|
251 |
if (playDurationDiff < 0)
|
|
252 |
playDurationDiff = -playDurationDiff;
|
|
253 |
|
|
254 |
if (playDurationDiff > KHalfSecond)
|
|
255 |
{
|
|
256 |
INFO_PRINTF1(_L("Difference is too high"));
|
|
257 |
return EFail;
|
|
258 |
}
|
|
259 |
|
|
260 |
delete iRecorder;
|
|
261 |
iRecorder = NULL;
|
|
262 |
|
|
263 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
264 |
// test steps return a result
|
|
265 |
return iTestStepResult;
|
|
266 |
}
|
|
267 |
|