messagingfw/biomsgfw/T_BIOMSG/SRC/testframeutils.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "testframeutils.h"
       
    17 
       
    18 _LIT(KCantOpenFile, "Could not open file: %S");
       
    19 _LIT(KSectionNotFound, "Could not find section: %S");
       
    20 _LIT(KMiscFileError, "File error");
       
    21 
       
    22 _LIT(KInfoTestFinished, "[%4d] Test finished: %S");
       
    23 _LIT(KInfoTestStarted, "[%4d] Starting test: %S");
       
    24 _LIT(KInfoTestError, "[%4d] Test failed in section: %S, command %S, reason %S (%d)");
       
    25 
       
    26 TInt TTestDebugInfo::LineNumber()
       
    27 {
       
    28 	return iLineNumber;
       
    29 }
       
    30 
       
    31 HBufC* TTestDebugInfo::TestStartStringLC()
       
    32 {
       
    33 	TBuf<256> startString;
       
    34 	HBufC* sectionName = TestHarnessNameLC();
       
    35 	startString.Format(KInfoTestStarted, iLineNumber, sectionName);
       
    36 	CleanupStack::PopAndDestroy(sectionName);
       
    37 	HBufC* startStringHBufC = HBufC::NewLC(startString.Length());
       
    38 	(startStringHBufC->Des()).Copy(startString);
       
    39 	return startStringHBufC;
       
    40 }
       
    41 
       
    42 HBufC* TTestDebugInfo::TestCompleteStringLC()
       
    43 {
       
    44 	TBuf<256> startString;
       
    45 	HBufC* sectionName = TestHarnessNameLC();
       
    46 	startString.Format(KInfoTestFinished, iLineNumber, sectionName);
       
    47 	CleanupStack::PopAndDestroy(sectionName);
       
    48 	HBufC* startStringHBufC = HBufC::NewLC(startString.Length());
       
    49 	(startStringHBufC->Des()).Copy(startString);
       
    50 	return startStringHBufC;
       
    51 }
       
    52 
       
    53 HBufC* TTestDebugInfo::TestFailedStringL(TInt aReason)
       
    54 {
       
    55 	TBuf<256> failedString;
       
    56 	HBufC* sectionName = SectionNameLC();
       
    57 	HBufC* commandName = CommandNameLC();
       
    58 
       
    59 	TBuf<20> errName;
       
    60 	StringFromErrNum(aReason, errName);
       
    61 	failedString.Format(KInfoTestError, iLineNumber, sectionName, commandName, &errName, aReason);
       
    62 
       
    63 	CleanupStack::PopAndDestroy(2, sectionName);
       
    64 	HBufC* failedStringHBufC = HBufC::NewL(failedString.Length());
       
    65 	(failedStringHBufC->Des()).Copy(failedString);
       
    66 	return failedStringHBufC;
       
    67 }
       
    68 
       
    69 void TTestDebugInfo::SetTestHarnessName(TInt aTestHarnessPosition)
       
    70 {
       
    71 	iTestHarnessPosition = aTestHarnessPosition;
       
    72 }
       
    73 
       
    74 HBufC* TTestDebugInfo::SectionNameLC()
       
    75 {
       
    76 	TBuf8<128> sectionName;
       
    77 	iScriptFile->GetLineL(sectionName, iSectionPosition);
       
    78 	HBufC* sectionNameHBufC = HBufC::NewLC(sectionName.Length());
       
    79 	sectionNameHBufC->Des().Copy(sectionName);
       
    80 	return sectionNameHBufC;
       
    81 }
       
    82 
       
    83 HBufC* TTestDebugInfo::TestHarnessNameLC()
       
    84 {
       
    85 	TBuf8<128> sectionName;
       
    86 	iScriptFile->GetLineL(sectionName, iTestHarnessPosition);
       
    87 	HBufC* sectionNameHBufC = HBufC::NewLC(sectionName.Length());
       
    88 	sectionNameHBufC->Des().Copy(sectionName);
       
    89 	return sectionNameHBufC;
       
    90 }
       
    91 
       
    92 HBufC* TTestDebugInfo::CommandNameLC()
       
    93 {
       
    94 	TBuf8<128> commandName;
       
    95 	iScriptFile->GetLineL(commandName, iCommandPosition);
       
    96 	HBufC* commandNameHBufC = HBufC::NewLC(commandName.Length());
       
    97 	commandNameHBufC->Des().Copy(commandName);
       
    98 	return commandNameHBufC;
       
    99 }
       
   100 
       
   101 void TTestDebugInfo::StringFromErrNum(TInt aErr, TDes& aDes)
       
   102 {
       
   103 	switch (aErr)
       
   104 	{
       
   105 		case KErrNone:
       
   106 			aDes.Copy(_L("KErrNone"));
       
   107 			break;
       
   108 		case KErrNotFound:
       
   109 			aDes.Copy(_L("KErrNotFound"));
       
   110 			break;
       
   111 		case KErrGeneral:
       
   112 			aDes.Copy(_L("KErrGeneral"));
       
   113 			break;
       
   114 		case KErrCancel:
       
   115 			aDes.Copy(_L("KErrCancel"));
       
   116 			break;
       
   117 		case KErrNoMemory:
       
   118 			aDes.Copy(_L("KErrNoMemory"));
       
   119 			break;
       
   120 		case KErrNotSupported:
       
   121 			aDes.Copy(_L("KErrNotSupported"));
       
   122 			break;
       
   123 		case KErrArgument:
       
   124 			aDes.Copy(_L("KErrArgument"));
       
   125 			break;
       
   126 		case KErrTotalLossOfPrecision:
       
   127 			aDes.Copy(_L("KErrTotalLossOfPrecision"));
       
   128 			break;
       
   129 		case KErrBadHandle:
       
   130 			aDes.Copy(_L("KErrBadHandle"));
       
   131 			break;
       
   132 		case KErrOverflow:
       
   133 			aDes.Copy(_L("KErrOverflow"));
       
   134 			break;
       
   135 		case KErrUnderflow:
       
   136 			aDes.Copy(_L("KErrUnderflow"));
       
   137 			break;
       
   138 		case KErrAlreadyExists:
       
   139 			aDes.Copy(_L("KErrAlreadyExists"));
       
   140 			break;
       
   141 		case KErrPathNotFound:
       
   142 			aDes.Copy(_L("KErrPathNotFound"));
       
   143 			break;
       
   144 		case KErrDied:
       
   145 			aDes.Copy(_L("KErrDied"));
       
   146 			break;
       
   147 		case KErrInUse:
       
   148 			aDes.Copy(_L("KErrInUse"));
       
   149 			break;
       
   150 		case KErrServerTerminated:
       
   151 			aDes.Copy(_L("KErrServerTerminated"));
       
   152 			break;
       
   153 		case KErrServerBusy:
       
   154 			aDes.Copy(_L("KErrServerBusy"));
       
   155 			break;
       
   156 		case KErrCompletion:
       
   157 			aDes.Copy(_L("KErrCompletion"));
       
   158 			break;
       
   159 		case KErrNotReady:
       
   160 			aDes.Copy(_L("KErrNotReady"));
       
   161 			break;
       
   162 		case KErrUnknown:
       
   163 			aDes.Copy(_L("KErrUnknown"));
       
   164 			break;
       
   165 		case KErrCorrupt:
       
   166 			aDes.Copy(_L("KErrCorrupt"));
       
   167 			break;
       
   168 		case KErrAccessDenied:
       
   169 			aDes.Copy(_L("KErrAccessDenied"));
       
   170 			break;
       
   171 		case KErrLocked:
       
   172 			aDes.Copy(_L("KErrLocked"));
       
   173 			break;
       
   174 		case KErrWrite:
       
   175 			aDes.Copy(_L("KErrWrite"));
       
   176 			break;
       
   177 		case KErrDisMounted:
       
   178 			aDes.Copy(_L("KErrDisMounted"));
       
   179 			break;
       
   180 		case KErrEof:
       
   181 			aDes.Copy(_L("KErrEof"));
       
   182 			break;
       
   183 		case KErrDiskFull:
       
   184 			aDes.Copy(_L("KErrDiskFull"));
       
   185 			break;
       
   186 		case KErrBadDriver:
       
   187 			aDes.Copy(_L("KErrBadDriver"));
       
   188 			break;
       
   189 		case KErrBadName:
       
   190 			aDes.Copy(_L("KErrBadName"));
       
   191 			break;
       
   192 		case KErrCommsLineFail:
       
   193 			aDes.Copy(_L("KErrCommsLineFail"));
       
   194 			break;
       
   195 		case KErrCommsFrame:
       
   196 			aDes.Copy(_L("KErrCommsFrame"));
       
   197 			break;
       
   198 		case KErrCommsOverrun:
       
   199 			aDes.Copy(_L("KErrCommsOverrun"));
       
   200 			break;
       
   201 		case KErrCommsParity:
       
   202 			aDes.Copy(_L("KErrCommsParity"));
       
   203 			break;
       
   204 		case KErrTimedOut:
       
   205 			aDes.Copy(_L("KErrTimedOut"));
       
   206 			break;
       
   207 		case KErrCouldNotConnect:
       
   208 			aDes.Copy(_L("KErrCouldNotConnect"));
       
   209 			break;
       
   210 		case KErrCouldNotDisconnect:
       
   211 			aDes.Copy(_L("KErrCouldNotDisconnect"));
       
   212 			break;
       
   213 		case KErrDisconnected:
       
   214 			aDes.Copy(_L("KErrDisconnected"));
       
   215 			break;
       
   216 		case KErrBadLibraryEntryPoint:
       
   217 			aDes.Copy(_L("KErrBadLibraryEntryPoint"));
       
   218 			break;
       
   219 		case KErrBadDescriptor:
       
   220 			aDes.Copy(_L("KErrBadDescriptor"));
       
   221 			break;
       
   222 		case KErrAbort:
       
   223 			aDes.Copy(_L("KErrAbort"));
       
   224 			break;
       
   225 		case KErrTooBig:
       
   226 			aDes.Copy(_L("KErrTooBig"));
       
   227 			break;
       
   228 		case KErrDivideByZero:
       
   229 			aDes.Copy(_L("KErrDivideByZero"));
       
   230 			break;
       
   231 		case KErrBadPower:
       
   232 			aDes.Copy(_L("KErrBadPower"));
       
   233 			break;
       
   234 		case KErrDirFull:
       
   235 			aDes.Copy(_L("KErrDirFull"));
       
   236 			break;
       
   237 		case KErrHardwareNotAvailable:
       
   238 			aDes.Copy(_L("KErrHardwareNotAvailable"));
       
   239 			break;
       
   240 //		case KErrSessionClosed:
       
   241 //			aDes.Copy(_L("KErrSessionClosed"));
       
   242 //			break;
       
   243 //		case KErrPermissionDenied:
       
   244 //			aDes.Copy(_L("KErrPermissionDenied"));
       
   245 //			break;
       
   246 		default:
       
   247 			aDes.Copy(_L("Unknown"));
       
   248 	}
       
   249 }
       
   250 
       
   251 TTestDebugInfo::TTestDebugInfo(CTestScript& aTestScript, TInt aSectionPosition, TInt aCommandPosition, TInt aLineNumber) : iScriptFile(&aTestScript), iSectionPosition(aSectionPosition), iCommandPosition(aCommandPosition), iLineNumber(aLineNumber)
       
   252 {
       
   253 }	
       
   254 
       
   255 TTestDebugInfo::TTestDebugInfo(CTestScript& aTestScript, TInt aSectionPosition, TInt aCommandPosition) : iScriptFile(&aTestScript), iSectionPosition(aSectionPosition), iCommandPosition(aCommandPosition), iLineNumber(0)
       
   256 {
       
   257 }
       
   258 
       
   259 TTestDebugInfo::TTestDebugInfo() :  iScriptFile(0), iSectionPosition(0), iCommandPosition(0), iLineNumber(0)
       
   260 {
       
   261 }
       
   262 
       
   263 
       
   264 //
       
   265 //
       
   266 // CTestScript
       
   267 //
       
   268 
       
   269 EXPORT_C CTestScript::~CTestScript()
       
   270 	{
       
   271 	delete iSectionPositions;
       
   272 	iFile.Close();
       
   273 	}
       
   274 
       
   275 EXPORT_C CTestScript* CTestScript::NewL(RFs& aFs)
       
   276 	{
       
   277 	CTestScript* self = new (ELeave) CTestScript(aFs);
       
   278 	CleanupStack::PushL(self);
       
   279 	self->ConstructL();
       
   280 	CleanupStack::Pop(self);
       
   281 	return self;
       
   282 	}
       
   283 
       
   284 void CTestScript::ConstructL()
       
   285 	{
       
   286 	iSectionPositions = new (ELeave) CArrayFixFlat<TSectionPosition>(10);
       
   287 	}
       
   288 
       
   289 EXPORT_C TBool CTestScript::LoadFileL(const TDesC& aFileName)
       
   290 	{
       
   291 	iFile.Close();
       
   292 	TBool loaded = EFalse;
       
   293 
       
   294 	iSectionPositions->ResizeL(0);
       
   295 	iEndOfFile = EFalse;
       
   296 
       
   297 	TTestScriptString line;
       
   298 
       
   299 	TInt err = iFile.Open(iFs, aFileName, EFileShareAny);
       
   300 
       
   301 	if (err == KErrNone)
       
   302 	// Scan the file for file sections, eg. [section1]
       
   303 		{
       
   304 		TInt lineNumber = 0;
       
   305 		TSectionPosition section;
       
   306 		section.iSectionPosition = 0;
       
   307 		while (GetLineL(line))
       
   308 			{
       
   309 			lineNumber++;
       
   310 			if (IsSection(line))
       
   311 			// If the line is the start of a section then add it to the list.
       
   312 				{
       
   313 				// Strip the '[' and ']' characters
       
   314 				line = line.Mid(1, line.Size() - 2);
       
   315 
       
   316 				// Store the section name and the position
       
   317 				section.iSectionName = line;
       
   318 				section.iFilePosition = 0;
       
   319 				section.iLineNumber = lineNumber;
       
   320 				err = iFile.Seek(ESeekCurrent, section.iFilePosition);
       
   321 				iSectionPositions->AppendL(section);
       
   322 				}
       
   323 			section.iSectionPosition = 0;
       
   324 			err = iFile.Seek(ESeekCurrent, section.iSectionPosition);
       
   325 			}
       
   326 
       
   327 		loaded = ETrue;
       
   328 		}
       
   329 	else
       
   330 		{
       
   331 		iLastError.Format(KCantOpenFile, &aFileName);
       
   332 		}
       
   333 
       
   334 	return loaded;
       
   335 	}
       
   336 
       
   337 EXPORT_C CTestSection* CTestScript::GetSectionL(const TDesC& aSectionName)
       
   338 	{
       
   339 	CTestSection* newSection = 0;
       
   340 
       
   341 	TSectionPosition section;
       
   342 	TTestScriptString command;
       
   343 	TBool sectionFound = EFalse;
       
   344 
       
   345 	// Look for the section name in the array
       
   346 	TInt sectionIndex = iSectionPositions->Count();
       
   347 	TBuf<128> tempSectionNameU;
       
   348 	while ((sectionIndex--) && (!sectionFound))
       
   349 		{
       
   350 		tempSectionNameU.Copy(((*iSectionPositions)[sectionIndex]).iSectionName);
       
   351 		if (tempSectionNameU == aSectionName)
       
   352 			{
       
   353 			section = (*iSectionPositions)[sectionIndex];
       
   354 			sectionFound = ETrue;
       
   355 			}
       
   356 		}
       
   357 
       
   358 	if (!sectionFound)
       
   359 		{
       
   360 		iLastError.Format(KSectionNotFound, aSectionName);
       
   361 		}
       
   362 	else
       
   363 		{
       
   364 		newSection = CTestSection::NewL(section.iSectionPosition, tempSectionNameU, section.iLineNumber);
       
   365 		CleanupStack::PushL(newSection);
       
   366 		TInt err = iFile.Seek(ESeekStart, section.iFilePosition);
       
   367 		if (err == KErrNone)
       
   368 			{
       
   369 			TInt commandLineNumber = section.iLineNumber;
       
   370 			TInt commandPosition = 0;
       
   371 			iFile.Seek(ESeekCurrent, commandPosition);
       
   372 			while (GetNextCommandInSectionL(command, commandPosition, commandLineNumber))
       
   373 				{
       
   374 				newSection->AddCommandL(command, commandPosition, commandLineNumber);
       
   375 				commandPosition = 0;
       
   376 				iFile.Seek(ESeekCurrent, commandPosition);
       
   377 				}
       
   378 			}
       
   379 		else
       
   380 			{
       
   381 			iLastError = KMiscFileError;
       
   382 			}
       
   383 		CleanupStack::Pop(newSection);
       
   384 		}
       
   385 
       
   386 	return newSection;
       
   387 	}
       
   388 
       
   389 CTestScript::CTestScript(RFs& aFs) : iFs(aFs)
       
   390 	{
       
   391 	}
       
   392 
       
   393 TBool CTestScript::GetLineL(TTestScriptString& aLine)
       
   394 	{
       
   395 	TBool noError = EFalse;
       
   396 
       
   397 	TInt startPosition = 0;
       
   398 	// Save the current position
       
   399 	TInt err = iFile.Seek(ESeekCurrent, startPosition);
       
   400 
       
   401 	if (err == KErrNone)
       
   402 		{
       
   403 		// Read a block of data
       
   404 		TTestScriptString dataFromFile;
       
   405 		err = iFile.Read(dataFromFile);
       
   406 
       
   407 		if (err != KErrNone)
       
   408 			{
       
   409 			iLastError.Copy(KMiscFileError);
       
   410 			}
       
   411 		else
       
   412 			{
       
   413 			// Look for the cr/lf pair or the end of the line
       
   414 			TInt bytesOnLine = 0;
       
   415 			TBool finished = EFalse;
       
   416 			while (!finished)
       
   417 				{
       
   418 				if (bytesOnLine == dataFromFile.Size())
       
   419 					{
       
   420 					finished = ETrue;
       
   421 					}
       
   422 				else if (dataFromFile[bytesOnLine] == 0x0d)
       
   423 					{
       
   424 					finished = ETrue;
       
   425 					}
       
   426 				else
       
   427 					{
       
   428 					bytesOnLine++;
       
   429 					}
       
   430 				}
       
   431 
       
   432 			TInt startOfNextLine = startPosition + bytesOnLine + 1;
       
   433 			if (bytesOnLine+1 < dataFromFile.Size())
       
   434 				{
       
   435 				if (dataFromFile[bytesOnLine+1] == 0x0a)
       
   436 					{
       
   437 					startOfNextLine++;
       
   438 					}
       
   439 				}
       
   440 
       
   441 			// Seek to after the cr/lf pair
       
   442 			iFile.Seek(ESeekStart, startOfNextLine);
       
   443 
       
   444 			// Set the line
       
   445 			aLine.Copy(dataFromFile.Left(bytesOnLine));
       
   446 			
       
   447 			// Get rid of any trailing white-space
       
   448 			TInt whiteSpaceIndex = aLine.Size();
       
   449 			TBool noMoreWhiteSpace = EFalse;
       
   450 			while ((whiteSpaceIndex--) && (!noMoreWhiteSpace))
       
   451 				{
       
   452 				if ((aLine[whiteSpaceIndex] == ' ')
       
   453 					|| (aLine[whiteSpaceIndex] == '\t'))
       
   454 					{
       
   455 					aLine.SetLength(whiteSpaceIndex);
       
   456 					}
       
   457 				else
       
   458 					{
       
   459 					noMoreWhiteSpace = ETrue;
       
   460 					}
       
   461 				}
       
   462 
       
   463 			if (dataFromFile.Size() != 0)
       
   464 				{
       
   465 				noError = ETrue;
       
   466 				}
       
   467 			}
       
   468 		}
       
   469 
       
   470 	return noError;
       
   471 	}
       
   472 
       
   473 TBool CTestScript::IsSection(const TDesC8& aLine) const
       
   474 	{
       
   475 	TBool isSection = EFalse;
       
   476 
       
   477 	if (aLine.Size() > 2)
       
   478 		{
       
   479 		if (aLine[0] == '[' && (aLine[aLine.Size() - 1] == ']'))
       
   480 			{
       
   481 			isSection = ETrue;
       
   482 			}
       
   483 		}
       
   484 
       
   485 	return isSection;
       
   486 	}
       
   487 
       
   488 TBool CTestScript::IsSectionEnd(const TDesC8& aLine) const
       
   489 	{
       
   490 	TBool isSectionEnd = EFalse;
       
   491 
       
   492 	if (aLine.Length() == 1 && aLine[0] == '.')
       
   493 		{
       
   494 		isSectionEnd = ETrue;
       
   495 		}
       
   496 
       
   497 	return isSectionEnd;
       
   498 	}
       
   499 
       
   500 
       
   501 // MU 20-11-00 New command to determine if the aLine is a comment.
       
   502 TBool CTestScript::IsComment(const TDesC8& aLine) const
       
   503 	{
       
   504 	TBool isComment = EFalse;
       
   505 
       
   506 	if (aLine.Size() >= 2)
       
   507 		{
       
   508 		if (aLine[0] == '/' && aLine[1] == '/')
       
   509 			{
       
   510 			isComment = ETrue;
       
   511 			}
       
   512 		}
       
   513 
       
   514 	return isComment;
       
   515 	}
       
   516 
       
   517 
       
   518 // MU 20-11-00 Changed this function to get the next "valid" command in section.
       
   519 //              This now allows the user to have comments within sections.
       
   520 //              Note:  the first blank line in a section denotes the end of a section.
       
   521 
       
   522 // MMS Test Harness: This function now takes the command position as a parameter.
       
   523 // This needs to be updated when a comment is read from the file, in order
       
   524 // to set the next command's position correctly.
       
   525 TBool CTestScript::GetNextCommandInSectionL(TTestScriptString& aCommand, TInt& aPosition, TInt& aLineNumber)
       
   526 	{
       
   527 	TBool commandFound;
       
   528 
       
   529 	do 	{
       
   530 			GetLineL(aCommand);
       
   531 			aLineNumber++;
       
   532 			// if the command is a comment, update the next command's
       
   533 			// position in the file (including the cr/lf)
       
   534 			if ((aCommand.Size() > 0) && (IsComment(aCommand)))
       
   535 				aPosition += aCommand.Size() + 2;
       
   536 		}
       
   537 	while (aCommand.Size() > 0 && IsComment(aCommand));
       
   538 
       
   539 	if(aCommand.Size() > 0 && !IsSection(aCommand) && !IsSectionEnd(aCommand))
       
   540 		commandFound = ETrue;
       
   541 	else
       
   542 		commandFound = EFalse;
       
   543 	
       
   544 	return commandFound;
       
   545 	}
       
   546 
       
   547 EXPORT_C TBool CTestScript::GetLineL(TTestScriptString& aLine, TInt aPos)
       
   548 	{
       
   549 	TBool lineFound = EFalse;
       
   550 	TInt err = iFile.Seek(ESeekStart, aPos);
       
   551 	if (err == KErrNone)
       
   552 		{
       
   553 		lineFound = GetLineL(aLine);
       
   554 		}
       
   555 
       
   556 	return lineFound;
       
   557 	}
       
   558 
       
   559 
       
   560 
       
   561 //
       
   562 //
       
   563 // CTestSection
       
   564 //
       
   565 EXPORT_C CTestSection* CTestSection::NewL(TInt aSectionPosition, const TDesC& aSectionName, TInt aLineNumber)
       
   566 	{
       
   567 	CTestSection* self = new (ELeave) CTestSection(aSectionPosition, aLineNumber);
       
   568 	CleanupStack::PushL(self);
       
   569 	self->ConstructL();
       
   570 	self->iSectionName = aSectionName;
       
   571 	CleanupStack::Pop(self);
       
   572 	return self;
       
   573 	}
       
   574 
       
   575 
       
   576 // Returns current command line number if found
       
   577 EXPORT_C TInt CTestSection::GetCurrentCommand(TDes& aCurrentCommand) const
       
   578 	{
       
   579 	TInt currentCommand = 0;
       
   580 
       
   581 	if (iCommandIndex < iCommandList->Count())
       
   582 		{
       
   583 		aCurrentCommand.Copy((*iCommandList)[iCommandIndex].iCommand);
       
   584 		currentCommand = (*iCommandList)[iCommandIndex].iLineNumber;
       
   585 		}
       
   586 	
       
   587 	return currentCommand;
       
   588 	}
       
   589 
       
   590 EXPORT_C TBool CTestSection::NextCommand()
       
   591 	{
       
   592 	TBool nextCommandFound = EFalse;
       
   593 
       
   594 	if ((iCommandIndex + 1) < iCommandList->Count())
       
   595 		{
       
   596 		nextCommandFound = ETrue;
       
   597 		}
       
   598 
       
   599 	iCommandIndex++;
       
   600 
       
   601 	return nextCommandFound;
       
   602 	}
       
   603 
       
   604 EXPORT_C void CTestSection::AddCommandL(const CTestScript::TTestScriptString& aCommand, TInt aCommandPosition, TInt aLineNumber)
       
   605 	{
       
   606 	TCommandInfo command;
       
   607 	command.iCommand = aCommand;
       
   608 	command.iCommandPosition = aCommandPosition;
       
   609 	command.iLineNumber = aLineNumber;
       
   610 	iCommandList->AppendL(command);
       
   611 	}
       
   612 
       
   613 CTestSection::CTestSection(TInt aSectionPosition, TInt aLineNumber) : iSectionPosition(aSectionPosition), iLineNumber(aLineNumber)
       
   614 	{
       
   615 	}
       
   616 
       
   617 
       
   618 void CTestSection::ConstructL()
       
   619 	{
       
   620 	iCommandList = new (ELeave) CArrayFixFlat<TCommandInfo>(10);
       
   621 	}
       
   622 
       
   623 EXPORT_C CTestSection::~CTestSection()
       
   624 	{
       
   625 	delete iCommandList;
       
   626 	}
       
   627 
       
   628 EXPORT_C TInt CTestSection::SectionPosition() const
       
   629 	{
       
   630 	return iSectionPosition;
       
   631 	}
       
   632 
       
   633 EXPORT_C TInt CTestSection::CurrentCommandPosition() const
       
   634 	{
       
   635 	return (*iCommandList)[iCommandIndex].iCommandPosition;
       
   636 	}
       
   637 
       
   638 EXPORT_C const TDesC& CTestSection::SectionName() const
       
   639 	{
       
   640 	return iSectionName;
       
   641 	}