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