|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include "ActiveTestStep.h" |
|
23 #include <test/appfwk_test_appui.h> |
|
24 |
|
25 _LIT(KTestDied, "Test step died with errno = %d"); |
|
26 |
|
27 void CActiveTestStepScheduler::Error(TInt aError) const |
|
28 { |
|
29 iStep->Stop(aError); // Generally this doesn't work, but it's a good place to break |
|
30 }; |
|
31 |
|
32 CActiveTestStepLauncher::CActiveTestStepLauncher() : |
|
33 CActive(EPriorityNormal), |
|
34 iVerdict(EAbort) |
|
35 { |
|
36 } |
|
37 |
|
38 CActiveTestStepLauncher::~CActiveTestStepLauncher() |
|
39 { |
|
40 Cancel(); |
|
41 } |
|
42 |
|
43 void CActiveTestStepLauncher::RunL() |
|
44 { |
|
45 TRAPD(err, iVerdict = iStep->doActiveTestStepL()); |
|
46 iStep->Stop(err); |
|
47 } |
|
48 |
|
49 void CActiveTestStepLauncher::DoCancel() |
|
50 { |
|
51 iStep->Stop(KErrCancel); |
|
52 } |
|
53 |
|
54 void CActiveTestStepLauncher::Launch(CActiveTestStep* aStep) |
|
55 { |
|
56 iStep = aStep; |
|
57 CActiveScheduler::Add(this); |
|
58 TRequestStatus * status = &iStatus; |
|
59 User::RequestComplete(status, KErrNone); |
|
60 SetActive(); |
|
61 } |
|
62 |
|
63 CActiveTestStep::CActiveTestStep() |
|
64 { |
|
65 } |
|
66 |
|
67 CActiveTestStep::~CActiveTestStep() |
|
68 { |
|
69 if(iLauncher) |
|
70 iLauncher->Cancel(); |
|
71 delete iLauncher; |
|
72 delete iScheduler; |
|
73 } |
|
74 |
|
75 TVerdict CActiveTestStep::doTestStepPreambleL() |
|
76 { |
|
77 SetTestStepResult(EPass); |
|
78 return TestStepResult(); |
|
79 } |
|
80 |
|
81 TVerdict CActiveTestStep::doTestStepL() |
|
82 { |
|
83 if(TestStepResult() == EPass) |
|
84 { |
|
85 iScheduler = new (ELeave) CActiveTestStepScheduler; |
|
86 CActiveScheduler::Install(iScheduler); |
|
87 |
|
88 iLauncher = new CActiveTestStepLauncher; |
|
89 iLauncher->Launch(this); |
|
90 iScheduler->Start(); |
|
91 |
|
92 SetTestStepResult(iLauncher->TestStepResult()); |
|
93 } |
|
94 return TestStepResult(); |
|
95 } |
|
96 |
|
97 TVerdict CActiveTestStep::doTestStepPostambleL() |
|
98 { |
|
99 return TestStepResult(); |
|
100 } |
|
101 |
|
102 void CActiveTestStep::Stop(TInt aError) |
|
103 { |
|
104 if(aError != KErrNone) |
|
105 { |
|
106 ERR_PRINTF2(KTestDied, aError); |
|
107 iLauncher->SetTestStepResult(EFail); |
|
108 } |
|
109 iScheduler->Stop(); |
|
110 } |