Update contrib.
1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 @internalComponent - Internal Symbian test code
22 #include "tsmallwindowstest.h"
23 #include "tsmallwindowraster.h"
24 #include "tflowwindowscontroller.h"
26 #include <imageconversion.h>
29 const TInt KNumberOfBounces = 3;
31 _LIT(KTestStep0012,"GRAPHICS-UI-BENCH-S60-0012");
34 CTSmallWindowsTest::CTSmallWindowsTest()
36 SetTestStepName(KTSmallWindows);
39 CTSmallWindowsTest::~CTSmallWindowsTest()
41 delete iFlowWindowsController;
45 TVerdict CTSmallWindowsTest::doTestStepPreambleL()
47 CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL();
48 iScreenSize = CTWindow::GetDisplaySizeInPixels();
49 TBool preload = EFalse;
50 GetBoolFromConfig(_L("FlowTests"), _L("Preload"), preload);
53 TEST(GetStringFromConfig(_L("FlowTests"), _L("Files"), fileNameList));
54 ExtractListL(fileNameList, iFileNames);
56 ComputeSmallWindows();
58 TPoint initialPosition(0, 0);
59 RArray<TPoint> initialPositions;
60 RArray<pTWindowCreatorFunction> windowCreatorFunctions;
61 CleanupClosePushL(initialPositions);
62 CleanupClosePushL(windowCreatorFunctions);
63 for (TInt i = 0; i < iWindowsAcross; i++)
65 initialPosition.iY = 0;
66 for (TInt j = 0; j < iWindowsAcross; j++)
68 windowCreatorFunctions.AppendL(CTSmallWindowRaster::NewL);
69 initialPositions.AppendL(initialPosition);
70 initialPosition.iY += iWindowSize.iHeight;
72 initialPosition.iX += iWindowSize.iWidth;
75 iFlowWindowsController = CTFlowWindowsController::NewL(preload, iFileNames, iWindowSize, windowCreatorFunctions, initialPositions, ETrue);
76 CleanupStack::PopAndDestroy(2, &initialPositions);
77 return TestStepResult();
80 void CTSmallWindowsTest::ComputeSmallWindows()
82 TReal sqrtWindowsAcross;
83 Math::Sqrt(sqrtWindowsAcross, iFileNames.Count());
84 iWindowsAcross = sqrtWindowsAcross;
87 TESTNOERRORL(fs.Connect());
88 CleanupClosePushL(fs);
89 CImageDecoder* decoder = CImageDecoder::FileNewL(fs, iFileNames[0], CImageDecoder::EOptionAlwaysThread);
90 TFrameInfo info = decoder->FrameInfo();
91 TReal imageAspectRatio = (TReal)info.iOverallSizeInPixels.iWidth/(TReal)info.iOverallSizeInPixels.iHeight;
93 CleanupStack::PopAndDestroy();
95 // set window size to create required grid
96 iWindowSize.iHeight = iScreenSize.iHeight / iWindowsAcross;
97 iWindowSize.iWidth = iScreenSize.iWidth / iWindowsAcross;
98 TReal windowAspectRatio = (TReal)iWindowSize.iWidth / (TReal)iWindowSize.iHeight;
100 // adjust window size to maintain image aspect ratio
101 if (iWindowSize.iWidth > iWindowSize.iHeight)
103 iWindowSize.iWidth /= windowAspectRatio / imageAspectRatio;
107 iWindowSize.iHeight *= windowAspectRatio / imageAspectRatio;
110 // run the test enough frames to see bounce the grid twice
111 if (iScreenSize.iHeight > iScreenSize.iWidth)
113 iIterationsToTest = KNumberOfBounces * (iScreenSize.iHeight - iWindowSize.iHeight * iWindowsAcross);
117 iIterationsToTest = KNumberOfBounces * (iScreenSize.iWidth - iWindowSize.iWidth * iWindowsAcross);
123 Override of base class pure virtual
124 Our implementation only gets called if the base class doTestStepPreambleL() did
127 @return - TVerdict code
129 TVerdict CTSmallWindowsTest::doTestStepL()
131 SetTestStepID(KTestStep0012);
133 //RecordTestResultL(); // todo: not possible because of heap alloc panic
134 return TestStepResult();
139 GRAPHICS-UI-BENCH-S60-0012
142 Tests how long it takes to move small windows over the screen.
145 Creates small windows which draw bitmaps and moves them over the screen.
147 @SYMTestExpectedResults
148 Test should pass and write the average framerate of the test to a log file.
150 void CTSmallWindowsTest::FlowWindowsL()
152 iProfiler->InitResults();
153 iIterationsToTest = 10;
154 for (TInt i = 0; i <= iIterationsToTest; ++i)
156 iFlowWindowsController->MoveL();
158 iProfiler->MarkResultSetL();
159 TInt drawingRect = iWindowSize.iHeight * iWindowSize.iWidth * iWindowsAcross * iWindowsAcross;
160 iProfiler->ResultsAnalysisFrameRate(KTestStep0012, 0, 0, 0, iIterationsToTest, drawingRect);