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 |
// TestStepRecorderRecord.cpp
|
|
15 |
// This file contains an example Test step implementation
|
|
16 |
// This demonstrates the various functions provided
|
|
17 |
// by the CTestStep base class which are available within
|
|
18 |
// a test step
|
|
19 |
//
|
|
20 |
//
|
|
21 |
|
|
22 |
// EPOC includes
|
|
23 |
#include <e32base.h>
|
|
24 |
#include <e32test.h>
|
|
25 |
#include <e32keys.h>
|
|
26 |
#include <c32comm.h>
|
|
27 |
#include <f32file.h>
|
|
28 |
#include <etel.h>
|
|
29 |
#include <etelmm.h>
|
|
30 |
#include <testframework.h>
|
|
31 |
|
|
32 |
//#include <MdaAudioSamplePlayer.h>
|
|
33 |
#include <mdaaudiosampleeditor.h>
|
|
34 |
//#include <MdaAudioTonePlayer.h>
|
|
35 |
|
|
36 |
// Test system includes
|
|
37 |
#include <testframework.h>
|
|
38 |
|
|
39 |
// Specific includes for this test suite
|
|
40 |
#include "TestStepUnitMMFAudClient.h"
|
|
41 |
#include "TestSuiteUnitMMFAudClient.h"
|
|
42 |
|
|
43 |
// Specific includes for these test steps
|
|
44 |
#include "TestStepRecorder.h"
|
|
45 |
|
|
46 |
|
|
47 |
#include "MmfAudioController.h"
|
|
48 |
#include "mmfclientaudiorecorder.h"
|
|
49 |
|
|
50 |
_LIT(KTestRecord, "c:\\RecStop.wav");
|
|
51 |
|
|
52 |
/**
|
|
53 |
|
|
54 |
Static constructor for CTestStepRecorderRecordStop.
|
|
55 |
|
|
56 |
|
|
57 |
@return "CTestStepRecorderRecordStop*"
|
|
58 |
The constructed CTestStepRecorderRecordStop
|
|
59 |
|
|
60 |
|
|
61 |
*/
|
|
62 |
CTestStepRecorderRecordStop* CTestStepRecorderRecordStop::NewL()
|
|
63 |
{
|
|
64 |
CTestStepRecorderRecordStop* self = new(ELeave) CTestStepRecorderRecordStop;
|
|
65 |
return self;
|
|
66 |
}
|
|
67 |
|
|
68 |
/**
|
|
69 |
|
|
70 |
Test step constructor.
|
|
71 |
Each test step initialises its own name.
|
|
72 |
|
|
73 |
|
|
74 |
*/
|
|
75 |
CTestStepRecorderRecordStop::CTestStepRecorderRecordStop() : iError(0)
|
|
76 |
|
|
77 |
{
|
|
78 |
// store the name of this test case
|
|
79 |
// this is the name that is used by the script file
|
|
80 |
iTestStepName = _L("MM-MMF-ACLNT-U-0826-HP");
|
|
81 |
}
|
|
82 |
|
|
83 |
/**
|
|
84 |
|
|
85 |
Test step destructor.
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
*/
|
|
90 |
CTestStepRecorderRecordStop::~CTestStepRecorderRecordStop()
|
|
91 |
{
|
|
92 |
}
|
|
93 |
|
|
94 |
/**
|
|
95 |
|
|
96 |
Test step Preamble.
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
*/
|
|
101 |
enum TVerdict CTestStepRecorderRecordStop::DoTestStepPreambleL()
|
|
102 |
{
|
|
103 |
enum TVerdict verdict = EPass;
|
|
104 |
|
|
105 |
// this installs the scheduler
|
|
106 |
verdict = CTestStepUnitMMFAudClient::DoTestStepPreambleL();
|
|
107 |
|
|
108 |
// Printing to the console and log file
|
|
109 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0826-HP"));
|
|
110 |
INFO_PRINTF1(_L("this is a test of the fix for DEF 42395"));
|
|
111 |
|
|
112 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
113 |
verdict = EInconclusive;
|
|
114 |
|
|
115 |
iTimer = CTestStepRecorderRecordStopTimer::NewL(this, iRecorder);
|
|
116 |
|
|
117 |
// Delete the output file.
|
|
118 |
User::LeaveIfError(iFs.Connect());
|
|
119 |
iFileMan = CFileMan::NewL(iFs);
|
|
120 |
iFileMan->Delete(KTestRecord);
|
|
121 |
|
|
122 |
|
|
123 |
iClipFileName = new TMdaFileClipLocation(KTestRecord);
|
|
124 |
|
|
125 |
// open a new file to record to.
|
|
126 |
iStopping = ETrue;
|
|
127 |
iRecorder->OpenL(iClipFileName, &iClipFormat, &iClipCodec);
|
|
128 |
CActiveScheduler::Start();
|
|
129 |
if (iError)
|
|
130 |
{
|
|
131 |
INFO_PRINTF2(_L("Open returned %d"), iError);
|
|
132 |
return EFail;
|
|
133 |
}
|
|
134 |
|
|
135 |
if (iError != KErrNone || iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
136 |
return EInconclusive;
|
|
137 |
|
|
138 |
iRecorder->SetGain(iRecorder->MaxGain()/2);
|
|
139 |
iBeginning = new TTimeIntervalMicroSeconds(0);
|
|
140 |
iRecorder->SetPosition(*iBeginning);
|
|
141 |
iRecorder->CropL();
|
|
142 |
return verdict;
|
|
143 |
}
|
|
144 |
|
|
145 |
/**
|
|
146 |
|
|
147 |
Test step Postamble.
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
*/
|
|
152 |
enum TVerdict CTestStepRecorderRecordStop::DoTestStepPostambleL()
|
|
153 |
{
|
|
154 |
// Delete the output file.
|
|
155 |
iFileMan->Delete(KTestRecord);
|
|
156 |
iFs.Close();
|
|
157 |
|
|
158 |
delete iFileMan;
|
|
159 |
iFileMan = NULL;
|
|
160 |
|
|
161 |
delete iRecorder;
|
|
162 |
iRecorder = NULL;
|
|
163 |
|
|
164 |
delete iTimer;
|
|
165 |
iTimer = NULL;
|
|
166 |
|
|
167 |
delete iBeginning;
|
|
168 |
iBeginning = NULL;
|
|
169 |
|
|
170 |
// Destroy the scheduler.
|
|
171 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
172 |
}
|
|
173 |
|
|
174 |
/**
|
|
175 |
|
|
176 |
Callback Handle.
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
*/
|
|
181 |
void CTestStepRecorderRecordStop::MoscoStateChangeEvent(CBase* /* aObject */, TInt /* aPreviousState */, TInt /* aCurrentState */, TInt aErrorCode)
|
|
182 |
{
|
|
183 |
iError = aErrorCode;
|
|
184 |
|
|
185 |
if (iStopping || (iError != KErrNone))
|
|
186 |
CActiveScheduler::Stop();
|
|
187 |
else
|
|
188 |
{
|
|
189 |
if (iDelay>2400000)
|
|
190 |
{
|
|
191 |
iRecorder->Stop();
|
|
192 |
CActiveScheduler::Stop();
|
|
193 |
}
|
|
194 |
else if (iDelay == 0)
|
|
195 |
{
|
|
196 |
iRecorder->Stop();
|
|
197 |
|
|
198 |
IncrementAndLogDelay();
|
|
199 |
iRecorder->RecordL();
|
|
200 |
}
|
|
201 |
else
|
|
202 |
iTimer->After(iDelay);
|
|
203 |
}
|
|
204 |
}
|
|
205 |
|
|
206 |
|
|
207 |
CTestStepRecorderRecordStopTimer* CTestStepRecorderRecordStopTimer::NewL(CTestStepRecorderRecordStop* aTestStep, CMMFMdaAudioRecorderUtility* aRecorder)
|
|
208 |
{
|
|
209 |
CTestStepRecorderRecordStopTimer* self = new(ELeave) CTestStepRecorderRecordStopTimer(aTestStep, aRecorder);
|
|
210 |
self->ConstructL();
|
|
211 |
return self;
|
|
212 |
}
|
|
213 |
|
|
214 |
CTestStepRecorderRecordStopTimer::CTestStepRecorderRecordStopTimer(CTestStepRecorderRecordStop* aTestStep, CMMFMdaAudioRecorderUtility* aRecorder)
|
|
215 |
: CTimer(0), iTestStep(aTestStep), iRecorder(aRecorder)
|
|
216 |
{
|
|
217 |
CActiveScheduler::Add(this);
|
|
218 |
}
|
|
219 |
|
|
220 |
void CTestStepRecorderRecordStopTimer::RunL()
|
|
221 |
{
|
|
222 |
iRecorder->Stop();
|
|
223 |
|
|
224 |
iTestStep->IncrementAndLogDelay();
|
|
225 |
iRecorder->RecordL();
|
|
226 |
}
|
|
227 |
|
|
228 |
// This can return a TBool hasPlayed to prove that it has played
|
|
229 |
// but the EPlaying state seems to get preserved for some reason...
|
|
230 |
void CTestStepRecorderRecordStop::RecordAndStartSchedulerL()
|
|
231 |
{
|
|
232 |
INFO_PRINTF2(_L("iDelay = %d"), iDelay);
|
|
233 |
iRecorder->RecordL();
|
|
234 |
|
|
235 |
iStopping = EFalse;
|
|
236 |
CActiveScheduler::Start();
|
|
237 |
}
|
|
238 |
|
|
239 |
/**
|
|
240 |
|
|
241 |
Do the test step.
|
|
242 |
Each test step must supply an implementation for DoTestStepL.
|
|
243 |
|
|
244 |
@return "TVerdict"
|
|
245 |
The result of the test step
|
|
246 |
|
|
247 |
|
|
248 |
|
|
249 |
*/
|
|
250 |
TVerdict CTestStepRecorderRecordStop::DoTestStepL()
|
|
251 |
{
|
|
252 |
iTestStepResult = EPass;
|
|
253 |
TRAPD(err, RecordAndStartSchedulerL());
|
|
254 |
|
|
255 |
// check result
|
|
256 |
if ((iError != KErrNone) || (err != KErrNone) || (iRecorder->State() != CMdaAudioRecorderUtility::EOpen))
|
|
257 |
{
|
|
258 |
INFO_PRINTF4(_L("Unexpected result (%d, %d, %d)"), iError, err, iRecorder->State());
|
|
259 |
iTestStepResult = EFail;
|
|
260 |
}
|
|
261 |
|
|
262 |
delete iRecorder;
|
|
263 |
iRecorder = NULL;
|
|
264 |
|
|
265 |
return iTestStepResult;
|
|
266 |
}
|
|
267 |
|
|
268 |
void CTestStepRecorderRecordStop::IncrementAndLogDelay()
|
|
269 |
{
|
|
270 |
if (iDelay<100)
|
|
271 |
iDelay += 10;
|
|
272 |
else if(iDelay<1000)
|
|
273 |
iDelay += 100;
|
|
274 |
else if (iDelay<10000)
|
|
275 |
iDelay += 1000;
|
|
276 |
else if (iDelay<100000)
|
|
277 |
iDelay += 10000;
|
|
278 |
else
|
|
279 |
iDelay += 100000;
|
|
280 |
|
|
281 |
INFO_PRINTF2(_L("iDelay = %d"), iDelay);
|
|
282 |
}
|
|
283 |
|