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: CAlfPerfApptextTestCase implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "alfperfappbasetestcasecontrol.h"
|
|
20 |
#include "alfperfapptexttestcase.h"
|
|
21 |
#include "alfperfapp.hrh"
|
|
22 |
#include "alfperfappconfigconstants.h"
|
|
23 |
#include <AknUtils.h>
|
|
24 |
#include <alf/alfenv.h>
|
|
25 |
#include <alf/alfdisplay.h>
|
|
26 |
#include <alf/alfcontrol.h>
|
|
27 |
#include <alf/alfcontrolgroup.h>
|
|
28 |
#include <alf/alfroster.h>
|
|
29 |
#include <alf/alfcommand.h>
|
|
30 |
#include <alf/alfevent.h>
|
|
31 |
#include <alf/alftexturemanager.h>
|
|
32 |
#include <alf/alftextvisual.h>
|
|
33 |
#include <alf/alfimageloaderutil.h>
|
|
34 |
#include <alf/alfutil.h>
|
|
35 |
#include <e32math.h>
|
|
36 |
|
|
37 |
//#include <alfperfapp_texttest.mbg>
|
|
38 |
|
|
39 |
/**
|
|
40 |
* Control group for Text test cases.
|
|
41 |
*/
|
|
42 |
const TInt KAlfPerfAppTextControlGroup = 1;
|
|
43 |
|
|
44 |
/*
|
|
45 |
* Square root of sequence length for the image sequence cases
|
|
46 |
*/
|
|
47 |
const TInt SEQUENCE_LENGTH_SQRT = 7;
|
|
48 |
|
|
49 |
/**
|
|
50 |
* Start next 'cycle' command.
|
|
51 |
*/
|
|
52 |
const TInt KAlfPerfAppTextCmdNext = 0x5001;
|
|
53 |
|
|
54 |
/**
|
|
55 |
* Amount of text visuals.
|
|
56 |
*/
|
|
57 |
const TInt KAlfPerfAppTextTestCaseBasicTextCount = 16;
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Basic Text scale & movement test case.
|
|
61 |
*/
|
|
62 |
class CAlfPerfAppTextTestCaseBasic : public CAlfPerfAppBaseTestCaseControl
|
|
63 |
{
|
|
64 |
public:
|
|
65 |
CAlfPerfAppTextTestCaseBasic();
|
|
66 |
~CAlfPerfAppTextTestCaseBasic();
|
|
67 |
|
|
68 |
virtual void ConstructL(
|
|
69 |
CAlfEnv& aEnv, TInt aCaseId, const TRect& aVisibleArea );
|
|
70 |
virtual void DoStartExecuteL();
|
|
71 |
virtual TBool OfferEventL( const TAlfEvent& aEvent );
|
|
72 |
virtual void SetVisibleArea( const TRect& aVisibleArea );
|
|
73 |
|
|
74 |
private:
|
|
75 |
|
|
76 |
/**
|
|
77 |
* Next cycle.
|
|
78 |
*/
|
|
79 |
void NextCycleL();
|
|
80 |
|
|
81 |
/**
|
|
82 |
* Returns opacity for index.
|
|
83 |
*/
|
|
84 |
TReal32 OpacityForIndex( TInt aIndex );
|
|
85 |
|
|
86 |
/**
|
|
87 |
* Returns size for index.
|
|
88 |
*/
|
|
89 |
TAlfRealSize SizeForIndex( TInt aIndex );
|
|
90 |
|
|
91 |
/**
|
|
92 |
* Returns position for index.
|
|
93 |
*/
|
|
94 |
TAlfRealPoint PositionForIndex( TInt aIndex, const TAlfRealSize& aSize );
|
|
95 |
|
|
96 |
private:
|
|
97 |
/**
|
|
98 |
* Test case of which execution this instance was created.
|
|
99 |
*/
|
|
100 |
TInt iCaseId;
|
|
101 |
|
|
102 |
/**
|
|
103 |
* Text visuals.
|
|
104 |
*/
|
|
105 |
RPointerArray< CAlfTextVisual > iTexts;
|
|
106 |
|
|
107 |
/**
|
|
108 |
* Cycle counter.
|
|
109 |
*/
|
|
110 |
TInt iCycleCounter;
|
|
111 |
|
|
112 |
|
|
113 |
};
|
|
114 |
|
|
115 |
/**
|
|
116 |
* Many texts at the same time
|
|
117 |
*/
|
|
118 |
class CAlfPerfAppTextTestCaseManyTexts : public CAlfPerfAppBaseTestCaseControl
|
|
119 |
{
|
|
120 |
public:
|
|
121 |
CAlfPerfAppTextTestCaseManyTexts();
|
|
122 |
~CAlfPerfAppTextTestCaseManyTexts();
|
|
123 |
|
|
124 |
virtual void ConstructL(
|
|
125 |
CAlfEnv& aEnv, TInt aCaseId, const TRect& aVisibleArea
|
|
126 |
, TInt aSequenceIndex, TInt aVisualCount );
|
|
127 |
virtual void DoStartExecuteL();
|
|
128 |
virtual TBool OfferEventL( const TAlfEvent& aEvent );
|
|
129 |
virtual void SetVisibleArea( const TRect& aVisibleArea );
|
|
130 |
TTestCaseSpecificResultText getResultL();
|
|
131 |
private:
|
|
132 |
|
|
133 |
/**
|
|
134 |
* Next cycle.
|
|
135 |
*/
|
|
136 |
void NextCycleL();
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Returns opacity for index.
|
|
140 |
*/
|
|
141 |
TReal32 OpacityForIndex( TInt aIndex );
|
|
142 |
|
|
143 |
/**
|
|
144 |
* Returns size for index.
|
|
145 |
*/
|
|
146 |
TAlfRealSize SizeForIndex( TInt aIndex );
|
|
147 |
|
|
148 |
/**
|
|
149 |
* Returns position for index.
|
|
150 |
*/
|
|
151 |
TBool PositionForIndex( TInt aIndex, TAlfRealPoint& aPos, const TAlfRealSize& aSize );
|
|
152 |
|
|
153 |
private:
|
|
154 |
|
|
155 |
/**
|
|
156 |
* Text visuals.
|
|
157 |
*/
|
|
158 |
RPointerArray< CAlfTextVisual > iTexts;
|
|
159 |
|
|
160 |
/**
|
|
161 |
* Cycle counter.
|
|
162 |
*/
|
|
163 |
TInt iCycleCounter;
|
|
164 |
|
|
165 |
/**
|
|
166 |
* Test case parameters
|
|
167 |
*/
|
|
168 |
TInt iVisualCount; // Number of visual to be created
|
|
169 |
TInt iVisualColums;
|
|
170 |
TInt iVisualRows;
|
|
171 |
TAlfRealPoint iVisualSpeed; // Pixels to move between cycles
|
|
172 |
//TFileName iImageFileName; // File name of the texture text file
|
|
173 |
TInt iTextCount; // Number of different texts
|
|
174 |
//TAlfTextureFlags iTextureFlags; // Texture flags
|
|
175 |
TAlfRealSize iVisualSize; // Initial size of the visual
|
|
176 |
TAlfRealPoint iVisualSizeVel; // Velocity of visual size change per cycle
|
|
177 |
TInt iSimulatedPointerEventCount; // Number of pointer events sent to visula in one cycle
|
|
178 |
TUint32 iPointerEventTime; //Time to handle pointer event
|
|
179 |
TBool iInactiveVisual;
|
|
180 |
TInt iLastIndexInAnimatedArea; // the index of the last visual that is animated, all before this are also animated
|
|
181 |
TInt iSequenceIndex;
|
|
182 |
};
|
|
183 |
|
|
184 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
185 |
|
|
186 |
// -----------------------------------------------------------------------------
|
|
187 |
// Checks if specified case is supported by this class.
|
|
188 |
// -----------------------------------------------------------------------------
|
|
189 |
//
|
|
190 |
TBool CAlfPerfAppTextTestCase::IsSupported( TInt aCaseId )
|
|
191 |
{
|
|
192 |
return aCaseId > EAlfPerfAppTextMin &&
|
|
193 |
aCaseId < EAlfPerfAppTextMax;
|
|
194 |
}
|
|
195 |
|
|
196 |
CAlfPerfAppTextTestCase* CAlfPerfAppTextTestCase::NewL( TInt aCaseId, TInt aSequenceIndex )
|
|
197 |
{
|
|
198 |
if ( !IsSupported( aCaseId ) )
|
|
199 |
{
|
|
200 |
User::Leave( KErrNotSupported );
|
|
201 |
}
|
|
202 |
|
|
203 |
CAlfPerfAppTextTestCase* self =
|
|
204 |
new (ELeave) CAlfPerfAppTextTestCase( aCaseId, aSequenceIndex );
|
|
205 |
CleanupStack::PushL( self );
|
|
206 |
self->ConstructL();
|
|
207 |
CleanupStack::Pop( self );
|
|
208 |
return self;
|
|
209 |
}
|
|
210 |
|
|
211 |
CAlfPerfAppTextTestCase::~CAlfPerfAppTextTestCase()
|
|
212 |
{
|
|
213 |
if ( iEnv && iControl )
|
|
214 |
{
|
|
215 |
iControl->CancelExecution();
|
|
216 |
iEnv->DeleteControlGroup( KAlfPerfAppTextControlGroup );
|
|
217 |
}
|
|
218 |
}
|
|
219 |
|
|
220 |
// -----------------------------------------------------------------------------
|
|
221 |
// Starts setup phase.
|
|
222 |
// -----------------------------------------------------------------------------
|
|
223 |
//
|
|
224 |
void CAlfPerfAppTextTestCase::SetupL(
|
|
225 |
CAlfEnv& aEnv, const TRect& aVisibleArea, TRequestStatus& aStatus )
|
|
226 |
{
|
|
227 |
iEnv = &aEnv;
|
|
228 |
|
|
229 |
// Init display, fullscreen if in sequence case mode
|
|
230 |
CAlfDisplay* display = 0;
|
|
231 |
CAlfControlGroup& group = iEnv->NewControlGroupL( KAlfPerfAppTextControlGroup );
|
|
232 |
CAlfPerfAppBaseTestCaseControl* control = 0;
|
|
233 |
iTotalVisualCount = -1;
|
|
234 |
iAnimationDivider = 0;
|
|
235 |
|
|
236 |
if(SequenceIndex() != 0)
|
|
237 |
{
|
|
238 |
// Calculate
|
|
239 |
TInt caseNum = SEQUENCE_LENGTH_SQRT - (SequenceIndex()-1) / SEQUENCE_LENGTH_SQRT - 1;
|
|
240 |
TReal trg = 0.0;
|
|
241 |
Math::Pow(trg, 2.0, caseNum);
|
|
242 |
iAnimationDivider = trg+0.5;
|
|
243 |
|
|
244 |
TRect rect;
|
|
245 |
AknLayoutUtils::LayoutMetricsRect(
|
|
246 |
AknLayoutUtils::EApplicationWindow,
|
|
247 |
rect );
|
|
248 |
iEnv->SetFullScreenDrawing( ETrue );
|
|
249 |
|
|
250 |
|
|
251 |
TInt counter = 10 - ((SequenceIndex()-1)%SEQUENCE_LENGTH_SQRT) - 1; // 2^3...2^9 always choose the
|
|
252 |
trg = 0.0;
|
|
253 |
Math::Pow(trg, 2.0, counter);
|
|
254 |
iTotalVisualCount = trg+0.5;
|
|
255 |
|
|
256 |
display = &iEnv->NewDisplayL( rect, CAlfEnv::ENewDisplayFullScreen );
|
|
257 |
|
|
258 |
display->SetClearBackgroundL( CAlfDisplay::EClearWithSkinBackground );
|
|
259 |
|
|
260 |
control = new (ELeave) CAlfPerfAppTextTestCaseManyTexts();
|
|
261 |
CleanupStack::PushL( control );
|
|
262 |
((CAlfPerfAppTextTestCaseManyTexts*)control)->ConstructL( *iEnv, iCaseId, aVisibleArea,SequenceIndex(),iTotalVisualCount );
|
|
263 |
|
|
264 |
}
|
|
265 |
else
|
|
266 |
{
|
|
267 |
display = &iEnv->NewDisplayL( aVisibleArea, CAlfEnv::ENewDisplayAsCoeControl );
|
|
268 |
display->SetClearBackgroundL( CAlfDisplay::EClearWithSkinBackground );
|
|
269 |
|
|
270 |
switch ( iCaseId )
|
|
271 |
{
|
|
272 |
case EAlfPerfAppTextBasicMoveScale:
|
|
273 |
control = new (ELeave) CAlfPerfAppTextTestCaseBasic;
|
|
274 |
CleanupStack::PushL( control );
|
|
275 |
control->ConstructL( *iEnv, iCaseId, aVisibleArea );
|
|
276 |
break;
|
|
277 |
|
|
278 |
case EAlfPerfAppTextManyTexts:
|
|
279 |
case EAlfPerfAppTextManyTextsWithPointerEvent:
|
|
280 |
case EAlfPerfAppTextManyTextsWithAutoSize:
|
|
281 |
case EAlfPerfAppTextInactiveVisuals:
|
|
282 |
control = new (ELeave) CAlfPerfAppTextTestCaseManyTexts;
|
|
283 |
CleanupStack::PushL( control );
|
|
284 |
((CAlfPerfAppTextTestCaseManyTexts*)control)->ConstructL( *iEnv, iCaseId, aVisibleArea,SequenceIndex(),iTotalVisualCount );
|
|
285 |
break;
|
|
286 |
|
|
287 |
default:
|
|
288 |
User::Leave( KErrNotSupported );
|
|
289 |
break;
|
|
290 |
}
|
|
291 |
}
|
|
292 |
|
|
293 |
group.AppendL( control ); // ownership passed to control group.
|
|
294 |
iControl = control;
|
|
295 |
CleanupStack::Pop( control );
|
|
296 |
|
|
297 |
display->Roster().ShowL( group );
|
|
298 |
|
|
299 |
// This must be last statement.
|
|
300 |
CAlfPerfAppTestCase::CompleteNow( aStatus, KErrNone );
|
|
301 |
}
|
|
302 |
|
|
303 |
// -----------------------------------------------------------------------------
|
|
304 |
// Starts execution phase.
|
|
305 |
// -----------------------------------------------------------------------------
|
|
306 |
//
|
|
307 |
void CAlfPerfAppTextTestCase::ExecuteL( TRequestStatus& aStatus )
|
|
308 |
{
|
|
309 |
// SetupL must have been called first.
|
|
310 |
__ASSERT_ALWAYS( iEnv, User::Invariant() );
|
|
311 |
__ASSERT_ALWAYS( iControl, User::Invariant() );
|
|
312 |
|
|
313 |
iControl->StartExecuteL( aStatus );
|
|
314 |
}
|
|
315 |
|
|
316 |
// -----------------------------------------------------------------------------
|
|
317 |
// Tears down.
|
|
318 |
// -----------------------------------------------------------------------------
|
|
319 |
//
|
|
320 |
void CAlfPerfAppTextTestCase::TearDown()
|
|
321 |
{
|
|
322 |
// Execution side will delete CAlfEnv, so it will delete everything
|
|
323 |
// related to this.
|
|
324 |
iEnv = NULL;
|
|
325 |
iControl = NULL;
|
|
326 |
}
|
|
327 |
|
|
328 |
void CAlfPerfAppTextTestCase::HandleVisibleAreaChange( const TRect& aRect )
|
|
329 |
{
|
|
330 |
if ( iEnv && iControl )
|
|
331 |
{
|
|
332 |
if ( iEnv->DisplayCount() > 0 )
|
|
333 |
{
|
|
334 |
iEnv->PrimaryDisplay().SetVisibleArea( aRect );
|
|
335 |
}
|
|
336 |
iControl->SetVisibleArea( aRect );
|
|
337 |
}
|
|
338 |
}
|
|
339 |
|
|
340 |
TInt CAlfPerfAppTextTestCase::CaseID()
|
|
341 |
{
|
|
342 |
return iCaseId;
|
|
343 |
}
|
|
344 |
|
|
345 |
CAlfPerfAppTextTestCase::CAlfPerfAppTextTestCase( TInt aCaseId, TInt aSequenceIndex )
|
|
346 |
: CAlfPerfAppTestCase(aSequenceIndex), iCaseId ( aCaseId )
|
|
347 |
{
|
|
348 |
}
|
|
349 |
|
|
350 |
void CAlfPerfAppTextTestCase::ConstructL()
|
|
351 |
{
|
|
352 |
}
|
|
353 |
|
|
354 |
// Implementation of CAlfPerfAppTextTestCaseBasic:
|
|
355 |
|
|
356 |
CAlfPerfAppTextTestCaseBasic::CAlfPerfAppTextTestCaseBasic()
|
|
357 |
{
|
|
358 |
}
|
|
359 |
|
|
360 |
CAlfPerfAppTextTestCaseBasic::~CAlfPerfAppTextTestCaseBasic()
|
|
361 |
{
|
|
362 |
iTexts.Close();
|
|
363 |
}
|
|
364 |
|
|
365 |
void CAlfPerfAppTextTestCaseBasic::ConstructL(
|
|
366 |
CAlfEnv& aEnv, TInt aCaseId, const TRect& aVisibleArea )
|
|
367 |
{
|
|
368 |
CAlfPerfAppBaseTestCaseControl::ConstructL( aEnv, aCaseId, aVisibleArea );
|
|
369 |
|
|
370 |
for ( TInt ii = 0; ii < KAlfPerfAppTextTestCaseBasicTextCount; ii++ )
|
|
371 |
{
|
|
372 |
CAlfTextVisual* visual = CAlfTextVisual::AddNewL( *this );
|
|
373 |
visual->SetFlag( EAlfVisualFlagManualLayout );
|
|
374 |
visual->SetOpacity( 1.0f );
|
|
375 |
|
|
376 |
visual->SetOpacity( OpacityForIndex( ii ) );
|
|
377 |
TAlfRealSize sz = SizeForIndex( ii );
|
|
378 |
visual->SetSize( sz );
|
|
379 |
visual->SetPos( PositionForIndex( ii, sz ) );
|
|
380 |
|
|
381 |
visual->SetTextL(_L("Text"));
|
|
382 |
|
|
383 |
iTexts.AppendL( visual );
|
|
384 |
|
|
385 |
}
|
|
386 |
|
|
387 |
}
|
|
388 |
|
|
389 |
void CAlfPerfAppTextTestCaseBasic::DoStartExecuteL()
|
|
390 |
{
|
|
391 |
NextCycleL();
|
|
392 |
|
|
393 |
CompleteAfterL( 5000 );
|
|
394 |
}
|
|
395 |
|
|
396 |
void CAlfPerfAppTextTestCaseBasic::SetVisibleArea(
|
|
397 |
const TRect& /*aVisibleArea*/ )
|
|
398 |
{
|
|
399 |
if ( IsExecutionOngoing() )
|
|
400 |
{
|
|
401 |
Env().CancelCustomCommands( this, KAlfPerfAppTextCmdNext );
|
|
402 |
TRAPD( err, NextCycleL() );
|
|
403 |
if ( err != KErrNone )
|
|
404 |
{
|
|
405 |
CompleteNow( err );
|
|
406 |
}
|
|
407 |
}
|
|
408 |
}
|
|
409 |
|
|
410 |
TBool CAlfPerfAppTextTestCaseBasic::OfferEventL( const TAlfEvent& aEvent )
|
|
411 |
{
|
|
412 |
if ( aEvent.IsCustomEvent() &&
|
|
413 |
aEvent.CustomParameter() == KAlfPerfAppTextCmdNext )
|
|
414 |
{
|
|
415 |
TRAPD( err, NextCycleL() );
|
|
416 |
if ( err != KErrNone )
|
|
417 |
{
|
|
418 |
CompleteNow( err );
|
|
419 |
}
|
|
420 |
return ETrue;
|
|
421 |
}
|
|
422 |
|
|
423 |
return CAlfPerfAppBaseTestCaseControl::OfferEventL( aEvent );
|
|
424 |
}
|
|
425 |
|
|
426 |
void CAlfPerfAppTextTestCaseBasic::NextCycleL()
|
|
427 |
{
|
|
428 |
TAlfCustomEventCommand command( KAlfPerfAppTextCmdNext, this );
|
|
429 |
User::LeaveIfError( Env().Send( command, 500 ) );
|
|
430 |
|
|
431 |
iCycleCounter++;
|
|
432 |
|
|
433 |
for ( TInt ii = 0; ii < iTexts.Count(); ii++ )
|
|
434 |
{
|
|
435 |
CAlfTextVisual* visual = iTexts[ ii ];
|
|
436 |
|
|
437 |
TInt speed = KVisualAnimSpeed;
|
|
438 |
if ( ii & 1 )
|
|
439 |
{
|
|
440 |
speed /= 2;
|
|
441 |
}
|
|
442 |
|
|
443 |
visual->SetOpacity( TAlfTimedValue( OpacityForIndex( ii ), speed ) );
|
|
444 |
TAlfRealSize sz = SizeForIndex( ii );
|
|
445 |
visual->SetSize( sz, speed );
|
|
446 |
visual->SetPos( PositionForIndex( ii, sz ), speed );
|
|
447 |
}
|
|
448 |
}
|
|
449 |
|
|
450 |
TReal32 CAlfPerfAppTextTestCaseBasic::OpacityForIndex( TInt aIndex )
|
|
451 |
{
|
|
452 |
switch ( ( iCycleCounter + aIndex ) % 3 )
|
|
453 |
{
|
|
454 |
case 0:
|
|
455 |
return 1.0f;
|
|
456 |
case 1:
|
|
457 |
return 0.5f;
|
|
458 |
case 2:
|
|
459 |
default:
|
|
460 |
return 0.25f;
|
|
461 |
}
|
|
462 |
}
|
|
463 |
|
|
464 |
TAlfRealSize CAlfPerfAppTextTestCaseBasic::SizeForIndex( TInt aIndex )
|
|
465 |
{
|
|
466 |
switch ( ( iCycleCounter + aIndex ) % 3 )
|
|
467 |
{
|
|
468 |
case 0:
|
|
469 |
return TAlfRealSize( 25.f, 25.f );
|
|
470 |
case 1:
|
|
471 |
return TAlfRealSize( 50.f, 50.f );
|
|
472 |
case 2:
|
|
473 |
default:
|
|
474 |
return TAlfRealSize( 100.f, 100.f );
|
|
475 |
}
|
|
476 |
}
|
|
477 |
|
|
478 |
TAlfRealPoint CAlfPerfAppTextTestCaseBasic::PositionForIndex(
|
|
479 |
TInt aIndex, const TAlfRealSize& aSize )
|
|
480 |
{
|
|
481 |
const TSize KSize( Env().PrimaryDisplay().VisibleArea().Size() );
|
|
482 |
|
|
483 |
switch ( ( iCycleCounter + aIndex ) & 3 )
|
|
484 |
{
|
|
485 |
case 0:
|
|
486 |
return TAlfRealPoint( 0.0f, 0.0f );
|
|
487 |
|
|
488 |
case 1:
|
|
489 |
return TAlfRealPoint( KSize.iWidth - aSize.iWidth, KSize.iHeight - aSize.iHeight );
|
|
490 |
|
|
491 |
case 2:
|
|
492 |
return TAlfRealPoint( KSize.iWidth - aSize.iWidth, 0.0f );
|
|
493 |
|
|
494 |
case 3:
|
|
495 |
default:
|
|
496 |
return TAlfRealPoint( 0.0f, KSize.iHeight - aSize.iHeight );
|
|
497 |
}
|
|
498 |
}
|
|
499 |
|
|
500 |
|
|
501 |
// Implementation of CAlfPerfAppTextTestCaseManyTexts:
|
|
502 |
CAlfPerfAppTextTestCaseManyTexts::CAlfPerfAppTextTestCaseManyTexts()
|
|
503 |
{
|
|
504 |
}
|
|
505 |
|
|
506 |
CAlfPerfAppTextTestCaseManyTexts::~CAlfPerfAppTextTestCaseManyTexts()
|
|
507 |
{
|
|
508 |
iTexts.Close();
|
|
509 |
|
|
510 |
//delete iLoader;
|
|
511 |
}
|
|
512 |
|
|
513 |
void CAlfPerfAppTextTestCaseManyTexts::ConstructL(
|
|
514 |
CAlfEnv& aEnv, TInt aCaseId, const TRect& aVisibleArea, TInt aSequenceIndex, TInt aVisualCount )
|
|
515 |
{
|
|
516 |
CAlfPerfAppBaseTestCaseControl::ConstructL( aEnv, aCaseId, aVisibleArea );
|
|
517 |
CAlfTextureManager& textureManager = aEnv.TextureManager();
|
|
518 |
|
|
519 |
// Parameters for test cases
|
|
520 |
|
|
521 |
iVisualSpeed = TAlfRealPoint(1,0);
|
|
522 |
iTextCount = 4;
|
|
523 |
iVisualCount = (aVisualCount != -1) ? aVisualCount : KVisualCout;
|
|
524 |
iVisualSize = TAlfRealSize( 25.f, 25.f );
|
|
525 |
iVisualSizeVel = TAlfRealPoint();
|
|
526 |
iSimulatedPointerEventCount = 0;
|
|
527 |
iLastIndexInAnimatedArea = 0;
|
|
528 |
iSequenceIndex = aSequenceIndex;
|
|
529 |
iPointerEventTime = 0;
|
|
530 |
iInactiveVisual = EFalse;
|
|
531 |
iVisualColums = 0;
|
|
532 |
iVisualRows = 0;
|
|
533 |
|
|
534 |
if(aSequenceIndex != 0)
|
|
535 |
{
|
|
536 |
TInt caseNum = SEQUENCE_LENGTH_SQRT - (iSequenceIndex-1) / SEQUENCE_LENGTH_SQRT - 1;
|
|
537 |
TReal trg = 0.0;
|
|
538 |
Math::Pow(trg, 2.0, caseNum);
|
|
539 |
TInt pow = trg+0.5;
|
|
540 |
TReal animatedAreaRelativeSize = 1.f/pow;
|
|
541 |
|
|
542 |
iLastIndexInAnimatedArea = iVisualCount*animatedAreaRelativeSize+0.5;
|
|
543 |
iLastIndexInAnimatedArea = (iLastIndexInAnimatedArea < 1) ? 1 : iLastIndexInAnimatedArea;
|
|
544 |
|
|
545 |
trg = 0.0;
|
|
546 |
Math::Sqrt(trg,TReal(iVisualCount));
|
|
547 |
iVisualColums = (trg + 0.5);
|
|
548 |
iVisualRows = ((TReal)iVisualCount/iVisualColums) + 0.5;
|
|
549 |
|
|
550 |
TSize displaySize(Env().PrimaryDisplay().VisibleArea().Size());
|
|
551 |
iVisualSize = TAlfRealSize((TReal32)displaySize.iWidth/iVisualColums, (TReal32)displaySize.iHeight/iVisualRows);
|
|
552 |
}
|
|
553 |
else
|
|
554 |
{
|
|
555 |
switch(CaseId())
|
|
556 |
{
|
|
557 |
case EAlfPerfAppTextManyTexts:
|
|
558 |
break;
|
|
559 |
|
|
560 |
case EAlfPerfAppTextManyTextsWithPointerEvent:
|
|
561 |
iSimulatedPointerEventCount = 10;
|
|
562 |
break;
|
|
563 |
|
|
564 |
case EAlfPerfAppTextManyTextsWithAutoSize:
|
|
565 |
iVisualSizeVel = TAlfRealPoint(10,10);
|
|
566 |
break;
|
|
567 |
//To set all but 2 visuals Inactive,
|
|
568 |
//i.e. those will not participate in any of roster operations
|
|
569 |
case EAlfPerfAppTextInactiveVisuals:
|
|
570 |
iInactiveVisual = ETrue;
|
|
571 |
iSimulatedPointerEventCount = 100;
|
|
572 |
break;
|
|
573 |
default:
|
|
574 |
User::Leave( KErrNotSupported );
|
|
575 |
break;
|
|
576 |
};
|
|
577 |
}
|
|
578 |
|
|
579 |
for ( TInt ii = 0; ii < iVisualCount; ii++ )
|
|
580 |
{
|
|
581 |
CAlfTextVisual* visual = CAlfTextVisual::AddNewL( *this );
|
|
582 |
iTexts.AppendL( visual );
|
|
583 |
|
|
584 |
visual->SetFlag( EAlfVisualFlagManualLayout );
|
|
585 |
visual->SetOpacity( 1.0f );
|
|
586 |
|
|
587 |
visual->SetOpacity( OpacityForIndex( ii ) );
|
|
588 |
visual->SetSize( iVisualSize );
|
|
589 |
|
|
590 |
TAlfRealPoint pos(0,0);
|
|
591 |
if (PositionForIndex( ii, pos, iVisualSize ))
|
|
592 |
{
|
|
593 |
visual->SetPos( pos );
|
|
594 |
}
|
|
595 |
|
|
596 |
visual->SetTextL( _L("TEXT"));
|
|
597 |
#ifdef ALFPERFAPP_ENABLE_INACTIVE_FLAG_CASES
|
|
598 |
if ( iInactiveVisual && ii < iVisualCount-2 )
|
|
599 |
{
|
|
600 |
visual->SetFlag( EAlfVisualFlagInactive );
|
|
601 |
}
|
|
602 |
#endif
|
|
603 |
}
|
|
604 |
}
|
|
605 |
|
|
606 |
void CAlfPerfAppTextTestCaseManyTexts::DoStartExecuteL()
|
|
607 |
{
|
|
608 |
NextCycleL();
|
|
609 |
|
|
610 |
CompleteAfterL( 5000 );
|
|
611 |
}
|
|
612 |
|
|
613 |
void CAlfPerfAppTextTestCaseManyTexts::SetVisibleArea(
|
|
614 |
const TRect& /*aVisibleArea*/ )
|
|
615 |
{
|
|
616 |
if ( IsExecutionOngoing() )
|
|
617 |
{
|
|
618 |
Env().CancelCustomCommands( this, KAlfPerfAppTextCmdNext );
|
|
619 |
TRAPD( err, NextCycleL() );
|
|
620 |
if ( err != KErrNone )
|
|
621 |
{
|
|
622 |
CompleteNow( err );
|
|
623 |
}
|
|
624 |
}
|
|
625 |
}
|
|
626 |
|
|
627 |
TBool CAlfPerfAppTextTestCaseManyTexts::OfferEventL( const TAlfEvent& aEvent )
|
|
628 |
{
|
|
629 |
if ( aEvent.IsCustomEvent() &&
|
|
630 |
aEvent.CustomParameter() == KAlfPerfAppTextCmdNext )
|
|
631 |
{
|
|
632 |
TRAPD( err, NextCycleL() );
|
|
633 |
if ( err != KErrNone )
|
|
634 |
{
|
|
635 |
CompleteNow( err );
|
|
636 |
}
|
|
637 |
return ETrue;
|
|
638 |
}
|
|
639 |
|
|
640 |
return CAlfPerfAppBaseTestCaseControl::OfferEventL( aEvent );
|
|
641 |
}
|
|
642 |
|
|
643 |
void CAlfPerfAppTextTestCaseManyTexts::NextCycleL()
|
|
644 |
{
|
|
645 |
TAlfCustomEventCommand command( KAlfPerfAppTextCmdNext, this );
|
|
646 |
User::LeaveIfError( Env().Send( command, 500 ) );
|
|
647 |
|
|
648 |
iCycleCounter++;
|
|
649 |
|
|
650 |
// Update cycle state
|
|
651 |
for ( TInt ii = 0; ii < iTexts.Count(); ii++ )
|
|
652 |
{
|
|
653 |
CAlfTextVisual* visual = iTexts[ ii ];
|
|
654 |
|
|
655 |
TInt speed = KVisualAnimSpeed;
|
|
656 |
|
|
657 |
visual->SetOpacity( TAlfTimedValue( OpacityForIndex( ii ), speed ) );
|
|
658 |
TAlfRealSize sz = SizeForIndex( ii );
|
|
659 |
visual->SetSize( sz, speed );
|
|
660 |
|
|
661 |
TAlfRealPoint pos(0,0);
|
|
662 |
if (PositionForIndex( ii, pos, iVisualSize ))
|
|
663 |
{
|
|
664 |
visual->SetPos( pos,speed );
|
|
665 |
}
|
|
666 |
}
|
|
667 |
if ( iSimulatedPointerEventCount )
|
|
668 |
{
|
|
669 |
TInt tickPeriod1;
|
|
670 |
tickPeriod1 = User::TickCount();
|
|
671 |
while( (User::TickCount() - tickPeriod1) ==0 ) ; // wait for a tick rollover
|
|
672 |
|
|
673 |
// Send pointer events
|
|
674 |
for (TInt i=0; i <iSimulatedPointerEventCount; i++)
|
|
675 |
{
|
|
676 |
const TSize KSize( Env().PrimaryDisplay().VisibleArea().Size() );
|
|
677 |
|
|
678 |
TPoint pos(AlfUtil::RandomInt(0, KSize.iWidth-1), AlfUtil::RandomInt(0, KSize.iWidth-1));
|
|
679 |
|
|
680 |
// down
|
|
681 |
TPointerEvent eventDown(TPointerEvent::EButton1Down, 0, pos, TPoint(0,0));
|
|
682 |
Env().PrimaryDisplay().HandlePointerEventL( eventDown );
|
|
683 |
|
|
684 |
//up
|
|
685 |
TPointerEvent eventUp(TPointerEvent::EButton1Up, 0, pos, TPoint(0,0));
|
|
686 |
Env().PrimaryDisplay().HandlePointerEventL( eventUp );
|
|
687 |
}
|
|
688 |
TInt tickPeriod2 = User::TickCount();
|
|
689 |
iPointerEventTime = iPointerEventTime + ( tickPeriod2 - tickPeriod1 );
|
|
690 |
}
|
|
691 |
}
|
|
692 |
|
|
693 |
TReal32 CAlfPerfAppTextTestCaseManyTexts::OpacityForIndex( TInt aIndex )
|
|
694 |
{
|
|
695 |
|
|
696 |
if (iSequenceIndex != 0 && aIndex <= iLastIndexInAnimatedArea)
|
|
697 |
{
|
|
698 |
if (iCycleCounter&0x01)
|
|
699 |
{
|
|
700 |
return 0.7f;
|
|
701 |
}
|
|
702 |
else
|
|
703 |
{
|
|
704 |
return 0.9f;
|
|
705 |
}
|
|
706 |
}
|
|
707 |
return 0.5f;
|
|
708 |
}
|
|
709 |
|
|
710 |
TAlfRealSize CAlfPerfAppTextTestCaseManyTexts::SizeForIndex( TInt aIndex )
|
|
711 |
{
|
|
712 |
TAlfRealSize size = iTexts[ aIndex ]->Size().Target();
|
|
713 |
return TAlfRealSize( size.iWidth + iVisualSizeVel.iX, size.iHeight + iVisualSizeVel.iY );
|
|
714 |
}
|
|
715 |
|
|
716 |
TBool CAlfPerfAppTextTestCaseManyTexts::PositionForIndex(
|
|
717 |
TInt aIndex, TAlfRealPoint& aPos, const TAlfRealSize& /*aSize*/ )
|
|
718 |
{
|
|
719 |
|
|
720 |
if (iSequenceIndex != 0)
|
|
721 |
{
|
|
722 |
if(iCycleCounter == 0 || aIndex <= iLastIndexInAnimatedArea)
|
|
723 |
{
|
|
724 |
TInt gridIndex = aIndex + iCycleCounter;
|
|
725 |
TInt columnPos = gridIndex % iVisualColums;
|
|
726 |
TInt rowPos = gridIndex / iVisualColums;
|
|
727 |
rowPos = rowPos % iVisualRows;
|
|
728 |
//TAlfRealSize visualSize = iImages[ aIndex ]->Size().Target();
|
|
729 |
aPos = TAlfRealPoint( columnPos*iVisualSize.iWidth, rowPos*iVisualSize.iHeight );
|
|
730 |
return ETrue;
|
|
731 |
}
|
|
732 |
else
|
|
733 |
{
|
|
734 |
return EFalse;
|
|
735 |
}
|
|
736 |
}
|
|
737 |
|
|
738 |
|
|
739 |
|
|
740 |
TInt KItemStep = 20;
|
|
741 |
const TSize KSize( Env().PrimaryDisplay().VisibleArea().Size() );
|
|
742 |
const TSize KSize2( KSize.iWidth/KItemStep, KSize.iHeight/KItemStep);
|
|
743 |
|
|
744 |
TInt pos = aIndex + iCycleCounter * iVisualSpeed.iX;
|
|
745 |
TInt ypos = pos / KSize2.iWidth;
|
|
746 |
ypos = ypos % KSize2.iHeight;
|
|
747 |
TInt xpos = pos % KSize2.iWidth;
|
|
748 |
aPos = TAlfRealPoint( xpos*KItemStep, ypos*KItemStep );
|
|
749 |
return ETrue;
|
|
750 |
}
|
|
751 |
//Write pointer event lag result
|
|
752 |
TTestCaseSpecificResultText CAlfPerfAppTextTestCase::getCaseSpecificResultL()
|
|
753 |
{
|
|
754 |
if(SequenceIndex() != 0 && CaseID() == EAlfPerfAppTextManyTexts)
|
|
755 |
{
|
|
756 |
TTestCaseSpecificResultText result = HBufC::NewL(KAlfPerfAppMaxCharsInSpecificResultText);
|
|
757 |
result->Des().Append(_L("Total Visual Count: "));
|
|
758 |
result->Des().AppendNum(iTotalVisualCount);
|
|
759 |
result->Des().Append(_L(" Animated: 1/"));
|
|
760 |
result->Des().AppendNum(iAnimationDivider);
|
|
761 |
return result;
|
|
762 |
}
|
|
763 |
|
|
764 |
if(iCaseId == EAlfPerfAppTextManyTextsWithPointerEvent ||
|
|
765 |
iCaseId == EAlfPerfAppTextInactiveVisuals)
|
|
766 |
{
|
|
767 |
if ( iControl)
|
|
768 |
{
|
|
769 |
return static_cast<CAlfPerfAppTextTestCaseManyTexts*>(iControl)->getResultL();
|
|
770 |
}
|
|
771 |
}
|
|
772 |
// If nothing was done before this, return empty result
|
|
773 |
TTestCaseSpecificResultText emptyResult = 0;
|
|
774 |
return emptyResult;
|
|
775 |
}
|
|
776 |
|
|
777 |
TTestCaseSpecificResultText CAlfPerfAppTextTestCaseManyTexts::getResultL()
|
|
778 |
{
|
|
779 |
TTestCaseSpecificResultText result = 0;
|
|
780 |
if ( iSimulatedPointerEventCount )
|
|
781 |
{
|
|
782 |
//Assuming tic period to be 1 ms
|
|
783 |
if(iPointerEventTime && iCycleCounter)
|
|
784 |
{
|
|
785 |
iPointerEventTime = ((iPointerEventTime/iCycleCounter)*1000)/(iSimulatedPointerEventCount*2);
|
|
786 |
}
|
|
787 |
if(iPointerEventTime)
|
|
788 |
{
|
|
789 |
result = HBufC::NewL(KAlfPerfAppMaxCharsInSpecificResultText);
|
|
790 |
if ( iInactiveVisual )
|
|
791 |
{
|
|
792 |
result->Des().Append(_L("Inactive Visual "));
|
|
793 |
}
|
|
794 |
result->Des().Append(_L("Avg Pointer event lag: "));
|
|
795 |
result->Des().AppendNum( iPointerEventTime );
|
|
796 |
result->Des().Append(_L("ms"));
|
|
797 |
}
|
|
798 |
}
|
|
799 |
return result;
|
|
800 |
}
|
|
801 |
|
|
802 |
|