|
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: CUIEnginePrinter handles prints from test cases. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <e32base.h> |
|
20 #include <e32svr.h> |
|
21 #include <stifinternal/UIEngineContainer.h> |
|
22 #include "UIEnginePrinter.h" |
|
23 #include "Logging.h" |
|
24 |
|
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 iUIEngineContainer->iUIEngine->iLogger |
|
40 |
|
41 |
|
42 // LOCAL CONSTANTS AND MACROS |
|
43 // None |
|
44 |
|
45 // MODULE DATA STRUCTURES |
|
46 // None |
|
47 |
|
48 // LOCAL FUNCTION PROTOTYPES |
|
49 // None |
|
50 |
|
51 // FORWARD DECLARATIONS |
|
52 // None |
|
53 |
|
54 |
|
55 // ==================== LOCAL FUNCTIONS ======================================= |
|
56 // None |
|
57 |
|
58 // ================= MEMBER FUNCTIONS ========================================= |
|
59 |
|
60 /* |
|
61 ------------------------------------------------------------------------------- |
|
62 |
|
63 Class: CUIEnginePrinter |
|
64 |
|
65 Method: NewL |
|
66 |
|
67 Description: Two-phased constructor. |
|
68 |
|
69 Parameters: CUIEngineContainer* CUIEngineContainer: in: Pointer to CUIEngineContainer Interface |
|
70 TTestInfo& aTestInfo: in: Test info |
|
71 |
|
72 Return Values: CUIEnginePrinter* : Pointer to created runner object |
|
73 |
|
74 Errors/Exceptions: Leaves if memory allocation for CUIEnginePrinter fails |
|
75 Leaves if ConstructL leaves |
|
76 |
|
77 Status: Approved |
|
78 |
|
79 ------------------------------------------------------------------------------- |
|
80 */ |
|
81 CUIEnginePrinter* CUIEnginePrinter::NewL( |
|
82 CUIEngineContainer* aUIEngineContainer ) |
|
83 { |
|
84 CUIEnginePrinter* self = |
|
85 new ( ELeave ) CUIEnginePrinter( aUIEngineContainer ); |
|
86 CleanupStack::PushL( self ); |
|
87 self->ConstructL(); |
|
88 CleanupStack::Pop(); |
|
89 return self; |
|
90 } |
|
91 |
|
92 /* |
|
93 ------------------------------------------------------------------------------- |
|
94 |
|
95 Class: CUIEnginePrinter |
|
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 called Open method returns error |
|
108 |
|
109 Status: Draft |
|
110 |
|
111 ------------------------------------------------------------------------------- |
|
112 */ |
|
113 void CUIEnginePrinter::ConstructL() |
|
114 { |
|
115 |
|
116 } |
|
117 |
|
118 /* |
|
119 ------------------------------------------------------------------------------- |
|
120 |
|
121 Class: CUIEnginePrinter |
|
122 |
|
123 Method: CUIEnginePrinter |
|
124 |
|
125 Description: Default constructor |
|
126 |
|
127 C++ default constructor can NOT contain any code, that |
|
128 might leave. |
|
129 |
|
130 Parameters: None |
|
131 |
|
132 Return Values: None |
|
133 |
|
134 Errors/Exceptions: None |
|
135 |
|
136 Status: Draft |
|
137 |
|
138 ------------------------------------------------------------------------------- |
|
139 */ |
|
140 CUIEnginePrinter::CUIEnginePrinter( |
|
141 CUIEngineContainer* aUIEngineContainer ) : |
|
142 CActive( CActive::EPriorityStandard ), |
|
143 iUIEngineContainer( aUIEngineContainer ), |
|
144 iProgressPckg( iProgress ), |
|
145 iRunning( EFalse ) |
|
146 { |
|
147 __TRACE( KPrint, ( _L( "CUIEnginePrinter::CUIEnginePrinter") ) ); |
|
148 __ASSERT_ALWAYS( aUIEngineContainer, User::Panic( _L("Null pointer"), KErrGeneral ) ); |
|
149 |
|
150 CActiveScheduler::Add( this ); |
|
151 |
|
152 } |
|
153 |
|
154 /* |
|
155 ------------------------------------------------------------------------------- |
|
156 |
|
157 Class: CUIEnginePrinter |
|
158 |
|
159 Method: ~CUIEnginePrinter |
|
160 |
|
161 Description: Destructor |
|
162 |
|
163 Parameters: None |
|
164 |
|
165 Return Values: None |
|
166 |
|
167 Errors/Exceptions: None |
|
168 |
|
169 Status: Draft |
|
170 |
|
171 ------------------------------------------------------------------------------- |
|
172 */ |
|
173 CUIEnginePrinter::~CUIEnginePrinter() |
|
174 { |
|
175 __TRACE( KPrint, ( _L( "CUIEnginePrinter::~CUIEnginePrinter") ) ); |
|
176 |
|
177 Cancel(); |
|
178 |
|
179 } |
|
180 |
|
181 /* |
|
182 ------------------------------------------------------------------------------- |
|
183 |
|
184 Class: CUIEnginePrinter |
|
185 |
|
186 Method: StartProgressL |
|
187 |
|
188 Description: Starts testing |
|
189 |
|
190 Parameters: RTestCase& aTestCase: in: Handle to test case |
|
191 TTestProgressPckg& aProgressPckg: in: Handle to TTestProgressPckg |
|
192 |
|
193 Return Values: None |
|
194 |
|
195 Errors/Exceptions: None |
|
196 |
|
197 Status: Draft |
|
198 |
|
199 ------------------------------------------------------------------------------- |
|
200 */ |
|
201 void CUIEnginePrinter::StartL( RTestCase& aTestCase ) |
|
202 { |
|
203 __TRACE( KPrint, ( _L( "CUIEnginePrinter::StartProgressL.") ) ); |
|
204 |
|
205 iTestCase = aTestCase; |
|
206 |
|
207 if ( IsActive() ) |
|
208 User::Leave( KErrInUse ); |
|
209 |
|
210 iRunning = ETrue; |
|
211 |
|
212 SetActive(); |
|
213 iTestCase.NotifyProgress( iProgressPckg, iStatus ); |
|
214 } |
|
215 |
|
216 |
|
217 /* |
|
218 ------------------------------------------------------------------------------- |
|
219 |
|
220 Class: CUIEnginePrinter |
|
221 |
|
222 Method: RunL |
|
223 |
|
224 Description: RunL handles completed requests |
|
225 |
|
226 Parameters: None |
|
227 |
|
228 Return Values: None |
|
229 |
|
230 Errors/Exceptions: Leaves if iStatus is not KErrNone, error is handled in |
|
231 RunError called by CActiveObject |
|
232 |
|
233 Status: Draft |
|
234 |
|
235 ------------------------------------------------------------------------------- |
|
236 */ |
|
237 void CUIEnginePrinter::RunL() |
|
238 { |
|
239 |
|
240 if( iStatus != KErrNone ) |
|
241 { |
|
242 // KErrEof and other errors |
|
243 iRunning = EFalse; |
|
244 // Signal to container |
|
245 iUIEngineContainer->PrintsDone(); |
|
246 return; |
|
247 } |
|
248 |
|
249 iUIEngineContainer->PrintProgress( iProgress ); |
|
250 |
|
251 // Start a new request |
|
252 SetActive(); |
|
253 iTestCase.NotifyProgress( iProgressPckg, iStatus ); |
|
254 |
|
255 } |
|
256 |
|
257 /* |
|
258 ------------------------------------------------------------------------------- |
|
259 |
|
260 Class: CUIEnginePrinter |
|
261 |
|
262 Method: DoCancel |
|
263 |
|
264 Description: Cancel active request. |
|
265 |
|
266 Parameters: None |
|
267 |
|
268 Return Values: None |
|
269 |
|
270 Errors/Exceptions: None |
|
271 |
|
272 Status: Draft |
|
273 |
|
274 ------------------------------------------------------------------------------- |
|
275 */ |
|
276 void CUIEnginePrinter::DoCancel() |
|
277 { |
|
278 __TRACE( KPrint, ( _L( "CUIEnginePrinter::DoCancel") ) ); |
|
279 |
|
280 iRunning = EFalse; |
|
281 |
|
282 iTestCase.CancelAsyncRequest( ETestCaseNotifyProgress ); |
|
283 |
|
284 } |
|
285 |
|
286 |
|
287 // ================= OTHER EXPORTED FUNCTIONS ================================= |
|
288 // None |
|
289 |
|
290 // End of File |