|
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 ConsoleUI. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CONSOLE_UI_H |
|
19 #define CONSOLE_UI_H |
|
20 |
|
21 |
|
22 // INCLUDE |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> |
|
25 #include <e32twin.h> |
|
26 |
|
27 #include <stifinternal/UIStoreIf.h> |
|
28 #include <stifinternal/UIStore.h> |
|
29 #include <stifinternal/UIEngine.h> |
|
30 |
|
31 #include "CallBack.h" |
|
32 |
|
33 #include "TestModuleInfo.h" |
|
34 |
|
35 #include "ConsoleMenus.h" |
|
36 |
|
37 // CONSTANTS |
|
38 const TInt KMaxLineLength = 80; // Longest supported line length |
|
39 const TInt KScrollPeriod = 300000; // Scrolling speed |
|
40 |
|
41 // MACROS |
|
42 |
|
43 // DATA TYPES |
|
44 |
|
45 // Case state |
|
46 // Menu update type |
|
47 enum TConsoleUIPanic |
|
48 { |
|
49 EInvalidCaseCompletion, |
|
50 }; |
|
51 |
|
52 // FUNCTION PROTOTYPES |
|
53 |
|
54 // FORWARD DECLARATIONS |
|
55 class CMenu; |
|
56 class CConsoleMain; |
|
57 class CConsoleReader; |
|
58 class CMenuDialog; |
|
59 |
|
60 // CLASS DECLARATION |
|
61 |
|
62 // DESCRIPTION |
|
63 // CModule contains a test module data |
|
64 |
|
65 class CScrollerTimer |
|
66 :public CActive |
|
67 { |
|
68 public: // Enumerations |
|
69 // None |
|
70 |
|
71 private: // Enumerations |
|
72 |
|
73 public: // Constructors and destructor |
|
74 |
|
75 /** |
|
76 * NewL is first phase of two-phased constructor. |
|
77 */ |
|
78 static CScrollerTimer* NewL( CConsoleMain* aMain ); |
|
79 |
|
80 /** |
|
81 * Destructor of CModule. |
|
82 */ |
|
83 ~CScrollerTimer(); |
|
84 |
|
85 public: // New functions |
|
86 |
|
87 /** |
|
88 * StartL |
|
89 */ |
|
90 void StartL(); |
|
91 |
|
92 /** |
|
93 * RunL |
|
94 */ |
|
95 void RunL(); |
|
96 |
|
97 /** |
|
98 * DoCancel |
|
99 */ |
|
100 void DoCancel(); |
|
101 |
|
102 /** |
|
103 * RunError |
|
104 */ |
|
105 TInt RunError ( TInt aError ); |
|
106 |
|
107 public: // Functions from base classes |
|
108 |
|
109 protected: // New functions |
|
110 // None |
|
111 |
|
112 protected: // Functions from base classes |
|
113 // None |
|
114 |
|
115 private: |
|
116 |
|
117 /** |
|
118 * C++ default constructor. |
|
119 */ |
|
120 CScrollerTimer(); |
|
121 |
|
122 /** |
|
123 * By default Symbian OS constructor is private. |
|
124 */ |
|
125 void ConstructL( CConsoleMain* aMain ); |
|
126 |
|
127 public: //Data |
|
128 // None |
|
129 |
|
130 protected: // Data |
|
131 // None |
|
132 |
|
133 private: // Data |
|
134 CConsoleMain* iMain; // Pointer to main console |
|
135 RTimer iTimer; |
|
136 |
|
137 public: // Friend classes |
|
138 // None |
|
139 |
|
140 protected: // Friend classes |
|
141 // None |
|
142 |
|
143 private: // Friend classes |
|
144 // None |
|
145 |
|
146 }; |
|
147 |
|
148 // DESCRIPTION |
|
149 // Console UI main class |
|
150 class CConsoleMain |
|
151 :public CUIStoreIf |
|
152 { |
|
153 public: // Enumerations |
|
154 // None |
|
155 |
|
156 private: // Enumerations |
|
157 enum TStartCasesOnStart |
|
158 { |
|
159 EStartCaseNo = 0, |
|
160 EStartSingleCase, |
|
161 EStartCasesSeq, |
|
162 EStartCasesPar, |
|
163 }; |
|
164 |
|
165 public: // Constructors and destructor |
|
166 |
|
167 /** |
|
168 * NewL is first phase of two-phased constructor. |
|
169 */ |
|
170 static CConsoleMain* NewL(); |
|
171 |
|
172 /** |
|
173 * Start |
|
174 */ |
|
175 TInt StartL(); |
|
176 |
|
177 /** |
|
178 * Destructor of CConsoleMain. |
|
179 */ |
|
180 ~CConsoleMain(); |
|
181 |
|
182 |
|
183 public: // New functions |
|
184 |
|
185 |
|
186 /** |
|
187 * Receives output update notification from CUIStore. |
|
188 */ |
|
189 void Update( CStartedTestCase* aTestCase, |
|
190 TInt aFlags ); |
|
191 |
|
192 /** |
|
193 * Function is called when test framework prints error. |
|
194 */ |
|
195 void Error( TErrorNotification& aError ); |
|
196 |
|
197 /** |
|
198 * Function is called when testframework |
|
199 * wants to print a popup window. |
|
200 */ |
|
201 TInt PopupMsg( const TDesC& aLine1, |
|
202 const TDesC& aLine2, |
|
203 TInt aTimeInSecs ); |
|
204 |
|
205 /** |
|
206 * Function is called when testframework |
|
207 * wants to print a popup window and |
|
208 * get the key pressed. |
|
209 */ |
|
210 TInt PopupMsg( const TDesC& aLine1, |
|
211 const TDesC& aLine2, |
|
212 TInt aTimeInSecs, |
|
213 TKeyCode& aKey, |
|
214 TRequestStatus& aStatus ); |
|
215 |
|
216 /** |
|
217 * Close instance. |
|
218 */ |
|
219 void Close( TInt aHandle ); |
|
220 |
|
221 /** |
|
222 * Console UI panic function |
|
223 */ |
|
224 static void Panic( TConsoleUIPanic aPanic ); |
|
225 |
|
226 /** |
|
227 * Return pointer to console |
|
228 */ |
|
229 |
|
230 RConsole* GetConsole(); |
|
231 |
|
232 /** |
|
233 * Called from timer to perform scrolling |
|
234 */ |
|
235 void TimerUpdate(); |
|
236 |
|
237 /** |
|
238 * Process keystokes. |
|
239 */ |
|
240 void KeyPressed(); |
|
241 |
|
242 TKeyCode mapKey(); |
|
243 |
|
244 /** |
|
245 * Displays no memory error message and closes ConsoleUI |
|
246 */ |
|
247 void ExitWithNoMemoryErrorMessage(); |
|
248 |
|
249 /** |
|
250 * Returns MainMenu of console |
|
251 */ |
|
252 CMainMenu* GetMainMenu(); |
|
253 |
|
254 /** |
|
255 * Get filter array for reading purpose |
|
256 */ |
|
257 const RPointerArray<TDesC>& GetFilterArray(void) const; |
|
258 |
|
259 /** |
|
260 * Set info about which index filter is used |
|
261 */ |
|
262 void SetFilterIndex(TInt aFilterIndex); |
|
263 |
|
264 /** |
|
265 * Get info about which index filter is used |
|
266 */ |
|
267 TInt GetFilterIndex(void); |
|
268 |
|
269 public: // Functions from base classes |
|
270 |
|
271 protected: // New functions |
|
272 // None |
|
273 |
|
274 protected: // Functions from base classes |
|
275 // None |
|
276 |
|
277 private: |
|
278 |
|
279 /** |
|
280 * C++ default constructor. |
|
281 */ |
|
282 CConsoleMain(); |
|
283 |
|
284 /** |
|
285 * By default Symbian OS constructor is private. |
|
286 */ |
|
287 void ConstructL(); |
|
288 |
|
289 |
|
290 /** |
|
291 * Print error from ConsoleUI. |
|
292 */ |
|
293 void UiError( const TDesC& aInfo ); |
|
294 |
|
295 /** |
|
296 * Process command line parameters. |
|
297 */ |
|
298 void ProcessCommandlineL( TFileName& aIniFile ); |
|
299 |
|
300 /** |
|
301 * Parse and search for module info and fill list of modules. |
|
302 */ |
|
303 void ParseTestModulesL(CStifParser* aParser, CTestModuleList* aModuleList, const TDesC& aSectionStart, const TDesC& aSectionEnd); |
|
304 |
|
305 public: //Data |
|
306 RPointerArray<CMenuDialog> iDialogs; |
|
307 |
|
308 TConsoleKey key; |
|
309 |
|
310 protected: // Data |
|
311 // None |
|
312 |
|
313 private: // Data |
|
314 //CConsoleBase* iConsole; // Pointer to console |
|
315 RConsole iConsole; // Pointer to console |
|
316 TBool rConsoleCreated; |
|
317 |
|
318 CMenu* iMainMenu; // Root menu |
|
319 CMenu* iCurrentMenu; // Current menu |
|
320 |
|
321 CScrollerTimer* iScroller; |
|
322 |
|
323 CConsoleReader* iReader; // Console reader |
|
324 |
|
325 // For starting runnning multiple cases upon start |
|
326 TStartCasesOnStart iStartCases; |
|
327 HBufC* iTestModule; |
|
328 HBufC* iTestModuleIni; |
|
329 HBufC* iTestCaseFile; |
|
330 TInt iTestCaseNum; |
|
331 HBufC* iTestSetName; |
|
332 |
|
333 // List of found modules (included from module given in parameters) |
|
334 CTestModuleList* iModuleList; |
|
335 |
|
336 // List of filters (for test cases title) |
|
337 RPointerArray<TDesC> iFilters; |
|
338 |
|
339 // Chosen filter index |
|
340 TInt iChosenFilterIndex; |
|
341 |
|
342 public: // Friend classes |
|
343 // None |
|
344 |
|
345 protected: // Friend classes |
|
346 // None |
|
347 |
|
348 private: // Friend classes |
|
349 // None |
|
350 |
|
351 }; |
|
352 |
|
353 // DESCRIPTION |
|
354 // Read keystrokes from console |
|
355 class CConsoleReader |
|
356 :public CActive |
|
357 { |
|
358 public: // Enumerations |
|
359 // None |
|
360 |
|
361 private: // Enumerations |
|
362 // None |
|
363 |
|
364 public: // Constructors and destructor |
|
365 |
|
366 /** |
|
367 * NewL is first phase of two-phased constructor. |
|
368 */ |
|
369 static CConsoleReader* NewL( CConsoleMain* aMain, |
|
370 //CConsoleBase* aConsole ); |
|
371 RConsole* aConsole ); |
|
372 |
|
373 /** |
|
374 * Start |
|
375 */ |
|
376 void StartL(); |
|
377 |
|
378 /** |
|
379 * Destructor of CConsoleReader. |
|
380 */ |
|
381 ~CConsoleReader(); |
|
382 |
|
383 |
|
384 public: // New functions |
|
385 |
|
386 public: // Functions from base classes |
|
387 |
|
388 /** |
|
389 * RunL derived from CActive handles the completed requests. |
|
390 */ |
|
391 void RunL(); |
|
392 |
|
393 /** |
|
394 * DoCancel derived from CActive handles the Cancel |
|
395 */ |
|
396 void DoCancel(); |
|
397 /** |
|
398 * RunError derived from CActive handles errors from active object |
|
399 */ |
|
400 virtual TInt RunError(TInt aError); |
|
401 |
|
402 protected: // New functions |
|
403 // None |
|
404 |
|
405 protected: // Functions from base classes |
|
406 // None |
|
407 |
|
408 private: |
|
409 |
|
410 /** |
|
411 * C++ default constructor. |
|
412 */ |
|
413 CConsoleReader( CConsoleMain* aMain, |
|
414 //CConsoleBase* iConsole ); |
|
415 RConsole* iConsole ); |
|
416 |
|
417 /** |
|
418 * By default Symbian OS constructor is private. |
|
419 */ |
|
420 void ConstructL(); |
|
421 |
|
422 public: //Data |
|
423 // None |
|
424 |
|
425 protected: // Data |
|
426 // None |
|
427 |
|
428 private: // Data |
|
429 //CConsoleBase* iConsole; // Pointer to console |
|
430 RConsole* iConsole; // Pointer to console |
|
431 CConsoleMain* iMain; // Backpointer |
|
432 |
|
433 public: // Friend classes |
|
434 // None |
|
435 |
|
436 protected: // Friend classes |
|
437 // None |
|
438 |
|
439 private: // Friend classes |
|
440 // None |
|
441 |
|
442 }; |
|
443 |
|
444 #endif // CONSOLEUI_H |
|
445 |
|
446 // End of File |