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 CTestStepRecorderState.
|
|
57 |
*
|
|
58 |
*
|
|
59 |
* @return "CTestStepRecorderState*"
|
|
60 |
* The constructed CTestStepRecorderState
|
|
61 |
*
|
|
62 |
* @xxxx
|
|
63 |
*
|
|
64 |
*/
|
|
65 |
CTestStepRecorderState* CTestStepRecorderState::NewL()
|
|
66 |
{
|
|
67 |
CTestStepRecorderState* self = new(ELeave) CTestStepRecorderState;
|
|
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 |
CTestStepRecorderState::CTestStepRecorderState() : iError(KErrNone), iHasRecorded(EFalse), iHasPlayed(EFalse)
|
|
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-0254-HP");
|
|
84 |
}
|
|
85 |
|
|
86 |
/**
|
|
87 |
*
|
|
88 |
* Test step destructor.
|
|
89 |
*
|
|
90 |
* @xxxx
|
|
91 |
*
|
|
92 |
*/
|
|
93 |
CTestStepRecorderState::~CTestStepRecorderState()
|
|
94 |
{
|
|
95 |
}
|
|
96 |
|
|
97 |
/**
|
|
98 |
*
|
|
99 |
* Test step Preamble.
|
|
100 |
*
|
|
101 |
* @xxxx
|
|
102 |
*
|
|
103 |
*/
|
|
104 |
enum TVerdict CTestStepRecorderState::DoTestStepPreambleL(void)
|
|
105 |
{
|
|
106 |
enum TVerdict verdict = EPass;
|
|
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-0254-HP"));
|
|
112 |
INFO_PRINTF1(_L("this is a test of CMdaAudioRecorderUtility::State()"));
|
|
113 |
|
|
114 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioFNameToRecord"), iFileName))
|
|
115 |
{
|
|
116 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
117 |
return EInconclusive;
|
|
118 |
}
|
|
119 |
|
|
120 |
return verdict;
|
|
121 |
|
|
122 |
}
|
|
123 |
|
|
124 |
/**
|
|
125 |
*
|
|
126 |
* Test step Postamble.
|
|
127 |
*
|
|
128 |
* @xxxx
|
|
129 |
*
|
|
130 |
*/
|
|
131 |
enum TVerdict CTestStepRecorderState::DoTestStepPostambleL(void)
|
|
132 |
{
|
|
133 |
//delete the output file
|
|
134 |
CFileMan* fileMan;
|
|
135 |
iFs.Connect();
|
|
136 |
fileMan = CFileMan::NewL(iFs);
|
|
137 |
fileMan->Delete(iFileName);
|
|
138 |
iFs.Close();
|
|
139 |
delete fileMan;
|
|
140 |
fileMan = NULL;
|
|
141 |
|
|
142 |
delete iRecorder;
|
|
143 |
iRecorder = NULL;
|
|
144 |
//[ Destroy the scheduler ]
|
|
145 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
146 |
}
|
|
147 |
|
|
148 |
/**
|
|
149 |
*
|
|
150 |
* Callback Handle.
|
|
151 |
*
|
|
152 |
* @xxxx
|
|
153 |
*
|
|
154 |
*/
|
|
155 |
void CTestStepRecorderState::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
156 |
TInt /*aPreviousState*/,
|
|
157 |
TInt aCurrentState,
|
|
158 |
TInt aErrorcCode)
|
|
159 |
{
|
|
160 |
iError = aErrorcCode;
|
|
161 |
if (iRecorder->State() == CMdaAudioRecorderUtility::EPlaying &&
|
|
162 |
aCurrentState == CMdaAudioRecorderUtility::EPlaying)
|
|
163 |
iHasPlayed = ETrue;
|
|
164 |
|
|
165 |
CActiveScheduler::Stop();
|
|
166 |
}
|
|
167 |
|
|
168 |
// this can return a TBool hasPlayed to prove that it has played
|
|
169 |
// but the EPlaying state seems to get preserved for some reason...
|
|
170 |
void CTestStepRecorderState::RecordAndStartSchedulerL()
|
|
171 |
{
|
|
172 |
iRecorder->RecordL();
|
|
173 |
CActiveScheduler::Start();
|
|
174 |
// record 2 secs, ...probably silence
|
|
175 |
User::After(2000000);
|
|
176 |
if (iRecorder->State() == CMdaAudioRecorderUtility::ERecording)
|
|
177 |
iHasRecorded = ETrue;
|
|
178 |
iRecorder->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 CTestStepRecorderState::DoTestStepL()
|
|
193 |
{
|
|
194 |
iTestStepResult = EPass;
|
|
195 |
TInt err = KErrNone;
|
|
196 |
|
|
197 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
198 |
return EInconclusive;
|
|
199 |
|
|
200 |
if (iRecorder->State() != CMdaAudioRecorderUtility::ENotReady)
|
|
201 |
return EFail;
|
|
202 |
|
|
203 |
// open an existing file to record and crop all its contents if any
|
|
204 |
TRAP( err, iRecorder->OpenFileL(iFileName) );
|
|
205 |
if (err != KErrNone )
|
|
206 |
return EInconclusive;
|
|
207 |
|
|
208 |
CActiveScheduler::Start();
|
|
209 |
if (iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
210 |
return EFail;
|
|
211 |
|
|
212 |
iRecorder->SetGain(iRecorder->MaxGain()/2);
|
|
213 |
iRecorder->SetPosition(TTimeIntervalMicroSeconds(0));
|
|
214 |
iRecorder->CropL();
|
|
215 |
|
|
216 |
if ( iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
217 |
return EFail;
|
|
218 |
|
|
219 |
TRAP( err, RecordAndStartSchedulerL() );
|
|
220 |
|
|
221 |
if (err != KErrNone ||
|
|
222 |
!iHasRecorded ||
|
|
223 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
224 |
return EFail;
|
|
225 |
|
|
226 |
iRecorder->SetPosition(TTimeIntervalMicroSeconds(0));
|
|
227 |
iRecorder->PlayL();
|
|
228 |
CActiveScheduler::Start();
|
|
229 |
User::After(1000000);
|
|
230 |
if (iError != KErrNone ||
|
|
231 |
!iHasPlayed)
|
|
232 |
return EFail;
|
|
233 |
|
|
234 |
iRecorder->Stop();
|
|
235 |
if (iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
236 |
return EFail;
|
|
237 |
|
|
238 |
iRecorder->Close();
|
|
239 |
if (iRecorder == NULL ||
|
|
240 |
iRecorder->State() != CMdaAudioRecorderUtility::ENotReady)
|
|
241 |
return EFail;
|
|
242 |
|
|
243 |
delete iRecorder;
|
|
244 |
iRecorder = NULL;
|
|
245 |
|
|
246 |
|
|
247 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
248 |
// test steps return a result
|
|
249 |
return iTestStepResult;
|
|
250 |
}
|
|
251 |
|