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 <mdaaudiotoneplayer.h>
|
|
32 |
|
|
33 |
// Test system includes
|
|
34 |
#include <testframework.h>
|
|
35 |
|
|
36 |
// Specific includes for this test suite
|
|
37 |
#include "TestStepUnitMMFAudClient.h"
|
|
38 |
#include "TestSuiteUnitMMFAudClient.h"
|
|
39 |
|
|
40 |
// Specific includes for these test steps
|
|
41 |
#include "TestStepTone.h"
|
|
42 |
#include "mmfclienttoneplayer.h"
|
|
43 |
|
|
44 |
|
|
45 |
// --------------------------------------------
|
|
46 |
|
|
47 |
/**
|
|
48 |
*
|
|
49 |
* Static constructor for CTestStepToneAllocFailNew.
|
|
50 |
*
|
|
51 |
*
|
|
52 |
* @return "CTestStepToneAllocFailNew*"
|
|
53 |
* The constructed CTestStepToneAllocFailNew
|
|
54 |
*
|
|
55 |
* @xxxx
|
|
56 |
*
|
|
57 |
*/
|
|
58 |
CTestStepToneAllocFailNew* CTestStepToneAllocFailNew::NewL()
|
|
59 |
{
|
|
60 |
CTestStepToneAllocFailNew* self = new(ELeave) CTestStepToneAllocFailNew;
|
|
61 |
return self;
|
|
62 |
}
|
|
63 |
|
|
64 |
/**
|
|
65 |
*
|
|
66 |
* Test step constructor.
|
|
67 |
* Each test step initialises its own name.
|
|
68 |
*
|
|
69 |
* @xxxx
|
|
70 |
*
|
|
71 |
*/
|
|
72 |
CTestStepToneAllocFailNew::CTestStepToneAllocFailNew() : iError(KErrNone)
|
|
73 |
{
|
|
74 |
// store the name of this test case
|
|
75 |
// this is the name that is used by the script file
|
|
76 |
iTestStepName = _L("MM-MMF-ACLNT-U-0400-CP");
|
|
77 |
}
|
|
78 |
|
|
79 |
/**
|
|
80 |
*
|
|
81 |
* Test step destructor.
|
|
82 |
*
|
|
83 |
* @xxxx
|
|
84 |
*
|
|
85 |
*/
|
|
86 |
CTestStepToneAllocFailNew::~CTestStepToneAllocFailNew()
|
|
87 |
{
|
|
88 |
}
|
|
89 |
|
|
90 |
void CTestStepToneAllocFailNew::MatoPrepareComplete(TInt aError)
|
|
91 |
{
|
|
92 |
iError = aError;
|
|
93 |
CActiveScheduler::Stop();
|
|
94 |
}
|
|
95 |
|
|
96 |
void CTestStepToneAllocFailNew::MatoPlayComplete(TInt aError)
|
|
97 |
{
|
|
98 |
iError = aError;
|
|
99 |
CActiveScheduler::Stop();
|
|
100 |
}
|
|
101 |
|
|
102 |
/**
|
|
103 |
*
|
|
104 |
* Do the test step.
|
|
105 |
* Each test step must supply an implementation for DoTestStepL.
|
|
106 |
*
|
|
107 |
* @return "TVerdict"
|
|
108 |
* The result of the test step
|
|
109 |
*
|
|
110 |
* @xxxx
|
|
111 |
*
|
|
112 |
*/
|
|
113 |
TVerdict CTestStepToneAllocFailNew::DoTestStepL()
|
|
114 |
{
|
|
115 |
iTestStepResult = EPass;
|
|
116 |
TInt err = KErrNone;
|
|
117 |
|
|
118 |
// Printing to the console and log file
|
|
119 |
INFO_PRINTF1(_L("MM-MMF-ACLNT-U-0400-CP"));
|
|
120 |
INFO_PRINTF1(_L("this is Alloc Failure test of CMMFMdaAudioToneUtility::NewL() "));
|
|
121 |
|
|
122 |
__MM_HEAP_MARK;
|
|
123 |
TRAP( err, (iTone = CMMFMdaAudioToneUtility::NewL(*this)) );
|
|
124 |
if (iTone == NULL ||
|
|
125 |
err != KErrNone ||
|
|
126 |
iTone->State() != EMdaAudioToneUtilityNotReady )
|
|
127 |
return EFail;
|
|
128 |
delete iTone;
|
|
129 |
iTone = NULL;
|
|
130 |
__MM_HEAP_MARKEND;
|
|
131 |
|
|
132 |
// fail it explicitly cause of CMMFDevSound::ContructL() failure
|
|
133 |
iTestStepResult = EFail;
|
|
134 |
|
|
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, (iTone = CMMFMdaAudioToneUtility::NewL(*this)) );
|
|
146 |
|
|
147 |
completed = EFalse;
|
|
148 |
if (err == 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--; // Failcount of 1 equates to 0 successful allocs, etc.
|
|
155 |
}
|
|
156 |
else
|
|
157 |
{
|
|
158 |
User::Free(testAlloc);
|
|
159 |
}
|
|
160 |
|
|
161 |
// see if valid result and break if wrong - might be premature result
|
|
162 |
if (iTone == NULL || (iTone->State() != EMdaAudioToneUtilityNotReady) )
|
|
163 |
{
|
|
164 |
badResult = ETrue;
|
|
165 |
}
|
|
166 |
else
|
|
167 |
{
|
|
168 |
if (iTone != NULL)
|
|
169 |
{
|
|
170 |
delete iTone;
|
|
171 |
iTone = NULL;
|
|
172 |
}
|
|
173 |
}
|
|
174 |
completed = reachedEnd || badResult;
|
|
175 |
}
|
|
176 |
else if (err != KErrNoMemory) // bad error code
|
|
177 |
{
|
|
178 |
completed = ETrue;
|
|
179 |
}
|
|
180 |
|
|
181 |
__MM_HEAP_MARKEND;
|
|
182 |
__UHEAP_SETFAIL(RHeap::ENone ,0);
|
|
183 |
|
|
184 |
if (completed)
|
|
185 |
break; // exit loop
|
|
186 |
|
|
187 |
failCount++;
|
|
188 |
}
|
|
189 |
|
|
190 |
|
|
191 |
if ((err != KErrNone) || badResult)
|
|
192 |
{
|
|
193 |
if (badResult)
|
|
194 |
INFO_PRINTF2(_L(" Bad result with %d memory allocations tested"), failCount);
|
|
195 |
else
|
|
196 |
INFO_PRINTF3(_L(" Error(%d) with %d memory allocations tested"), err, failCount);
|
|
197 |
iTestStepResult = EFail;
|
|
198 |
}
|
|
199 |
else
|
|
200 |
{
|
|
201 |
INFO_PRINTF2(_L(" Completed OK with %d memory allocations tested"), failCount);
|
|
202 |
iTestStepResult = EPass;
|
|
203 |
}
|
|
204 |
|
|
205 |
INFO_PRINTF1(_L("finished with this test step"));
|
|
206 |
return iTestStepResult;
|
|
207 |
}
|
|
208 |
|