2
|
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: CUIEngine: This object executes test cases from STIF
|
|
15 |
* Test Framework.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <e32base.h>
|
|
21 |
#include <e32svr.h>
|
|
22 |
#include <stifinternal/UIEngine.h>
|
|
23 |
#include <stifinternal/UIEngineContainer.h>
|
|
24 |
#include "UIEnginePrinter.h"
|
|
25 |
#include "UIEngineRunner.h"
|
|
26 |
#include "UIEngineRemote.h"
|
|
27 |
#include "Logging.h"
|
|
28 |
|
|
29 |
|
|
30 |
// EXTERNAL DATA STRUCTURES
|
|
31 |
// None
|
|
32 |
|
|
33 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
34 |
// None
|
|
35 |
|
|
36 |
// CONSTANTS
|
|
37 |
// None
|
|
38 |
|
|
39 |
// MACROS
|
|
40 |
#ifdef LOGGER
|
|
41 |
#undef LOGGER
|
|
42 |
#endif
|
|
43 |
#define LOGGER iUIEngine->iLogger
|
|
44 |
|
|
45 |
// LOCAL CONSTANTS AND MACROS
|
|
46 |
// None
|
|
47 |
|
|
48 |
// MODULE DATA STRUCTURES
|
|
49 |
// None
|
|
50 |
|
|
51 |
// LOCAL FUNCTION PROTOTYPES
|
|
52 |
// None
|
|
53 |
|
|
54 |
// FORWARD DECLARATIONS
|
|
55 |
// None
|
|
56 |
|
|
57 |
// ==================== LOCAL FUNCTIONS =======================================
|
|
58 |
// None
|
|
59 |
|
|
60 |
// ================= MEMBER FUNCTIONS =========================================
|
|
61 |
|
|
62 |
|
|
63 |
/*
|
|
64 |
-------------------------------------------------------------------------------
|
|
65 |
|
|
66 |
Class: CUIEngineContainer
|
|
67 |
|
|
68 |
Method: CUIEngineContainer
|
|
69 |
|
|
70 |
Description: Default constructor
|
|
71 |
|
|
72 |
C++ default constructor can NOT contain any code, that
|
|
73 |
might leave.
|
|
74 |
|
|
75 |
Parameters: CUIEngine* aUIEngine: in: Pointer to CUIEngine interface
|
|
76 |
TTestInfo& aTestInfo: in: Test information
|
|
77 |
|
|
78 |
Return Values: None
|
|
79 |
|
|
80 |
Errors/Exceptions: None
|
|
81 |
|
|
82 |
Status: Draft
|
|
83 |
|
|
84 |
-------------------------------------------------------------------------------
|
|
85 |
*/
|
|
86 |
CUIEngineContainer::CUIEngineContainer( CUIEngine* aUIEngine,
|
|
87 |
const TTestInfo& aTestInfo,
|
|
88 |
RTestEngine& aTestEngine ) :
|
|
89 |
iUIEngine( aUIEngine ),
|
|
90 |
iTestInfo( aTestInfo ),
|
|
91 |
iTestInfoPckg( iTestInfo ),
|
|
92 |
iState( ENotStarted )
|
|
93 |
{
|
|
94 |
__TRACE( KPrint, ( _L( "CUIEngineContainer::CUIEngineContainer.") ) );
|
|
95 |
|
|
96 |
iTestEngine = aTestEngine;
|
|
97 |
|
|
98 |
__ASSERT_ALWAYS( aUIEngine, User::Panic( _L("Null pointer"), KErrGeneral ) );
|
|
99 |
|
|
100 |
}
|
|
101 |
|
|
102 |
/*
|
|
103 |
-------------------------------------------------------------------------------
|
|
104 |
|
|
105 |
Class: CUIEngineContainer
|
|
106 |
|
|
107 |
Method: ConstructL
|
|
108 |
|
|
109 |
Description: Symbian OS second phase constructor
|
|
110 |
|
|
111 |
Symbian OS default constructor can leave
|
|
112 |
|
|
113 |
Parameters: None
|
|
114 |
|
|
115 |
Return Values: None
|
|
116 |
|
|
117 |
Errors/Exceptions: Leaves if called Open method returns error
|
|
118 |
|
|
119 |
Status: Draft
|
|
120 |
|
|
121 |
-------------------------------------------------------------------------------
|
|
122 |
*/
|
|
123 |
void CUIEngineContainer::ConstructL()
|
|
124 |
{
|
|
125 |
__TRACE( KPrint, ( _L( "CUIEngineContainer::ConstructL.") ) );
|
|
126 |
|
|
127 |
// Open test case
|
|
128 |
User::LeaveIfError( iTestCase.Open( iTestEngine, iTestInfoPckg ) );
|
|
129 |
}
|
|
130 |
|
|
131 |
/*
|
|
132 |
-------------------------------------------------------------------------------
|
|
133 |
|
|
134 |
Class: CUIEngineContainer
|
|
135 |
|
|
136 |
Method: NewL
|
|
137 |
|
|
138 |
Description: Two-phased constructor.
|
|
139 |
|
|
140 |
Parameters: CUIEngine* aUIEngine: in: pointer to CUIEngine Interface
|
|
141 |
TTestInfo& aTestInfo: in: Test info
|
|
142 |
|
|
143 |
Return Values: CUIEngineRunner* : pointer to created runner object
|
|
144 |
|
|
145 |
Errors/Exceptions: Leaves if memory allocation for CUIEngineRunner fails
|
|
146 |
Leaves if ConstructL leaves
|
|
147 |
|
|
148 |
Status: Draft
|
|
149 |
|
|
150 |
-------------------------------------------------------------------------------
|
|
151 |
*/
|
|
152 |
CUIEngineContainer* CUIEngineContainer::NewL( CUIEngine* aUIEngine,
|
|
153 |
const TTestInfo& aTestInfo,
|
|
154 |
RTestEngine& aTestEngine )
|
|
155 |
{
|
|
156 |
CUIEngineContainer* self =
|
|
157 |
new ( ELeave ) CUIEngineContainer( aUIEngine,
|
|
158 |
aTestInfo,
|
|
159 |
aTestEngine );
|
|
160 |
CleanupStack::PushL( self );
|
|
161 |
self->ConstructL();
|
|
162 |
CleanupStack::Pop();
|
|
163 |
return self;
|
|
164 |
}
|
|
165 |
|
|
166 |
/*
|
|
167 |
-------------------------------------------------------------------------------
|
|
168 |
|
|
169 |
Class: CUIEngineContainer
|
|
170 |
|
|
171 |
Method: ~CUIEngineContainer
|
|
172 |
|
|
173 |
Description: Destructor
|
|
174 |
|
|
175 |
Parameters: None
|
|
176 |
|
|
177 |
Return Values: None
|
|
178 |
|
|
179 |
Errors/Exceptions: None
|
|
180 |
|
|
181 |
Status: Draft
|
|
182 |
|
|
183 |
-------------------------------------------------------------------------------
|
|
184 |
*/
|
|
185 |
CUIEngineContainer::~CUIEngineContainer()
|
|
186 |
{
|
|
187 |
|
|
188 |
__TRACE( KPrint, ( _L( "CUIEngineContainer::~CUIEngineContainer.") ) );
|
|
189 |
|
|
190 |
delete iPrinter;
|
|
191 |
delete iRunner;
|
|
192 |
delete iRemote;
|
|
193 |
|
|
194 |
// Close test case
|
|
195 |
iTestCase.Close();
|
|
196 |
|
|
197 |
}
|
|
198 |
|
|
199 |
|
|
200 |
/*
|
|
201 |
-------------------------------------------------------------------------------
|
|
202 |
|
|
203 |
Class: CUIEngineContainer
|
|
204 |
|
|
205 |
Method: StartContinerL
|
|
206 |
|
|
207 |
Description: StartContinerL call CUIEngineRunner to starting test case execution
|
|
208 |
|
|
209 |
Parameters: None
|
|
210 |
|
|
211 |
Return Values: TInt KErrNone: Always returned KErrNone
|
|
212 |
|
|
213 |
Errors/Exceptions: None
|
|
214 |
|
|
215 |
Status: Draft
|
|
216 |
|
|
217 |
-------------------------------------------------------------------------------
|
|
218 |
*/
|
|
219 |
TInt CUIEngineContainer::StartContainerL()
|
|
220 |
{
|
|
221 |
|
|
222 |
__TRACE( KPrint, ( _L( "CUIEngineContainer::StartContainerL. Running test case: %S"),
|
|
223 |
&( iTestInfo.iTestCaseInfo.iTitle ) ) );
|
|
224 |
|
|
225 |
// Start printer
|
|
226 |
iPrinter = CUIEnginePrinter::NewL( this );
|
|
227 |
iPrinter->StartL( iTestCase );
|
|
228 |
|
|
229 |
// Start remote
|
|
230 |
iRemote = CUIEngineRemote::NewL( this );
|
|
231 |
iRemote->StartL( iTestCase );
|
|
232 |
|
|
233 |
// Start runner
|
|
234 |
iRunner = CUIEngineRunner::NewL( this );
|
|
235 |
iRunner->StartL( iTestCase );
|
|
236 |
|
|
237 |
// Update state of test case
|
|
238 |
iState = ERunning;
|
|
239 |
|
|
240 |
__TRACE( KPrint, ( _L( "CUIEngineContainer::StartContainerL: started") ) );
|
|
241 |
|
|
242 |
return KErrNone;
|
|
243 |
|
|
244 |
}
|
|
245 |
|
|
246 |
/*
|
|
247 |
-------------------------------------------------------------------------------
|
|
248 |
|
|
249 |
Class: CUIEngineContainer
|
|
250 |
|
|
251 |
Method: CancelTest
|
|
252 |
|
|
253 |
Description: CancelTest cancels test case execution
|
|
254 |
|
|
255 |
Parameters: None
|
|
256 |
|
|
257 |
Return Values: TInt KErrNone: Always returned KErrNone
|
|
258 |
|
|
259 |
Errors/Exceptions: None
|
|
260 |
|
|
261 |
Status: Draft
|
|
262 |
|
|
263 |
-------------------------------------------------------------------------------
|
|
264 |
*/
|
|
265 |
EXPORT_C TInt CUIEngineContainer::CancelTest()
|
|
266 |
{
|
|
267 |
|
|
268 |
if ( iState == ERunning || iState == EPaused )
|
|
269 |
{
|
|
270 |
__TRACE( KPrint, ( _L( "CUIEngineContainer::CancelTest") ) );
|
|
271 |
|
|
272 |
// Cancel test case execution
|
|
273 |
iTestCase.CancelAsyncRequest( RTestCase::ERunTestCase );
|
|
274 |
|
|
275 |
}
|
|
276 |
|
|
277 |
return KErrNone;
|
|
278 |
}
|
|
279 |
|
|
280 |
|
|
281 |
/*
|
|
282 |
-------------------------------------------------------------------------------
|
|
283 |
|
|
284 |
Class: CUIEngineContainer
|
|
285 |
|
|
286 |
Method: PauseTest
|
|
287 |
|
|
288 |
Description: PauseTest pauses test case execution
|
|
289 |
|
|
290 |
Parameters: None
|
|
291 |
|
|
292 |
Return Values: Symbian OS error: Error code
|
|
293 |
|
|
294 |
Errors/Exceptions: None
|
|
295 |
|
|
296 |
Status: Draft
|
|
297 |
|
|
298 |
-------------------------------------------------------------------------------
|
|
299 |
*/
|
|
300 |
EXPORT_C TInt CUIEngineContainer::PauseTest()
|
|
301 |
{
|
|
302 |
TInt ret(KErrNone);
|
|
303 |
|
|
304 |
if ( iState == ERunning )
|
|
305 |
{
|
|
306 |
ret = iTestCase.Pause();
|
|
307 |
|
|
308 |
__TRACE( KPrint, ( _L( "CUIEngineContainer::PauseTest. Ret = %d"), ret ) );
|
|
309 |
|
|
310 |
if ( ret == KErrNone)
|
|
311 |
{
|
|
312 |
iState = EPaused;
|
|
313 |
}
|
|
314 |
}
|
|
315 |
|
|
316 |
return ret;
|
|
317 |
}
|
|
318 |
|
|
319 |
|
|
320 |
/*
|
|
321 |
-------------------------------------------------------------------------------
|
|
322 |
|
|
323 |
Class: CUIEngineContainer
|
|
324 |
|
|
325 |
Method: ResumeTest
|
|
326 |
|
|
327 |
Description: PauseTest resumes test case execution
|
|
328 |
|
|
329 |
Parameters: None
|
|
330 |
|
|
331 |
Return Values: Symbian OS error: Error code
|
|
332 |
|
|
333 |
Errors/Exceptions: None
|
|
334 |
|
|
335 |
Status: Draft
|
|
336 |
|
|
337 |
-------------------------------------------------------------------------------
|
|
338 |
*/
|
|
339 |
EXPORT_C TInt CUIEngineContainer::ResumeTest()
|
|
340 |
{
|
|
341 |
TInt ret(KErrNone);
|
|
342 |
|
|
343 |
if ( iState == EPaused )
|
|
344 |
{
|
|
345 |
ret = iTestCase.Resume();
|
|
346 |
|
|
347 |
__TRACE( KPrint, ( _L( "CUIEngineContainer::ResumeTest. Ret = %d"), ret ) );
|
|
348 |
|
|
349 |
if ( ret == KErrNone)
|
|
350 |
{
|
|
351 |
iState = ERunning;
|
|
352 |
}
|
|
353 |
}
|
|
354 |
|
|
355 |
return ret;
|
|
356 |
}
|
|
357 |
|
|
358 |
|
|
359 |
/*
|
|
360 |
-------------------------------------------------------------------------------
|
|
361 |
|
|
362 |
Class: CUIEngineContainer
|
|
363 |
|
|
364 |
Method: TestCaseExecuted
|
|
365 |
|
|
366 |
Description: TestCaseExecuted informs that test case is executed
|
|
367 |
|
|
368 |
Parameters: TFullTestResult& aFullTestResult: in: Full information of
|
|
369 |
test case execution. Includes also test case results
|
|
370 |
|
|
371 |
Return Values: None
|
|
372 |
|
|
373 |
Errors/Exceptions: TInt KErrNone: Always returned KErrNone
|
|
374 |
|
|
375 |
Status: Draft
|
|
376 |
|
|
377 |
-------------------------------------------------------------------------------
|
|
378 |
*/
|
|
379 |
void CUIEngineContainer::TestCaseExecuted( TFullTestResult& aFullTestResult,
|
|
380 |
TInt aStatus )
|
|
381 |
{
|
|
382 |
|
|
383 |
iState = EExecuted;
|
|
384 |
|
|
385 |
// Set execution result
|
|
386 |
if( ( KErrNone != aStatus ) &&
|
|
387 |
( aFullTestResult.iCaseExecutionResultCode == KErrNone ) &&
|
|
388 |
( aFullTestResult.iTestResult.iResult == KErrNone ) )
|
|
389 |
{
|
|
390 |
aFullTestResult.iTestResult.iResultDes.Copy(
|
|
391 |
_L("Completed with error") );
|
|
392 |
aFullTestResult.iCaseExecutionResultType =
|
|
393 |
TFullTestResult::ECaseErrorFromModule;
|
|
394 |
aFullTestResult.iCaseExecutionResultCode = aStatus;
|
|
395 |
}
|
|
396 |
|
|
397 |
__TRACE( KPrint, ( _L( "CUIEngineContainer::TestCaseExecuted.") ) );
|
|
398 |
|
|
399 |
// Test execution is not completed before all prints are
|
|
400 |
// delivered to UI.
|
|
401 |
if( !iPrinter->IsRunning() ||
|
|
402 |
( aStatus != KErrNone ) ||
|
|
403 |
( aFullTestResult.iCaseExecutionResultCode != KErrNone ) )
|
|
404 |
{
|
|
405 |
// Call TestExecuted of CUIEngine interface
|
|
406 |
iUIEngine->TestExecuted(this, aFullTestResult);
|
|
407 |
// 1. This method is called from CUIEngineRunner::RunL() and it is
|
|
408 |
// last operation => no other call to CUIEngineContainer class.
|
|
409 |
// 2. TestExecuted() method takes this pointer. Inside TestExecuted()
|
|
410 |
// will be deleted the this pointer => iUIEngine not valid anymore.
|
|
411 |
// 1 and 2 => Do not handle any CUIEngineContainer variable here
|
|
412 |
// because memory is not valid anymore.
|
|
413 |
//e.g. iState = EFinished; // illegal operation here->crash
|
|
414 |
|
|
415 |
}
|
|
416 |
|
|
417 |
}
|
|
418 |
|
|
419 |
|
|
420 |
/*
|
|
421 |
-------------------------------------------------------------------------------
|
|
422 |
|
|
423 |
Class: CUIEngineContainer
|
|
424 |
|
|
425 |
Method: PrintProgress
|
|
426 |
|
|
427 |
Description: PrintProgress prints information from test case
|
|
428 |
|
|
429 |
Parameters: TTestProgress& aProgress: in: Progress info
|
|
430 |
|
|
431 |
Return Values: None
|
|
432 |
|
|
433 |
Errors/Exceptions: None
|
|
434 |
|
|
435 |
Status: Draft
|
|
436 |
|
|
437 |
-------------------------------------------------------------------------------
|
|
438 |
*/
|
|
439 |
void CUIEngineContainer::PrintProgress( TTestProgress& aProgress )
|
|
440 |
{
|
|
441 |
if( iState == ERunning )
|
|
442 |
{
|
|
443 |
// Only running cases may print
|
|
444 |
iUIEngine->PrintProg( this, aProgress );
|
|
445 |
}
|
|
446 |
else
|
|
447 |
{
|
|
448 |
__TRACE( KPrint,
|
|
449 |
( _L("%S: %S"), &aProgress.iDescription, &aProgress.iText ) );
|
|
450 |
}
|
|
451 |
}
|
|
452 |
|
|
453 |
/*
|
|
454 |
-------------------------------------------------------------------------------
|
|
455 |
|
|
456 |
Class: CUIEngineContainer
|
|
457 |
|
|
458 |
Method: PrintsDone
|
|
459 |
|
|
460 |
Description: Signals that printing is completed
|
|
461 |
|
|
462 |
Parameters: None
|
|
463 |
|
|
464 |
Return Values: None
|
|
465 |
|
|
466 |
Errors/Exceptions: None
|
|
467 |
|
|
468 |
Status: Draft
|
|
469 |
|
|
470 |
-------------------------------------------------------------------------------
|
|
471 |
*/
|
|
472 |
void CUIEngineContainer::PrintsDone()
|
|
473 |
{
|
|
474 |
if( iState == EExecuted )
|
|
475 |
{
|
|
476 |
// Call TestExecuted of CUIEngine interface
|
|
477 |
iUIEngine->TestExecuted(this, iRunner->FullResult() );
|
|
478 |
iState = EFinished;
|
|
479 |
}
|
|
480 |
}
|
|
481 |
|
|
482 |
/*
|
|
483 |
-------------------------------------------------------------------------------
|
|
484 |
|
|
485 |
Class: CUIEngineContainer
|
|
486 |
|
|
487 |
Method: RemoteSend
|
|
488 |
|
|
489 |
Description: RemoteSend forwards remote protocol messages from master
|
|
490 |
|
|
491 |
Parameters:
|
|
492 |
|
|
493 |
Return Values: None
|
|
494 |
|
|
495 |
Errors/Exceptions: None
|
|
496 |
|
|
497 |
Status: Draft
|
|
498 |
|
|
499 |
-------------------------------------------------------------------------------
|
|
500 |
*/
|
|
501 |
void CUIEngineContainer::RemoteSend( const TDesC& aRemoteMsg,
|
|
502 |
TInt /* aStatus */ )
|
|
503 |
{
|
|
504 |
|
|
505 |
__TRACE( KPrint, ( _L( "CUIEngineContainer::RemoteSend.") ) );
|
|
506 |
|
|
507 |
// Save master id if doesn't exists already
|
|
508 |
if( iMasterId == 0 )
|
|
509 |
{
|
|
510 |
CStifTFwIfProt* msg = NULL;
|
|
511 |
TRAPD( err,
|
|
512 |
msg = CStifTFwIfProt::NewL();
|
|
513 |
msg->SetL( aRemoteMsg );
|
|
514 |
);
|
|
515 |
if( err != KErrNone )
|
|
516 |
{
|
|
517 |
delete msg;
|
|
518 |
// oom
|
|
519 |
return;
|
|
520 |
}
|
|
521 |
iMasterId = msg->SrcId();
|
|
522 |
delete msg;
|
|
523 |
}
|
|
524 |
|
|
525 |
// Call AtsSend of CUIEngine interface
|
|
526 |
iUIEngine->RemoteMsg( this, aRemoteMsg );
|
|
527 |
|
|
528 |
}
|
|
529 |
|
|
530 |
/*
|
|
531 |
-------------------------------------------------------------------------------
|
|
532 |
|
|
533 |
Class: CUIEngineContainer
|
|
534 |
|
|
535 |
Method: GoingToReboot
|
|
536 |
|
|
537 |
Description: Inform UI that phone is going to rebooted
|
|
538 |
|
|
539 |
Parameters:
|
|
540 |
|
|
541 |
Return Values: None
|
|
542 |
|
|
543 |
Errors/Exceptions: None
|
|
544 |
|
|
545 |
Status: Draft
|
|
546 |
|
|
547 |
-------------------------------------------------------------------------------
|
|
548 |
*/
|
|
549 |
TInt CUIEngineContainer::GoingToReboot( TRequestStatus& aStatus )
|
|
550 |
{
|
|
551 |
|
|
552 |
__TRACE( KPrint, ( _L( "CUIEngineContainer::GoingToReboot.") ) );
|
|
553 |
|
|
554 |
// Forward
|
|
555 |
return iUIEngine->GoingToReboot( this, aStatus );
|
|
556 |
|
|
557 |
}
|
|
558 |
|
|
559 |
/*
|
|
560 |
-------------------------------------------------------------------------------
|
|
561 |
|
|
562 |
Class: CUIEngineContainer
|
|
563 |
|
|
564 |
Method: RemoteReceive
|
|
565 |
|
|
566 |
Description: RemoteReceive forwards remote protocol messages to master
|
|
567 |
|
|
568 |
Parameters:
|
|
569 |
|
|
570 |
Return Values: None
|
|
571 |
|
|
572 |
Errors/Exceptions: None
|
|
573 |
|
|
574 |
Status: Draft
|
|
575 |
|
|
576 |
-------------------------------------------------------------------------------
|
|
577 |
*/
|
|
578 |
TInt CUIEngineContainer::RemoteReceive( const TDesC& aRemoteMsg )
|
|
579 |
{
|
|
580 |
|
|
581 |
__TRACE( KPrint, ( _L( "CUIEngineContainer::RemoteReceive.") ) );
|
|
582 |
|
|
583 |
// Check master test case status, FIX110
|
|
584 |
if( iState != ERunning )
|
|
585 |
{
|
|
586 |
__TRACE( KError, ( _L( "Master case not running") ) );
|
|
587 |
|
|
588 |
return KErrNotFound;
|
|
589 |
}
|
|
590 |
|
|
591 |
HBufC8* buf = HBufC8::New( aRemoteMsg.Length() );
|
|
592 |
if( buf == NULL )
|
|
593 |
{
|
|
594 |
return KErrNoMemory;
|
|
595 |
}
|
|
596 |
|
|
597 |
TPtr8 tmp = buf->Des();
|
|
598 |
tmp.Copy( aRemoteMsg );
|
|
599 |
TInt ret = iTestCase.NotifyRemoteMsg( tmp, EStifCmdReceive );
|
|
600 |
delete buf;
|
|
601 |
|
|
602 |
return ret;
|
|
603 |
|
|
604 |
}
|
|
605 |
|
|
606 |
// ================= OTHER EXPORTED FUNCTIONS =================================
|
|
607 |
|
|
608 |
// End of File
|