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 CTestStepRecorderAllocFailOpen.
|
|
57 |
*
|
|
58 |
*
|
|
59 |
* @return "CTestStepRecorderAllocFailOpen*"
|
|
60 |
* The constructed CTestStepRecorderAllocFailOpen
|
|
61 |
*
|
|
62 |
* @xxxx
|
|
63 |
*
|
|
64 |
*/
|
|
65 |
CTestStepRecorderAllocFailOpen* CTestStepRecorderAllocFailOpen::NewL()
|
|
66 |
{
|
|
67 |
CTestStepRecorderAllocFailOpen* self = new(ELeave) CTestStepRecorderAllocFailOpen;
|
|
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 |
CTestStepRecorderAllocFailOpen::CTestStepRecorderAllocFailOpen()
|
|
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-0303-CP");
|
|
84 |
}
|
|
85 |
|
|
86 |
/**
|
|
87 |
*
|
|
88 |
* Test step destructor.
|
|
89 |
*
|
|
90 |
* @xxxx
|
|
91 |
*
|
|
92 |
*/
|
|
93 |
CTestStepRecorderAllocFailOpen::~CTestStepRecorderAllocFailOpen()
|
|
94 |
{
|
|
95 |
}
|
|
96 |
|
|
97 |
/**
|
|
98 |
*
|
|
99 |
* Test step Preamble.
|
|
100 |
*
|
|
101 |
* @xxxx
|
|
102 |
*
|
|
103 |
*/
|
|
104 |
enum TVerdict CTestStepRecorderAllocFailOpen::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-0303-CP"));
|
|
112 |
INFO_PRINTF1(_L("this is Alloc failure test of CMdaAudioRecorderUtility::OpenDesL"));
|
|
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 |
// create the Recorder utility
|
|
121 |
if ( (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) == NULL )
|
|
122 |
verdict = EInconclusive;
|
|
123 |
|
|
124 |
iClipLocation = new TMdaFileClipLocation(iFileName);
|
|
125 |
iFormat = new TMdaWavClipFormat();
|
|
126 |
|
|
127 |
return verdict;
|
|
128 |
|
|
129 |
}
|
|
130 |
|
|
131 |
/**
|
|
132 |
*
|
|
133 |
* Test step Postamble.
|
|
134 |
*
|
|
135 |
* @xxxx
|
|
136 |
*
|
|
137 |
*/
|
|
138 |
enum TVerdict CTestStepRecorderAllocFailOpen::DoTestStepPostambleL(void)
|
|
139 |
{
|
|
140 |
delete iRecorder;
|
|
141 |
iRecorder = NULL;
|
|
142 |
//[ Destroy the scheduler ]
|
|
143 |
return CTestStepUnitMMFAudClient::DoTestStepPostambleL();
|
|
144 |
}
|
|
145 |
|
|
146 |
/**
|
|
147 |
*
|
|
148 |
* Callback Handle.
|
|
149 |
*
|
|
150 |
* @xxxx
|
|
151 |
*
|
|
152 |
*/
|
|
153 |
void CTestStepRecorderAllocFailOpen::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
154 |
TInt /*aPreviousState*/,
|
|
155 |
TInt /*aCurrentState*/,
|
|
156 |
TInt aErrorcCode)
|
|
157 |
{
|
|
158 |
iError = aErrorcCode;
|
|
159 |
CActiveScheduler::Stop();
|
|
160 |
}
|
|
161 |
|
|
162 |
void CTestStepRecorderAllocFailOpen::OpenAndStartSchedulerL()
|
|
163 |
{
|
|
164 |
iRecorder->OpenL( iClipLocation, iFormat );
|
|
165 |
CActiveScheduler::Start();
|
|
166 |
User::LeaveIfError(iError);
|
|
167 |
}
|
|
168 |
|
|
169 |
/**
|
|
170 |
*
|
|
171 |
* Do the test step.
|
|
172 |
* Each test step must supply an implementation for DoTestStepL.
|
|
173 |
*
|
|
174 |
* @return "TVerdict"
|
|
175 |
* The result of the test step
|
|
176 |
*
|
|
177 |
* @xxxx
|
|
178 |
*
|
|
179 |
*/
|
|
180 |
TVerdict CTestStepRecorderAllocFailOpen::DoTestStepL()
|
|
181 |
{
|
|
182 |
iTestStepResult = EPass;
|
|
183 |
TInt err = KErrNone;
|
|
184 |
|
|
185 |
TInt failCount = 1;
|
|
186 |
TBool completed = EFalse;
|
|
187 |
TBool badResult = EFalse;
|
|
188 |
TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
|
|
189 |
for(;;)
|
|
190 |
{
|
|
191 |
__UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
|
|
192 |
//__MM_HEAP_MARK;
|
|
193 |
|
|
194 |
TRAP( err, OpenAndStartSchedulerL() );
|
|
195 |
|
|
196 |
completed = EFalse;
|
|
197 |
if ((err == KErrNone) && (iError == KErrNone))
|
|
198 |
{
|
|
199 |
TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
|
|
200 |
if (testAlloc==NULL)
|
|
201 |
{
|
|
202 |
reachedEnd = ETrue;
|
|
203 |
failCount--; // -= 1;
|
|
204 |
}
|
|
205 |
else
|
|
206 |
{
|
|
207 |
User::Free(testAlloc);
|
|
208 |
}
|
|
209 |
|
|
210 |
// see if valid result and break if wrong - might be premature result
|
|
211 |
INFO_PRINTF2(_L("state CMdaAudioRecorderUtility %d"), iRecorder->State() );
|
|
212 |
if (iRecorder == NULL ||
|
|
213 |
iError != KErrNone ||
|
|
214 |
iRecorder->State() != CMdaAudioRecorderUtility::EOpen)
|
|
215 |
badResult = ETrue;
|
|
216 |
|
|
217 |
if(iRecorder)
|
|
218 |
iRecorder->Close();
|
|
219 |
|
|
220 |
completed = reachedEnd || badResult;
|
|
221 |
}
|
|
222 |
else if (((err != KErrNone) && (err != KErrNoMemory)) ||
|
|
223 |
((iError != KErrNone) && (iError != KErrNoMemory))) // bad error code
|
|
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 |
|