|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Cae Test DLL |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32math.h> |
|
21 #include "StifCaeTestTop.h" |
|
22 #include "TestFrameWork/testSuite.h" |
|
23 #include "CaeTestTop.h" |
|
24 #include "CaeTestRelease.h" |
|
25 #include "CaeTestStillSettings.h" |
|
26 #include "CaeTestStillStates.h" |
|
27 #include "CaeTestVideoStates.h" |
|
28 #include "CaeTestVideoSettings.h" |
|
29 |
|
30 // EXTERNAL DATA STRUCTURES |
|
31 // None |
|
32 |
|
33 // EXTERNAL FUNCTION PROTOTYPES |
|
34 // None |
|
35 |
|
36 // CONSTANTS |
|
37 // None |
|
38 |
|
39 // MACROS |
|
40 // None |
|
41 |
|
42 // LOCAL CONSTANTS AND MACROS |
|
43 // None |
|
44 |
|
45 // MODULE DATA STRUCTURES |
|
46 // None |
|
47 |
|
48 // LOCAL FUNCTION PROTOTYPES |
|
49 // None |
|
50 |
|
51 // FORWARD DECLARATIONS |
|
52 // None |
|
53 |
|
54 // ==================== LOCAL FUNCTIONS ======================================= |
|
55 |
|
56 |
|
57 /* |
|
58 ------------------------------------------------------------------------------- |
|
59 |
|
60 DESCRIPTION |
|
61 |
|
62 This file (DemoModule.cpp) contains all STIF test framework related parts of |
|
63 this test module. |
|
64 |
|
65 ------------------------------------------------------------------------------- |
|
66 */ |
|
67 EXPORT_C TInt SetRequirements( CTestModuleParam*& aTestModuleParam, TUint32& aParameterValid ) |
|
68 { |
|
69 aParameterValid = KStifTestModuleParameterChanged; |
|
70 |
|
71 CTestModuleParamVer01* param = CTestModuleParamVer01::NewL(); |
|
72 |
|
73 // Stack size |
|
74 param->iTestThreadStackSize= 2*16384; // 2*16K stack |
|
75 |
|
76 // Heap sizes |
|
77 param->iTestThreadMinHeap = 4096; // 4K heap min |
|
78 param->iTestThreadMaxHeap = 8*1048576;// 8M heap max |
|
79 |
|
80 aTestModuleParam = param; |
|
81 |
|
82 return KErrNone; |
|
83 } |
|
84 |
|
85 // ================= MEMBER FUNCTIONS ========================================= |
|
86 |
|
87 |
|
88 CTestModule::CTestModule() |
|
89 { |
|
90 } |
|
91 |
|
92 |
|
93 void CTestModule::ConstructL() |
|
94 { |
|
95 iTestSuite = CTestSuite::NewL(_L8("Test Suite Container")); |
|
96 |
|
97 iTestSuite->addTestL( CCaeTestRelease::suiteL() ); |
|
98 |
|
99 //iTestSuite->addTestL( CCaeTestStillStates::suiteL() ); |
|
100 //iTestSuite->addTestL( CCaeTestVideoStates::suiteL() ); |
|
101 //iTestSuite->addTestL( CCaeTestStillSettings::suiteL() ); |
|
102 //iTestSuite->addTestL( CCaeTestVideoSettings::suiteL() ); |
|
103 |
|
104 |
|
105 //SetAllocFailureSimulation( RHeap::EDeterministic, 0 ); // Enable OOM test loop |
|
106 SetAllocFailureSimulation( RHeap::ENone, 0 ); // Disable OOM test loop |
|
107 |
|
108 /* Install an active scheduler */ |
|
109 iScheduler = new(ELeave)CActiveScheduler; |
|
110 CActiveScheduler::Install(iScheduler); |
|
111 |
|
112 } |
|
113 |
|
114 |
|
115 CTestModule* CTestModule::NewL() |
|
116 { |
|
117 |
|
118 // Construct new CTestModule instance. |
|
119 CTestModule* self = new ( ELeave ) CTestModule(); |
|
120 CleanupStack::PushL( self ); |
|
121 self->ConstructL(); |
|
122 CleanupStack::Pop(); |
|
123 |
|
124 return self; |
|
125 |
|
126 } |
|
127 |
|
128 |
|
129 CTestModule::~CTestModule() |
|
130 { |
|
131 delete iTestSuite; |
|
132 delete iScheduler; |
|
133 } |
|
134 |
|
135 |
|
136 /* |
|
137 ------------------------------------------------------------------------------- |
|
138 |
|
139 Class: CTestModule |
|
140 |
|
141 Method: GetTestCases |
|
142 |
|
143 Description: GetTestCases is used to inquire test cases |
|
144 from the test module. Because this test module have hard coded test cases |
|
145 (i.e cases are not read from file), paramter aConfigFile is not used. |
|
146 |
|
147 This function loops through all cases defined in Cases() function and |
|
148 adds corresponding items to aTestCases array. |
|
149 |
|
150 Parameters: const TFileName& : in: Configuration file name. Not used |
|
151 RPointerArray<TTestCaseInfo>& aTestCases: out: |
|
152 Array of TestCases. |
|
153 |
|
154 Return Values: KErrNone: No error |
|
155 |
|
156 Errors/Exceptions: Function leaves if any memory allocation operation fails |
|
157 |
|
158 Status: Proposal |
|
159 |
|
160 ------------------------------------------------------------------------------- |
|
161 */ |
|
162 TInt CTestModule::GetTestCasesL( const TFileName& /*aConfigFile*/, |
|
163 RPointerArray<TTestCaseInfo>& aTestCases ) |
|
164 { |
|
165 |
|
166 // Loop through all test cases and create new |
|
167 // TTestCaseInfo items and append items to aTestCase array |
|
168 for( TInt i = 0; i< iTestSuite->CountTestCases(); i++ ) |
|
169 { |
|
170 |
|
171 // Allocate new TTestCaseInfo from heap for a testcase definition. |
|
172 TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo(); |
|
173 |
|
174 // PushL TTestCaseInfo to CleanupStack. |
|
175 CleanupStack::PushL( newCase ); |
|
176 |
|
177 // Set number for the testcase. |
|
178 // When the testcase is run, this comes as a parameter to RunTestCaseL. |
|
179 newCase->iCaseNumber = i; |
|
180 |
|
181 // Set title for the test case. This is shown in UI to user. |
|
182 newCase->iTitle.Copy( iTestSuite->TestCaseName(i) ); |
|
183 |
|
184 // Append TTestCaseInfo to the testcase array. After appended |
|
185 // successfully the TTestCaseInfo object is owned (and freed) |
|
186 // by the TestServer. |
|
187 User::LeaveIfError(aTestCases.Append ( newCase ) ); |
|
188 |
|
189 // Pop TTestCaseInfo from the CleanupStack. |
|
190 CleanupStack::Pop( newCase ); |
|
191 |
|
192 } |
|
193 |
|
194 return KErrNone; |
|
195 |
|
196 } |
|
197 |
|
198 /* |
|
199 ------------------------------------------------------------------------------- |
|
200 |
|
201 Class: CTestModule |
|
202 |
|
203 Method: RunTestCase |
|
204 |
|
205 Description: Run a specified testcase. |
|
206 |
|
207 Function runs a test case specified by test case number. Test case file |
|
208 parameter is not used. |
|
209 |
|
210 If case number is valid, this function runs a test case returned by |
|
211 function Cases(). |
|
212 |
|
213 Parameters: const TInt aCaseNumber: in: Testcase number |
|
214 const TFileName& : in: Configuration file name. Not used |
|
215 TTestResult& aResult: out: Testcase result |
|
216 |
|
217 Return Values: KErrNone: Testcase ran. |
|
218 KErrNotFound: Unknown testcase |
|
219 |
|
220 Errors/Exceptions: None |
|
221 |
|
222 Status: Proposal |
|
223 |
|
224 ------------------------------------------------------------------------------- |
|
225 */ |
|
226 TInt CTestModule::RunTestCaseL( const TInt aCaseNumber, |
|
227 const TFileName& /*aConfig*/, |
|
228 TTestResult& aResult ) |
|
229 { |
|
230 // Next is a temporary solution for Stif memory leak error |
|
231 TestModuleIf().SetBehavior(CTestModuleIf::ETestLeaksMem); |
|
232 TestModuleIf().SetBehavior(CTestModuleIf::ETestLeaksRequests); |
|
233 TestModuleIf().SetBehavior(CTestModuleIf::ETestLeaksHandles); |
|
234 |
|
235 if ( iAllocFailureType != RHeap::ENone ) |
|
236 { |
|
237 RunTestCaseInOOMLoopL( aCaseNumber, aResult ); |
|
238 } |
|
239 else |
|
240 { |
|
241 iTestSuite->ExecuteTestL( aResult, aCaseNumber ); |
|
242 } |
|
243 |
|
244 // Return case execution status (not the result of the case execution) |
|
245 return KErrNone; |
|
246 } |
|
247 |
|
248 |
|
249 /* |
|
250 */ |
|
251 |
|
252 void CTestModule::RunTestCaseInOOMLoopL( const TInt aCaseNumber, |
|
253 TTestResult& aResult ) |
|
254 { |
|
255 |
|
256 // |
|
257 TInt error = KErrNone; |
|
258 aResult.SetResult( KErrNoMemory, _L("") ); // Initial value |
|
259 |
|
260 for (; ( aResult.iResult == KErrNoMemory ) && !error;) |
|
261 { |
|
262 // Switches on alloc failure simulation if the parameters are set for it |
|
263 AllocFailureSimulation( ETrue ); |
|
264 RDebug::Print(_L("*** OOM loop : %d ***\n"), iCurrentAllocFailureRate ); |
|
265 TRAP( error, iTestSuite->ExecuteTestL( aResult, aCaseNumber ) ); |
|
266 if ( error == KErrNoMemory ) |
|
267 { |
|
268 error = KErrNone; |
|
269 } |
|
270 } |
|
271 |
|
272 // |
|
273 AllocFailureSimulation( EFalse ); |
|
274 User::LeaveIfError( error ); |
|
275 } |
|
276 |
|
277 |
|
278 /* |
|
279 */ |
|
280 |
|
281 void CTestModule::AllocFailureSimulation (TBool aSwitchedOn) |
|
282 { |
|
283 if (aSwitchedOn) |
|
284 { |
|
285 __UHEAP_SETFAIL ( iAllocFailureType, iCurrentAllocFailureRate ); |
|
286 iCurrentAllocFailureRate++; |
|
287 } |
|
288 else |
|
289 { |
|
290 __UHEAP_RESET; |
|
291 iCurrentAllocFailureRate = iAllocFailureRate; |
|
292 } |
|
293 } |
|
294 |
|
295 |
|
296 /* |
|
297 */ |
|
298 |
|
299 void CTestModule::SetAllocFailureSimulation( RHeap::TAllocFail aAllocFailureType, TInt aAllocFailureRate ) |
|
300 { |
|
301 iAllocFailureType = aAllocFailureType; |
|
302 iAllocFailureRate = aAllocFailureRate; |
|
303 iCurrentAllocFailureRate = aAllocFailureRate; |
|
304 } |
|
305 |
|
306 // ================= OTHER EXPORTED FUNCTIONS ================================= |
|
307 |
|
308 /* |
|
309 ------------------------------------------------------------------------------- |
|
310 |
|
311 Function: LibEntryL |
|
312 |
|
313 Description: Polymorphic Dll Entry Point |
|
314 |
|
315 Test framework calls this function to obtain new instance of test module |
|
316 class. |
|
317 |
|
318 Parameters: None |
|
319 |
|
320 Return Values: CTestModule* Pointer to CTestModule instance |
|
321 |
|
322 Errors/Exceptions: Leaves if CTestModule::NewL leaves |
|
323 |
|
324 Status: Approved |
|
325 |
|
326 ------------------------------------------------------------------------------- |
|
327 */ |
|
328 EXPORT_C CTestModule* LibEntryL() |
|
329 { |
|
330 return CTestModule::NewL(); |
|
331 |
|
332 } |
|
333 |
|
334 /* |
|
335 ------------------------------------------------------------------------------- |
|
336 |
|
337 Function: E32Dll |
|
338 |
|
339 Description: DLL entry point function |
|
340 |
|
341 Parameters: TDllReason: Not used |
|
342 |
|
343 Return Values: KErrNone: always |
|
344 |
|
345 Errors/Exceptions: None |
|
346 |
|
347 Status: Approved |
|
348 |
|
349 ------------------------------------------------------------------------------- |
|
350 */ |
|
351 #ifndef EKA2 |
|
352 GLDEF_C TInt E32Dll(TDllReason /*aReason*/) |
|
353 { |
|
354 return( KErrNone ); |
|
355 |
|
356 } |
|
357 #endif |
|
358 |
|
359 // End of File |