|
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 module contains implementation of |
|
15 * CTestEngineServer class member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32std.h> |
|
21 #include <e32svr.h> |
|
22 #include <f32file.h> |
|
23 #include "TestEngineServer.h" |
|
24 #include "TestEngine.h" |
|
25 #include <TestEngineClient.h> |
|
26 #include "TestEngineClientServer.h" |
|
27 #include <stifinternal/TestServerClient.h> |
|
28 #include "TestModuleController.h" |
|
29 #include "TestCaseController.h" |
|
30 #include "TestReport.h" |
|
31 #include "Logging.h" |
|
32 #include "SettingServerClient.h" |
|
33 //--PYTHON-- begin |
|
34 #include "StifPython.h" |
|
35 #include "StifPythonFunEng.h" |
|
36 //--PYTHON-- end |
|
37 |
|
38 // EXTERNAL DATA STRUCTURES |
|
39 // None |
|
40 |
|
41 // EXTERNAL FUNCTION PROTOTYPES |
|
42 // None |
|
43 |
|
44 // CONSTANTS |
|
45 _LIT( KTestModule, "TestModule=" ); |
|
46 _LIT( KTestCaseFile, "TestCaseFile=" ); |
|
47 _LIT( KTestCaseNumber, "TestCaseNumber=" ); |
|
48 _LIT( KTestCaseTitle, "TestCaseTitle=" ); |
|
49 _LIT( KStateCode, "StateCode=" ); |
|
50 _LIT( KStateName, "StateName=" ); |
|
51 |
|
52 // MACROS |
|
53 // None |
|
54 |
|
55 // LOCAL CONSTANTS AND MACROS |
|
56 // None |
|
57 |
|
58 // MODULE DATA STRUCTURES |
|
59 struct TThreadStartTestEngine |
|
60 { |
|
61 RThread iEngineThread; // The server thread |
|
62 RSemaphore iStarted; // Startup syncronisation semaphore |
|
63 }; |
|
64 |
|
65 // LOCAL FUNCTION PROTOTYPES |
|
66 // None |
|
67 |
|
68 // FORWARD DECLARATIONS |
|
69 // None |
|
70 |
|
71 // ==================== LOCAL FUNCTIONS ======================================= |
|
72 // None |
|
73 |
|
74 // ================= MEMBER FUNCTIONS ========================================= |
|
75 |
|
76 /* |
|
77 ------------------------------------------------------------------------------- |
|
78 |
|
79 Class: CTestEngine |
|
80 |
|
81 Function: ErrorPrint |
|
82 |
|
83 Description: ErrorPrint |
|
84 |
|
85 Parameters: const TInt aPriority: in: Priority of error |
|
86 TPtrC aError: in: Error description |
|
87 |
|
88 Return Values: None |
|
89 |
|
90 Errors/Exceptions: None |
|
91 |
|
92 Status: Approved |
|
93 |
|
94 ------------------------------------------------------------------------------- |
|
95 */ |
|
96 void CTestEngine::ErrorPrint( const TInt aPriority, |
|
97 TPtrC aError ) |
|
98 { |
|
99 TErrorNotification error; |
|
100 TErrorNotificationPckg errorPckg ( error ); |
|
101 |
|
102 error.iModule = _L("TestEngine"); |
|
103 error.iPriority = aPriority; |
|
104 error.iText = aError; |
|
105 |
|
106 ErrorPrint( errorPckg ); |
|
107 |
|
108 } |
|
109 |
|
110 /* |
|
111 ------------------------------------------------------------------------------- |
|
112 |
|
113 Class: CTestModule |
|
114 |
|
115 Method: ErrorPrint |
|
116 |
|
117 Description: Sends error notification |
|
118 |
|
119 Parameters: TErrorNotificationPckg aError: in: Error |
|
120 |
|
121 Return Values: None |
|
122 |
|
123 Errors/Exceptions: None |
|
124 |
|
125 Status: Approved |
|
126 |
|
127 ------------------------------------------------------------------------------- |
|
128 */ |
|
129 void CTestEngine::ErrorPrint( TErrorNotificationPckg aError ) |
|
130 { |
|
131 // Add new item to end of queue |
|
132 if ( iErrorQueue.Append ( aError() ) != KErrNone ) |
|
133 { |
|
134 RDebug::Print (_L("Error message lost")); |
|
135 return; |
|
136 } |
|
137 |
|
138 ProcessErrorQueue(); |
|
139 |
|
140 } |
|
141 |
|
142 /* |
|
143 ------------------------------------------------------------------------------- |
|
144 |
|
145 Class: CTestModule |
|
146 |
|
147 Method: ProcessErrorQueue |
|
148 |
|
149 Description: Process error queue |
|
150 |
|
151 Parameters: None |
|
152 |
|
153 Return Values: None |
|
154 |
|
155 Errors/Exceptions: None |
|
156 |
|
157 Status: Approved |
|
158 |
|
159 ------------------------------------------------------------------------------- |
|
160 */ |
|
161 void CTestEngine::ProcessErrorQueue() |
|
162 { |
|
163 // If message is available, complete first item from queue |
|
164 if ( iErrorMessageAvailable ) |
|
165 { |
|
166 |
|
167 if ( iErrorQueue.Count() > 0 ) |
|
168 { |
|
169 TErrorNotification err = iErrorQueue[0]; |
|
170 TErrorNotificationPckg errPckg(err); |
|
171 iErrorQueue.Remove(0); |
|
172 |
|
173 TInt r( KErrNone ); |
|
174 |
|
175 TRAP( r, iErrorMessage.WriteL( 0, errPckg ) ); |
|
176 |
|
177 // Do not handle errors |
|
178 |
|
179 iErrorMessageAvailable = EFalse; |
|
180 iErrorMessage.Complete( KErrNone ); |
|
181 } |
|
182 } |
|
183 |
|
184 } |
|
185 |
|
186 /* |
|
187 ------------------------------------------------------------------------------- |
|
188 |
|
189 Function: LeaveIfErrorWithNotify |
|
190 |
|
191 Description: If error leave with notify |
|
192 |
|
193 Parameters: TInt aCode: in: Error code |
|
194 |
|
195 Return Values: None |
|
196 |
|
197 Errors/Exceptions: None |
|
198 |
|
199 Status: Approved |
|
200 |
|
201 ------------------------------------------------------------------------------- |
|
202 */ |
|
203 void CTestEngine::LeaveIfErrorWithNotify( TInt aCode ) |
|
204 { |
|
205 LeaveIfErrorWithNotify ( aCode, _L("Check testengine log") ); |
|
206 |
|
207 } |
|
208 |
|
209 /* |
|
210 ------------------------------------------------------------------------------- |
|
211 |
|
212 Function: LeaveIfErrorWithNotify |
|
213 |
|
214 Description: If error leave with notify |
|
215 |
|
216 Parameters: TInt aCode: in: Error code |
|
217 const TDesC& aText: in: Descriptive text |
|
218 |
|
219 Return Values: None |
|
220 |
|
221 Errors/Exceptions: None |
|
222 |
|
223 Status: Approved |
|
224 |
|
225 ------------------------------------------------------------------------------- |
|
226 */ |
|
227 void CTestEngine::LeaveIfErrorWithNotify( TInt aCode, |
|
228 const TDesC& aText ) |
|
229 { |
|
230 if ( aCode != KErrNone ) |
|
231 { |
|
232 LeaveWithNotifyL ( aCode, aText ); |
|
233 } |
|
234 |
|
235 } |
|
236 |
|
237 /* |
|
238 ------------------------------------------------------------------------------- |
|
239 |
|
240 Function: LeaveWithNotifyL |
|
241 |
|
242 Description: Leave with notify |
|
243 |
|
244 Parameters: TInt aCode: in: Error code |
|
245 |
|
246 Return Values: None |
|
247 |
|
248 Errors/Exceptions: None |
|
249 |
|
250 Status: Approved |
|
251 |
|
252 ------------------------------------------------------------------------------- |
|
253 */ |
|
254 void CTestEngine::LeaveWithNotifyL( TInt aCode ) |
|
255 { |
|
256 LeaveWithNotifyL ( aCode, _L("Check testengine log") ); |
|
257 |
|
258 } |
|
259 |
|
260 /* |
|
261 ------------------------------------------------------------------------------- |
|
262 |
|
263 Function: LeaveWithNotifyL |
|
264 |
|
265 Description: Leave with notify |
|
266 |
|
267 Parameters: TInt aCode: in: Error code |
|
268 const TDesC& aText: in: Descriptive text |
|
269 |
|
270 Return Values: None |
|
271 |
|
272 Errors/Exceptions: None |
|
273 |
|
274 Status: Approved |
|
275 |
|
276 ------------------------------------------------------------------------------- |
|
277 */ |
|
278 void CTestEngine::LeaveWithNotifyL( TInt aCode, |
|
279 const TDesC& aText ) |
|
280 { |
|
281 ErrorPrint ( 0, aText ); |
|
282 User::Leave ( aCode ); |
|
283 |
|
284 } |
|
285 |
|
286 /* |
|
287 ------------------------------------------------------------------------------- |
|
288 |
|
289 DESCRIPTION |
|
290 |
|
291 This module contains implementation of CTestEngine class member functions. |
|
292 |
|
293 ------------------------------------------------------------------------------- |
|
294 */ |
|
295 #undef LOGGER |
|
296 #define LOGGER Logger() |
|
297 |
|
298 // ================= MEMBER FUNCTIONS ========================================= |
|
299 |
|
300 /* |
|
301 ------------------------------------------------------------------------------- |
|
302 |
|
303 Class: CTestEngine |
|
304 |
|
305 Method: CTestEngine |
|
306 |
|
307 Description: Default constructor |
|
308 |
|
309 C++ default constructor can NOT contain any code, that |
|
310 might leave. |
|
311 |
|
312 Parameters: RThread& aClient: in: Client's thread |
|
313 |
|
314 Return Values: None |
|
315 |
|
316 Errors/Exceptions: None |
|
317 |
|
318 Status: Approved |
|
319 |
|
320 ------------------------------------------------------------------------------- |
|
321 */ |
|
322 CTestEngine::CTestEngine() : |
|
323 CSession2(), |
|
324 iTestReport(NULL), |
|
325 iReportMode( CTestReport::ETestReportFull ), |
|
326 iReportOutput( CTestReport::ETestReportNone ), |
|
327 iEnumerateModuleCount( 0 ), |
|
328 iIsTestReportGenerated( EFalse ), |
|
329 iDisableMeasurement( EEnableAll) |
|
330 |
|
331 { |
|
332 |
|
333 } |
|
334 |
|
335 /* |
|
336 ------------------------------------------------------------------------------- |
|
337 |
|
338 Class: CTestEngine |
|
339 |
|
340 Method: ConstructL |
|
341 |
|
342 Description: Symbian OS second phase constructor |
|
343 |
|
344 Symbian OS default constructor can leave. |
|
345 |
|
346 Parameters: CTestEngineServer* aServer: in: Pointer to CTestEngineServer |
|
347 |
|
348 Return Values: None |
|
349 |
|
350 Errors/Exceptions: Leaves if some of called leaving methods leaves |
|
351 |
|
352 Status: Approved |
|
353 |
|
354 ------------------------------------------------------------------------------- |
|
355 */ |
|
356 void CTestEngine::ConstructL( CTestEngineServer* aServer ) |
|
357 { |
|
358 // Create report setting |
|
359 iTestReportSettings = CTestReportSettings::NewL(); |
|
360 |
|
361 // Second-phase construct base class |
|
362 //CSession2::CreateL(); |
|
363 |
|
364 iTestEngineServer = aServer; |
|
365 |
|
366 // Create new object index |
|
367 iTestCases = CObjectIx::NewL(); |
|
368 |
|
369 // Initialize the object container from Server |
|
370 iContainer = iTestEngineServer->NewContainerL(); |
|
371 |
|
372 __TRACE( KInit, ( _L( "CTestEngine::ConstructL: Test Engine Created" ) ) ); |
|
373 |
|
374 RFs iFs; |
|
375 User::LeaveIfError( iFs.Connect() ); |
|
376 _LIT(KCSteve,"C:\\Testframework\\"); |
|
377 iFs.MkDirAll(KCSteve); |
|
378 |
|
379 iFs.Close(); |
|
380 |
|
381 iIndexTestModuleControllers = 1; |
|
382 |
|
383 SetTestEngineDefaultSettings(); |
|
384 } |
|
385 |
|
386 /* |
|
387 ------------------------------------------------------------------------------- |
|
388 |
|
389 Class: CTestEngine |
|
390 |
|
391 Method: NewL |
|
392 |
|
393 Description: Two-phased constructor. |
|
394 |
|
395 Parameters: RThread& aClient : Client's thread |
|
396 CTestEngineServer* aServer : Pointer to CTestEngineServer |
|
397 |
|
398 Return Values: CTestEngine* : pointer to CTestEngine object |
|
399 |
|
400 Errors/Exceptions: None |
|
401 |
|
402 Status: Approved |
|
403 |
|
404 ------------------------------------------------------------------------------- |
|
405 */ |
|
406 CTestEngine* CTestEngine::NewL( CTestEngineServer* aServer ) |
|
407 { |
|
408 CTestEngine* self = new ( ELeave ) CTestEngine(); |
|
409 CleanupStack::PushL( self ); |
|
410 self->ConstructL( aServer ); |
|
411 CleanupStack::Pop(); |
|
412 return self; |
|
413 } |
|
414 |
|
415 CTestEngine::~CTestEngine() |
|
416 { |
|
417 // Remove contents of iTestCases |
|
418 if ( iTestCases ) |
|
419 { |
|
420 TInt handle; |
|
421 CObject* object = NULL; |
|
422 TInt count = iTestCases->Count(); |
|
423 |
|
424 for ( TInt i = 0; i < count; i++ ) |
|
425 { |
|
426 object = iTestCases->operator[](i); |
|
427 if ( object ) |
|
428 { |
|
429 handle = iTestCases->At( object ); |
|
430 iTestCases->Remove( handle ); |
|
431 } |
|
432 } |
|
433 |
|
434 delete iTestCases; |
|
435 iTestCases = NULL; |
|
436 } |
|
437 |
|
438 iTestCaseArray.Close(); |
|
439 |
|
440 CloseTestEngineL(); |
|
441 |
|
442 if ( !iIsTestReportGenerated && RetrieveTestReport() ) |
|
443 { |
|
444 iTestReport->GenerateReportL(); |
|
445 iIsTestReportGenerated = ETrue; |
|
446 } |
|
447 CloseSession(); |
|
448 delete iTestReportSettings; |
|
449 iTestReportSettings = NULL; |
|
450 } |
|
451 |
|
452 /* |
|
453 ------------------------------------------------------------------------------- |
|
454 |
|
455 Class: CTestEngine |
|
456 |
|
457 Method: CloseSession |
|
458 |
|
459 Description: Close client server session to Test Engine |
|
460 |
|
461 Parameters: None |
|
462 |
|
463 Return Values: None |
|
464 |
|
465 Errors/Exceptions: None |
|
466 |
|
467 Status: Approved |
|
468 |
|
469 ------------------------------------------------------------------------------- |
|
470 */ |
|
471 void CTestEngine::CloseSession() |
|
472 { |
|
473 __TRACE( KInit, ( _L( "CTestEngine::CloseSession" ) ) ); |
|
474 |
|
475 iErrorQueue.Close(); |
|
476 |
|
477 // Delete device reset module's DLL name |
|
478 delete iDeviceResetDllName; |
|
479 iDeviceResetDllName = NULL; |
|
480 |
|
481 // Delete state events |
|
482 iStateEvents.ResetAndDestroy(); |
|
483 iStateEvents.Close(); |
|
484 |
|
485 //Delete Client events |
|
486 iClientEvents.ResetAndDestroy(); |
|
487 iClientEvents.Close(); |
|
488 |
|
489 // Delete the object container |
|
490 // This provides unique ids for the objects of this session |
|
491 iTestEngineServer->DeleteContainer( iContainer ); |
|
492 |
|
493 // Inform server that session is closed |
|
494 iTestEngineServer->SessionClosed(); |
|
495 |
|
496 // Delete test report |
|
497 delete iTestReport; |
|
498 iTestReport = NULL; |
|
499 |
|
500 delete iIniFile; |
|
501 iIniFile = NULL; |
|
502 |
|
503 delete iRebootPath; |
|
504 iRebootPath = NULL; |
|
505 |
|
506 delete iRebootFilename; |
|
507 iRebootFilename = NULL; |
|
508 |
|
509 delete iRebootParams; |
|
510 iRebootParams = 0; |
|
511 |
|
512 __TRACE(KVerbose, ( _L( "CTestEngine::CloseSession finished" ) ) ); |
|
513 |
|
514 } |
|
515 |
|
516 /* |
|
517 ------------------------------------------------------------------------------- |
|
518 |
|
519 Class: CTestEngine |
|
520 |
|
521 Method: CountResources |
|
522 |
|
523 Description: Resource counding |
|
524 |
|
525 Parameters: None |
|
526 |
|
527 Return Values: TInt Resource count |
|
528 |
|
529 Errors/Exceptions: None |
|
530 |
|
531 Status: Approved |
|
532 |
|
533 ------------------------------------------------------------------------------- |
|
534 */ |
|
535 TInt CTestEngine::CountResources() |
|
536 { |
|
537 return iResourceCount; |
|
538 |
|
539 } |
|
540 |
|
541 /* |
|
542 ------------------------------------------------------------------------------- |
|
543 |
|
544 Class: CTestEngine |
|
545 |
|
546 Method: NumResources |
|
547 |
|
548 Description: Get resources, writes to Message() |
|
549 |
|
550 Parameters: None |
|
551 |
|
552 Return Values: None |
|
553 |
|
554 Errors/Exceptions: None |
|
555 |
|
556 Status: Approved |
|
557 |
|
558 ------------------------------------------------------------------------------- |
|
559 */ |
|
560 void CTestEngine::NumResources( const RMessage2& aMessage ) |
|
561 { |
|
562 |
|
563 TInt ret( 0 ); |
|
564 |
|
565 TPckgBuf<TInt> countPckg( iResourceCount ); |
|
566 |
|
567 TRAP( ret, aMessage.WriteL( 0, countPckg ) ); |
|
568 |
|
569 if ( ret != KErrNone ) |
|
570 { |
|
571 PanicClient( EBadDescriptor, aMessage ); |
|
572 } |
|
573 |
|
574 |
|
575 } |
|
576 |
|
577 /* |
|
578 ------------------------------------------------------------------------------- |
|
579 |
|
580 Class: CTestEngine |
|
581 |
|
582 Method: PanicClient |
|
583 |
|
584 Description: Panic the client |
|
585 |
|
586 Parameters: TTestEnginePanic aPanic: in: Panic number |
|
587 |
|
588 Return Values: None |
|
589 |
|
590 Errors/Exceptions: None |
|
591 |
|
592 Status: Approved |
|
593 |
|
594 ------------------------------------------------------------------------------- |
|
595 */ |
|
596 void CTestEngine::PanicClient( TTestEnginePanic aPanic, |
|
597 const RMessage2& aMessage ) const |
|
598 { |
|
599 iTestEngineServer->Logger()->Log( CStifLogger::ERed, _L( "CTestEngine::PanicClient [%d]" ), aPanic ); |
|
600 |
|
601 _LIT( KTestEngine, "CTestEngine" ); |
|
602 |
|
603 aMessage.Panic( KTestEngine, aPanic ); |
|
604 |
|
605 } |
|
606 |
|
607 /* |
|
608 ------------------------------------------------------------------------------- |
|
609 |
|
610 Class: CTestEngine |
|
611 |
|
612 Method: ServiceL |
|
613 |
|
614 Description: Message handling method that calls trapped DispatchMessageL |
|
615 |
|
616 Parameters: const RMessage& aMessage: in: Server message |
|
617 |
|
618 Return Values: None |
|
619 |
|
620 Errors/Exceptions: Error from DispatchMessageL is trapped and handled |
|
621 |
|
622 Status: Approved |
|
623 |
|
624 ------------------------------------------------------------------------------- |
|
625 */ |
|
626 void CTestEngine::ServiceL( const RMessage2& aMessage ) |
|
627 { |
|
628 TRAPD( ret, DispatchMessageL( aMessage ) ); |
|
629 if ( ret != KErrNone ) |
|
630 { |
|
631 __TRACE(KError, ( CStifLogger::ERed, _L( "CTestEngine::DispatchMessageL Function=[%d], left with [%d]" ), |
|
632 aMessage.Function(), ret ) ); |
|
633 if( ret == KErrNoMemory ) |
|
634 { |
|
635 __TRACE( KError, ( CStifLogger::ERed, _L( "No memory available. Some possibility to do: 1. Reduce test case count. 2. Increase StifTestEngine's heap size." ) ) ); |
|
636 } |
|
637 aMessage.Complete( ret ); |
|
638 } |
|
639 |
|
640 } |
|
641 |
|
642 /* |
|
643 ------------------------------------------------------------------------------- |
|
644 |
|
645 Class: CTestEngine |
|
646 |
|
647 Method: DispatchMessageL |
|
648 |
|
649 Description: Actual message handling |
|
650 |
|
651 Parameters: const RMessage& aMessage: in: Server message |
|
652 |
|
653 Return Values: None |
|
654 |
|
655 Errors/Exceptions: Leaves if some of called leaving methods leaves |
|
656 |
|
657 Status: Approved |
|
658 |
|
659 ------------------------------------------------------------------------------- |
|
660 */ |
|
661 void CTestEngine::DispatchMessageL( const RMessage2& aMessage ) |
|
662 { |
|
663 iComplete = ETrue; |
|
664 iReturn = KErrNone; |
|
665 |
|
666 switch ( aMessage.Function() ) |
|
667 { |
|
668 case ETestEngineLoadConfiguration: |
|
669 { |
|
670 LoadConfigurationL( aMessage ); |
|
671 break; |
|
672 } |
|
673 case ETestEngineUpdateLogConfiguration: |
|
674 { |
|
675 UpdateLogConfigurationL( aMessage ); |
|
676 break; |
|
677 } |
|
678 case ETestEngineUpdateEngineConfiguration: |
|
679 { |
|
680 UpdateEngineConfigurationL( aMessage ); |
|
681 break; |
|
682 } |
|
683 case ETestEngineSetAttribute: |
|
684 { |
|
685 SetAttributeL( aMessage ); |
|
686 break; |
|
687 } |
|
688 case ETestEngineAddTestModule: |
|
689 { |
|
690 AddTestModuleL( aMessage ); |
|
691 break; |
|
692 } |
|
693 case ETestEngineRemoveTestModule: |
|
694 { |
|
695 iReturn = RemoveTestModuleL( aMessage ); |
|
696 break; |
|
697 } |
|
698 case ETestEngineAddConfigFile: |
|
699 { |
|
700 AddConfigFileL( aMessage ); |
|
701 break; |
|
702 } |
|
703 case ETestEngineRemoveConfigFile: |
|
704 { |
|
705 RemoveConfigFileL( aMessage ); |
|
706 break; |
|
707 } |
|
708 case ETestEngineEnumerateTestCases: |
|
709 { |
|
710 EnumerateTestCasesL( aMessage ); |
|
711 break; |
|
712 } |
|
713 case ETestEngineGetTestCases: |
|
714 { |
|
715 GetTestCasesL( aMessage ); |
|
716 break; |
|
717 } |
|
718 case ETestEngineCancelAsyncRequest: |
|
719 { |
|
720 CancelAsyncRequest( aMessage ); |
|
721 break; |
|
722 } |
|
723 case ETestEngineEvent: |
|
724 { |
|
725 EventControlL( aMessage ); |
|
726 iComplete = EFalse; |
|
727 break; |
|
728 } |
|
729 case ETestEngineErrorNotification: |
|
730 { |
|
731 HandleErrorNotificationL( aMessage ); |
|
732 iComplete = EFalse; |
|
733 break; |
|
734 } |
|
735 case ETestEngineLoggerSettings: |
|
736 { |
|
737 LoggerSettings( aMessage ); |
|
738 break; |
|
739 } |
|
740 case ETestEngineReportTestCase: |
|
741 { |
|
742 iReturn = AddTestCaseToTestReport(aMessage); |
|
743 break; |
|
744 } |
|
745 // Subsession specific functions |
|
746 case ETestCaseCreateSubSession: |
|
747 { |
|
748 NewTestCaseL( aMessage ); |
|
749 break; |
|
750 } |
|
751 case ETestCaseCloseSubSession: |
|
752 { |
|
753 DeleteTestCase( aMessage.Int3() ); |
|
754 break; |
|
755 } |
|
756 case ETestCaseRunTestCase: |
|
757 { |
|
758 TestCaseByHandle( aMessage.Int3(), aMessage )->RunTestCaseL( aMessage ); |
|
759 iComplete = EFalse; |
|
760 break; |
|
761 } |
|
762 case ETestCasePause: |
|
763 { |
|
764 iReturn = TestCaseByHandle( aMessage.Int3(), aMessage )->Pause(); |
|
765 break; |
|
766 } |
|
767 case ETestCaseResume: |
|
768 { |
|
769 iReturn = TestCaseByHandle( aMessage.Int3(), aMessage )->Resume(); |
|
770 break; |
|
771 } |
|
772 case ETestCaseNotifyProgress: |
|
773 { |
|
774 TestCaseByHandle( aMessage.Int3(), aMessage )->NotifyProgressL( aMessage ); |
|
775 iComplete = EFalse; |
|
776 break; |
|
777 } |
|
778 case ETestCaseNotifyRemoteType: |
|
779 { |
|
780 TestCaseByHandle( aMessage.Int3(), aMessage )->NotifyRemoteTypeL( aMessage ); |
|
781 iComplete = EFalse; |
|
782 break; |
|
783 } |
|
784 case ETestCaseNotifyRemoteMsg: |
|
785 { |
|
786 TestCaseByHandle( aMessage.Int3(), aMessage )->NotifyRemoteMsgL( aMessage ); |
|
787 iComplete = EFalse; |
|
788 break; |
|
789 } |
|
790 case ETestCaseCancelAsyncRequest: |
|
791 { |
|
792 TestCaseByHandle( |
|
793 aMessage.Int3(), aMessage )->CancelAsyncRequest( aMessage ); |
|
794 break; |
|
795 } |
|
796 default: |
|
797 { |
|
798 User::Leave( KErrNotSupported ); |
|
799 break; |
|
800 } |
|
801 } |
|
802 |
|
803 if ( iComplete ) |
|
804 { |
|
805 aMessage.Complete( iReturn ); |
|
806 } |
|
807 |
|
808 } |
|
809 |
|
810 void CTestEngine::SetTestEngineDefaultSettings() |
|
811 { |
|
812 // Test report settings initialization |
|
813 iTestReportSettings->iCreateTestReport = ETrue; |
|
814 _LIT( path, "C:\\LOGS\\TestFramework\\"); |
|
815 _LIT( name, "TestReport"); |
|
816 delete iTestReportSettings->iPath; |
|
817 iTestReportSettings->iPath = NULL; |
|
818 iTestReportSettings->iPath = path().AllocL(); |
|
819 delete iTestReportSettings->iName; |
|
820 iTestReportSettings->iName = NULL; |
|
821 iTestReportSettings->iName = name().AllocL(); |
|
822 iTestReportSettings->iFormat = CStifLogger::ETxt; |
|
823 iTestReportSettings->iOutput = CStifLogger::EFile; |
|
824 iTestReportSettings->iOverwrite = ETrue; |
|
825 |
|
826 iRebootDefaultPath.Set( _L( "C:\\TestFramework\\" ) ); |
|
827 iRebootDefaultFilename.Set( _L( "Reboot.txt" ) ); |
|
828 |
|
829 TPtrC dllName; |
|
830 dllName.Set( _L( "StifHWResetStub.dll" ) ); |
|
831 iDeviceResetDllName = dllName.AllocL(); |
|
832 |
|
833 iDefaultTimeout = 0; |
|
834 iUITestingSupport = EFalse; |
|
835 iSeparateProcesses = EFalse; |
|
836 } |
|
837 |
|
838 /* |
|
839 ------------------------------------------------------------------------------- |
|
840 |
|
841 Class: CTestEngine |
|
842 |
|
843 Method: InitEngineL |
|
844 |
|
845 Description: Init the test engine |
|
846 |
|
847 Parameters: const RMessage& aMessage: in: Server message |
|
848 |
|
849 Return Values: None |
|
850 |
|
851 Errors/Exceptions: Leaves if some of called leaving methods leaves |
|
852 |
|
853 Status: Approved |
|
854 |
|
855 ------------------------------------------------------------------------------- |
|
856 */ |
|
857 void CTestEngine::LoadConfigurationL( const RMessage2& aMessage ) |
|
858 { |
|
859 |
|
860 // Parse reboot file |
|
861 ParseRebootParamsL(); |
|
862 |
|
863 TName iniFileName; |
|
864 |
|
865 // Read ini file name from aMessage |
|
866 aMessage.ReadL( 0, iniFileName ); |
|
867 TStifUtil::CorrectFilePathL( iniFileName ); |
|
868 |
|
869 iIniFile = iniFileName.AllocL(); |
|
870 |
|
871 __TRACE( KInit, ( CStifLogger::EBold, _L( "CTestEngine::InitEngineL\t iIniFile=[%S]" ), iIniFile ) ); |
|
872 |
|
873 // Connect to the Setting server and open handle(Handle will close when |
|
874 // closing TestEngine). |
|
875 TInt ret = iSettingServer.Connect(); |
|
876 if ( ret != KErrNone ) |
|
877 { |
|
878 User::Leave( ret ); |
|
879 } |
|
880 |
|
881 if ( iIniFile->Length() > 0 ) |
|
882 { |
|
883 Logger()->WriteDelimiter(); |
|
884 __TRACE( KInit,( _L( "Starting to parse initialization file" ) ) ); |
|
885 |
|
886 // Struct to Logger settigs. |
|
887 TLoggerSettings loggerSettings; |
|
888 // Parse Logger defaults from STIF initialization file. |
|
889 User::LeaveIfError( iSettingServer.LoadLoggerSettingsFromIniFile( loggerSettings, iniFileName, EFalse ) ); |
|
890 |
|
891 // Create parser for parsing ini file |
|
892 CStifParser* parser = NULL; |
|
893 TRAPD( r, parser = CStifParser::NewL( _L(""), *iIniFile ) ); |
|
894 if ( r != KErrNone ) |
|
895 { |
|
896 __TRACE( KError,( CStifLogger::ERed, _L( "Can't open ini-file [%S], code %d" ), iIniFile, r ) ); |
|
897 LeaveWithNotifyL(r); |
|
898 } |
|
899 |
|
900 CleanupStack::PushL( parser ); |
|
901 |
|
902 CSTIFTestFrameworkSettings* settings = NULL; |
|
903 TRAPD( settings_ret, settings = CSTIFTestFrameworkSettings::NewL() ); |
|
904 CleanupStack::PushL( settings ); |
|
905 if ( settings_ret != KErrNone ) |
|
906 { |
|
907 __TRACE( KError,( CStifLogger::ERed, _L( "CSTIFTestFrameworkSettings class object creation fails") ) ); |
|
908 LeaveWithNotifyL( settings_ret ); |
|
909 } |
|
910 |
|
911 ReadEngineDefaultsL( parser, settings ); |
|
912 |
|
913 iTestEngineServer->SetLoggerSettings( loggerSettings ); |
|
914 |
|
915 TRAP(r, ReadTestModulesL( parser )); |
|
916 if(r != KErrNone) |
|
917 { |
|
918 __TRACE(KError, (CStifLogger::ERed, _L("Reading test modules finished with error [%d]"), r)); |
|
919 User::Leave(r); |
|
920 } |
|
921 |
|
922 CleanupStack::PopAndDestroy( settings ); |
|
923 CleanupStack::PopAndDestroy( parser ); |
|
924 __TRACE( KInit, ( _L( "Configuration file reading finished" ) ) ); |
|
925 } |
|
926 else |
|
927 { |
|
928 __TRACE( KInit,( CStifLogger::EBold, _L( "Initialisation file not specified." ) ) ); |
|
929 } |
|
930 |
|
931 Logger()->WriteDelimiter(); |
|
932 // Notch up another resource |
|
933 iResourceCount++; |
|
934 } |
|
935 |
|
936 void CTestEngine::UpdateLogConfigurationL( const RMessage2& aMessage ) |
|
937 { |
|
938 TBuf<256> logconfiguration; |
|
939 aMessage.ReadL( 0, logconfiguration ); |
|
940 iSettingServer.LoadLoggerSettingsFromCommandLine(logconfiguration); |
|
941 } |
|
942 |
|
943 |
|
944 /* |
|
945 ------------------------------------------------------------------------------- |
|
946 |
|
947 Class: CTestEngine |
|
948 |
|
949 Method: ReadEngineDefaults |
|
950 |
|
951 Description: Parse Test Engine defaults from STIF |
|
952 initialization file. |
|
953 |
|
954 Parameters: CStifParser& parser: in: CStifParser object |
|
955 CSTIFTestFrameworkSettings* aSettings: in: |
|
956 CSTIFTestFrameworkSettings object |
|
957 |
|
958 Return Values: None |
|
959 |
|
960 Errors/Exceptions: Leaves if some of called leaving methods leaves |
|
961 |
|
962 Status: Approved |
|
963 |
|
964 ------------------------------------------------------------------------------- |
|
965 */ |
|
966 void CTestEngine::ReadEngineDefaultsL( CStifParser* aParser, |
|
967 CSTIFTestFrameworkSettings* aSettings ) |
|
968 { |
|
969 __TRACE( KInit,( _L( "" ) ) ); |
|
970 __TRACE( KInit,( _L( "Start parsing engine defaults" ) ) ); |
|
971 TInt get_ret( KErrNone ); |
|
972 |
|
973 CStifSectionParser* sectionParser = NULL; |
|
974 |
|
975 // Parse Engine's default values |
|
976 _LIT( KDefaultsStart, "[Engine_Defaults]" ); |
|
977 _LIT( KDefaultsEnd, "[End_Defaults]" ); |
|
978 __TRACE( KInit,( _L( "Starting to search sections" ) ) ); |
|
979 sectionParser = aParser->SectionL( KDefaultsStart, KDefaultsEnd ); |
|
980 CleanupStack::PushL( sectionParser ); |
|
981 if ( sectionParser ) |
|
982 { |
|
983 __TRACE( KInit,( _L( "Found '%S' and '%S' sections" ), &KDefaultsStart, &KDefaultsEnd ) ); |
|
984 |
|
985 // Get Test Report Mode |
|
986 __TRACE( KInit,( _L( "Parsing Test report mode" ) ) ); |
|
987 TUint reportMode( 0 ); |
|
988 get_ret = aSettings->GetReportModeL( sectionParser, |
|
989 _L( "TestReportMode=" ), reportMode ); |
|
990 if ( get_ret == KErrNone ) |
|
991 { |
|
992 __TRACE( KInit,( _L( "Report mode: %d"), reportMode ) ); |
|
993 iReportMode = reportMode; |
|
994 } |
|
995 else |
|
996 { |
|
997 __TRACE( KInit,( _L( "Report mode not found or not given" ) ) ); |
|
998 } |
|
999 |
|
1000 // Indicator to test report creation |
|
1001 __TRACE( KInit,( _L( "Parsing Test report creation indicator" ) ) ); |
|
1002 TBool createTestReport( 0 ); |
|
1003 get_ret = aSettings->GetBooleanSettingsL( sectionParser, |
|
1004 _L( "CreateTestReport=" ), createTestReport ); |
|
1005 if ( get_ret == KErrNone ) |
|
1006 { |
|
1007 __TRACE( KInit,( _L( "Test report creation indicator: %d"), createTestReport ) ); |
|
1008 iTestReportSettings->iCreateTestReport = createTestReport; |
|
1009 } |
|
1010 else |
|
1011 { |
|
1012 __TRACE( KInit,( _L( "Creation indicator not found or not given" ) ) ); |
|
1013 } |
|
1014 |
|
1015 // Get Test report path settings |
|
1016 if ( iTestReportSettings->iCreateTestReport ) |
|
1017 { |
|
1018 __TRACE( KInit,( _L( "Parsing Test report path" ) ) ); |
|
1019 TPtrC path; |
|
1020 get_ret = aSettings->GetFileSetting( sectionParser, |
|
1021 _L( "TestReportFilePath=" ), path ); |
|
1022 if ( get_ret == KErrNone ) |
|
1023 { |
|
1024 __TRACE( KInit,( _L( "Test report path: %S"), &path ) ); |
|
1025 // Delete old one before setting new one |
|
1026 delete iTestReportSettings->iPath; |
|
1027 iTestReportSettings->iPath = NULL; |
|
1028 iTestReportSettings->iPath = path.AllocL(); |
|
1029 } |
|
1030 else |
|
1031 { |
|
1032 __TRACE( KInit,( _L( "Path not found or not given" ) ) ); |
|
1033 } |
|
1034 } |
|
1035 |
|
1036 // Get Test report name settings |
|
1037 if ( iTestReportSettings->iCreateTestReport ) |
|
1038 { |
|
1039 __TRACE( KInit,( _L( "Parsing Test report filename" ) ) ); |
|
1040 TPtrC name; |
|
1041 get_ret = aSettings->GetFileSetting( sectionParser, |
|
1042 _L( "TestReportFileName=" ), name ); |
|
1043 if ( get_ret == KErrNone ) |
|
1044 { |
|
1045 __TRACE( KInit,( _L( "Test report filename: %S"), &name ) ); |
|
1046 // Delete old one before setting new one |
|
1047 delete iTestReportSettings->iName; |
|
1048 iTestReportSettings->iName = NULL; |
|
1049 iTestReportSettings->iName = name.AllocL(); |
|
1050 } |
|
1051 else |
|
1052 { |
|
1053 __TRACE( KInit,( _L( "Filename not found or not given" ) ) ); |
|
1054 } |
|
1055 |
|
1056 } |
|
1057 |
|
1058 // Get Test report format settings |
|
1059 if ( iTestReportSettings->iCreateTestReport ) |
|
1060 { |
|
1061 __TRACE( KInit,( _L( "Parsing Test report format" ) ) ); |
|
1062 CStifLogger::TLoggerType type; |
|
1063 TBool xml; |
|
1064 get_ret = aSettings->GetFormatL( sectionParser, |
|
1065 _L( "TestReportFormat=" ), type, xml ); |
|
1066 if ( get_ret == KErrNone ) |
|
1067 { |
|
1068 __TRACE( KInit,( _L( "Test report format: %d, xml: %d"), type, xml ) ); |
|
1069 iTestReportSettings->iFormat = type; |
|
1070 iTestReportSettings->iXML = xml; |
|
1071 } |
|
1072 else |
|
1073 { |
|
1074 __TRACE( KInit,( _L( "Format not found or not given" ) ) ); |
|
1075 } |
|
1076 } |
|
1077 |
|
1078 // Get Test report output settings |
|
1079 if ( iTestReportSettings->iCreateTestReport ) |
|
1080 { |
|
1081 __TRACE( KInit,( _L( "Parsing Test report output" ) ) ); |
|
1082 CStifLogger::TOutput output; |
|
1083 get_ret = aSettings->GetOutputL( sectionParser, |
|
1084 _L( "TestReportOutput=" ), output ); |
|
1085 if ( get_ret == KErrNone ) |
|
1086 { |
|
1087 __TRACE( KInit,( _L( "Test report output: %d"), output ) ); |
|
1088 iTestReportSettings->iOutput = output; |
|
1089 } |
|
1090 else |
|
1091 { |
|
1092 __TRACE( KInit,( _L( "Output not found or not given" ) ) ); |
|
1093 } |
|
1094 } |
|
1095 |
|
1096 // Get Test report file creation mode (overwrite settings) |
|
1097 if ( iTestReportSettings->iCreateTestReport ) |
|
1098 { |
|
1099 __TRACE( KInit,( _L( "Parsing Test report file writing mode" ) ) ); |
|
1100 TBool overwrite; |
|
1101 get_ret = aSettings->GetOverwriteL( sectionParser, |
|
1102 _L( "TestReportFileCreationMode=" ), overwrite ); |
|
1103 if ( get_ret == KErrNone ) |
|
1104 { |
|
1105 __TRACE( KInit,( _L( "Test report file creation mode: %d"), overwrite ) ); |
|
1106 iTestReportSettings->iOverwrite = overwrite; |
|
1107 } |
|
1108 else |
|
1109 { |
|
1110 __TRACE( KInit,( _L( "Writing mode not found or not given" ) ) ); |
|
1111 } |
|
1112 } |
|
1113 // Get device reset module's DLL name |
|
1114 __TRACE( KInit,( _L( "Parsing device reset module's DLL name" ) ) ); |
|
1115 TPtrC deviceResetName; |
|
1116 get_ret = aSettings->GetFileSetting( sectionParser, |
|
1117 _L( "DeviceResetDllName=" ), deviceResetName ); |
|
1118 if ( get_ret == KErrNone ) |
|
1119 { |
|
1120 __TRACE( KInit,( _L( "Device reset module's name: %S"), &deviceResetName ) ); |
|
1121 // Delete old one before setting new one |
|
1122 delete iDeviceResetDllName; |
|
1123 iDeviceResetDllName = NULL; |
|
1124 iDeviceResetDllName = deviceResetName.AllocL(); |
|
1125 } |
|
1126 else |
|
1127 { |
|
1128 __TRACE( KInit,( _L( "Device reset module's name not found or not given" ) ) ); |
|
1129 } |
|
1130 |
|
1131 // Get measurement disable option |
|
1132 CStifItemParser* item = NULL; |
|
1133 TRAPD( ret, item = sectionParser->GetItemLineL( _L( "DisableMeasurement=" ), ENoTag ) ); |
|
1134 if( ( ret != KErrNone ) || ( item == NULL ) ) |
|
1135 { |
|
1136 __TRACE( KInit,( _L( "Measurement 'DiableMeasurement=' not found or not given" ) ) ); |
|
1137 delete item; |
|
1138 item = NULL; |
|
1139 } |
|
1140 else |
|
1141 { |
|
1142 CleanupStack::PushL( item ); |
|
1143 TPtrC string; |
|
1144 ret = item->GetString( KNullDesC(), string ); |
|
1145 while( ret == KErrNone ) |
|
1146 { |
|
1147 HBufC* stringHbuf = string.AllocL(); |
|
1148 TPtr modifiableString = stringHbuf->Des(); |
|
1149 modifiableString.LowerCase(); |
|
1150 |
|
1151 if( modifiableString == KStifMeasurementDisableNone || |
|
1152 modifiableString == KStifMeasurementDisableAll || |
|
1153 modifiableString == KStifMeasurement01 || |
|
1154 modifiableString == KStifMeasurement02 || |
|
1155 modifiableString == KStifMeasurement03 || |
|
1156 modifiableString == KStifMeasurement04 || |
|
1157 modifiableString == KStifMeasurement05 || |
|
1158 modifiableString == KStifMeasurementBappea ) |
|
1159 { |
|
1160 __TRACE( KInit,( _L( "Measurement disable option: %S"), &modifiableString ) ); |
|
1161 DisableStifMeasurement( modifiableString ); |
|
1162 } |
|
1163 else if( modifiableString == _L( "#" ) ) |
|
1164 { |
|
1165 delete stringHbuf; |
|
1166 stringHbuf = NULL; |
|
1167 break; |
|
1168 } |
|
1169 else |
|
1170 { |
|
1171 __TRACE( KInit,( _L( "Measurement disable option not found or not given" ) ) ); |
|
1172 delete stringHbuf; |
|
1173 stringHbuf = NULL; |
|
1174 break; |
|
1175 } |
|
1176 delete stringHbuf; |
|
1177 ret = item->GetNextString( string ); |
|
1178 } |
|
1179 CleanupStack::PopAndDestroy( item ); |
|
1180 item = NULL; |
|
1181 } |
|
1182 |
|
1183 // Get timeout value option |
|
1184 __TRACE(KInit, (_L("Parsing default timeout value"))); |
|
1185 iDefaultTimeout = 0; |
|
1186 item = NULL; |
|
1187 TRAP(ret, item = sectionParser->GetItemLineL(_L("Timeout=" ), ENoTag)); |
|
1188 if( ( ret != KErrNone ) || ( item == NULL ) ) |
|
1189 { |
|
1190 __TRACE(KInit, (_L("'Timeout' option not found or not given"))); |
|
1191 delete item; |
|
1192 item = NULL; |
|
1193 } |
|
1194 else |
|
1195 { |
|
1196 CleanupStack::PushL( item ); |
|
1197 TPtrC string; |
|
1198 ret = item->GetString(KNullDesC(), string); |
|
1199 if(string.Length() > 0) |
|
1200 { |
|
1201 TLex lex(string); |
|
1202 ret = lex.Val(iDefaultTimeout); |
|
1203 if(ret != KErrNone) |
|
1204 { |
|
1205 __TRACE(KError, (_L("Could not convert timeout value '%S' to integer. Error %d. Ignoring this setting."), &string, ret)); |
|
1206 } |
|
1207 if(iDefaultTimeout < 0) |
|
1208 { |
|
1209 __TRACE(KError, (_L("'Timeout' value cannot be negative. Resetting to 0."))); |
|
1210 iDefaultTimeout = 0; |
|
1211 } |
|
1212 } |
|
1213 else |
|
1214 { |
|
1215 __TRACE(KInit, (_L("'Timeout' value not given"))); |
|
1216 } |
|
1217 CleanupStack::PopAndDestroy( item ); |
|
1218 item = NULL; |
|
1219 } |
|
1220 __TRACE(KInit, (_L("'Timeout' value set to %d"), iDefaultTimeout)); |
|
1221 iDefaultTimeout *= 1000; |
|
1222 |
|
1223 // Get UITestingSupport value option |
|
1224 __TRACE(KInit, (_L("Parsing UITestingSupport value"))); |
|
1225 iUITestingSupport = EFalse; |
|
1226 item = NULL; |
|
1227 TRAP(ret, item = sectionParser->GetItemLineL(_L("UITestingSupport=" ), ENoTag)); |
|
1228 if((ret != KErrNone) || (item == NULL)) |
|
1229 { |
|
1230 __TRACE(KInit, (_L("'UITestingSupport' option not found"))); |
|
1231 delete item; |
|
1232 item = NULL; |
|
1233 } |
|
1234 else |
|
1235 { |
|
1236 CleanupStack::PushL(item); |
|
1237 TPtrC string; |
|
1238 ret = item->GetString(KNullDesC(), string); |
|
1239 if(string.Length() > 0) |
|
1240 { |
|
1241 iUITestingSupport = (string == _L("YES")); |
|
1242 } |
|
1243 else |
|
1244 { |
|
1245 __TRACE(KInit, (_L("'UITestingSupport' value not given"))); |
|
1246 } |
|
1247 CleanupStack::PopAndDestroy(item); |
|
1248 item = NULL; |
|
1249 } |
|
1250 __TRACE(KInit, (_L("'UITestingSupport' value set to %d"), iUITestingSupport)); |
|
1251 |
|
1252 // Get SeparateProcesses value option |
|
1253 __TRACE(KInit, (_L("Parsing SeparateProcesses value"))); |
|
1254 iSeparateProcesses = EFalse; |
|
1255 item = NULL; |
|
1256 TRAP(ret, item = sectionParser->GetItemLineL(_L("SeparateProcesses=" ), ENoTag)); |
|
1257 if((ret != KErrNone) || (item == NULL)) |
|
1258 { |
|
1259 __TRACE(KInit, (_L("'SeparateProcesses' option not found"))); |
|
1260 delete item; |
|
1261 item = NULL; |
|
1262 } |
|
1263 else |
|
1264 { |
|
1265 CleanupStack::PushL(item); |
|
1266 TPtrC string; |
|
1267 ret = item->GetString(KNullDesC(), string); |
|
1268 if(string.Length() > 0) |
|
1269 { |
|
1270 iSeparateProcesses = (string == _L("YES")); |
|
1271 } |
|
1272 else |
|
1273 { |
|
1274 __TRACE(KInit, (_L("'SeparateProcesses' value not given"))); |
|
1275 } |
|
1276 CleanupStack::PopAndDestroy(item); |
|
1277 item = NULL; |
|
1278 } |
|
1279 __TRACE(KInit, (_L("'SeparateProcesses' value set to %d"), iSeparateProcesses)); |
|
1280 } |
|
1281 else |
|
1282 { |
|
1283 __TRACE( KInit,( _L( "Not found '%S' and '%S' sections" ), &KDefaultsStart, &KDefaultsEnd ) ); |
|
1284 } |
|
1285 __TRACE( KInit,( _L( "End parsing engine defaults" ) ) ); |
|
1286 CleanupStack::PopAndDestroy( sectionParser ); |
|
1287 |
|
1288 } |
|
1289 |
|
1290 void CTestEngine::ReadEngineFromCommandLineL(const TDesC& aCommand) |
|
1291 { |
|
1292 _LIT(KTestReportMode,"TestReportMode"); |
|
1293 _LIT(KCreateTestReport,"CreateTestReport"); |
|
1294 _LIT(KTestReportFilePath,"TestReportFilePath"); |
|
1295 _LIT(KTestReportFileName,"TestReportFileName"); |
|
1296 _LIT(KTestReportFormat,"TestReportFormat"); |
|
1297 _LIT(KTestReportOutput,"TestReportOutput"); |
|
1298 _LIT(KTestReportFileCreationMode,"TestReportFileCreationMode"); |
|
1299 _LIT(KDeviceResetDllName,"DeviceResetDllName"); |
|
1300 _LIT(KDisableMeasurement,"DisableMeasurement"); |
|
1301 _LIT(KTimeout,"Timeout"); |
|
1302 _LIT(KUITestingSupport,"UITestingSupport"); |
|
1303 _LIT(KSeparateProcesses,"SeparateProcesses"); |
|
1304 TInt i=0; |
|
1305 TLex lex(aCommand); |
|
1306 while ( !lex.Eos() ) |
|
1307 { |
|
1308 TPtrC key=lex.NextToken(); |
|
1309 i++; |
|
1310 TPtrC value=lex.NextToken(); |
|
1311 i++; |
|
1312 if(key !=KNullDesC && value !=KNullDesC) |
|
1313 { |
|
1314 if(key==KTestReportMode) |
|
1315 { |
|
1316 if( value == _L( "EMPTY" ) ) |
|
1317 { |
|
1318 // No test report |
|
1319 iReportMode = CTestReport::ETestReportBlank; |
|
1320 } |
|
1321 else if( value == _L( "SUMMARY" ) ) |
|
1322 { |
|
1323 // Increment aSetting |
|
1324 iReportMode += CTestReport::ETestReportSummary; |
|
1325 } |
|
1326 else if( value == _L( "ENVIRONMENT" ) ) |
|
1327 { |
|
1328 // Increment aSetting |
|
1329 iReportMode += CTestReport::ETestReportEnvironment; |
|
1330 } |
|
1331 else if( value == _L( "TESTCASES" ) ) |
|
1332 { |
|
1333 // Increment aSetting |
|
1334 iReportMode += CTestReport::ETestReportCases; |
|
1335 } |
|
1336 else if( value == _L( "FULLREPORT" ) ) |
|
1337 { |
|
1338 // Set aSettings to max value and break |
|
1339 iReportMode = CTestReport::ETestReportFull; |
|
1340 |
|
1341 } |
|
1342 else if( value == _L( "#" ) ) |
|
1343 { |
|
1344 |
|
1345 } |
|
1346 } |
|
1347 else if(key==KCreateTestReport) |
|
1348 { |
|
1349 if( value == _L( "NO" ) ) |
|
1350 { |
|
1351 iTestReportSettings->iCreateTestReport = EFalse; |
|
1352 } |
|
1353 // Parsed parameter is true |
|
1354 else if( value == _L( "YES" ) ) |
|
1355 { |
|
1356 iTestReportSettings->iCreateTestReport = ETrue; |
|
1357 } |
|
1358 |
|
1359 } |
|
1360 else if(key==KTestReportFilePath) |
|
1361 { |
|
1362 if(iTestReportSettings->iCreateTestReport) |
|
1363 { |
|
1364 delete iTestReportSettings->iPath; |
|
1365 iTestReportSettings->iPath = NULL; |
|
1366 iTestReportSettings->iPath = value.AllocL(); |
|
1367 } |
|
1368 |
|
1369 } |
|
1370 else if(key==KTestReportFileName) |
|
1371 { |
|
1372 if(iTestReportSettings->iCreateTestReport) |
|
1373 { |
|
1374 delete iTestReportSettings->iName; |
|
1375 iTestReportSettings->iName = NULL; |
|
1376 iTestReportSettings->iName = value.AllocL(); |
|
1377 } |
|
1378 |
|
1379 } |
|
1380 else if(key==KTestReportFormat) |
|
1381 { |
|
1382 if( value == _L( "TXT" ) ) |
|
1383 { |
|
1384 iTestReportSettings->iFormat = CStifLogger::ETxt; |
|
1385 |
|
1386 } |
|
1387 else if( value == _L( "HTML" ) ) |
|
1388 { |
|
1389 iTestReportSettings->iFormat = CStifLogger::EHtml; |
|
1390 } |
|
1391 else if( value == _L( "DATA" ) ) |
|
1392 { |
|
1393 iTestReportSettings->iFormat = CStifLogger::EData; |
|
1394 } |
|
1395 else if( value == _L( "XML" ) ) |
|
1396 { |
|
1397 iTestReportSettings->iFormat = CStifLogger::ETxt; |
|
1398 iTestReportSettings->iXML = ETrue; |
|
1399 } |
|
1400 |
|
1401 } |
|
1402 else if(key==KTestReportOutput) |
|
1403 { |
|
1404 if( value == _L( "FILE" ) ) |
|
1405 { |
|
1406 iTestReportSettings->iOutput = CStifLogger::EFile; |
|
1407 } |
|
1408 else if( value == _L( "RDEBUG" ) ) |
|
1409 { |
|
1410 iTestReportSettings->iOutput = CStifLogger::ERDebug; |
|
1411 } |
|
1412 |
|
1413 } |
|
1414 else if(key==KTestReportFileCreationMode) |
|
1415 { |
|
1416 if( value == _L( "APPEND" ) ) |
|
1417 { |
|
1418 iTestReportSettings->iOverwrite = EFalse; |
|
1419 } |
|
1420 else if( value == _L( "OVERWRITE") ) |
|
1421 { |
|
1422 iTestReportSettings->iOverwrite = ETrue; |
|
1423 } |
|
1424 |
|
1425 } |
|
1426 else if(key==KDeviceResetDllName) |
|
1427 { |
|
1428 delete iDeviceResetDllName; |
|
1429 iDeviceResetDllName = NULL; |
|
1430 iDeviceResetDllName = value.AllocL(); |
|
1431 } |
|
1432 else if(key==KTimeout) |
|
1433 { |
|
1434 TLex temp(value); |
|
1435 lex.Val(iDefaultTimeout); |
|
1436 iDefaultTimeout *= 1000; |
|
1437 } |
|
1438 else if(key==KUITestingSupport) |
|
1439 { |
|
1440 iUITestingSupport = (value == _L("YES")); |
|
1441 } |
|
1442 else if(key==KSeparateProcesses) |
|
1443 { |
|
1444 iSeparateProcesses = (value == _L("YES")); |
|
1445 } |
|
1446 else if(key==KDisableMeasurement) |
|
1447 { |
|
1448 if( value == KStifMeasurementDisableNone || |
|
1449 value == KStifMeasurementDisableAll || |
|
1450 value == KStifMeasurement01 || |
|
1451 value == KStifMeasurement02 || |
|
1452 value == KStifMeasurement03 || |
|
1453 value == KStifMeasurement04 || |
|
1454 value == KStifMeasurement05 || |
|
1455 value == KStifMeasurementBappea ) |
|
1456 { |
|
1457 |
|
1458 DisableStifMeasurement( value ); |
|
1459 } |
|
1460 |
|
1461 |
|
1462 } |
|
1463 } |
|
1464 } |
|
1465 |
|
1466 |
|
1467 } |
|
1468 void CTestEngine::UpdateEngineConfigurationL( const RMessage2& aMessage ) |
|
1469 { |
|
1470 TBuf<256> engineconfiguration; |
|
1471 aMessage.ReadL( 0, engineconfiguration ); |
|
1472 engineconfiguration.TrimAll(); |
|
1473 ReadEngineFromCommandLineL(engineconfiguration); |
|
1474 |
|
1475 } |
|
1476 |
|
1477 |
|
1478 /* |
|
1479 ------------------------------------------------------------------------------- |
|
1480 |
|
1481 Class: CTestEngine |
|
1482 |
|
1483 Method: ParseTestModulesL |
|
1484 |
|
1485 Description: Parse and search for module info and fill list of modules. |
|
1486 |
|
1487 Parameters: CStifParser* aParser: in: CStifParser object |
|
1488 CTestModuleList* aModuleList: in: list of modules |
|
1489 TPtrC& aSectionStart: in: descriptor with start of section string |
|
1490 TPTrC& aSectionEnd: in: descriptor with end of section string |
|
1491 |
|
1492 Return Values: None |
|
1493 |
|
1494 Errors/Exceptions: Leaves if some of called leaving methods leaves |
|
1495 |
|
1496 Status: Approved |
|
1497 |
|
1498 ------------------------------------------------------------------------------- |
|
1499 */ |
|
1500 void CTestEngine::ParseTestModulesL(CStifParser* aParser, CTestModuleList* aModuleList, const TDesC& aSectionStart, const TDesC& aSectionEnd) |
|
1501 { |
|
1502 //First let's find all modules given in Stif's ini file and store that info in CTestModuleList object |
|
1503 CStifSectionParser* sectionParser = NULL; |
|
1504 CStifItemParser* item = NULL; |
|
1505 |
|
1506 sectionParser = aParser->SectionL(aSectionStart, aSectionEnd); |
|
1507 |
|
1508 TBool sectionOK; |
|
1509 |
|
1510 while(sectionParser) |
|
1511 { |
|
1512 sectionOK = ETrue; |
|
1513 __TRACE(KInit, (_L("Found '%S' and '%S' sections"), &aSectionStart, &aSectionEnd)); |
|
1514 CleanupStack::PushL(sectionParser); |
|
1515 __TRACE(KInit, (_L("Starting to read module information"))); |
|
1516 |
|
1517 // Get name of module |
|
1518 _LIT(KModuleName, "ModuleName="); |
|
1519 item = sectionParser->GetItemLineL(KModuleName); |
|
1520 CleanupStack::PushL(item); |
|
1521 if(!item) |
|
1522 { |
|
1523 __TRACE(KError, (CStifLogger::ERed, _L("'%S' not found from Module section. Skipping whole section."), &KModuleName)); |
|
1524 sectionOK = EFalse; |
|
1525 } |
|
1526 else |
|
1527 { |
|
1528 __TRACE(KInit, (_L("'%S' found"), &KModuleName)); |
|
1529 } |
|
1530 |
|
1531 TName moduleName; |
|
1532 TInt ret(KErrNone); |
|
1533 |
|
1534 if(sectionOK) |
|
1535 { |
|
1536 TPtrC name; |
|
1537 ret = item->GetString(KModuleName, name); |
|
1538 if(ret != KErrNone) |
|
1539 { |
|
1540 __TRACE(KError, (CStifLogger::ERed, _L("Module name parsing ended with error [%d]. Skipping whole section"), ret)); |
|
1541 sectionOK = EFalse; |
|
1542 } |
|
1543 else |
|
1544 { |
|
1545 __TRACE(KInit, (_L("Module '%S' found from ini-file"), &name)); |
|
1546 moduleName.Copy(name); |
|
1547 moduleName.LowerCase(); |
|
1548 ret = aModuleList->AddTestModule(moduleName); |
|
1549 if(ret != KErrNone && ret != KErrAlreadyExists) |
|
1550 { |
|
1551 CleanupStack::PopAndDestroy(item); |
|
1552 __TRACE(KError, (CStifLogger::ERed, _L("Could not add module to list of modules. Error %d"), ret)); |
|
1553 LeaveIfErrorWithNotify(ret); |
|
1554 } |
|
1555 } |
|
1556 } |
|
1557 CleanupStack::PopAndDestroy(item); |
|
1558 |
|
1559 //Get pointer to added module |
|
1560 if(sectionOK) |
|
1561 { |
|
1562 CTestModuleInfo* moduleInfo = aModuleList->GetModule(moduleName); |
|
1563 if(!moduleInfo) |
|
1564 { |
|
1565 __TRACE(KError, (CStifLogger::ERed, _L("Could not add get module info from list"))); |
|
1566 LeaveIfErrorWithNotify(KErrNotFound); |
|
1567 } |
|
1568 |
|
1569 // Get ini file, if it exists |
|
1570 __TRACE(KInit, (_L("Start parsing ini file"))); |
|
1571 _LIT(KIniFile, "IniFile="); |
|
1572 item = sectionParser->GetItemLineL(KIniFile); |
|
1573 if(item) |
|
1574 { |
|
1575 __TRACE(KInit, (_L("'%S' found"), &KIniFile)); |
|
1576 CleanupStack::PushL(item); |
|
1577 TPtrC iniFile; |
|
1578 ret = item->GetString(KIniFile, iniFile); |
|
1579 if(ret == KErrNone) |
|
1580 { |
|
1581 // Module inifile (might be empty) OK |
|
1582 TFileName filename; |
|
1583 filename.Copy(iniFile); |
|
1584 TStifUtil::CorrectFilePathL( filename ); |
|
1585 filename.LowerCase(); |
|
1586 __TRACE(KInit, (CStifLogger::EBold, _L("Initialization file '%S' found, file can be empty"), &iniFile)); |
|
1587 moduleInfo->SetIniFile(filename); |
|
1588 } |
|
1589 else |
|
1590 { |
|
1591 __TRACE(KInit, (_L("Initialization file not found"))); |
|
1592 } |
|
1593 CleanupStack::PopAndDestroy(item); |
|
1594 } |
|
1595 else |
|
1596 { |
|
1597 __TRACE(KInit, (_L("'%S' not found"), &KIniFile)); |
|
1598 } |
|
1599 |
|
1600 // Get config (testcase) file |
|
1601 __TRACE(KInit, (_L("Start parsing cfg files"))); |
|
1602 TPtrC cfgTag; |
|
1603 for(TInt i = 0; i < 2; i++) |
|
1604 { |
|
1605 //Set tag for config files |
|
1606 if(i == 0) |
|
1607 { |
|
1608 cfgTag.Set(_L("ConfigFile=")); |
|
1609 } |
|
1610 else |
|
1611 { |
|
1612 cfgTag.Set(_L("TestCaseFile=")); |
|
1613 } |
|
1614 //Read data |
|
1615 item = sectionParser->GetItemLineL(cfgTag); |
|
1616 while(item) |
|
1617 { |
|
1618 CleanupStack::PushL(item); |
|
1619 __TRACE(KInit, (_L("Item '%S' found"), &cfgTag)); |
|
1620 TPtrC cfgFile; |
|
1621 ret = item->GetString(cfgTag, cfgFile); |
|
1622 if(ret == KErrNone) |
|
1623 { |
|
1624 TFileName ifile; |
|
1625 ifile.Copy(cfgFile); |
|
1626 TStifUtil::CorrectFilePathL( ifile ); |
|
1627 ifile.LowerCase(); |
|
1628 __TRACE(KInit, (_L("Configuration file '%S' found"), &ifile)); |
|
1629 moduleInfo->AddCfgFile(ifile); |
|
1630 } |
|
1631 else |
|
1632 { |
|
1633 __TRACE(KInit, (_L("Configuration file not found"))); |
|
1634 } |
|
1635 CleanupStack::PopAndDestroy(item); |
|
1636 item = sectionParser->GetNextItemLineL(cfgTag); |
|
1637 } |
|
1638 } |
|
1639 |
|
1640 __TRACE(KInit, (_L("Module '%S' information read correctly"), &moduleName)); |
|
1641 } |
|
1642 else |
|
1643 { |
|
1644 __TRACE(KError, (_L("Module '%S' information skipped"), &moduleName)); |
|
1645 } |
|
1646 |
|
1647 // Get next section... |
|
1648 CleanupStack::PopAndDestroy(sectionParser); |
|
1649 sectionParser = aParser->NextSectionL(aSectionStart, aSectionEnd); |
|
1650 } |
|
1651 } |
|
1652 |
|
1653 /* |
|
1654 ------------------------------------------------------------------------------- |
|
1655 |
|
1656 Class: CTestEngine |
|
1657 |
|
1658 Method: ReadTestModules |
|
1659 |
|
1660 Description: Parse Test modules and module information from |
|
1661 STIF initialization file. |
|
1662 |
|
1663 Parameters: CStifParser& parser: in: CStifParser object |
|
1664 |
|
1665 Return Values: None |
|
1666 |
|
1667 Errors/Exceptions: Leaves if some of called leaving methods leaves |
|
1668 |
|
1669 Status: Approved |
|
1670 |
|
1671 ------------------------------------------------------------------------------- |
|
1672 */ |
|
1673 void CTestEngine::ReadTestModulesL(CStifParser* aParser) |
|
1674 { |
|
1675 __TRACE( KInit, (_L(""))); |
|
1676 __TRACE( KInit, (CStifLogger::EBold, _L("Start parsing test modules"))); |
|
1677 |
|
1678 //Create CTestModuleList object. It will keep information about all found test modules, |
|
1679 //its initialization files and test case (config) files. |
|
1680 CTestModuleList* moduleList = CTestModuleList::NewL(Logger()); |
|
1681 CleanupStack::PushL(moduleList); |
|
1682 |
|
1683 // Parse Test Module information |
|
1684 _LIT(KTestModuleStart, "[New_Module]"); |
|
1685 _LIT(KTestModuleEnd, "[End_Module]"); |
|
1686 |
|
1687 __TRACE(KInit, (_L("Starting to search module sections"))); |
|
1688 TRAPD(err, ParseTestModulesL(aParser, moduleList, KTestModuleStart, KTestModuleEnd)); |
|
1689 if(err != KErrNone) |
|
1690 { |
|
1691 __TRACE(KError, (CStifLogger::ERed, _L("Parsing test modules returned error [%d]"), err)); |
|
1692 User::Leave(err); |
|
1693 } |
|
1694 __TRACE(KInit, (CStifLogger::EBold, _L("End parsing test modules"))); |
|
1695 __TRACE(KInit, (_L(""))); |
|
1696 |
|
1697 //Now, find included test modules and also add them to CTestModuleList object. |
|
1698 _LIT(KIncludeModuleStart, "[New_Include_Module]"); |
|
1699 _LIT(KIncludeModuleEnd, "[End_Include_Module]"); |
|
1700 |
|
1701 __TRACE(KInit, (CStifLogger::EBold, _L("Start parsing included modules"))); |
|
1702 CTestCaseFileInfo* finfo = moduleList->GetUncheckedCfgFile(); |
|
1703 while(finfo) |
|
1704 { |
|
1705 TFileName fname; |
|
1706 finfo->GetCfgFileName(fname); |
|
1707 |
|
1708 __TRACE(KInit, (_L("checking file: '%S'"), &fname)); |
|
1709 finfo->SetChecked(); |
|
1710 |
|
1711 CStifParser* parser = NULL; |
|
1712 |
|
1713 TRAPD(err, parser = CStifParser::NewL(_L(""), fname)); |
|
1714 if(err == KErrNotFound) |
|
1715 { |
|
1716 __TRACE(KError, (CStifLogger::ERed, _L("Could not open file '%S'"), &fname)); |
|
1717 } |
|
1718 else if(err != KErrNone) |
|
1719 { |
|
1720 __TRACE(KError, (CStifLogger::ERed, _L("Could not create parser for file '%S'"), &fname)); |
|
1721 LeaveIfErrorWithNotify(err); |
|
1722 } |
|
1723 else |
|
1724 { |
|
1725 CleanupStack::PushL(parser); |
|
1726 |
|
1727 ParseTestModulesL(parser, moduleList, KIncludeModuleStart, KIncludeModuleEnd); |
|
1728 |
|
1729 CleanupStack::PopAndDestroy(parser); |
|
1730 } |
|
1731 |
|
1732 finfo = moduleList->GetUncheckedCfgFile(); |
|
1733 } |
|
1734 |
|
1735 __TRACE(KInit, (CStifLogger::EBold, _L("End parsing included modules"))); |
|
1736 __TRACE(KInit, (_L(""))); |
|
1737 |
|
1738 //Now, when all modules have been found, create them |
|
1739 __TRACE(KInit, (CStifLogger::EBold, _L("Start creating modules"))); |
|
1740 TBool afterReset = EFalse; |
|
1741 if(iRebootParams) |
|
1742 { |
|
1743 afterReset = ETrue; |
|
1744 } |
|
1745 CTestModuleInfo* moduleInfo = NULL; |
|
1746 TInt i; |
|
1747 TInt modCnt = moduleList->Count(); |
|
1748 |
|
1749 for(i = 0; i < modCnt; i++) |
|
1750 { |
|
1751 moduleInfo = moduleList->GetModule(i); |
|
1752 if(!moduleInfo) |
|
1753 { |
|
1754 __TRACE(KInit, (CStifLogger::ERed, _L("Could not get module info at index %d"), i)); |
|
1755 TName error; |
|
1756 error.AppendFormat(_L("Could not get module info at index %d"), i); |
|
1757 ErrorPrint(1, error); |
|
1758 continue; |
|
1759 } |
|
1760 |
|
1761 TName moduleName; |
|
1762 moduleInfo->GetModuleName(moduleName); |
|
1763 |
|
1764 // Create module controller |
|
1765 __TRACE(KInit, (_L("Creating module controller for '%S'"), &moduleName)); |
|
1766 CTestModuleController* module = NULL; |
|
1767 if( moduleName == _L( "testscripter" ) ) |
|
1768 { |
|
1769 module = CTestModuleController::NewL(this, moduleName, afterReset, ETrue); |
|
1770 } |
|
1771 else |
|
1772 { |
|
1773 module = CTestModuleController::NewL(this, moduleName, afterReset); |
|
1774 } |
|
1775 CleanupStack::PushL(module); |
|
1776 __TRACE(KInit, (_L("Module controller created"))); |
|
1777 |
|
1778 // Get ini file, if exists |
|
1779 __TRACE(KInit, (_L("Checking ini file"))); |
|
1780 TFileName ini; |
|
1781 moduleInfo->GetIniFileName(ini); |
|
1782 if(ini.Length() == 0) |
|
1783 { |
|
1784 __TRACE(KInit, (_L("Ini file not found"))); |
|
1785 } |
|
1786 |
|
1787 TRAPD(err, module->InitL(ini, KNullDesC)); |
|
1788 if(err != KErrNone) |
|
1789 { |
|
1790 __TRACE(KInit, (CStifLogger::ERed, _L("Module '%S' loading failed: %d"), &moduleName, err)); |
|
1791 TName error; |
|
1792 error.AppendFormat(_L("Module '%S' loading failed: %d"), &moduleName, err); |
|
1793 ErrorPrint(1, error); |
|
1794 |
|
1795 CleanupStack::PopAndDestroy(module); |
|
1796 continue; |
|
1797 } |
|
1798 |
|
1799 //Add test case files |
|
1800 __TRACE(KInit, (_L("Checking cfg files"))); |
|
1801 TInt cfgCnt = moduleInfo->CountCfgFiles(); |
|
1802 TInt j; |
|
1803 TFileName cfgFile; |
|
1804 for(j = 0; j < cfgCnt; j++) |
|
1805 { |
|
1806 moduleInfo->GetCfgFileName(j, cfgFile); |
|
1807 if(cfgFile.Length() > 0) |
|
1808 { |
|
1809 __TRACE(KInit, (_L("Adding config file '%S'"), &cfgFile)); |
|
1810 module->AddConfigFileL(cfgFile); |
|
1811 } |
|
1812 else |
|
1813 { |
|
1814 __TRACE(KInit, (_L("Got empty config filename"))); |
|
1815 } |
|
1816 } |
|
1817 if(cfgCnt == 0) |
|
1818 { |
|
1819 __TRACE(KInit, (_L("Cfg file not found"))); |
|
1820 } |
|
1821 |
|
1822 __TRACE(KInit, (_L("Module '%S' created correctly"), &moduleName)); |
|
1823 |
|
1824 // Store module for later use |
|
1825 User::LeaveIfError(iModules.Append(module)); |
|
1826 CleanupStack::Pop(module); |
|
1827 } |
|
1828 |
|
1829 __TRACE(KInit, (CStifLogger::EBold, _L("End creating test modules"))); |
|
1830 __TRACE(KInit, (_L(""))); |
|
1831 |
|
1832 //Check if there are any modules added to Stif |
|
1833 if (iModules.Count() == 0) |
|
1834 { |
|
1835 __TRACE(KInit, (_L("Not found '%S' and '%S' sections"), &KTestModuleStart, &KTestModuleEnd)); |
|
1836 __TRACE(KInit, (CStifLogger::EBold, _L("Test module(s) not defined in initialisation file"))); |
|
1837 // Note is printed from UI, not from here anymore |
|
1838 // ErrorPrint( 0 , _L("Test modules not found. Check testengine log")); |
|
1839 } |
|
1840 |
|
1841 //Delete CTestModuleList object. It is not needed any more |
|
1842 CleanupStack::PopAndDestroy(moduleList); |
|
1843 } |
|
1844 |
|
1845 /* |
|
1846 ------------------------------------------------------------------------------- |
|
1847 |
|
1848 Class: CTestEngine |
|
1849 |
|
1850 Method: TestModuleConfigFileL |
|
1851 |
|
1852 Description: Add config file to test module |
|
1853 |
|
1854 Parameters: CTestModuleController* aModule: in: CTestModuleController |
|
1855 object. |
|
1856 CStifSectionParser* aSectionParser: in: CStifSectionParser |
|
1857 object. |
|
1858 TDesC& aTag :in: Founded tag. |
|
1859 |
|
1860 Return Values: None |
|
1861 |
|
1862 Errors/Exceptions: Leaves if GetNextItemLineL leaves |
|
1863 |
|
1864 Status: Approved |
|
1865 |
|
1866 ------------------------------------------------------------------------------- |
|
1867 */ |
|
1868 void CTestEngine::TestModuleConfigFileL( CTestModuleController* aModule, |
|
1869 CStifSectionParser* aSectionParser, |
|
1870 TDesC& aTag ) |
|
1871 { |
|
1872 // Add config files to Test Module |
|
1873 TPtrC configFile; |
|
1874 CStifItemParser* item = NULL; |
|
1875 item = aSectionParser->GetItemLineL( aTag ); |
|
1876 |
|
1877 TInt cfgFiles = 0; |
|
1878 TFileName config; |
|
1879 |
|
1880 TInt ret( 0 ); |
|
1881 |
|
1882 while ( item ) |
|
1883 { |
|
1884 __TRACE( KInit,( _L( "Found '%S' section" ), &aTag ) ); |
|
1885 CleanupStack::PushL( item ); |
|
1886 ret = item->GetString( aTag, configFile ); |
|
1887 if ( ret != KErrNone ) |
|
1888 { |
|
1889 CleanupStack::PopAndDestroy( item ); |
|
1890 __TRACE( KError, ( CStifLogger::ERed, _L( "File parsing left with error [%d]" ), ret ) ); |
|
1891 } |
|
1892 else |
|
1893 { |
|
1894 config = configFile; |
|
1895 aModule->AddConfigFileL( config ); |
|
1896 |
|
1897 // Module configfile (might be empty) OK |
|
1898 __TRACE( KInit,( _L( "Adding configuration file [%S]" ), &config ) ); |
|
1899 cfgFiles++; |
|
1900 CleanupStack::PopAndDestroy( item ); |
|
1901 } |
|
1902 item = aSectionParser->GetNextItemLineL( aTag ); |
|
1903 } |
|
1904 |
|
1905 // Print trace |
|
1906 if ( cfgFiles == 0) |
|
1907 { |
|
1908 __TRACE( KInit,( _L( "Module does not have '%S' files") , &aTag ) ); |
|
1909 } |
|
1910 |
|
1911 } |
|
1912 |
|
1913 /* |
|
1914 ------------------------------------------------------------------------------- |
|
1915 |
|
1916 Class: CTestEngine |
|
1917 |
|
1918 Method: ModuleControllerByName |
|
1919 |
|
1920 Description: Return the module controller specified by given parameter. |
|
1921 |
|
1922 Parameters: const TName& aModuleName: in: Test module name |
|
1923 |
|
1924 Return Values: CTestModuleController* : pointer to CTestModuleController |
|
1925 |
|
1926 Errors/Exceptions: None |
|
1927 |
|
1928 Status: Approved |
|
1929 |
|
1930 ------------------------------------------------------------------------------- |
|
1931 */ |
|
1932 CTestModuleController* CTestEngine::ModuleControllerByName( |
|
1933 const TName& aModuleName ) |
|
1934 { |
|
1935 TInt modules = iModules.Count(); |
|
1936 |
|
1937 for ( TInt i = 0; i < modules; i++ ) |
|
1938 { |
|
1939 if ( iModules[i]->ModuleName( aModuleName ) == aModuleName ) |
|
1940 { |
|
1941 return iModules[i]; |
|
1942 } |
|
1943 } |
|
1944 return NULL; |
|
1945 } |
|
1946 |
|
1947 /* |
|
1948 ------------------------------------------------------------------------------- |
|
1949 |
|
1950 Class: CTestEngine |
|
1951 |
|
1952 Method: GetFreeOrCreateModuleControllerL |
|
1953 |
|
1954 Description: Return free module controller specified by given parameter. |
|
1955 If it can't be found, new one will be created. |
|
1956 |
|
1957 Parameters: TTestInfo& aTestInfo: test info structure |
|
1958 CTestModuleController** aRealModuleController: for test scripter a real module controller will be returned |
|
1959 |
|
1960 Return Values: CTestModuleController* : pointer to CTestModuleController |
|
1961 |
|
1962 Errors/Exceptions: None |
|
1963 |
|
1964 Status: Approved |
|
1965 |
|
1966 ------------------------------------------------------------------------------- |
|
1967 */ |
|
1968 CTestModuleController* CTestEngine::GetFreeOrCreateModuleControllerL(TTestInfo& aTestInfo, |
|
1969 CTestModuleController** aRealModuleController) |
|
1970 { |
|
1971 TInt i, j; |
|
1972 *aRealModuleController = NULL; |
|
1973 |
|
1974 TInt modules = iModules.Count(); |
|
1975 |
|
1976 //Find out which way it should be processed |
|
1977 //New way means that Stif is going to find free test module controller |
|
1978 //(free means that it does not run any test case) |
|
1979 TBool oldWay = ETrue; |
|
1980 if((iUITestingSupport && aTestInfo.iModuleName.Find(KTestScripterName) == 0) |
|
1981 || (aTestInfo.iModuleName == KPythonScripter) |
|
1982 || (iSeparateProcesses)) |
|
1983 { |
|
1984 __TRACE(KInit, (_L("Module controllers handling mode: exclusive"))); |
|
1985 //Exclusive mode means that every test case must be run in separate module controller. |
|
1986 oldWay = EFalse; |
|
1987 } |
|
1988 else |
|
1989 { |
|
1990 __TRACE(KInit, (_L("Module controllers handling mode: normal"))); |
|
1991 oldWay = ETrue; |
|
1992 } |
|
1993 |
|
1994 //If option is not set and it is not python scripter case |
|
1995 //(python scripter always should look for free module controller) |
|
1996 //This is the old way |
|
1997 if(oldWay) |
|
1998 { |
|
1999 __TRACE(KInit, (_L("Find test module controller for [%S]"), &aTestInfo.iModuleName)); |
|
2000 for(i = 0; i < modules; i++) |
|
2001 { |
|
2002 if(iModules[i]->ModuleName(aTestInfo.iModuleName) == aTestInfo.iModuleName) |
|
2003 { |
|
2004 __TRACE(KInit, (_L("Found test module controller for [%S]"), &aTestInfo.iModuleName)); |
|
2005 return iModules[i]; |
|
2006 } |
|
2007 } |
|
2008 __TRACE(KInit, (_L("Test module controller for [%S] NOT FOUND"), &aTestInfo.iModuleName)); |
|
2009 return NULL; |
|
2010 } |
|
2011 |
|
2012 //This is a new way |
|
2013 __TRACE(KInit, (_L("Find free test module controller for [%S]"), &aTestInfo.iModuleName)); |
|
2014 |
|
2015 TName moduleName(aTestInfo.iModuleName); |
|
2016 CTestModuleController* parentController = NULL; |
|
2017 |
|
2018 //First find original test module controller (parent) |
|
2019 for(TInt i = 0; i < modules; i++) |
|
2020 { |
|
2021 if(iModules[i]->ModuleName(moduleName) == moduleName) |
|
2022 { |
|
2023 parentController = iModules[i]; |
|
2024 __TRACE(KInit, (_L("Original (parent) module controller found [%S]"), &moduleName)); |
|
2025 break; |
|
2026 } |
|
2027 } |
|
2028 |
|
2029 //Search free module controller among parent's children |
|
2030 if(parentController) |
|
2031 { |
|
2032 //TestScripter is handled in other way |
|
2033 if(moduleName.Find(KTestScripterName) == 0) |
|
2034 { |
|
2035 __TRACE(KInit, (_L("This is testscripter case. Searching real module controller."))); |
|
2036 *aRealModuleController = parentController->GetFreeOrCreateModuleControllerL(aTestInfo, iUITestingSupport); |
|
2037 return parentController; |
|
2038 } |
|
2039 |
|
2040 //When UITestingSupport always create new module controller! |
|
2041 TInt childrenCount = parentController->iChildrenControllers.Count(); |
|
2042 for(TInt i = 0; i < childrenCount; i++) |
|
2043 { |
|
2044 if(parentController->iChildrenControllers[i]->iTestCaseCounter == 0) |
|
2045 { |
|
2046 if(iUITestingSupport && aTestInfo.iModuleName.Find(KTestScripterName) == 0) |
|
2047 { |
|
2048 __TRACE(KInit, (_L("Free module controller found but in UITestingSupport mode always new one will be created"))); |
|
2049 } |
|
2050 else |
|
2051 { |
|
2052 __TRACE(KInit, (_L("Free module controller found [%S]"), parentController->iChildrenControllers[i]->iName)); |
|
2053 return parentController->iChildrenControllers[i]; |
|
2054 } |
|
2055 } |
|
2056 else |
|
2057 { |
|
2058 __TRACE(KInit, (_L("Module controller [%S] found but it is not free (it runs %d test cases)"), parentController->iChildrenControllers[i]->iName, parentController->iChildrenControllers[i]->iTestCaseCounter)); |
|
2059 } |
|
2060 } |
|
2061 } |
|
2062 else |
|
2063 { |
|
2064 __TRACE(KError, (_L("Parent module controller NOT found [%S]"), &moduleName)); |
|
2065 User::Leave(KErrNotFound); |
|
2066 } |
|
2067 |
|
2068 //No free module controller has been found. Create new one. |
|
2069 TBuf<10> ind; |
|
2070 ind.Format(_L("%d"), GetIndexForNewTestModuleController()); |
|
2071 moduleName.Append(_L("@")); |
|
2072 moduleName.Append(ind); |
|
2073 __TRACE(KInit, (_L("Free module controller not found. Creating new one [%S]."), &moduleName)); |
|
2074 |
|
2075 //Create server and active object (This uses CTestModuleController::InitL()) |
|
2076 CTestModuleController* module = CTestModuleController::NewL(this, moduleName, parentController->iAfterReboot); |
|
2077 CleanupStack::PushL(module); |
|
2078 |
|
2079 TRAPD(err, module->InitL(parentController->iInifile, aTestInfo.iConfig)); |
|
2080 if(err != KErrNone) |
|
2081 { |
|
2082 __TRACE(KInit, (_L("InitL fails with error: %d for module [%S]" ), err, &moduleName)); |
|
2083 User::Leave(err); |
|
2084 } |
|
2085 __TRACE(KInit, (_L("New module controller created [%S]."), &moduleName)); |
|
2086 |
|
2087 // Store module for later use |
|
2088 User::LeaveIfError(parentController->iChildrenControllers.Append(module)); |
|
2089 CleanupStack::Pop(module); |
|
2090 __TRACE(KInit, (_L("Child added to [%S] controller. Currently it has %d children:"), parentController->iName, parentController->iChildrenControllers.Count())); |
|
2091 for(j = 0; j < parentController->iChildrenControllers.Count(); j++) |
|
2092 { |
|
2093 __TRACE(KInit, (_L(" %d. [%S]"), j + 1, parentController->iChildrenControllers[j]->iName)); |
|
2094 } |
|
2095 |
|
2096 return module; |
|
2097 } |
|
2098 |
|
2099 /* |
|
2100 ------------------------------------------------------------------------------- |
|
2101 |
|
2102 Class: CTestEngine |
|
2103 |
|
2104 Method: SetAttributeL |
|
2105 |
|
2106 Description: Sets attributes to Test Framework |
|
2107 |
|
2108 Parameters: const RMessage& aMessage: in: Server message |
|
2109 |
|
2110 Return Values: None |
|
2111 |
|
2112 Errors/Exceptions: Leave if ReadL leaves |
|
2113 |
|
2114 Status: Approved |
|
2115 |
|
2116 ------------------------------------------------------------------------------- |
|
2117 */ |
|
2118 void CTestEngine::SetAttributeL( const RMessage2& aMessage ) |
|
2119 { |
|
2120 __TRACE( KVerbose, ( _L( "CTestEngine::SetAttributeL" ) ) ); |
|
2121 |
|
2122 TAttribute attribute; |
|
2123 TName genericTName; |
|
2124 |
|
2125 // Read attribute from aMessage |
|
2126 attribute = (TAttribute)aMessage.Int0(); |
|
2127 |
|
2128 switch( attribute ) |
|
2129 { |
|
2130 // Path attribute |
|
2131 case ELogPath: |
|
2132 { |
|
2133 // Read path from aMessage. |
|
2134 // NOTE!If message length is over TName, ReadL will cut the message |
|
2135 // to allowed size and won't return any error code or leave code. |
|
2136 aMessage.ReadL( 1, genericTName ); |
|
2137 |
|
2138 // Handle to Setting server. |
|
2139 RSettingServer settingServer; |
|
2140 // Connect to the Setting server and create session |
|
2141 TInt ret = settingServer.Connect(); |
|
2142 if ( ret != KErrNone ) |
|
2143 { |
|
2144 User::Leave( ret ); |
|
2145 } |
|
2146 settingServer.SetLoggerOutputPath( genericTName ); |
|
2147 // Close Setting server session |
|
2148 settingServer.Close(); |
|
2149 break; |
|
2150 } |
|
2151 // Reboot directory |
|
2152 case ERebootPath: |
|
2153 { |
|
2154 // Read reboot path from aMessage. |
|
2155 // NOTE!If message length is over TName, ReadL will cut the message |
|
2156 // to allowed size and won't return any error code or leave code. |
|
2157 aMessage.ReadL( 1, genericTName ); |
|
2158 // Allocated dynamically iRebootPath size and copies aMessage path. |
|
2159 iRebootPath = genericTName.AllocL(); |
|
2160 break; |
|
2161 } |
|
2162 // Reboot path |
|
2163 case ERebootFilename: |
|
2164 { |
|
2165 // Read reboot path from aMessage. |
|
2166 // NOTE!If message length is over TName, ReadL will cut the message |
|
2167 // to allowed size and won't return any error code or leave code. |
|
2168 aMessage.ReadL( 1, genericTName ); |
|
2169 // Allocated dynamically iRebootFilename size and copies aMessage |
|
2170 // filename. |
|
2171 iRebootFilename = genericTName.AllocL(); |
|
2172 break; |
|
2173 } |
|
2174 // Measurement configuration info |
|
2175 case EStifMeasurementOn: |
|
2176 { |
|
2177 // Read Measurement configuration info from aMessage. |
|
2178 aMessage.ReadL( 1, genericTName ); |
|
2179 |
|
2180 // Set info to test engine |
|
2181 User::LeaveIfError( EnableStifMeasurement( genericTName ) ); |
|
2182 break; |
|
2183 } |
|
2184 // Measurement configuration info |
|
2185 case EStifMeasurementOff: |
|
2186 { |
|
2187 // Read Measurement configuration info from aMessage. |
|
2188 aMessage.ReadL( 1, genericTName ); |
|
2189 |
|
2190 // Set info to test engine |
|
2191 User::LeaveIfError( DisableStifMeasurement( genericTName ) ); |
|
2192 break; |
|
2193 } |
|
2194 default: |
|
2195 { |
|
2196 __TRACE( KVerbose, ( _L( "Not valid attribute" ) ) ); |
|
2197 } |
|
2198 } |
|
2199 |
|
2200 } |
|
2201 |
|
2202 /* |
|
2203 ------------------------------------------------------------------------------- |
|
2204 |
|
2205 Class: CTestEngine |
|
2206 |
|
2207 Method: AddTestModuleL |
|
2208 |
|
2209 Description: Adds new Test Module |
|
2210 |
|
2211 Parameters: const RMessage& aMessage: in: Server message |
|
2212 |
|
2213 Return Values: None |
|
2214 |
|
2215 Errors/Exceptions: Leaves if some of called leaving methods leaves |
|
2216 Leaves if name length is zero |
|
2217 |
|
2218 Status: Approved: Proposal |
|
2219 |
|
2220 ------------------------------------------------------------------------------- |
|
2221 */ |
|
2222 void CTestEngine::AddTestModuleL( const RMessage2& aMessage ) |
|
2223 { |
|
2224 __TRACE( KVerbose, ( _L( "CTestEngine::AddTestModuleL" ) ) ); |
|
2225 TName name; |
|
2226 TFileName iniFile; |
|
2227 |
|
2228 // Read test module name from aMessage |
|
2229 aMessage.ReadL( 0, name ); |
|
2230 |
|
2231 if( name.Length() == 0 ) |
|
2232 { |
|
2233 LeaveWithNotifyL( KErrArgument ); |
|
2234 } |
|
2235 // Read ini file name from aMessage |
|
2236 aMessage.ReadL( 1, iniFile ); |
|
2237 |
|
2238 name.LowerCase(); |
|
2239 // Remove optional '.DLL' from file name |
|
2240 TParse parse; |
|
2241 parse.Set( name, NULL, NULL ); |
|
2242 |
|
2243 if ( parse.Ext() == _L(".dll") ) |
|
2244 { |
|
2245 const TInt len = parse.Ext().Length(); |
|
2246 name.Delete ( name.Length()-len, len ); |
|
2247 } |
|
2248 |
|
2249 __TRACE( KInit, ( |
|
2250 _L( "CTestEngine::AddTestModuleL, Adding Module:[%S]"), &name ) ); |
|
2251 |
|
2252 // Check if test module already exists |
|
2253 CTestModuleController* testModule = ModuleControllerByName( name ); |
|
2254 if ( testModule == NULL ) |
|
2255 { |
|
2256 TBool afterReset = EFalse; |
|
2257 if( iRebootParams && iRebootParams->iTestModule == name ) |
|
2258 { |
|
2259 afterReset = ETrue; |
|
2260 } |
|
2261 |
|
2262 // Create module controller |
|
2263 CTestModuleController* module = NULL; |
|
2264 if( name == _L( "testscripter" ) ) |
|
2265 { |
|
2266 module = CTestModuleController::NewL( this, name, afterReset, ETrue ); |
|
2267 } |
|
2268 else |
|
2269 { |
|
2270 //CTestModuleController* module = |
|
2271 module = CTestModuleController::NewL( this, name, afterReset ); |
|
2272 } |
|
2273 CleanupStack::PushL( module ); |
|
2274 |
|
2275 module->InitL( iniFile, KNullDesC ); |
|
2276 |
|
2277 // Store module for later use |
|
2278 User::LeaveIfError( iModules.Append( module ) ); |
|
2279 CleanupStack::Pop( module ); |
|
2280 // Done |
|
2281 iReturn = KErrNone; |
|
2282 |
|
2283 __TRACE( KInit, ( |
|
2284 _L( "CTestEngine::AddTestModuleL, module added correctly") ) ); |
|
2285 } |
|
2286 else |
|
2287 { |
|
2288 iReturn = KErrAlreadyExists; |
|
2289 __TRACE( KInit, ( |
|
2290 _L( "CTestEngine::AddTestModuleL, module already added, all ok.") ) ); |
|
2291 } |
|
2292 |
|
2293 } |
|
2294 |
|
2295 /* |
|
2296 ------------------------------------------------------------------------------- |
|
2297 |
|
2298 Class: CTestEngine |
|
2299 |
|
2300 Method: RemoveTestModuleL |
|
2301 |
|
2302 Description: Removes Test Module |
|
2303 |
|
2304 Parameters: const RMessage& aMessage: in: Server message |
|
2305 |
|
2306 Return Values: TInt KErrNone: No errors occurred |
|
2307 KErrNotFound: Test module not found |
|
2308 KErrInUse: Test module is in use, cannot be removed |
|
2309 |
|
2310 Errors/Exceptions: Leaves if some of called leaving methods leaves |
|
2311 Leaves if moduleName length is zero |
|
2312 |
|
2313 Status: Approved |
|
2314 |
|
2315 ------------------------------------------------------------------------------- |
|
2316 */ |
|
2317 TInt CTestEngine::RemoveTestModuleL( const RMessage2& aMessage ) |
|
2318 { |
|
2319 __TRACE( KInit, ( _L( "CTestEngine::RemoveTestModuleL" ) ) ); |
|
2320 // Read Module name from message |
|
2321 TName moduleName; |
|
2322 aMessage.ReadL( 0, moduleName ); |
|
2323 if( moduleName.Length() == 0 ) |
|
2324 { |
|
2325 LeaveWithNotifyL( KErrArgument ); |
|
2326 } |
|
2327 |
|
2328 moduleName.LowerCase(); |
|
2329 // Remove optional '.DLL' from file name |
|
2330 TParse parse; |
|
2331 parse.Set( moduleName, NULL, NULL ); |
|
2332 |
|
2333 if ( parse.Ext() == _L(".dll") ) |
|
2334 { |
|
2335 const TInt len = parse.Ext().Length(); |
|
2336 moduleName.Delete ( moduleName.Length()-len, len ); |
|
2337 } |
|
2338 |
|
2339 __TRACE(KInit, (_L("Going to remove module controller [%S]"), &moduleName)); |
|
2340 // Check that the module that will be removed exists |
|
2341 TInt moduleCount = iModules.Count(); |
|
2342 TBool found = EFalse; |
|
2343 TInt moduleIndex; |
|
2344 for ( moduleIndex = 0; moduleIndex < moduleCount; moduleIndex++ ) |
|
2345 { |
|
2346 if ( iModules[moduleIndex]->ModuleName( moduleName ) == moduleName ) |
|
2347 { |
|
2348 found = ETrue; |
|
2349 break; |
|
2350 } |
|
2351 } |
|
2352 |
|
2353 if ( !found ) |
|
2354 { |
|
2355 // Test Module does not exists |
|
2356 __TRACE(KInit, (_L("Module controller [%S] to be removed NOT FOUND"), &moduleName)); |
|
2357 return KErrNotFound; |
|
2358 } |
|
2359 // Check module controller and its children |
|
2360 if(iModules[moduleIndex]->iTestCaseCounter > 0) |
|
2361 { |
|
2362 __TRACE(KInit, (_L("Cannot remove module controller [%S], it is running %d test cases"), &moduleName, iModules[moduleIndex]->iTestCaseCounter)); |
|
2363 return KErrInUse; |
|
2364 } |
|
2365 TInt j; |
|
2366 for(j = 0; j < iModules[moduleIndex]->iChildrenControllers.Count(); j++) |
|
2367 { |
|
2368 if(iModules[moduleIndex]->iChildrenControllers[j]->iTestCaseCounter > 0) |
|
2369 { |
|
2370 __TRACE(KInit, (_L("Cannot remove module controller [%S], its child [%S] is running %d test cases"), &moduleName, iModules[moduleIndex]->iChildrenControllers[j]->iName, iModules[moduleIndex]->iChildrenControllers[j]->iTestCaseCounter)); |
|
2371 return KErrInUse; |
|
2372 } |
|
2373 } |
|
2374 // Test cases not running so we can remove the Test Module |
|
2375 __TRACE(KInit, (_L("Removing module controller [%S]"), &moduleName)); |
|
2376 CTestModuleController* module = iModules[moduleIndex]; |
|
2377 iModules.Remove(moduleIndex); |
|
2378 delete module; |
|
2379 |
|
2380 return KErrNone; |
|
2381 |
|
2382 } |
|
2383 |
|
2384 /* |
|
2385 ------------------------------------------------------------------------------- |
|
2386 |
|
2387 Class: CTestEngine |
|
2388 |
|
2389 Method: CloseTestEngineL |
|
2390 |
|
2391 Description: Close test engine |
|
2392 |
|
2393 Parameters: None |
|
2394 |
|
2395 Return Values: None |
|
2396 |
|
2397 Errors/Exceptions: Leaves if GenerateReportL leaves |
|
2398 |
|
2399 Status: Approved |
|
2400 |
|
2401 ------------------------------------------------------------------------------- |
|
2402 */ |
|
2403 void CTestEngine::CloseTestEngineL() |
|
2404 { |
|
2405 __TRACE( KInit, ( _L( "CTestEngine::CloseTestEngineL" ) ) ); |
|
2406 // Remove all module controllers |
|
2407 iModules.ResetAndDestroy(); |
|
2408 iModules.Close(); |
|
2409 |
|
2410 // If test report is created |
|
2411 if( RetrieveTestReport() ) |
|
2412 { |
|
2413 iTestReport->GenerateReportL(); |
|
2414 iIsTestReportGenerated = ETrue; |
|
2415 } |
|
2416 |
|
2417 // Close Setting server, no handle available anymore |
|
2418 iSettingServer.Close(); |
|
2419 |
|
2420 // Decrement resource count |
|
2421 iResourceCount--; |
|
2422 } |
|
2423 |
|
2424 /* |
|
2425 ------------------------------------------------------------------------------- |
|
2426 |
|
2427 Class: CTestEngine |
|
2428 |
|
2429 Method: AddConfigFileL |
|
2430 |
|
2431 Description: Adds new config file to Test Module |
|
2432 |
|
2433 Parameters: const RMessage& aMessage: in: Server Message |
|
2434 |
|
2435 Return Values: None |
|
2436 |
|
2437 Errors/Exceptions: Leaves if some of called leaving methods leaves |
|
2438 Leaves if module length is zero |
|
2439 Leaves if configFile length is zero |
|
2440 |
|
2441 Status: Approved |
|
2442 |
|
2443 ------------------------------------------------------------------------------- |
|
2444 */ |
|
2445 void CTestEngine::AddConfigFileL( const RMessage2& aMessage ) |
|
2446 { |
|
2447 TName module; |
|
2448 TFileName configFile; |
|
2449 |
|
2450 // Read module name from aMessage |
|
2451 aMessage.ReadL( 0, module ); |
|
2452 |
|
2453 if( module.Length() == 0 ) |
|
2454 { |
|
2455 LeaveWithNotifyL( KErrArgument ); |
|
2456 } |
|
2457 // Read config file name from aMessage |
|
2458 aMessage.ReadL( 1, configFile ); |
|
2459 |
|
2460 if( configFile.Length() == 0 ) |
|
2461 { |
|
2462 LeaveWithNotifyL( KErrArgument ); |
|
2463 } |
|
2464 |
|
2465 module.LowerCase(); |
|
2466 // Remove optional '.DLL' from file name |
|
2467 TParse parse; |
|
2468 parse.Set( module, NULL, NULL ); |
|
2469 |
|
2470 if ( parse.Ext() == _L(".dll") ) |
|
2471 { |
|
2472 const TInt len = parse.Ext().Length(); |
|
2473 module.Delete ( module.Length()-len, len ); |
|
2474 } |
|
2475 |
|
2476 __TRACE( KInit, ( _L( "Adding config file [%S] to [%S] module"), &configFile, &module ) ); |
|
2477 |
|
2478 // Get correct test module controller |
|
2479 CTestModuleController* testModule = ModuleControllerByName( module ); |
|
2480 if ( testModule == NULL ) |
|
2481 { |
|
2482 __TRACE( KError, ( CStifLogger::ERed, _L( "Added configure file has an invalid module:[%S]"), &module ) ); |
|
2483 LeaveWithNotifyL ( KErrNotFound ); |
|
2484 } |
|
2485 |
|
2486 // Add config file to Module |
|
2487 testModule->AddConfigFileL( configFile ); |
|
2488 |
|
2489 } |
|
2490 |
|
2491 /* |
|
2492 ------------------------------------------------------------------------------- |
|
2493 |
|
2494 Class: CTestEngine |
|
2495 |
|
2496 Method: RemoveConfigFileL |
|
2497 |
|
2498 Description: Removes a config file from test module |
|
2499 |
|
2500 Parameters: const RMessage& aMessage: in: Server Message |
|
2501 |
|
2502 Return Values: None |
|
2503 |
|
2504 Errors/Exceptions: Leaves if some of called leaving methods leaves |
|
2505 Leaves if module length is zero |
|
2506 Leaves if configFile length is zero |
|
2507 |
|
2508 Status: Proposal |
|
2509 |
|
2510 ------------------------------------------------------------------------------- |
|
2511 */ |
|
2512 void CTestEngine::RemoveConfigFileL( const RMessage2& aMessage ) |
|
2513 { |
|
2514 TName module; |
|
2515 TFileName configFile; |
|
2516 |
|
2517 // Read module name from aMessage |
|
2518 aMessage.ReadL( 0, module ); |
|
2519 |
|
2520 if( module.Length() == 0 ) |
|
2521 { |
|
2522 LeaveWithNotifyL( KErrArgument ); |
|
2523 } |
|
2524 // Read config file name from aMessage |
|
2525 aMessage.ReadL( 1, configFile ); |
|
2526 |
|
2527 if( configFile.Length() == 0 ) |
|
2528 { |
|
2529 LeaveWithNotifyL( KErrArgument ); |
|
2530 } |
|
2531 |
|
2532 module.LowerCase(); |
|
2533 // Remove optional '.DLL' from file name |
|
2534 TParse parse; |
|
2535 parse.Set( module, NULL, NULL ); |
|
2536 |
|
2537 if ( parse.Ext() == _L(".dll") ) |
|
2538 { |
|
2539 const TInt len = parse.Ext().Length(); |
|
2540 module.Delete ( module.Length()-len, len ); |
|
2541 } |
|
2542 |
|
2543 __TRACE( KInit, ( _L( "Removing config file [%S] from [%S] module"), &configFile, &module ) ); |
|
2544 |
|
2545 // Get correct test module controller |
|
2546 CTestModuleController* testModule = ModuleControllerByName( module ); |
|
2547 if ( testModule == NULL ) |
|
2548 { |
|
2549 __TRACE( KError, ( CStifLogger::ERed, _L( "Added configure file has an invalid module:[%S]"), &module ) ); |
|
2550 LeaveWithNotifyL ( KErrNotFound ); |
|
2551 } |
|
2552 |
|
2553 // Remove config file from Module |
|
2554 testModule->RemoveConfigFileL( configFile ); |
|
2555 |
|
2556 } |
|
2557 |
|
2558 |
|
2559 /* |
|
2560 ------------------------------------------------------------------------------- |
|
2561 |
|
2562 Class: CTestEngine |
|
2563 |
|
2564 Method: EnumerateTestCasesL |
|
2565 |
|
2566 Description: Enumerates test cases |
|
2567 |
|
2568 Parameters: const RMessage& aMessage: in: Server message |
|
2569 |
|
2570 Return Values: None |
|
2571 |
|
2572 Errors/Exceptions: Panics the client if enumeration is already pending |
|
2573 Leaves if called StartEnumerateL method leaves |
|
2574 |
|
2575 Status: Proposal |
|
2576 |
|
2577 ------------------------------------------------------------------------------- |
|
2578 */ |
|
2579 void CTestEngine::EnumerateTestCasesL( const RMessage2& aMessage ) |
|
2580 { |
|
2581 __TRACE( KInit, ( _L( "CTestEngine::EnumerateTestCasesL" ) ) ); |
|
2582 // Check if enumerate is ongoing!! |
|
2583 __ASSERT_ALWAYS( iEnumerateModuleCount == 0, PanicClient( EReqPending, aMessage ) ); |
|
2584 |
|
2585 iCaseCount = 0; |
|
2586 iEnumError = KErrNone; |
|
2587 |
|
2588 TInt count = iModules.Count(); |
|
2589 if ( count == 0 ) |
|
2590 { |
|
2591 |
|
2592 __TRACE( KInit, ( CStifLogger::EBold, _L( "Test module(s) not loaded - returning 0 test cases" ) ) ); |
|
2593 |
|
2594 // Note is printed from UI |
|
2595 // ErrorPrint(0, _L("No test modules, check testengine log")); |
|
2596 // Write test case count to client |
|
2597 TCaseCount countPckg( 0 ); |
|
2598 TRAPD( err, aMessage.WriteL( 0, countPckg ) ); |
|
2599 |
|
2600 // Request will be completed in DispatchMessageL |
|
2601 iReturn = err; |
|
2602 } |
|
2603 else |
|
2604 { |
|
2605 for ( TInt i = 0; i < count; i++ ) |
|
2606 { |
|
2607 // Send enumerate request to each test module. |
|
2608 iModules[i]->StartEnumerateL(); |
|
2609 iEnumerateModuleCount++; |
|
2610 } |
|
2611 |
|
2612 // Message is completed later from EnumerationCompleted function |
|
2613 iComplete = EFalse; |
|
2614 |
|
2615 // Store the message |
|
2616 iEnumerationMessage = aMessage; |
|
2617 } |
|
2618 |
|
2619 } |
|
2620 |
|
2621 /* |
|
2622 ------------------------------------------------------------------------------- |
|
2623 |
|
2624 Class: CTestEngine |
|
2625 |
|
2626 Method: EnumerationCompleted |
|
2627 |
|
2628 Description: Return the module controller specified by given parameter. |
|
2629 |
|
2630 Parameters: TInt aCount: in: Count of test cases |
|
2631 TInt aError: in: Symbian OS Error code: Error from Test Module |
|
2632 |
|
2633 Return Values: None |
|
2634 |
|
2635 Errors/Exceptions: None |
|
2636 |
|
2637 Status: Proposal |
|
2638 |
|
2639 ------------------------------------------------------------------------------- |
|
2640 */ |
|
2641 void CTestEngine::EnumerationCompleted( TInt aCount, TInt aError ) |
|
2642 { |
|
2643 // Increment test case count by aCount |
|
2644 iCaseCount+= aCount; |
|
2645 |
|
2646 if ( aError != KErrNone ) |
|
2647 { |
|
2648 iEnumError = aError; |
|
2649 } |
|
2650 |
|
2651 iEnumerateModuleCount--; |
|
2652 |
|
2653 if ( iEnumerateModuleCount == 0 ) |
|
2654 { |
|
2655 |
|
2656 TInt attrib = CStifLogger::ENoStyle; |
|
2657 if ( iCaseCount == 0 ) |
|
2658 { |
|
2659 attrib = CStifLogger::EBold; |
|
2660 } |
|
2661 __TRACE( KInit, ( attrib, _L( "Test case enumeration completed, testcase count %d"), iCaseCount ) ); |
|
2662 |
|
2663 // Write test case count to client |
|
2664 TCaseCount countPckg( iCaseCount ); |
|
2665 TRAPD( err, iEnumerationMessage.WriteL( 0, countPckg ) ); |
|
2666 |
|
2667 if ( err != KErrNone ) |
|
2668 { |
|
2669 iEnumError = err; |
|
2670 __TRACE( KError, ( CStifLogger::ERed, _L( "CTestEngine::EnumerationCompleted: Failed %d"), iEnumError ) ); |
|
2671 } |
|
2672 |
|
2673 // Complete request |
|
2674 iEnumerationMessage.Complete( iEnumError ); |
|
2675 } |
|
2676 |
|
2677 } |
|
2678 |
|
2679 /* |
|
2680 ------------------------------------------------------------------------------- |
|
2681 |
|
2682 Class: CTestEngine |
|
2683 |
|
2684 Method: GetTestCasesL |
|
2685 |
|
2686 Description: Get test cases |
|
2687 |
|
2688 Parameters: const RMessage& aMessage: in: Server message |
|
2689 |
|
2690 Return Values: None |
|
2691 |
|
2692 Errors/Exceptions: Leaves if enumeration is not yet complete |
|
2693 |
|
2694 Status: Approved |
|
2695 |
|
2696 ------------------------------------------------------------------------------- |
|
2697 */ |
|
2698 void CTestEngine::GetTestCasesL( const RMessage2& aMessage ) |
|
2699 { |
|
2700 __TRACE( KVerbose, ( _L( "CTestEngine::GetTestCasesL" ) ) ); |
|
2701 |
|
2702 const TInt len = sizeof( TTestInfo ); |
|
2703 |
|
2704 // Loop through all test modules |
|
2705 TInt moduleCount = iModules.Count(); |
|
2706 TInt pos = 0; |
|
2707 TInt totalCount = 0; |
|
2708 for ( TInt i = 0; i < moduleCount; i++ ) |
|
2709 { |
|
2710 CTestModuleController* module = iModules[i]; |
|
2711 |
|
2712 // Check that test cases are enumerated first |
|
2713 if ( !module->EnumerationComplete() ) |
|
2714 { |
|
2715 __TRACE( KError, ( CStifLogger::ERed, _L( "CTestEngine::GetTestCasesL, Test Cases not yet enumerated!" ) ) ); |
|
2716 LeaveIfErrorWithNotify( KErrNotFound ); |
|
2717 } |
|
2718 |
|
2719 CFixedFlatArray<TTestInfo>* testCases = module->TestCasesL(); |
|
2720 CleanupStack::PushL( testCases ); |
|
2721 |
|
2722 // Loop through all test cases got from test module |
|
2723 const TInt caseCount = testCases->Count(); |
|
2724 totalCount+=caseCount; |
|
2725 |
|
2726 for ( TInt j = 0; j < caseCount; j++ ) |
|
2727 { |
|
2728 if(((*testCases)[j]).iTestCaseInfo.iTimeout == 0 && iDefaultTimeout > 0) |
|
2729 { |
|
2730 ((*testCases)[j]).iTestCaseInfo.iTimeout = iDefaultTimeout; |
|
2731 } |
|
2732 |
|
2733 // Construct package for source data |
|
2734 TTestInfoPckg tmpPackage( ( *testCases )[j] ); |
|
2735 |
|
2736 // Copy test case package to client's memory |
|
2737 aMessage.WriteL( 0, tmpPackage, pos ) ; |
|
2738 |
|
2739 pos = pos + len; |
|
2740 } |
|
2741 CleanupStack::PopAndDestroy( testCases ); |
|
2742 |
|
2743 // Free allocated test cases because not needed anymore |
|
2744 module->FreeTestCases(); |
|
2745 |
|
2746 } |
|
2747 |
|
2748 __TRACE( KVerbose, ( _L( "CTestEngine::GetTestCasesL, case count %d" ), totalCount ) ); |
|
2749 |
|
2750 // Finished |
|
2751 iReturn = KErrNone; |
|
2752 } |
|
2753 |
|
2754 /* |
|
2755 ------------------------------------------------------------------------------- |
|
2756 |
|
2757 Class: CTestEngine |
|
2758 |
|
2759 Method: CancelAsyncRequest |
|
2760 |
|
2761 Description: Asynchronous requests are canceled by this function. |
|
2762 |
|
2763 Parameters: const RMessage aMessage |
|
2764 |
|
2765 Return Values: None |
|
2766 |
|
2767 Errors/Exceptions: None |
|
2768 |
|
2769 Status: Proposal |
|
2770 |
|
2771 ------------------------------------------------------------------------------- |
|
2772 */ |
|
2773 void CTestEngine::CancelAsyncRequest( const RMessage2& aMessage ) |
|
2774 { |
|
2775 switch ( aMessage.Int0() ) |
|
2776 { |
|
2777 case ETestEngineEnumerateTestCases: |
|
2778 { |
|
2779 TInt count = iModules.Count(); |
|
2780 for ( TInt i=0; i < count; i++ ) |
|
2781 { |
|
2782 // Cancel enumerate |
|
2783 iModules[i]->Cancel(); |
|
2784 } |
|
2785 break; |
|
2786 } |
|
2787 |
|
2788 case ETestEngineErrorNotification: |
|
2789 { |
|
2790 if ( iErrorMessageAvailable ) |
|
2791 { |
|
2792 iErrorMessageAvailable = EFalse; |
|
2793 iErrorMessage.Complete ( KErrCancel ); |
|
2794 } |
|
2795 } |
|
2796 break; |
|
2797 case ETestEngineEvent: |
|
2798 // Event command cannot be cancelled |
|
2799 // Only EWaitEvent can be cancelled with ECancelWait |
|
2800 default: |
|
2801 PanicClient( EBadRequest, aMessage ); |
|
2802 break; |
|
2803 } |
|
2804 |
|
2805 } |
|
2806 |
|
2807 /* |
|
2808 ------------------------------------------------------------------------------- |
|
2809 |
|
2810 Class: CTestEngine |
|
2811 |
|
2812 Method: EventControlL |
|
2813 |
|
2814 Description: Controls event system. |
|
2815 |
|
2816 Parameters: const RMessage& aMessage: in: Server message |
|
2817 |
|
2818 Return Values: None |
|
2819 |
|
2820 Errors/Exceptions: Leaves if some of called leaving methods leaves |
|
2821 |
|
2822 Status: Proposal |
|
2823 |
|
2824 ------------------------------------------------------------------------------- |
|
2825 */ |
|
2826 void CTestEngine::EventControlL( const RMessage2& aMessage ) |
|
2827 |
|
2828 { |
|
2829 __TRACE( KVerbose, ( _L( "CTestEngine::EventControlL" ) ) ); |
|
2830 TInt ret = KErrNone; |
|
2831 |
|
2832 // Read EventIf from aMessage |
|
2833 TEventIf event; |
|
2834 TEventIfPckg eventIfPckg( event ); |
|
2835 aMessage.ReadL( 0, eventIfPckg ); |
|
2836 |
|
2837 // EWaitEvent, EReqEvent and ERelEvent need processing here |
|
2838 if( ( event.Type() == TEventIf::EWaitEvent ) || |
|
2839 ( event.Type() == TEventIf::EReqEvent ) || |
|
2840 ( event.Type() == TEventIf::ERelEvent ) || |
|
2841 ( event.Type() == TEventIf::ECancelWait ) ) |
|
2842 { |
|
2843 TInt ind = 0; |
|
2844 TInt count = iClientEvents.Count(); |
|
2845 const TDesC& eventName = event.Name(); |
|
2846 // Search event from client event list |
|
2847 for( ind=0; ind < count; ind++ ) |
|
2848 { |
|
2849 if( iClientEvents[ind]->Name() == eventName ) |
|
2850 { |
|
2851 break; |
|
2852 } |
|
2853 } |
|
2854 |
|
2855 switch( event.Type() ) |
|
2856 { |
|
2857 // Handle event waiting |
|
2858 case TEventIf::EWaitEvent: |
|
2859 { |
|
2860 // Check that we found event from client events list |
|
2861 if( ind == count ) |
|
2862 { |
|
2863 ret = KErrNotFound; |
|
2864 } |
|
2865 else |
|
2866 { |
|
2867 TEventMsg* eventEntry = iClientEvents[ind]; |
|
2868 |
|
2869 __TRACE( KVerbose, ( _L( "CTestEngine::EventControlL: Waiting %S (count %i)"), |
|
2870 &event.Name(), count ) ); |
|
2871 |
|
2872 // Waiting is completed either from here in Wait method |
|
2873 // if event is already pending, |
|
2874 // or from Set method in CtlEvent when event is set. |
|
2875 eventEntry->Wait( aMessage ); |
|
2876 return; |
|
2877 } |
|
2878 } |
|
2879 break; |
|
2880 case TEventIf::ECancelWait: |
|
2881 { |
|
2882 // Check that we found event from client events list |
|
2883 if( ind == count ) |
|
2884 { |
|
2885 ret = KErrNotFound; |
|
2886 } |
|
2887 else |
|
2888 { |
|
2889 TEventMsg* eventEntry = iClientEvents[ind]; |
|
2890 |
|
2891 __TRACE( KVerbose, ( _L( "CTestEngine::EventControlL: Cancel waiting %S (count %i)"), |
|
2892 &event.Name(), count ) ); |
|
2893 |
|
2894 eventEntry->CancelWait(); |
|
2895 } |
|
2896 } |
|
2897 break; |
|
2898 // Handle event request |
|
2899 case TEventIf::EReqEvent: |
|
2900 { |
|
2901 // Check that event is not already requested |
|
2902 if( ind < count ) |
|
2903 { |
|
2904 // Already exists |
|
2905 ret = KErrArgument; |
|
2906 } |
|
2907 else |
|
2908 { |
|
2909 // Requested events are added to iClientEvents |
|
2910 TEventMsg* eventEntry = new TEventMsg; |
|
2911 if( eventEntry == NULL ) |
|
2912 { |
|
2913 ret = KErrNoMemory; |
|
2914 } |
|
2915 else |
|
2916 { |
|
2917 CleanupStack::PushL( eventEntry ); |
|
2918 eventEntry->Copy( event ); |
|
2919 // Check if state event is set already |
|
2920 if( IsStateEventAndSet( event.Name() ) ) |
|
2921 { |
|
2922 // If it was set already, set the event |
|
2923 eventEntry->Set( TEventIf::EState ); |
|
2924 } |
|
2925 ret = iClientEvents.Append( eventEntry ); |
|
2926 if( ret != KErrNone ) |
|
2927 { |
|
2928 CleanupStack::PopAndDestroy( eventEntry ); |
|
2929 } |
|
2930 else |
|
2931 { |
|
2932 CleanupStack::Pop( eventEntry ); |
|
2933 |
|
2934 __TRACE( KVerbose, ( _L( "CTestEngine::EventControlL: Req added %S (count %i)"), |
|
2935 &event.Name(), iClientEvents.Count() ) ); |
|
2936 } |
|
2937 } |
|
2938 } |
|
2939 } |
|
2940 break; |
|
2941 // Release event |
|
2942 case TEventIf::ERelEvent: |
|
2943 { |
|
2944 // Released events are deleted from iClientEvents |
|
2945 // Check that we found entry from client events list |
|
2946 if( ind == count ) |
|
2947 { |
|
2948 ret = KErrNotFound; |
|
2949 } |
|
2950 else |
|
2951 { |
|
2952 __TRACE( KVerbose, ( _L( "CTestEngine::EventControlL: Release event %S (count %i)"), |
|
2953 &event.Name(), iClientEvents.Count() ) ); |
|
2954 |
|
2955 TEventMsg* eventEntry = iClientEvents[ind]; |
|
2956 iClientEvents.Remove( ind ); |
|
2957 eventEntry->Release(); |
|
2958 delete eventEntry; |
|
2959 } |
|
2960 } |
|
2961 break; |
|
2962 default: // This should never happen!!! |
|
2963 { |
|
2964 _LIT( KEngine, "CTestEngine" ); |
|
2965 User::Panic( KEngine, KErrGeneral ); |
|
2966 } |
|
2967 break; |
|
2968 } |
|
2969 } |
|
2970 else |
|
2971 { |
|
2972 // ESetEvent and EUnsetEvent are only forwarded |
|
2973 TRequestStatus req; |
|
2974 CtlEventL( event, req ); |
|
2975 User::WaitForRequest( req ); |
|
2976 } |
|
2977 |
|
2978 aMessage.Complete( ret ); |
|
2979 |
|
2980 } |
|
2981 |
|
2982 /* |
|
2983 ------------------------------------------------------------------------------- |
|
2984 |
|
2985 Class: CTestEngine |
|
2986 |
|
2987 Method: HandleErrorNotificationL |
|
2988 |
|
2989 Description: Handle error notifications. |
|
2990 |
|
2991 Parameters: const RMessage& aMessage: in: Server message |
|
2992 |
|
2993 Return Values: None |
|
2994 |
|
2995 Errors/Exceptions: None |
|
2996 |
|
2997 Status: Approved |
|
2998 |
|
2999 ------------------------------------------------------------------------------- |
|
3000 */ |
|
3001 void CTestEngine::HandleErrorNotificationL( const RMessage2& aMessage ) |
|
3002 { |
|
3003 iErrorMessage = aMessage; |
|
3004 iErrorMessageAvailable = ETrue; |
|
3005 |
|
3006 ProcessErrorQueue(); |
|
3007 |
|
3008 } |
|
3009 |
|
3010 /* |
|
3011 ------------------------------------------------------------------------------- |
|
3012 |
|
3013 Class: CTestEngine |
|
3014 |
|
3015 Method: LoggerSettings |
|
3016 |
|
3017 Description: Get Logger's overwrite parameters |
|
3018 |
|
3019 Parameters: const RMessage& aMessage: in: Server message |
|
3020 |
|
3021 Return Values: None |
|
3022 |
|
3023 Errors/Exceptions: Panics if WriteL fails |
|
3024 |
|
3025 Status: Approved |
|
3026 |
|
3027 ------------------------------------------------------------------------------- |
|
3028 */ |
|
3029 void CTestEngine::LoggerSettings( const RMessage2& aMessage ) |
|
3030 { |
|
3031 __TRACE( KInit, ( _L( "CTestEngine::LoggerSettings" ) ) ); |
|
3032 |
|
3033 // Copies logger settings to the package |
|
3034 TPckg<TLoggerSettings> loggerSettingsPckg( iTestEngineServer->GetLoggerSettings() ); |
|
3035 |
|
3036 // Writes a packege that includes the logger overwrite settings to aMessage |
|
3037 TRAPD( err, aMessage.WriteL( 0, loggerSettingsPckg ) ); |
|
3038 if ( err != KErrNone ) |
|
3039 { |
|
3040 PanicClient( EBadDescriptor, aMessage ); |
|
3041 } |
|
3042 |
|
3043 } |
|
3044 |
|
3045 /* |
|
3046 ------------------------------------------------------------------------------- |
|
3047 |
|
3048 Class: CTestEngine |
|
3049 |
|
3050 Method: CloseLoggerSettings |
|
3051 |
|
3052 Description: Close logger settings |
|
3053 |
|
3054 Parameters: None |
|
3055 |
|
3056 Return Values: None |
|
3057 |
|
3058 Errors/Exceptions: None |
|
3059 |
|
3060 Status: Approved |
|
3061 |
|
3062 ------------------------------------------------------------------------------- |
|
3063 */ |
|
3064 void CTestEngine::CloseLoggerSettings() |
|
3065 { |
|
3066 __TRACE( KInit, ( _L( "CTestEngine::CloseLoggerSettings" ) ) ); |
|
3067 |
|
3068 } |
|
3069 |
|
3070 /* |
|
3071 ------------------------------------------------------------------------------- |
|
3072 |
|
3073 Class: CTestEngine |
|
3074 |
|
3075 Method: TestCaseByHandle |
|
3076 |
|
3077 Description: Return test case specified by aHandle |
|
3078 |
|
3079 Parameters: TUint aHandle : in : TUint : Handle to TestCase subsession |
|
3080 |
|
3081 Return Values: CTestCase* : pointer to CTestCase object |
|
3082 |
|
3083 Errors/Exceptions: None |
|
3084 |
|
3085 Status: Approved |
|
3086 |
|
3087 ------------------------------------------------------------------------------- |
|
3088 */ |
|
3089 CTestCase* CTestEngine::TestCaseByHandle( TUint aHandle, const RMessage2& aMessage ) |
|
3090 { |
|
3091 // Try to get test case from test case container |
|
3092 CTestCase* testCase = |
|
3093 ( CTestCase* )iTestCases->At( aHandle ); |
|
3094 if ( testCase == NULL ) |
|
3095 { |
|
3096 PanicClient( EBadSubsessionHandle, aMessage ); |
|
3097 } |
|
3098 |
|
3099 return testCase; |
|
3100 |
|
3101 } |
|
3102 |
|
3103 /* |
|
3104 ------------------------------------------------------------------------------- |
|
3105 |
|
3106 Class: CTestEngine |
|
3107 |
|
3108 Method: NewTestCaseL |
|
3109 |
|
3110 Description: Create new test execution subsession |
|
3111 |
|
3112 Parameters: const RMessage& aMessage: in: Server Message |
|
3113 |
|
3114 Return Values: None |
|
3115 |
|
3116 Errors/Exceptions: Leaves if some of called leaving method leaves |
|
3117 |
|
3118 Status: Proposal |
|
3119 |
|
3120 ------------------------------------------------------------------------------- |
|
3121 */ |
|
3122 void CTestEngine::NewTestCaseL( const RMessage2& aMessage ) |
|
3123 { |
|
3124 __TRACE( KVerbose, ( _L( "CTestEngine::NewTestCaseL start" ) ) ); |
|
3125 |
|
3126 // Get data from message |
|
3127 TTestInfo testInfo; |
|
3128 TTestInfoPckg testInfoPckg = testInfo; |
|
3129 |
|
3130 TRAPD( res, aMessage.ReadL( 0, testInfoPckg ) ); |
|
3131 if ( res != KErrNone ) |
|
3132 { |
|
3133 PanicClient( EBadDescriptor, aMessage ); |
|
3134 return; |
|
3135 } |
|
3136 |
|
3137 testInfo.iModuleName.LowerCase(); |
|
3138 // Remove optional '.DLL' from file name |
|
3139 TParse parse; |
|
3140 parse.Set( testInfo.iModuleName, NULL, NULL ); |
|
3141 |
|
3142 if ( parse.Ext() == _L(".dll") ) |
|
3143 { |
|
3144 const TInt len = parse.Ext().Length(); |
|
3145 testInfo.iModuleName.Delete ( testInfo.iModuleName.Length()-len, len ); |
|
3146 } |
|
3147 |
|
3148 // Get correct test module controller |
|
3149 CTestModuleController* scrModule = NULL; |
|
3150 CTestModuleController* module = GetFreeOrCreateModuleControllerL(testInfo, &scrModule); |
|
3151 if ( module == NULL ) |
|
3152 { |
|
3153 //@spe PanicClient( EInvalidModuleName, aMessage ); |
|
3154 //@spe return; |
|
3155 __TRACE( KError, ( CStifLogger::ERed, _L( "Invalid module:[%S]"), &testInfo.iModuleName ) ); |
|
3156 LeaveWithNotifyL ( KErrNotFound ); |
|
3157 } |
|
3158 |
|
3159 // Create test case object |
|
3160 CTestCase* testCase = |
|
3161 CTestCase::NewL( this, module, RetrieveTestReport(), testInfo, scrModule); |
|
3162 CleanupStack::PushL( testCase ); |
|
3163 |
|
3164 // Add object to object container to generate unique id |
|
3165 iContainer->AddL( testCase ); |
|
3166 |
|
3167 // Add object to object index |
|
3168 // This returns a unique handle so we can get it again |
|
3169 TInt handle = iTestCases->AddL( testCase ); |
|
3170 |
|
3171 // Write the handle to client |
|
3172 TPckg<TInt> handlePckg( handle ); |
|
3173 |
|
3174 TRAP( res, aMessage.WriteL( 3, handlePckg ) ); |
|
3175 if ( res != KErrNone ) |
|
3176 { |
|
3177 iTestCases->Remove( handle ); |
|
3178 PanicClient( EBadDescriptor, aMessage ); |
|
3179 return; |
|
3180 } |
|
3181 |
|
3182 // Add new test case to testcase array |
|
3183 User::LeaveIfError( iTestCaseArray.Append( testCase ) ); |
|
3184 CleanupStack::Pop( testCase ); |
|
3185 |
|
3186 // Notch up another resource |
|
3187 iResourceCount++; |
|
3188 |
|
3189 iReturn = KErrNone; |
|
3190 |
|
3191 __TRACE( KVerbose, ( _L( "CTestEngine::NewTestCaseL done" ) ) ); |
|
3192 |
|
3193 } |
|
3194 |
|
3195 /* |
|
3196 ------------------------------------------------------------------------------- |
|
3197 |
|
3198 Class: CTestEngine |
|
3199 |
|
3200 Method: DeleteTestCase |
|
3201 |
|
3202 Description: Delete test case from container list |
|
3203 |
|
3204 Parameters: TUint aHandle: in: Handle to test case to be removed |
|
3205 |
|
3206 Return Values: None |
|
3207 |
|
3208 Errors/Exceptions: None |
|
3209 |
|
3210 Status: Approved |
|
3211 |
|
3212 ------------------------------------------------------------------------------- |
|
3213 */ |
|
3214 void CTestEngine::DeleteTestCase( TUint aHandle ) |
|
3215 { |
|
3216 __TRACE( KVerbose, ( _L( "CTestEngine::DeleteTestCase" ) ) ); |
|
3217 |
|
3218 // Get test case from container |
|
3219 CTestCase* testCase = ( CTestCase* )iTestCases->At( aHandle ); |
|
3220 |
|
3221 // Do nothing if invalid handle |
|
3222 if ( testCase == NULL ) |
|
3223 { |
|
3224 // Handle might be already deleted, so do nothing. |
|
3225 return; |
|
3226 } |
|
3227 |
|
3228 //Get controllers |
|
3229 CTestModuleController* moduleController; |
|
3230 CTestModuleController* realModuleController; |
|
3231 |
|
3232 moduleController = testCase->GetModuleControllers(&realModuleController); |
|
3233 |
|
3234 // Check if module controllers have crashed |
|
3235 TBool moduleControllerCrashed = EFalse; |
|
3236 TBool realModuleControllerCrashed = EFalse; |
|
3237 |
|
3238 if(moduleController) |
|
3239 { |
|
3240 moduleControllerCrashed = moduleController->iTestModuleCrashDetected; |
|
3241 } |
|
3242 if(realModuleController) |
|
3243 { |
|
3244 realModuleControllerCrashed = realModuleController->iTestModuleCrashDetected; |
|
3245 } |
|
3246 |
|
3247 //__TRACE(KInit, (_L("CTestEngine::DeleteTestCase moduleController=[%x] crashed=[%d] realModuleController=[%x] crashed=[%d]"), moduleController, moduleControllerCrashed, realModuleController, realModuleControllerCrashed)); |
|
3248 // For UITestingSupport, SeparateProcesses and PythonSupport, when module is crashed, |
|
3249 // remove it from module lists, because it will be deleted when closing test case. |
|
3250 if(moduleController) |
|
3251 { |
|
3252 if(moduleControllerCrashed && iUITestingSupport && moduleController->iName->Find(KTestScripterName) == 0 |
|
3253 || moduleControllerCrashed && iSeparateProcesses |
|
3254 || moduleControllerCrashed && moduleController->iName->Find(KPythonScripter) == 0 |
|
3255 ) |
|
3256 { |
|
3257 __TRACE(KInit, (_L("Removing module controller from module list because of crash"))); |
|
3258 //Look for specific module controller and delete it |
|
3259 TInt i; |
|
3260 TInt j, children; |
|
3261 TInt modules = iModules.Count(); |
|
3262 for(i = 0; i < modules; i++) |
|
3263 { |
|
3264 if(iModules[i] == moduleController) |
|
3265 { |
|
3266 __TRACE(KInit, (_L("Module controller found - removing"))); |
|
3267 iModules.Remove(i); |
|
3268 break; |
|
3269 } |
|
3270 |
|
3271 //Check children of the module and if module to be deleted found there, remove it |
|
3272 children = iModules[i]->iChildrenControllers.Count(); |
|
3273 __TRACE(KInit, (_L("Checking %d children of [%S]"), children, iModules[i]->iName)); |
|
3274 for(j = 0; j < children; j++) |
|
3275 { |
|
3276 if(iModules[i]->iChildrenControllers[j] == moduleController) |
|
3277 { |
|
3278 __TRACE(KInit, (_L("Module controller found (child) - removing"))); |
|
3279 |
|
3280 iModules[i]->iChildrenControllers.Remove(j); |
|
3281 |
|
3282 __TRACE(KInit, (_L("Child removed from [%S] controller. Currently it has %d children:"), iModules[i]->iName, iModules[i]->iChildrenControllers.Count())); |
|
3283 for(TInt k = 0; k < iModules[i]->iChildrenControllers.Count(); k++) |
|
3284 { |
|
3285 __TRACE(KInit, (_L(" %d. [%S]"), k + 1, iModules[i]->iChildrenControllers[k]->iName)); |
|
3286 } |
|
3287 break; |
|
3288 } |
|
3289 } |
|
3290 } |
|
3291 } |
|
3292 } |
|
3293 if(moduleController && realModuleController) |
|
3294 { |
|
3295 if(realModuleControllerCrashed && iUITestingSupport && realModuleController->iName->Find(KTestScripterName) == 0 |
|
3296 || realModuleControllerCrashed && iSeparateProcesses |
|
3297 || realModuleControllerCrashed && realModuleController->iName->Find(KPythonScripter) == 0 |
|
3298 ) |
|
3299 { |
|
3300 __TRACE(KInit, (_L("Removing real module controller from module list because of crash"))); |
|
3301 //Remove module controller from scripter controller |
|
3302 moduleController->RemoveModuleController(realModuleController); |
|
3303 } |
|
3304 } |
|
3305 |
|
3306 // Close test case and remove it from container |
|
3307 //testCase->CloseTestCase(); |
|
3308 iTestCases->Remove( aHandle ); |
|
3309 |
|
3310 // Decrement resource count |
|
3311 iResourceCount--; |
|
3312 |
|
3313 // Remove from testcase array |
|
3314 iTestCaseArray.Remove( iTestCaseArray.Find( testCase ) ); |
|
3315 |
|
3316 //If this is UITestingSupport and module is not crashed, delete controller |
|
3317 //(in other words, kill process, because we need somehow reset the test server). |
|
3318 if(moduleController && !moduleControllerCrashed) |
|
3319 { |
|
3320 if(iUITestingSupport && moduleController->iName->Find(KTestScripterName) == 0) |
|
3321 { |
|
3322 if(realModuleController) |
|
3323 { |
|
3324 if(!realModuleControllerCrashed) |
|
3325 { |
|
3326 __TRACE(KInit, (_L("Delete module controller (and kill process in which test case was run)."))); |
|
3327 __TRACE(KInit, (_L("Real module controller provided - processing"))); |
|
3328 //Remove module controller from scripter controller |
|
3329 moduleController->DeleteModuleController(realModuleController); |
|
3330 } |
|
3331 } |
|
3332 else |
|
3333 { |
|
3334 __TRACE(KInit, (_L("Delete module controller (and kill process in which test case was run)."))); |
|
3335 __TRACE(KInit, (_L("Real module controller not provided, checking normal controllers"))); |
|
3336 //Look for specific module controller and delete it |
|
3337 TInt i; |
|
3338 TInt j, children; |
|
3339 TInt modules = iModules.Count(); |
|
3340 for(i = 0; i < modules; i++) |
|
3341 { |
|
3342 if(iModules[i] == moduleController) |
|
3343 { |
|
3344 __TRACE(KInit, (_L("Module controller found - deleting"))); |
|
3345 delete iModules[i]; |
|
3346 iModules.Remove(i); |
|
3347 break; |
|
3348 } |
|
3349 |
|
3350 //Check children of the module and if module to be deleted found there, remove it |
|
3351 children = iModules[i]->iChildrenControllers.Count(); |
|
3352 __TRACE(KInit, (_L("Checking %d children of [%S]"), children, iModules[i]->iName)); |
|
3353 for(j = 0; j < children; j++) |
|
3354 { |
|
3355 if(iModules[i]->iChildrenControllers[j] == moduleController) |
|
3356 { |
|
3357 __TRACE(KInit, (_L("Module controller found (child) - deleting"))); |
|
3358 |
|
3359 delete iModules[i]->iChildrenControllers[j]; |
|
3360 iModules[i]->iChildrenControllers.Remove(j); |
|
3361 |
|
3362 __TRACE(KInit, (_L("Child removed from [%S] controller. Currently it has %d children:"), iModules[i]->iName, iModules[i]->iChildrenControllers.Count())); |
|
3363 for(TInt k = 0; k < iModules[i]->iChildrenControllers.Count(); k++) |
|
3364 { |
|
3365 __TRACE(KInit, (_L(" %d. [%S]"), k + 1, iModules[i]->iChildrenControllers[k]->iName)); |
|
3366 } |
|
3367 break; |
|
3368 } |
|
3369 } |
|
3370 } |
|
3371 } |
|
3372 } |
|
3373 } |
|
3374 } |
|
3375 |
|
3376 /* |
|
3377 ------------------------------------------------------------------------------- |
|
3378 |
|
3379 Class: CTestEngine |
|
3380 |
|
3381 Method: IsStateEventAndSet |
|
3382 |
|
3383 Description: Callback to check state event status. |
|
3384 |
|
3385 Parameters: const TName& aEventName: in: Event name |
|
3386 |
|
3387 Return Values: ETrue: event is set |
|
3388 EFalse: event is not set |
|
3389 |
|
3390 Errors/Exceptions: None |
|
3391 |
|
3392 Status: Approved |
|
3393 |
|
3394 ------------------------------------------------------------------------------- |
|
3395 */ |
|
3396 TBool CTestEngine::IsStateEventAndSet( const TName& aEventName ) |
|
3397 { |
|
3398 TInt count = iStateEvents.Count(); |
|
3399 for( TInt i = 0; i < count; i++ ) |
|
3400 { |
|
3401 TPtrC name = iStateEvents[i]->Des(); |
|
3402 if( name == aEventName ) |
|
3403 { |
|
3404 // Requested state event set already |
|
3405 return ETrue; |
|
3406 } |
|
3407 } |
|
3408 return EFalse; |
|
3409 |
|
3410 } |
|
3411 |
|
3412 /* |
|
3413 ------------------------------------------------------------------------------- |
|
3414 |
|
3415 Class: CTestEngine |
|
3416 |
|
3417 Method: CtlEventL |
|
3418 |
|
3419 Description: Callback to control events. |
|
3420 |
|
3421 Parameters: const TEventIf& aEvent: in: event information |
|
3422 TRequestStatus& aStatus: in: Request status |
|
3423 |
|
3424 Return Values: CTestEventController*: CTestEventController object |
|
3425 |
|
3426 Errors/Exceptions: Leaves if CtlEventL leaves |
|
3427 Leaves if memory allocation fails |
|
3428 Leaves if unset event not found from pending |
|
3429 state event list |
|
3430 |
|
3431 Status: Approved |
|
3432 |
|
3433 ------------------------------------------------------------------------------- |
|
3434 */ |
|
3435 CTestEventController* CTestEngine::CtlEventL( const TEventIf& aEvent, |
|
3436 TRequestStatus& aStatus ) |
|
3437 { |
|
3438 __TRACE( KVerbose, ( _L( "CTestEngine::CtlEventL" ) ) ); |
|
3439 |
|
3440 aStatus = KRequestPending; |
|
3441 |
|
3442 UpdateEventL( aEvent ); |
|
3443 return CTestEventController::NewL( this, aEvent, &aStatus ); |
|
3444 |
|
3445 } |
|
3446 |
|
3447 /* |
|
3448 ------------------------------------------------------------------------------- |
|
3449 |
|
3450 Class: CTestEngine |
|
3451 |
|
3452 Method: UpdateEventL |
|
3453 |
|
3454 Description: Update event lists. |
|
3455 |
|
3456 Parameters: const TEventIf& aEvent: in: event information |
|
3457 |
|
3458 Return Values: None |
|
3459 |
|
3460 Errors/Exceptions: Leaves if CtlEventL leaves |
|
3461 Leaves if memory allocation fails |
|
3462 Leaves if unset event not found from pending |
|
3463 state event list |
|
3464 |
|
3465 Status: Approved |
|
3466 |
|
3467 ------------------------------------------------------------------------------- |
|
3468 */ |
|
3469 void CTestEngine::UpdateEventL( const TEventIf& aEvent ) |
|
3470 { |
|
3471 // Handle ESetEvent and EUnsetEvent for state events here |
|
3472 if( aEvent.EventType() == TEventIf::EState ) |
|
3473 { |
|
3474 // Find event from the list |
|
3475 TInt count = iStateEvents.Count(); |
|
3476 TInt index = 0; |
|
3477 const TDesC& eventName = aEvent.Name(); |
|
3478 for( ; index < count; index++ ) |
|
3479 { |
|
3480 TPtrC name = iStateEvents[index]->Des(); |
|
3481 if( name == eventName ) |
|
3482 { |
|
3483 break; |
|
3484 } |
|
3485 } |
|
3486 |
|
3487 if( aEvent.Type() == TEventIf::ESetEvent ) |
|
3488 { |
|
3489 // Check that event is not already pending |
|
3490 if( index < count ) |
|
3491 { |
|
3492 User::Leave( KErrAlreadyExists ); |
|
3493 } |
|
3494 |
|
3495 // Add set event to pending state event list |
|
3496 HBufC* name = aEvent.Name().AllocLC(); |
|
3497 User::LeaveIfError( iStateEvents.Append( name ) ); |
|
3498 CleanupStack::Pop( name ); |
|
3499 } |
|
3500 else if( aEvent.Type() == TEventIf::EUnsetEvent ) |
|
3501 { |
|
3502 if( index == count ) |
|
3503 { |
|
3504 // Not found from state event list |
|
3505 User::Leave( KErrNotFound ); |
|
3506 } |
|
3507 HBufC* tmp = iStateEvents[index]; |
|
3508 iStateEvents.Remove( index ); |
|
3509 delete tmp; |
|
3510 } |
|
3511 } |
|
3512 else if( aEvent.Type() == TEventIf::EUnsetEvent ) |
|
3513 { |
|
3514 // Can not give Unset for indication event |
|
3515 User::Leave( KErrNotSupported ); |
|
3516 } |
|
3517 |
|
3518 } |
|
3519 |
|
3520 /* |
|
3521 ------------------------------------------------------------------------------- |
|
3522 |
|
3523 Class: CTestEngine |
|
3524 |
|
3525 Method: Logger |
|
3526 |
|
3527 Description: Return the pointer to Logger. |
|
3528 |
|
3529 Parameters: None |
|
3530 |
|
3531 Return Values: CStifLogger*: Pointer to StifLogger |
|
3532 |
|
3533 Errors/Exceptions: None |
|
3534 |
|
3535 Status: Approved |
|
3536 |
|
3537 ------------------------------------------------------------------------------- |
|
3538 */ |
|
3539 CStifLogger* CTestEngine::Logger() |
|
3540 { |
|
3541 return iTestEngineServer->Logger(); |
|
3542 |
|
3543 } |
|
3544 |
|
3545 /* |
|
3546 ------------------------------------------------------------------------------- |
|
3547 |
|
3548 Class: CTestEngine |
|
3549 |
|
3550 Method: WriteRebootParams |
|
3551 |
|
3552 Description: Write the Reboot's state parameters. |
|
3553 |
|
3554 Parameters: TTestInfo& aTestInfo: in: Test case information. |
|
3555 TInt& aCode: in: Reboot related integer information. |
|
3556 TDesC& aName: in: Reboot related string information. |
|
3557 |
|
3558 Return Values: TInt: Symbian OS error |
|
3559 |
|
3560 Errors/Exceptions: Error code returned if Logger creation fails. |
|
3561 |
|
3562 Status: Proposal |
|
3563 |
|
3564 ------------------------------------------------------------------------------- |
|
3565 */ |
|
3566 TInt CTestEngine::WriteRebootParams( TTestInfo& aTestInfo, |
|
3567 TInt& aCode, |
|
3568 TDesC& aName ) |
|
3569 { |
|
3570 __TRACE( KVerbose, ( _L( "WriteRebootParams() starts..." ) ) ); |
|
3571 |
|
3572 // Logger's setting definitions |
|
3573 TLoggerSettings loggerSettings; |
|
3574 |
|
3575 loggerSettings.iCreateLogDirectories = ETrue; |
|
3576 loggerSettings.iOverwrite = ETrue; |
|
3577 loggerSettings.iTimeStamp = EFalse; |
|
3578 loggerSettings.iLineBreak = EFalse; |
|
3579 loggerSettings.iEventRanking = EFalse; |
|
3580 loggerSettings.iThreadId = EFalse; |
|
3581 // EData format because now we don't have to check file type when |
|
3582 // parsing this. |
|
3583 loggerSettings.iHardwareFormat = CStifLogger::EData; |
|
3584 loggerSettings.iHardwareOutput = CStifLogger::EFile; |
|
3585 loggerSettings.iEmulatorFormat = CStifLogger::EData; |
|
3586 loggerSettings.iEmulatorOutput = CStifLogger::EFile; |
|
3587 loggerSettings.iUnicode = EFalse; |
|
3588 loggerSettings.iAddTestCaseTitle = EFalse; |
|
3589 |
|
3590 // Use default setting if path or filename are not set by SetAttribute() |
|
3591 if( iRebootPath == NULL ) |
|
3592 { |
|
3593 iRebootPath= iRebootDefaultPath.Alloc(); |
|
3594 } |
|
3595 if( iRebootFilename == NULL ) |
|
3596 { |
|
3597 iRebootFilename= iRebootDefaultFilename.Alloc(); |
|
3598 } |
|
3599 |
|
3600 CStifLogger* logger = NULL; |
|
3601 TRAPD( ret, logger = CStifLogger::NewL( *iRebootPath, |
|
3602 *iRebootFilename, |
|
3603 loggerSettings ) ); |
|
3604 if( ret != KErrNone ) |
|
3605 { |
|
3606 __TRACE( KError, ( _L( "WriteRebootParams() Logger creation fails with error: " ), ret ) ); |
|
3607 delete logger; |
|
3608 return ret; |
|
3609 } |
|
3610 |
|
3611 // Write reboot parameters |
|
3612 // Because logging format is EData we need add line breaks by hand. |
|
3613 logger->Log( _L( "\r\n" ) ); |
|
3614 logger->Log( _L( "This is TestFramework's file which includes Reboot related informations" ) ); |
|
3615 logger->Log( _L( "\r\n" ) ); |
|
3616 logger->Log( _L( "\r\n" ) ); |
|
3617 logger->Log( _L( "Reboot case's related information:" ) ); |
|
3618 logger->Log( _L( "\r\n" ) ); |
|
3619 logger->Log( _L( "%S %S" ), &KTestModule, &aTestInfo.iModuleName ); |
|
3620 logger->Log( _L( "\r\n" ) ); |
|
3621 logger->Log( _L( "%S %S" ), &KTestCaseFile, &aTestInfo.iConfig ); |
|
3622 logger->Log( _L( "\r\n" ) ); |
|
3623 logger->Log( _L( "%S %d" ), &KTestCaseNumber, aTestInfo.iTestCaseInfo.iCaseNumber ); |
|
3624 logger->Log( _L( "\r\n" ) ); |
|
3625 logger->Log( _L( "%S %S" ), &KTestCaseTitle, &aTestInfo.iTestCaseInfo.iTitle ); |
|
3626 logger->Log( _L( "\r\n" ) ); |
|
3627 logger->Log( _L( "\r\n" ) ); |
|
3628 logger->Log( _L( "%S %d" ), &KStateCode, aCode ); |
|
3629 logger->Log( _L( "\r\n" ) ); |
|
3630 logger->Log( _L( "%S " ), &KStateName ); |
|
3631 logger->Log( aName ); |
|
3632 logger->Log( _L( "\r\n" ) ); |
|
3633 logger->Log( _L( "\r\n" ) ); |
|
3634 |
|
3635 delete logger; |
|
3636 |
|
3637 __TRACE( KVerbose, ( _L( "WriteRebootParams() ends" ) ) ); |
|
3638 |
|
3639 return KErrNone; |
|
3640 |
|
3641 } |
|
3642 |
|
3643 /* |
|
3644 ------------------------------------------------------------------------------- |
|
3645 |
|
3646 Class: CTestEngine |
|
3647 |
|
3648 Method: ReadRebootParams |
|
3649 |
|
3650 Description: Read the Reboot parameters. |
|
3651 |
|
3652 Parameters: TTestInfo& aTestInfo: in: Test case information. |
|
3653 |
|
3654 Return Values: TInt: Symbian OS error |
|
3655 |
|
3656 Errors/Exceptions: Error code returned if Parser creation fails. |
|
3657 Error code returned if section creation fails. |
|
3658 Error code returned if item creation fails. |
|
3659 Error code returned if parsing operation fails. |
|
3660 KErrArgument returned if parsed values and test case |
|
3661 values are different. |
|
3662 |
|
3663 Status: Proposal |
|
3664 |
|
3665 ------------------------------------------------------------------------------- |
|
3666 */ |
|
3667 TInt CTestEngine::ReadRebootParams( TTestInfo& aTestInfo, |
|
3668 TDes& aStateDes, |
|
3669 TInt& aState ) |
|
3670 { |
|
3671 __TRACE( KVerbose, ( _L( "ReadRebootParams() starts..." ) ) ); |
|
3672 |
|
3673 if( iRebootParams == NULL ) |
|
3674 { |
|
3675 __TRACE( KVerbose, ( _L( "ReadRebootParams(): Reboot not done" )) ); |
|
3676 return KErrNotFound; |
|
3677 } |
|
3678 |
|
3679 // --.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.-- |
|
3680 // Checks parsed values and test case values |
|
3681 // --.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.-- |
|
3682 if( iRebootParams->iTestModule != aTestInfo.iModuleName || |
|
3683 iRebootParams->iTestCaseFile != aTestInfo.iConfig || |
|
3684 iRebootParams->iCaseNumber != aTestInfo.iTestCaseInfo.iCaseNumber ) |
|
3685 { |
|
3686 __TRACE( KVerbose, |
|
3687 ( _L( "ReadRebootParams(): Reboot not done by %S" ), |
|
3688 &aTestInfo.iModuleName) ); |
|
3689 return KErrArgument; |
|
3690 } |
|
3691 |
|
3692 aStateDes.Copy( iRebootParams->iStateName ); |
|
3693 aState = iRebootParams->iStateCode; |
|
3694 |
|
3695 // delete reboot params, to ensure that same test case |
|
3696 // does not get indication about reboot again |
|
3697 delete iRebootParams; |
|
3698 iRebootParams = 0; |
|
3699 |
|
3700 __TRACE( KVerbose, ( _L("ReadRebootParams() ends" ) ) ); |
|
3701 |
|
3702 return KErrNone; |
|
3703 |
|
3704 } |
|
3705 |
|
3706 /* |
|
3707 ------------------------------------------------------------------------------- |
|
3708 |
|
3709 Class: CTestEngine |
|
3710 |
|
3711 Method: ParseRebootParamsL |
|
3712 |
|
3713 Description: Parse the Reboot parameters. |
|
3714 |
|
3715 Parameters: None |
|
3716 |
|
3717 Return Values: TInt: Symbian OS error |
|
3718 |
|
3719 Errors/Exceptions: Error code returned if Parser creation fails. |
|
3720 Error code returned if section creation fails. |
|
3721 Error code returned if item creation fails. |
|
3722 Error code returned if parsing operation fails. |
|
3723 KErrArgument returned if parsed values and test case |
|
3724 values are different. |
|
3725 |
|
3726 Status: Proposal |
|
3727 |
|
3728 ------------------------------------------------------------------------------- |
|
3729 */ |
|
3730 TInt CTestEngine::ParseRebootParamsL() |
|
3731 { |
|
3732 __TRACE( KVerbose, ( _L( "ParseRebootParamsL() starts..." ) ) ); |
|
3733 |
|
3734 TInt ret_parsing( 0 ); |
|
3735 TPtrC tmp; |
|
3736 |
|
3737 // Use default setting if path or filename are not set by SetAttribute() |
|
3738 if( iRebootPath == NULL ) |
|
3739 { |
|
3740 iRebootPath= iRebootDefaultPath.Alloc(); |
|
3741 } |
|
3742 if( iRebootFilename == NULL ) |
|
3743 { |
|
3744 iRebootFilename= iRebootDefaultFilename.Alloc(); |
|
3745 } |
|
3746 |
|
3747 // Create parser object |
|
3748 CStifParser* parser = NULL; |
|
3749 TRAPD( ret, parser = CStifParser::NewL( *iRebootPath, |
|
3750 *iRebootFilename ) ); |
|
3751 if( ret != KErrNone ) |
|
3752 { |
|
3753 __TRACE( KError, ( _L( "ReadRebootParams(): Reboot file not found" )) ); |
|
3754 return ret; |
|
3755 } |
|
3756 CleanupStack::PushL( parser ); |
|
3757 |
|
3758 // Create section object |
|
3759 CStifSectionParser* section = parser->SectionL( KNullDesC, KNullDesC ); |
|
3760 CleanupStack::PushL( section ); |
|
3761 |
|
3762 // Delete old reboot params |
|
3763 delete iRebootParams; |
|
3764 iRebootParams = 0; |
|
3765 iRebootParams = CRebootParams::NewL(); |
|
3766 |
|
3767 // ----------------------Test module parsing |
|
3768 CStifItemParser* item = section->GetItemLineL( KTestModule ); |
|
3769 CleanupStack::PushL( item ); |
|
3770 |
|
3771 // Parsing integer |
|
3772 ret_parsing = item->GetString( KTestModule, tmp ); |
|
3773 if( ret_parsing == KErrNone || ret_parsing == KErrNotFound ) |
|
3774 { |
|
3775 __TRACE( KVerbose, ( _L("ReadRebootParams(): TestModule: %S" ), &tmp ) ); |
|
3776 } |
|
3777 else |
|
3778 { |
|
3779 __TRACE( KError, |
|
3780 ( _L("ReadRebootParams(): TestModule parsing fails with error: " ), |
|
3781 ret_parsing ) ); |
|
3782 User::Leave( ret_parsing ); |
|
3783 } |
|
3784 iRebootParams->SetTestModuleNameL( tmp ); |
|
3785 CleanupStack::PopAndDestroy( item ); |
|
3786 |
|
3787 // ----------------------Testcase parsing |
|
3788 item = section->GetItemLineL( KTestCaseFile ); |
|
3789 CleanupStack::PushL( item ); |
|
3790 |
|
3791 // Parsing string |
|
3792 ret_parsing = item->GetString( KTestCaseFile, tmp ); |
|
3793 if( ret_parsing == KErrNone ) |
|
3794 { |
|
3795 __TRACE( KVerbose, ( _L("ReadRebootParams(): TestCaseFile: %S" ), &tmp ) ); |
|
3796 iRebootParams->SetTestCaseFileNameL( tmp ); |
|
3797 } |
|
3798 else if( ret_parsing == KErrNotFound ) |
|
3799 { |
|
3800 __TRACE( KVerbose, |
|
3801 ( _L("ReadRebootParams(): No testcasefile defined for test module" )) ); |
|
3802 } |
|
3803 else |
|
3804 { |
|
3805 __TRACE( KError, |
|
3806 ( _L("ReadRebootParams(): TestCaseFile parsing fails with error: %d " ), |
|
3807 ret_parsing ) ); |
|
3808 User::Leave( ret_parsing ); |
|
3809 } |
|
3810 CleanupStack::PopAndDestroy( item ); |
|
3811 |
|
3812 // ----------------------Testcase number parsing |
|
3813 item = section->GetItemLineL( KTestCaseNumber ); |
|
3814 CleanupStack::PushL( item ); |
|
3815 |
|
3816 // Parsing integer |
|
3817 ret_parsing = item->GetInt( KTestCaseNumber, iRebootParams->iCaseNumber ); |
|
3818 if( ret_parsing == KErrNone || ret_parsing == KErrNotFound ) |
|
3819 { |
|
3820 __TRACE( KVerbose, ( _L("ReadRebootParams(): TestCaseNumber: %d" ), |
|
3821 iRebootParams->iCaseNumber ) ); |
|
3822 } |
|
3823 else |
|
3824 { |
|
3825 __TRACE( KError, |
|
3826 ( _L("ReadRebootParams(): TestCaseNumber parsing fails with error: %d " ), |
|
3827 ret_parsing ) ); |
|
3828 User::Leave( ret_parsing ); |
|
3829 } |
|
3830 CleanupStack::PopAndDestroy( item ); |
|
3831 |
|
3832 // --.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.-- |
|
3833 // --.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.-- |
|
3834 // Next state code and name parsing if no error found |
|
3835 // --.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.--.-- |
|
3836 |
|
3837 // ----------------------State code parsing |
|
3838 item = section->GetItemLineL( KStateCode ); |
|
3839 CleanupStack::PushL( item ); |
|
3840 |
|
3841 // Parsing integer |
|
3842 ret_parsing = item->GetInt( KStateCode, iRebootParams->iStateCode ); |
|
3843 if( ret_parsing == KErrNone || ret_parsing == KErrNotFound ) |
|
3844 { |
|
3845 __TRACE( KVerbose, ( _L("ReadRebootParams(): StateCode: %d" ), |
|
3846 iRebootParams->iStateCode ) ); |
|
3847 } |
|
3848 else |
|
3849 { |
|
3850 __TRACE( KError, |
|
3851 ( _L("ReadRebootParams(): StateCode parsing fails with error: %d " ), |
|
3852 ret_parsing ) ); |
|
3853 User::Leave( ret_parsing ); |
|
3854 } |
|
3855 CleanupStack::PopAndDestroy( item ); |
|
3856 |
|
3857 // ----------------------State name parsing |
|
3858 ret_parsing = section->GetLine( KStateName, tmp, ENoTag ); |
|
3859 if( ret_parsing != KErrNone ) |
|
3860 { |
|
3861 __TRACE( KError, |
|
3862 ( _L("ReadRebootParams(): State name parsing fails with error: %d " ), |
|
3863 ret_parsing ) ); |
|
3864 User::Leave( ret_parsing ); |
|
3865 } |
|
3866 |
|
3867 iRebootParams->SetTestCaseStateL( tmp ); |
|
3868 |
|
3869 __TRACE( KVerbose, ( _L("ReadRebootParams() ends" ) ) ); |
|
3870 |
|
3871 CleanupStack::PopAndDestroy( section ); |
|
3872 CleanupStack::PopAndDestroy( parser ); |
|
3873 |
|
3874 // Delete file |
|
3875 RFs rf; |
|
3876 TInt retVal = rf.Connect(); |
|
3877 if( retVal != KErrNone ) |
|
3878 { |
|
3879 User::Leave( retVal ); |
|
3880 } |
|
3881 |
|
3882 TFileName file( *iRebootPath ); |
|
3883 file.Append( *iRebootFilename ); |
|
3884 rf.Delete( file ); |
|
3885 rf.Close(); |
|
3886 |
|
3887 return KErrNone; |
|
3888 |
|
3889 } |
|
3890 |
|
3891 /* |
|
3892 ------------------------------------------------------------------------------- |
|
3893 |
|
3894 Class: CTestEngine |
|
3895 |
|
3896 Method: PauseAllTestCases |
|
3897 |
|
3898 Description: Pause all test case(s) which are/is running. |
|
3899 |
|
3900 Parameters: None |
|
3901 |
|
3902 Return Values: None |
|
3903 |
|
3904 Errors/Exceptions: None |
|
3905 |
|
3906 Status: Draft |
|
3907 |
|
3908 ------------------------------------------------------------------------------- |
|
3909 */ |
|
3910 void CTestEngine::PauseAllTestCases() |
|
3911 { |
|
3912 __TRACE( KVerbose, ( _L( "CTestEngine::PauseAllTestCases()" ) ) ); |
|
3913 |
|
3914 TInt count( 0 ); |
|
3915 count = iTestCaseArray.Count(); |
|
3916 |
|
3917 for( TInt a = 0; a < count; a++ ) |
|
3918 { |
|
3919 // Pause test case |
|
3920 iTestCaseArray[a]->Pause(); |
|
3921 } |
|
3922 |
|
3923 } |
|
3924 |
|
3925 /* |
|
3926 ------------------------------------------------------------------------------- |
|
3927 |
|
3928 Class: CTestEngine |
|
3929 |
|
3930 Method: FlushAtsLogger |
|
3931 |
|
3932 Description: Flush ATS logger's |
|
3933 |
|
3934 Parameters: None |
|
3935 |
|
3936 Return Values: None |
|
3937 |
|
3938 Errors/Exceptions: None |
|
3939 |
|
3940 Status: Draft |
|
3941 |
|
3942 ------------------------------------------------------------------------------- |
|
3943 */ |
|
3944 void CTestEngine::FlushAtsLogger() |
|
3945 { |
|
3946 __TRACE( KVerbose, ( _L( "CTestEngine::FlushAtsLogger()" ) ) ); |
|
3947 |
|
3948 TInt count( 0 ); |
|
3949 count = iModules.Count(); |
|
3950 |
|
3951 for( TInt a = 0; a < count; a++ ) |
|
3952 { |
|
3953 // Pause test case |
|
3954 iModules[a]->AtsLogger().SaveForRebootL(); |
|
3955 } |
|
3956 |
|
3957 } |
|
3958 |
|
3959 /* |
|
3960 ------------------------------------------------------------------------------- |
|
3961 |
|
3962 Class: CTestEngine |
|
3963 |
|
3964 Method: GetDeviceResetDllName |
|
3965 |
|
3966 Description: Get device reset module's DLL name. |
|
3967 |
|
3968 Parameters: None |
|
3969 |
|
3970 Return Values: TPtrC |
|
3971 |
|
3972 Errors/Exceptions: None |
|
3973 |
|
3974 Status: Draft |
|
3975 |
|
3976 ------------------------------------------------------------------------------- |
|
3977 */ |
|
3978 TPtrC CTestEngine::GetDeviceResetDllName() |
|
3979 { |
|
3980 __TRACE( KVerbose, ( _L( "CTestEngine::GetDeviceResetDllName()" ) ) ); |
|
3981 |
|
3982 return iDeviceResetDllName->Des(); |
|
3983 |
|
3984 } |
|
3985 |
|
3986 /* |
|
3987 ------------------------------------------------------------------------------- |
|
3988 |
|
3989 Class: CTestEngine |
|
3990 |
|
3991 Method: EnableStifMeasurement |
|
3992 |
|
3993 Description: Set measurements related information, enable measurement. |
|
3994 |
|
3995 Parameters: const TName& aInfoType: in: Enabled measurement type |
|
3996 |
|
3997 Return Values: TInt: Symbian error code |
|
3998 |
|
3999 Errors/Exceptions: None |
|
4000 |
|
4001 Status: Approved |
|
4002 |
|
4003 ------------------------------------------------------------------------------- |
|
4004 */ |
|
4005 TInt CTestEngine::EnableStifMeasurement( const TDesC& aInfoType ) |
|
4006 { |
|
4007 __TRACE( KInit, ( _L( "Measurement [%S] enabled" ), &aInfoType ) ); |
|
4008 |
|
4009 if( aInfoType == KStifMeasurement01 ) |
|
4010 { |
|
4011 iDisableMeasurement &= ~EMeasurement01; |
|
4012 } |
|
4013 else if( aInfoType == KStifMeasurement02 ) |
|
4014 { |
|
4015 iDisableMeasurement &= ~EMeasurement02; |
|
4016 } |
|
4017 else if( aInfoType == KStifMeasurement03 ) |
|
4018 { |
|
4019 iDisableMeasurement &= ~EMeasurement03; |
|
4020 } |
|
4021 else if( aInfoType == KStifMeasurement04 ) |
|
4022 { |
|
4023 iDisableMeasurement &= ~EMeasurement04; |
|
4024 } |
|
4025 else if( aInfoType == KStifMeasurement05 ) |
|
4026 { |
|
4027 iDisableMeasurement &= ~EMeasurement05; |
|
4028 } |
|
4029 else if( aInfoType == KStifMeasurementBappea ) |
|
4030 { |
|
4031 iDisableMeasurement &= ~EBappea; |
|
4032 } |
|
4033 else if( aInfoType == KStifMeasurementDisableAll ) |
|
4034 { |
|
4035 __TRACE( KInit, ( _L( "All measurements are disabled" ) ) ); |
|
4036 iDisableMeasurement &= EDisableAll; // Does change anything !!! |
|
4037 } |
|
4038 else if( aInfoType == KStifMeasurementEnableAll ) |
|
4039 { |
|
4040 __TRACE( KInit, ( _L( "All measurements types are enabled" ) ) ); |
|
4041 iDisableMeasurement &= EEnableAll; |
|
4042 } |
|
4043 else |
|
4044 { |
|
4045 __TRACE( KInit, ( _L( "Measurement [%S] not recognized" ), &aInfoType ) ); |
|
4046 return KErrArgument; |
|
4047 } |
|
4048 |
|
4049 return KErrNone; |
|
4050 |
|
4051 } |
|
4052 |
|
4053 /* |
|
4054 ------------------------------------------------------------------------------- |
|
4055 |
|
4056 Class: CTestEngine |
|
4057 |
|
4058 Method: DisableStifMeasurement |
|
4059 |
|
4060 Description: Set measurements related information, disable measurement. |
|
4061 |
|
4062 Parameters: const TName& aInfoType: in: Disabled measurement type |
|
4063 |
|
4064 Return Values: TInt: Symbian error code |
|
4065 |
|
4066 Errors/Exceptions: None |
|
4067 |
|
4068 Status: Approved |
|
4069 |
|
4070 ------------------------------------------------------------------------------- |
|
4071 */ |
|
4072 TInt CTestEngine::DisableStifMeasurement( const TDesC& aInfoType ) |
|
4073 { |
|
4074 __TRACE( KInit, ( _L( "Measurement [%S] disabled" ), &aInfoType ) ); |
|
4075 |
|
4076 if( aInfoType == KStifMeasurement01 ) |
|
4077 { |
|
4078 iDisableMeasurement |= EMeasurement01; |
|
4079 } |
|
4080 else if( aInfoType == KStifMeasurement02 ) |
|
4081 { |
|
4082 iDisableMeasurement |= EMeasurement02; |
|
4083 } |
|
4084 else if( aInfoType == KStifMeasurement03 ) |
|
4085 { |
|
4086 iDisableMeasurement |= EMeasurement03; |
|
4087 } |
|
4088 else if( aInfoType == KStifMeasurement04 ) |
|
4089 { |
|
4090 iDisableMeasurement |= EMeasurement04; |
|
4091 } |
|
4092 else if( aInfoType == KStifMeasurement05 ) |
|
4093 { |
|
4094 iDisableMeasurement |= EMeasurement05; |
|
4095 } |
|
4096 else if( aInfoType == KStifMeasurementBappea ) |
|
4097 { |
|
4098 iDisableMeasurement |= EBappea; |
|
4099 } |
|
4100 else if( aInfoType == KStifMeasurementDisableAll ) |
|
4101 { |
|
4102 __TRACE( KInit, ( _L( "All measurements are disabled" ) ) ); |
|
4103 iDisableMeasurement |= EDisableAll; |
|
4104 } |
|
4105 else if( aInfoType == KStifMeasurementEnableAll ) |
|
4106 { |
|
4107 __TRACE( KInit, ( _L( "All measurements types are enabled" ) ) ); |
|
4108 iDisableMeasurement |= EEnableAll; // Does change anything !!! |
|
4109 } |
|
4110 // This option can be defined in TestFramework.ini file |
|
4111 else if( aInfoType == KStifMeasurementDisableNone ) |
|
4112 { |
|
4113 __TRACE( KInit, ( _L( "All measurements types are enabled" ) ) ); |
|
4114 iDisableMeasurement = EEnableAll; // Sets to 0 |
|
4115 } |
|
4116 else |
|
4117 { |
|
4118 __TRACE( KInit, ( _L( "Measurement [%S] not recognized" ), &aInfoType ) ); |
|
4119 return KErrArgument; |
|
4120 } |
|
4121 |
|
4122 return KErrNone; |
|
4123 |
|
4124 } |
|
4125 |
|
4126 /* |
|
4127 ------------------------------------------------------------------------------- |
|
4128 |
|
4129 Class: CTestEngine |
|
4130 |
|
4131 Method: StifMeasurement |
|
4132 |
|
4133 Description: Get measurements related information. Returns is measurement |
|
4134 disable. |
|
4135 |
|
4136 Parameters: None |
|
4137 |
|
4138 Return Values: TInt: Indication what measurement types is/are disabled. |
|
4139 |
|
4140 Errors/Exceptions: None |
|
4141 |
|
4142 Status: Approved |
|
4143 |
|
4144 ------------------------------------------------------------------------------- |
|
4145 */ |
|
4146 TInt CTestEngine::StifMeasurement() |
|
4147 { |
|
4148 return iDisableMeasurement; |
|
4149 |
|
4150 } |
|
4151 /* |
|
4152 ------------------------------------------------------------------------------- |
|
4153 |
|
4154 Class: CTestEngine |
|
4155 |
|
4156 Method: TestModuleCrash |
|
4157 |
|
4158 Description: This method is called only when test module crashed |
|
4159 with KErrServerTerminated (-15). |
|
4160 Clones new TestModuleController: |
|
4161 - Find crashed testmodulecontroller |
|
4162 - Creates new copy of that testmodulecontroller |
|
4163 - Replaces old crashed testmodulecontroller with this new one |
|
4164 |
|
4165 Parameters: CTestModuleController* aTestModuleController: in: TestModuleController |
|
4166 Return Values: None |
|
4167 |
|
4168 Errors/Exceptions: Leaves if error happens when adding clone to the list |
|
4169 |
|
4170 Status: Approved |
|
4171 |
|
4172 ------------------------------------------------------------------------------- |
|
4173 */ |
|
4174 void CTestEngine::TestModuleCrash(CTestModuleController* aTestModuleController) |
|
4175 { |
|
4176 TName crashModuleName = aTestModuleController->ModuleName(KNullDesC); |
|
4177 __TRACE(KInit, (_L("Handling crashed test module [%S]"), &crashModuleName)); |
|
4178 TBool isTestScripter(EFalse); |
|
4179 |
|
4180 // Find crashed test module controller |
|
4181 CTestScripterController* testScripterController = aTestModuleController->iTestScripterController; |
|
4182 if(testScripterController) |
|
4183 { |
|
4184 isTestScripter = ETrue; |
|
4185 } |
|
4186 |
|
4187 // If UITestingSupport or SeparateProcesses is enabled, there is no need |
|
4188 // to create clone of Test Module Controller, because it will be created |
|
4189 // automatically when needed. |
|
4190 if(iUITestingSupport && crashModuleName.Find(KTestScripterName) == 0 |
|
4191 || iSeparateProcesses |
|
4192 || (crashModuleName.Find(KPythonScripter) == 0) |
|
4193 ) |
|
4194 { |
|
4195 __TRACE(KInit, (_L("Handling crashed test module with enabled UITestingSupport or SeparateProcesses is not needed"))); |
|
4196 aTestModuleController->iTestModuleCrashDetected = ETrue; |
|
4197 return; |
|
4198 } |
|
4199 |
|
4200 // Clone crashed module |
|
4201 TBool afterReset = EFalse; |
|
4202 if(iRebootParams && iRebootParams->iTestModule == crashModuleName) |
|
4203 { |
|
4204 afterReset = ETrue; |
|
4205 } |
|
4206 |
|
4207 CTestModuleController* clone; |
|
4208 clone = aTestModuleController->CloneL(aTestModuleController, afterReset, testScripterController); |
|
4209 |
|
4210 // Replaces crashed testmodulecontroller with this new one |
|
4211 // Note: Old Testmodulecontroller is deleted in CTestModuleController::CaseFinished |
|
4212 // that is called from CTestCase::~CTestCase() |
|
4213 |
|
4214 TInt index = KErrNotFound; |
|
4215 if(isTestScripter) |
|
4216 { |
|
4217 index = testScripterController->iTestScripter.Find(aTestModuleController); |
|
4218 __TRACE(KInit, (_L("Crashed module index [%d]"), index)); |
|
4219 if(index != KErrNotFound) |
|
4220 { |
|
4221 testScripterController->iTestScripter.Remove(index); |
|
4222 } |
|
4223 testScripterController->iTestScripter.Append(clone); |
|
4224 } |
|
4225 else |
|
4226 { |
|
4227 index = iModules.Find(aTestModuleController); |
|
4228 __TRACE(KInit, (_L("Crashed module index [%d]"), index)); |
|
4229 if(index != KErrNotFound) |
|
4230 { |
|
4231 iModules.Remove(index); |
|
4232 } |
|
4233 iModules.Append(clone); |
|
4234 } |
|
4235 __TRACE(KInit, (_L("End of handling crashed test module"))); |
|
4236 } |
|
4237 |
|
4238 /* |
|
4239 ------------------------------------------------------------------------------- |
|
4240 |
|
4241 Class: CTestEngine |
|
4242 |
|
4243 Method: ExecuteCommandL |
|
4244 |
|
4245 Description: Executes command received from test case. |
|
4246 The method was created to allow test case to kill itself. |
|
4247 |
|
4248 Parameters: aTestCaseHandle: handler to test case |
|
4249 Return Values: None |
|
4250 |
|
4251 Errors/Exceptions: Leaves if error happens when adding clone to the list |
|
4252 |
|
4253 Status: Approved |
|
4254 |
|
4255 ------------------------------------------------------------------------------- |
|
4256 */ |
|
4257 void CTestEngine::ExecuteCommandL(TCommand aCommand, TDesC8& aParamsPckg) |
|
4258 { |
|
4259 TInt testCaseHandle = 0; |
|
4260 // Get params |
|
4261 switch(aCommand) |
|
4262 { |
|
4263 case EStopExecution: |
|
4264 { |
|
4265 //Unpack received parameters |
|
4266 TStopExecutionCommandParams par; |
|
4267 TStopExecutionCommandParamsPckg parPack(par); |
|
4268 parPack.Copy(aParamsPckg); |
|
4269 |
|
4270 __TRACE(KInit, (_L("CTestEngine::ExecuteCommandL received command [%d] type [%d] code [%d] test handle [%d]"), TInt(aCommand), TInt(par.iType), TInt(par.iCode), par.iTestCaseHandle)); |
|
4271 |
|
4272 //Get test case handle |
|
4273 testCaseHandle = par.iTestCaseHandle; |
|
4274 |
|
4275 break; |
|
4276 } |
|
4277 case ESendTestModuleVersion: |
|
4278 { |
|
4279 TSendTestModuleVesionCommandParams par; |
|
4280 TSendTestModuleVesionCommandParamsPckg parPack(par); |
|
4281 parPack.Copy(aParamsPckg); |
|
4282 |
|
4283 TTestModuleVersionInfo testModuleVersionInfo; |
|
4284 testModuleVersionInfo.iMajor = par.iMajor; |
|
4285 testModuleVersionInfo.iMinor = par.iMinor; |
|
4286 testModuleVersionInfo.iBuild = par.iBuild; |
|
4287 testModuleVersionInfo.iTestModuleName = par.iTestModuleName; |
|
4288 if( RetrieveTestReport() ) |
|
4289 { |
|
4290 iTestReport->AddTestModuleVersion(testModuleVersionInfo); |
|
4291 } |
|
4292 |
|
4293 return; |
|
4294 } |
|
4295 default: |
|
4296 __TRACE(KError, (_L("CTestEngine::ExecuteCommandL Unknown command [%d]"), TInt(aCommand))); |
|
4297 return; |
|
4298 } |
|
4299 |
|
4300 // Get test case from container |
|
4301 CTestCase* testCase = (CTestCase*)iTestCases->At(testCaseHandle); |
|
4302 |
|
4303 // Log some info if invalid handle |
|
4304 if(testCase == NULL) |
|
4305 { |
|
4306 __TRACE(KInit, ( _L( "CTestEngine::ExecuteCommandL - invalid handle. Unable to get test case to execute command [%d]"), TInt(aCommand))); |
|
4307 return; |
|
4308 } |
|
4309 |
|
4310 testCase->ExecuteCommandL(aCommand, aParamsPckg); |
|
4311 |
|
4312 } |
|
4313 |
|
4314 /* |
|
4315 ------------------------------------------------------------------------------- |
|
4316 |
|
4317 Class: CTestEngine |
|
4318 |
|
4319 Method: GetIndexForNewTestModuleController |
|
4320 |
|
4321 Description: Returns new index for test module controller. |
|
4322 This number is appended to module controller name. |
|
4323 This method is used when option to run every test case in |
|
4324 separate process is set to on. |
|
4325 |
|
4326 Parameters: aTestCaseHandle: handler to test case |
|
4327 Return Values: None |
|
4328 |
|
4329 Errors/Exceptions: Leaves if error happens when adding clone to the list |
|
4330 |
|
4331 Status: Approved |
|
4332 |
|
4333 ------------------------------------------------------------------------------- |
|
4334 */ |
|
4335 TInt CTestEngine::GetIndexForNewTestModuleController(void) |
|
4336 { |
|
4337 return iIndexTestModuleControllers++; |
|
4338 } |
|
4339 |
|
4340 /* |
|
4341 ------------------------------------------------------------------------------- |
|
4342 |
|
4343 Class: CTestEngine |
|
4344 |
|
4345 Method: AddTestCaseToTestReport |
|
4346 |
|
4347 Description: Get parameters from message and add test case to test report. |
|
4348 |
|
4349 Parameters: aMessage: message |
|
4350 Return Values: error id |
|
4351 |
|
4352 Status: Approved |
|
4353 |
|
4354 ------------------------------------------------------------------------------- |
|
4355 */ |
|
4356 TInt CTestEngine::AddTestCaseToTestReport(const RMessage2& aMessage) |
|
4357 { |
|
4358 if( RetrieveTestReport() ) |
|
4359 { |
|
4360 // Read test data |
|
4361 TTestInfo testInfo; |
|
4362 TTestInfoPckg testInfoPckg(testInfo); |
|
4363 |
|
4364 TFullTestResult fullTestResult; |
|
4365 TFullTestResultPckg fullTestResultPckg(fullTestResult); |
|
4366 |
|
4367 TRAPD(err, aMessage.ReadL(0, testInfoPckg)); |
|
4368 if(err) |
|
4369 { |
|
4370 __TRACE(KError, (_L("Leave when reading TTestInfo in AddTestCaseToTestReport [%d]"), err)); |
|
4371 return err; |
|
4372 } |
|
4373 |
|
4374 TRAP(err, aMessage.ReadL(1, fullTestResultPckg)); |
|
4375 if(err) |
|
4376 { |
|
4377 __TRACE(KError, (_L("Leave when reading TFullTestResult in AddTestCaseToTestReport [%d]"), err)); |
|
4378 return err; |
|
4379 } |
|
4380 |
|
4381 TRAP( err, iTestReport->AddTestCaseResultL(testInfo, fullTestResult, aMessage.Int2())); |
|
4382 if( err ) |
|
4383 { |
|
4384 __TRACE(KError, (_L("Leave from test report in AddTestCaseToTestReport [%d]"), err)); |
|
4385 return err; |
|
4386 } |
|
4387 } |
|
4388 else |
|
4389 { |
|
4390 __TRACE(KError, (_L("TestReport not initialized in AddTestCaseToTestReport"))); |
|
4391 return KErrNotReady; |
|
4392 } |
|
4393 |
|
4394 return KErrNone; |
|
4395 } |
|
4396 |
|
4397 TBool CTestEngine::UITesting() |
|
4398 { |
|
4399 return iUITestingSupport; |
|
4400 } |
|
4401 |
|
4402 TBool CTestEngine::SeparateProcesses() |
|
4403 { |
|
4404 return iSeparateProcesses; |
|
4405 } |
|
4406 |
|
4407 CTestReport* CTestEngine::RetrieveTestReport() |
|
4408 { |
|
4409 if(iTestReport==NULL) |
|
4410 { |
|
4411 // Create Test Reporter if allowed |
|
4412 if ( iTestReportSettings->iCreateTestReport ) |
|
4413 { |
|
4414 TRAPD(err, iTestReport = |
|
4415 CTestReport::NewL( *iTestReportSettings, ( CTestReport::TTestReportMode ) iReportMode )); |
|
4416 if(err!=KErrNone) |
|
4417 { |
|
4418 iTestReport = NULL; |
|
4419 __TRACE( KInit,( CStifLogger::ERed, _L( "Test report creation failed with error: %d, test report not created." ), err ) ); |
|
4420 __TRACE( KInit,( CStifLogger::ERed, _L( "Check your testreport settings from testframework.ini file (e.g. TestReportFilePath)." ) ) ); |
|
4421 __TRACE( KInit,( CStifLogger::ERed, _L( "Also check if testreport is not used by other testengine session. If it is change testreport " ) ) ); |
|
4422 __TRACE( KInit,( CStifLogger::ERed, _L( "name in TestFramework.ini." ) ) ); |
|
4423 } |
|
4424 } |
|
4425 } |
|
4426 return iTestReport; |
|
4427 } |
|
4428 |
|
4429 /* |
|
4430 ------------------------------------------------------------------------------- |
|
4431 |
|
4432 DESCRIPTION |
|
4433 |
|
4434 This module contains implementation of CTestEngineSubSession class member functions. |
|
4435 |
|
4436 ------------------------------------------------------------------------------- |
|
4437 */ |
|
4438 |
|
4439 // ================= MEMBER FUNCTIONS ========================================= |
|
4440 |
|
4441 /* |
|
4442 ------------------------------------------------------------------------------- |
|
4443 |
|
4444 DESCRIPTION |
|
4445 |
|
4446 This module contains implementation of CTestCase class member functions. |
|
4447 |
|
4448 ------------------------------------------------------------------------------- |
|
4449 */ |
|
4450 |
|
4451 // ================= MEMBER FUNCTIONS ========================================= |
|
4452 |
|
4453 /* |
|
4454 ------------------------------------------------------------------------------- |
|
4455 |
|
4456 Class: CTestCase |
|
4457 |
|
4458 Method: CTestCase |
|
4459 |
|
4460 Description: Default constructor |
|
4461 |
|
4462 C++ default constructor can NOT contain any code, that |
|
4463 might leave. |
|
4464 |
|
4465 Parameters: CTestEngine* aEngine: in: Pointer to Test Engine |
|
4466 CTestModuleController* aModuleController: in: Pointer to |
|
4467 Module Controller |
|
4468 TTestInfo& aTestInfo: in: Test info for this test case |
|
4469 CTestModuleController* aRealModuleController: in: Pointer to |
|
4470 module controller used inside in scripter controller |
|
4471 |
|
4472 Return Values: None |
|
4473 |
|
4474 Errors/Exceptions: None |
|
4475 |
|
4476 Status: Proposal |
|
4477 |
|
4478 ------------------------------------------------------------------------------- |
|
4479 */ |
|
4480 CTestCase::CTestCase( CTestEngine* aEngine, |
|
4481 CTestModuleController* aModuleController, |
|
4482 TTestInfo& aTestInfo, |
|
4483 CTestModuleController* aRealModuleController ) : |
|
4484 iTestEngine( aEngine ), |
|
4485 iTestModule( aModuleController ), |
|
4486 iRealModuleController (aRealModuleController) |
|
4487 { |
|
4488 |
|
4489 // This method must be called to find out how |
|
4490 // many testcases are currently ongoing by increasing iTestCaseCounter. |
|
4491 // This is a part of the implementation for |
|
4492 // supporting test module crashing with -15 |
|
4493 iTestModule->CaseCreated(); |
|
4494 |
|
4495 // Store handle to RTestServer |
|
4496 //If test scripter is used (it uses internally module controllers) |
|
4497 //then use it (real module controller). |
|
4498 if(iRealModuleController) |
|
4499 { |
|
4500 iTestServer = iRealModuleController->Server(aTestInfo); |
|
4501 } |
|
4502 else |
|
4503 { |
|
4504 iTestServer = iTestModule->Server( aTestInfo ); |
|
4505 } |
|
4506 |
|
4507 //If real test module controller is provided, increase test case count |
|
4508 if(iRealModuleController) |
|
4509 { |
|
4510 iRealModuleController->CaseCreated(); |
|
4511 } |
|
4512 } |
|
4513 |
|
4514 /* |
|
4515 ------------------------------------------------------------------------------- |
|
4516 |
|
4517 Class: CTestCase |
|
4518 |
|
4519 Method: ConstructL |
|
4520 |
|
4521 Description: Symbian OS second phase constructor |
|
4522 |
|
4523 Symbian OS default constructor can leave. |
|
4524 |
|
4525 Parameters: CTestReport* aTestReport: in: Pointer to Test Report |
|
4526 TTestInfo& aTestInfo: in: Test Info for this test case |
|
4527 |
|
4528 Return Values: None |
|
4529 |
|
4530 Errors/Exceptions: Leaves if RTestExecution::Open returns error |
|
4531 Leaves if some of called leaving methods leaves |
|
4532 |
|
4533 Status: Approved |
|
4534 |
|
4535 ------------------------------------------------------------------------------- |
|
4536 */ |
|
4537 void CTestCase::ConstructL( CTestReport* aTestReport, |
|
4538 TTestInfo& aTestInfo ) |
|
4539 { |
|
4540 __TRACE( KVerbose, ( _L( "CTestCase::ConstructL" ) ) ); |
|
4541 |
|
4542 // Open handle to RTestExecution |
|
4543 User::LeaveIfError( iTestExecution.Open( iTestServer, |
|
4544 aTestInfo.iTestCaseInfo.iCaseNumber, aTestInfo.iConfig ) ); |
|
4545 |
|
4546 // Make new test case runner |
|
4547 iTestCaseController = CTestCaseController::NewL( iTestEngine, |
|
4548 aTestReport, iTestModule->AtsLogger(), iTestExecution, aTestInfo ); |
|
4549 |
|
4550 // Make new test case printer |
|
4551 iTestCasePrint = CTestProgressNotifier::NewL( iTestEngine, |
|
4552 iTestExecution ); |
|
4553 |
|
4554 iTestCaseEvent = CTestEventNotifier::NewL( iTestEngine, iTestExecution ); |
|
4555 |
|
4556 iTestCaseRemoteCmd = CTestRemoteCmdNotifier::NewL( iTestEngine, |
|
4557 iTestExecution, |
|
4558 iTestCaseController, |
|
4559 iTestModule->AtsLogger() ); |
|
4560 |
|
4561 iTestCaseCommand = CTestCommandNotifier::NewL(iTestEngine, iTestExecution); |
|
4562 } |
|
4563 |
|
4564 /* |
|
4565 ------------------------------------------------------------------------------- |
|
4566 |
|
4567 Class: CTestCase |
|
4568 |
|
4569 Method: NewL |
|
4570 |
|
4571 Description: Two-phased constructor. |
|
4572 |
|
4573 Parameters: CTestEngine* aEngine: in: Pointer to Test Engine |
|
4574 CTestModuleController* aModuleController: in: Pointer to |
|
4575 Module Controller |
|
4576 CTestReport* aTestReport: in: Pointer to Test Report |
|
4577 TTestInfo& aTestInfo: in: Test Info for this test case |
|
4578 |
|
4579 Return Values: CTestCase* : pointer to created CTestCase object |
|
4580 |
|
4581 Errors/Exceptions: Leaves if ConstructL leaves |
|
4582 |
|
4583 Status: Approved |
|
4584 |
|
4585 ------------------------------------------------------------------------------- |
|
4586 */ |
|
4587 CTestCase* CTestCase::NewL( CTestEngine* aEngine, |
|
4588 CTestModuleController* aModuleController, |
|
4589 CTestReport* aTestReport, |
|
4590 TTestInfo& aTestInfo, |
|
4591 CTestModuleController* aRealModuleController ) |
|
4592 { |
|
4593 CTestCase* self = new ( ELeave ) CTestCase( aEngine, aModuleController, aTestInfo, aRealModuleController ); |
|
4594 CleanupClosePushL( *self ); |
|
4595 self->ConstructL( aTestReport, aTestInfo ); |
|
4596 CleanupStack::Pop(); |
|
4597 return self; |
|
4598 |
|
4599 } |
|
4600 |
|
4601 /* |
|
4602 ------------------------------------------------------------------------------- |
|
4603 |
|
4604 Class: CTestCase |
|
4605 |
|
4606 Method: ~CTestCase |
|
4607 |
|
4608 Description: Destructor |
|
4609 |
|
4610 Parameters: None |
|
4611 |
|
4612 Return Values: None |
|
4613 |
|
4614 Errors/Exceptions: None |
|
4615 |
|
4616 Status: Approved |
|
4617 |
|
4618 ------------------------------------------------------------------------------- |
|
4619 */ |
|
4620 CTestCase::~CTestCase() |
|
4621 { |
|
4622 CloseTestCase(); |
|
4623 |
|
4624 // This added method call is a part of the implementation for |
|
4625 // supporting test module crashing with -15. |
|
4626 // It checks that can old Testmodulecontroller be deletd or not |
|
4627 if( iTestModule != NULL ) |
|
4628 { |
|
4629 iTestModule->CaseFinished(); |
|
4630 } |
|
4631 |
|
4632 //If real test module controller is provided, decrease test case count |
|
4633 if( iRealModuleController != NULL ) |
|
4634 { |
|
4635 iRealModuleController->CaseFinished(); |
|
4636 } |
|
4637 } |
|
4638 |
|
4639 /* |
|
4640 ------------------------------------------------------------------------------- |
|
4641 |
|
4642 Class: CTestCase |
|
4643 |
|
4644 Method: CloseTestCase |
|
4645 |
|
4646 Description: Close session |
|
4647 |
|
4648 Parameters: None |
|
4649 |
|
4650 Return Values: None |
|
4651 |
|
4652 Errors/Exceptions: None |
|
4653 |
|
4654 Status: Approved |
|
4655 |
|
4656 ------------------------------------------------------------------------------- |
|
4657 */ |
|
4658 void CTestCase::CloseTestCase() |
|
4659 { |
|
4660 __TRACE( KVerbose, ( _L( "CTestCase::CloseTestCase" ) ) ); |
|
4661 |
|
4662 // Free allocated resources |
|
4663 delete iTestCaseController; |
|
4664 iTestCaseController = NULL; |
|
4665 delete iTestCasePrint; |
|
4666 iTestCasePrint = NULL; |
|
4667 delete iTestCaseRemoteCmd; |
|
4668 iTestCaseRemoteCmd = NULL; |
|
4669 |
|
4670 delete iTestCaseEvent; |
|
4671 iTestCaseEvent = NULL; |
|
4672 |
|
4673 delete iTestCaseCommand; |
|
4674 iTestCaseCommand = NULL; |
|
4675 |
|
4676 iTestExecution.Close(); |
|
4677 |
|
4678 } |
|
4679 |
|
4680 /* |
|
4681 ------------------------------------------------------------------------------- |
|
4682 |
|
4683 Class: CTestCase |
|
4684 |
|
4685 Method: RunTestCaseL |
|
4686 |
|
4687 Description: Enumerates test cases |
|
4688 |
|
4689 Parameters: const RMessage& aMessage: in: Server Message |
|
4690 |
|
4691 Return Values: None |
|
4692 |
|
4693 Errors/Exceptions: Leaves if some of called leaving methods leaves |
|
4694 |
|
4695 Status: Approved |
|
4696 |
|
4697 ------------------------------------------------------------------------------- |
|
4698 */ |
|
4699 void CTestCase::RunTestCaseL( const RMessage2& aMessage ) |
|
4700 { |
|
4701 __TRACE( KVerbose, ( _L( "CTestCase::RunTestCaseL" ) ) ); |
|
4702 // Start active objects for running test case |
|
4703 iTestCaseController->StartL( aMessage ); |
|
4704 iTestCaseEvent->Start(); |
|
4705 iTestCaseCommand->Start(); |
|
4706 } |
|
4707 |
|
4708 /* |
|
4709 ------------------------------------------------------------------------------- |
|
4710 |
|
4711 Class: CTestCase |
|
4712 |
|
4713 Method: Pause |
|
4714 |
|
4715 Description: Suspend the test case execution |
|
4716 |
|
4717 Parameters: None |
|
4718 |
|
4719 Return Values: TInt: Return value from RTestExecution::Pause |
|
4720 |
|
4721 Errors/Exceptions: None |
|
4722 |
|
4723 Status: Approved |
|
4724 |
|
4725 ------------------------------------------------------------------------------- |
|
4726 */ |
|
4727 TInt CTestCase::Pause() |
|
4728 { |
|
4729 __TRACE( KVerbose, ( _L( "CTestCase::Pause" ) ) ); |
|
4730 |
|
4731 return iTestExecution.Pause(); |
|
4732 |
|
4733 } |
|
4734 |
|
4735 /* |
|
4736 ------------------------------------------------------------------------------- |
|
4737 |
|
4738 Class: CTestCase |
|
4739 |
|
4740 Method: Resume |
|
4741 |
|
4742 Description: Resume the suspended test case execution |
|
4743 |
|
4744 Parameters: None |
|
4745 |
|
4746 Return Values: TInt: Return value from RTestExecution::Resume |
|
4747 |
|
4748 Errors/Exceptions: None |
|
4749 |
|
4750 Status: Approved |
|
4751 |
|
4752 ------------------------------------------------------------------------------- |
|
4753 */ |
|
4754 TInt CTestCase::Resume() |
|
4755 { |
|
4756 __TRACE( KVerbose, ( _L( "CTestCase::Resume" ) ) ); |
|
4757 |
|
4758 return iTestExecution.Resume(); |
|
4759 |
|
4760 } |
|
4761 |
|
4762 /* |
|
4763 ------------------------------------------------------------------------------- |
|
4764 |
|
4765 Class: CTestCase |
|
4766 |
|
4767 Method: NotifyProgressL |
|
4768 |
|
4769 Description: Notifies progresses from Test Module |
|
4770 |
|
4771 Parameters: const RMessage& aMessage: in: Server message |
|
4772 |
|
4773 Return Values: None |
|
4774 |
|
4775 Errors/Exceptions: Leaves if called StartL method leaves |
|
4776 |
|
4777 Status: Approved |
|
4778 |
|
4779 ------------------------------------------------------------------------------- |
|
4780 */ |
|
4781 void CTestCase::NotifyProgressL( const RMessage2& aMessage ) |
|
4782 { |
|
4783 __TRACE( KVerbose, ( _L( "CTestCase::NotifyProgressL" ) ) ); |
|
4784 iTestCasePrint->StartL( aMessage ); |
|
4785 |
|
4786 } |
|
4787 |
|
4788 /* |
|
4789 ------------------------------------------------------------------------------- |
|
4790 |
|
4791 Class: CTestCase |
|
4792 |
|
4793 Method: NotifyRemoteTypeL |
|
4794 |
|
4795 Description: Notifies remote commands from Test Module |
|
4796 |
|
4797 Parameters: const RMessage& aMessage: in: Server message |
|
4798 |
|
4799 Return Values: None |
|
4800 |
|
4801 Errors/Exceptions: Leaves if called StartL method leaves |
|
4802 |
|
4803 Status: Approved |
|
4804 |
|
4805 ------------------------------------------------------------------------------- |
|
4806 */ |
|
4807 void CTestCase::NotifyRemoteTypeL( const RMessage2& aMessage ) |
|
4808 { |
|
4809 |
|
4810 __TRACE( KVerbose, ( _L( "CTestCase::NotifyRemoteTypeL" ) ) ); |
|
4811 iTestCaseRemoteCmd->EnableReceive( aMessage ); |
|
4812 |
|
4813 } |
|
4814 |
|
4815 /* |
|
4816 ------------------------------------------------------------------------------- |
|
4817 |
|
4818 Class: CTestCase |
|
4819 |
|
4820 Method: NotifyRemoteMsgL |
|
4821 |
|
4822 Description: Notifies remote commands from Test Module |
|
4823 |
|
4824 Parameters: const RMessage& aMessage: in: Server message |
|
4825 |
|
4826 Return Values: None |
|
4827 |
|
4828 Errors/Exceptions: Leaves if called StartL method leaves |
|
4829 |
|
4830 Status: Approved |
|
4831 |
|
4832 ------------------------------------------------------------------------------- |
|
4833 */ |
|
4834 void CTestCase::NotifyRemoteMsgL( const RMessage2& aMessage ) |
|
4835 { |
|
4836 |
|
4837 __TRACE( KVerbose, ( _L( "CTestCase::NotifyRemoteMsgL" ) ) ); |
|
4838 switch( aMessage.Int1() ) |
|
4839 { |
|
4840 case EStifCmdSend: |
|
4841 { |
|
4842 iTestCaseRemoteCmd->GetReceivedMsg( aMessage ); |
|
4843 } |
|
4844 break; |
|
4845 case EStifCmdReceive: |
|
4846 { |
|
4847 TInt len = aMessage.Int2(); |
|
4848 if( len <= 0 ) |
|
4849 { |
|
4850 User::Leave( KErrGeneral ); |
|
4851 } |
|
4852 HBufC8* buf = HBufC8::NewLC( len ); |
|
4853 |
|
4854 TPtr8 tmp = buf->Des(); |
|
4855 aMessage.ReadL( 0, tmp ); |
|
4856 |
|
4857 TInt ret = iTestExecution.ReadRemoteCmdInfo( tmp, EStifCmdReceive ); |
|
4858 |
|
4859 CleanupStack::PopAndDestroy( buf ); |
|
4860 |
|
4861 aMessage.Complete( ret ); |
|
4862 } |
|
4863 break; |
|
4864 case EStifCmdRebootProceed: |
|
4865 { |
|
4866 TInt value = 0; |
|
4867 TPckg<TInt> tmp( value ); |
|
4868 aMessage.ReadL( 0, tmp ); |
|
4869 |
|
4870 TInt ret = iTestExecution.ReadRemoteCmdInfo( tmp, |
|
4871 EStifCmdRebootProceed, |
|
4872 value ); |
|
4873 aMessage.Complete( ret ); |
|
4874 } |
|
4875 break; |
|
4876 default: |
|
4877 { |
|
4878 User::Leave( KErrGeneral ); |
|
4879 } |
|
4880 } |
|
4881 } |
|
4882 |
|
4883 /* |
|
4884 ------------------------------------------------------------------------------- |
|
4885 |
|
4886 Class: CTestCase |
|
4887 |
|
4888 Method: CancelAsyncRequest |
|
4889 |
|
4890 Description: Asynchronous requests are canceled by this function. |
|
4891 |
|
4892 Parameters: const RMessage aMessage |
|
4893 |
|
4894 Return Values: None |
|
4895 |
|
4896 Errors/Exceptions: None |
|
4897 |
|
4898 Status: Approved |
|
4899 |
|
4900 ------------------------------------------------------------------------------- |
|
4901 */ |
|
4902 void CTestCase::CancelAsyncRequest( const RMessage2& aMessage ) |
|
4903 { |
|
4904 switch ( aMessage.Int0() ) |
|
4905 { |
|
4906 case ETestCaseRunTestCase: |
|
4907 { |
|
4908 iTestCaseController->Cancel(); |
|
4909 iTestCaseEvent->Cancel(); |
|
4910 break; |
|
4911 } |
|
4912 case ETestCaseNotifyProgress: |
|
4913 { |
|
4914 iTestCasePrint->Cancel(); |
|
4915 break; |
|
4916 } |
|
4917 case ETestCaseNotifyRemoteType: |
|
4918 { |
|
4919 iTestCaseRemoteCmd->CancelReq(); |
|
4920 break; |
|
4921 } |
|
4922 case ETestCaseNotifyCommand: |
|
4923 { |
|
4924 iTestCaseCommand->Cancel(); |
|
4925 break; |
|
4926 } |
|
4927 default: |
|
4928 iTestEngine->PanicClient( EBadRequest, aMessage ); |
|
4929 break; |
|
4930 } |
|
4931 |
|
4932 } |
|
4933 |
|
4934 /* |
|
4935 ------------------------------------------------------------------------------- |
|
4936 |
|
4937 Class: CTestCase |
|
4938 |
|
4939 Method: ModuleName |
|
4940 |
|
4941 Description: Return the name of Test Module. |
|
4942 |
|
4943 Parameters: None |
|
4944 |
|
4945 Return Values: const TFileName& : Test Module owning this test case |
|
4946 |
|
4947 Errors/Exceptions: None |
|
4948 |
|
4949 Status: Approved |
|
4950 |
|
4951 ------------------------------------------------------------------------------- |
|
4952 */ |
|
4953 const TDesC& CTestCase::ModuleName() |
|
4954 { |
|
4955 return iTestModule->ModuleName( KNullDesC ); |
|
4956 |
|
4957 } |
|
4958 |
|
4959 /* |
|
4960 ------------------------------------------------------------------------------- |
|
4961 |
|
4962 Class: CTestCase |
|
4963 |
|
4964 Method: CtlEvent |
|
4965 |
|
4966 Description: Control events |
|
4967 |
|
4968 Parameters: const TEventIf& aEvent: in: Event |
|
4969 TRequestStatus& aStatus: in: Request status |
|
4970 |
|
4971 Return Values: None |
|
4972 |
|
4973 Errors/Exceptions: None |
|
4974 |
|
4975 Status: Approved |
|
4976 |
|
4977 ------------------------------------------------------------------------------- |
|
4978 */ |
|
4979 void CTestCase::CtlEvent( const TEventIf& aEvent, TRequestStatus& aStatus ) |
|
4980 { |
|
4981 __ASSERT_ALWAYS( iTestCaseEvent, User::Panic( _L( "TestEngine event panic" ), KErrArgument ) ); |
|
4982 |
|
4983 iTestCaseEvent->CtlEvent( aEvent, aStatus ); |
|
4984 } |
|
4985 |
|
4986 /* |
|
4987 ------------------------------------------------------------------------------- |
|
4988 |
|
4989 Class: CTestCase |
|
4990 |
|
4991 Method: CheckCtlEvent |
|
4992 |
|
4993 Description: Check if CtlEvent should be called |
|
4994 |
|
4995 Parameters: const TEventIf& aEvent: in: Event |
|
4996 |
|
4997 Return Values: None |
|
4998 |
|
4999 Errors/Exceptions: None |
|
5000 |
|
5001 Status: Approved |
|
5002 |
|
5003 ------------------------------------------------------------------------------- |
|
5004 */ |
|
5005 TBool CTestCase::CheckCtlEvent( const TEventIf& aEvent ) |
|
5006 { |
|
5007 return iTestCaseEvent->CheckCtlEvent( aEvent ); |
|
5008 } |
|
5009 |
|
5010 |
|
5011 /* |
|
5012 ------------------------------------------------------------------------------- |
|
5013 |
|
5014 Class: CTestCase |
|
5015 |
|
5016 Method: Logger |
|
5017 |
|
5018 Description: Return the pointer to Logger. |
|
5019 |
|
5020 Parameters: None |
|
5021 |
|
5022 Return Values: CStifLogger*: Pointer to StifLogger |
|
5023 |
|
5024 Errors/Exceptions: None |
|
5025 |
|
5026 Status: Approved |
|
5027 |
|
5028 ------------------------------------------------------------------------------- |
|
5029 */ |
|
5030 CStifLogger* CTestCase::Logger() |
|
5031 { |
|
5032 return iTestEngine->Logger(); |
|
5033 |
|
5034 } |
|
5035 |
|
5036 /* |
|
5037 ------------------------------------------------------------------------------- |
|
5038 |
|
5039 Class: CTestCase |
|
5040 |
|
5041 Method: ExecuteCommaandL |
|
5042 |
|
5043 Description: Executes command received from test case. |
|
5044 |
|
5045 Parameters: aStifCommand command to be executed |
|
5046 aParam1 parameter to command |
|
5047 |
|
5048 Return Values: None |
|
5049 |
|
5050 Errors/Exceptions: None |
|
5051 |
|
5052 Status: Approved |
|
5053 |
|
5054 ------------------------------------------------------------------------------- |
|
5055 */ |
|
5056 void CTestCase::ExecuteCommandL(TCommand aCommand, TDesC8& aParamsPckg) |
|
5057 { |
|
5058 switch(aCommand) |
|
5059 { |
|
5060 case EStopExecution: |
|
5061 { |
|
5062 //Unpack received parameters |
|
5063 TStopExecutionCommandParams par; |
|
5064 TStopExecutionCommandParamsPckg parPack(par); |
|
5065 parPack.Copy(aParamsPckg); |
|
5066 |
|
5067 __TRACE(KVerbose, (_L("CTestCase::ExecuteCommandL command [%d] type [%d] code [%d]"), TInt(aCommand), TInt(par.iType), par.iCode)); |
|
5068 |
|
5069 iTestCaseController->Suicide(par.iType, par.iCode); |
|
5070 break; |
|
5071 } |
|
5072 default: |
|
5073 __TRACE(KVerbose, (_L("CTestCase::ExecuteCommandL unknown command [%d]"), TInt(aCommand))); |
|
5074 return; |
|
5075 } |
|
5076 |
|
5077 } |
|
5078 |
|
5079 /* |
|
5080 ------------------------------------------------------------------------------- |
|
5081 |
|
5082 Class: CTestCase |
|
5083 |
|
5084 Method: GetModuleControllers |
|
5085 |
|
5086 Description: Return module controller and real module controller |
|
5087 |
|
5088 Parameters: aRealModuleController: out: real module controller |
|
5089 |
|
5090 Return Values: module controller |
|
5091 |
|
5092 Errors/Exceptions: None |
|
5093 |
|
5094 Status: Approved |
|
5095 |
|
5096 ------------------------------------------------------------------------------- |
|
5097 */ |
|
5098 CTestModuleController* CTestCase::GetModuleControllers(CTestModuleController** aRealModuleController) |
|
5099 { |
|
5100 *aRealModuleController = iRealModuleController; |
|
5101 return iTestModule; |
|
5102 } |
|
5103 |
|
5104 /* |
|
5105 ------------------------------------------------------------------------------- |
|
5106 |
|
5107 Class: CTestCase |
|
5108 |
|
5109 Method: ResetModuleController |
|
5110 |
|
5111 Description: Set new module controller for test case (only in case when |
|
5112 original controller crashed) |
|
5113 |
|
5114 Parameters: aModuleController: in: new module controller |
|
5115 |
|
5116 Return Values: None |
|
5117 |
|
5118 Errors/Exceptions: None |
|
5119 |
|
5120 Status: Approved |
|
5121 |
|
5122 ------------------------------------------------------------------------------- |
|
5123 */ |
|
5124 void CTestCase::ResetModuleController(CTestModuleController* aModuleController) |
|
5125 { |
|
5126 iTestModule = aModuleController; |
|
5127 } |
|
5128 |
|
5129 /* |
|
5130 ------------------------------------------------------------------------------- |
|
5131 |
|
5132 Class: CTestCase |
|
5133 |
|
5134 Method: ResetRealModuleController |
|
5135 |
|
5136 Description: Set new real module controller for test case (only in case |
|
5137 when original controller crashed). |
|
5138 |
|
5139 Parameters: aRealModuleController: in: new real module controller |
|
5140 |
|
5141 Return Values: None |
|
5142 |
|
5143 Errors/Exceptions: None |
|
5144 |
|
5145 Status: Approved |
|
5146 |
|
5147 ------------------------------------------------------------------------------- |
|
5148 */ |
|
5149 void CTestCase::ResetRealModuleController(CTestModuleController* aRealModuleController) |
|
5150 { |
|
5151 iRealModuleController = aRealModuleController; |
|
5152 } |
|
5153 |
|
5154 /* |
|
5155 ------------------------------------------------------------------------------- |
|
5156 |
|
5157 DESCRIPTION |
|
5158 |
|
5159 Default constructor |
|
5160 |
|
5161 ------------------------------------------------------------------------------- |
|
5162 */ |
|
5163 CTestReportSettings::CTestReportSettings() |
|
5164 { |
|
5165 iCreateTestReport = ETrue; |
|
5166 iPath = NULL; |
|
5167 iName = NULL; |
|
5168 iFormat = CStifLogger::ETxt; |
|
5169 iOutput = CStifLogger::EFile; |
|
5170 iOverwrite = ETrue; |
|
5171 iXML = EFalse; |
|
5172 } |
|
5173 |
|
5174 /* |
|
5175 ------------------------------------------------------------------------------- |
|
5176 |
|
5177 DESCRIPTION |
|
5178 |
|
5179 Two-phased constructor. |
|
5180 |
|
5181 ------------------------------------------------------------------------------- |
|
5182 */ |
|
5183 CTestReportSettings* CTestReportSettings::NewL() |
|
5184 { |
|
5185 CTestReportSettings* self = new ( ELeave ) CTestReportSettings(); |
|
5186 CleanupStack::PushL( self ); |
|
5187 self->ConstructL(); |
|
5188 CleanupStack::Pop(); |
|
5189 return self; |
|
5190 } |
|
5191 |
|
5192 /* |
|
5193 ------------------------------------------------------------------------------- |
|
5194 |
|
5195 DESCRIPTION |
|
5196 |
|
5197 Symbian OS second phase constructor |
|
5198 |
|
5199 ------------------------------------------------------------------------------- |
|
5200 */ |
|
5201 void CTestReportSettings::ConstructL() |
|
5202 { |
|
5203 |
|
5204 } |
|
5205 /* |
|
5206 ------------------------------------------------------------------------------- |
|
5207 |
|
5208 DESCRIPTION |
|
5209 |
|
5210 Destructor |
|
5211 |
|
5212 ------------------------------------------------------------------------------- |
|
5213 */ |
|
5214 CTestReportSettings::~CTestReportSettings() |
|
5215 { |
|
5216 delete iPath; |
|
5217 iPath = NULL; |
|
5218 delete iName; |
|
5219 iName = NULL; |
|
5220 } |
|
5221 |
|
5222 |
|
5223 /* |
|
5224 ------------------------------------------------------------------------------- |
|
5225 |
|
5226 DESCRIPTION |
|
5227 |
|
5228 This module contains implementation of CRebootParams class member functions. |
|
5229 |
|
5230 ------------------------------------------------------------------------------- |
|
5231 */ |
|
5232 |
|
5233 // ================= MEMBER FUNCTIONS ========================================= |
|
5234 |
|
5235 /* |
|
5236 ------------------------------------------------------------------------------- |
|
5237 |
|
5238 Class: CRebootParams |
|
5239 |
|
5240 Method: CRebootParams |
|
5241 |
|
5242 Description: Default constructor |
|
5243 |
|
5244 Parameters: None |
|
5245 |
|
5246 Return Values: None |
|
5247 |
|
5248 Errors/Exceptions: None |
|
5249 |
|
5250 Status: Draft |
|
5251 |
|
5252 ------------------------------------------------------------------------------- |
|
5253 */ |
|
5254 CRebootParams::CRebootParams() |
|
5255 { |
|
5256 } |
|
5257 |
|
5258 /* |
|
5259 ------------------------------------------------------------------------------- |
|
5260 |
|
5261 Class: CRebootParams |
|
5262 |
|
5263 Method: ConstructL |
|
5264 |
|
5265 Description: Symbian OS second phase constructor |
|
5266 |
|
5267 |
|
5268 Parameters: None |
|
5269 |
|
5270 Return Values: None |
|
5271 |
|
5272 Errors/Exceptions: Leaves if RTestExecution::Open returns error |
|
5273 Leaves if some of called leaving methods leaves |
|
5274 |
|
5275 Status: Draft |
|
5276 |
|
5277 ------------------------------------------------------------------------------- |
|
5278 */ |
|
5279 void CRebootParams::ConstructL() |
|
5280 { |
|
5281 } |
|
5282 |
|
5283 /* |
|
5284 ------------------------------------------------------------------------------- |
|
5285 |
|
5286 Class: CRebootParams |
|
5287 |
|
5288 Method: NewL |
|
5289 |
|
5290 Description: Two-phased constructor. |
|
5291 |
|
5292 Parameters: none |
|
5293 |
|
5294 Return Values: CRebootParams* : pointer to created CRebootParams object |
|
5295 |
|
5296 Errors/Exceptions: Leaves if ConstructL leaves |
|
5297 |
|
5298 Status: Draft |
|
5299 |
|
5300 ------------------------------------------------------------------------------- |
|
5301 */ |
|
5302 CRebootParams* CRebootParams::NewL() |
|
5303 { |
|
5304 |
|
5305 CRebootParams* self = new ( ELeave ) CRebootParams(); |
|
5306 CleanupStack::PushL( self ); |
|
5307 self->ConstructL(); |
|
5308 CleanupStack::Pop(); |
|
5309 return self; |
|
5310 |
|
5311 } |
|
5312 |
|
5313 /* |
|
5314 ------------------------------------------------------------------------------- |
|
5315 |
|
5316 Class: CRebootParams |
|
5317 |
|
5318 Method: ~CRebootParams |
|
5319 |
|
5320 Description: Destructor |
|
5321 |
|
5322 Parameters: None |
|
5323 |
|
5324 Return Values: None |
|
5325 |
|
5326 Errors/Exceptions: None |
|
5327 |
|
5328 Status: Draft |
|
5329 |
|
5330 ------------------------------------------------------------------------------- |
|
5331 */ |
|
5332 CRebootParams::~CRebootParams() |
|
5333 { |
|
5334 |
|
5335 delete iTestModuleBuf; |
|
5336 iTestModuleBuf = 0; |
|
5337 delete iTestCaseFileBuf; |
|
5338 iTestCaseFileBuf = 0; |
|
5339 delete iTestCaseTitleBuf; |
|
5340 iTestCaseTitleBuf = 0; |
|
5341 delete iStateNameBuf; |
|
5342 iStateNameBuf = 0; |
|
5343 |
|
5344 } |
|
5345 |
|
5346 |
|
5347 /* |
|
5348 ------------------------------------------------------------------------------- |
|
5349 |
|
5350 Class: CRebootParams |
|
5351 |
|
5352 Method: SetTestModuleNameL |
|
5353 |
|
5354 Description: Setter |
|
5355 |
|
5356 Parameters: const TDesC& aName: in: name to set |
|
5357 |
|
5358 Return Values: None |
|
5359 |
|
5360 Errors/Exceptions: Leaves if memory allocation fails |
|
5361 |
|
5362 Status: Draft |
|
5363 |
|
5364 ------------------------------------------------------------------------------- |
|
5365 */ |
|
5366 void CRebootParams::SetTestModuleNameL( const TDesC& aName ) |
|
5367 { |
|
5368 |
|
5369 delete iTestModuleBuf; |
|
5370 iTestModuleBuf = 0; |
|
5371 iTestModuleBuf = aName.AllocLC(); |
|
5372 iTestModule.Set( iTestModuleBuf->Des() ); |
|
5373 CleanupStack::Pop( iTestModuleBuf ); |
|
5374 |
|
5375 } |
|
5376 |
|
5377 /* |
|
5378 ------------------------------------------------------------------------------- |
|
5379 |
|
5380 Class: CRebootParams |
|
5381 |
|
5382 Method: SetTestModuleNameL |
|
5383 |
|
5384 Description: Setter |
|
5385 |
|
5386 Parameters: const TDesC& aName: in: name to set |
|
5387 |
|
5388 Return Values: None |
|
5389 |
|
5390 Errors/Exceptions: Leaves if memory allocation fails |
|
5391 |
|
5392 Status: Draft |
|
5393 |
|
5394 ------------------------------------------------------------------------------- |
|
5395 */ |
|
5396 void CRebootParams::SetTestCaseFileNameL( const TDesC& aName ) |
|
5397 { |
|
5398 |
|
5399 delete iTestCaseFileBuf; |
|
5400 iTestCaseFileBuf = 0; |
|
5401 iTestCaseFileBuf = aName.AllocLC(); |
|
5402 iTestCaseFile.Set( iTestCaseFileBuf->Des() ); |
|
5403 CleanupStack::Pop( iTestCaseFileBuf ); |
|
5404 |
|
5405 } |
|
5406 |
|
5407 /* |
|
5408 ------------------------------------------------------------------------------- |
|
5409 |
|
5410 Class: CRebootParams |
|
5411 |
|
5412 Method: SetTestModuleNameL |
|
5413 |
|
5414 Description: Setter |
|
5415 |
|
5416 Parameters: const TDesC& aName: in: name to set |
|
5417 |
|
5418 Return Values: None |
|
5419 |
|
5420 Errors/Exceptions: Leaves if memory allocation fails |
|
5421 |
|
5422 Status: Draft |
|
5423 |
|
5424 ------------------------------------------------------------------------------- |
|
5425 */ |
|
5426 void CRebootParams::SetTestCaseTitleL( const TDesC& aName ) |
|
5427 { |
|
5428 |
|
5429 delete iTestCaseTitleBuf; |
|
5430 iTestCaseTitleBuf = 0; |
|
5431 iTestCaseTitleBuf = aName.AllocLC(); |
|
5432 iTestCaseTitle.Set( iTestCaseTitleBuf->Des() ); |
|
5433 CleanupStack::Pop( iTestCaseTitleBuf ); |
|
5434 |
|
5435 } |
|
5436 |
|
5437 /* |
|
5438 ------------------------------------------------------------------------------- |
|
5439 |
|
5440 Class: CRebootParams |
|
5441 |
|
5442 Method: SetTestModuleNameL |
|
5443 |
|
5444 Description: Setter |
|
5445 |
|
5446 Parameters: const TDesC& aName: in: name to set |
|
5447 |
|
5448 Return Values: None |
|
5449 |
|
5450 Errors/Exceptions: Leaves if memory allocation fails |
|
5451 |
|
5452 Status: Draft |
|
5453 |
|
5454 ------------------------------------------------------------------------------- |
|
5455 */ |
|
5456 void CRebootParams::SetTestCaseStateL( const TDesC& aName ) |
|
5457 { |
|
5458 |
|
5459 delete iStateNameBuf; |
|
5460 iStateNameBuf = 0; |
|
5461 iStateNameBuf = aName.AllocLC(); |
|
5462 iStateName.Set( iStateNameBuf->Des() ); |
|
5463 CleanupStack::Pop( iStateNameBuf ); |
|
5464 |
|
5465 } |
|
5466 |
|
5467 |
|
5468 /* |
|
5469 ------------------------------------------------------------------------------- |
|
5470 |
|
5471 DESCRIPTION |
|
5472 |
|
5473 This module contains implementation of TEventMsg class member functions. |
|
5474 |
|
5475 ------------------------------------------------------------------------------- |
|
5476 */ |
|
5477 |
|
5478 // ================= MEMBER FUNCTIONS ========================================= |
|
5479 |
|
5480 /* |
|
5481 ------------------------------------------------------------------------------- |
|
5482 |
|
5483 Class: TEventMsg |
|
5484 |
|
5485 Method: TEventMsg |
|
5486 |
|
5487 Description: Default constructor |
|
5488 |
|
5489 Parameters: None |
|
5490 |
|
5491 Return Values: None |
|
5492 |
|
5493 Errors/Exceptions: None |
|
5494 |
|
5495 Status: Proposal |
|
5496 |
|
5497 ------------------------------------------------------------------------------- |
|
5498 */ |
|
5499 TEventMsg::TEventMsg(): |
|
5500 TEventIf(), |
|
5501 iWaitPending(EFalse), |
|
5502 iStateEventPending(EFalse), |
|
5503 iStatus( NULL ) |
|
5504 { |
|
5505 } |
|
5506 |
|
5507 /* |
|
5508 ------------------------------------------------------------------------------- |
|
5509 |
|
5510 Class: TEventMsg |
|
5511 |
|
5512 Method: ~TEventMsg |
|
5513 |
|
5514 Description: Destructor |
|
5515 |
|
5516 Parameters: None |
|
5517 |
|
5518 Return Values: None |
|
5519 |
|
5520 Errors/Exceptions: None |
|
5521 |
|
5522 Status: Proposal |
|
5523 |
|
5524 ------------------------------------------------------------------------------- |
|
5525 */ |
|
5526 TEventMsg::~TEventMsg() |
|
5527 { |
|
5528 if( iWaitPending ) |
|
5529 { |
|
5530 iWaitMsg.Complete( KErrCancel ); |
|
5531 iWaitPending = EFalse; |
|
5532 } |
|
5533 |
|
5534 if( iStatus ) |
|
5535 { |
|
5536 User::RequestComplete( iStatus, KErrCancel ); |
|
5537 } |
|
5538 |
|
5539 } |
|
5540 |
|
5541 /* |
|
5542 ------------------------------------------------------------------------------- |
|
5543 |
|
5544 Class: TEventMsg |
|
5545 |
|
5546 Method: Set |
|
5547 |
|
5548 Description: Set event. |
|
5549 |
|
5550 Parameters: TEventType aEventType: in: Event type |
|
5551 |
|
5552 Return Values: None |
|
5553 |
|
5554 Errors/Exceptions: None |
|
5555 |
|
5556 Status: Proposal |
|
5557 |
|
5558 ------------------------------------------------------------------------------- |
|
5559 */ |
|
5560 void TEventMsg::Set( TEventType aEventType ) |
|
5561 { |
|
5562 iEventType = aEventType; |
|
5563 if( aEventType == EState ) |
|
5564 { |
|
5565 iStateEventPending = ETrue; |
|
5566 } |
|
5567 if( iWaitPending ) |
|
5568 { |
|
5569 TEventIf event; |
|
5570 event.Copy( *this ); |
|
5571 TEventIfPckg eventIfPckg( event ); |
|
5572 iWaitMsg.WriteL( 0, eventIfPckg ); |
|
5573 |
|
5574 iWaitMsg.Complete( KErrNone ); |
|
5575 iWaitPending = EFalse; |
|
5576 } |
|
5577 } |
|
5578 |
|
5579 /* |
|
5580 ------------------------------------------------------------------------------- |
|
5581 |
|
5582 Class: TEventMsg |
|
5583 |
|
5584 Method: Wait |
|
5585 |
|
5586 Description: Wait event. |
|
5587 |
|
5588 Parameters: const RMessage& aMessage: in: Message |
|
5589 |
|
5590 Return Values: None |
|
5591 |
|
5592 Errors/Exceptions: None |
|
5593 |
|
5594 Status: Proposal |
|
5595 |
|
5596 ------------------------------------------------------------------------------- |
|
5597 */ |
|
5598 void TEventMsg::Wait( const RMessage2& aMessage ) |
|
5599 { |
|
5600 if( iStateEventPending ) |
|
5601 { |
|
5602 TEventIf event; |
|
5603 event.Copy( *this ); |
|
5604 TEventIfPckg eventIfPckg( event ); |
|
5605 aMessage.WriteL( 0, eventIfPckg ); |
|
5606 aMessage.Complete( KErrNone ); |
|
5607 } |
|
5608 else |
|
5609 { |
|
5610 iWaitMsg = aMessage; |
|
5611 iWaitPending = ETrue; |
|
5612 } |
|
5613 } |
|
5614 |
|
5615 /* |
|
5616 ------------------------------------------------------------------------------- |
|
5617 |
|
5618 Class: TEventMsg |
|
5619 |
|
5620 Method: CancelWait |
|
5621 |
|
5622 Description: Cancel pending Wait |
|
5623 |
|
5624 Parameters: None |
|
5625 |
|
5626 Return Values: None |
|
5627 |
|
5628 Errors/Exceptions: None |
|
5629 |
|
5630 Status: Proposal |
|
5631 |
|
5632 ------------------------------------------------------------------------------- |
|
5633 */ |
|
5634 void TEventMsg::CancelWait() |
|
5635 { |
|
5636 if( iWaitPending ) |
|
5637 { |
|
5638 iWaitMsg.Complete( KErrCancel ); |
|
5639 iWaitPending = EFalse; |
|
5640 } |
|
5641 } |
|
5642 |
|
5643 /* |
|
5644 ------------------------------------------------------------------------------- |
|
5645 |
|
5646 Class: TEventMsg |
|
5647 |
|
5648 Method: Release |
|
5649 |
|
5650 Description: Release event. Unset released. |
|
5651 |
|
5652 Parameters: None |
|
5653 |
|
5654 Return Values: None |
|
5655 |
|
5656 Errors/Exceptions: None |
|
5657 |
|
5658 Status: Proposal |
|
5659 |
|
5660 ------------------------------------------------------------------------------- |
|
5661 */ |
|
5662 void TEventMsg::Release() |
|
5663 { |
|
5664 |
|
5665 if( iStatus ) |
|
5666 { |
|
5667 User::RequestComplete( iStatus, KErrNone ); |
|
5668 } |
|
5669 |
|
5670 } |
|
5671 /* |
|
5672 ------------------------------------------------------------------------------- |
|
5673 |
|
5674 Class: TEventMsg |
|
5675 |
|
5676 Method: Unset |
|
5677 |
|
5678 Description: Unset event. Blocks until Release is called. |
|
5679 |
|
5680 Parameters: TRequestStatus& aStatus: in: Status |
|
5681 |
|
5682 Return Values: None |
|
5683 |
|
5684 Errors/Exceptions: None |
|
5685 |
|
5686 Status: Proposal |
|
5687 |
|
5688 ------------------------------------------------------------------------------- |
|
5689 */ |
|
5690 void TEventMsg::Unset( TRequestStatus& aStatus ) |
|
5691 { |
|
5692 |
|
5693 iStatus = &aStatus; |
|
5694 |
|
5695 } |
|
5696 |
|
5697 |
|
5698 // End of File |