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 "TestStepRecorderAllocFail.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 CTestStepRecorderAllocFailPlay.
|
|
57 |
*
|
|
58 |
*
|
|
59 |
* @return "CTestStepRecorderAllocFailPlay*"
|
|
60 |
* The constructed CTestStepRecorderAllocFailPlay
|
|
61 |
*
|
|
62 |
* @xxxx
|
|
63 |
*
|
|
64 |
*/
|
|
65 |
CTestStepRecorderAllocFailPlay* CTestStepRecorderAllocFailPlay::NewL()
|
|
66 |
{
|
|
67 |
CTestStepRecorderAllocFailPlay* self = new(ELeave) CTestStepRecorderAllocFailPlay;
|
|
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 |
CTestStepRecorderAllocFailPlay::CTestStepRecorderAllocFailPlay()
|
|
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-0305-CP");
|
|
84 |
}
|
|
85 |
|
|
86 |
/**
|
|
87 |
*
|
|
88 |
* Test step destructor.
|
|
89 |
*
|
|
90 |
* @xxxx
|
|
91 |
*
|
|
92 |
*/
|
|
93 |
CTestStepRecorderAllocFailPlay::~CTestStepRecorderAllocFailPlay()
|
|
94 |
{
|
|
95 |
}
|
|
96 |
|
|
97 |
/**
|
|
98 |
*
|
|
99 |
* Test step Preamble.
|
|
100 |
*
|
|
101 |
* @xxxx
|
|
102 |
*
|
|
103 |
*/
|
|
104 |
enum TVerdict CTestStepRecorderAllocFailPlay::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-0305-CP"));
|
|
112 |
INFO_PRINTF1(_L("this is Alloc failure test of CMdaAudioRecorderUtility::PlayL"));
|
|
113 |
|
|
114 |
if(!GetStringFromConfig(_L("SectionOne"), _L("AudioPlayFName7"), iFileName))
|
|
115 |
{
|
|
116 |
//INFO_PRINTF2(_L("file name %s not found..."), fileptr);
|
|
117 |
return EInconclusive;
|
|
118 |
}
|
|
119 |
|
|
120 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
121 |
verdict = EInconclusive;
|
|
122 |
|
|
123 |
iRecorder->OpenFileL(iFileName);
|
|
124 |
CActiveScheduler::Start();
|
|
125 |
|
|
126 |
if ( iError != KErrNone ||
|
|
127 |
iRecorder->State() != 1) // EOpened
|
|
128 |
verdict = EInconclusive;
|
|
129 |
|
|
130 |
return verdict;
|
|
131 |
|
|
132 |
}
|
|
133 |
|
|
134 |
/**
|
|
135 |
*
|
|
136 |
* Test step Postamble.
|
|
137 |
*
|
|
138 |
* @xxxx
|
|
139 |
*
|
|
140 |
*/
|
|
141 |
enum TVerdict CTestStepRecorderAllocFailPlay::DoTestStepPostambleL(void)
|
|
142 |
{
|
|
143 |
delete iRecorder;
|
|
144 |
iRecorder = NULL;
|
|
145 |
//[ Destroy the scheduler ]
|
|
146 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
147 |
}
|
|
148 |
|
|
149 |
/**
|
|
150 |
*
|
|
151 |
* Callback Handle.
|
|
152 |
*
|
|
153 |
* @xxxx
|
|
154 |
*
|
|
155 |
*/
|
|
156 |
void CTestStepRecorderAllocFailPlay::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
157 |
TInt /*aPreviousState*/,
|
|
158 |
TInt /*aCurrentState*/,
|
|
159 |
TInt aErrorcCode)
|
|
160 |
{
|
|
161 |
iError = aErrorcCode;
|
|
162 |
CActiveScheduler::Stop();
|
|
163 |
}
|
|
164 |
|
|
165 |
// this can return a TBool hasPlayed to prove that it has played
|
|
166 |
// but the EPlaying state seems to get preserved for some reason...
|
|
167 |
void CTestStepRecorderAllocFailPlay::PlayAndStartSchedulerL()
|
|
168 |
{
|
|
169 |
iRecorder->PlayL();
|
|
170 |
CActiveScheduler::Start(); // open->play
|
|
171 |
User::LeaveIfError(iError);
|
|
172 |
CActiveScheduler::Start(); // play->open
|
|
173 |
//INFO_PRINTF2(_L("playing state: %d "), iRecorder->State() );
|
|
174 |
User::LeaveIfError(iError);
|
|
175 |
}
|
|
176 |
|
|
177 |
/**
|
|
178 |
*
|
|
179 |
* Do the test step.
|
|
180 |
* Each test step must supply an implementation for DoTestStepL.
|
|
181 |
*
|
|
182 |
* @return "TVerdict"
|
|
183 |
* The result of the test step
|
|
184 |
*
|
|
185 |
* @xxxx
|
|
186 |
*
|
|
187 |
*/
|
|
188 |
TVerdict CTestStepRecorderAllocFailPlay::DoTestStepL()
|
|
189 |
{
|
|
190 |
iTestStepResult = EPass;
|
|
191 |
TInt err = KErrNone;
|
|
192 |
|
|
193 |
TInt failCount = 1;
|
|
194 |
TBool completed = EFalse;
|
|
195 |
TBool badResult = EFalse;
|
|
196 |
TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
|
|
197 |
for(;;)
|
|
198 |
{
|
|
199 |
__UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
|
|
200 |
//__MM_HEAP_MARK;
|
|
201 |
|
|
202 |
TRAP( err, PlayAndStartSchedulerL() );
|
|
203 |
|
|
204 |
completed = EFalse;
|
|
205 |
if (err == KErrNone)
|
|
206 |
{
|
|
207 |
TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
|
|
208 |
if (testAlloc==NULL)
|
|
209 |
{
|
|
210 |
reachedEnd = ETrue;
|
|
211 |
failCount--; // -= 1;
|
|
212 |
}
|
|
213 |
else
|
|
214 |
User::Free(testAlloc);
|
|
215 |
// see if valid result and break if wrong - might be premature result
|
|
216 |
//INFO_PRINTF2(_L("state CMdaAudioRecorderUtility %d"), static_cast<CMMFMdaAudioRecorderUtility*>(iRecorder)->iState);
|
|
217 |
if (iError != KErrNone ||
|
|
218 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
219 |
badResult = ETrue;
|
|
220 |
|
|
221 |
completed = reachedEnd || badResult;
|
|
222 |
}
|
|
223 |
else if (err != KErrNoMemory)
|
|
224 |
completed = ETrue;
|
|
225 |
|
|
226 |
//__MM_HEAP_MARKEND;
|
|
227 |
__UHEAP_SETFAIL(RHeap::ENone ,0);
|
|
228 |
|
|
229 |
if (completed)
|
|
230 |
break; // exit loop
|
|
231 |
|
|
232 |
failCount++;
|
|
233 |
}
|
|
234 |
|
|
235 |
//failCount -= 1; // Failcount of 1 equates to 0 successful allocs, etc.
|
|
236 |
|
|
237 |
if (err != KErrNone || badResult)
|
|
238 |
{
|
|
239 |
if (badResult)
|
|
240 |
INFO_PRINTF2(_L(" Bad result with %d memory allocations tested"), failCount);
|
|
241 |
else
|
|
242 |
INFO_PRINTF3(_L(" Error(%d) with %d memory allocations tested"), err, failCount);
|
|
243 |
iTestStepResult = EFail;
|
|
244 |
}
|
|
245 |
else
|
|
246 |
{
|
|
247 |
INFO_PRINTF2(_L(" Completed OK with %d memory allocations tested"), failCount);
|
|
248 |
iTestStepResult = EPass;
|
|
249 |
}
|
|
250 |
|
|
251 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
252 |
// test steps return a result
|
|
253 |
return iTestStepResult;
|
|
254 |
}
|
|
255 |
|