os/graphics/graphicstest/uibench/s60/src/tests_flowwindow/tsmallwindowstestzoom.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicstest/uibench/s60/src/tests_flowwindow/tsmallwindowstestzoom.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,140 @@
1.4 +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +/**
1.20 + @file
1.21 + @test
1.22 + @internalComponent - Internal Symbian test code
1.23 +*/
1.24 +
1.25 +#include "tsmallwindowstestzoom.h"
1.26 +#include "tsmallwindowzoom.h"
1.27 +
1.28 +
1.29 +const TInt KWindowsAcross = 2;
1.30 +const TInt KWindowsDown = 2;
1.31 +
1.32 +const TInt KNumberOfBounces = 3;
1.33 +
1.34 +_LIT(KSmallBitmap,"z:\\resource\\apps\\uibench_s60_small.mbm");
1.35 +_LIT(KTestStep0016,"GRAPHICS-UI-BENCH-S60-0016");
1.36 +
1.37 +
1.38 +CTSmallWindowsTestZoom::CTSmallWindowsTestZoom()
1.39 + {
1.40 + SetTestStepName(KTSmallWindowsZoom);
1.41 + }
1.42 +
1.43 +CTSmallWindowsTestZoom::~CTSmallWindowsTestZoom()
1.44 + {
1.45 + delete iFlowWindowsController;
1.46 + iFileNames.Close();
1.47 + }
1.48 +
1.49 +TVerdict CTSmallWindowsTestZoom::doTestStepPreambleL()
1.50 + {
1.51 + CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL();
1.52 +
1.53 + TSize screenSize = CTWindow::GetDisplaySizeInPixels();
1.54 +
1.55 + // set window size to create required grid
1.56 + iWindowSize.iHeight = screenSize.iHeight / KWindowsDown;
1.57 + iWindowSize.iWidth = screenSize.iWidth / KWindowsAcross;
1.58 + // adjust window size to maintain image aspect ratio
1.59 + if (iWindowSize.iWidth > iWindowSize.iHeight)
1.60 + {
1.61 + iWindowSize.iWidth = iWindowSize.iHeight;
1.62 + }
1.63 + else
1.64 + {
1.65 + iWindowSize.iHeight = iWindowSize.iWidth;
1.66 + }
1.67 +
1.68 + TPoint initialPosition(0, 0);
1.69 + RArray<TPoint> initialPositions;
1.70 + RArray<pTWindowCreatorFunction> windowCreatorFunctions;
1.71 + CleanupClosePushL(initialPositions);
1.72 + CleanupClosePushL(windowCreatorFunctions);
1.73 + for (TInt i = 0; i < KWindowsAcross; i++)
1.74 + {
1.75 + initialPosition.iY = 0;
1.76 + for (TInt j = 0; j < KWindowsDown; j++)
1.77 + {
1.78 + windowCreatorFunctions.AppendL(CTSmallWindowZoom::NewL);
1.79 + initialPositions.AppendL(initialPosition);
1.80 + iFileNames.AppendL(KSmallBitmap());
1.81 + initialPosition.iY += iWindowSize.iHeight;
1.82 + }
1.83 + initialPosition.iX += iWindowSize.iWidth;
1.84 + }
1.85 +
1.86 + iFlowWindowsController = CTFlowWindowsController::NewL(ETrue, iFileNames, iWindowSize, windowCreatorFunctions, initialPositions, ETrue);
1.87 + CleanupStack::PopAndDestroy(2, &initialPositions);
1.88 +
1.89 + // run the test enough frames to see move the grid across the screen
1.90 + if (screenSize.iHeight > screenSize.iWidth)
1.91 + {
1.92 + iIterationsToTest = KNumberOfBounces * (screenSize.iHeight - iWindowSize.iHeight * KWindowsDown);
1.93 + }
1.94 + else
1.95 + {
1.96 + iIterationsToTest = KNumberOfBounces * (screenSize.iWidth - iWindowSize.iWidth * KWindowsAcross);
1.97 + }
1.98 +
1.99 + return TestStepResult();
1.100 + }
1.101 +
1.102 +/**
1.103 + Override of base class pure virtual
1.104 + Our implementation only gets called if the base class doTestStepPreambleL() did
1.105 + not leave.
1.106 +
1.107 + @return - TVerdict code
1.108 +*/
1.109 +TVerdict CTSmallWindowsTestZoom::doTestStepL()
1.110 + {
1.111 + SetTestStepID(KTestStep0016);
1.112 + FlowWindowsL();
1.113 + //RecordTestResultL(); // todo: not possible because of heap alloc panic
1.114 + return TestStepResult();
1.115 + }
1.116 +
1.117 +/**
1.118 +@SYMTestCaseID
1.119 +GRAPHICS-UI-BENCH-S60-0016
1.120 +
1.121 +@SYMTestCaseDesc
1.122 +Tests how long it takes to zoom small windows.
1.123 +
1.124 +@SYMTestActions
1.125 +Creates windows which draw Bitmaps and zooms them.
1.126 +
1.127 +@SYMTestExpectedResults
1.128 +Test should pass and write the average framerate of the test to a log file.
1.129 +*/
1.130 +void CTSmallWindowsTestZoom::FlowWindowsL()
1.131 + {
1.132 + iProfiler->InitResults();
1.133 + iIterationsToTest = 50;
1.134 + for (TInt i = 0; i <= iIterationsToTest; ++i)
1.135 + {
1.136 + iFlowWindowsController->MoveL();
1.137 + // todo: why is a pause needed to let wserv redraw the screen?
1.138 + User::After(10000); // needed, otherwise test is not waiting for wserv to redraw (10 ms)
1.139 + }
1.140 + iProfiler->MarkResultSetL();
1.141 + TInt drawingRect = iWindowSize.iHeight * iWindowSize.iWidth * KWindowsAcross * KWindowsDown;
1.142 + iProfiler->ResultsAnalysisFrameRate(KTestStep0016, 0, 0, 0, iIterationsToTest, drawingRect);
1.143 + }