messagingfw/biomsgfw/T_BIOMSG/INC/testframeutils.h
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     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 <e32std.h>
       
    17 #include <f32file.h>
       
    18 
       
    19 #ifndef TESTFRAMEUTILS_H
       
    20 #define TESTFRAMEUTILS_H
       
    21 
       
    22 class CTestSection;
       
    23 class CTestScript;
       
    24 
       
    25 class TTestDebugInfo
       
    26 {
       
    27 public:
       
    28 	HBufC* TestStartStringLC();
       
    29 	HBufC* TestCompleteStringLC();
       
    30 	HBufC* TestFailedStringL(TInt aReason);
       
    31 	HBufC* TestHarnessStringLC();
       
    32 	TInt LineNumber();
       
    33 	HBufC* CommandNameLC();
       
    34 
       
    35 	void SetTestHarnessName(TInt aTestHarnessPosition);
       
    36 
       
    37 	TTestDebugInfo(CTestScript& aTestScript, TInt aSectionPosition, TInt aCommandPosition);
       
    38 	TTestDebugInfo(CTestScript& aTestScript, TInt aSectionPosition, TInt aCommandPosition, TInt aLineNumber);
       
    39 	TTestDebugInfo();
       
    40 
       
    41 	inline CTestScript* ScriptFile() {return iScriptFile;}
       
    42 
       
    43 private:
       
    44 	HBufC* SectionNameLC();
       
    45 	HBufC* TestHarnessNameLC();
       
    46 	void StringFromErrNum(TInt aError, TDes& aDes);
       
    47 
       
    48 private:
       
    49 	CTestScript* iScriptFile;
       
    50 	TInt iSectionPosition;
       
    51 	TInt iCommandPosition;
       
    52 	TInt iTestHarnessPosition;
       
    53 	TInt iLineNumber;
       
    54 };
       
    55 
       
    56 
       
    57 
       
    58 //
       
    59 //
       
    60 // CTestScript
       
    61 //
       
    62 
       
    63 class CTestScript : public CBase
       
    64 	{
       
    65 public:
       
    66 	typedef TBuf8<128> TTestScriptString;
       
    67 
       
    68 	IMPORT_C static CTestScript* NewL(RFs& aFs);
       
    69 
       
    70 	IMPORT_C ~CTestScript();
       
    71 
       
    72 	IMPORT_C TBool LoadFileL(const TDesC& aFileName);
       
    73 	IMPORT_C CTestSection* GetSectionL(const TDesC& aSectionName);
       
    74 	IMPORT_C TBool GetLineL(TTestScriptString& aLine, TInt aPos);
       
    75 
       
    76 private:
       
    77 	void ConstructL();
       
    78 	CTestScript(RFs& aFs);
       
    79 	TBool GetLineL(TTestScriptString& aLine);
       
    80 	TBool IsSection(const TDesC8& aLine) const;
       
    81 	TBool IsSectionEnd(const TDesC8& aLine) const;
       
    82 	TBool IsComment(const TDesC8& aLine) const;
       
    83 	TBool GetNextCommandInSectionL(TTestScriptString& aCommand, TInt& aPosition, TInt& aLineNumber);
       
    84 
       
    85 private:
       
    86 	TBuf<512> iLastError;
       
    87 
       
    88 	struct TSectionPosition
       
    89 		{
       
    90 		TInt				iFilePosition;		// Start of commands
       
    91 		TInt				iSectionPosition;	// Start of header name
       
    92 		TTestScriptString	iSectionName;
       
    93 		TInt				iLineNumber;		// MU 20/11/00 added to aid error messages
       
    94 		};
       
    95 
       
    96 	CArrayFixFlat<TSectionPosition>* iSectionPositions;
       
    97 	TInt iCurrentSection;
       
    98 
       
    99 	RFile iFile;
       
   100 	RFs& iFs;
       
   101 	TBool iEndOfFile;
       
   102 	};
       
   103 
       
   104 
       
   105 //
       
   106 //
       
   107 // CTestSection
       
   108 //
       
   109 
       
   110 class CTestSection : public CBase
       
   111 	{
       
   112 public:
       
   113 	IMPORT_C static CTestSection* NewL(TInt aSectionPosition, const TDesC& aSectionName, TInt aLineNumber);
       
   114 	IMPORT_C TInt GetCurrentCommand(TDes& aCurrentCommand) const;
       
   115 	IMPORT_C TBool NextCommand();
       
   116 	IMPORT_C void AddCommandL(const CTestScript::TTestScriptString& aCommand, TInt aCommandPosition, TInt aLineNumber);
       
   117 	IMPORT_C TInt SectionPosition() const;
       
   118 	IMPORT_C TInt CurrentCommandPosition() const;
       
   119 	IMPORT_C const TDesC& SectionName() const;
       
   120 	IMPORT_C ~CTestSection();
       
   121 
       
   122 private:
       
   123 	CTestSection(TInt aSectionPosition, TInt aLineNumber);
       
   124 	void ConstructL();
       
   125 
       
   126 private:
       
   127 	struct TCommandInfo
       
   128 		{
       
   129 		CTestScript::TTestScriptString iCommand;
       
   130 		TInt iCommandPosition;
       
   131 		TInt iLineNumber;
       
   132 		};
       
   133 
       
   134 	CArrayFixFlat<TCommandInfo>* iCommandList;
       
   135 	TInt iCommandIndex;
       
   136 	TInt iSectionPosition;
       
   137 	TInt iLineNumber;
       
   138 	TBuf<128> iSectionName;
       
   139 	};
       
   140 
       
   141 
       
   142 
       
   143 #endif