|
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: CUIEngineRemote: This object executes test cases |
|
15 * from STIF Test Framework. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32base.h> |
|
21 #include <e32svr.h> |
|
22 #include <stifinternal/UIEngineContainer.h> |
|
23 #include "UIEngineRemote.h" |
|
24 #include "Logging.h" |
|
25 |
|
26 |
|
27 // EXTERNAL DATA STRUCTURES |
|
28 // None |
|
29 |
|
30 // EXTERNAL FUNCTION PROTOTYPES |
|
31 // None |
|
32 |
|
33 // CONSTANTS |
|
34 // None |
|
35 |
|
36 // MACROS |
|
37 #ifdef LOGGER |
|
38 #undef LOGGER |
|
39 #endif |
|
40 #define LOGGER iUIEngineContainer->iUIEngine->iLogger |
|
41 |
|
42 |
|
43 // LOCAL CONSTANTS AND MACROS |
|
44 // None |
|
45 |
|
46 // MODULE DATA STRUCTURES |
|
47 // None |
|
48 |
|
49 // LOCAL FUNCTION PROTOTYPES |
|
50 // None |
|
51 |
|
52 // FORWARD DECLARATIONS |
|
53 // None |
|
54 |
|
55 |
|
56 // ==================== LOCAL FUNCTIONS ======================================= |
|
57 // None |
|
58 |
|
59 // ================= MEMBER FUNCTIONS ========================================= |
|
60 |
|
61 /* |
|
62 ------------------------------------------------------------------------------- |
|
63 |
|
64 Class: CUIEngineRemote |
|
65 |
|
66 Method: CUIEngineRemote |
|
67 |
|
68 Description: Default constructor |
|
69 |
|
70 C++ default constructor can NOT contain any code, that |
|
71 might leave. |
|
72 |
|
73 Parameters: None |
|
74 |
|
75 Return Values: None |
|
76 |
|
77 Errors/Exceptions: None |
|
78 |
|
79 Status: Draft |
|
80 |
|
81 ------------------------------------------------------------------------------- |
|
82 */ |
|
83 CUIEngineRemote::CUIEngineRemote( CUIEngineContainer* aUIEngineContainer) : |
|
84 CActive( CActive::EPriorityStandard ), |
|
85 iUIEngineContainer( aUIEngineContainer ), |
|
86 iRemoteTypePckg ( iRemoteType ), |
|
87 iMsgLenPckg ( iMsgLen ), |
|
88 iState( EIdle ) |
|
89 { |
|
90 __TRACE( KPrint, ( _L( "CUIEngineRemote::CUIEngineRemote") ) ); |
|
91 __ASSERT_ALWAYS( aUIEngineContainer, User::Panic( _L("Null pointer"), KErrGeneral ) ); |
|
92 |
|
93 CActiveScheduler::Add( this ); |
|
94 } |
|
95 |
|
96 |
|
97 /* |
|
98 ------------------------------------------------------------------------------- |
|
99 |
|
100 Class: CUIEngineRemote |
|
101 |
|
102 Method: ConstructL |
|
103 |
|
104 Description: Symbian OS second phase constructor |
|
105 |
|
106 Symbian OS default constructor can leave. |
|
107 |
|
108 Parameters: None |
|
109 |
|
110 Return Values: None |
|
111 |
|
112 Errors/Exceptions: Leaves if called Open method returns error |
|
113 |
|
114 Status: Approved |
|
115 |
|
116 ------------------------------------------------------------------------------- |
|
117 */ |
|
118 void CUIEngineRemote::ConstructL() |
|
119 { |
|
120 |
|
121 } |
|
122 |
|
123 |
|
124 /* |
|
125 ------------------------------------------------------------------------------- |
|
126 |
|
127 Class: CUIEngineRemote |
|
128 |
|
129 Method: NewL |
|
130 |
|
131 Description: Two-phased constructor. |
|
132 |
|
133 Parameters: CUIEngineContainer* CUIEngineContainer: in: Pointer to CUIEngineContainer Interface |
|
134 TTestInfo& aTestInfo: in: Test info |
|
135 |
|
136 Return Values: CUIEngineRemote* : Pointer to created runner object |
|
137 |
|
138 Errors/Exceptions: Leaves if memory allocation for CUIEngineRemote fails |
|
139 Leaves if ConstructL leaves |
|
140 |
|
141 Status: Draft |
|
142 |
|
143 ------------------------------------------------------------------------------- |
|
144 */ |
|
145 CUIEngineRemote* CUIEngineRemote::NewL( CUIEngineContainer* aUIEngineContainer ) |
|
146 { |
|
147 |
|
148 CUIEngineRemote* self = |
|
149 new ( ELeave ) CUIEngineRemote( aUIEngineContainer ); |
|
150 CleanupStack::PushL( self ); |
|
151 self->ConstructL(); |
|
152 CleanupStack::Pop(); |
|
153 return self; |
|
154 |
|
155 } |
|
156 |
|
157 |
|
158 /* |
|
159 ------------------------------------------------------------------------------- |
|
160 |
|
161 Class: CUIEngineRemote |
|
162 |
|
163 Method: ~CUIEngineRemote |
|
164 |
|
165 Description: Destructor |
|
166 |
|
167 Parameters: None |
|
168 |
|
169 Return Values: None |
|
170 |
|
171 Errors/Exceptions: None |
|
172 |
|
173 Status: Draft |
|
174 |
|
175 ------------------------------------------------------------------------------- |
|
176 */ |
|
177 CUIEngineRemote::~CUIEngineRemote() |
|
178 { |
|
179 __TRACE( KPrint, ( _L( "CUIEngineRemote::~CUIEngineRemote()") ) ); |
|
180 Cancel(); |
|
181 |
|
182 } |
|
183 |
|
184 |
|
185 /* |
|
186 ------------------------------------------------------------------------------- |
|
187 |
|
188 Class: CUIEngineRemote |
|
189 |
|
190 Method: StartTestL |
|
191 |
|
192 Description: Starts testing |
|
193 |
|
194 Parameters: RTestCase& aTestCase: in: Handle to test case |
|
195 TFullTestResultPckg& aFullTestResultPckg: in: Handle to TFullTestResultPckg |
|
196 |
|
197 Return Values: None |
|
198 |
|
199 Errors/Exceptions: None |
|
200 |
|
201 Status: Draft |
|
202 |
|
203 ------------------------------------------------------------------------------- |
|
204 */ |
|
205 void CUIEngineRemote::StartL( RTestCase& aTestCase ) |
|
206 { |
|
207 __TRACE( KPrint, ( _L( "CUIEngineRemote::StartL") ) ); |
|
208 |
|
209 iTestCase = aTestCase; |
|
210 |
|
211 if ( IsActive() ) |
|
212 User::Leave( KErrInUse ); |
|
213 |
|
214 Start(); |
|
215 |
|
216 } |
|
217 |
|
218 /* |
|
219 ------------------------------------------------------------------------------- |
|
220 |
|
221 Class: CUIEngineRemote |
|
222 |
|
223 Method: Start |
|
224 |
|
225 Description: Start request |
|
226 |
|
227 Parameters: None |
|
228 |
|
229 Return Values: None |
|
230 |
|
231 Errors/Exceptions: None |
|
232 |
|
233 Status: Draft |
|
234 |
|
235 ------------------------------------------------------------------------------- |
|
236 */ |
|
237 void CUIEngineRemote::Start() |
|
238 { |
|
239 __TRACE( KPrint, ( _L( "CUIEngineRemote::Start") ) ); |
|
240 |
|
241 iState = EPending; |
|
242 SetActive(); |
|
243 iTestCase.NotifyRemoteType( iRemoteTypePckg, iMsgLenPckg, iStatus ); |
|
244 |
|
245 } |
|
246 |
|
247 /* |
|
248 ------------------------------------------------------------------------------- |
|
249 |
|
250 Class: CUIEngineRemote |
|
251 |
|
252 Method: RunL |
|
253 |
|
254 Description: RunL handles completed requests. |
|
255 |
|
256 Parameters: None |
|
257 |
|
258 Return Values: None |
|
259 |
|
260 Errors/Exceptions: Leaves if iStatus is not KErrNone, error is handled in |
|
261 RunError called by CActiveObject |
|
262 |
|
263 Status: Draft |
|
264 |
|
265 ------------------------------------------------------------------------------- |
|
266 */ |
|
267 void CUIEngineRemote::RunL() |
|
268 { |
|
269 __TRACE( KPrint, ( _L( "CUIEngineRemote::RunL") ) ); |
|
270 |
|
271 switch( iState ) |
|
272 { |
|
273 case EPending: |
|
274 iState = EIdle; |
|
275 |
|
276 switch( iRemoteType ) |
|
277 { |
|
278 case EStifCmdSend: // Sending message |
|
279 { |
|
280 if( iMsgLen <= 0 ) |
|
281 { |
|
282 User::Leave( KErrGeneral ); |
|
283 } |
|
284 HBufC8* buf = HBufC8::NewLC( iMsgLen ); |
|
285 TPtr8 tmp = buf->Des(); |
|
286 if( iTestCase.NotifyRemoteMsg( tmp, iRemoteType ) == KErrNone ) |
|
287 { |
|
288 HBufC* buf2 = HBufC::NewLC( iMsgLen ); |
|
289 TPtr tmp2 = buf2->Des(); |
|
290 tmp2.Copy( tmp ); |
|
291 |
|
292 // Forward message |
|
293 iUIEngineContainer->RemoteSend( tmp2, iStatus.Int() ); |
|
294 CleanupStack::PopAndDestroy( buf2 ); |
|
295 } |
|
296 CleanupStack::PopAndDestroy( buf ); |
|
297 } |
|
298 break; |
|
299 case EStifCmdStoreState: // Got indication that reboot will follow |
|
300 { |
|
301 // System will reboot, inform UI |
|
302 // Forward message |
|
303 SetActive(); |
|
304 TInt ret = iUIEngineContainer->GoingToReboot( iStatus ); |
|
305 if( ret != KErrNone ) |
|
306 { |
|
307 User::Leave( ret ); |
|
308 } |
|
309 iState = EUIMsgPending; |
|
310 return; |
|
311 } |
|
312 // The rest should never come here |
|
313 case EStifCmdReboot: |
|
314 case EStifCmdReceive: |
|
315 case EStifCmdGetStoredState: |
|
316 default: |
|
317 { |
|
318 if( iStatus.Int() != KErrServerTerminated ) |
|
319 { |
|
320 RDebug::Print( _L("CUIEngineRemote::RunL() -- Leaved with [%d] "), iStatus.Int() ); |
|
321 User::Leave( KErrNotFound ); |
|
322 } |
|
323 break; |
|
324 } |
|
325 } |
|
326 break; |
|
327 case EUIMsgPending: |
|
328 { |
|
329 TInt result = iStatus.Int(); |
|
330 if( result == KErrCancel ) |
|
331 { |
|
332 result = KErrNone; |
|
333 } |
|
334 // Let the system to reboot.. |
|
335 TPckg<TInt> tmp( result ); |
|
336 iTestCase.NotifyRemoteMsg( tmp, EStifCmdRebootProceed ); |
|
337 Start(); |
|
338 return; |
|
339 } |
|
340 default: |
|
341 User::Leave( KErrGeneral ); |
|
342 } |
|
343 |
|
344 if( iStatus.Int() == KErrNone ) |
|
345 { |
|
346 Start(); |
|
347 } |
|
348 |
|
349 } |
|
350 |
|
351 /* |
|
352 ------------------------------------------------------------------------------- |
|
353 |
|
354 Class: CUIEngineRemote |
|
355 |
|
356 Method: DoCancel |
|
357 |
|
358 Description: Cancel active request. |
|
359 |
|
360 Parameters: None |
|
361 |
|
362 Return Values: None |
|
363 |
|
364 Errors/Exceptions: None |
|
365 |
|
366 Status: Draft |
|
367 |
|
368 ------------------------------------------------------------------------------- |
|
369 */ |
|
370 void CUIEngineRemote::DoCancel() |
|
371 { |
|
372 __TRACE( KPrint, ( _L( "CUIEngineRemote::DoCancel") ) ); |
|
373 iTestCase.CancelAsyncRequest( ETestCaseNotifyRemoteType ); |
|
374 |
|
375 } |
|
376 /* |
|
377 ------------------------------------------------------------------------------- |
|
378 |
|
379 Class: CUIEngineRemote |
|
380 |
|
381 Method: RunError |
|
382 |
|
383 Description: None |
|
384 |
|
385 Parameters: TInt aError: in: Symbian error code |
|
386 |
|
387 Return Values: Error code |
|
388 |
|
389 Errors/Exceptions: None |
|
390 |
|
391 Status: Draft |
|
392 |
|
393 ------------------------------------------------------------------------------- |
|
394 */ |
|
395 TInt CUIEngineRemote::RunError(TInt aError) |
|
396 { |
|
397 return aError; |
|
398 } |
|
399 |
|
400 /* |
|
401 ------------------------------------------------------------------------------- |
|
402 |
|
403 DESCRIPTION |
|
404 |
|
405 CActiveTimer: This object prints running seconds to console screen. |
|
406 |
|
407 ------------------------------------------------------------------------------- |
|
408 */ |
|
409 |
|
410 // ================= MEMBER FUNCTIONS ========================================= |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 // ================= OTHER EXPORTED FUNCTIONS ================================= |
|
416 // None |
|
417 |
|
418 // End of File |