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 the implementation of |
|
15 * CTestCase 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 #include "StifPython.h" |
|
25 |
|
26 // EXTERNAL DATA STRUCTURES |
|
27 // None |
|
28 |
|
29 // EXTERNAL FUNCTION PROTOTYPES |
|
30 // None |
|
31 |
|
32 // CONSTANTS |
|
33 // None |
|
34 |
|
35 // MACROS |
|
36 #ifdef LOGGER |
|
37 #undef LOGGER |
|
38 #endif |
|
39 #define LOGGER iTestCombiner->iLog |
|
40 |
|
41 // LOCAL CONSTANTS AND MACROS |
|
42 // None |
|
43 |
|
44 // MODULE DATA STRUCTURES |
|
45 // None |
|
46 |
|
47 // LOCAL FUNCTION PROTOTYPES |
|
48 // None |
|
49 |
|
50 // FORWARD DECLARATIONS |
|
51 // None |
|
52 |
|
53 // ================= MEMBER FUNCTIONS ========================================= |
|
54 |
|
55 /* |
|
56 ------------------------------------------------------------------------------- |
|
57 |
|
58 Class: CTestCase |
|
59 |
|
60 Method: CTestCase |
|
61 |
|
62 Description: Default constructor |
|
63 |
|
64 C++ default constructor can NOT contain any code, that |
|
65 might leave. |
|
66 |
|
67 Parameters: CTestCombiner* testCombiner: in: Backpointer to CTestCombiner |
|
68 TDesC& aModuleName: in: name of the used test module |
|
69 TDesC& aTestId: in: TestId for testcase |
|
70 TInt aExpectedResult: in: expected result for the testcase |
|
71 |
|
72 Return Values: None. |
|
73 |
|
74 Errors/Exceptions: None. |
|
75 |
|
76 Status: Draft |
|
77 |
|
78 ------------------------------------------------------------------------------- |
|
79 */ |
|
80 |
|
81 CTestCase::CTestCase( CTestCombiner* testCombiner, |
|
82 TInt aExpectedResult, |
|
83 TFullTestResult::TCaseExecutionResult aCategory, |
|
84 TCaseType aType, |
|
85 CTCTestModule* aModule ): //--PYTHON |
|
86 CActive( CActive::EPriorityStandard ), |
|
87 iType( aType ), |
|
88 iTestCombiner( testCombiner ), |
|
89 iState( ETestCaseIdle ), |
|
90 iExpectedResult( aExpectedResult ), |
|
91 iExpectedResultCategory( aCategory ), |
|
92 iTestModule( aModule ) //--PYTHON |
|
93 { |
|
94 |
|
95 CActiveScheduler::Add( this ); |
|
96 |
|
97 } |
|
98 |
|
99 /* |
|
100 ------------------------------------------------------------------------------- |
|
101 |
|
102 Class: CTestCase |
|
103 |
|
104 Method: ConstructL |
|
105 |
|
106 Description: Symbian OS second phase constructor |
|
107 |
|
108 Symbian OS default constructor can leave. |
|
109 |
|
110 Parameters: TDesC& aTestId: in: Test identifier |
|
111 |
|
112 Return Values: None. |
|
113 |
|
114 Errors/Exceptions: None |
|
115 |
|
116 Status: Proposal |
|
117 |
|
118 ------------------------------------------------------------------------------- |
|
119 */ |
|
120 |
|
121 void CTestCase::ConstructL( TDesC& aTestId ) |
|
122 { |
|
123 __ASSERT_ALWAYS( aTestId.Length() < KMaxFileName, User::Leave( KErrArgument ) ); |
|
124 iTestId = aTestId.AllocL(); |
|
125 |
|
126 } |
|
127 |
|
128 /* |
|
129 ------------------------------------------------------------------------------- |
|
130 |
|
131 Class: CTestCase |
|
132 |
|
133 Method: ~CTestCase |
|
134 |
|
135 Description: Destructor |
|
136 |
|
137 Parameters: None. |
|
138 |
|
139 Return Values: None. |
|
140 |
|
141 Errors/Exceptions: None. |
|
142 |
|
143 Status: Proposal |
|
144 |
|
145 ------------------------------------------------------------------------------- |
|
146 */ |
|
147 |
|
148 CTestCase::~CTestCase() |
|
149 { |
|
150 |
|
151 Cancel(); |
|
152 delete iTestId; |
|
153 |
|
154 } |
|
155 |
|
156 /* |
|
157 ------------------------------------------------------------------------------- |
|
158 |
|
159 Class: CTestCase |
|
160 |
|
161 Method: RunL |
|
162 |
|
163 Description: Derived from CActive. Handles the completed testcase. |
|
164 |
|
165 Parameters: None. |
|
166 |
|
167 Return Values: None. |
|
168 |
|
169 Errors/Exceptions: Leaves if completed with error. |
|
170 |
|
171 Status: Proposal |
|
172 |
|
173 ------------------------------------------------------------------------------- |
|
174 */ |
|
175 |
|
176 void CTestCase::RunL() |
|
177 { |
|
178 __TRACE( KMessage, ( _L("CTestCase::RunL: [%d] "), iStatus.Int() )); |
|
179 |
|
180 Complete( iStatus.Int() ); |
|
181 |
|
182 __TRACE( KMessage, ( _L( "CTestCase::RunL: Testcase completed" ))); |
|
183 |
|
184 } |
|
185 |
|
186 /* |
|
187 ------------------------------------------------------------------------------- |
|
188 |
|
189 Class: CTestCase |
|
190 |
|
191 Method: DoCancel |
|
192 |
|
193 Description: Derived from CActive, handles the Cancel. |
|
194 |
|
195 Parameters: None. |
|
196 |
|
197 Return Values: None. |
|
198 |
|
199 Errors/Exceptions: None. |
|
200 |
|
201 Status: Proposal |
|
202 |
|
203 ------------------------------------------------------------------------------- |
|
204 */ |
|
205 void CTestCase::DoCancel() |
|
206 { |
|
207 __TRACE( KMessage, ( _L("CTestCase::DoCancel"))); |
|
208 |
|
209 TRequestStatus* rs = &iStatus; |
|
210 User::RequestComplete( rs, KErrCancel ); |
|
211 Complete( KErrCancel ); |
|
212 |
|
213 } |
|
214 |
|
215 /* |
|
216 ------------------------------------------------------------------------------- |
|
217 |
|
218 Class: CTestCase |
|
219 |
|
220 Method: Start |
|
221 |
|
222 Description: Start progress and event notifiers and set CTestCase active. |
|
223 |
|
224 Parameters: None. |
|
225 |
|
226 Return Values: None. |
|
227 |
|
228 Errors/Exceptions: None. |
|
229 |
|
230 Status: Proposal |
|
231 |
|
232 ------------------------------------------------------------------------------- |
|
233 */ |
|
234 void CTestCase::StartL() |
|
235 { |
|
236 |
|
237 iState = ETestCaseRunning; |
|
238 iStatus = KRequestPending; |
|
239 SetActive(); |
|
240 |
|
241 } |
|
242 |
|
243 /* |
|
244 ------------------------------------------------------------------------------- |
|
245 |
|
246 Class: CTestCase |
|
247 |
|
248 Method: Complete |
|
249 |
|
250 Description: Completes testcase to CTestCombiner. |
|
251 |
|
252 Parameters: TInt aError: in: Completion error |
|
253 |
|
254 Return Values: None. |
|
255 |
|
256 Errors/Exceptions: None. |
|
257 |
|
258 Status: Proposal |
|
259 |
|
260 ------------------------------------------------------------------------------- |
|
261 */ |
|
262 void CTestCase::Complete( TInt aError ) |
|
263 { |
|
264 |
|
265 __TRACE( KMessage, ( _L("CTestCase::Complete: %d "), aError )); |
|
266 iState = ETestCaseCompleted; |
|
267 |
|
268 iTestCombiner->Complete( this, aError ); |
|
269 |
|
270 } |
|
271 |
|
272 /* |
|
273 ------------------------------------------------------------------------------- |
|
274 |
|
275 Class: CTestCase |
|
276 |
|
277 Method: IsCompletelyFinished |
|
278 |
|
279 Description: Checks state. |
|
280 |
|
281 Parameters: None |
|
282 |
|
283 Return Values: TBool. |
|
284 |
|
285 Errors/Exceptions: None. |
|
286 |
|
287 Status: Proposal |
|
288 |
|
289 ------------------------------------------------------------------------------- |
|
290 */ |
|
291 TBool CTestCase::IsCompletelyFinished(void) |
|
292 { |
|
293 TBool result = (iState == CTestCase::ETestCaseCompleted); |
|
294 return result; |
|
295 } |
|
296 |
|
297 /* |
|
298 ------------------------------------------------------------------------------- |
|
299 |
|
300 DESCRIPTION |
|
301 |
|
302 This module contains the implementation of CTCTestCase class |
|
303 member functions. |
|
304 |
|
305 ------------------------------------------------------------------------------- |
|
306 */ |
|
307 |
|
308 // ================= MEMBER FUNCTIONS ========================================= |
|
309 |
|
310 /* |
|
311 ------------------------------------------------------------------------------- |
|
312 |
|
313 Class: CTCTestCase |
|
314 |
|
315 Method: CTCTestCase |
|
316 |
|
317 Description: Default constructor |
|
318 |
|
319 C++ default constructor can NOT contain any code, that |
|
320 might leave. |
|
321 |
|
322 Parameters: CTestCombiner* testCombiner: in: Backpointer to CTestCombiner |
|
323 TDesC& aModuleName: in: name of the used test module |
|
324 TDesC& aTestId: in: TestId for testcase |
|
325 TInt aExpectedResult: in: expected result for the testcase |
|
326 |
|
327 Return Values: None. |
|
328 |
|
329 Errors/Exceptions: None. |
|
330 |
|
331 Status: Proposal |
|
332 |
|
333 ------------------------------------------------------------------------------- |
|
334 */ |
|
335 |
|
336 CTCTestCase::CTCTestCase( CTestCombiner* testCombiner, |
|
337 TInt aExpectedResult, |
|
338 TFullTestResult::TCaseExecutionResult aCategory, |
|
339 CTCTestModule* aModule ): //--PYTHON |
|
340 CTestCase( testCombiner, aExpectedResult, aCategory, ECaseLocal, aModule ), //--PYTHON |
|
341 iResultPckg( iResult ) |
|
342 { |
|
343 } |
|
344 |
|
345 /* |
|
346 ------------------------------------------------------------------------------- |
|
347 |
|
348 Class: CTCTestCase |
|
349 |
|
350 Method: ConstructL |
|
351 |
|
352 Description: Symbian OS second phase constructor |
|
353 |
|
354 Symbian OS default constructor can leave. |
|
355 |
|
356 Parameters: None. |
|
357 |
|
358 Return Values: None. |
|
359 |
|
360 Errors/Exceptions: None |
|
361 |
|
362 Status: Proposal |
|
363 |
|
364 ------------------------------------------------------------------------------- |
|
365 */ |
|
366 |
|
367 void CTCTestCase::ConstructL( TDesC& aModuleName, |
|
368 TDesC& aTestId, |
|
369 const TDesC& aTestCaseArguments ) |
|
370 { |
|
371 __ASSERT_ALWAYS( aModuleName.Length() < KMaxFileName, User::Leave( KErrArgument ) ); |
|
372 CTestCase::ConstructL( aTestId ); |
|
373 iModuleName = aModuleName.AllocL(); |
|
374 iTestCaseArguments = aTestCaseArguments.AllocL(); |
|
375 } |
|
376 |
|
377 /* |
|
378 ------------------------------------------------------------------------------- |
|
379 |
|
380 Class: CTCTestCase |
|
381 |
|
382 Method: NewL |
|
383 |
|
384 Description: Two-phased constructor. |
|
385 |
|
386 Parameters: CTestCombiner* testCombiner: in: Backpointer to CTestCombiner |
|
387 |
|
388 Return Values: CTCTestCase*: pointer to new CTCTestCase object |
|
389 |
|
390 Errors/Exceptions: Leaves if new or ConstructL leaves. |
|
391 |
|
392 Status: Proposal |
|
393 |
|
394 ------------------------------------------------------------------------------- |
|
395 */ |
|
396 |
|
397 CTCTestCase* CTCTestCase::NewL( CTestCombiner* testCombiner, |
|
398 TDesC& aModuleName, |
|
399 TDesC& aTestId, |
|
400 TInt aExpectedResult, |
|
401 TFullTestResult::TCaseExecutionResult aCategory, |
|
402 const TDesC& aTestCaseArguments, |
|
403 CTCTestModule* aModule ) //--PYTHON |
|
404 { |
|
405 CTCTestCase* self = new (ELeave) CTCTestCase( testCombiner, |
|
406 aExpectedResult, |
|
407 aCategory, |
|
408 aModule ); //--PYTHON |
|
409 |
|
410 CleanupStack::PushL( self ); |
|
411 self->ConstructL( aModuleName, aTestId, aTestCaseArguments ); |
|
412 CleanupStack::Pop(); |
|
413 return self; |
|
414 |
|
415 } |
|
416 |
|
417 /* |
|
418 ------------------------------------------------------------------------------- |
|
419 |
|
420 Class: CTCTestCase |
|
421 |
|
422 Method: ~CTCTestCase |
|
423 |
|
424 Description: Destructor |
|
425 |
|
426 Parameters: None. |
|
427 |
|
428 Return Values: None. |
|
429 |
|
430 Errors/Exceptions: None. |
|
431 |
|
432 Status: Proposal |
|
433 |
|
434 ------------------------------------------------------------------------------- |
|
435 */ |
|
436 |
|
437 CTCTestCase::~CTCTestCase() |
|
438 { |
|
439 Cancel(); |
|
440 |
|
441 delete iEvent; |
|
442 |
|
443 // Unset all set events |
|
444 TInt count = iStateEventArray.Count(); |
|
445 TInt i = 0; |
|
446 for( i = 0; i < count; i++ ) |
|
447 { |
|
448 if( iStateEventArray[i] != NULL ) |
|
449 { |
|
450 iStateEventArray[i]->SetType( TEventIf::EUnsetEvent ); |
|
451 } |
|
452 if( iTestCombiner != NULL ) |
|
453 { |
|
454 iTestCombiner->TestModuleIf().Event( *iStateEventArray[i] ); |
|
455 } |
|
456 } |
|
457 iStateEventArray.ResetAndDestroy(); |
|
458 iStateEventArray.Close(); |
|
459 |
|
460 // to be sure.. |
|
461 count = iEventArray.Count(); |
|
462 TEventIf event; |
|
463 for( i = 0; i < count; i++ ) |
|
464 { |
|
465 event.Copy( iEventArray[i]->Event() ); |
|
466 event.SetType( TEventIf::ERelEvent ); |
|
467 if( iTestCombiner != NULL ) |
|
468 { |
|
469 iTestCombiner->TestModuleIf().Event( event ); |
|
470 } |
|
471 } |
|
472 |
|
473 |
|
474 iEventArray.ResetAndDestroy(); |
|
475 iEventArray.Close(); |
|
476 |
|
477 delete iProgress; |
|
478 delete iModuleName; |
|
479 delete iTestCaseArguments; |
|
480 |
|
481 delete iCommand; |
|
482 } |
|
483 |
|
484 /* |
|
485 ------------------------------------------------------------------------------- |
|
486 |
|
487 Class: CTCTestCase |
|
488 |
|
489 Method: TestCaseArguments |
|
490 |
|
491 Description: Get test case arguments |
|
492 |
|
493 Parameters: None. |
|
494 |
|
495 Return Values: Test case arguments. |
|
496 |
|
497 Errors/Exceptions: None. |
|
498 |
|
499 Status: Proposal |
|
500 |
|
501 ------------------------------------------------------------------------------- |
|
502 */ |
|
503 const TDesC& CTCTestCase::TestCaseArguments() const |
|
504 { |
|
505 if ( iTestCaseArguments !=NULL ) |
|
506 { |
|
507 return *iTestCaseArguments; |
|
508 } |
|
509 return KNullDesC; |
|
510 } |
|
511 |
|
512 /* |
|
513 ------------------------------------------------------------------------------- |
|
514 |
|
515 Class: CTCTestCase |
|
516 |
|
517 Method: DoCancel |
|
518 |
|
519 Description: Derived from CActive, handles the Cancel. |
|
520 |
|
521 Parameters: None. |
|
522 |
|
523 Return Values: None. |
|
524 |
|
525 Errors/Exceptions: None. |
|
526 |
|
527 Status: Proposal |
|
528 |
|
529 ------------------------------------------------------------------------------- |
|
530 */ |
|
531 void CTCTestCase::DoCancel() |
|
532 { |
|
533 __TRACE( KMessage, ( _L("CTCTestCase::DoCancel"))); |
|
534 iTestExecution.CancelAsyncRequest( ETestExecutionRunTestCase ); |
|
535 Complete( KErrCancel ); |
|
536 |
|
537 } |
|
538 |
|
539 /* |
|
540 ------------------------------------------------------------------------------- |
|
541 |
|
542 Class: CTCTestCase |
|
543 |
|
544 Method: Start |
|
545 |
|
546 Description: Start progress and event notifiers and set CTCTestCase active. |
|
547 |
|
548 Parameters: None. |
|
549 |
|
550 Return Values: None. |
|
551 |
|
552 Errors/Exceptions: None. |
|
553 |
|
554 Status: Proposal |
|
555 |
|
556 ------------------------------------------------------------------------------- |
|
557 */ |
|
558 void CTCTestCase::StartL() |
|
559 { |
|
560 iProgress = CTestProgressNotifier::NewL( iTestCombiner, this ); |
|
561 iEvent = CTestEventNotifier::NewL( iTestCombiner, this ); |
|
562 iCommand = CTestCommandNotifier::NewL(iTestCombiner, this); |
|
563 iState = ETestCaseRunning; |
|
564 SetActive(); |
|
565 |
|
566 } |
|
567 |
|
568 /* |
|
569 ------------------------------------------------------------------------------- |
|
570 |
|
571 Class: CTCTestCase |
|
572 |
|
573 Method: Complete |
|
574 |
|
575 Description: Start complete the testcase to CTestCombiner (Complete2 make |
|
576 the final complete). |
|
577 |
|
578 Parameters: TInt aError: in: Completion error |
|
579 |
|
580 Return Values: None. |
|
581 |
|
582 Errors/Exceptions: None. |
|
583 |
|
584 Status: Proposal |
|
585 |
|
586 ------------------------------------------------------------------------------- |
|
587 */ |
|
588 void CTCTestCase::Complete( TInt aError ) |
|
589 { |
|
590 if( iState == ETestCaseRunning ) |
|
591 { |
|
592 // Testcase is in running state, complete and delete notifiers |
|
593 if( aError != KErrNone ) |
|
594 { |
|
595 iResult.iTestResult.iResult = aError; |
|
596 } |
|
597 |
|
598 iState = ETestCaseCompleted; |
|
599 __TRACE( KMessage, ( _L("CTCTestCase::Complete: %d "), aError )); |
|
600 |
|
601 } |
|
602 |
|
603 if( iProgress->IsPrintProgressFinished() ) |
|
604 { |
|
605 // Print process is finished to UI => make final complete of |
|
606 // the test case |
|
607 Complete2(); |
|
608 } |
|
609 |
|
610 } |
|
611 |
|
612 /* |
|
613 ------------------------------------------------------------------------------- |
|
614 |
|
615 Class: CTCTestCase |
|
616 |
|
617 Method: Complete2 |
|
618 |
|
619 Description: Testcase final complete to CTestCombiner. |
|
620 |
|
621 Parameters: None |
|
622 |
|
623 Return Values: None. |
|
624 |
|
625 Errors/Exceptions: None. |
|
626 |
|
627 Status: Proposal |
|
628 |
|
629 ------------------------------------------------------------------------------- |
|
630 */ |
|
631 void CTCTestCase::Complete2() |
|
632 { |
|
633 // to be sure.. |
|
634 TInt count = iEventArray.Count(); |
|
635 TEventIf event; |
|
636 for( TInt i = 0; i < count; i++ ) |
|
637 { |
|
638 event.Copy( iEventArray[0]->Event() ); |
|
639 event.SetType( TEventIf::ERelEvent ); |
|
640 CTestEventNotify* eventEntry = iEventArray[0]; |
|
641 iEventArray.Remove( 0 ); |
|
642 delete eventEntry; |
|
643 iTestCombiner->TestModuleIf().Event( event ); |
|
644 } |
|
645 |
|
646 iEventArray.ResetAndDestroy(); |
|
647 iEventArray.Close(); |
|
648 |
|
649 delete iEvent; |
|
650 iEvent = NULL; |
|
651 delete iProgress; |
|
652 iProgress = NULL; |
|
653 delete iCommand; |
|
654 iCommand = NULL; |
|
655 |
|
656 iTestCombiner->Complete( this ); |
|
657 |
|
658 // Close execution handle |
|
659 iTestExecution.Close(); |
|
660 |
|
661 } |
|
662 |
|
663 /* |
|
664 ------------------------------------------------------------------------------- |
|
665 |
|
666 Class: CTCTestCase |
|
667 |
|
668 Method: IsCompletelyFinished |
|
669 |
|
670 Description: Checks state and progress notifier. |
|
671 |
|
672 Parameters: None |
|
673 |
|
674 Return Values: TBool. |
|
675 |
|
676 Errors/Exceptions: None. |
|
677 |
|
678 Status: Proposal |
|
679 |
|
680 ------------------------------------------------------------------------------- |
|
681 */ |
|
682 TBool CTCTestCase::IsCompletelyFinished(void) |
|
683 { |
|
684 TBool result = (iState == CTCTestCase::ETestCaseCompleted); |
|
685 if(iProgress) |
|
686 { |
|
687 result = result && (iProgress->IsPrintProgressFinished()); |
|
688 } |
|
689 return result; |
|
690 } |
|
691 |
|
692 /* |
|
693 ------------------------------------------------------------------------------- |
|
694 |
|
695 DESCRIPTION |
|
696 |
|
697 This module contains the implementation of CRemoteTestCase class |
|
698 member functions. |
|
699 |
|
700 ------------------------------------------------------------------------------- |
|
701 */ |
|
702 |
|
703 // ================= MEMBER FUNCTIONS ========================================= |
|
704 |
|
705 /* |
|
706 ------------------------------------------------------------------------------- |
|
707 |
|
708 Class: CRemoteTestCase |
|
709 |
|
710 Method: CRemoteTestCase |
|
711 |
|
712 Description: Default constructor |
|
713 |
|
714 C++ default constructor can NOT contain any code, that |
|
715 might leave. |
|
716 |
|
717 Parameters: CTestCombiner* testCombiner: in: Backpointer to CTestCombiner |
|
718 TInt aExpectedResult: in: expected result for the testcase |
|
719 TFullTestResult::TCaseExecutionResult aCategory: in: |
|
720 result category |
|
721 Return Values: None. |
|
722 |
|
723 Errors/Exceptions: None. |
|
724 |
|
725 Status: Proposal |
|
726 |
|
727 ------------------------------------------------------------------------------- |
|
728 */ |
|
729 |
|
730 CRemoteTestCase::CRemoteTestCase( CTestCombiner* testCombiner, |
|
731 TInt aExpectedResult, |
|
732 TFullTestResult::TCaseExecutionResult aCategory ): |
|
733 CTestCase( testCombiner, aExpectedResult, aCategory, ECaseRemote, NULL ), //--PYTHON |
|
734 iRemoteState( ECaseIdle ), |
|
735 iFreeSlave( EFalse ) |
|
736 { |
|
737 } |
|
738 |
|
739 /* |
|
740 ------------------------------------------------------------------------------- |
|
741 |
|
742 Class: CRemoteTestCase |
|
743 |
|
744 Method: ConstructL |
|
745 |
|
746 Description: Symbian OS second phase constructor |
|
747 |
|
748 Symbian OS default constructor can leave. |
|
749 |
|
750 Parameters: None. |
|
751 |
|
752 Return Values: None. |
|
753 |
|
754 Errors/Exceptions: None |
|
755 |
|
756 Status: Proposal |
|
757 |
|
758 ------------------------------------------------------------------------------- |
|
759 */ |
|
760 |
|
761 void CRemoteTestCase::ConstructL( TDesC& aTestId ) |
|
762 { |
|
763 CTestCase::ConstructL( aTestId ); |
|
764 |
|
765 } |
|
766 |
|
767 /* |
|
768 ------------------------------------------------------------------------------- |
|
769 |
|
770 Class: CRemoteTestCase |
|
771 |
|
772 Method: NewL |
|
773 |
|
774 Description: Two-phased constructor. |
|
775 |
|
776 Parameters: CTestCombiner* testCombiner: in: Backpointer to CTestCombiner |
|
777 |
|
778 Return Values: CRemoteTestCase*: pointer to new CRemoteTestCase object |
|
779 |
|
780 Errors/Exceptions: Leaves if new or ConstructL leaves. |
|
781 |
|
782 Status: Proposal |
|
783 |
|
784 ------------------------------------------------------------------------------- |
|
785 */ |
|
786 |
|
787 CRemoteTestCase* CRemoteTestCase::NewL( CTestCombiner* testCombiner, |
|
788 TDesC& aTestId, |
|
789 TInt aExpectedResult, |
|
790 TFullTestResult::TCaseExecutionResult |
|
791 aCategory ) |
|
792 { |
|
793 CRemoteTestCase* self = new (ELeave) CRemoteTestCase( testCombiner, |
|
794 aExpectedResult, |
|
795 aCategory ); |
|
796 |
|
797 CleanupStack::PushL( self ); |
|
798 self->ConstructL( aTestId ); |
|
799 CleanupStack::Pop(); |
|
800 return self; |
|
801 |
|
802 } |
|
803 |
|
804 /* |
|
805 ------------------------------------------------------------------------------- |
|
806 |
|
807 Class: CRemoteTestCase |
|
808 |
|
809 Method: ~CRemoteTestCase |
|
810 |
|
811 Description: Destructor |
|
812 |
|
813 Parameters: None. |
|
814 |
|
815 Return Values: None. |
|
816 |
|
817 Errors/Exceptions: None. |
|
818 |
|
819 Status: Proposal |
|
820 |
|
821 ------------------------------------------------------------------------------- |
|
822 */ |
|
823 |
|
824 CRemoteTestCase::~CRemoteTestCase() |
|
825 { |
|
826 } |
|
827 |
|
828 /* |
|
829 ------------------------------------------------------------------------------- |
|
830 |
|
831 DESCRIPTION |
|
832 |
|
833 This module contains the implementation of CTCTestModule class |
|
834 member functions. |
|
835 |
|
836 ------------------------------------------------------------------------------- |
|
837 */ |
|
838 |
|
839 // ================= MEMBER FUNCTIONS ========================================= |
|
840 |
|
841 /* |
|
842 ------------------------------------------------------------------------------- |
|
843 |
|
844 Class: CTCTestModule |
|
845 |
|
846 Method: CTCTestModule |
|
847 |
|
848 Description: Default constructor |
|
849 |
|
850 C++ default constructor can NOT contain any code, that |
|
851 might leave. |
|
852 |
|
853 Parameters: TDesC& aModule: in: module name |
|
854 TDesC& aIni: in: inifile name |
|
855 |
|
856 Return Values: None. |
|
857 |
|
858 Errors/Exceptions: None. |
|
859 |
|
860 Status: Approved |
|
861 |
|
862 ------------------------------------------------------------------------------- |
|
863 */ |
|
864 CTCTestModule::CTCTestModule( CTestCombiner* testCombiner ): |
|
865 iTestCombiner( testCombiner ) |
|
866 { |
|
867 iTestCases = NULL; |
|
868 } |
|
869 |
|
870 /* |
|
871 ------------------------------------------------------------------------------- |
|
872 |
|
873 Class: CTCTestModule |
|
874 |
|
875 Method: ConstructL |
|
876 |
|
877 Description: Symbian OS second phase constructor |
|
878 |
|
879 Symbian OS default constructor can leave. |
|
880 |
|
881 Parameters: TDesC& aModule: in: Module name. |
|
882 TDesC& aIni: in: Inifile name. |
|
883 const TDesC& aConfigFile: in: Test case(config) file name. |
|
884 |
|
885 Return Values: None. |
|
886 |
|
887 Errors/Exceptions: None |
|
888 |
|
889 Status: Proposal |
|
890 |
|
891 ------------------------------------------------------------------------------- |
|
892 */ |
|
893 |
|
894 void CTCTestModule::ConstructL( TDesC& aModule, |
|
895 TDesC& aIni, |
|
896 const TDesC& aConfigFile ) |
|
897 { |
|
898 __TRACE( KMessage, ( _L("CTCTestModule::ConstructL [%S]"), &aModule)); |
|
899 |
|
900 __ASSERT_ALWAYS( aModule.Length() < KMaxFileName, User::Leave( KErrArgument ) ); |
|
901 __ASSERT_ALWAYS( aIni.Length() < KMaxFileName, User::Leave( KErrArgument ) ); |
|
902 iModuleName = aModule.AllocL(); |
|
903 iIniFile = aIni.AllocL(); |
|
904 |
|
905 TFileName ini = *iIniFile; |
|
906 // Open handles |
|
907 __TRACE( KMessage, ( _L("CTCTestModule: Server connect"))); |
|
908 User::LeaveIfError( iTestServer.Connect( ModuleName(), aConfigFile ) ); |
|
909 __TRACE( KMessage, ( _L("CTCTestModule: Module open"))); |
|
910 User::LeaveIfError( iTestModule.Open( iTestServer, ini ) ); |
|
911 |
|
912 iErrorPrinter = CTestErrorNotifier::NewL( iTestCombiner, this ); |
|
913 |
|
914 } |
|
915 |
|
916 /* |
|
917 ------------------------------------------------------------------------------- |
|
918 |
|
919 Class: CTCTestModule |
|
920 |
|
921 Method: NewL |
|
922 |
|
923 Description: Two-phased constructor. |
|
924 |
|
925 Parameters: None |
|
926 |
|
927 Return Values: TDesC& aModule: in: Module name. |
|
928 TDesC& aIni: in: Inifile name. |
|
929 const TDesC& aConfigFile: in: Test case(config) file name. |
|
930 |
|
931 Errors/Exceptions: Leaves if ConstructL leaves |
|
932 Leaves if memory allocation fails |
|
933 Leaves if illegal arguments are given |
|
934 |
|
935 Status: Proposal |
|
936 |
|
937 ------------------------------------------------------------------------------- |
|
938 */ |
|
939 |
|
940 CTCTestModule* CTCTestModule::NewL( CTestCombiner* testCombiner, |
|
941 TDesC& aModule, |
|
942 TDesC& aIni, |
|
943 const TDesC& aConfigFile ) |
|
944 { |
|
945 CTCTestModule* self = new (ELeave) CTCTestModule( testCombiner ); |
|
946 |
|
947 CleanupStack::PushL( self ); |
|
948 self->ConstructL( aModule, aIni, aConfigFile ); |
|
949 CleanupStack::Pop(); |
|
950 |
|
951 return self; |
|
952 |
|
953 } |
|
954 |
|
955 /* |
|
956 |
|
957 ------------------------------------------------------------------------------- |
|
958 |
|
959 Class: CTCTestModule |
|
960 |
|
961 Method: ~CTCTestModule |
|
962 |
|
963 Description: Destructor |
|
964 |
|
965 Parameters: None. |
|
966 |
|
967 Return Values: None. |
|
968 |
|
969 Errors/Exceptions: None. |
|
970 |
|
971 Status: Approved |
|
972 |
|
973 ------------------------------------------------------------------------------- |
|
974 */ |
|
975 |
|
976 CTCTestModule::~CTCTestModule() |
|
977 { |
|
978 __TRACE( KMessage, ( _L("CTCTestModule::~CTCTestModule [%S]"), iModuleName)); |
|
979 |
|
980 // delete error printer |
|
981 delete iErrorPrinter; |
|
982 // Close handles |
|
983 if( iTestServer.Handle() != 0 ) |
|
984 { |
|
985 iTestModule.Close(); |
|
986 iTestServer.Close(); |
|
987 } |
|
988 delete iModuleName; |
|
989 delete iIniFile; |
|
990 delete iTestCases; |
|
991 } |
|
992 |
|
993 /* |
|
994 ------------------------------------------------------------------------------- |
|
995 |
|
996 Class: CTCTestModule |
|
997 |
|
998 Method: GetTestCasesForCombiner |
|
999 |
|
1000 Description: Get array of test cases (used to find test case number by title) |
|
1001 |
|
1002 Parameters: const TDesC& aConfigFile: in: config file name. |
|
1003 |
|
1004 Return Values: None. |
|
1005 |
|
1006 Errors/Exceptions: None. |
|
1007 |
|
1008 Status: Proposal |
|
1009 |
|
1010 ------------------------------------------------------------------------------- |
|
1011 */ |
|
1012 void CTCTestModule::GetTestCasesForCombiner(const TDesC& aConfigFile) |
|
1013 { |
|
1014 __TRACE(KMessage, (_L("Going to enumerate test cases for TestCombiner"))); |
|
1015 TName configFile(aConfigFile); |
|
1016 |
|
1017 // Enumerate test cases |
|
1018 TCaseCount caseCount; |
|
1019 TRequestStatus status; |
|
1020 iTestModule.EnumerateTestCases(configFile, caseCount, status); |
|
1021 User::WaitForRequest(status); |
|
1022 |
|
1023 // Check that enumerate succeeded |
|
1024 if(status != KErrNone) |
|
1025 { |
|
1026 __TRACE(KMessage, (_L("Enumerating test cases from module returned error. Status %d."), status.Int())); |
|
1027 return; |
|
1028 } |
|
1029 __TRACE(KMessage, (_L("Enumeration for TestCombiner returned %d cases"), caseCount())); |
|
1030 |
|
1031 // Get test cases to buffer |
|
1032 iTestCases = CFixedFlatArray<TTestCaseInfo>::NewL(caseCount()); |
|
1033 |
|
1034 TInt ret = iTestModule.GetTestCases(*iTestCases); |
|
1035 if(ret != KErrNone) |
|
1036 { |
|
1037 __TRACE(KMessage, (_L("Getting test cases from module returned error %d."), ret)); |
|
1038 return; |
|
1039 } |
|
1040 |
|
1041 __TRACE(KMessage, (_L("Test cases for TestCombiner have been enumerated"))); |
|
1042 } |
|
1043 |
|
1044 |
|
1045 /* |
|
1046 ------------------------------------------------------------------------------- |
|
1047 |
|
1048 Class: CTCTestModule |
|
1049 |
|
1050 Method: GetCaseNumByTitle |
|
1051 |
|
1052 Description: Finds test case index by title |
|
1053 |
|
1054 Parameters: TDesC& aTitle: in: test case title. |
|
1055 TInt& aCaseNum: in out: test case index |
|
1056 |
|
1057 Return Values: KErrNone if everything is ok |
|
1058 KErrNotFound if there is no such test case |
|
1059 |
|
1060 Errors/Exceptions: None. |
|
1061 |
|
1062 Status: Proposal |
|
1063 |
|
1064 ------------------------------------------------------------------------------- |
|
1065 */ |
|
1066 TInt CTCTestModule::GetCaseNumByTitle(TDesC& aTitle, TInt& aCaseNum) |
|
1067 { |
|
1068 for(TInt i = 0; i < iTestCases->Count(); i++) |
|
1069 { |
|
1070 if((*iTestCases)[i].iTitle == aTitle) |
|
1071 { |
|
1072 aCaseNum = i; |
|
1073 //TestScripter relies on 1-based indexing |
|
1074 if((iModuleName->Find(KTestScripterName) != KErrNotFound) || (iModuleName->Find(KPythonScripter) != KErrNotFound) || (iModuleName->Find(KTestCombinerName) != KErrNotFound)) |
|
1075 aCaseNum++; |
|
1076 return KErrNone; |
|
1077 } |
|
1078 } |
|
1079 |
|
1080 return KErrNotFound; |
|
1081 } |
|
1082 |
|
1083 /* |
|
1084 ------------------------------------------------------------------------------- |
|
1085 |
|
1086 DESCRIPTION |
|
1087 |
|
1088 This module contains the implementation of CRemoteSendReceive class |
|
1089 member functions. |
|
1090 |
|
1091 ------------------------------------------------------------------------------- |
|
1092 */ |
|
1093 |
|
1094 // ================= MEMBER FUNCTIONS ========================================= |
|
1095 |
|
1096 /* |
|
1097 ------------------------------------------------------------------------------- |
|
1098 |
|
1099 Class: CRemoteSendReceive |
|
1100 |
|
1101 Method: CRemoteSendReceive |
|
1102 |
|
1103 Description: Default constructor |
|
1104 |
|
1105 C++ default constructor can NOT contain any code, that |
|
1106 might leave. |
|
1107 |
|
1108 Parameters: |
|
1109 |
|
1110 Return Values: None. |
|
1111 |
|
1112 Errors/Exceptions: None. |
|
1113 |
|
1114 Status: Proposal |
|
1115 |
|
1116 ------------------------------------------------------------------------------- |
|
1117 */ |
|
1118 CRemoteSendReceive::CRemoteSendReceive( CTestCombiner* aTestCombiner ) : |
|
1119 iTestCombiner( aTestCombiner ) |
|
1120 { |
|
1121 // None |
|
1122 |
|
1123 } |
|
1124 |
|
1125 /* |
|
1126 ------------------------------------------------------------------------------- |
|
1127 |
|
1128 Class: CRemoteSendReceive |
|
1129 |
|
1130 Method: ConstructL |
|
1131 |
|
1132 Description: Symbian OS second phase constructor |
|
1133 |
|
1134 Symbian OS default constructor can leave. |
|
1135 |
|
1136 Parameters: None. |
|
1137 |
|
1138 Return Values: None. |
|
1139 |
|
1140 Errors/Exceptions: None |
|
1141 |
|
1142 Status: Proposal |
|
1143 |
|
1144 ------------------------------------------------------------------------------- |
|
1145 */ |
|
1146 void CRemoteSendReceive::ConstructL() |
|
1147 { |
|
1148 // None |
|
1149 |
|
1150 } |
|
1151 |
|
1152 /* |
|
1153 ------------------------------------------------------------------------------- |
|
1154 |
|
1155 Class: CRemoteSendReceive |
|
1156 |
|
1157 Method: NewL |
|
1158 |
|
1159 Description: Two-phased constructor. |
|
1160 |
|
1161 Parameters: |
|
1162 |
|
1163 Return Values: CRemoteTestCase*: pointer to new CRemoteTestCase object |
|
1164 |
|
1165 Errors/Exceptions: Leaves if new or ConstructL leaves. |
|
1166 |
|
1167 Status: Proposal |
|
1168 |
|
1169 ------------------------------------------------------------------------------- |
|
1170 */ |
|
1171 CRemoteSendReceive* CRemoteSendReceive::NewL( CTestCombiner* aTestCombiner ) |
|
1172 { |
|
1173 CRemoteSendReceive* self = new (ELeave) CRemoteSendReceive( aTestCombiner ); |
|
1174 |
|
1175 CleanupStack::PushL( self ); |
|
1176 self->ConstructL(); |
|
1177 CleanupStack::Pop(); |
|
1178 return self; |
|
1179 |
|
1180 } |
|
1181 |
|
1182 /* |
|
1183 ------------------------------------------------------------------------------- |
|
1184 |
|
1185 Class: CRemoteSendReceive |
|
1186 |
|
1187 Method: ~CRemoteSendReceive |
|
1188 |
|
1189 Description: Destructor |
|
1190 |
|
1191 Parameters: None. |
|
1192 |
|
1193 Return Values: None. |
|
1194 |
|
1195 Errors/Exceptions: None. |
|
1196 |
|
1197 Status: Proposal |
|
1198 |
|
1199 ------------------------------------------------------------------------------- |
|
1200 */ |
|
1201 CRemoteSendReceive::~CRemoteSendReceive() |
|
1202 { |
|
1203 // None |
|
1204 |
|
1205 } |
|
1206 |
|
1207 // End of File |
|