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 CTestStepRecorderAllocFailNew.
|
|
57 |
*
|
|
58 |
*
|
|
59 |
* @return "CTestStepRecorderAllocFailNew*"
|
|
60 |
* The constructed CTestStepRecorderAllocFailNew
|
|
61 |
*
|
|
62 |
* @xxxx
|
|
63 |
*
|
|
64 |
*/
|
|
65 |
CTestStepRecorderAllocFailNew* CTestStepRecorderAllocFailNew::NewL()
|
|
66 |
{
|
|
67 |
CTestStepRecorderAllocFailNew* self = new(ELeave) CTestStepRecorderAllocFailNew;
|
|
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 |
CTestStepRecorderAllocFailNew::CTestStepRecorderAllocFailNew()
|
|
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-0300-CP");
|
|
84 |
}
|
|
85 |
|
|
86 |
/**
|
|
87 |
*
|
|
88 |
* Test step destructor.
|
|
89 |
*
|
|
90 |
* @xxxx
|
|
91 |
*
|
|
92 |
*/
|
|
93 |
CTestStepRecorderAllocFailNew::~CTestStepRecorderAllocFailNew()
|
|
94 |
{
|
|
95 |
}
|
|
96 |
|
|
97 |
void CTestStepRecorderAllocFailNew::MoscoStateChangeEvent(CBase* /*aObject*/,
|
|
98 |
TInt /*aPreviousState*/,
|
|
99 |
TInt /*aCurrentState*/,
|
|
100 |
TInt aErrorcCode)
|
|
101 |
{
|
|
102 |
iError = aErrorcCode;
|
|
103 |
CActiveScheduler::Stop();
|
|
104 |
}
|
|
105 |
|
|
106 |
/**
|
|
107 |
*
|
|
108 |
* Do the test step.
|
|
109 |
* Each test step must supply an implementation for DoTestStepL.
|
|
110 |
*
|
|
111 |
* @return "TVerdict"
|
|
112 |
* The result of the test step
|
|
113 |
*
|
|
114 |
* @xxxx
|
|
115 |
*
|
|
116 |
*/
|
|
117 |
TVerdict CTestStepRecorderAllocFailNew::DoTestStepL()
|
|
118 |
{
|
|
119 |
iTestStepResult = EPass;
|
|
120 |
TInt err = KErrNone;
|
|
121 |
|
|
122 |
// Printing to the console and log file
|
|
123 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0300-CP"));
|
|
124 |
INFO_PRINTF1(_L("this is Alloc Failure test of CMdaAudioRecordererUtility::NewL() "));
|
|
125 |
|
|
126 |
__MM_HEAP_MARK;
|
|
127 |
TRAP( err, (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) );
|
|
128 |
delete iRecorder;
|
|
129 |
iRecorder = NULL;
|
|
130 |
__MM_HEAP_MARKEND;
|
|
131 |
|
|
132 |
|
|
133 |
if (err != KErrNone)
|
|
134 |
return EFail;
|
|
135 |
|
|
136 |
TInt failCount = 1;
|
|
137 |
TBool completed = EFalse;
|
|
138 |
TBool badResult = EFalse;
|
|
139 |
TBool reachedEnd = EFalse; // Note: declare outside loop to help with debugging
|
|
140 |
for(;;)
|
|
141 |
{
|
|
142 |
__UHEAP_SETFAIL(RHeap::EFailNext ,failCount);
|
|
143 |
//__MM_HEAP_MARK;
|
|
144 |
|
|
145 |
TRAP( err, (iRecorder = CMMFMdaAudioRecorderUtility::NewL(*this)) );
|
|
146 |
|
|
147 |
completed = EFalse;
|
|
148 |
if (err == KErrNone && iError == KErrNone)
|
|
149 |
{
|
|
150 |
TAny *testAlloc = User::Alloc(1); // when this fails, we passed through all allocs within test
|
|
151 |
if (testAlloc==NULL)
|
|
152 |
{
|
|
153 |
reachedEnd = ETrue;
|
|
154 |
failCount--; // -= 1;
|
|
155 |
}
|
|
156 |
else
|
|
157 |
User::Free(testAlloc);
|
|
158 |
// see if valid result and break if wrong - might be premature result
|
|
159 |
if (iRecorder == NULL ||
|
|
160 |
iError != KErrNone ||
|
|
161 |
iRecorder->State() != CMdaAudioRecorderUtility::ENotReady )
|
|
162 |
badResult = ETrue;
|
|
163 |
else
|
|
164 |
{
|
|
165 |
if (iRecorder != NULL)
|
|
166 |
{
|
|
167 |
delete iRecorder;
|
|
168 |
iRecorder = NULL;
|
|
169 |
}
|
|
170 |
}
|
|
171 |
completed = reachedEnd || badResult;
|
|
172 |
}
|
|
173 |
else if (err != KErrNoMemory || (err==KErrNone && iError != KErrNoMemory)) // bad error code
|
|
174 |
completed = ETrue;
|
|
175 |
|
|
176 |
//__MM_HEAP_MARKEND;
|
|
177 |
__UHEAP_SETFAIL(RHeap::ENone ,0);
|
|
178 |
|
|
179 |
if (completed)
|
|
180 |
break; // exit loop
|
|
181 |
|
|
182 |
failCount++;
|
|
183 |
}
|
|
184 |
|
|
185 |
//failCount -= 1; // Failcount of 1 equates to 0 successful allocs, etc.
|
|
186 |
|
|
187 |
if (err != KErrNone || badResult)
|
|
188 |
{
|
|
189 |
if (badResult)
|
|
190 |
INFO_PRINTF2(_L(" Bad result with %d memory allocations tested"), failCount);
|
|
191 |
else
|
|
192 |
INFO_PRINTF3(_L(" Error(%d) with %d memory allocations tested"), err, failCount);
|
|
193 |
iTestStepResult = EFail;
|
|
194 |
}
|
|
195 |
else
|
|
196 |
{
|
|
197 |
INFO_PRINTF2(_L(" Completed OK with %d memory allocations tested"), failCount);
|
|
198 |
iTestStepResult = EPass;
|
|
199 |
}
|
|
200 |
|
|
201 |
if (iRecorder != NULL)
|
|
202 |
{
|
|
203 |
delete iRecorder;
|
|
204 |
iRecorder = NULL;
|
|
205 |
}
|
|
206 |
|
|
207 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
208 |
// test steps return a result
|
|
209 |
return iTestStepResult;
|
|
210 |
}
|
|
211 |
|