|
1 /* |
|
2 * Copyright (c) 2009 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: This file contains the header file of the |
|
15 * CScriptBase. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef SCRIPTRUNNERINTERNAL_H |
|
20 #define SCRIPTRUNNERINTERNAL_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <StifTestModule.h> |
|
24 #include <StifLogger.h> |
|
25 |
|
26 // CONSTANTS |
|
27 // None |
|
28 |
|
29 // MACROS |
|
30 #define ENTRY(A,B) \ |
|
31 { (TText*) L ##A, (StifTestFunction) &B } |
|
32 |
|
33 // DATA TYPES |
|
34 |
|
35 // For function pointer operations. If need a new method that calls |
|
36 // from testscriptclass the testscripter. Add method's enum definition |
|
37 // here and implement the new method also TestScripterInternal.h need |
|
38 // new implementations. |
|
39 enum TStifTSCallBackType |
|
40 { |
|
41 EStifTSCallClass, |
|
42 EStifTSGetObject, |
|
43 }; |
|
44 |
|
45 // FORWARD DECLARATIONS |
|
46 class CStifItemParser; |
|
47 class CTestScripter; |
|
48 class CScriptBase; |
|
49 |
|
50 // DATA TYPES |
|
51 typedef TInt (CScriptBase::* StifTestFunction)( CStifItemParser& ); |
|
52 class TStifFunctionInfo |
|
53 { |
|
54 public: |
|
55 const TText* iFunctionName; |
|
56 StifTestFunction iMethod; |
|
57 }; |
|
58 |
|
59 // FUNCTION PROTOTYPES |
|
60 // (Function pointer) Used to forward operations from test script class |
|
61 // to TestScripter. |
|
62 typedef TInt (*CallBackFunc)( CTestScripter* aTestScripter, |
|
63 TStifTSCallBackType aType, |
|
64 const TDesC& aLine ); |
|
65 // CLASS DECLARATION |
|
66 // None |
|
67 |
|
68 // DESCRIPTION |
|
69 // This a Test Module interface template |
|
70 // that does not really do anything. |
|
71 |
|
72 class CScriptBase |
|
73 :public CBase |
|
74 { |
|
75 public: // Enumerations |
|
76 |
|
77 private: // Enumerations |
|
78 |
|
79 public: // Constructors and destructor |
|
80 |
|
81 public: // New functions |
|
82 |
|
83 /** |
|
84 * Get reference to TestModuleIf API. |
|
85 */ |
|
86 IMPORT_C CTestModuleIf& TestModuleIf(); |
|
87 |
|
88 /** |
|
89 * Signal TestScripter to continue from waittestclass. |
|
90 */ |
|
91 IMPORT_C void Signal( TInt aError = KErrNone ); |
|
92 |
|
93 // Called from test class. TestScripter forwards |
|
94 // operations to other test class object. |
|
95 // aLine: in: <object name> <method name> <parameters> |
|
96 IMPORT_C TInt CallTestClass( const TDesC& aLine ); |
|
97 |
|
98 // Get TestClass object pointer. Use CallTestClass instead if |
|
99 // you can, use this only with your own risk!!! |
|
100 // aObjectName: in: <object name> |
|
101 IMPORT_C CScriptBase* GetTestObject( const TDesC& aObjectName ); |
|
102 |
|
103 // Result description can be set from within the test class method |
|
104 IMPORT_C void SetResultDescription(const TDesC& aDescription); |
|
105 |
|
106 public: |
|
107 |
|
108 /** |
|
109 * Runs a script line, must be implemented in derived class. |
|
110 */ |
|
111 virtual TInt RunMethodL( CStifItemParser& aItem ) = 0; |
|
112 |
|
113 /** |
|
114 * Destructor of CScriptBase. |
|
115 */ |
|
116 virtual ~CScriptBase(){ iSignalErrors.Reset(); iSignalErrors.Close(); }; |
|
117 |
|
118 protected: // New functions |
|
119 |
|
120 /** |
|
121 * Constructor. |
|
122 */ |
|
123 IMPORT_C CScriptBase( CTestModuleIf& aTestModuleIf ); |
|
124 |
|
125 /** |
|
126 * Internal fuction to run specified method. |
|
127 */ |
|
128 IMPORT_C virtual TInt RunInternalL( |
|
129 TStifFunctionInfo const aFunctions[], |
|
130 TInt aCount, |
|
131 CStifItemParser& aItem ); |
|
132 |
|
133 /** |
|
134 * Internal fuction to get const value defined in |
|
135 * [Define]...[Enddefine] section of script file |
|
136 */ |
|
137 IMPORT_C TInt GetConstantValue( const TDesC& aName, TDes& aValue ); |
|
138 |
|
139 |
|
140 /** |
|
141 * Internal fuction to get const value defined in |
|
142 * [Define]...[Enddefine] section of script file |
|
143 */ |
|
144 IMPORT_C TInt GetConstantValue( const TDesC& aName, TInt& aValue ); |
|
145 |
|
146 |
|
147 /** |
|
148 * Internal fuction to get const value defined in |
|
149 * [Define]...[Enddefine] section of script file |
|
150 */ |
|
151 IMPORT_C TInt GetConstantValue( const TDesC& aName, TReal& aValue ); |
|
152 |
|
153 /** |
|
154 * Internal fuction to set value of local variable |
|
155 */ |
|
156 IMPORT_C TInt SetLocalValue(const TDesC& aName, const TDesC& aValue); |
|
157 |
|
158 /** |
|
159 * Internal fuction to set value of local variable |
|
160 */ |
|
161 IMPORT_C TInt SetLocalValue(const TDesC& aName, const TInt aValue); |
|
162 |
|
163 /** |
|
164 * Internal fuction to set value of local variable |
|
165 */ |
|
166 IMPORT_C TInt SetLocalValue(const TDesC& aName, const TReal aValue); |
|
167 |
|
168 /** |
|
169 * Internal fuction to get value of local variable |
|
170 */ |
|
171 IMPORT_C TInt GetLocalValue(const TDesC& aName, TDes& aValue); |
|
172 |
|
173 /** |
|
174 * Internal fuction to get value of local variable |
|
175 */ |
|
176 IMPORT_C TInt GetLocalValue(const TDesC& aName, TInt& aValue); |
|
177 |
|
178 /** |
|
179 * Internal fuction to get value of local variable |
|
180 */ |
|
181 IMPORT_C TInt GetLocalValue(const TDesC& aName, TReal& aValue); |
|
182 |
|
183 protected: // Functions from base classes |
|
184 |
|
185 private: |
|
186 |
|
187 IMPORT_C void EnableSignal( TRequestStatus& aStatus ); |
|
188 |
|
189 IMPORT_C void CancelSignal(); |
|
190 |
|
191 // This set from TestScripter(Initializes function pointer to use) |
|
192 IMPORT_C void SetScripter( CallBackFunc aFunc, CTestScripter* aTestScripter ); |
|
193 |
|
194 public: // Data |
|
195 |
|
196 protected: // Data |
|
197 |
|
198 /** |
|
199 * Logger. |
|
200 */ |
|
201 CStifLogger* iLog; |
|
202 |
|
203 /** |
|
204 * Array for handling multiple 'waittestclass' given from testclass's |
|
205 * test configure file. |
|
206 */ |
|
207 RArray<TInt> iSignalErrors; |
|
208 |
|
209 private: // Data |
|
210 // Backpointer |
|
211 CTestModuleIf& iTestModuleIf; |
|
212 |
|
213 // Completed when test class signals continue script execution |
|
214 TRequestStatus* iStatus; |
|
215 |
|
216 // Backpointer to TestScripter |
|
217 CallBackFunc iFunc; |
|
218 |
|
219 // Backpointer |
|
220 CTestScripter* iTestScripter; |
|
221 |
|
222 public: // Friend classes |
|
223 |
|
224 protected: // Friend classes |
|
225 |
|
226 private: // Friend classes |
|
227 friend class CTestScripter; |
|
228 friend class CTestContinue; |
|
229 |
|
230 }; |
|
231 |
|
232 #endif // SCRIPTRUNNER_H |
|
233 |
|
234 // End of File |