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 * CTestProgressNotifier class member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "TestCombiner.h" |
|
21 #include "TestCase.h" |
|
22 #include "TestCaseNotify.h" |
|
23 #include "Logging.h" |
|
24 |
|
25 // EXTERNAL DATA STRUCTURES |
|
26 // None |
|
27 |
|
28 // EXTERNAL FUNCTION PROTOTYPES |
|
29 // None |
|
30 |
|
31 // CONSTANTS |
|
32 // None |
|
33 |
|
34 // MACROS |
|
35 #ifdef LOGGER |
|
36 #undef LOGGER |
|
37 #endif |
|
38 #define LOGGER iTestCombiner->iLog |
|
39 |
|
40 // LOCAL CONSTANTS AND MACROS |
|
41 // None |
|
42 |
|
43 // MODULE DATA STRUCTURES |
|
44 // None |
|
45 |
|
46 // LOCAL FUNCTION PROTOTYPES |
|
47 // None |
|
48 |
|
49 // FORWARD DECLARATIONS |
|
50 // None |
|
51 |
|
52 // ==================== LOCAL FUNCTIONS ======================================= |
|
53 // None |
|
54 |
|
55 // ================= MEMBER FUNCTIONS ========================================= |
|
56 |
|
57 /* |
|
58 ------------------------------------------------------------------------------- |
|
59 |
|
60 Class: CTestProgressNotifier |
|
61 |
|
62 Method: CTestProgressNotifier |
|
63 |
|
64 Description: Default constructor |
|
65 |
|
66 C++ default constructor can NOT contain any code, that |
|
67 might leave. |
|
68 |
|
69 Parameters: None |
|
70 |
|
71 Return Values: None |
|
72 |
|
73 Errors/Exceptions: None |
|
74 |
|
75 Status: Approved |
|
76 |
|
77 ------------------------------------------------------------------------------- |
|
78 */ |
|
79 CTestProgressNotifier::CTestProgressNotifier( CTestCombiner* aTestCombiner, |
|
80 CTCTestCase* aTestCase ) : |
|
81 CActive( CActive::EPriorityStandard ), |
|
82 iTestCombiner( aTestCombiner ), |
|
83 iTestCase( aTestCase ), |
|
84 iState( ETestProgressIdle ), |
|
85 iProgressPckg( iProgress ), |
|
86 iIsPrintProcessFinished( EFalse ) |
|
87 { |
|
88 CActiveScheduler::Add( this ); |
|
89 |
|
90 } |
|
91 |
|
92 /* |
|
93 ------------------------------------------------------------------------------- |
|
94 |
|
95 Class: CTestProgressNotifier |
|
96 |
|
97 Method: ConstructL |
|
98 |
|
99 Description: Symbian OS second phase constructor |
|
100 |
|
101 Symbian OS default constructor can leave. |
|
102 |
|
103 Parameters: None |
|
104 |
|
105 Return Values: None |
|
106 |
|
107 Errors/Exceptions: Leaves if StartL leaves |
|
108 |
|
109 Status: Approved |
|
110 |
|
111 ------------------------------------------------------------------------------- |
|
112 */ |
|
113 void CTestProgressNotifier::ConstructL() |
|
114 { |
|
115 StartL(); |
|
116 |
|
117 } |
|
118 |
|
119 /* |
|
120 ------------------------------------------------------------------------------- |
|
121 |
|
122 Class: CTestProgressNotifier |
|
123 |
|
124 Method: NewL |
|
125 |
|
126 Description: Two-phased constructor. |
|
127 |
|
128 Parameters: CTestCombiner* aTestCombiner: in: Backpointer to TestCombiner |
|
129 CTCTestCase* aTestCase: in: Pointer to used CTCTestCase |
|
130 |
|
131 Return Values: CTestProgressNotifier* : pointer to created object |
|
132 |
|
133 Errors/Exceptions: Leaves if ConstructL leaves or memory allocation fails |
|
134 |
|
135 Status: Approved |
|
136 |
|
137 ------------------------------------------------------------------------------- |
|
138 */ |
|
139 CTestProgressNotifier* CTestProgressNotifier::NewL( CTestCombiner* aTestCombiner, |
|
140 CTCTestCase* aTestCase ) |
|
141 { |
|
142 CTestProgressNotifier* self = |
|
143 new ( ELeave ) CTestProgressNotifier( aTestCombiner, aTestCase ); |
|
144 CleanupStack::PushL( self ); |
|
145 self->ConstructL(); |
|
146 CleanupStack::Pop( self ); |
|
147 return self; |
|
148 |
|
149 } |
|
150 |
|
151 /* |
|
152 ------------------------------------------------------------------------------- |
|
153 |
|
154 Class: CTestProgressNotifier |
|
155 |
|
156 Method: ~CTestProgressNotifier |
|
157 |
|
158 Description: Destructor |
|
159 |
|
160 Parameters: None |
|
161 |
|
162 Return Values: None |
|
163 |
|
164 Errors/Exceptions: None |
|
165 |
|
166 Status: Approved |
|
167 |
|
168 ------------------------------------------------------------------------------- |
|
169 */ |
|
170 CTestProgressNotifier::~CTestProgressNotifier() |
|
171 { |
|
172 __TRACE( KMessage, ( _L("~CTestProgressNotifier") )); |
|
173 Cancel(); |
|
174 |
|
175 } |
|
176 |
|
177 /* |
|
178 ------------------------------------------------------------------------------- |
|
179 |
|
180 Class: CTestProgressNotifier |
|
181 |
|
182 Method: StartL |
|
183 |
|
184 Description: Start ProgressNotifier |
|
185 |
|
186 Parameters: None |
|
187 |
|
188 Return Values: None |
|
189 |
|
190 Errors/Exceptions: Leaves if allready pending |
|
191 |
|
192 Status: Approved |
|
193 |
|
194 ------------------------------------------------------------------------------- |
|
195 */ |
|
196 void CTestProgressNotifier::StartL() |
|
197 { |
|
198 // Check that this request is not pending!! |
|
199 if( iState == ETestProgressPending ) |
|
200 { |
|
201 User::Leave( KErrGeneral ); |
|
202 } |
|
203 |
|
204 iState = ETestProgressPending; |
|
205 iTestCase->TestExecution().NotifyProgress( iProgressPckg, iStatus ); |
|
206 SetActive(); |
|
207 |
|
208 } |
|
209 |
|
210 /* |
|
211 ------------------------------------------------------------------------------- |
|
212 |
|
213 Class: CTestProgressNotifier |
|
214 |
|
215 Method: RunL |
|
216 |
|
217 Description: RunL handles completed requests. |
|
218 |
|
219 Parameters: None |
|
220 |
|
221 Return Values: None |
|
222 |
|
223 Errors/Exceptions: None |
|
224 |
|
225 Status: Approved |
|
226 |
|
227 ------------------------------------------------------------------------------- |
|
228 */ |
|
229 void CTestProgressNotifier::RunL() |
|
230 { |
|
231 |
|
232 iState = ETestProgressCompleted; |
|
233 |
|
234 // Check that request was successful or completed with acceptable error |
|
235 // KErrEof is acceptable error and it means that the test case will not |
|
236 // send progresses anymore (because it is closed) |
|
237 if ( KErrNone == iStatus.Int() ) |
|
238 { |
|
239 TStifInfoName desc( iProgress.iDescription ); |
|
240 |
|
241 // Append testid if possible |
|
242 if( ( iTestCase->TestId().Length() > 0 ) && |
|
243 ( desc.MaxLength() > |
|
244 ( desc.Length() + iTestCase->TestId().Length() + 1 ) ) ) |
|
245 { |
|
246 desc.Append( _L("_") ); |
|
247 desc.Append( iTestCase->TestId() ); |
|
248 } |
|
249 // Append module name if possible |
|
250 else if( desc.MaxLength() > |
|
251 ( desc.Length() + iTestCase->ModuleName().Length() + 1 ) ) |
|
252 { |
|
253 desc.Append( _L("_") ); |
|
254 desc.Append( iTestCase->ModuleName() ); |
|
255 } |
|
256 |
|
257 // Forward printing to engine |
|
258 iTestCombiner->TestModuleIf().Printf( iProgress.iPosition, |
|
259 desc, |
|
260 iProgress.iText ); |
|
261 |
|
262 // Set request pending again |
|
263 StartL(); |
|
264 } |
|
265 else if ( KErrEof != iStatus.Int() ) |
|
266 { |
|
267 // Leave, error will be handled in RunError |
|
268 User::Leave( iStatus.Int() ); |
|
269 } |
|
270 |
|
271 if( KErrEof == iStatus.Int() ) |
|
272 { |
|
273 // KErrEof indicates that all print process to UI is completed. |
|
274 iIsPrintProcessFinished = ETrue; |
|
275 if(iTestCase->State() == CTestCase::ETestCaseCompleted ) |
|
276 { |
|
277 // Test case is completed so do final complete. |
|
278 iTestCase->Complete2(); |
|
279 } |
|
280 |
|
281 } |
|
282 |
|
283 } |
|
284 |
|
285 |
|
286 /* |
|
287 ------------------------------------------------------------------------------- |
|
288 |
|
289 Class: CTestProgressNotifier |
|
290 |
|
291 Method: DoCancel |
|
292 |
|
293 Description: Cancel active request |
|
294 |
|
295 Parameters: None |
|
296 |
|
297 Return Values: None |
|
298 |
|
299 Errors/Exceptions: None |
|
300 |
|
301 Status: Approved |
|
302 |
|
303 ------------------------------------------------------------------------------- |
|
304 */ |
|
305 void CTestProgressNotifier::DoCancel() |
|
306 { |
|
307 switch ( iState ) |
|
308 { |
|
309 case ETestProgressPending: |
|
310 iTestCase->TestExecution().CancelAsyncRequest( ETestExecutionNotifyProgress ); |
|
311 break; |
|
312 case ETestProgressIdle: |
|
313 case ETestProgressCompleted: |
|
314 default: |
|
315 // DoCancel called in wrong state => Panic |
|
316 _LIT( KTestProgressNotifier, "CTestProgressNotifier" ); |
|
317 User::Panic( KTestProgressNotifier, KErrGeneral ); |
|
318 break; |
|
319 } |
|
320 iState = ETestProgressIdle; |
|
321 |
|
322 } |
|
323 |
|
324 |
|
325 /* |
|
326 ------------------------------------------------------------------------------- |
|
327 |
|
328 Class: CTestProgressNotifier |
|
329 |
|
330 Method: RunError |
|
331 |
|
332 Description: Handle errors. Should newer come here so we return error. |
|
333 |
|
334 Parameters: TInt aError: in: Symbian OS error: Error code |
|
335 |
|
336 Return Values: Symbian OS error value |
|
337 |
|
338 Errors/Exceptions: None |
|
339 |
|
340 Status: Approved |
|
341 |
|
342 ------------------------------------------------------------------------------- |
|
343 */ |
|
344 TInt CTestProgressNotifier::RunError( TInt aError ) |
|
345 { |
|
346 return aError; |
|
347 |
|
348 } |
|
349 |
|
350 /* |
|
351 ------------------------------------------------------------------------------- |
|
352 |
|
353 Class: CTestProgressNotifier |
|
354 |
|
355 Method: IsPrintProgressFinished |
|
356 |
|
357 Description: Indicates is print process to UI finished |
|
358 |
|
359 Parameters: None |
|
360 |
|
361 Return Values: TBool: ETrue indicates that print process is finished, |
|
362 EFalse indicates that print process is not finished |
|
363 |
|
364 Errors/Exceptions: None |
|
365 |
|
366 Status: Proposal |
|
367 |
|
368 ------------------------------------------------------------------------------- |
|
369 */ |
|
370 TBool CTestProgressNotifier::IsPrintProgressFinished() |
|
371 { |
|
372 return iIsPrintProcessFinished; |
|
373 |
|
374 } |
|
375 |
|
376 /* |
|
377 ------------------------------------------------------------------------------- |
|
378 |
|
379 DESCRIPTION |
|
380 |
|
381 This module contains implementation of CTestErrorNotifier class member |
|
382 functions. |
|
383 |
|
384 ------------------------------------------------------------------------------- |
|
385 */ |
|
386 |
|
387 // ================= MEMBER FUNCTIONS ========================================= |
|
388 |
|
389 /* |
|
390 ------------------------------------------------------------------------------- |
|
391 |
|
392 Class: CTestErrorNotifier |
|
393 |
|
394 Method: CTestErrorNotifier |
|
395 |
|
396 Description: Default constructor |
|
397 |
|
398 C++ default constructor can NOT contain any code, that |
|
399 might leave. |
|
400 |
|
401 Parameters: None |
|
402 |
|
403 Return Values: None |
|
404 |
|
405 Errors/Exceptions: None |
|
406 |
|
407 Status: Approved |
|
408 |
|
409 ------------------------------------------------------------------------------- |
|
410 */ |
|
411 CTestErrorNotifier::CTestErrorNotifier( CTestCombiner* aTestCombiner, |
|
412 CTCTestModule* aTestModule ) : |
|
413 CActive( CActive::EPriorityStandard ), |
|
414 iTestCombiner( aTestCombiner ), |
|
415 iTestModule( aTestModule ), |
|
416 iState( ETestErrorIdle ), |
|
417 iErrorPckg( iError ) |
|
418 { |
|
419 CActiveScheduler::Add( this ); |
|
420 |
|
421 } |
|
422 |
|
423 /* |
|
424 ------------------------------------------------------------------------------- |
|
425 |
|
426 Class: CTestErrorNotifier |
|
427 |
|
428 Method: ConstructL |
|
429 |
|
430 Description: Symbian OS second phase constructor |
|
431 |
|
432 Symbian OS default constructor can leave. |
|
433 |
|
434 Parameters: None |
|
435 |
|
436 Return Values: None |
|
437 |
|
438 Errors/Exceptions: Leaves if StartL leaves |
|
439 |
|
440 Status: Approved |
|
441 |
|
442 ------------------------------------------------------------------------------- |
|
443 */ |
|
444 void CTestErrorNotifier::ConstructL() |
|
445 { |
|
446 StartL(); |
|
447 |
|
448 } |
|
449 |
|
450 /* |
|
451 ------------------------------------------------------------------------------- |
|
452 |
|
453 Class: CTestErrorNotifier |
|
454 |
|
455 Method: NewL |
|
456 |
|
457 Description: Two-phased constructor. |
|
458 |
|
459 Parameters: CTestCombiner* aTestCombiner: in: Backpointer to TestCombiner |
|
460 CTCTestModule* aTestModule: in: Pointer to used CTCTestModule |
|
461 |
|
462 Return Values: CTestErrorNotifier* : pointer to created object |
|
463 |
|
464 Errors/Exceptions: Leaves if ConstructL leaves or memory allocation fails |
|
465 |
|
466 Status: Approved |
|
467 |
|
468 ------------------------------------------------------------------------------- |
|
469 */ |
|
470 CTestErrorNotifier* CTestErrorNotifier::NewL( CTestCombiner* aTestCombiner, |
|
471 CTCTestModule* aTestModule ) |
|
472 { |
|
473 CTestErrorNotifier* self = |
|
474 new ( ELeave ) CTestErrorNotifier( aTestCombiner, aTestModule ); |
|
475 CleanupStack::PushL( self ); |
|
476 self->ConstructL(); |
|
477 CleanupStack::Pop( self ); |
|
478 return self; |
|
479 |
|
480 } |
|
481 |
|
482 /* |
|
483 ------------------------------------------------------------------------------- |
|
484 |
|
485 Class: CTestErrorNotifier |
|
486 |
|
487 Method: ~CTestErrorNotifier |
|
488 |
|
489 Description: Destructor |
|
490 |
|
491 Parameters: None |
|
492 |
|
493 Return Values: None |
|
494 |
|
495 Errors/Exceptions: None |
|
496 |
|
497 Status: Approved |
|
498 |
|
499 ------------------------------------------------------------------------------- |
|
500 */ |
|
501 CTestErrorNotifier::~CTestErrorNotifier() |
|
502 { |
|
503 __TRACE( KMessage, ( _L("~CTestErrorNotifier") )); |
|
504 Cancel(); |
|
505 |
|
506 } |
|
507 |
|
508 /* |
|
509 ------------------------------------------------------------------------------- |
|
510 |
|
511 Class: CTestErrorNotifier |
|
512 |
|
513 Method: StartL |
|
514 |
|
515 Description: Start ProgressNotifier |
|
516 |
|
517 Parameters: None |
|
518 |
|
519 Return Values: None |
|
520 |
|
521 Errors/Exceptions: Leaves if allready pending |
|
522 |
|
523 Status: Approved |
|
524 |
|
525 ------------------------------------------------------------------------------- |
|
526 */ |
|
527 void CTestErrorNotifier::StartL() |
|
528 { |
|
529 // Check that this request is not pending!! |
|
530 if( iState == ETestErrorPending ) |
|
531 { |
|
532 User::Leave( KErrGeneral ); |
|
533 } |
|
534 |
|
535 iState = ETestErrorPending; |
|
536 iTestModule->TestModule().ErrorNotification( iErrorPckg, iStatus ); |
|
537 SetActive(); |
|
538 |
|
539 } |
|
540 |
|
541 /* |
|
542 ------------------------------------------------------------------------------- |
|
543 |
|
544 Class: CTestErrorNotifier |
|
545 |
|
546 Method: RunL |
|
547 |
|
548 Description: RunL handles completed requests. |
|
549 |
|
550 Parameters: None |
|
551 |
|
552 Return Values: None |
|
553 |
|
554 Errors/Exceptions: None |
|
555 |
|
556 Status: Approved |
|
557 |
|
558 ------------------------------------------------------------------------------- |
|
559 */ |
|
560 void CTestErrorNotifier::RunL() |
|
561 { |
|
562 |
|
563 iState = ETestErrorCompleted; |
|
564 |
|
565 // Check that request was successful or completed with acceptable error |
|
566 // KErrEof is acceptable error and it means that the test case will not |
|
567 // send progresses anymore (because it is closed) |
|
568 if ( KErrNone == iStatus.Int() ) |
|
569 { |
|
570 |
|
571 // Forward printing to engine |
|
572 iTestCombiner->TestModuleIf().Printf( iError.iPriority, |
|
573 iError.iModule, |
|
574 iError.iText ); |
|
575 |
|
576 // Set request pending again |
|
577 StartL(); |
|
578 } |
|
579 else if ( KErrEof != iStatus.Int() ) |
|
580 { |
|
581 // Leave, error will be handled in RunError |
|
582 User::Leave( iStatus.Int() ); |
|
583 } |
|
584 |
|
585 } |
|
586 |
|
587 |
|
588 /* |
|
589 ------------------------------------------------------------------------------- |
|
590 |
|
591 Class: CTestErrorNotifier |
|
592 |
|
593 Method: DoCancel |
|
594 |
|
595 Description: Cancel active request |
|
596 |
|
597 Parameters: None |
|
598 |
|
599 Return Values: None |
|
600 |
|
601 Errors/Exceptions: None |
|
602 |
|
603 Status: Approved |
|
604 |
|
605 ------------------------------------------------------------------------------- |
|
606 */ |
|
607 void CTestErrorNotifier::DoCancel() |
|
608 { |
|
609 switch ( iState ) |
|
610 { |
|
611 case ETestErrorPending: |
|
612 iTestModule->TestModule().CancelAsyncRequest( ETestModuleErrorNotification ); |
|
613 break; |
|
614 case ETestErrorIdle: |
|
615 case ETestErrorCompleted: |
|
616 default: |
|
617 // DoCancel called in wrong state => Panic |
|
618 _LIT( KTestErrorNotifier, "CTestErrorNotifier" ); |
|
619 User::Panic( KTestErrorNotifier, KErrGeneral ); |
|
620 break; |
|
621 } |
|
622 iState = ETestErrorIdle; |
|
623 |
|
624 } |
|
625 |
|
626 |
|
627 /* |
|
628 ------------------------------------------------------------------------------- |
|
629 |
|
630 Class: CTestErrorNotifier |
|
631 |
|
632 Method: RunError |
|
633 |
|
634 Description: Handle errors. Should newer come here so we return error. |
|
635 |
|
636 Parameters: TInt aError: in: Symbian OS error: Error code |
|
637 |
|
638 Return Values: Symbian OS error value |
|
639 |
|
640 Errors/Exceptions: None |
|
641 |
|
642 Status: Approved |
|
643 |
|
644 ------------------------------------------------------------------------------- |
|
645 */ |
|
646 TInt CTestErrorNotifier::RunError( TInt /*aError*/ ) |
|
647 { |
|
648 |
|
649 // Ignore error, stop error note forwarding |
|
650 return KErrNone; |
|
651 |
|
652 } |
|
653 |
|
654 |
|
655 /* |
|
656 ------------------------------------------------------------------------------- |
|
657 |
|
658 DESCRIPTION |
|
659 |
|
660 This module contains implementation of CTestEventNotify class member |
|
661 functions. Handles requested events from test modules below. |
|
662 |
|
663 ------------------------------------------------------------------------------- |
|
664 */ |
|
665 |
|
666 // ================= MEMBER FUNCTIONS ========================================= |
|
667 |
|
668 |
|
669 /* |
|
670 ------------------------------------------------------------------------------- |
|
671 |
|
672 Class: CTestEventNotify |
|
673 |
|
674 Method: CTestEventNotify |
|
675 |
|
676 Description: Default constructor |
|
677 |
|
678 C++ default constructor can NOT contain any code, that |
|
679 might leave. |
|
680 |
|
681 Parameters: CTestCombiner* aTestCombiner: in: Backpointer to TestCombiner |
|
682 CTCTestCase* aTestCase: in: Pointer to used CTCTestCase |
|
683 |
|
684 Return Values: None |
|
685 |
|
686 Errors/Exceptions: None |
|
687 |
|
688 Status: Proposal |
|
689 |
|
690 ------------------------------------------------------------------------------- |
|
691 */ |
|
692 CTestEventNotify::CTestEventNotify( CTestCombiner* aTestCombiner, |
|
693 CTCTestCase* aTestCase ) : |
|
694 CActive( CActive::EPriorityStandard ), |
|
695 iTestCombiner( aTestCombiner ), |
|
696 iTestCase( aTestCase ), |
|
697 iState( ETestEventNotifyIdle ), |
|
698 iEventPckg( iEvent ) |
|
699 { |
|
700 CActiveScheduler::Add( this ); |
|
701 |
|
702 } |
|
703 |
|
704 /* |
|
705 ------------------------------------------------------------------------------- |
|
706 |
|
707 Class: CTestEventNotify |
|
708 |
|
709 Method: ConstructL |
|
710 |
|
711 Description: Symbian OS second phase constructor |
|
712 |
|
713 Symbian OS default constructor can leave. |
|
714 |
|
715 Parameters: None |
|
716 |
|
717 Return Values: None |
|
718 |
|
719 Errors/Exceptions: None |
|
720 |
|
721 Status: Proposal |
|
722 |
|
723 ------------------------------------------------------------------------------- |
|
724 */ |
|
725 void CTestEventNotify::ConstructL( TEventIf& aEvent ) |
|
726 { |
|
727 iEvent.Copy( aEvent ); |
|
728 |
|
729 iEvent.SetType( TEventIf::EWaitEvent ); |
|
730 iState = ETestEventNotifyPending; |
|
731 iTestCombiner->TestModuleIf().Event( iEvent, iStatus ); |
|
732 SetActive(); |
|
733 |
|
734 } |
|
735 |
|
736 /* |
|
737 ------------------------------------------------------------------------------- |
|
738 |
|
739 Class: CTestEventNotify |
|
740 |
|
741 Method: NewL |
|
742 |
|
743 Description: Two-phased constructor. |
|
744 |
|
745 Parameters: CTestCombiner* aTestCombiner: in: Backpointer to TestCombiner |
|
746 CTCTestCase* aTestCase: in: Pointer to used CTCTestCase |
|
747 |
|
748 Return Values: CTestEventNotify* : pointer to created object |
|
749 |
|
750 Errors/Exceptions: Leaves if ConstructL leaves or memory allocation fails |
|
751 |
|
752 Status: Proposal |
|
753 |
|
754 ------------------------------------------------------------------------------- |
|
755 */ |
|
756 CTestEventNotify* CTestEventNotify::NewL( CTestCombiner* aTestCombiner, |
|
757 CTCTestCase* aTestCase, |
|
758 TEventIf& aEvent ) |
|
759 { |
|
760 CTestEventNotify* self = |
|
761 new ( ELeave ) CTestEventNotify( aTestCombiner, aTestCase ); |
|
762 CleanupStack::PushL( self ); |
|
763 self->ConstructL( aEvent ); |
|
764 CleanupStack::Pop( self ); |
|
765 return self; |
|
766 } |
|
767 |
|
768 /* |
|
769 ------------------------------------------------------------------------------- |
|
770 |
|
771 Class: CTestEventNotify |
|
772 |
|
773 Method: ~CTestEventNotify |
|
774 |
|
775 Description: Destructor |
|
776 |
|
777 Parameters: None |
|
778 |
|
779 Return Values: None |
|
780 |
|
781 Errors/Exceptions: None |
|
782 |
|
783 Status: Proposal |
|
784 |
|
785 ------------------------------------------------------------------------------- |
|
786 */ |
|
787 CTestEventNotify::~CTestEventNotify() |
|
788 { |
|
789 __TRACE( KMessage, ( _L("~CTestEventNotify") )); |
|
790 |
|
791 Cancel(); |
|
792 |
|
793 } |
|
794 |
|
795 /* |
|
796 ------------------------------------------------------------------------------- |
|
797 |
|
798 Class: CTestEventNotify |
|
799 |
|
800 Method: RunL |
|
801 |
|
802 Description: Handles completed event wait |
|
803 |
|
804 Parameters: None |
|
805 |
|
806 Return Values: None |
|
807 |
|
808 Errors/Exceptions: Leaves on error. |
|
809 |
|
810 Status: Proposal |
|
811 |
|
812 ------------------------------------------------------------------------------- |
|
813 */ |
|
814 |
|
815 void CTestEventNotify::RunL() |
|
816 { |
|
817 __TRACE( KMessage, ( _L("CTestEventNotify::RunL(%d): %d, %d"), |
|
818 this, iStatus.Int(), iState ) ); |
|
819 User::LeaveIfError( iStatus.Int() ); |
|
820 |
|
821 switch( iState ) |
|
822 { |
|
823 case ETestEventNotifyPending: |
|
824 { |
|
825 // Forward event set/unset |
|
826 iEvent.SetType( TEventIf::ESetEvent ); |
|
827 iState = ETestEventNotifyCompleted; |
|
828 User::LeaveIfError( |
|
829 iTestCase->TestExecution().NotifyEvent( iEventPckg, iStatus ) ); |
|
830 SetActive(); |
|
831 } |
|
832 break; |
|
833 case ETestEventNotifyCompleted: |
|
834 // Enable wait again |
|
835 iEvent.SetType( TEventIf::ESetWaitPending ); |
|
836 iState = ETestEventNotifyPending; |
|
837 iTestCombiner->TestModuleIf().Event( iEvent, iStatus ); |
|
838 SetActive(); |
|
839 break; |
|
840 default: |
|
841 User::LeaveIfError( KErrGeneral ); |
|
842 break; |
|
843 } |
|
844 __TRACE( KMessage, ( _L("CTestEventNotify::RunL(%d) done: %d"), |
|
845 this, iState ) ); |
|
846 |
|
847 } |
|
848 |
|
849 /* |
|
850 ------------------------------------------------------------------------------- |
|
851 |
|
852 Class: CTestEventNotify |
|
853 |
|
854 Method: DoCancel |
|
855 |
|
856 Description: Handle Cancel |
|
857 |
|
858 Parameters: None |
|
859 |
|
860 Return Values: None |
|
861 |
|
862 Errors/Exceptions: None |
|
863 |
|
864 Status: Proposal |
|
865 |
|
866 ------------------------------------------------------------------------------- |
|
867 */ |
|
868 |
|
869 void CTestEventNotify::DoCancel() |
|
870 { |
|
871 __TRACE( KMessage, ( _L("CTestEventNotify::DoCancel"))); |
|
872 |
|
873 _LIT( KTestEventNotify, "CTestEventNotify" ); |
|
874 switch ( iState ) |
|
875 { |
|
876 case ETestEventNotifyPending: |
|
877 { |
|
878 TInt ret = |
|
879 iTestCombiner->TestModuleIf().CancelEvent( iEvent, &iStatus ); |
|
880 if( ret != KErrNone ) |
|
881 { |
|
882 __TRACE( KMessage, ( _L("CTestEventNotify::DoCancel(%d) not pending: %d"), |
|
883 this, ret ) ); |
|
884 } |
|
885 } |
|
886 break; |
|
887 case ETestEventNotifyCompleted: |
|
888 iTestCase->TestExecution(). |
|
889 CancelAsyncRequest( ETestExecutionNotifyEvent ); |
|
890 break; |
|
891 case ETestEventNotifyIdle: |
|
892 default: |
|
893 // DoCancel called in wrong state => Panic |
|
894 User::Panic( KTestEventNotify, KErrGeneral ); |
|
895 break; |
|
896 } |
|
897 |
|
898 iState = ETestEventNotifyIdle; |
|
899 |
|
900 } |
|
901 |
|
902 /* |
|
903 ------------------------------------------------------------------------------- |
|
904 |
|
905 Class: CTestEventNotify |
|
906 |
|
907 Method: RunError |
|
908 |
|
909 Description: Handle error. Should newer come here so we return error. |
|
910 |
|
911 Parameters: TInt aError: in: error from CActive |
|
912 |
|
913 Return Values: Symbian OS error value |
|
914 |
|
915 Errors/Exceptions: None |
|
916 |
|
917 Status: Proposal |
|
918 |
|
919 ------------------------------------------------------------------------------- |
|
920 */ |
|
921 |
|
922 TInt CTestEventNotify::RunError( TInt aError ) |
|
923 { |
|
924 __TRACE( KMessage, ( _L("CTestEventNotify::RunError"))); |
|
925 |
|
926 return aError; |
|
927 |
|
928 } |
|
929 |
|
930 /* |
|
931 ------------------------------------------------------------------------------- |
|
932 |
|
933 DESCRIPTION |
|
934 |
|
935 This module contains implementation of CTestEventNotifier class member |
|
936 functions. |
|
937 |
|
938 ------------------------------------------------------------------------------- |
|
939 */ |
|
940 |
|
941 // ================= MEMBER FUNCTIONS ========================================= |
|
942 |
|
943 |
|
944 /* |
|
945 ------------------------------------------------------------------------------- |
|
946 |
|
947 Class: CTestEventNotifier |
|
948 |
|
949 Method: CTestEventNotifier |
|
950 |
|
951 Description: Default constructor |
|
952 |
|
953 C++ default constructor can NOT contain any code, that |
|
954 might leave. |
|
955 |
|
956 Parameters: CTestCombiner* aTestCombiner: in: Backpointer to TestCombiner |
|
957 CTCTestCase* aTestCase: in: Pointer to used CTCTestCase |
|
958 |
|
959 Return Values: None |
|
960 |
|
961 Errors/Exceptions: None |
|
962 |
|
963 Status: Approved |
|
964 |
|
965 ------------------------------------------------------------------------------- |
|
966 */ |
|
967 CTestEventNotifier::CTestEventNotifier( CTestCombiner* aTestCombiner, |
|
968 CTCTestCase* aTestCase ) : |
|
969 CActive( CActive::EPriorityStandard ), |
|
970 iTestCombiner( aTestCombiner ), |
|
971 iTestCase( aTestCase ), |
|
972 iState( ETestEventIdle ), |
|
973 iEventPckg( iEvent ) |
|
974 { |
|
975 CActiveScheduler::Add( this ); |
|
976 |
|
977 } |
|
978 |
|
979 /* |
|
980 ------------------------------------------------------------------------------- |
|
981 |
|
982 Class: CTestEventNotifier |
|
983 |
|
984 Method: ConstructL |
|
985 |
|
986 Description: Symbian OS second phase constructor |
|
987 |
|
988 Symbian OS default constructor can leave. |
|
989 |
|
990 Parameters: None |
|
991 |
|
992 Return Values: None |
|
993 |
|
994 Errors/Exceptions: None |
|
995 |
|
996 Status: Approved |
|
997 |
|
998 ------------------------------------------------------------------------------- |
|
999 */ |
|
1000 void CTestEventNotifier::ConstructL( ) |
|
1001 { |
|
1002 StartL(); |
|
1003 |
|
1004 } |
|
1005 |
|
1006 /* |
|
1007 ------------------------------------------------------------------------------- |
|
1008 |
|
1009 Class: CTestEventNotifier |
|
1010 |
|
1011 Method: NewL |
|
1012 |
|
1013 Description: Two-phased constructor. |
|
1014 |
|
1015 Parameters: CTestCombiner* aTestCombiner: in: Backpointer to TestCombiner |
|
1016 CTCTestCase* aTestCase: in: Pointer to used CTCTestCase |
|
1017 |
|
1018 Return Values: CTestEventNotifier* : pointer to created object |
|
1019 |
|
1020 Errors/Exceptions: Leaves if ConstructL leaves or memory allocation fails |
|
1021 |
|
1022 Status: Approved |
|
1023 |
|
1024 ------------------------------------------------------------------------------- |
|
1025 */ |
|
1026 CTestEventNotifier* CTestEventNotifier::NewL( CTestCombiner* aTestCombiner, |
|
1027 CTCTestCase* aTestCase ) |
|
1028 { |
|
1029 CTestEventNotifier* self = |
|
1030 new ( ELeave ) CTestEventNotifier( aTestCombiner, aTestCase ); |
|
1031 CleanupStack::PushL( self ); |
|
1032 self->ConstructL(); |
|
1033 CleanupStack::Pop( self ); |
|
1034 return self; |
|
1035 } |
|
1036 |
|
1037 /* |
|
1038 ------------------------------------------------------------------------------- |
|
1039 |
|
1040 Class: CTestEventNotifier |
|
1041 |
|
1042 Method: ~CTestEventNotifier |
|
1043 |
|
1044 Description: Destructor |
|
1045 |
|
1046 Parameters: None |
|
1047 |
|
1048 Return Values: None |
|
1049 |
|
1050 Errors/Exceptions: None |
|
1051 |
|
1052 Status: Proposal |
|
1053 |
|
1054 ------------------------------------------------------------------------------- |
|
1055 */ |
|
1056 CTestEventNotifier::~CTestEventNotifier() |
|
1057 { |
|
1058 __TRACE( KMessage, ( _L("~CTestEventNotifier") )); |
|
1059 |
|
1060 |
|
1061 |
|
1062 Cancel(); |
|
1063 |
|
1064 |
|
1065 } |
|
1066 |
|
1067 /* |
|
1068 ------------------------------------------------------------------------------- |
|
1069 |
|
1070 Class: CTestEventNotifier |
|
1071 |
|
1072 Method: StartL |
|
1073 |
|
1074 Description: Start active object |
|
1075 |
|
1076 Parameters: None |
|
1077 |
|
1078 Return Values: None |
|
1079 |
|
1080 Errors/Exceptions: Leave if already pending |
|
1081 |
|
1082 Status: Proposal |
|
1083 |
|
1084 ------------------------------------------------------------------------------- |
|
1085 */ |
|
1086 void CTestEventNotifier::StartL() |
|
1087 { |
|
1088 // Check that this request is not pending!! |
|
1089 if( iState == ETestEventPending ) |
|
1090 { |
|
1091 User::Leave( KErrGeneral ); |
|
1092 } |
|
1093 |
|
1094 iEvent.SetType( TEventIf::EEnable ); |
|
1095 iState = ETestEventPending; |
|
1096 __TRACE( KMessage, ( _L("Set event pending %d"), this ) ); |
|
1097 iTestCase->TestExecution().NotifyEvent( iEventPckg, iStatus ); |
|
1098 SetActive(); |
|
1099 |
|
1100 } |
|
1101 |
|
1102 /* |
|
1103 ------------------------------------------------------------------------------- |
|
1104 |
|
1105 Class: CTestEventNotifier |
|
1106 |
|
1107 Method: RunL |
|
1108 |
|
1109 Description: Handles completed event request |
|
1110 |
|
1111 Parameters: None |
|
1112 |
|
1113 Return Values: None |
|
1114 |
|
1115 Errors/Exceptions: Leaves on error. |
|
1116 |
|
1117 Status: Proposal |
|
1118 |
|
1119 ------------------------------------------------------------------------------- |
|
1120 */ |
|
1121 |
|
1122 void CTestEventNotifier::RunL() |
|
1123 { |
|
1124 __TRACE( KMessage, ( _L("CTestEventNotifier::RunL(%d): %d, %d"), |
|
1125 this, iStatus.Int(), iState ) ); |
|
1126 |
|
1127 User::LeaveIfError( iStatus.Int() ); |
|
1128 |
|
1129 switch( iState ) |
|
1130 { |
|
1131 case ETestEventPending: |
|
1132 case ETestEventWaitUnset: |
|
1133 { |
|
1134 iState = ETestEventCompleted; |
|
1135 |
|
1136 switch( iEvent.Type() ) |
|
1137 { |
|
1138 case TEventIf::ERelEvent: |
|
1139 { |
|
1140 // Remove from requested events list |
|
1141 TInt count = iTestCase->EventArray().Count(); |
|
1142 TInt ind = 0; |
|
1143 for( ; ind < count; ind++) |
|
1144 { |
|
1145 if( iTestCase->EventArray()[ind]->Event().Name() == iEvent.Name() ) |
|
1146 { |
|
1147 __RDEBUG( ( _L("TC CTestEventNotifier(RelEvent) %S"), |
|
1148 &iEvent.Name() )); |
|
1149 CTestEventNotify* event = iTestCase->EventArray()[ind]; |
|
1150 iTestCase->EventArray().Remove( ind ); |
|
1151 delete event; |
|
1152 break; |
|
1153 } |
|
1154 } |
|
1155 if( ind == count ) |
|
1156 { |
|
1157 User::Leave( KErrNotFound ); |
|
1158 } |
|
1159 } |
|
1160 break; |
|
1161 case TEventIf::EUnsetEvent: |
|
1162 { |
|
1163 __RDEBUG( ( _L("TC CTestEventNotifier(UnsetEvent) %S"), |
|
1164 &iEvent.Name() )); |
|
1165 TInt count = iTestCase->StateEventArray().Count(); |
|
1166 for( TInt i=0; i<count; i++ ) |
|
1167 { |
|
1168 if( iTestCase->StateEventArray()[i]->Name() == iEvent.Name() ) |
|
1169 { |
|
1170 TEventIf* event = iTestCase->StateEventArray()[i]; |
|
1171 iTestCase->StateEventArray().Remove(i); |
|
1172 delete event; |
|
1173 break; |
|
1174 } |
|
1175 } |
|
1176 |
|
1177 if( iTestCombiner->UnsetEvent( iEvent, iStatus ) ) |
|
1178 { |
|
1179 // Event request is pending from modules below test |
|
1180 // combiner, stay waiting |
|
1181 iState = ETestEventWaitUnset; |
|
1182 // Wait for unset to complete |
|
1183 SetActive(); |
|
1184 return; |
|
1185 } |
|
1186 } |
|
1187 break; |
|
1188 case TEventIf::EReqEvent: |
|
1189 // Do nothing |
|
1190 __RDEBUG( ( _L("TC CTestEventNotifier(ReqEvent) %S"), |
|
1191 &iEvent.Name() )); |
|
1192 break; |
|
1193 case TEventIf::ESetEvent: |
|
1194 // Do nothing |
|
1195 __RDEBUG( ( _L("TC CTestEventNotifier(SetEvent) %S"), |
|
1196 &iEvent.Name() )); |
|
1197 break; |
|
1198 default: |
|
1199 User::Leave( KErrArgument ); |
|
1200 break; |
|
1201 } |
|
1202 |
|
1203 // Forward event request |
|
1204 iTestCombiner->TestModuleIf().Event( iEvent, iStatus ); |
|
1205 SetActive(); |
|
1206 |
|
1207 } |
|
1208 break; |
|
1209 case ETestEventCompleted: |
|
1210 __RDEBUG( ( _L("TC CTestEventNotifier(Complete)"))); |
|
1211 switch( iEvent.Type() ) |
|
1212 { |
|
1213 case TEventIf::EReqEvent: |
|
1214 { |
|
1215 // Store requested events |
|
1216 CTestEventNotify* event = |
|
1217 CTestEventNotify::NewL( iTestCombiner, iTestCase, iEvent ); |
|
1218 CleanupStack::PushL( event ); |
|
1219 User::LeaveIfError( iTestCase->EventArray().Append( event ) ); |
|
1220 CleanupStack::Pop( event ); |
|
1221 } |
|
1222 break; |
|
1223 case TEventIf::ESetEvent: |
|
1224 if( iEvent.EventType() == TEventIf::EState ) |
|
1225 { |
|
1226 TEventIf* event = new( ELeave )TEventIf; |
|
1227 CleanupStack::PushL( event ); |
|
1228 event->Copy( iEvent ); |
|
1229 User::LeaveIfError( iTestCase->StateEventArray().Append( event ) ); |
|
1230 CleanupStack::Pop( event ); |
|
1231 } |
|
1232 break; |
|
1233 case TEventIf::ERelEvent: |
|
1234 case TEventIf::EUnsetEvent: |
|
1235 // Do nothing |
|
1236 break; |
|
1237 default: |
|
1238 User::Leave( KErrArgument ); |
|
1239 break; |
|
1240 } |
|
1241 |
|
1242 // Enable request again |
|
1243 StartL(); |
|
1244 break; |
|
1245 default: |
|
1246 User::LeaveIfError( KErrGeneral ); |
|
1247 break; |
|
1248 } |
|
1249 __TRACE( KMessage, ( _L("CTestEventNotifier::RunL(%d) done: %d"), |
|
1250 this, iState ) ); |
|
1251 } |
|
1252 |
|
1253 /* |
|
1254 ------------------------------------------------------------------------------- |
|
1255 |
|
1256 Class: CTestEventNotifier |
|
1257 |
|
1258 Method: DoCancel |
|
1259 |
|
1260 Description: Handle Cancel |
|
1261 |
|
1262 Parameters: None |
|
1263 |
|
1264 Return Values: None |
|
1265 |
|
1266 Errors/Exceptions: None |
|
1267 |
|
1268 Status: Proposal |
|
1269 |
|
1270 ------------------------------------------------------------------------------- |
|
1271 */ |
|
1272 |
|
1273 void CTestEventNotifier::DoCancel() |
|
1274 { |
|
1275 __TRACE( KMessage, ( _L("CTestEventNotifier::DoCancel"))); |
|
1276 _LIT( KTestEventNotifier, "CTestEventNotifier" ); |
|
1277 |
|
1278 switch ( iState ) |
|
1279 { |
|
1280 case ETestEventPending: |
|
1281 iTestCase->TestExecution(). |
|
1282 CancelAsyncRequest( ETestExecutionNotifyEvent ); |
|
1283 break; |
|
1284 case ETestEventCompleted: |
|
1285 { |
|
1286 TInt ret = iTestCombiner->TestModuleIf().CancelEvent( iEvent, &iStatus ); |
|
1287 if( ret != KErrNone ) |
|
1288 { |
|
1289 __TRACE( KMessage, ( _L("CTestEventNotifier::DoCancel(%d) not pending: %d"), |
|
1290 this, ret ) ); |
|
1291 } |
|
1292 } |
|
1293 User::WaitForRequest( iStatus ); |
|
1294 break; |
|
1295 case ETestEventIdle: |
|
1296 default: |
|
1297 // DoCancel called in wrong state => Panic |
|
1298 User::Panic( KTestEventNotifier, KErrGeneral ); |
|
1299 break; |
|
1300 } |
|
1301 |
|
1302 iState = ETestEventIdle; |
|
1303 |
|
1304 } |
|
1305 |
|
1306 /* |
|
1307 ------------------------------------------------------------------------------- |
|
1308 |
|
1309 Class: CTestEventNotifier |
|
1310 |
|
1311 Method: RunError |
|
1312 |
|
1313 Description: Handle error. Should newer come here so we return error. |
|
1314 |
|
1315 Parameters: TInt aError: in: error from CActive |
|
1316 |
|
1317 Return Values: Symbian OS error value |
|
1318 |
|
1319 Errors/Exceptions: None |
|
1320 |
|
1321 Status: Approved |
|
1322 |
|
1323 ------------------------------------------------------------------------------- |
|
1324 */ |
|
1325 |
|
1326 TInt CTestEventNotifier::RunError( TInt aError ) |
|
1327 { |
|
1328 __TRACE( KMessage, ( _L("CTestEventNotifier::RunError"))); |
|
1329 |
|
1330 switch( iState ) |
|
1331 { |
|
1332 case ETestEventPending: |
|
1333 case ETestEventWaitUnset: |
|
1334 // Either the event request is cancelled or some |
|
1335 // unknown error occurred. We go idle state. |
|
1336 iState = ETestEventIdle; |
|
1337 break; |
|
1338 |
|
1339 case ETestEventCompleted: |
|
1340 // Error in event command, forward it to the test module |
|
1341 iEvent.SetType( TEventIf::EEnable ); |
|
1342 iState = ETestEventPending; |
|
1343 __TRACE( KMessage, ( _L("Cmd error %d"), this ) ); |
|
1344 iTestCase->TestExecution().NotifyEvent( iEventPckg, iStatus, aError ); |
|
1345 SetActive(); |
|
1346 break; |
|
1347 default: |
|
1348 __TRACE( KMessage, ( _L("Illegal state %d"), this ) ); |
|
1349 return aError; |
|
1350 } |
|
1351 |
|
1352 return KErrNone; |
|
1353 |
|
1354 } |
|
1355 |
|
1356 // ================= MEMBER FUNCTIONS ========================================= |
|
1357 /* |
|
1358 ------------------------------------------------------------------------------- |
|
1359 |
|
1360 Class: CTestCommandNotifier |
|
1361 |
|
1362 Method: CTestCommandNotifier |
|
1363 |
|
1364 Description: Default constructor |
|
1365 |
|
1366 C++ default constructor can NOT contain any code, that |
|
1367 might leave. |
|
1368 |
|
1369 Parameters: CTestCombiner* aTestCombiner: in: Pointer to TestCombiner |
|
1370 CTCTestCase* aTestCase: in: Pointer to test case |
|
1371 |
|
1372 Return Values: None |
|
1373 |
|
1374 Errors/Exceptions: None |
|
1375 |
|
1376 Status: Approved |
|
1377 |
|
1378 ------------------------------------------------------------------------------- |
|
1379 */ |
|
1380 CTestCommandNotifier::CTestCommandNotifier(CTestCombiner* aTestCombiner, |
|
1381 CTCTestCase* aTestCase): |
|
1382 CActive(CActive::EPriorityStandard), |
|
1383 iTestCombiner(aTestCombiner), |
|
1384 iTestCase(aTestCase), |
|
1385 iCommandPckg(iCommand) |
|
1386 { |
|
1387 CActiveScheduler::Add(this); |
|
1388 } |
|
1389 |
|
1390 /* |
|
1391 ------------------------------------------------------------------------------- |
|
1392 |
|
1393 Class: CTestCommandNotifier |
|
1394 |
|
1395 Method: ConstructL |
|
1396 |
|
1397 Description: Symbian OS second phase constructor |
|
1398 |
|
1399 Symbian OS default constructor can leave. |
|
1400 |
|
1401 Parameters: None |
|
1402 |
|
1403 Return Values: None |
|
1404 |
|
1405 Errors/Exceptions: None |
|
1406 |
|
1407 Status: Approved |
|
1408 |
|
1409 ------------------------------------------------------------------------------- |
|
1410 */ |
|
1411 void CTestCommandNotifier::ConstructL( ) |
|
1412 { |
|
1413 __TRACE(KMessage, (_L("CTestCommandNotifier::ConstructL (combiner)"))); |
|
1414 Start(); |
|
1415 } |
|
1416 |
|
1417 /* |
|
1418 ------------------------------------------------------------------------------- |
|
1419 |
|
1420 Class: CTestCommandNotifier |
|
1421 |
|
1422 Method: NewL |
|
1423 |
|
1424 Description: Two-phased constructor. |
|
1425 |
|
1426 Parameters: CTestCombiner* aTestCombiner: in: Pointer to TestCombiner |
|
1427 CTCTestCase* aTestCase: in: Pointer to test case |
|
1428 |
|
1429 Return Values: CTestCommandNotifier* : pointer to created object |
|
1430 |
|
1431 Errors/Exceptions: Leaves if construction of CTestCommandNotifier fails |
|
1432 |
|
1433 Status: Approved |
|
1434 |
|
1435 ------------------------------------------------------------------------------- |
|
1436 */ |
|
1437 CTestCommandNotifier* CTestCommandNotifier::NewL(CTestCombiner* aTestCombiner, |
|
1438 CTCTestCase* aTestCase) |
|
1439 { |
|
1440 CTestCommandNotifier* self = new (ELeave) CTestCommandNotifier(aTestCombiner, aTestCase); |
|
1441 CleanupStack::PushL(self); |
|
1442 self->ConstructL(); |
|
1443 CleanupStack::Pop(self); |
|
1444 return self; |
|
1445 } |
|
1446 |
|
1447 /* |
|
1448 ------------------------------------------------------------------------------- |
|
1449 |
|
1450 Class: CTestCommandNotifier |
|
1451 |
|
1452 Method: ~CTestCommandNotifier |
|
1453 |
|
1454 Description: Destructor |
|
1455 |
|
1456 Parameters: None |
|
1457 |
|
1458 Return Values: None |
|
1459 |
|
1460 Errors/Exceptions: None |
|
1461 |
|
1462 Status: Approved |
|
1463 |
|
1464 ------------------------------------------------------------------------------- |
|
1465 */ |
|
1466 CTestCommandNotifier::~CTestCommandNotifier() |
|
1467 { |
|
1468 __TRACE(KMessage, (_L("CTestEventNotifier::~CTestEventNotifier (combiner)"))); |
|
1469 Cancel(); |
|
1470 } |
|
1471 |
|
1472 /* |
|
1473 ------------------------------------------------------------------------------- |
|
1474 |
|
1475 Class: CTestCommandNotifier |
|
1476 |
|
1477 Method: StartL |
|
1478 |
|
1479 Description: Start active object |
|
1480 |
|
1481 Parameters: None |
|
1482 |
|
1483 Return Values: None |
|
1484 |
|
1485 Errors/Exceptions: None |
|
1486 |
|
1487 Status: Approved |
|
1488 |
|
1489 ------------------------------------------------------------------------------- |
|
1490 */ |
|
1491 void CTestCommandNotifier::Start() |
|
1492 { |
|
1493 __TRACE(KMessage, (_L("CTestEventNotifier::StartL (combiner)"))); |
|
1494 |
|
1495 iTestCase->TestExecution().NotifyCommand2(iCommandPckg, iParamsPckg, iStatus, KErrNone); |
|
1496 SetActive(); |
|
1497 } |
|
1498 |
|
1499 /* |
|
1500 ------------------------------------------------------------------------------- |
|
1501 |
|
1502 Class: CTestCommandNotifier |
|
1503 |
|
1504 Method: RunL |
|
1505 |
|
1506 Description: RunL handles completed requests. |
|
1507 |
|
1508 Parameters: None |
|
1509 |
|
1510 Return Values: None |
|
1511 |
|
1512 Errors/Exceptions: Leaves if iStatus is not KErrNone |
|
1513 Leaves if iState is not ETestEventPending |
|
1514 Leaves if some leaving method called here leaves |
|
1515 |
|
1516 Status: Approved |
|
1517 |
|
1518 ------------------------------------------------------------------------------- |
|
1519 */ |
|
1520 void CTestCommandNotifier::RunL() |
|
1521 { |
|
1522 __TRACE(KMessage, (_L("CTestCommandNotifier::RunL (combiner): iStatus=[%d]"), iStatus.Int())); |
|
1523 |
|
1524 User::LeaveIfError(iStatus.Int()); |
|
1525 |
|
1526 switch(iCommand) |
|
1527 { |
|
1528 case EStopExecution: |
|
1529 { |
|
1530 __TRACE(KMessage, (_L("CTestCommandNotifier::RunL (combiner): StopExecution command received"))); |
|
1531 TStopExecutionCommandParams par; |
|
1532 TStopExecutionCommandParamsPckg parPack(par); |
|
1533 parPack.Copy(iParamsPckg); |
|
1534 __TRACE(KMessage, (_L("CTestCommandNotifier::RunL(combiner): propagating stop execution [%d][%d]"), par.iType, par.iCode)); |
|
1535 iTestCombiner->TestModuleIf().StopExecution(par.iType, par.iCode); |
|
1536 } |
|
1537 break; |
|
1538 |
|
1539 case ESendTestModuleVersion: |
|
1540 { |
|
1541 __TRACE(KMessage, (_L("CTestCommandNotifier::RunL (combiner): SendTestModuleVersion command received"))); |
|
1542 TSendTestModuleVesionCommandParams params; |
|
1543 TSendTestModuleVesionCommandParamsPckg paramsPack(params); |
|
1544 paramsPack.Copy(iParamsPckg); |
|
1545 |
|
1546 __TRACE(KMessage, (_L("CTestCommandNotifier::RunL(combiner): propagating module version [%d][%d][%d][%S]"), params.iMajor, params.iMinor, params.iBuild, ¶ms.iTestModuleName)); |
|
1547 TVersion moduleVersion(params.iMajor, params.iMinor, params.iBuild); |
|
1548 |
|
1549 TBool newVersionOfMethod = ETrue; |
|
1550 iTestCombiner->TestModuleIf().SendTestModuleVersion(moduleVersion, params.iTestModuleName, newVersionOfMethod); |
|
1551 } |
|
1552 break; |
|
1553 |
|
1554 default: |
|
1555 __TRACE(KError, (_L("CTestCommandNotifier::RunL (combiner): Unknown command [%d]."), iCommand)); |
|
1556 } |
|
1557 |
|
1558 // Set request again |
|
1559 Start(); |
|
1560 } |
|
1561 |
|
1562 /* |
|
1563 ------------------------------------------------------------------------------- |
|
1564 |
|
1565 Class: CTestCommandNotifier |
|
1566 |
|
1567 Method: DoCancel |
|
1568 |
|
1569 Description: Cancel active request |
|
1570 |
|
1571 Parameters: None |
|
1572 |
|
1573 Return Values: None |
|
1574 |
|
1575 Errors/Exceptions: None |
|
1576 |
|
1577 Status: Approved |
|
1578 |
|
1579 ------------------------------------------------------------------------------- |
|
1580 */ |
|
1581 void CTestCommandNotifier::DoCancel() |
|
1582 { |
|
1583 __TRACE(KMessage, (_L( "CTestEventNotifier::DoCancel (combiner)"))); |
|
1584 |
|
1585 iTestCase->TestExecution().CancelAsyncRequest(ETestExecutionNotifyCommand); |
|
1586 } |
|
1587 |
|
1588 /* |
|
1589 ------------------------------------------------------------------------------- |
|
1590 |
|
1591 Class: CTestCommandNotifier |
|
1592 |
|
1593 Method: RunError |
|
1594 |
|
1595 Description: Handle errors. |
|
1596 |
|
1597 Parameters: TInt aError: in: Symbian OS error: Error code |
|
1598 |
|
1599 Return Values: TInt KErrNone: Always returned KErrNone |
|
1600 |
|
1601 Errors/Exceptions: None |
|
1602 |
|
1603 Status: Approved |
|
1604 |
|
1605 ------------------------------------------------------------------------------- |
|
1606 */ |
|
1607 TInt CTestCommandNotifier::RunError(TInt aError) |
|
1608 { |
|
1609 __TRACE(KError, (CStifLogger::ERed, _L("CTestCommandNotifier::RunError %d (combiner)"), aError)); |
|
1610 return KErrNone; |
|
1611 } |
|
1612 |
|
1613 // ================= OTHER EXPORTED FUNCTIONS ================================= |
|
1614 |
|
1615 // None |
|
1616 |
|
1617 // End of File |
|