|
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 * CTestModuleController. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef TEST_MODULE_CONTROLLER_H |
|
20 #define TEST_MODULE_CONTROLLER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> |
|
25 #include <atslogger.h> |
|
26 #include <StifTestInterface.h> |
|
27 #include <stifinternal/TestServerClient.h> |
|
28 |
|
29 // CONSTANTS |
|
30 // None |
|
31 |
|
32 // MACROS |
|
33 // None |
|
34 |
|
35 // DATA TYPES |
|
36 // None |
|
37 |
|
38 // FUNCTION PROTOTYPES |
|
39 // None |
|
40 |
|
41 // FORWARD DECLARATIONS |
|
42 class CTestEngine; |
|
43 class CBufferArray; |
|
44 class CTestScripterController; |
|
45 class CTestModuleController; |
|
46 |
|
47 // CLASS DECLARATION |
|
48 // None |
|
49 |
|
50 // CErrorPrinter is an active object which handles the execute test case |
|
51 // asynchronous request. |
|
52 class CErrorPrinter : public CActive |
|
53 { |
|
54 public: // Enumerations |
|
55 |
|
56 private: // Enumerations |
|
57 |
|
58 public: // Constructors and destructor |
|
59 |
|
60 /** |
|
61 * NewL is first phase of two-phased constructor. |
|
62 */ |
|
63 static CErrorPrinter* NewL( CTestEngine* aTestEngine ); |
|
64 |
|
65 /** |
|
66 * Destructor of CErrorPrinter. |
|
67 */ |
|
68 virtual ~CErrorPrinter(); |
|
69 |
|
70 /** |
|
71 * Start |
|
72 */ |
|
73 TInt StartL( RTestModule& aEngine ); |
|
74 |
|
75 public: // New functions |
|
76 // None |
|
77 |
|
78 protected: // New functions |
|
79 // None |
|
80 |
|
81 private: |
|
82 /** |
|
83 * C++ default constructor. |
|
84 */ |
|
85 CErrorPrinter(); |
|
86 |
|
87 /** |
|
88 * By default Symbian OS constructor is private. |
|
89 */ |
|
90 void ConstructL( CTestEngine* aEngine ); |
|
91 |
|
92 public: // Functions from base classes |
|
93 |
|
94 /** |
|
95 * RunL derived from CActive handles the completed requests. |
|
96 */ |
|
97 void RunL(); |
|
98 |
|
99 /** |
|
100 * DoCancel derived from CActive handles the Cancel |
|
101 */ |
|
102 void DoCancel(); |
|
103 |
|
104 /** |
|
105 * RunError derived from CActive handles errors from active handler. |
|
106 */ |
|
107 TInt RunError( TInt aError ); |
|
108 |
|
109 protected: // New functions |
|
110 // None |
|
111 |
|
112 protected: // Functions from base classes |
|
113 // None |
|
114 |
|
115 private: // Functions from base classes |
|
116 // None |
|
117 |
|
118 public: // Data |
|
119 // None |
|
120 |
|
121 protected: // Data |
|
122 // None |
|
123 |
|
124 private: // Data |
|
125 CTestEngine* iEngine; // Pointer to main console |
|
126 |
|
127 TErrorNotification iError; // Error notification |
|
128 TErrorNotificationPckg iErrorPckg; // Error package |
|
129 RTestModule iServer; // Handle to TestModule |
|
130 |
|
131 public: // Friend classes |
|
132 // None |
|
133 |
|
134 protected: // Friend classes |
|
135 // None |
|
136 |
|
137 private: // Friend classes |
|
138 // None |
|
139 |
|
140 }; |
|
141 // CLASS DECLARATION |
|
142 |
|
143 // DESCRIPTION |
|
144 // CServerStateHandler class is an active object that handles server state |
|
145 // e.g. KErrServerTerminated |
|
146 NONSHARABLE_CLASS( CServerStateHandler ) |
|
147 : public CActive |
|
148 { |
|
149 |
|
150 public: // Enumerations |
|
151 |
|
152 private: // Enumerations |
|
153 |
|
154 public: // Constructors and destructor |
|
155 |
|
156 /** |
|
157 * NewL is first phase of two-phased constructor. |
|
158 */ |
|
159 static CServerStateHandler* NewL( CTestEngine* aTestEngine, CTestModuleController* aTestModuleController ); |
|
160 |
|
161 /** |
|
162 * Destructor of CServerStateHandler. |
|
163 */ |
|
164 virtual ~CServerStateHandler(); |
|
165 |
|
166 public: // New functions |
|
167 |
|
168 /** |
|
169 * Start monitoring |
|
170 */ |
|
171 TInt StartL( RTestServer& aServer ); |
|
172 |
|
173 public: // Functions from base classes |
|
174 |
|
175 /** |
|
176 * RunL derived from CActive handles the completed requests. |
|
177 */ |
|
178 void RunL(); |
|
179 |
|
180 /** |
|
181 * DoCancel derived from CActive handles the Cancel |
|
182 */ |
|
183 void DoCancel(); |
|
184 |
|
185 /** |
|
186 * RunError derived from CActive handles errors from active handler. |
|
187 */ |
|
188 TInt RunError( TInt aError ); |
|
189 |
|
190 protected: // New functions |
|
191 // None |
|
192 |
|
193 protected: // Functions from base classes |
|
194 // None |
|
195 |
|
196 private: |
|
197 |
|
198 /** |
|
199 * C++ default constructor. |
|
200 */ |
|
201 CServerStateHandler( CTestEngine* aTestEngine, CTestModuleController* aTestModuleController ); |
|
202 |
|
203 /** |
|
204 * By default Symbian OS constructor is private. |
|
205 */ |
|
206 void ConstructL(); |
|
207 |
|
208 public: //Data |
|
209 // None |
|
210 |
|
211 protected: // Data |
|
212 // None |
|
213 |
|
214 private: // Data |
|
215 CTestEngine* iEngine; // Pointer to TestEngine |
|
216 RThread iServerThread; // Handle to TestServer thread |
|
217 CTestModuleController* iTestModuleController; //Pointer to TestModuleController |
|
218 public: // Friend classes |
|
219 // None |
|
220 |
|
221 protected: // Friend classes |
|
222 // None |
|
223 |
|
224 private: // Friend classes |
|
225 // None |
|
226 |
|
227 }; |
|
228 |
|
229 // DESCRIPTION |
|
230 // CTestModuleController is an active object used for controlling the test |
|
231 // module using the RTestModule API. |
|
232 |
|
233 class CTestModuleController |
|
234 : public CActive |
|
235 { |
|
236 public: // Enumerations |
|
237 // None |
|
238 |
|
239 private: // Enumerations |
|
240 |
|
241 protected: // Enumerations |
|
242 |
|
243 // TTestModuleStatus defines the status of test module |
|
244 enum TTestModuleStatus |
|
245 { |
|
246 ETestModuleIdle, |
|
247 ETestModuleEnumerateCases, |
|
248 ETestModuleEnumerateCasesCompleted, |
|
249 }; |
|
250 |
|
251 public: // Constructors and destructor |
|
252 |
|
253 /** |
|
254 * Two-phased constructor. |
|
255 */ |
|
256 static CTestModuleController* NewL( CTestEngine* aEngine, |
|
257 const TName& aName, |
|
258 TBool aAfterReboot, |
|
259 TBool aCreateTestScripterCont = EFalse, |
|
260 CTestScripterController* aTestScripterController = NULL ); |
|
261 |
|
262 /** |
|
263 * Destructor. |
|
264 */ |
|
265 virtual ~CTestModuleController(); |
|
266 |
|
267 public: // New functions |
|
268 |
|
269 /** |
|
270 * StartEnumerateL starts the CTestModuleController active object. |
|
271 */ |
|
272 virtual void StartEnumerateL(); |
|
273 |
|
274 /** |
|
275 * Init the test module |
|
276 */ |
|
277 virtual void InitL( TFileName& aIniFile, const TDesC& aConfigFile ); |
|
278 |
|
279 /** |
|
280 * Add config file |
|
281 */ |
|
282 virtual void AddConfigFileL( TFileName& aConfigFile ); |
|
283 |
|
284 /** |
|
285 * Remove config file |
|
286 */ |
|
287 virtual void RemoveConfigFileL( TFileName& aConfigFile ); |
|
288 |
|
289 /** |
|
290 * Get Test Cases |
|
291 */ |
|
292 virtual CFixedFlatArray<TTestInfo>* TestCasesL(); |
|
293 |
|
294 /** |
|
295 * Free used memory for test cases |
|
296 */ |
|
297 virtual void FreeTestCases(); |
|
298 |
|
299 /** |
|
300 * Return handle to Test Server |
|
301 */ |
|
302 virtual RTestServer& Server( TTestInfo& aTestInfo ); |
|
303 |
|
304 /** |
|
305 * Return the name of Test Module. |
|
306 */ |
|
307 virtual const TDesC& ModuleName( const TDesC& aModuleName ); |
|
308 |
|
309 /** |
|
310 * Return reference to AtsLogger |
|
311 */ |
|
312 virtual CAtsLogger& AtsLogger(){ return *iAtsLogger; }; |
|
313 |
|
314 /** |
|
315 * Is enumeration complete? |
|
316 */ |
|
317 virtual TBool EnumerationComplete(); |
|
318 |
|
319 /** |
|
320 * Returns pointer to the created clone of the TestModuleController |
|
321 */ |
|
322 virtual CTestModuleController* CloneL( CTestModuleController* aTestModuleController, TBool aAfterReset, CTestScripterController* aTestScripterController ); |
|
323 |
|
324 /** |
|
325 * Increases the value of iTestCaseCounter |
|
326 */ |
|
327 virtual void CaseCreated(); |
|
328 |
|
329 /** |
|
330 * Decreases the value of iTestCaseCounter and checks |
|
331 * can old testmodulecontroller deleted or not. |
|
332 */ |
|
333 virtual void CaseFinished(); |
|
334 |
|
335 public: // Functions from base classes |
|
336 |
|
337 /** |
|
338 * RunL derived from CActive handles the completed requests. |
|
339 */ |
|
340 virtual void RunL(); |
|
341 |
|
342 /** |
|
343 * DoCancel derived from CActive handles the cancellation |
|
344 */ |
|
345 virtual void DoCancel(); |
|
346 |
|
347 /** |
|
348 * RunError derived from CActive handles errors from active handler. |
|
349 */ |
|
350 virtual TInt RunError( TInt aError ); |
|
351 |
|
352 /** |
|
353 * Finds free test module controller, if not possible, creates new one. |
|
354 */ |
|
355 virtual CTestModuleController* GetFreeOrCreateModuleControllerL(TTestInfo& aTestInfo, TBool aUITestingSupport); |
|
356 |
|
357 /** |
|
358 * Deletes given module controller (used only in CTestScripterController). |
|
359 */ |
|
360 virtual void DeleteModuleController(CTestModuleController* aRealModuleController); |
|
361 |
|
362 /** |
|
363 * Removes given module controller from child list (used only in CTestScripterController). |
|
364 */ |
|
365 virtual void RemoveModuleController(CTestModuleController* aRealModuleController); |
|
366 |
|
367 /** |
|
368 * Enumerates test module controller synchronously. |
|
369 * This is used when new test module controller is created when stif |
|
370 * is about to run test case. |
|
371 */ |
|
372 virtual void EnumerateSynchronously(void); |
|
373 |
|
374 protected: // New functions |
|
375 // None |
|
376 |
|
377 protected: // Functions from base classes |
|
378 // None |
|
379 |
|
380 private: |
|
381 |
|
382 /** |
|
383 * By default Symbian OS constructor is private. |
|
384 */ |
|
385 void ConstructL( const TName& aName, |
|
386 TBool aAfterReboot, |
|
387 CTestScripterController* aTestScripterController ); |
|
388 |
|
389 /** |
|
390 * Generate error report to xml result file and leave with notify. |
|
391 */ |
|
392 void LeaveWithNotifyL( TInt aCode, const TDesC& aText ); |
|
393 |
|
394 /** |
|
395 * Construct ATS logger. Added this function due to compiler error with |
|
396 * CW 3.0 when there are multiple TRAPDs |
|
397 */ |
|
398 TInt ConstructASTLoggerL( TDesC& atsName, TBool & aAfterReboot); |
|
399 |
|
400 protected: |
|
401 /** |
|
402 * Parametric constructor. |
|
403 */ |
|
404 CTestModuleController( CTestEngine* aEngine ); |
|
405 |
|
406 public: // Data |
|
407 // None |
|
408 |
|
409 // Config file array |
|
410 RPointerArray<HBufC> iConfigFiles; |
|
411 |
|
412 // Tells is TestModuleController cloned or not in -15 (KErrServerTerminated) cases. |
|
413 TBool iTestModuleCrashDetected; |
|
414 |
|
415 private: // Data |
|
416 |
|
417 protected: // Data |
|
418 |
|
419 // Test Engine owning us |
|
420 CTestEngine* iEngine; |
|
421 |
|
422 // Test case array |
|
423 typedef CFixedFlatArray<TTestCaseInfo> TTestCaseArray; |
|
424 RPointerArray<TTestCaseArray> iTestCaseArray; |
|
425 |
|
426 // Handle to Test Server |
|
427 RTestServer iServer; |
|
428 |
|
429 // Handle to Test Module |
|
430 RTestModule iModule; |
|
431 |
|
432 // Module name |
|
433 HBufC* iName; |
|
434 |
|
435 // Internal state |
|
436 TTestModuleStatus iState; |
|
437 |
|
438 // Enumeration result |
|
439 TCaseSize iEnumResultPackage; |
|
440 |
|
441 // Count of test cases |
|
442 TInt iTestCaseCount; |
|
443 |
|
444 // Count of enumerated config files |
|
445 TInt iEnumerateCount; |
|
446 |
|
447 // Count of failed enumerated config files(This is used to decrease |
|
448 // iEnumerateCount) |
|
449 TInt iFailedEnumerateCount; |
|
450 // For removing faulty config (test case) file(s) |
|
451 RPointerArray<HBufC> iFailedEnumerateConfig; |
|
452 |
|
453 // Is enumeration complete |
|
454 TBool iEnumerateComplete; |
|
455 |
|
456 // Temporary config file for each Enumerate call |
|
457 TPtrC iEnumConfigFile; |
|
458 |
|
459 // Pointer to CErrorPrinter |
|
460 CErrorPrinter* iErrorPrinter; |
|
461 // Server state handler |
|
462 CServerStateHandler* iServerStateHandler; |
|
463 |
|
464 // ATS Logger |
|
465 CAtsLogger* iAtsLogger; |
|
466 |
|
467 // Pointer to CTestScripterController |
|
468 CTestScripterController* iTestScripterController; |
|
469 // Indication is CTestScripterController's services needed. Services |
|
470 // that is implemented in CTestScripterController class. |
|
471 TInt iTestScripterIndicator; |
|
472 |
|
473 // Initialization file of Test Module |
|
474 TFileName iInifile; |
|
475 |
|
476 // Number of running test cases |
|
477 TInt iTestCaseCounter; |
|
478 |
|
479 // Reboot indication (moved here from ScripterControlle) |
|
480 TBool iAfterReboot; |
|
481 |
|
482 // List of additional module controllers "owned" by current controller |
|
483 // Used only with UITestingSupport and in case when every test case |
|
484 // has to be run in separate process |
|
485 RPointerArray<CTestModuleController> iChildrenControllers; |
|
486 |
|
487 public: // Friend classes |
|
488 // None |
|
489 |
|
490 protected: // Friend classes |
|
491 // None |
|
492 |
|
493 private: // Friend classes |
|
494 // None |
|
495 |
|
496 friend class CTestScripterController; |
|
497 //friend class CTestModuleController; |
|
498 friend class CTestEngine; //iTestScripterController used from CTestEngine::TestModuleCrash |
|
499 |
|
500 }; |
|
501 |
|
502 // DESCRIPTION |
|
503 // CTestScripterController is for handling TestScripter's server session |
|
504 // creations and handling operations that concern to TestScripter. |
|
505 |
|
506 class CTestScripterController |
|
507 : public CTestModuleController |
|
508 { |
|
509 public: // Enumerations |
|
510 // None |
|
511 |
|
512 private: // Enumerations |
|
513 // None |
|
514 |
|
515 public: // Constructors and destructor |
|
516 |
|
517 /** |
|
518 * Two-phased constructor. |
|
519 */ |
|
520 static CTestScripterController* NewL( CTestEngine* aEngine, |
|
521 const TName& aName, |
|
522 TBool aAfterReboot ); |
|
523 |
|
524 /** |
|
525 * Destructor. |
|
526 */ |
|
527 virtual ~CTestScripterController(); |
|
528 |
|
529 public: // New functions |
|
530 |
|
531 /** |
|
532 * StartEnumerateL starts the CTestModuleController active object. |
|
533 */ |
|
534 void StartEnumerateL(); |
|
535 |
|
536 /** |
|
537 * Init the test module |
|
538 */ |
|
539 void InitL( TFileName& aIniFile, const TDesC& aConfigFile ); |
|
540 |
|
541 /** |
|
542 * Add config file |
|
543 */ |
|
544 void AddConfigFileL( TFileName& aConfigFile ); |
|
545 |
|
546 /** |
|
547 * Remove config file |
|
548 */ |
|
549 void RemoveConfigFileL( TFileName& aConfigFile ); |
|
550 |
|
551 /** |
|
552 * Get Test Cases |
|
553 */ |
|
554 CFixedFlatArray<TTestInfo>* TestCasesL(); |
|
555 |
|
556 /** |
|
557 * Free used memory for test cases |
|
558 */ |
|
559 void FreeTestCases(); |
|
560 |
|
561 /** |
|
562 * Return handle to Test Server |
|
563 */ |
|
564 RTestServer& Server( TTestInfo& aTestInfo ); |
|
565 |
|
566 /** |
|
567 * Return the name of Test Module. |
|
568 */ |
|
569 const TDesC& ModuleName( const TDesC& aModuleName ); |
|
570 |
|
571 /** |
|
572 * Return reference to AtsLogger |
|
573 */ |
|
574 CAtsLogger& AtsLogger(){ return *iTestScripter[0]->iAtsLogger; }; |
|
575 |
|
576 /** |
|
577 * Is enumeration complete? |
|
578 */ |
|
579 TBool EnumerationComplete(); |
|
580 |
|
581 /** |
|
582 * Handles completed requests (Emulates RunL() ). |
|
583 */ |
|
584 void RunLEmulator( CTestModuleController* aTestModuleController ); |
|
585 |
|
586 /** |
|
587 * Handle errors(Emulates RunError()). |
|
588 */ |
|
589 TInt RunErrorEmulator( TInt aError, |
|
590 CTestModuleController* aTestModuleController ); |
|
591 |
|
592 /** |
|
593 * Cancel active request(Emulates DoCancel()). |
|
594 */ |
|
595 void DoCancelEmulator( CTestModuleController* aTestModuleController ); |
|
596 |
|
597 /** |
|
598 * Get current CTestScripterController. |
|
599 */ |
|
600 TInt GetCurrentIndex( CTestModuleController* aTestModuleController ); |
|
601 |
|
602 /** |
|
603 * Finds free test module controller, if not possible, creates new one. |
|
604 */ |
|
605 CTestModuleController* GetFreeOrCreateModuleControllerL(TTestInfo& aTestInfo, TBool aUITestingSupport); |
|
606 |
|
607 /** |
|
608 * Deletes given module controller. |
|
609 */ |
|
610 void DeleteModuleController(CTestModuleController *aRealModuleController); |
|
611 |
|
612 /** |
|
613 * Removes given module controller from children list. |
|
614 */ |
|
615 void RemoveModuleController(CTestModuleController *aRealModuleController); |
|
616 |
|
617 public: // Functions from base classes |
|
618 |
|
619 /** |
|
620 * RunL derived from CActive handles the completed requests. |
|
621 */ |
|
622 void RunL(); |
|
623 |
|
624 /** |
|
625 * DoCancel derived from CActive handles the cancellation |
|
626 */ |
|
627 void DoCancel(); |
|
628 |
|
629 /** |
|
630 * RunError derived from CActive handles errors from active handler. |
|
631 */ |
|
632 TInt RunError( TInt aError ); |
|
633 |
|
634 protected: // New functions |
|
635 // None |
|
636 |
|
637 protected: // Functions from base classes |
|
638 // None |
|
639 |
|
640 private: |
|
641 |
|
642 /** |
|
643 * By default Symbian OS constructor is private. |
|
644 */ |
|
645 void ConstructL( const TName& aName, TBool aAfterReboot ); |
|
646 |
|
647 /** |
|
648 * Parametric constructor. |
|
649 */ |
|
650 CTestScripterController( CTestEngine* aEngine ); |
|
651 |
|
652 /** |
|
653 * Create name according to TestScripter and Test case file. |
|
654 */ |
|
655 HBufC* CreateTestScripterNameL( TFileName& aTestCaseFile, HBufC* aCreatedName ); |
|
656 |
|
657 public: // Data |
|
658 |
|
659 // Array for created CTestScripterController |
|
660 RPointerArray<CTestModuleController> iTestScripter; |
|
661 |
|
662 protected: // Data |
|
663 |
|
664 private: // Data |
|
665 // None |
|
666 |
|
667 public: // Friend classes |
|
668 // None |
|
669 |
|
670 protected: // Friend classes |
|
671 // None |
|
672 |
|
673 private: // Friend classes |
|
674 // None |
|
675 |
|
676 }; |
|
677 |
|
678 /** |
|
679 * Check is module TestScripter. Does parsing and returns new module name and |
|
680 * error codes(Needed operations when creating server sessions to TestScripter). |
|
681 */ |
|
682 TInt GenerateModuleName(const TDesC& aModuleName, TDes& aNewModuleName); |
|
683 |
|
684 #endif // TEST_MODULE_CONTROLLER_H |
|
685 |
|
686 // End of File |