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 CUIStore |
|
15 * class |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef UISTORE_H |
|
20 #define UISTORE_H |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32std.h> |
|
25 #include <e32base.h> |
|
26 |
|
27 #include <stifinternal/UIEngine.h> |
|
28 #include <stifinternal/UIStoreIf.h> |
|
29 #include <stifinternal/UIStoreContainer.h> |
|
30 |
|
31 #include <StifLogger.h> |
|
32 |
|
33 // CONSTANTS |
|
34 _LIT( KDefaultIni, "\\testframework\\testframework.ini" ); |
|
35 |
|
36 // Timeout for popups |
|
37 const TInt KDefaultPopupTimeout = 2100; // 35s. Note this is maximun time in |
|
38 // current implementation(used in |
|
39 // After()-method, 32bit). |
|
40 // Timeout for popups |
|
41 const TInt KRebootPopupTimeout = 1; |
|
42 |
|
43 // MACROS |
|
44 |
|
45 // DATA TYPES |
|
46 |
|
47 // Menu update type |
|
48 |
|
49 // FUNCTION PROTOTYPES |
|
50 // |
|
51 // FORWARD DECLARATIONS |
|
52 class CUIStoreIf; |
|
53 class CStartedTestCase; |
|
54 class CUIEngine; |
|
55 class CTestInfo; |
|
56 class CUIEngineContainer; |
|
57 class CStartedTestSet; |
|
58 class CUIStorePopup; |
|
59 |
|
60 // DESCRIPTION |
|
61 // CUIStore class |
|
62 class CUIStore |
|
63 :public CUIIf |
|
64 { |
|
65 public: // Enumerations |
|
66 |
|
67 private: // Enumerations |
|
68 |
|
69 // Popup priorities |
|
70 enum TPopupPriority |
|
71 { |
|
72 EPopupPriorityHighest, |
|
73 EPopupPriorityNormal, |
|
74 EPopupPriorityLow |
|
75 }; |
|
76 |
|
77 public: // Constructors and destructor |
|
78 |
|
79 /** |
|
80 * NewL is first phase of two-phased constructor. |
|
81 */ |
|
82 static CUIStore* NewL( CUIStoreIf* iUIStoreIf ); |
|
83 |
|
84 /** |
|
85 * Destructor of CUIStore. |
|
86 */ |
|
87 ~CUIStore(); |
|
88 |
|
89 |
|
90 public: // New functions |
|
91 |
|
92 /** |
|
93 * Used to open TestFramework. |
|
94 * |
|
95 * Returns Symbian OS error code. |
|
96 */ |
|
97 IMPORT_C TInt Open( const TDesC& aTestFrameworkIni = KNullDesC ); |
|
98 |
|
99 /** |
|
100 * Used to close TestFramework. |
|
101 * |
|
102 * Returns Symbian OS error code. |
|
103 */ |
|
104 IMPORT_C TInt Close(); |
|
105 |
|
106 /** |
|
107 * Used to add test module to test framework. |
|
108 * |
|
109 * Returns Symbian OS error code. |
|
110 */ |
|
111 IMPORT_C TInt AddTestModule( const TDesC& aModuleName, |
|
112 const TDesC& aIniFile = KNullDesC ); |
|
113 |
|
114 /** |
|
115 * Used to remove test module to test framework. |
|
116 * |
|
117 * Returns Symbian OS error code. |
|
118 */ |
|
119 IMPORT_C TInt RemoveTestModule( const TDesC& aModuleName ); |
|
120 |
|
121 /** |
|
122 * Used to add test case file for test module. |
|
123 * |
|
124 * Returns Symbian OS error code. |
|
125 */ |
|
126 IMPORT_C TInt AddTestCaseFile( const TDesC& aModuleName, |
|
127 const TDesC& aCaseFile ); |
|
128 |
|
129 /** |
|
130 * Used to remove test case file from test module. |
|
131 * |
|
132 * Returns Symbian OS error code. |
|
133 */ |
|
134 IMPORT_C TInt RemoveTestCaseFile( const TDesC& aModuleName, |
|
135 const TDesC& aCaseFile ); |
|
136 |
|
137 /** |
|
138 * Start selected test case identified with CTestInfo. |
|
139 * anIndex contains index in StartedTestCase array, |
|
140 * which is valid only during execution of calling |
|
141 * function. |
|
142 * |
|
143 * Returns Symbian OS error code. |
|
144 */ |
|
145 IMPORT_C TInt StartTestCase( const CTestInfo& aTestInfo, |
|
146 TInt& anIndex ); |
|
147 |
|
148 /** |
|
149 * Return array of existing test cases. |
|
150 */ |
|
151 IMPORT_C TInt TestCases( RRefArray<CTestInfo>& aTestCases, |
|
152 const TDesC& aTestModule = (TDesC&) KNullDesC(), |
|
153 const TDesC& aTestCaseFile = (TDesC&) KNullDesC() ); |
|
154 |
|
155 |
|
156 |
|
157 /** |
|
158 * Return started (running/runned) test case |
|
159 */ |
|
160 IMPORT_C CStartedTestCase& StartedTestCaseL( TInt anIndex ); |
|
161 |
|
162 /** |
|
163 * Return started (running/runned) test cases |
|
164 */ |
|
165 IMPORT_C TInt StartedTestCases( RRefArray<CStartedTestCase>& aTestCases, |
|
166 TInt aStatus = CUIStoreIf::EStatusAll, |
|
167 const TDesC& aTestModule = (TDesC&) KNullDesC(), |
|
168 const TDesC& aTestCaseFile = (TDesC&) KNullDesC() ); |
|
169 |
|
170 /** |
|
171 * Return modules array |
|
172 */ |
|
173 IMPORT_C TInt Modules( RRefArray<TDesC>& aTestModules ); |
|
174 |
|
175 /** |
|
176 * Return test case files |
|
177 */ |
|
178 IMPORT_C TInt TestCaseFiles( RRefArray<TDesC>& aTestCaseFiles, |
|
179 const TDesC& aTestModule = (TDesC&) KNullDesC() ); |
|
180 |
|
181 |
|
182 /** |
|
183 * Loads all TestFramework test modules from \sys\bin\ directories |
|
184 * of all drives. |
|
185 */ |
|
186 IMPORT_C TInt LoadAllModules(); |
|
187 |
|
188 /** |
|
189 * Lists all TestFramework test modules from \sys\bin\ directories |
|
190 * of all drives. |
|
191 */ |
|
192 IMPORT_C TInt ListAllModules( RPointerArray<TDesC>& aModuleNames ); |
|
193 |
|
194 |
|
195 /** |
|
196 * Test set support. |
|
197 */ |
|
198 |
|
199 /** |
|
200 * Create new test set. |
|
201 * |
|
202 * Returns Symbian OS error code. |
|
203 */ |
|
204 IMPORT_C TInt CreateTestSet( const TDesC& aSetName ); |
|
205 |
|
206 /** |
|
207 * Remove active test set. |
|
208 * |
|
209 * Returns Symbian OS error code. |
|
210 */ |
|
211 IMPORT_C TInt RemoveTestSet( const TDesC& aSetName ); |
|
212 |
|
213 /** |
|
214 * Query test sets. |
|
215 * |
|
216 * Returns Symbian OS error code. |
|
217 */ |
|
218 IMPORT_C TInt TestSets( RRefArray<CTestSetInfo>& aSetInfos ); |
|
219 |
|
220 /** |
|
221 * Query test set. |
|
222 * |
|
223 * Returns Symbian OS error code. |
|
224 */ |
|
225 IMPORT_C const CTestSetInfo& TestSetL( const TDesC& aSetName ); |
|
226 |
|
227 /** |
|
228 * Add test case to test set. |
|
229 * |
|
230 * Returns Symbian OS error code. |
|
231 */ |
|
232 IMPORT_C TInt AddToTestSet( const TDesC& aSetName, const CTestInfo& aTestInfo ); |
|
233 |
|
234 /** |
|
235 * Insert test case to test set. |
|
236 * |
|
237 * Returns Symbian OS error code. |
|
238 */ |
|
239 IMPORT_C TInt InsertToTestSet( const TDesC& aSetName, |
|
240 const CTestInfo& aTestInfo, |
|
241 TInt aPos ); |
|
242 |
|
243 /** |
|
244 * Remove test case from test set. |
|
245 * |
|
246 * Returns Symbian OS error code. |
|
247 */ |
|
248 IMPORT_C TInt RemoveFromTestSet( const TDesC& aSetName, const CTestInfo& aTestInfo ); |
|
249 |
|
250 /** |
|
251 * Save test set. Depreceated, SaveTestSet2 to be used instead |
|
252 * |
|
253 * Returns Symbian OS error code. |
|
254 */ |
|
255 IMPORT_C TInt SaveTestSet( const TDesC& aSetName ); |
|
256 |
|
257 /** |
|
258 * Save test set. |
|
259 * |
|
260 * Returns Symbian OS error code. |
|
261 */ |
|
262 IMPORT_C TInt CUIStore::SaveTestSet2( TDes& aSetName ); |
|
263 /** |
|
264 * Load test set. |
|
265 * |
|
266 * Returns Symbian OS error code. |
|
267 */ |
|
268 IMPORT_C TInt LoadTestSet( const TDesC& aSetName ); |
|
269 |
|
270 /** |
|
271 * Unload active test set. |
|
272 * |
|
273 * Returns Symbian OS error code. |
|
274 */ |
|
275 IMPORT_C TInt UnloadTestSet( const TDesC& aSetName ); |
|
276 |
|
277 |
|
278 /** |
|
279 * Load saved test cases. |
|
280 * |
|
281 * Returns Symbian OS error code. |
|
282 */ |
|
283 IMPORT_C TInt LoadSavedTestCases(); |
|
284 |
|
285 /** |
|
286 * Start selected test set identified with CTestSetInfo. |
|
287 * anIndex contains index in StartedTestSet array, |
|
288 * which is valid only during execution of calling |
|
289 * function. |
|
290 * |
|
291 * Returns Symbian OS error code. |
|
292 */ |
|
293 IMPORT_C TInt StartTestSet( const CTestSetInfo& aTestSetInfo, |
|
294 TInt& anIndex, |
|
295 CStartedTestSet::TSetType aType = |
|
296 CStartedTestSet::ESetSequential ); |
|
297 IMPORT_C TInt StartTestSet( const CTestSetInfo& aTestSetInfo, |
|
298 TInt& anIndex, |
|
299 CStartedTestSet::TSetType aType, |
|
300 TBool aNotStartedCasesMode); |
|
301 |
|
302 /** |
|
303 * Abort running test set. |
|
304 * |
|
305 * Returns Symbian OS error code. |
|
306 */ |
|
307 IMPORT_C TInt AbortTestSet( CStartedTestSet& aSetInfo ); |
|
308 |
|
309 /** |
|
310 * Return started (running/runned) test set |
|
311 * |
|
312 * Returns Symbian OS error code. |
|
313 */ |
|
314 IMPORT_C CStartedTestSet& StartedTestSetL( TInt anIndex ); |
|
315 |
|
316 /** |
|
317 * Return started (running/runned) test cases |
|
318 * |
|
319 * Returns Symbian OS error code. |
|
320 */ |
|
321 IMPORT_C TInt StartedTestSets( RRefArray<CStartedTestSet>& aTestCases, |
|
322 TInt aStatus = CUIStoreIf::ESetAll ); |
|
323 |
|
324 /** |
|
325 * Updates information stored about test set in file. |
|
326 * |
|
327 * Returns Symbian OS error code. |
|
328 */ |
|
329 IMPORT_C TInt UpdateTestSet(CTestSetInfo& aSetInfo); |
|
330 |
|
331 /** |
|
332 * Reads filters (if any) from initialization file. |
|
333 */ |
|
334 IMPORT_C void ReadFiltersL(RPointerArray<TDesC>& aFilters); |
|
335 |
|
336 /** |
|
337 * Creates list of available Test Sets. |
|
338 * |
|
339 * Returns Symbian OS error code. |
|
340 */ |
|
341 |
|
342 IMPORT_C TInt GetTestSetsList( RRefArray<TDesC>& aArray ); |
|
343 |
|
344 |
|
345 public: // Functions from base classes |
|
346 |
|
347 |
|
348 protected: // New functions |
|
349 // None |
|
350 |
|
351 protected: // Functions from base classes |
|
352 // None |
|
353 |
|
354 private: |
|
355 |
|
356 /** |
|
357 * C++ default constructor. |
|
358 */ |
|
359 CUIStore( CUIStoreIf* iUIStoreIf ); |
|
360 |
|
361 /** |
|
362 * By default Symbian OS constructor is private. |
|
363 */ |
|
364 void ConstructL(); |
|
365 |
|
366 /** |
|
367 * Test case executed. |
|
368 * |
|
369 * Returns Symbian OS error code. |
|
370 */ |
|
371 void TestExecuted ( CUIEngineContainer* aContainer, |
|
372 TFullTestResult& aFullTestResult ); |
|
373 |
|
374 /** |
|
375 * Progress information from Test case execution. |
|
376 * |
|
377 * Returns Symbian OS error code. |
|
378 */ |
|
379 TInt PrintProg ( CUIEngineContainer* aContainer, |
|
380 TTestProgress& aProgress ); |
|
381 |
|
382 /** |
|
383 * Error information from Test framework. |
|
384 * |
|
385 * Returns Symbian OS error code. |
|
386 */ |
|
387 TInt ErrorPrint( TErrorNotification& aError ); |
|
388 |
|
389 /** |
|
390 * Remote protocol messages handler. |
|
391 */ |
|
392 TInt RemoteMsg( CUIEngineContainer* aContainer, |
|
393 const TDesC& aMessage ); |
|
394 /** |
|
395 * Reboot indication handler. |
|
396 */ |
|
397 TInt GoingToReboot( CUIEngineContainer* aContainer, |
|
398 TRequestStatus& aStatus ); |
|
399 |
|
400 TInt MsgRemote( CUIEngineContainer* aContainer, |
|
401 CStifTFwIfProt& aReq, |
|
402 CStifTFwIfProt& aResp ); |
|
403 TInt MsgRemoteRun( CUIEngineContainer* aContainer, |
|
404 CStifTFwIfProt& aReq, |
|
405 CStifTFwIfProt& aResp ); |
|
406 TInt MsgRemoteTestCtl( CUIEngineContainer* aContainer, |
|
407 CStifTFwIfProt& aReq, |
|
408 CStifTFwIfProt& aResp ); |
|
409 TInt MsgRemoteEventCtl( CUIEngineContainer* aContainer, |
|
410 CStifTFwIfProt& aReq, |
|
411 CStifTFwIfProt& aResp ); |
|
412 |
|
413 /** |
|
414 * Asynchronous remote sendreceive message. |
|
415 */ |
|
416 TInt MsgRemoteSendReceive( CUIEngineContainer* aContainer, |
|
417 CStifTFwIfProt& aReq, |
|
418 CStifTFwIfProt& aResp ); |
|
419 |
|
420 /** |
|
421 * Initialize logger from UI engine. |
|
422 */ |
|
423 inline void InitializeLogger( CStifLogger* aLogger ) |
|
424 { iLogger = aLogger; }; |
|
425 |
|
426 /** |
|
427 * Set update flag. |
|
428 */ |
|
429 inline void RefreshAllCases() |
|
430 { iUpdateNeeded = ETrue; }; |
|
431 |
|
432 /** |
|
433 * Update test case list if required. |
|
434 */ |
|
435 TInt UpdateCases(); |
|
436 |
|
437 /** |
|
438 * Try to locate default initialization file. |
|
439 */ |
|
440 void CheckIniL( TFileName& aIni ); |
|
441 |
|
442 /** |
|
443 * Find testcase by container. |
|
444 */ |
|
445 TInt FindByContainer( CUIEngineContainer* const aContainer, |
|
446 CStartedTestCase*& aTestCase ); |
|
447 |
|
448 /** |
|
449 * Loads all TestFramework test modules from \sys\bin\ directories . |
|
450 */ |
|
451 void LoadAllModulesL(); |
|
452 |
|
453 /** |
|
454 * Lists all TestFramework test modules from \sys\bin\ directories. |
|
455 */ |
|
456 void ListAllModulesL( RPointerArray<TDesC>& aModuleNames ); |
|
457 |
|
458 /** |
|
459 * Find test set by name. |
|
460 */ |
|
461 TInt FindSetByName( const TDesC& aSetName, CTestSetInfo*& aSetInfo ); |
|
462 |
|
463 /** |
|
464 * Find test set by CStartedTestCase. |
|
465 */ |
|
466 TInt FindStartedSetByCase( const CStartedTestCase* aTestCase, |
|
467 CStartedTestSet*& aSet ); |
|
468 |
|
469 /** |
|
470 * Load test set. |
|
471 */ |
|
472 void LoadTestSetL( const TDesC& aSetName, const TDesC& aSetFileName ); |
|
473 |
|
474 /** |
|
475 * Save test set. |
|
476 */ |
|
477 void SaveTestSetL( CTestSetInfo& aSetInfo, const TDesC& aSetFileName ); |
|
478 |
|
479 /** |
|
480 * Updates in file information about test set. |
|
481 */ |
|
482 void UpdateTestSetL(CTestSetInfo& aSetInfo, const TDesC& aSetFileName); |
|
483 |
|
484 /** |
|
485 * Read the whole line from the file. |
|
486 */ |
|
487 void ReadLineL(RFile &file, TDes& buffer); |
|
488 |
|
489 /** |
|
490 * Write given line to the file and adds end of line. |
|
491 */ |
|
492 void WriteLineL(RFile &file, const TDesC& buffer); |
|
493 |
|
494 /** |
|
495 * Load saved executed test cases. |
|
496 * |
|
497 * Returns Symbian OS error code. |
|
498 */ |
|
499 void LoadExecutedTestCasesL(); |
|
500 |
|
501 /** |
|
502 * Load test modules and test case files used in |
|
503 * aTestCases if not already done. |
|
504 */ |
|
505 void LoadTestModulesAndTestCaseFilesL( const RRefArray<const CTestInfo>& aTestCases ); |
|
506 |
|
507 /** |
|
508 * Parse test set name from test set file name. |
|
509 */ |
|
510 TInt ParseTestSetName( const TDesC& aSetFileName, TPtrC& aSetName, TFileName& aFileName ); |
|
511 |
|
512 /** |
|
513 * Do remote popup. Added aPopupPriority parameter for prioritizing popups @js |
|
514 */ |
|
515 TInt RemotePopup( CUIEngineContainer* aContainer, |
|
516 const TDesC& aReq, |
|
517 CStifTFwIfProt* aResp, |
|
518 TPopupPriority aPopupPriority = EPopupPriorityLow); |
|
519 |
|
520 /** |
|
521 * Callback from UIStorePopup. |
|
522 */ |
|
523 TInt RemotePopupComplete( CUIStorePopup* aPopup, |
|
524 TInt aError, |
|
525 CUIEngineContainer* aContainer, |
|
526 CStifTFwIfProt* aResp, |
|
527 TKeyCode aKeyCode ); |
|
528 /** |
|
529 * Return slave id. |
|
530 */ |
|
531 inline TInt16 DevId(){ return 1; }; |
|
532 |
|
533 /** |
|
534 * Prints the highest priority popup from queue |
|
535 */ |
|
536 void SetRemotePopupFromQueue(); |
|
537 |
|
538 /** |
|
539 * Shuffles remote run result popups |
|
540 */ |
|
541 void ShuffleRemoteRunResultPopups( CUIStorePopup* aPopup ); |
|
542 |
|
543 public: //Data |
|
544 // Logger |
|
545 CStifLogger* iLogger; |
|
546 |
|
547 protected: // Data |
|
548 // None |
|
549 |
|
550 private: // Data |
|
551 RPointerArray<HBufC> iFileList; |
|
552 // Pointer to UI (up) |
|
553 CUIStoreIf* iUIStoreIf; |
|
554 |
|
555 // Pointer to UI engine (down) |
|
556 CUIEngine* iUIEngine; |
|
557 |
|
558 // Available test cases |
|
559 RPointerArray<CTestInfo> iTestCases; |
|
560 // Started test cases |
|
561 RPointerArray<CStartedTestCase> iStartedTestCases; |
|
562 |
|
563 // Available test sets |
|
564 RPointerArray<CTestSetInfo> iTestSets; |
|
565 // Started test sets |
|
566 RPointerArray<CStartedTestSet> iStartedTestSets; |
|
567 |
|
568 RPointerArray<CUIStorePopup> iPopups; |
|
569 |
|
570 // Flag for update for test case list required |
|
571 TBool iUpdateNeeded; |
|
572 |
|
573 // Tells if popup is already active |
|
574 TBool iPopupActive; |
|
575 |
|
576 // Priority of the currently active popup |
|
577 TPopupPriority iActivePopupPriority; |
|
578 |
|
579 TFileName iTestFrameworkIni; |
|
580 |
|
581 public: // Friend classes |
|
582 // None |
|
583 |
|
584 protected: // Friend classes |
|
585 // None |
|
586 |
|
587 private: // Friend classes |
|
588 friend class CUIStorePopup; |
|
589 |
|
590 }; |
|
591 |
|
592 #endif // UISTORE_H |
|
593 |
|
594 // End of File |
|