64
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: CAlfPerfAppTestCaseExecutionView implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <AknUtils.h>
|
|
20 |
#include <aknViewAppUi.h>
|
|
21 |
#include <alfperfapp.rsg>
|
|
22 |
#include <alf/alfenv.h>
|
|
23 |
#include <hal.h>
|
|
24 |
#include "alfperfapptestcaseexecutionview.h"
|
|
25 |
#include "alfperfappconstants.h"
|
|
26 |
#include "alfperfapptestcasefactory.h"
|
|
27 |
#include "alfperfapptestcase.h"
|
|
28 |
#include "alfperfappmodel.h"
|
|
29 |
|
|
30 |
#include "../../alfdebugextension/inc/alfdebug.h"
|
|
31 |
|
|
32 |
/**
|
|
33 |
* Client-server interface for daemon.
|
|
34 |
*/
|
|
35 |
class RAlfPerfAppDaemon : public RApaAppServiceBase
|
|
36 |
{
|
|
37 |
public:
|
|
38 |
/**
|
|
39 |
* Constructor.
|
|
40 |
*/
|
|
41 |
RAlfPerfAppDaemon();
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Connects to daemon.
|
|
45 |
* @return error code, KErrNone upon success.
|
|
46 |
*/
|
|
47 |
TInt Connect();
|
|
48 |
|
|
49 |
/**
|
|
50 |
* Gets measurements.
|
|
51 |
* @param aMeasurements this will contain measurements.
|
|
52 |
* @return error code.
|
|
53 |
*/
|
|
54 |
TInt GetMeasurements( TAlfDebugServerMeasurements& aMeasurements );
|
|
55 |
|
|
56 |
/**
|
|
57 |
* Enables activity polling.
|
|
58 |
* @param aEnable ETrue if enabled, EFalse if disabled.
|
|
59 |
* @return error code.
|
|
60 |
*/
|
|
61 |
TInt EnableActivityPoll( TBool aEnable );
|
|
62 |
|
|
63 |
private:
|
|
64 |
/**
|
|
65 |
* From RApaAppServiceBase, returns service UID.
|
|
66 |
* @return service UID.
|
|
67 |
*/
|
|
68 |
virtual TUid ServiceUid() const;
|
|
69 |
};
|
|
70 |
|
|
71 |
/**
|
|
72 |
* CAlfPerfAppTestCaseExecutionView::CContainer container class.
|
|
73 |
*/
|
|
74 |
class CAlfPerfAppTestCaseExecutionView::CContainer : public CCoeControl
|
|
75 |
{
|
|
76 |
public:
|
|
77 |
|
|
78 |
CContainer( CAlfPerfAppTestCaseExecutionView& aView );
|
|
79 |
void ConstructL();
|
|
80 |
~CContainer();
|
|
81 |
|
|
82 |
// From base class CCoeControl
|
|
83 |
virtual TKeyResponse OfferKeyEventL(
|
|
84 |
const TKeyEvent& aKeyEvent, TEventCode aType );
|
|
85 |
virtual void HandleResourceChange( TInt aType );
|
|
86 |
virtual void Draw(const TRect& aRect) const;
|
|
87 |
|
|
88 |
private:
|
|
89 |
/**
|
|
90 |
* Reference to execution view.
|
|
91 |
* Now owned.
|
|
92 |
*/
|
|
93 |
CAlfPerfAppTestCaseExecutionView& iView;
|
|
94 |
};
|
|
95 |
|
|
96 |
/**
|
|
97 |
* Active object to execute test cases.
|
|
98 |
*/
|
|
99 |
class CAlfPerfAppTestCaseExecutionView::CActiveExecuter
|
|
100 |
: public CActive, private MAlfPerfAppTestCaseInterface
|
|
101 |
{
|
|
102 |
public:
|
|
103 |
CActiveExecuter(
|
|
104 |
CAlfPerfAppTestCaseExecutionView& aView,
|
|
105 |
CAlfPerfAppTestCaseFactory& aFactory,
|
|
106 |
CAlfPerfAppModel& aModel,
|
|
107 |
RAlfPerfAppDaemon& aDaemon,
|
|
108 |
TBool aUseContinuousRun = EFalse);
|
|
109 |
~CActiveExecuter();
|
|
110 |
|
|
111 |
/**
|
|
112 |
* Starts executing test cases.
|
|
113 |
*/
|
|
114 |
void StartNextCase();
|
|
115 |
|
|
116 |
/**
|
|
117 |
* Sets visible area.
|
|
118 |
* @param aRect new visible area.
|
|
119 |
*/
|
|
120 |
void SetVisibleArea( const TRect& aRect );
|
|
121 |
|
|
122 |
/**
|
|
123 |
* Ends the continuous run if it was on, otherwise does nothing.
|
|
124 |
*/
|
|
125 |
void EndContinuousRun();
|
|
126 |
|
|
127 |
private:
|
|
128 |
|
|
129 |
// From base class CActive
|
|
130 |
virtual void RunL();
|
|
131 |
virtual void DoCancel();
|
|
132 |
virtual TInt RunError( TInt aError );
|
|
133 |
|
|
134 |
// From base class MAlfPerfAppTestCaseInterface
|
|
135 |
virtual void MeasureNow();
|
|
136 |
|
|
137 |
private:
|
|
138 |
|
|
139 |
/**
|
|
140 |
* Gets next test case.
|
|
141 |
* @return ETrue if test case received ok.
|
|
142 |
*/
|
|
143 |
TBool GetNextTestCaseL();
|
|
144 |
|
|
145 |
/**
|
|
146 |
* Reports error. Calls DoReportErrorL in TRAP harness.
|
|
147 |
* @param aErrorCode error code.
|
|
148 |
*/
|
|
149 |
void ReportError( TInt aErrorCode );
|
|
150 |
|
|
151 |
/**
|
|
152 |
* Reports error to model.
|
|
153 |
* @param aErrorCode error code.
|
|
154 |
*/
|
|
155 |
void DoReportErrorL( TInt aErrorCode );
|
|
156 |
|
|
157 |
/**
|
|
158 |
* Reports error and continues to next case.
|
|
159 |
* @param aErrorCode error code.
|
|
160 |
*/
|
|
161 |
void ReportErrorAndContinue( TInt aErrorCode );
|
|
162 |
|
|
163 |
/**
|
|
164 |
* Resets current state.
|
|
165 |
*/
|
|
166 |
void Reset( TBool aOkToCallObserver );
|
|
167 |
|
|
168 |
/**
|
|
169 |
* Completes request status with specified error code.
|
|
170 |
* @param aErrorCode error code.
|
|
171 |
*/
|
|
172 |
void CompleteNow( TInt aErrorCode );
|
|
173 |
|
|
174 |
/**
|
|
175 |
* Determine next state based on current state.
|
|
176 |
* It's expected that current state has been completed
|
|
177 |
* successfully.
|
|
178 |
*/
|
|
179 |
void DetermineNextState();
|
|
180 |
|
|
181 |
/**
|
|
182 |
* Creates alf environment and initializes
|
|
183 |
* debug extension plugin.
|
|
184 |
*/
|
|
185 |
void CreateEnvL();
|
|
186 |
|
|
187 |
/**
|
|
188 |
* Deletes alf environment.
|
|
189 |
*/
|
|
190 |
void DeleteEnv();
|
|
191 |
|
|
192 |
/**
|
|
193 |
* Performs measurements.
|
|
194 |
*/
|
|
195 |
void PerformMeasurementsL();
|
|
196 |
|
|
197 |
private:
|
|
198 |
|
|
199 |
/**
|
|
200 |
* Reference to execution view.
|
|
201 |
* Not owned.
|
|
202 |
*/
|
|
203 |
CAlfPerfAppTestCaseExecutionView& iView;
|
|
204 |
|
|
205 |
/**
|
|
206 |
* Reference to test case factory.
|
|
207 |
* Not owned.
|
|
208 |
*/
|
|
209 |
CAlfPerfAppTestCaseFactory& iFactory;
|
|
210 |
|
|
211 |
/**
|
|
212 |
* Reference to model.
|
|
213 |
* Not owned.
|
|
214 |
*/
|
|
215 |
CAlfPerfAppModel& iModel;
|
|
216 |
|
|
217 |
/**
|
|
218 |
* Reference to daemon.
|
|
219 |
* Not owned.
|
|
220 |
*/
|
|
221 |
RAlfPerfAppDaemon& iDaemon;
|
|
222 |
|
|
223 |
/**
|
|
224 |
* Visible area rect.
|
|
225 |
*/
|
|
226 |
TRect iVisibleArea;
|
|
227 |
|
|
228 |
/**
|
|
229 |
* Current test case id.
|
|
230 |
*/
|
|
231 |
TInt iCaseId;
|
|
232 |
|
|
233 |
/*
|
|
234 |
* Current cases place in the sequence
|
|
235 |
*/
|
|
236 |
TInt iSequenceIndex;
|
|
237 |
|
|
238 |
/**
|
|
239 |
* Enumerates different possibilities for current state.
|
|
240 |
*/
|
|
241 |
enum TCurrentState
|
|
242 |
{
|
|
243 |
EStateIdle,
|
|
244 |
EStateCreateTestCase,
|
|
245 |
EStateSetupTestCase,
|
|
246 |
EStateExecuteTestCase,
|
|
247 |
EStateTearDownTestCase
|
|
248 |
};
|
|
249 |
|
|
250 |
/**
|
|
251 |
* Current state.
|
|
252 |
*/
|
|
253 |
TCurrentState iCurrentState;
|
|
254 |
|
|
255 |
/**
|
|
256 |
* Alf environment.
|
|
257 |
* Owned.
|
|
258 |
*/
|
|
259 |
CAlfEnv* iEnv;
|
|
260 |
|
|
261 |
/**
|
|
262 |
* Current test case under execution.
|
|
263 |
* Owned.
|
|
264 |
*/
|
|
265 |
CAlfPerfAppTestCase* iCurrentTestCase;
|
|
266 |
|
|
267 |
/**
|
|
268 |
* NTickCount tick period.
|
|
269 |
*/
|
|
270 |
TInt iTickPeriod;
|
|
271 |
|
|
272 |
/**
|
|
273 |
* Tells if the continuous run is enabled.
|
|
274 |
*/
|
|
275 |
TBool iContinuousRunOngoing;
|
|
276 |
|
|
277 |
/**
|
|
278 |
* Tells if this is the last case. Used only to end continuous run correctly.
|
|
279 |
*/
|
|
280 |
TBool iFinalCase;
|
|
281 |
};
|
|
282 |
|
|
283 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
284 |
|
|
285 |
CAlfPerfAppTestCaseExecutionView* CAlfPerfAppTestCaseExecutionView::NewLC(
|
|
286 |
CAlfPerfAppModel& aModel )
|
|
287 |
{
|
|
288 |
CAlfPerfAppTestCaseExecutionView* self =
|
|
289 |
new (ELeave) CAlfPerfAppTestCaseExecutionView( aModel );
|
|
290 |
CleanupStack::PushL( self );
|
|
291 |
self->ConstructL();
|
|
292 |
return self;
|
|
293 |
}
|
|
294 |
|
|
295 |
CAlfPerfAppTestCaseExecutionView::~CAlfPerfAppTestCaseExecutionView()
|
|
296 |
{
|
|
297 |
delete iExecuter;
|
|
298 |
delete iFactory;
|
|
299 |
|
|
300 |
if ( iDaemon )
|
|
301 |
{
|
|
302 |
iDaemon->Close();
|
|
303 |
delete iDaemon;
|
|
304 |
}
|
|
305 |
}
|
|
306 |
|
|
307 |
void CAlfPerfAppTestCaseExecutionView::NotifyLayoutChange(
|
|
308 |
const TRect& aRect )
|
|
309 |
{
|
|
310 |
if ( iExecuter )
|
|
311 |
{
|
|
312 |
iExecuter->SetVisibleArea( aRect );
|
|
313 |
}
|
|
314 |
}
|
|
315 |
|
|
316 |
void CAlfPerfAppTestCaseExecutionView::NotifyExecutionCompletedL()
|
|
317 |
{
|
|
318 |
AppUi()->ActivateLocalViewL( KAlfPerfAppTestCaseResultsViewId );
|
|
319 |
}
|
|
320 |
|
|
321 |
void CAlfPerfAppTestCaseExecutionView::NotifyTestCaseVisible( TBool aVisible )
|
|
322 |
{
|
|
323 |
if ( iContainer )
|
|
324 |
{
|
|
325 |
if ( iDaemon )
|
|
326 |
{
|
|
327 |
// Call User::ResetInactivityTime periodically if test case
|
|
328 |
// is visible. This ensures that screensaver is not activated
|
|
329 |
// and thus test case execution is not disturbed.
|
|
330 |
(void)iDaemon->EnableActivityPoll( aVisible );
|
|
331 |
}
|
|
332 |
|
|
333 |
iContainer->MakeVisible( !aVisible );
|
|
334 |
}
|
|
335 |
}
|
|
336 |
|
|
337 |
CAlfPerfAppTestCaseExecutionView::CAlfPerfAppTestCaseExecutionView(
|
|
338 |
CAlfPerfAppModel& aModel )
|
|
339 |
: iModel( aModel )
|
|
340 |
{
|
|
341 |
}
|
|
342 |
|
|
343 |
#include <apgcli.h>
|
|
344 |
#include <apacmdln.h>
|
|
345 |
#include "alfperfapp.hrh"
|
|
346 |
|
|
347 |
static void StartDaemonL()
|
|
348 |
{
|
|
349 |
_LIT( KAlfPerfAppDaemonExe, "alfperfappdaemon.exe" );
|
|
350 |
const TUid KAlfPerfAppDaemonUid = { KAlfPerfAppDaemonUidValue };
|
|
351 |
|
|
352 |
RApaLsSession apa;
|
|
353 |
User::LeaveIfError(apa.Connect());
|
|
354 |
CleanupClosePushL(apa);
|
|
355 |
|
|
356 |
CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
|
|
357 |
cmdLine->SetExecutableNameL( KAlfPerfAppDaemonExe );
|
|
358 |
cmdLine->SetServerRequiredL( KAlfPerfAppDaemonUid.iUid );
|
|
359 |
cmdLine->SetCommandL( EApaCommandBackground );
|
|
360 |
TThreadId dummy;
|
|
361 |
|
|
362 |
TRequestStatus requestStatusForRendezvous;
|
|
363 |
User::LeaveIfError( apa.StartApp(*cmdLine, dummy, &requestStatusForRendezvous) );
|
|
364 |
User::WaitForRequest( requestStatusForRendezvous );
|
|
365 |
User::LeaveIfError( requestStatusForRendezvous.Int() );
|
|
366 |
|
|
367 |
CleanupStack::PopAndDestroy(2, &apa);
|
|
368 |
}
|
|
369 |
|
|
370 |
void CAlfPerfAppTestCaseExecutionView::ConstructL()
|
|
371 |
{
|
|
372 |
BaseConstructL( R_ALFPERFAPP_TEST_CASE_EXECUTION_VIEW );
|
|
373 |
iFactory = CAlfPerfAppTestCaseFactory::NewL();
|
|
374 |
|
|
375 |
iDaemon = new (ELeave) RAlfPerfAppDaemon;
|
|
376 |
TInt err = iDaemon->Connect();
|
|
377 |
if ( err == KErrNotFound )
|
|
378 |
{
|
|
379 |
TRAP( err, StartDaemonL() );
|
|
380 |
if ( err == KErrNone ||
|
|
381 |
err == KErrAlreadyExists )
|
|
382 |
{
|
|
383 |
err = iDaemon->Connect();
|
|
384 |
}
|
|
385 |
}
|
|
386 |
if ( err != KErrNotFound )
|
|
387 |
{
|
|
388 |
User::LeaveIfError( err );
|
|
389 |
}
|
|
390 |
}
|
|
391 |
|
|
392 |
TUid CAlfPerfAppTestCaseExecutionView::Id() const
|
|
393 |
{
|
|
394 |
return KAlfPerfAppTestCaseExecutionViewId;
|
|
395 |
}
|
|
396 |
|
|
397 |
// -----------------------------------------------------------------------------
|
|
398 |
// Handles view activation
|
|
399 |
// -----------------------------------------------------------------------------
|
|
400 |
//
|
|
401 |
void CAlfPerfAppTestCaseExecutionView::DoActivateL(
|
|
402 |
const TVwsViewId& /*aPrevViewId*/,
|
|
403 |
TUid /*aCustomMessageId*/,
|
|
404 |
const TDesC8& aCustomMessage )
|
|
405 |
{
|
|
406 |
CContainer* container = new (ELeave) CContainer( *this );
|
|
407 |
CleanupStack::PushL( container );
|
|
408 |
container->ConstructL();
|
|
409 |
AppUi()->AddToStackL( *this, container );
|
|
410 |
CleanupStack::Pop( container );
|
|
411 |
iContainer = container;
|
|
412 |
|
|
413 |
if(aCustomMessage == _L8("UseContinuousRun"))
|
|
414 |
{
|
|
415 |
// If we should use the continuous run, use it (the ETrue in the end)
|
|
416 |
iExecuter = new (ELeave) CActiveExecuter( *this, *iFactory, iModel, *iDaemon, ETrue );
|
|
417 |
Cba()->SetCommandSetL(R_AVKON_SOFTKEYS_OK_EMPTY);
|
|
418 |
Cba()->DrawDeferred();
|
|
419 |
}
|
|
420 |
else
|
|
421 |
{
|
|
422 |
// If not, then just use the default parameters
|
|
423 |
iExecuter = new (ELeave) CActiveExecuter( *this, *iFactory, iModel, *iDaemon);
|
|
424 |
Cba()->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY);
|
|
425 |
Cba()->DrawDeferred();
|
|
426 |
|
|
427 |
}
|
|
428 |
iExecuter->SetVisibleArea(
|
|
429 |
TRect( container->Position(), container->Size() ) );
|
|
430 |
iExecuter->StartNextCase();
|
|
431 |
}
|
|
432 |
|
|
433 |
// -----------------------------------------------------------------------------
|
|
434 |
// Handles view deactivation
|
|
435 |
// -----------------------------------------------------------------------------
|
|
436 |
//
|
|
437 |
void CAlfPerfAppTestCaseExecutionView::DoDeactivate()
|
|
438 |
{
|
|
439 |
if ( iContainer )
|
|
440 |
{
|
|
441 |
AppUi()->RemoveFromStack( iContainer );
|
|
442 |
delete iContainer;
|
|
443 |
iContainer = NULL;
|
|
444 |
}
|
|
445 |
|
|
446 |
delete iExecuter;
|
|
447 |
iExecuter = NULL;
|
|
448 |
}
|
|
449 |
|
|
450 |
// -----------------------------------------------------------------------------
|
|
451 |
// Handles test case selection view specific commands.
|
|
452 |
// -----------------------------------------------------------------------------
|
|
453 |
//
|
|
454 |
void CAlfPerfAppTestCaseExecutionView::HandleCommandL( TInt aCommand )
|
|
455 |
{
|
|
456 |
if(aCommand == EAknSoftkeyOk) // For some reason, switch didn't catch this
|
|
457 |
{
|
|
458 |
iExecuter->EndContinuousRun();
|
|
459 |
return;
|
|
460 |
}
|
|
461 |
switch ( aCommand )
|
|
462 |
{
|
|
463 |
default:
|
|
464 |
AppUi()->HandleCommandL( aCommand );
|
|
465 |
break;
|
|
466 |
}
|
|
467 |
}
|
|
468 |
|
|
469 |
//
|
|
470 |
// Implementation of CAlfPerfAppTestCaseExecutionView::CContainer:
|
|
471 |
//
|
|
472 |
|
|
473 |
CAlfPerfAppTestCaseExecutionView::CContainer::CContainer(
|
|
474 |
CAlfPerfAppTestCaseExecutionView& aView )
|
|
475 |
: iView( aView )
|
|
476 |
{
|
|
477 |
}
|
|
478 |
|
|
479 |
void CAlfPerfAppTestCaseExecutionView::CContainer::ConstructL()
|
|
480 |
{
|
|
481 |
CreateWindowL();
|
|
482 |
|
|
483 |
TRect rect;
|
|
484 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, rect );
|
|
485 |
SetRect( rect );
|
|
486 |
|
|
487 |
ActivateL();
|
|
488 |
}
|
|
489 |
|
|
490 |
CAlfPerfAppTestCaseExecutionView::CContainer::~CContainer()
|
|
491 |
{
|
|
492 |
}
|
|
493 |
|
|
494 |
|
|
495 |
|
|
496 |
TKeyResponse CAlfPerfAppTestCaseExecutionView::CContainer::OfferKeyEventL(
|
|
497 |
const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/ )
|
|
498 |
{
|
|
499 |
TKeyResponse resp = EKeyWasNotConsumed;
|
|
500 |
if ( IsVisible() )
|
|
501 |
{
|
|
502 |
resp = EKeyWasConsumed;
|
|
503 |
}
|
|
504 |
return resp;
|
|
505 |
}
|
|
506 |
|
|
507 |
void CAlfPerfAppTestCaseExecutionView::CContainer::HandleResourceChange( TInt aType )
|
|
508 |
{
|
|
509 |
CCoeControl::HandleResourceChange( aType );
|
|
510 |
|
|
511 |
if ( aType == KEikDynamicLayoutVariantSwitch )
|
|
512 |
{
|
|
513 |
TRect rect;
|
|
514 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, rect );
|
|
515 |
SetRect( rect );
|
|
516 |
|
|
517 |
iView.NotifyLayoutChange( rect );
|
|
518 |
}
|
|
519 |
}
|
|
520 |
|
|
521 |
void CAlfPerfAppTestCaseExecutionView::CContainer::Draw(
|
|
522 |
const TRect& /*aRect*/ ) const
|
|
523 |
{
|
|
524 |
CWindowGc& gc = SystemGc();
|
|
525 |
gc.SetPenStyle( CGraphicsContext::ENullPen );
|
|
526 |
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
|
|
527 |
gc.SetBrushColor( TRgb( 128, 0, 0 ) ); // red color
|
|
528 |
gc.DrawRect( Rect() );
|
|
529 |
gc.SetBrushStyle( CGraphicsContext::ENullBrush );
|
|
530 |
}
|
|
531 |
|
|
532 |
//
|
|
533 |
// Implementation of CAlfPerfAppTestCaseExecutionView::CActiveExecuter:
|
|
534 |
//
|
|
535 |
CAlfPerfAppTestCaseExecutionView::CActiveExecuter::CActiveExecuter(
|
|
536 |
CAlfPerfAppTestCaseExecutionView& aView,
|
|
537 |
CAlfPerfAppTestCaseFactory& aFactory,
|
|
538 |
CAlfPerfAppModel& aModel,
|
|
539 |
RAlfPerfAppDaemon& aDaemon,
|
|
540 |
TBool aUseContinuousRun)
|
|
541 |
: CActive( CActive::EPriorityHigh ),
|
|
542 |
iView( aView ),
|
|
543 |
iFactory( aFactory ),
|
|
544 |
iModel( aModel ),
|
|
545 |
iDaemon( aDaemon ),
|
|
546 |
iCurrentState( EStateIdle ),
|
|
547 |
iContinuousRunOngoing( aUseContinuousRun ),
|
|
548 |
iFinalCase(EFalse),
|
|
549 |
iSequenceIndex(0)
|
|
550 |
{
|
|
551 |
CActiveScheduler::Add( this );
|
|
552 |
|
|
553 |
TInt err = HAL::Get( HAL::ENanoTickPeriod, iTickPeriod );
|
|
554 |
if ( err != KErrNone )
|
|
555 |
{
|
|
556 |
iTickPeriod = 1000; // assume 1ms
|
|
557 |
}
|
|
558 |
}
|
|
559 |
|
|
560 |
CAlfPerfAppTestCaseExecutionView::CActiveExecuter::~CActiveExecuter()
|
|
561 |
{
|
|
562 |
Reset( EFalse ); // calls Cancel()
|
|
563 |
}
|
|
564 |
|
|
565 |
void CAlfPerfAppTestCaseExecutionView::CActiveExecuter::StartNextCase()
|
|
566 |
{
|
|
567 |
Reset( ETrue ); // reset sets current state to idle
|
|
568 |
|
|
569 |
CompleteNow( KErrNone );
|
|
570 |
SetActive();
|
|
571 |
}
|
|
572 |
|
|
573 |
void CAlfPerfAppTestCaseExecutionView::CActiveExecuter::SetVisibleArea(
|
|
574 |
const TRect& aRect )
|
|
575 |
{
|
|
576 |
iVisibleArea = aRect;
|
|
577 |
|
|
578 |
if ( iCurrentTestCase )
|
|
579 |
{
|
|
580 |
iCurrentTestCase->HandleVisibleAreaChange( aRect );
|
|
581 |
}
|
|
582 |
}
|
|
583 |
|
|
584 |
void CAlfPerfAppTestCaseExecutionView::CActiveExecuter::EndContinuousRun()
|
|
585 |
{
|
|
586 |
if(iContinuousRunOngoing)
|
|
587 |
{
|
|
588 |
iFinalCase = ETrue;
|
|
589 |
}
|
|
590 |
|
|
591 |
iContinuousRunOngoing = EFalse;
|
|
592 |
}
|
|
593 |
|
|
594 |
void CAlfPerfAppTestCaseExecutionView::CActiveExecuter::RunL()
|
|
595 |
{
|
|
596 |
const TInt errorCode = iStatus.Int();
|
|
597 |
|
|
598 |
if ( errorCode != KErrNone )
|
|
599 |
{
|
|
600 |
// If current test step failed, report and continue to next
|
|
601 |
// test case.
|
|
602 |
__ASSERT_ALWAYS( iCurrentState != EStateIdle, User::Invariant() );
|
|
603 |
ReportErrorAndContinue( errorCode );
|
|
604 |
return;
|
|
605 |
}
|
|
606 |
|
|
607 |
if ( iCurrentState == EStateIdle )
|
|
608 |
{
|
|
609 |
// When current state is idle and RunL is reached,
|
|
610 |
// it's time to take next case from queue and start
|
|
611 |
// execution.
|
|
612 |
if ( iFinalCase || !GetNextTestCaseL())
|
|
613 |
{
|
|
614 |
// No more test cases - stop.
|
|
615 |
iView.NotifyExecutionCompletedL();
|
|
616 |
return;
|
|
617 |
}
|
|
618 |
}
|
|
619 |
|
|
620 |
if(iCurrentTestCase && iContinuousRunOngoing && iCurrentState == EStateExecuteTestCase)
|
|
621 |
{
|
|
622 |
TInt CaseID = iCurrentTestCase->CaseID();
|
|
623 |
iModel.AddToExecuteArrayL(CaseID);
|
|
624 |
}
|
|
625 |
|
|
626 |
// Perform measurements before switching to next state
|
|
627 |
switch ( iCurrentState )
|
|
628 |
{
|
|
629 |
case EStateSetupTestCase:
|
|
630 |
case EStateExecuteTestCase:
|
|
631 |
// Going to execution or teardown phase.
|
|
632 |
PerformMeasurementsL();
|
|
633 |
break;
|
|
634 |
case EStateCreateTestCase:
|
|
635 |
case EStateTearDownTestCase:
|
|
636 |
case EStateIdle:
|
|
637 |
default:
|
|
638 |
// Either these do not contain any activity or
|
|
639 |
// then it's performed synchronously.
|
|
640 |
break;
|
|
641 |
}
|
|
642 |
|
|
643 |
DetermineNextState();
|
|
644 |
|
|
645 |
// Execute according to current state
|
|
646 |
switch ( iCurrentState )
|
|
647 |
{
|
|
648 |
case EStateCreateTestCase:
|
|
649 |
__ASSERT_ALWAYS( !iCurrentTestCase, User::Invariant() );
|
|
650 |
iCurrentTestCase = iFactory.CreateL( iCaseId, iSequenceIndex);
|
|
651 |
|
|
652 |
iStatus = KRequestPending;
|
|
653 |
CompleteNow( KErrNone );
|
|
654 |
SetActive();
|
|
655 |
break;
|
|
656 |
|
|
657 |
case EStateSetupTestCase:
|
|
658 |
__ASSERT_ALWAYS( iCurrentTestCase, User::Invariant() );
|
|
659 |
// Make sure test case is visible.
|
|
660 |
// NotifyTestCaseVisible is called with EFalse in Reset().
|
|
661 |
iView.NotifyTestCaseVisible( ETrue );
|
|
662 |
|
|
663 |
PerformMeasurementsL();
|
|
664 |
CreateEnvL();
|
|
665 |
|
|
666 |
iStatus = KRequestPending;
|
|
667 |
iCurrentTestCase->SetInterface( this );
|
|
668 |
iCurrentTestCase->SetupL( *iEnv, iVisibleArea, iStatus );
|
|
669 |
SetActive();
|
|
670 |
break;
|
|
671 |
|
|
672 |
case EStateExecuteTestCase:
|
|
673 |
__ASSERT_ALWAYS( iCurrentTestCase, User::Invariant() );
|
|
674 |
PerformMeasurementsL();
|
|
675 |
|
|
676 |
iStatus = KRequestPending;
|
|
677 |
iCurrentTestCase->ExecuteL( iStatus );
|
|
678 |
SetActive();
|
|
679 |
break;
|
|
680 |
|
|
681 |
case EStateTearDownTestCase:
|
|
682 |
__ASSERT_ALWAYS( iCurrentTestCase, User::Invariant() );
|
|
683 |
PerformMeasurementsL();
|
|
684 |
|
|
685 |
iCurrentTestCase->TearDown();
|
|
686 |
|
|
687 |
PerformMeasurementsL();
|
|
688 |
|
|
689 |
// Perform some reset actions. Cancel() is not
|
|
690 |
// needed, because we are in RunL method.
|
|
691 |
iCurrentTestCase->SetInterface( NULL );
|
|
692 |
delete iCurrentTestCase;
|
|
693 |
iCurrentTestCase = NULL;
|
|
694 |
DeleteEnv();
|
|
695 |
|
|
696 |
|
|
697 |
Reset( ETrue );
|
|
698 |
|
|
699 |
iStatus = KRequestPending;
|
|
700 |
CompleteNow( KErrNone );
|
|
701 |
SetActive();
|
|
702 |
break;
|
|
703 |
|
|
704 |
case EStateIdle:
|
|
705 |
break;
|
|
706 |
|
|
707 |
default:
|
|
708 |
break;
|
|
709 |
}
|
|
710 |
}
|
|
711 |
|
|
712 |
void CAlfPerfAppTestCaseExecutionView::CActiveExecuter::DoCancel()
|
|
713 |
{
|
|
714 |
delete iCurrentTestCase;
|
|
715 |
iCurrentTestCase = NULL;
|
|
716 |
}
|
|
717 |
|
|
718 |
TInt CAlfPerfAppTestCaseExecutionView::CActiveExecuter::RunError(
|
|
719 |
TInt aError )
|
|
720 |
{
|
|
721 |
if ( iCurrentState != EStateIdle )
|
|
722 |
{
|
|
723 |
if(iCurrentTestCase)
|
|
724 |
{
|
|
725 |
iCurrentTestCase->TearDown();
|
|
726 |
iCurrentTestCase->SetInterface( NULL );
|
|
727 |
}
|
|
728 |
ReportErrorAndContinue( aError );
|
|
729 |
}
|
|
730 |
|
|
731 |
return KErrNone;
|
|
732 |
}
|
|
733 |
|
|
734 |
void CAlfPerfAppTestCaseExecutionView::CActiveExecuter::MeasureNow()
|
|
735 |
{
|
|
736 |
TRAP_IGNORE( PerformMeasurementsL() );
|
|
737 |
}
|
|
738 |
|
|
739 |
TBool CAlfPerfAppTestCaseExecutionView::CActiveExecuter::GetNextTestCaseL()
|
|
740 |
{
|
|
741 |
TBool casesLeft = iModel.GetFromExecuteArray( iCaseId );
|
|
742 |
|
|
743 |
if(casesLeft)
|
|
744 |
{
|
|
745 |
if(iCaseId < 0)
|
|
746 |
{
|
|
747 |
iSequenceIndex++;
|
|
748 |
}
|
|
749 |
else
|
|
750 |
{
|
|
751 |
iSequenceIndex = 1;
|
|
752 |
}
|
|
753 |
}
|
|
754 |
|
|
755 |
return casesLeft;
|
|
756 |
}
|
|
757 |
|
|
758 |
void CAlfPerfAppTestCaseExecutionView::CActiveExecuter::ReportError(
|
|
759 |
TInt aErrorCode )
|
|
760 |
{
|
|
761 |
TRAP_IGNORE( DoReportErrorL( aErrorCode ) );
|
|
762 |
}
|
|
763 |
|
|
764 |
void CAlfPerfAppTestCaseExecutionView::CActiveExecuter::DoReportErrorL(
|
|
765 |
TInt aErrorCode )
|
|
766 |
{
|
|
767 |
_LIT( KAlfPerfAppErrorMessage, "0x%x failed with %d (state:%d)" );
|
|
768 |
HBufC* messageBuffer = HBufC::NewLC( 128 );
|
|
769 |
|
|
770 |
messageBuffer->Des().Format(
|
|
771 |
KAlfPerfAppErrorMessage,
|
|
772 |
iCaseId,
|
|
773 |
aErrorCode,
|
|
774 |
iCurrentState );
|
|
775 |
|
|
776 |
iModel.AddToErrorArrayL( *messageBuffer );
|
|
777 |
CleanupStack::PopAndDestroy( messageBuffer );
|
|
778 |
}
|
|
779 |
|
|
780 |
void CAlfPerfAppTestCaseExecutionView::CActiveExecuter::ReportErrorAndContinue(
|
|
781 |
TInt aErrorCode )
|
|
782 |
{
|
|
783 |
ReportError( aErrorCode );
|
|
784 |
StartNextCase();
|
|
785 |
}
|
|
786 |
|
|
787 |
void CAlfPerfAppTestCaseExecutionView::CActiveExecuter::Reset(
|
|
788 |
TBool aOkToCallObserver )
|
|
789 |
{
|
|
790 |
Cancel();
|
|
791 |
|
|
792 |
delete iCurrentTestCase;
|
|
793 |
iCurrentTestCase = NULL;
|
|
794 |
|
|
795 |
DeleteEnv();
|
|
796 |
|
|
797 |
iCaseId = 0;
|
|
798 |
iCurrentState = EStateIdle;
|
|
799 |
|
|
800 |
if ( aOkToCallObserver )
|
|
801 |
{
|
|
802 |
iView.NotifyTestCaseVisible( EFalse );
|
|
803 |
}
|
|
804 |
}
|
|
805 |
|
|
806 |
void CAlfPerfAppTestCaseExecutionView::CActiveExecuter::CompleteNow(
|
|
807 |
TInt aErrorCode )
|
|
808 |
{
|
|
809 |
TRequestStatus* status = &iStatus;
|
|
810 |
User::RequestComplete( status, aErrorCode );
|
|
811 |
}
|
|
812 |
|
|
813 |
void CAlfPerfAppTestCaseExecutionView::CActiveExecuter::DetermineNextState()
|
|
814 |
{
|
|
815 |
// Determine next state after step has been completed.
|
|
816 |
switch ( iCurrentState )
|
|
817 |
{
|
|
818 |
case EStateIdle:
|
|
819 |
iCurrentState = EStateCreateTestCase;
|
|
820 |
break;
|
|
821 |
|
|
822 |
case EStateCreateTestCase:
|
|
823 |
iCurrentState = EStateSetupTestCase;
|
|
824 |
break;
|
|
825 |
|
|
826 |
case EStateSetupTestCase:
|
|
827 |
iCurrentState = EStateExecuteTestCase;
|
|
828 |
break;
|
|
829 |
|
|
830 |
case EStateExecuteTestCase:
|
|
831 |
iCurrentState = EStateTearDownTestCase;
|
|
832 |
break;
|
|
833 |
|
|
834 |
case EStateTearDownTestCase:
|
|
835 |
iCurrentState = EStateIdle;
|
|
836 |
break;
|
|
837 |
|
|
838 |
default:
|
|
839 |
break;
|
|
840 |
}
|
|
841 |
}
|
|
842 |
|
|
843 |
void CAlfPerfAppTestCaseExecutionView::CActiveExecuter::CreateEnvL()
|
|
844 |
{
|
|
845 |
__ASSERT_ALWAYS( !iEnv, User::Invariant() );
|
|
846 |
iEnv = CAlfEnv::NewL();
|
|
847 |
iEnv->SetMaxFrameRate(100);
|
|
848 |
}
|
|
849 |
|
|
850 |
void CAlfPerfAppTestCaseExecutionView::CActiveExecuter::DeleteEnv()
|
|
851 |
{
|
|
852 |
delete iEnv;
|
|
853 |
iEnv = NULL;
|
|
854 |
}
|
|
855 |
|
|
856 |
void CAlfPerfAppTestCaseExecutionView::CActiveExecuter::PerformMeasurementsL()
|
|
857 |
{
|
|
858 |
CAlfPerfAppModel::TTestCaseResultItem item;
|
|
859 |
|
|
860 |
// Test case identifiers
|
|
861 |
item.iCaseId = iCaseId;
|
|
862 |
|
|
863 |
// Phase (0 = setup, 1 = execution, 2 = teardown)
|
|
864 |
switch ( iCurrentState )
|
|
865 |
{
|
|
866 |
case EStateIdle:
|
|
867 |
case EStateCreateTestCase:
|
|
868 |
case EStateSetupTestCase:
|
|
869 |
item.iPhase = 0;
|
|
870 |
break;
|
|
871 |
|
|
872 |
case EStateExecuteTestCase:
|
|
873 |
item.iPhase = 1;
|
|
874 |
break;
|
|
875 |
|
|
876 |
case EStateTearDownTestCase:
|
|
877 |
item.iPhase = 2;
|
|
878 |
break;
|
|
879 |
|
|
880 |
default:
|
|
881 |
item.iPhase = -1;
|
|
882 |
break;
|
|
883 |
}
|
|
884 |
|
|
885 |
TInt dummy; // not used.
|
|
886 |
|
|
887 |
// Amount of cells allocated in Application heap.
|
|
888 |
// Total size taken by allocated cells in Application heap.
|
|
889 |
// Amount of free space in Application heap.
|
|
890 |
item.iAppCells = User::AllocSize( item.iAppMemory );
|
|
891 |
item.iAppFree = User::Available( dummy );
|
|
892 |
|
|
893 |
// Perform server side measurements
|
|
894 |
TAlfDebugServerMeasurements serverMeasurements;
|
|
895 |
TBool measureOk =
|
|
896 |
( iDaemon.GetMeasurements( serverMeasurements ) == KErrNone );
|
|
897 |
|
|
898 |
if ( !measureOk )
|
|
899 |
{
|
|
900 |
serverMeasurements.iTimeStamp = User::NTickCount();
|
|
901 |
serverMeasurements.iServerCells = 0;
|
|
902 |
serverMeasurements.iServerMemory = 0;
|
|
903 |
serverMeasurements.iServerFree = 0;
|
|
904 |
serverMeasurements.iFrameCount = 0;
|
|
905 |
}
|
|
906 |
|
|
907 |
// Convert timestamps to ms
|
|
908 |
if ( iTickPeriod != 1000 )
|
|
909 |
{
|
|
910 |
TUint64 stamp = serverMeasurements.iTimeStamp;
|
|
911 |
stamp *= iTickPeriod;
|
|
912 |
stamp /= 1000;
|
|
913 |
stamp &= 0xFFFFFFFF; // modulo 2**32
|
|
914 |
serverMeasurements.iTimeStamp = I64LOW( stamp );
|
|
915 |
}
|
|
916 |
|
|
917 |
|
|
918 |
// Amount of cells allocated in Server heap.
|
|
919 |
// Total size taken by allocated cells in Server heap.
|
|
920 |
// Amount of free space in Server heap.
|
|
921 |
// Time stamp (preferably from server side)
|
|
922 |
// Frame count
|
|
923 |
item.iTimeStamp = serverMeasurements.iTimeStamp;
|
|
924 |
item.iServerCells = serverMeasurements.iServerCells;
|
|
925 |
item.iServerMemory = serverMeasurements.iServerMemory;
|
|
926 |
item.iServerFree = serverMeasurements.iServerFree;
|
|
927 |
item.iFrameCount = serverMeasurements.iFrameCount;
|
|
928 |
|
|
929 |
// Amount of free memory in the system.
|
|
930 |
// Memory consumption of the system.
|
|
931 |
TInt systemFreeRam = 0;
|
|
932 |
HAL::Get( HALData::EMemoryRAMFree, systemFreeRam );
|
|
933 |
TInt systemTotalRam = 0;
|
|
934 |
HAL::Get( HALData::EMemoryRAM, systemTotalRam );
|
|
935 |
item.iSystemMemory = systemTotalRam - systemFreeRam;
|
|
936 |
item.iSystemFree = systemFreeRam;
|
|
937 |
|
|
938 |
TTestCaseSpecificResultText specificResult = 0;
|
|
939 |
specificResult = iCurrentTestCase->getCaseSpecificResultL();
|
|
940 |
if(specificResult)
|
|
941 |
{
|
|
942 |
item.specificResult8.Copy(specificResult->Des());
|
|
943 |
delete specificResult;
|
|
944 |
}
|
|
945 |
|
|
946 |
// Append to model
|
|
947 |
iModel.AddToResultFilesL( item );
|
|
948 |
}
|
|
949 |
|
|
950 |
//
|
|
951 |
// Implementation of RAlfPerfAppDaemon
|
|
952 |
//
|
|
953 |
|
|
954 |
RAlfPerfAppDaemon::RAlfPerfAppDaemon()
|
|
955 |
{
|
|
956 |
}
|
|
957 |
|
|
958 |
TInt RAlfPerfAppDaemon::Connect()
|
|
959 |
{
|
|
960 |
TInt result = KErrNone;
|
|
961 |
if ( !Handle() )
|
|
962 |
{
|
|
963 |
_LIT(KServerNameFormat, "%08x_%08x_AppServer");
|
|
964 |
TFullName serverName;
|
|
965 |
serverName.Format(
|
|
966 |
KServerNameFormat,
|
|
967 |
KAlfPerfAppDaemonUidValue,
|
|
968 |
KAlfPerfAppDaemonUidValue );
|
|
969 |
TRAP( result, ConnectExistingByNameL( serverName ) );
|
|
970 |
}
|
|
971 |
return result;
|
|
972 |
}
|
|
973 |
|
|
974 |
TInt RAlfPerfAppDaemon::GetMeasurements(
|
|
975 |
TAlfDebugServerMeasurements& aMeasurements )
|
|
976 |
{
|
|
977 |
if ( !Handle() )
|
|
978 |
{
|
|
979 |
return KErrNotSupported;
|
|
980 |
}
|
|
981 |
|
|
982 |
TPckg<TAlfDebugServerMeasurements> pckg( aMeasurements );
|
|
983 |
return SendReceive( EAlfPerfAppIpcGetMeasurements, TIpcArgs( &pckg ) );
|
|
984 |
}
|
|
985 |
|
|
986 |
TInt RAlfPerfAppDaemon::EnableActivityPoll( TBool aEnable )
|
|
987 |
{
|
|
988 |
if ( !Handle() )
|
|
989 |
{
|
|
990 |
return KErrNotSupported;
|
|
991 |
}
|
|
992 |
|
|
993 |
return SendReceive( EAlfPerfAppIpcEnableActivityPoll, TIpcArgs( aEnable ? 1 : 0 ) );
|
|
994 |
}
|
|
995 |
|
|
996 |
TUid RAlfPerfAppDaemon::ServiceUid() const
|
|
997 |
{
|
|
998 |
return TUid::Uid( KAlfPerfAppDaemonUidValue );
|
|
999 |
}
|
|
1000 |
|