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