mmfenh/advancedaudiocontroller/tsrc/advancedaudiocontrollertestmodule/ActiveScheduledTestModule/src/ActiveScheduledTestModuleBase.cpp
changeset 0 71ca22bcf22a
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Active Scheduler Test Module
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <StifTestInterface.h>
       
    21 #include "ActiveScheduledTestModuleBase.h"
       
    22 
       
    23 // EXTERNAL DATA STRUCTURES
       
    24 // None
       
    25 
       
    26 // EXTERNAL FUNCTION PROTOTYPES
       
    27 // None
       
    28 
       
    29 // CONSTANTS
       
    30 // None
       
    31 
       
    32 // MACROS
       
    33 // None
       
    34 
       
    35 // LOCAL CONSTANTS AND MACROS
       
    36 // None
       
    37 
       
    38 // MODULE DATA STRUCTURES
       
    39 // None
       
    40 
       
    41 // LOCAL FUNCTION PROTOTYPES
       
    42 // None
       
    43 
       
    44 // FORWARD DECLARATIONS
       
    45 // None
       
    46 
       
    47 // ==================== LOCAL FUNCTIONS =======================================
       
    48 // None
       
    49 
       
    50 
       
    51 /*-------------------------------------------------------------------------------
       
    52 
       
    53     DESCRIPTION
       
    54 
       
    55     This module contains the implementation of ActiveScheduledTestModuleBase class
       
    56 	member functions.
       
    57 
       
    58 -------------------------------------------------------------------------------*/
       
    59 
       
    60 // ================= MEMBER FUNCTIONS =========================================
       
    61 
       
    62 /*-------------------------------------------------------------------------------
       
    63 
       
    64     Class: CActiveScheduledTestModuleBase
       
    65 
       
    66     Method: CActiveScheduledTestModuleBase
       
    67 
       
    68     Description: Default constructor
       
    69 
       
    70     C++ default constructor can NOT contain any code, that might leave.
       
    71 
       
    72     Parameters:	None
       
    73     Return Values: None
       
    74     Errors/Exceptions: None
       
    75     Status: Draft
       
    76 
       
    77 ------------------------------------------------------------------------------- */
       
    78 CActiveScheduledTestModuleBase::CActiveScheduledTestModuleBase(TInt aMinTestCaseId, TInt aMaxTestCaseId, const TDesC &aTitleFormat)
       
    79 	:	iTitleFormat(aTitleFormat) ,
       
    80 		iOutputPrinter(0, iLogger, KDefaultConsoleTraceDescription, KDefaultTracePrefix) ,
       
    81 		iMaxTestCaseId(aMaxTestCaseId) ,
       
    82 		iMinTestCaseId(aMinTestCaseId)
       
    83     {}
       
    84 
       
    85 CActiveScheduledTestModuleBase::CActiveScheduledTestModuleBase
       
    86 	(
       
    87 		TInt aMinTestCaseId,
       
    88 		TInt aMaxTestCaseId,
       
    89 		const TDesC &aTitleFormat,
       
    90 		const TDesC &aConsoleTraceDescription,
       
    91 		const TDesC &aTracePrefix, TInt aPrintPriority
       
    92 	)
       
    93 	:	iTitleFormat(aTitleFormat) ,
       
    94 		iOutputPrinter(0, iLogger, aConsoleTraceDescription, aTracePrefix, aPrintPriority) ,
       
    95 		iMaxTestCaseId(aMaxTestCaseId) ,
       
    96 		iMinTestCaseId(aMinTestCaseId)
       
    97     {}
       
    98 
       
    99 	/* -------------------------------------------------------------------------------
       
   100     Class: CActiveScheduledTestModuleBase
       
   101     Method: ~CActiveScheduledTestModuleBase
       
   102     Description: Destructor
       
   103     Parameters:	None
       
   104     Return Values: None
       
   105     Errors/Exceptions: None
       
   106     Status: Draft
       
   107 ------------------------------------------------------------------------------- */
       
   108 CActiveScheduledTestModuleBase::~CActiveScheduledTestModuleBase()
       
   109     {
       
   110 		delete iScheduler;
       
   111 		delete iLogger;
       
   112     }
       
   113 
       
   114 /* -------------------------------------------------------------------------------
       
   115     Class: CActiveScheduledTestModuleBase
       
   116     Method: ConstructL
       
   117     Description: Symbian OS second phase constructor
       
   118     Symbian OS default constructor can leave.
       
   119     Parameters:	None
       
   120     Return Values: None
       
   121     Errors/Exceptions: <description how errors and exceptions are handled>
       
   122     Status: Draft
       
   123 ------------------------------------------------------------------------------- */
       
   124 void CActiveScheduledTestModuleBase::ConstructL()
       
   125     {
       
   126 	iOutputPrinter.SetTestModule(this);
       
   127 	if ( ! iScheduler)
       
   128 		{
       
   129 		iScheduler = new (ELeave) CActiveScheduler;
       
   130 		CActiveScheduler::Install(iScheduler); // install as active scheduler
       
   131 		}
       
   132     }
       
   133 
       
   134 /*-------------------------------------------------------------------------------
       
   135 
       
   136     Class: CActiveScheduledTestModuleBase
       
   137 
       
   138     Method: InitL
       
   139     Description: Initialization function.
       
   140     Init is used to initialize the Test Module.
       
   141     Parameters:	TName& aIniFile: in: Filename:
       
   142                     Configuration file for the test module
       
   143 
       
   144     Return Values: KErrNone: No error
       
   145                    <value_1: Description
       
   146 		            value_n: Description line 1
       
   147 			                 description line 2>
       
   148 
       
   149     Errors/Exceptions: None
       
   150     Status: Draft
       
   151 
       
   152 ------------------------------------------------------------------------------- */
       
   153 TInt CActiveScheduledTestModuleBase::InitL( TFileName& aIniFile , TBool /*aFirstTime*/ )
       
   154     {
       
   155 	CStifParser *parser=0;
       
   156 
       
   157 	TParsePtrC fp(aIniFile);
       
   158 	TRAPD(parserError, parser = CStifParser::NewL(fp.DriveAndPath() , fp.NameAndExt() )   );
       
   159 	if (!parserError && parser)
       
   160 		{
       
   161 		CleanupStack::PushL(parser);
       
   162 
       
   163 		if (parser)
       
   164 			{
       
   165 			CStifSectionParser *section;
       
   166 
       
   167 			section = parser->SectionL(KSectionStart, KSectionEnd);
       
   168 			CleanupStack::PushL(section);
       
   169 			if (section)
       
   170 				{
       
   171 				TPtrC logFileName;
       
   172 				TPtrC logPath;
       
   173 
       
   174 				if ( (section->GetLine(KLogFileTag, logFileName, ENoTag) == KErrNone)  && (section->GetLine(KLogPathTag, logPath, ENoTag) == KErrNone) )
       
   175 					{
       
   176 					InitLoggerL(logPath, logFileName);
       
   177 					}
       
   178 				}
       
   179 			if (!iLogger)
       
   180 				{
       
   181 				InitLoggerL();
       
   182 				}
       
   183 			iOutputPrinter.Printf(KLoggerStarted, &aIniFile);
       
   184 			CleanupStack::PopAndDestroy(section);
       
   185 			}
       
   186 
       
   187 		CleanupStack::PopAndDestroy(parser);
       
   188 		}
       
   189 	else
       
   190 		{
       
   191 		iLogger = 0;
       
   192 		}
       
   193 	iOutputPrinter.SetLogger(iLogger);
       
   194 
       
   195     TInt error = iLogger ? KErrNone : KErrNotFound;
       
   196 	return error;
       
   197 	}
       
   198 
       
   199 /* -------------------------------------------------------------------------------
       
   200 
       
   201     Class: CActiveScheduledTestModuleBase
       
   202     Method: InitLoggerL
       
   203     Description: Initialize the logger for this test module
       
   204     Parameters:	File name where to append data
       
   205     Return Values: Error value
       
   206     Errors/Exceptions: <description how errors and exceptions are handled>
       
   207     Status: Draft
       
   208 
       
   209 ------------------------------------------------------------------------------- */
       
   210 void CActiveScheduledTestModuleBase::InitLoggerL( const TFileName& aLogPath , const TFileName& aLogFile)
       
   211     {
       
   212 		//iLogger = CStifLogger::NewL(aLogPath, aLogFile, ETxt, EFile, EFalse);	//, ETrue, ETrue, ETrue, ETrue, EFalse);
       
   213 		iLogger = CStifLogger::NewL(aLogPath, aLogFile, CStifLogger::ETxt, CStifLogger::EFile, EFalse) ;
       
   214 		if (  ! iLogger  )
       
   215 			{
       
   216 			InitLoggerL();
       
   217 			}
       
   218     }
       
   219 
       
   220 void CActiveScheduledTestModuleBase::InitLoggerL()
       
   221 	{
       
   222 	iLogger = CStifLogger::NewL(KDefLogPath, KDefLogFile, CStifLogger::ETxt, CStifLogger::EFile, EFalse);
       
   223 	}
       
   224 
       
   225 
       
   226 /* -------------------------------------------------------------------------------
       
   227     Class: CActiveScheduledTestModuleBase
       
   228     Method: GetTestCasesL
       
   229     Description: Get test cases.
       
   230     GetTestCases is used to inquire test cases from the Test Module. Test
       
   231     cases are stored to array of test cases. The Test Framework will be
       
   232     the owner of the data in the RPointerArray after GetTestCases return
       
   233     and it does the memory deallocation.
       
   234 
       
   235     Parameters:	const TFileName& aConfig: in: Test case file (optional)
       
   236                 RPointerArray<RTestEngine::TTestCaseInfo>& aTestCases: out:
       
   237                     Array of TestCases
       
   238 
       
   239     Return Values: KErrNone: No error
       
   240                    <value_1: Description
       
   241 		            value_n: Description line 1
       
   242 			                 description line 2>
       
   243     Errors/Exceptions: None
       
   244 ------------------------------------------------------------------------------- */
       
   245 TInt CActiveScheduledTestModuleBase::GetTestCasesL( const TFileName& aConfig , RPointerArray<TTestCaseInfo>& aTestCases )
       
   246     {
       
   247 
       
   248 	//Get a parser for the config file
       
   249 	iOutputPrinter.Printf(KOpeningConfig, &aConfig);
       
   250 
       
   251 	if (! aConfig.Length() ) {
       
   252 		iOutputPrinter.Printf(KConfigRequired() );
       
   253 		return KErrConfigInvalid;
       
   254 	}
       
   255 
       
   256 	TParsePtrC fp(aConfig);
       
   257 	CStifParser *parser = CStifParser::NewL(fp.DriveAndPath() , fp.NameAndExt() );
       
   258 	CleanupStack::PushL(parser);
       
   259 
       
   260 	if (!parser)
       
   261 		{
       
   262 		iOutputPrinter.Printf(KConfigRequired() );
       
   263 		return KErrPathNotFound;
       
   264 		}
       
   265 
       
   266 	//Get a section parser
       
   267 	CStifSectionParser *section;
       
   268 	TInt x = 0;
       
   269 
       
   270 	//Read all cases in config file
       
   271 	while ( (section = parser->NextSectionL(KTestCaseConfigStart , KTestCaseConfigEnd) ),section  )	// use comma to avoid warning
       
   272 		{
       
   273 		CleanupStack::PushL(section);
       
   274 		TInt id = -1;
       
   275 		TPtrC TestCaseTitle;
       
   276 		TInt ErrorResult = KErrNone;
       
   277 
       
   278 		CStifItemParser *item;
       
   279 		item = section->GetItemLineL(KTagId);
       
   280 		if (item)
       
   281 			{
       
   282 			CleanupStack::PushL(item);
       
   283 
       
   284 			if (!item->GetInt(KTagId, id))
       
   285 				{
       
   286 				ErrorResult = section->GetLine(KTagTitle, TestCaseTitle, ENoTag);
       
   287 				if (!ErrorResult) {iOutputPrinter.Printf( _L("Adding case: (%d) %S") , id, &TestCaseTitle ); }
       
   288 				}
       
   289 			else
       
   290 				{
       
   291 				id = -1;
       
   292 				}
       
   293 			CleanupStack::PopAndDestroy(item);
       
   294 			}
       
   295 
       
   296 		//Read test case id
       
   297 		//Read test case title
       
   298 		//if id is valid then add the test case
       
   299 		if (iMinTestCaseId<=id && id<=iMaxTestCaseId)
       
   300 			{
       
   301 			TTestCaseInfo* testCase = new ( ELeave ) TTestCaseInfo();
       
   302 			CleanupStack::PushL( testCase );
       
   303 			testCase->iCaseNumber = x++;
       
   304 
       
   305 			testCase->iTitle.Format(iTitleFormat, id, &TestCaseTitle);	//testCase->iTitle.Copy( KTestCaseTitleFormat() );
       
   306 
       
   307 			User::LeaveIfError( aTestCases.Append( testCase ) );
       
   308 
       
   309 			CleanupStack::Pop( testCase );
       
   310 			}
       
   311 		else
       
   312 			{
       
   313 			iOutputPrinter.Printf(_L("Skipping test with Id (%d)") , id);
       
   314 			}
       
   315 
       
   316 		CleanupStack::PopAndDestroy(section);
       
   317 		}
       
   318 
       
   319 	CleanupStack::PopAndDestroy(parser);
       
   320 
       
   321     return KErrNone;
       
   322     }
       
   323 
       
   324 /*
       
   325 -------------------------------------------------------------------------------
       
   326 
       
   327     Class: CActiveScheduledTestModuleBase
       
   328 
       
   329     Method: RunTestCaseL
       
   330 
       
   331     Description: Run a specified testcase.
       
   332 
       
   333     RunTestCaseL is used to run an individual test case specified
       
   334     by aTestCase. Test cases that can be run may be requested from
       
   335     Test Module by GetTestCases method before calling RunTestCase.
       
   336 
       
   337     Parameters:	const TInt aCaseNumber: in: case number
       
   338                 const TFileName& aConfig: in: Test case file (optional)
       
   339                 TTestResult& aResult: out: Test case result
       
   340 
       
   341     Return Values: KErrNone: Test case is started
       
   342                    KErrNotFound: Test case not available
       
   343                    <value_1: Description
       
   344 		            value_n: Description line 1
       
   345 			                 description line 2>
       
   346 
       
   347     Errors/Exceptions: None
       
   348 
       
   349     Status: Draft
       
   350 
       
   351 -------------------------------------------------------------------------------
       
   352 */
       
   353 TInt CActiveScheduledTestModuleBase::RunTestCaseL( const TInt aCaseNumber , const TFileName& aConfig , TTestResult& aResult )
       
   354     {
       
   355 	TInt id=-1;
       
   356 
       
   357 	//Get a parser for the config file
       
   358 	iOutputPrinter.Printf(KOpeningConfig, &aConfig);
       
   359 
       
   360 	if (! aConfig.Length() ) {
       
   361 		iOutputPrinter.Printf(KConfigRequired() );
       
   362 		aResult.iResultDes.Copy(KConfigRequired());
       
   363 		aResult.iResult = KErrNotExecuted;
       
   364 		return KErrConfigInvalid;
       
   365 	}
       
   366 
       
   367 	TParsePtrC fp(aConfig);
       
   368 	iOutputPrinter.Printf(_L("Opening configuration file [%S], case #%d"), &aConfig, aCaseNumber);
       
   369 	CStifParser *parser = CStifParser::NewL(fp.DriveAndPath() , fp.NameAndExt() );
       
   370 	CleanupStack::PushL(parser);
       
   371 
       
   372 	//Get a section parser
       
   373 	TInt retVal=0;
       
   374 	CStifSectionParser *section=0;
       
   375 	CStifItemParser *item=0;
       
   376 	section = parser->NextSectionL(KTestCaseConfigStart , KTestCaseConfigEnd, aCaseNumber+1);
       
   377 
       
   378 	if (section) {
       
   379 		CleanupStack::PushL(section);
       
   380 		item = section->GetItemLineL(KTagId);
       
   381 
       
   382 		if (item) {
       
   383 			CleanupStack::PushL(item);
       
   384 
       
   385 			if (!item->GetInt(KTagId, id)) {
       
   386 				TPtrC TestCaseTitle;
       
   387 
       
   388 				TInt TitleErrorResult = section->GetLine(KTagTitle, TestCaseTitle, ENoTag);
       
   389 				if (TitleErrorResult) { iOutputPrinter.Printf( _L("Executing test case (%d)") , id ); }
       
   390 				else { iOutputPrinter.Printf( _L("Executing test case (%d) %S") , id, &TestCaseTitle ); }
       
   391 
       
   392 				//Call Funtion to perform test
       
   393 				__UHEAP_MARK;
       
   394 				TRAPD(error, retVal = RunTestCaseFunctionL(id, section, aResult););
       
   395 				__UHEAP_MARKEND;
       
   396 
       
   397 				iOutputPrinter.Printf( _L("Finished Executing test case (%d), LeaveError=(%d)\r\n") , id, error);
       
   398 
       
   399 				if (error)
       
   400 					{
       
   401 					retVal = KErrLeft;
       
   402 					aResult.iResult=error;
       
   403 					aResult.iResultDes.Copy( KTestCaseResultLeft() );
       
   404 					}
       
   405 			} else {
       
   406 				id=-1;
       
   407 			}
       
   408 			CleanupStack::PopAndDestroy(item);
       
   409 		}
       
   410 		CleanupStack::PopAndDestroy(section);
       
   411 	}
       
   412 	CleanupStack::PopAndDestroy(parser);
       
   413 
       
   414 	if (-1!=id)
       
   415 	{
       
   416 		return retVal;
       
   417 	}
       
   418 	iOutputPrinter.Printf(KConfigInvalid() );
       
   419 	aResult.iResultDes.Copy(KConfigInvalid());
       
   420 	aResult.iResult = KErrNotFound;
       
   421 	return KErrNotFound;
       
   422     }
       
   423 
       
   424 TTimeIntervalMicroSeconds CActiveScheduledTestModuleBase::GetTimeIntervalL(CStifSectionParser *aSection, const TDesC &aTag, TBool &aUsingDefaults, const TTimeIntervalMicroSeconds &aDefaultInterval, TBool aContinue)
       
   425 	{
       
   426 	TInt TempInterval1=0 , TempInterval2=0;
       
   427 	TInt64 tmp=0;
       
   428 	TInt ParseError=KErrNotFound;
       
   429 	TTimeIntervalMicroSeconds ReturnValue = aDefaultInterval;
       
   430 	aUsingDefaults = ETrue;
       
   431 
       
   432 	CStifItemParser *item;
       
   433 	if (aContinue)
       
   434 		{
       
   435 		item = aSection->GetNextItemLineL(aTag);
       
   436 		}
       
   437 	else
       
   438 		{
       
   439 		item = aSection->GetItemLineL(aTag);
       
   440 		}
       
   441 	if (item)
       
   442 		{
       
   443 		CleanupStack::PushL(item);
       
   444 		ParseError = item->GetInt(aTag, TempInterval1) ;
       
   445 		if (!ParseError)
       
   446 			{
       
   447 			//First delay found.
       
   448 			aUsingDefaults = EFalse;
       
   449 			//tmp = TempInterval1*1000000;	//convert from seconds to microseconds
       
   450 			tmp = TempInterval1;
       
   451 			tmp*= 1000000;
       
   452 
       
   453 			if ( ! item->GetNextInt(TempInterval2) )
       
   454 				{
       
   455 				//tmp += TempInterval2*1000;	//add miliseconds
       
   456 				TInt64 tmp2 = TempInterval2;
       
   457 				tmp2 *= 1000;
       
   458 				tmp += tmp2;
       
   459 
       
   460 				if ( ! item->GetNextInt(TempInterval2) )
       
   461 					{
       
   462 					tmp += TempInterval2;
       
   463 					}
       
   464 				}
       
   465 			ReturnValue = tmp;
       
   466 			}
       
   467 		CleanupStack::PopAndDestroy(item);
       
   468 		}
       
   469 	if (ParseError) {iOutputPrinter.Printf(_L("Error retrieving interval"));}
       
   470 	iOutputPrinter.Printf(_L("Interval retrieved: (%d)") , ReturnValue);
       
   471 	return ReturnValue;
       
   472 	}
       
   473 
       
   474 TTimeIntervalMicroSeconds32 CActiveScheduledTestModuleBase::GetTimeIntervalL(CStifSectionParser *aSection, const TDesC &aTag, TBool &aUsingDefault, const TTimeIntervalMicroSeconds32 &aDefaultDelay, TBool aContinue)
       
   475 	{
       
   476 	TInt ParseError=KErrNotFound;
       
   477 	TInt TempDelay=0;
       
   478 	TTimeIntervalMicroSeconds32 ReturnValue=aDefaultDelay;
       
   479 	CStifItemParser *item;
       
   480 	if (aContinue)
       
   481 		{
       
   482 		item = aSection->GetNextItemLineL(aTag);
       
   483 		}
       
   484 	else
       
   485 		{
       
   486 		item = aSection->GetItemLineL(aTag);
       
   487 		}
       
   488 	if (item)
       
   489 		{
       
   490 		CleanupStack::PushL(item);
       
   491 		ParseError = item->GetInt(aTag, TempDelay) ;
       
   492 		if (ParseError)
       
   493 			{	//Delay not found, using defaults
       
   494 			aUsingDefault=ETrue;
       
   495 			}
       
   496 		else
       
   497 			{	//Delay found.
       
   498 			aUsingDefault=EFalse;
       
   499 			ReturnValue=TempDelay;
       
   500 			}
       
   501 			CleanupStack::PopAndDestroy(item);
       
   502 			}
       
   503 		if (ParseError) {iOutputPrinter.Printf(_L("Error retrieving report delay"));}
       
   504 	return ReturnValue;
       
   505 	}
       
   506 
       
   507 HBufC8 *CActiveScheduledTestModuleBase::GetDescriptor8LC(const TFileName &aFileName)
       
   508 	{
       
   509 	TInt FileError, SoundSize=0;
       
   510 	RFile file;
       
   511 	RFs FsSession;
       
   512 	HBufC8 *SoundFile;
       
   513 
       
   514 	iOutputPrinter.Printf(_L("Reading descriptor from file [%S]") , &aFileName );
       
   515 	iOutputPrinter.Printf(_L("Connecting to File Server Session") );
       
   516 	FileError = FsSession.Connect();
       
   517 	if (FileError)
       
   518 		{
       
   519 		iOutputPrinter.Printf(_L("File error (%d)") , FileError);
       
   520 		User::LeaveIfError(FileError);
       
   521 		}
       
   522 
       
   523 	iOutputPrinter.Printf(_L("Opening file to get size") );
       
   524 	FileError = file.Open(FsSession, aFileName, EFileStream);
       
   525 	if (FileError)
       
   526 		{
       
   527 		iOutputPrinter.Printf(_L("File error (%d)") , FileError);
       
   528 		User::LeaveIfError(FileError);
       
   529 		}
       
   530 	FileError = file.Size(SoundSize);
       
   531 	iOutputPrinter.Printf(_L("File Size (%d)") , SoundSize);
       
   532 	if (FileError)
       
   533 		{
       
   534 		iOutputPrinter.Printf(_L("Error getting size") );
       
   535 		User::LeaveIfError(FileError);
       
   536 		}
       
   537 
       
   538 	SoundFile = HBufC8::NewLC(SoundSize);
       
   539 	TPtr8 helper = SoundFile->Des();
       
   540 	FileError = file.Read( helper );
       
   541 
       
   542 	iOutputPrinter.Printf(_L("Descriptor length [%d]") , SoundFile->Size() );
       
   543 	file.Close();
       
   544 	FsSession.Close();
       
   545 	return SoundFile;
       
   546 	}
       
   547 
       
   548 TInt CActiveScheduledTestModuleBase::GetIntL(CStifSectionParser *aSection, const TDesC &aTag, TBool &aUsingDefault, const TInt &aDefaultInt, TBool aContinue)
       
   549 	{
       
   550 	TInt ParseError=KErrNotFound;
       
   551 	TInt TempDelay=0;
       
   552 	TInt ReturnValue=aDefaultInt;
       
   553 
       
   554 	CStifItemParser *item;
       
   555 	if (aContinue)
       
   556 		{
       
   557 		item = aSection->GetNextItemLineL(aTag);
       
   558 		}
       
   559 	else
       
   560 		{
       
   561 		 item = aSection->GetItemLineL(aTag);
       
   562 		}
       
   563 	if (item)
       
   564 		{
       
   565 		CleanupStack::PushL(item);
       
   566 		ParseError = item->GetInt(aTag, TempDelay) ;
       
   567 		CleanupStack::PopAndDestroy(item);
       
   568 		}
       
   569 
       
   570 	if (ParseError)
       
   571 		{	//Integer not found, using defaults
       
   572 		aUsingDefault=ETrue;
       
   573 		}
       
   574 	else
       
   575 		{	//Integer found.
       
   576 		aUsingDefault=EFalse;
       
   577 		ReturnValue=TempDelay;
       
   578 		}
       
   579 
       
   580 	if (ParseError) {iOutputPrinter.Printf(_L("Error retrieving integer, [%S] not found"), &aTag);}
       
   581 	iOutputPrinter.Printf(_L("Integer read, value (%d)") , ReturnValue);
       
   582 	return ReturnValue;
       
   583 	}
       
   584 
       
   585 TBool CActiveScheduledTestModuleBase::IsDurationInRange
       
   586 	(	TInt aRepeatTimes, TTimeIntervalMicroSeconds aToneDuration, TTimeIntervalMicroSeconds aRepeatSilence,
       
   587 		TTimeIntervalMicroSeconds aErrorRange , TTime aStartTime , TTime aEndTime )
       
   588 	{
       
   589 	TInt64 tmp=aToneDuration.Int64();
       
   590 	TInt64 tmp2=aRepeatSilence.Int64();
       
   591 
       
   592 	tmp*=(aRepeatTimes+1);  tmp2*=(aRepeatTimes+1);
       
   593 	TTimeIntervalMicroSeconds ExpectedDuration = tmp+tmp2;
       
   594 
       
   595 	TTime EndTimeRange1 = aStartTime;
       
   596 	EndTimeRange1+= ExpectedDuration;
       
   597 	TTime EndTimeRange2 = EndTimeRange1;
       
   598 	EndTimeRange1-=aErrorRange;
       
   599 	EndTimeRange2+=aErrorRange;
       
   600 
       
   601 	iOutputPrinter.Printf(_L("Play duration (%d)") , aEndTime.MicroSecondsFrom(aStartTime) );
       
   602 	iOutputPrinter.Printf(_L("Expected duration (%d)") , ExpectedDuration);
       
   603 	return (EndTimeRange1<aEndTime && aEndTime<EndTimeRange2) ;
       
   604 	}