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