|
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: 3dringingtoneinterface_tests class member functions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <Stiftestinterface.h> |
|
22 #include "3dringingtoneinterface_tests.h" |
|
23 |
|
24 // EXTERNAL DATA STRUCTURES |
|
25 //extern ?external_data; |
|
26 |
|
27 // EXTERNAL FUNCTION PROTOTYPES |
|
28 //extern ?external_function( ?arg_type,?arg_type ); |
|
29 |
|
30 // CONSTANTS |
|
31 //const ?type ?constant_var = ?constant; |
|
32 |
|
33 // MACROS |
|
34 //#define ?macro ?macro_def |
|
35 |
|
36 // LOCAL CONSTANTS AND MACROS |
|
37 //const ?type ?constant_var = ?constant; |
|
38 //#define ?macro_name ?macro_def |
|
39 |
|
40 // MODULE DATA STRUCTURES |
|
41 //enum ?declaration |
|
42 //typedef ?declaration |
|
43 |
|
44 // LOCAL FUNCTION PROTOTYPES |
|
45 //?type ?function_name( ?arg_type, ?arg_type ); |
|
46 |
|
47 // FORWARD DECLARATIONS |
|
48 //class ?FORWARD_CLASSNAME; |
|
49 |
|
50 // ============================= LOCAL FUNCTIONS =============================== |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // ?function_name ?description. |
|
54 // ?description |
|
55 // Returns: ?value_1: ?description |
|
56 // ?value_n: ?description_line1 |
|
57 // ?description_line2 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 /* |
|
61 ?type ?function_name( |
|
62 ?arg_type arg, // ?description |
|
63 ?arg_type arg) // ?description |
|
64 { |
|
65 |
|
66 ?code // ?comment |
|
67 |
|
68 // ?comment |
|
69 ?code |
|
70 } |
|
71 */ |
|
72 |
|
73 // ============================ MEMBER FUNCTIONS =============================== |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // C3dringingtoneinterface_tests::C3dringingtoneinterface_tests |
|
77 // C++ default constructor can NOT contain any code, that |
|
78 // might leave. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 C3dringingtoneinterface_tests::C3dringingtoneinterface_tests() |
|
82 { |
|
83 |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // C3dringingtoneinterface_tests::ConstructL |
|
88 // Symbian 2nd phase constructor can leave. |
|
89 // |
|
90 // Note: If OOM test case uses STIF Logger, then STIF Logger must be created |
|
91 // with static buffer size parameter (aStaticBufferSize). Otherwise Logger |
|
92 // allocates memory from heap and therefore causes error situations with OOM |
|
93 // testing. For more information about STIF Logger construction, see STIF Users |
|
94 // Guide. |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void C3dringingtoneinterface_tests::ConstructL() |
|
98 { |
|
99 iLog = CStifLogger::NewL( K3dringingtoneinterface_testsLogPath, |
|
100 K3dringingtoneinterface_testsLogFile); |
|
101 |
|
102 // Sample how to use logging |
|
103 _LIT( KLogStart, "3dringingtoneinterface_tests logging starts!" ); |
|
104 iLog->Log( KLogStart ); |
|
105 |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // C3dringingtoneinterface_tests::NewL |
|
110 // Two-phased constructor. |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 C3dringingtoneinterface_tests* C3dringingtoneinterface_tests::NewL() |
|
114 { |
|
115 C3dringingtoneinterface_tests* self = new (ELeave) C3dringingtoneinterface_tests; |
|
116 |
|
117 CleanupStack::PushL( self ); |
|
118 self->ConstructL(); |
|
119 CleanupStack::Pop(); |
|
120 |
|
121 return self; |
|
122 |
|
123 } |
|
124 |
|
125 // Destructor |
|
126 C3dringingtoneinterface_tests::~C3dringingtoneinterface_tests() |
|
127 { |
|
128 delete iLog; |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // C3dringingtoneinterface_tests::InitL |
|
133 // InitL is used to initialize the Test Module. |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 TInt C3dringingtoneinterface_tests::InitL( |
|
137 TFileName& /*aIniFile*/, |
|
138 TBool /*aFirstTime*/ ) |
|
139 { |
|
140 return KErrNone; |
|
141 |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // C3dringingtoneinterface_tests::GetTestCasesL |
|
146 // GetTestCases is used to inquire test cases from the Test Module. Test |
|
147 // cases are stored to array of test cases. The Test Framework will be |
|
148 // the owner of the data in the RPointerArray after GetTestCases return |
|
149 // and it does the memory deallocation. |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 TInt C3dringingtoneinterface_tests::GetTestCasesL( |
|
153 const TFileName& /*aConfig*/, |
|
154 RPointerArray<TTestCaseInfo>& aTestCases ) |
|
155 { |
|
156 |
|
157 // Loop through all test cases and create new |
|
158 // TTestCaseInfo items and append items to aTestCase array |
|
159 for( TInt i = 0; Case(i).iMethod != NULL; i++ ) |
|
160 { |
|
161 |
|
162 // Allocate new TTestCaseInfo from heap for a testcase definition. |
|
163 TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo(); |
|
164 |
|
165 // PushL TTestCaseInfo to CleanupStack. |
|
166 CleanupStack::PushL( newCase ); |
|
167 |
|
168 // Set number for the testcase. |
|
169 // When the testcase is run, this comes as a parameter to RunTestCaseL. |
|
170 newCase->iCaseNumber = i; |
|
171 |
|
172 // Set title for the test case. This is shown in UI to user. |
|
173 newCase->iTitle.Copy( Case(i).iCaseName ); |
|
174 |
|
175 // Append TTestCaseInfo to the testcase array. After appended |
|
176 // successfully the TTestCaseInfo object is owned (and freed) |
|
177 // by the TestServer. |
|
178 User::LeaveIfError(aTestCases.Append ( newCase ) ); |
|
179 |
|
180 // Pop TTestCaseInfo from the CleanupStack. |
|
181 CleanupStack::Pop( newCase ); |
|
182 |
|
183 } |
|
184 |
|
185 return KErrNone; |
|
186 |
|
187 } |
|
188 |
|
189 // ----------------------------------------------------------------------------- |
|
190 // C3dringingtoneinterface_tests::RunTestCaseL |
|
191 // RunTestCaseL is used to run an individual test case specified |
|
192 // by aTestCase. Test cases that can be run may be requested from |
|
193 // Test Module by GetTestCases method before calling RunTestCase. |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 TInt C3dringingtoneinterface_tests::RunTestCaseL( |
|
197 const TInt aCaseNumber, |
|
198 const TFileName& /*aConfig*/, |
|
199 TTestResult& aResult ) |
|
200 { |
|
201 |
|
202 // Return value |
|
203 TInt execStatus = KErrNone; |
|
204 |
|
205 // Get the pointer to test case function |
|
206 TCaseInfo tmp = Case ( aCaseNumber ); |
|
207 |
|
208 _LIT( KLogStartTC, "Starting testcase [%S]" ); |
|
209 iLog->Log( KLogStartTC, &tmp.iCaseName); |
|
210 |
|
211 // Check that case number was valid |
|
212 if ( tmp.iMethod != NULL ) |
|
213 { |
|
214 // Valid case was found, call it via function pointer |
|
215 iMethod = tmp.iMethod; |
|
216 execStatus = ( this->*iMethod )( aResult ); |
|
217 } |
|
218 else |
|
219 { |
|
220 // Valid case was not found, return error. |
|
221 execStatus = KErrNotFound; |
|
222 } |
|
223 |
|
224 // Return case execution status (not the result of the case execution) |
|
225 return execStatus; |
|
226 |
|
227 } |
|
228 |
|
229 // ----------------------------------------------------------------------------- |
|
230 // C3dringingtoneinterface_tests::OOMTestQueryL |
|
231 // Used to check if a particular test case should be run in OOM conditions and |
|
232 // which memory allocations should fail. |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 TBool C3dringingtoneinterface_tests::OOMTestQueryL( |
|
236 const TFileName& /* aTestCaseFile */, |
|
237 const TInt aCaseNumber, |
|
238 TOOMFailureType& /* aFailureType */, |
|
239 TInt& aFirstMemFailure, |
|
240 TInt& aLastMemFailure ) |
|
241 { |
|
242 _LIT( KLogOOMTestQueryL, "C3dringingtoneinterface_tests::OOMTestQueryL" ); |
|
243 iLog->Log( KLogOOMTestQueryL ); |
|
244 |
|
245 aFirstMemFailure = Case( aCaseNumber ).iFirstMemoryAllocation; |
|
246 aLastMemFailure = Case( aCaseNumber ).iLastMemoryAllocation; |
|
247 |
|
248 return Case( aCaseNumber ).iIsOOMTest; |
|
249 |
|
250 } |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // C3dringingtoneinterface_tests::OOMTestInitializeL |
|
254 // Used to perform the test environment setup for a particular OOM test case. |
|
255 // Test Modules may use the initialization file to read parameters for Test |
|
256 // Module initialization but they can also have their own configure file or |
|
257 // some other routine to initialize themselves. |
|
258 // |
|
259 // NOTE: User may add implementation for OOM test environment initialization. |
|
260 // Usually no implementation is required. |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 void C3dringingtoneinterface_tests::OOMTestInitializeL( |
|
264 const TFileName& /* aTestCaseFile */, |
|
265 const TInt /* aCaseNumber */ ) |
|
266 { |
|
267 } |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // C3dringingtoneinterface_tests::OOMHandleWarningL |
|
271 // In some cases the heap memory allocation should be skipped, either due to |
|
272 // problems in the OS code or components used by the code being tested, or even |
|
273 // inside the tested components which are implemented this way on purpose (by |
|
274 // design), so it is important to give the tester a way to bypass allocation |
|
275 // failures. |
|
276 // |
|
277 // NOTE: User may add implementation for OOM test warning handling. Usually no |
|
278 // implementation is required. |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 void C3dringingtoneinterface_tests::OOMHandleWarningL( |
|
282 const TFileName& /* aTestCaseFile */, |
|
283 const TInt /* aCaseNumber */, |
|
284 TInt& /* aFailNextValue */ ) |
|
285 { |
|
286 } |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // C3dringingtoneinterface_tests::OOMTestFinalizeL |
|
290 // Used to perform the test environment cleanup for a particular OOM test case. |
|
291 // |
|
292 // NOTE: User may add implementation for OOM test environment finalization. |
|
293 // Usually no implementation is required. |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 void C3dringingtoneinterface_tests::OOMTestFinalizeL( |
|
297 const TFileName& /* aTestCaseFile */, |
|
298 const TInt /* aCaseNumber */ ) |
|
299 { |
|
300 } |
|
301 |
|
302 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
303 |
|
304 // ----------------------------------------------------------------------------- |
|
305 // LibEntryL is a polymorphic Dll entry point |
|
306 // Returns: CTestModuleBase*: Pointer to Test Module object |
|
307 // ----------------------------------------------------------------------------- |
|
308 // |
|
309 EXPORT_C CTestModuleBase* LibEntryL() |
|
310 { |
|
311 return C3dringingtoneinterface_tests::NewL(); |
|
312 |
|
313 } |
|
314 |
|
315 // ----------------------------------------------------------------------------- |
|
316 // SetRequirements handles test module parameters(implements evolution |
|
317 // version 1 for test module's heap and stack sizes configuring). |
|
318 // Returns: TInt: Symbian error code. |
|
319 // ----------------------------------------------------------------------------- |
|
320 // |
|
321 EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, |
|
322 TUint32& /*aParameterValid*/ ) |
|
323 { |
|
324 |
|
325 /* --------------------------------- NOTE --------------------------------- |
|
326 USER PANICS occurs in test thread creation when: |
|
327 1) "The panic occurs when the value of the stack size is negative." |
|
328 2) "The panic occurs if the minimum heap size specified is less |
|
329 than KMinHeapSize". |
|
330 KMinHeapSize: "Functions that require a new heap to be allocated will |
|
331 either panic, or will reset the required heap size to this value if |
|
332 a smaller heap size is specified". |
|
333 3) "The panic occurs if the minimum heap size specified is greater than |
|
334 the maximum size to which the heap can grow". |
|
335 Other: |
|
336 1) Make sure that your hardware or Symbian OS is supporting given sizes. |
|
337 e.g. Hardware might support only sizes that are divisible by four. |
|
338 ------------------------------- NOTE end ------------------------------- */ |
|
339 |
|
340 // Normally STIF uses default heap and stack sizes for test thread, see: |
|
341 // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize. |
|
342 // If needed heap and stack sizes can be configured here by user. Remove |
|
343 // comments and define sizes. |
|
344 |
|
345 /* |
|
346 aParameterValid = KStifTestModuleParameterChanged; |
|
347 |
|
348 CTestModuleParamVer01* param = CTestModuleParamVer01::NewL(); |
|
349 // Stack size |
|
350 param->iTestThreadStackSize= 16384; // 16K stack |
|
351 // Heap sizes |
|
352 param->iTestThreadMinHeap = 4096; // 4K heap min |
|
353 param->iTestThreadMaxHeap = 1048576;// 1M heap max |
|
354 |
|
355 aTestModuleParam = param; |
|
356 */ |
|
357 return KErrNone; |
|
358 |
|
359 } |
|
360 |
|
361 |
|
362 // End of File |