|
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: AudioInputStreamTestApp class member functions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <Stiftestinterface.h> |
|
22 #include "AudioStreamTestApp.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 // Input Stream Test Cases |
|
34 const TInt CAudioStreamTestApp::KTestCaseInputNew=301; |
|
35 const TInt CAudioStreamTestApp::KTestCaseInputNewWithParam=302; |
|
36 const TInt CAudioStreamTestApp::KTestCaseInputSetAudioProperties=303; |
|
37 const TInt CAudioStreamTestApp::KTestCaseInputSetGain=304; |
|
38 const TInt CAudioStreamTestApp::KTestCaseInputSetBalance=305; |
|
39 const TInt CAudioStreamTestApp::KTestCaseInputSetPriority=306; |
|
40 const TInt CAudioStreamTestApp::KTestCaseInputSetDataType=307; |
|
41 const TInt CAudioStreamTestApp::KTestCaseInputOpen=308; |
|
42 const TInt CAudioStreamTestApp::KTestCaseInputRecord=309; |
|
43 const TInt CAudioStreamTestApp::KTestCaseInputBitRate=310; |
|
44 |
|
45 // Output Stream Test Cases |
|
46 const TInt CAudioStreamTestApp::KTestCaseOutputNew=351; |
|
47 const TInt CAudioStreamTestApp::KTestCaseOutputNewWithParam=352; |
|
48 const TInt CAudioStreamTestApp::KTestCaseOutputSetAudioProperties=353; |
|
49 const TInt CAudioStreamTestApp::KTestCaseOutputOpen=354; |
|
50 const TInt CAudioStreamTestApp::KTestCaseOutputSetVolume=355; |
|
51 const TInt CAudioStreamTestApp::KTestCaseOutputSetPriority=356; |
|
52 const TInt CAudioStreamTestApp::KTestCaseOutputPlay=357; |
|
53 const TInt CAudioStreamTestApp::KTestCaseOutputSetBalance=358; |
|
54 const TInt CAudioStreamTestApp::KTestCaseOutputSetDataType=359; |
|
55 const TInt CAudioStreamTestApp::KTestCaseOutputStop=360; |
|
56 |
|
57 |
|
58 const TInt CAudioStreamTestApp::MAX_TESTCASE_ID=360; |
|
59 |
|
60 // MACROS |
|
61 //#define ?macro ?macro_def |
|
62 |
|
63 // LOCAL CONSTANTS AND MACROS |
|
64 //const ?type ?constant_var = ?constant; |
|
65 //#define ?macro_name ?macro_def |
|
66 |
|
67 // MODULE DATA STRUCTURES |
|
68 //enum ?declaration |
|
69 //typedef ?declaration |
|
70 |
|
71 // LOCAL FUNCTION PROTOTYPES |
|
72 //?type ?function_name( ?arg_type, ?arg_type ); |
|
73 |
|
74 // FORWARD DECLARATIONS |
|
75 //class ?FORWARD_CLASSNAME; |
|
76 |
|
77 // ============================= LOCAL FUNCTIONS =============================== |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // ?function_name ?description. |
|
81 // ?description |
|
82 // Returns: ?value_1: ?description |
|
83 // ?value_n: ?description_line1 |
|
84 // ?description_line2 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 /* |
|
88 ?type ?function_name( |
|
89 ?arg_type arg, // ?description |
|
90 ?arg_type arg) // ?description |
|
91 { |
|
92 |
|
93 ?code // ?comment |
|
94 |
|
95 // ?comment |
|
96 ?code |
|
97 } |
|
98 */ |
|
99 |
|
100 // ============================ MEMBER FUNCTIONS =============================== |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CAudioStreamTestApp::CAudioStreamTestApp |
|
104 // C++ default constructor can NOT contain any code, that |
|
105 // might leave. |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 CAudioStreamTestApp::CAudioStreamTestApp() |
|
109 { |
|
110 iErrName[0].Copy(_L("KErrNone")); |
|
111 iErrName[1].Copy(_L("KErrNotFound")); |
|
112 iErrName[2].Copy(_L("KErrGeneral")); |
|
113 iErrName[3].Copy(_L("KErrCancel")); |
|
114 iErrName[4].Copy(_L("KErrNoMemory")); |
|
115 iErrName[5].Copy(_L("KErrNotSupported")); |
|
116 iErrName[6].Copy(_L("KErrArgument")); |
|
117 iErrName[7].Copy(_L("KErrTotalLossOfPrecision")); |
|
118 iErrName[8].Copy(_L("KErrBadHandle")); |
|
119 iErrName[9].Copy(_L("KErrOverflow")); |
|
120 iErrName[10].Copy(_L("KErrUnderflow")); |
|
121 iErrName[11].Copy(_L("KErrAlreadyExists")); |
|
122 iErrName[12].Copy(_L("KErrPathNotFound")); |
|
123 iErrName[13].Copy(_L("KErrDied")); |
|
124 iErrName[14].Copy(_L("KErrInUse")); |
|
125 iErrName[15].Copy(_L("KErrServerTerminated")); |
|
126 iErrName[16].Copy(_L("KErrServerBusy")); |
|
127 iErrName[17].Copy(_L("KErrCompletion")); |
|
128 iErrName[18].Copy(_L("KErrNotReady")); |
|
129 iErrName[19].Copy(_L("KErrUnknown")); |
|
130 iErrName[20].Copy(_L("KErrCorrupt")); |
|
131 iErrName[21].Copy(_L("KErrAccessDenied")); |
|
132 iErrName[22].Copy(_L("KErrLocked")); |
|
133 iErrName[23].Copy(_L("KErrWrite")); |
|
134 iErrName[24].Copy(_L("KErrDisMounted")); |
|
135 iErrName[25].Copy(_L("KErrEof")); |
|
136 iErrName[26].Copy(_L("KErrDiskFull")); |
|
137 iErrName[27].Copy(_L("KErrBadDriver")); |
|
138 iErrName[28].Copy(_L("KErrBadName")); |
|
139 iErrName[29].Copy(_L("KErrCommsLineFail")); |
|
140 iErrName[30].Copy(_L("KErrCommsFrame")); |
|
141 iErrName[31].Copy(_L("KErrCommsOverrun")); |
|
142 iErrName[32].Copy(_L("KErrCommsParity")); |
|
143 iErrName[33].Copy(_L("KErrTimedOut")); |
|
144 iErrName[34].Copy(_L("KErrCouldNotConnect")); |
|
145 iErrName[35].Copy(_L("KErrCouldNotDisconnect")); |
|
146 iErrName[36].Copy(_L("KErrDisconnected")); |
|
147 iErrName[37].Copy(_L("KErrBadLibraryEntryPoint")); |
|
148 iErrName[38].Copy(_L("KErrBadDescriptor")); |
|
149 iErrName[39].Copy(_L("KErrAbort")); |
|
150 iErrName[40].Copy(_L("KErrTooBig")); |
|
151 iErrName[41].Copy(_L("KErrDivideByZero")); |
|
152 iErrName[42].Copy(_L("KErrBadPower")); |
|
153 iErrName[43].Copy(_L("KErrDirFull")); |
|
154 iErrName[44].Copy(_L("KErrHardwareNotAvailable")); |
|
155 iErrName[45].Copy(_L("KErrSessionClosed")); |
|
156 iErrName[46].Copy(_L("KErrPermissionDenied")); |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CAudioStreamTestApp::ConstructL |
|
161 // Symbian 2nd phase constructor can leave. |
|
162 // Note: If OOM test case uses STIF Logger, then STIF Logger must be created |
|
163 // with static buffer size parameter (aStaticBufferSize). Otherwise Logger |
|
164 // allocates memory from heap and therefore causes error situations with OOM |
|
165 // testing. For more information about STIF Logger construction, see STIF Users |
|
166 // Guide. |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 void CAudioStreamTestApp::ConstructL() |
|
170 { |
|
171 if ( ! iScheduler) |
|
172 { |
|
173 iScheduler = new (ELeave) CActiveScheduler; |
|
174 CActiveScheduler::Install(iScheduler); // install as active scheduler |
|
175 } |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CAudioStreamTestApp::NewL |
|
180 // Two-phased constructor. |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 CAudioStreamTestApp* CAudioStreamTestApp::NewL() |
|
184 { |
|
185 CAudioStreamTestApp* self = new (ELeave) CAudioStreamTestApp; |
|
186 |
|
187 CleanupStack::PushL( self ); |
|
188 self->ConstructL(); |
|
189 CleanupStack::Pop(); |
|
190 |
|
191 return self; |
|
192 |
|
193 } |
|
194 |
|
195 // Destructor |
|
196 CAudioStreamTestApp::~CAudioStreamTestApp() |
|
197 { |
|
198 delete iLogger; |
|
199 delete iScheduler; |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CAudioStreamTestApp::InitL |
|
204 // InitL is used to initialize the Test Module. |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 TInt CAudioStreamTestApp::InitL( |
|
208 TFileName& aIniFile, |
|
209 TBool /*aFirstTime*/ ) |
|
210 { |
|
211 CStifParser *parser; |
|
212 RDebug::Print(_L("CAudioStreamTestApp::InitL:")); |
|
213 TParsePtrC fp(aIniFile); |
|
214 //fp.Set(); |
|
215 parser = CStifParser::NewL(fp.DriveAndPath() , fp.NameAndExt() ); |
|
216 CleanupStack::PushL(parser); |
|
217 |
|
218 if (parser) |
|
219 { |
|
220 RDebug::Print(_L("CAudioStreamTestApp::InitL: parser is not null")); |
|
221 CStifSectionParser *section; |
|
222 |
|
223 section = parser->SectionL(KSectionStart, KSectionEnd); |
|
224 CleanupStack::PushL(section); |
|
225 TPtrC logFileName; |
|
226 TPtrC logPath; |
|
227 if (section) |
|
228 { |
|
229 RDebug::Print(_L("CAudioStreamTestApp::InitL: section is not null")); |
|
230 |
|
231 |
|
232 if ( (section->GetLine(KLogFileTag, logFileName, ENoTag) == KErrNone) && (section->GetLine(KLogPathTag, logPath, ENoTag) == KErrNone) ) |
|
233 { |
|
234 RDebug::Print(_L("CAudioStreamTestApp::InitL: InitLoggerL(logPath, logFileName);")); |
|
235 InitLoggerL(logPath, logFileName); |
|
236 } |
|
237 } |
|
238 if (!iLogger) |
|
239 { |
|
240 RDebug::Print(_L("CAudioStreamTestApp::InitL: InitLoggerL(); again")); |
|
241 InitLoggerL(); |
|
242 } |
|
243 iLogger->Log(KOpeningLogFilepath, &logPath); |
|
244 iLogger->Log(KLoggerStarted, &aIniFile); |
|
245 CleanupStack::PopAndDestroy(section); //section |
|
246 } |
|
247 |
|
248 CleanupStack::PopAndDestroy(parser); //parser |
|
249 |
|
250 return KErrNone; |
|
251 } |
|
252 |
|
253 /* ------------------------------------------------------------------------------- |
|
254 |
|
255 Class: CMmfTsPlay |
|
256 Method: InitLoggerL |
|
257 Description: Initialize the logger for this test module |
|
258 Parameters: File name where to append data |
|
259 Return Values: Error value |
|
260 Errors/Exceptions: <description how errors and exceptions are handled> |
|
261 Status: Draft |
|
262 |
|
263 ------------------------------------------------------------------------------- */ |
|
264 void CAudioStreamTestApp::InitLoggerL( const TFileName& aLogPath , const TFileName& aLogFile) |
|
265 { |
|
266 iLogger = CStifLogger::NewL(aLogPath, aLogFile, CStifLogger::ETxt, CStifLogger::EFile, EFalse) ; |
|
267 if ( ! iLogger ) |
|
268 { |
|
269 RDebug::Print(_L("CAudioStreamTestApp::InitL: InitLoggerL(); with filename failed")); |
|
270 InitLoggerL(); |
|
271 } |
|
272 } |
|
273 |
|
274 void CAudioStreamTestApp::InitLoggerL() |
|
275 { |
|
276 RDebug::Print(_L("CAudioStreamTestApp::InitL: InitLoggerL(); with default")); |
|
277 iLogger = CStifLogger::NewL(KDefLogPath, KDefLogFile, CStifLogger::ETxt, CStifLogger::EFile, EFalse); |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // CAudioStreamTestApp::GetTestCasesL |
|
282 // GetTestCases is used to inquire test cases from the Test Module. Test |
|
283 // cases are stored to array of test cases. The Test Framework will be |
|
284 // the owner of the data in the RPointerArray after GetTestCases return |
|
285 // and it does the memory deallocation. |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 TInt CAudioStreamTestApp::GetTestCasesL( |
|
289 const TFileName& aConfig, |
|
290 RPointerArray<TTestCaseInfo>& aTestCases ) |
|
291 { |
|
292 //Get a parser for the config file |
|
293 iLogger->Log(KOpeningConfig, &aConfig); |
|
294 |
|
295 if (! aConfig.Length() ) { |
|
296 iLogger->Log(KConfigRequired() ); |
|
297 return KErrConfigInvalid; |
|
298 } |
|
299 |
|
300 TParsePtrC fp(aConfig); |
|
301 CStifParser *parser = CStifParser::NewL(fp.DriveAndPath() , fp.NameAndExt() ); |
|
302 CleanupStack::PushL(parser); |
|
303 |
|
304 //Get a section parser |
|
305 CStifSectionParser *section; |
|
306 TInt x = 0; |
|
307 |
|
308 //Read all cases in config file |
|
309 //while ( section = parser->SectionL(KTestCaseConfigStart , KTestCaseConfigEnd, x++) ) |
|
310 |
|
311 while ( (section = parser->NextSectionL(KTestCaseConfigStart , KTestCaseConfigEnd) ),section ) // use comma to avoid warning |
|
312 { |
|
313 CleanupStack::PushL(section); |
|
314 TInt id = -1; |
|
315 TPtrC TestCaseTitle; |
|
316 TInt ErrorResult = KErrNone; |
|
317 |
|
318 CStifItemParser *item; |
|
319 item = section->GetItemLineL(KTagId); |
|
320 if (item) |
|
321 { |
|
322 CleanupStack::PushL(item); |
|
323 |
|
324 if (!item->GetInt(KTagId, id)) |
|
325 { |
|
326 ErrorResult = section->GetLine(KTagTitle, TestCaseTitle, ENoTag); |
|
327 if (!ErrorResult) {iLogger->Log( _L("Adding case: (%d) %S") , id, &TestCaseTitle ); } |
|
328 } |
|
329 else |
|
330 { |
|
331 id = -1; |
|
332 } |
|
333 CleanupStack::PopAndDestroy(item); //item |
|
334 } |
|
335 |
|
336 if (0<id && id<=MAX_TESTCASE_ID) |
|
337 { |
|
338 TTestCaseInfo* testCase = new ( ELeave ) TTestCaseInfo(); |
|
339 CleanupStack::PushL( testCase ); |
|
340 testCase->iCaseNumber = x++; |
|
341 |
|
342 testCase->iTitle.Format(KTestCaseTitleFormat, id, &TestCaseTitle); //testCase->iTitle.Copy( KTestCaseTitleFormat() ); |
|
343 |
|
344 User::LeaveIfError( aTestCases.Append( testCase ) ); |
|
345 |
|
346 CleanupStack::Pop( testCase ); //testCase |
|
347 } |
|
348 |
|
349 CleanupStack::PopAndDestroy(section); //section |
|
350 } |
|
351 |
|
352 CleanupStack::PopAndDestroy(parser); //parser |
|
353 |
|
354 return KErrNone; |
|
355 |
|
356 } |
|
357 |
|
358 // ----------------------------------------------------------------------------- |
|
359 // CAudioStreamTestApp::RunTestCaseL |
|
360 // RunTestCaseL is used to run an individual test case specified |
|
361 // by aTestCase. Test cases that can be run may be requested from |
|
362 // Test Module by GetTestCases method before calling RunTestCase. |
|
363 // ----------------------------------------------------------------------------- |
|
364 // |
|
365 TInt CAudioStreamTestApp::RunTestCaseL( |
|
366 const TInt aCaseNumber, |
|
367 const TFileName& aConfig, |
|
368 TTestResult& aResult ) |
|
369 { |
|
370 TInt id=-1; |
|
371 |
|
372 //Get a parser for the config file |
|
373 iLogger->Log(KOpeningConfig, &aConfig); |
|
374 |
|
375 if (! aConfig.Length() ) { |
|
376 iLogger->Log(KConfigRequired() ); |
|
377 aResult.iResultDes.Copy(KConfigRequired()); |
|
378 aResult.iResult = KErrNotExecuted; |
|
379 return KErrConfigInvalid; |
|
380 } |
|
381 |
|
382 TParsePtrC fp(aConfig); |
|
383 iLogger->Log(_L("Opening configuration file [%S], case #%d"), &aConfig, aCaseNumber); |
|
384 CStifParser *parser = CStifParser::NewL(fp.DriveAndPath() , fp.NameAndExt() ); |
|
385 CleanupStack::PushL(parser); |
|
386 |
|
387 //Get a section parser |
|
388 TInt retVal=0; |
|
389 CStifSectionParser *section=0; |
|
390 CStifItemParser *item=0; |
|
391 section = parser->NextSectionL(KTestCaseConfigStart , KTestCaseConfigEnd, aCaseNumber+1); |
|
392 |
|
393 if (section) { |
|
394 CleanupStack::PushL(section); |
|
395 item = section->GetItemLineL(KTagId); |
|
396 |
|
397 if (item) { |
|
398 CleanupStack::PushL(item); |
|
399 |
|
400 if (!item->GetInt(KTagId, id)) { |
|
401 TPtrC TestCaseTitle; |
|
402 |
|
403 TInt TitleErrorResult = section->GetLine(KTagTitle, TestCaseTitle, ENoTag); |
|
404 if (!TitleErrorResult) {iLogger->Log( _L("Executing test case (%d) %S") , id, &TestCaseTitle ); } |
|
405 |
|
406 //Call Funtion to perform test |
|
407 __UHEAP_MARK; |
|
408 TRAPD(error, retVal = RunTestCaseFunctionL(id, section, aResult);); |
|
409 REComSession::FinalClose(); |
|
410 __UHEAP_MARKEND; |
|
411 |
|
412 if (error) |
|
413 { |
|
414 retVal = KErrLeft; |
|
415 aResult.iResult=error; |
|
416 aResult.iResultDes.Copy( KTestCaseResultLeft() ); |
|
417 } |
|
418 |
|
419 iLogger->Log( _L("Finished Executing test case (%d)"), id); |
|
420 iLogger->Log( _L(" Error code (%d)"), retVal); |
|
421 iLogger->Log( _L(" aResult.iResult=(%d)") , aResult.iResult); |
|
422 iLogger->Log( _L(" aResult.iResultDes=(%S)\r\n") , &aResult.iResultDes); |
|
423 |
|
424 } else { |
|
425 id=-1; |
|
426 } |
|
427 CleanupStack::PopAndDestroy(item); |
|
428 } |
|
429 CleanupStack::PopAndDestroy(section); |
|
430 } |
|
431 CleanupStack::PopAndDestroy(parser); |
|
432 |
|
433 if (-1!=id) |
|
434 { |
|
435 return retVal; |
|
436 } |
|
437 iLogger->Log(KConfigInvalid() ); |
|
438 aResult.iResultDes.Copy(KConfigInvalid()); |
|
439 aResult.iResult = KErrNotFound; |
|
440 return KErrNotFound; |
|
441 } |
|
442 |
|
443 TInt CAudioStreamTestApp::RunTestCaseFunctionL(TInt id, CStifSectionParser *section, TTestResult &aResult) |
|
444 { |
|
445 TInt retValue=KErrConfigInvalid; |
|
446 aResult.iResult=KErrNotExecuted; |
|
447 |
|
448 switch (id) |
|
449 { |
|
450 // Audio Input Stream Test Cases |
|
451 case KTestCaseInputNew: |
|
452 retValue = TestCaseInputNewL(section, aResult); |
|
453 break; |
|
454 case KTestCaseInputNewWithParam: |
|
455 retValue = TestCaseInputNewWithParamL(section, aResult); |
|
456 break; |
|
457 case KTestCaseInputSetAudioProperties: |
|
458 retValue = TestCaseInputSetPropL(section, aResult); |
|
459 break; |
|
460 case KTestCaseInputSetGain: |
|
461 retValue = TestCaseInputSetGainL(section, aResult); |
|
462 break; |
|
463 case KTestCaseInputSetBalance: |
|
464 retValue = TestCaseInputSetBalanceL(section, aResult); |
|
465 break; |
|
466 case KTestCaseInputSetPriority: |
|
467 retValue = TestCaseInputSetPriorityL(section, aResult); |
|
468 break; |
|
469 case KTestCaseInputSetDataType: |
|
470 retValue = TestCaseInputSetDataTypeL(section, aResult); |
|
471 break; |
|
472 case KTestCaseInputOpen: |
|
473 retValue = TestCaseInputOpenL(section, aResult); |
|
474 break; |
|
475 case KTestCaseInputRecord: |
|
476 retValue = TestCaseInputRecordL(section, aResult); |
|
477 break; |
|
478 case KTestCaseInputBitRate: |
|
479 retValue = TestCaseInputBitRateL(section, aResult); |
|
480 break; |
|
481 |
|
482 // Audio Output Stream Test Cases |
|
483 case KTestCaseOutputNew: |
|
484 retValue = TestCaseOutputNewL(section, aResult); |
|
485 break; |
|
486 case KTestCaseOutputNewWithParam: |
|
487 retValue = TestCaseOutputNewWithParamL(section, aResult); |
|
488 break; |
|
489 case KTestCaseOutputSetAudioProperties: |
|
490 retValue = TestCaseOutputSetPropL(section, aResult); |
|
491 break; |
|
492 case KTestCaseOutputOpen: |
|
493 retValue = TestCaseOutputOpenL(section, aResult); |
|
494 break; |
|
495 case KTestCaseOutputSetVolume: |
|
496 retValue = TestCaseOutputSetVolumeL(section, aResult); |
|
497 break; |
|
498 case KTestCaseOutputSetPriority: |
|
499 retValue = TestCaseOutputSetPriorityL(section, aResult); |
|
500 break; |
|
501 case KTestCaseOutputPlay: |
|
502 retValue = TestCaseOutputPlayL(section, aResult); |
|
503 break; |
|
504 case KTestCaseOutputSetBalance: |
|
505 retValue = TestCaseOutputSetBalanceL(section, aResult); |
|
506 break; |
|
507 case KTestCaseOutputSetDataType: |
|
508 retValue = TestCaseOutputSetDataTypeL(section, aResult); |
|
509 break; |
|
510 case KTestCaseOutputStop: |
|
511 retValue = TestCaseOutputStopL(section, aResult); |
|
512 break; |
|
513 |
|
514 default: |
|
515 aResult.iResultDes.Copy(KConfigInvalid()); |
|
516 aResult.iResult = KErrNotExecuted; |
|
517 } |
|
518 |
|
519 return retValue; |
|
520 } |
|
521 |
|
522 |
|
523 // ----------------------------------------------------------------------------- |
|
524 // CAudioStreamTestApp::OOMTestQueryL |
|
525 // Used to check if a particular test case should be run in OOM conditions and |
|
526 // which memory allocations should fail. |
|
527 // |
|
528 // NOTE: This method is virtual and must be implemented only if test case |
|
529 // should be executed using OOM conditions. |
|
530 // ----------------------------------------------------------------------------- |
|
531 // |
|
532 TBool CAudioStreamTestApp::OOMTestQueryL( |
|
533 const TFileName& /* aTestCaseFile */, |
|
534 const TInt /* aCaseNumber */, |
|
535 TOOMFailureType& /* aFailureType */, |
|
536 TInt& /* aFirstMemFailure */, |
|
537 TInt& /* aLastMemFailure */ ) |
|
538 { |
|
539 //_LIT( KOOMTestQueryL, "CAudioStreamTestApp::OOMTestQueryL" ); |
|
540 //iLogger->Log( KOOMTestQueryL ); |
|
541 |
|
542 return EFalse; |
|
543 |
|
544 } |
|
545 |
|
546 // ----------------------------------------------------------------------------- |
|
547 // CAudioStreamTestApp::OOMTestInitializeL |
|
548 // Used to perform the test environment setup for a particular OOM test case. |
|
549 // Test Modules may use the initialization file to read parameters for Test |
|
550 // Module initialization but they can also have their own configure file or |
|
551 // some other routine to initialize themselves. |
|
552 // |
|
553 // NOTE: This method is virtual and must be implemented only if test case |
|
554 // should be executed using OOM conditions. |
|
555 // ----------------------------------------------------------------------------- |
|
556 // |
|
557 void CAudioStreamTestApp::OOMTestInitializeL( |
|
558 const TFileName& /* aTestCaseFile */, |
|
559 const TInt /* aCaseNumber */ ) |
|
560 { |
|
561 } |
|
562 |
|
563 // ----------------------------------------------------------------------------- |
|
564 // CAudioStreamTestApp::OOMHandleWarningL |
|
565 // In some cases the heap memory allocation should be skipped, either due to |
|
566 // problems in the OS code or components used by the code being tested, or even |
|
567 // inside the tested components which are implemented this way on purpose (by |
|
568 // design), so it is important to give the tester a way to bypass allocation |
|
569 // failures. |
|
570 // |
|
571 // NOTE: This method is virtual and must be implemented only if test case |
|
572 // should be executed using OOM conditions. |
|
573 // ----------------------------------------------------------------------------- |
|
574 // |
|
575 void CAudioStreamTestApp::OOMHandleWarningL( |
|
576 const TFileName& /* aTestCaseFile */, |
|
577 const TInt /* aCaseNumber */, |
|
578 TInt& /* aFailNextValue */ ) |
|
579 { |
|
580 } |
|
581 |
|
582 // ----------------------------------------------------------------------------- |
|
583 // CAudioStreamTestApp::OOMTestFinalizeL |
|
584 // Used to perform the test environment cleanup for a particular OOM test case. |
|
585 // |
|
586 // NOTE: This method is virtual and must be implemented only if test case |
|
587 // should be executed using OOM conditions. |
|
588 // ----------------------------------------------------------------------------- |
|
589 // |
|
590 void CAudioStreamTestApp::OOMTestFinalizeL( |
|
591 const TFileName& /* aTestCaseFile */, |
|
592 const TInt /* aCaseNumber */ ) |
|
593 { |
|
594 } |
|
595 |
|
596 |
|
597 TMdaPriorityPreference CAudioStreamTestApp::IntToPriorityPreference (TInt aPriorityPreference) |
|
598 { |
|
599 switch (aPriorityPreference) |
|
600 { |
|
601 case 0: |
|
602 return EMdaPriorityPreferenceNone; break; |
|
603 case 1: |
|
604 return EMdaPriorityPreferenceTime; break; |
|
605 case 2: |
|
606 return EMdaPriorityPreferenceQuality; break; |
|
607 case 3: |
|
608 default: |
|
609 return EMdaPriorityPreferenceTimeAndQuality; break; |
|
610 } |
|
611 } |
|
612 |
|
613 HBufC8 *CAudioStreamTestApp::GetDescriptor8LC(const TFileName &aFileName) |
|
614 { |
|
615 TInt FileError, SoundSize=0; |
|
616 RFile file; |
|
617 RFs FsSession; |
|
618 HBufC8 *SoundFile; |
|
619 |
|
620 iLogger->Log(_L("Reading descriptor from file [%S]") , &aFileName ); |
|
621 iLogger->Log(_L("Connecting to File Server Session") ); |
|
622 FileError = FsSession.Connect(); |
|
623 if (FileError) |
|
624 { |
|
625 iLogger->Log(_L("File error (%d)") , FileError); |
|
626 User::LeaveIfError(FileError); |
|
627 } |
|
628 |
|
629 iLogger->Log(_L("Opening file to get size") ); |
|
630 FileError = file.Open(FsSession, aFileName, EFileStream); |
|
631 if (FileError) |
|
632 { |
|
633 iLogger->Log(_L("File error (%d)") , FileError); |
|
634 User::LeaveIfError(FileError); |
|
635 } |
|
636 FileError = file.Size(SoundSize); |
|
637 iLogger->Log(_L("File Size (%d)") , SoundSize); |
|
638 if (FileError) |
|
639 { |
|
640 iLogger->Log(_L("Error getting size") ); |
|
641 User::LeaveIfError(FileError); |
|
642 } |
|
643 |
|
644 SoundFile = HBufC8::NewLC(SoundSize); |
|
645 TPtr8 helper = SoundFile->Des(); |
|
646 FileError = file.Read( helper ); |
|
647 |
|
648 iLogger->Log(_L("Descriptor length [%d]") , SoundFile->Size() ); |
|
649 file.Close(); |
|
650 FsSession.Close(); |
|
651 return SoundFile; |
|
652 } |
|
653 |
|
654 TInt CAudioStreamTestApp::GetIntL(CStifSectionParser *aSection, |
|
655 const TDesC &aTag, TBool &aUsingDefault, |
|
656 const TInt &aDefaultInt, |
|
657 TBool aContinue) |
|
658 { |
|
659 TInt ParseError=KErrNotFound; |
|
660 TInt TempDelay=0; |
|
661 TInt ReturnValue=aDefaultInt; |
|
662 |
|
663 CStifItemParser *item; |
|
664 if (aContinue) |
|
665 { |
|
666 item = aSection->GetNextItemLineL(aTag); |
|
667 } |
|
668 else |
|
669 { |
|
670 item = aSection->GetItemLineL(aTag); |
|
671 } |
|
672 if (item) |
|
673 { |
|
674 CleanupStack::PushL(item); |
|
675 ParseError = item->GetInt(aTag, TempDelay) ; |
|
676 CleanupStack::PopAndDestroy(item); |
|
677 } |
|
678 |
|
679 if (ParseError) |
|
680 { //Integer not found, using defaults |
|
681 aUsingDefault=ETrue; |
|
682 } |
|
683 else |
|
684 { //Integer found. |
|
685 aUsingDefault=EFalse; |
|
686 ReturnValue=TempDelay; |
|
687 } |
|
688 |
|
689 if (ParseError) {iLogger->Log(_L("Error retrieving integer, [%S] not found"), &aTag);} |
|
690 iLogger->Log(_L("Integer read, value (%d)") , ReturnValue); |
|
691 return ReturnValue; |
|
692 } |
|
693 |
|
694 TTimeIntervalMicroSeconds32 CAudioStreamTestApp::GetTimeIntervalL(CStifSectionParser *aSection, |
|
695 const TDesC &aTag, |
|
696 TBool &aUsingDefault, |
|
697 const TTimeIntervalMicroSeconds32 &aDefaultDelay, |
|
698 TBool aContinue) |
|
699 { |
|
700 TInt ParseError=KErrNotFound; |
|
701 TInt TempDelay=0; |
|
702 TTimeIntervalMicroSeconds32 ReturnValue=aDefaultDelay; |
|
703 CStifItemParser *item; |
|
704 if (aContinue) |
|
705 { |
|
706 item = aSection->GetNextItemLineL(aTag); |
|
707 } |
|
708 else |
|
709 { |
|
710 item = aSection->GetItemLineL(aTag); |
|
711 } |
|
712 if (item) |
|
713 { |
|
714 CleanupStack::PushL(item); |
|
715 ParseError = item->GetInt(aTag, TempDelay) ; |
|
716 if (ParseError) |
|
717 { //Delay not found, using defaults |
|
718 aUsingDefault=ETrue; |
|
719 } |
|
720 else |
|
721 { //Delay found. |
|
722 aUsingDefault=EFalse; |
|
723 ReturnValue=TempDelay; |
|
724 } |
|
725 CleanupStack::PopAndDestroy(item); |
|
726 } |
|
727 if (ParseError) {iLogger->Log(_L("Error retrieving report delay"));} |
|
728 return ReturnValue; |
|
729 } |
|
730 |
|
731 TDesC& CAudioStreamTestApp::GetErrorDes(TInt aErr) |
|
732 { |
|
733 TInt err = Abs(aErr); |
|
734 if ( (err < 0) || (err > 46) ) |
|
735 { |
|
736 iErrBuf = KTestCaseResultFail; |
|
737 return iErrBuf; |
|
738 } |
|
739 |
|
740 iErrBuf = iErrName[err]; |
|
741 return iErrBuf; |
|
742 } |
|
743 |
|
744 |
|
745 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
746 |
|
747 // ----------------------------------------------------------------------------- |
|
748 // LibEntryL is a polymorphic Dll entry point |
|
749 // Returns: CTestModuleBase*: Pointer to Test Module object |
|
750 // ----------------------------------------------------------------------------- |
|
751 // |
|
752 EXPORT_C CTestModuleBase* LibEntryL() |
|
753 { |
|
754 return CAudioStreamTestApp::NewL(); |
|
755 |
|
756 } |
|
757 |
|
758 // ----------------------------------------------------------------------------- |
|
759 // SetRequirements handles test module parameters(implements evolution |
|
760 // version 1 for test module's heap and stack sizes configuring). |
|
761 // Returns: TInt: Symbian error code. |
|
762 // ----------------------------------------------------------------------------- |
|
763 // |
|
764 EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, |
|
765 TUint32& /*aParameterValid*/ ) |
|
766 { |
|
767 |
|
768 /* --------------------------------- NOTE --------------------------------- |
|
769 USER PANICS occurs in test thread creation when: |
|
770 1) "The panic occurs when the value of the stack size is negative." |
|
771 2) "The panic occurs if the minimum heap size specified is less |
|
772 than KMinHeapSize". |
|
773 KMinHeapSize: "Functions that require a new heap to be allocated will |
|
774 either panic, or will reset the required heap size to this value if |
|
775 a smaller heap size is specified". |
|
776 3) "The panic occurs if the minimum heap size specified is greater than |
|
777 the maximum size to which the heap can grow". |
|
778 Other: |
|
779 1) Make sure that your hardware or Symbian OS is supporting given sizes. |
|
780 e.g. Hardware might support only sizes that are divisible by four. |
|
781 ------------------------------- NOTE end ------------------------------- */ |
|
782 |
|
783 // Normally STIF uses default heap and stack sizes for test thread, see: |
|
784 // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize. |
|
785 // If needed heap and stack sizes can be configured here by user. Remove |
|
786 // comments and define sizes. |
|
787 |
|
788 /* |
|
789 aParameterValid = KStifTestModuleParameterChanged; |
|
790 |
|
791 CTestModuleParamVer01* param = CTestModuleParamVer01::NewL(); |
|
792 // Stack size |
|
793 param->iTestThreadStackSize= 16384; // 16K stack |
|
794 // Heap sizes |
|
795 param->iTestThreadMinHeap = 4096; // 4K heap min |
|
796 param->iTestThreadMaxHeap = 1048576;// 1M heap max |
|
797 |
|
798 aTestModuleParam = param; |
|
799 */ |
|
800 return KErrNone; |
|
801 |
|
802 } |
|
803 |
|
804 // ----------------------------------------------------------------------------- |
|
805 // E32Dll is a DLL entry point function |
|
806 // Returns: KErrNone: No error |
|
807 // ----------------------------------------------------------------------------- |
|
808 // |
|
809 #ifndef EKA2 // Hide Dll entry point to EKA2 |
|
810 GLDEF_C TInt E32Dll( |
|
811 TDllReason /*aReason*/) // Reason |
|
812 { |
|
813 return(KErrNone); |
|
814 |
|
815 } |
|
816 #endif // EKA2 |
|
817 |
|
818 |
|
819 |
|
820 // End of File |