os/graphics/graphicstest/uibench/s60/src/tests_flowwindow/tsmallwindowstest.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicstest/uibench/s60/src/tests_flowwindow/tsmallwindowstest.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,163 @@
     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 "tsmallwindowstest.h"
    1.26 +#include "tsmallwindowraster.h"
    1.27 +#include "tflowwindowscontroller.h"
    1.28 +
    1.29 +#include <imageconversion.h>
    1.30 +
    1.31 +
    1.32 +const TInt KNumberOfBounces = 3;
    1.33 +
    1.34 +_LIT(KTestStep0012,"GRAPHICS-UI-BENCH-S60-0012");
    1.35 +
    1.36 +
    1.37 +CTSmallWindowsTest::CTSmallWindowsTest()
    1.38 +	{
    1.39 +	SetTestStepName(KTSmallWindows);
    1.40 +	}
    1.41 +
    1.42 +CTSmallWindowsTest::~CTSmallWindowsTest()
    1.43 +	{
    1.44 +	delete iFlowWindowsController;
    1.45 +    iFileNames.Close();
    1.46 +    }
    1.47 +
    1.48 +TVerdict CTSmallWindowsTest::doTestStepPreambleL()
    1.49 +	{
    1.50 +	CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL();
    1.51 +	iScreenSize = CTWindow::GetDisplaySizeInPixels();	
    1.52 +	TBool preload = EFalse;
    1.53 +	GetBoolFromConfig(_L("FlowTests"), _L("Preload"), preload);
    1.54 +
    1.55 +	TPtrC fileNameList;
    1.56 +	TEST(GetStringFromConfig(_L("FlowTests"), _L("Files"), fileNameList));
    1.57 +	ExtractListL(fileNameList, iFileNames);
    1.58 +
    1.59 +	ComputeSmallWindows();
    1.60 +
    1.61 +	TPoint initialPosition(0, 0);
    1.62 +	RArray<TPoint> initialPositions;
    1.63 +    RArray<pTWindowCreatorFunction> windowCreatorFunctions;
    1.64 +    CleanupClosePushL(initialPositions);
    1.65 +    CleanupClosePushL(windowCreatorFunctions);
    1.66 +	for (TInt i = 0; i < iWindowsAcross; i++)
    1.67 +		{
    1.68 +		initialPosition.iY = 0;
    1.69 +		for (TInt j = 0; j < iWindowsAcross; j++)
    1.70 +			{
    1.71 +			windowCreatorFunctions.AppendL(CTSmallWindowRaster::NewL);
    1.72 +			initialPositions.AppendL(initialPosition);
    1.73 +			initialPosition.iY += iWindowSize.iHeight;
    1.74 +			}
    1.75 +		initialPosition.iX += iWindowSize.iWidth;
    1.76 +		}
    1.77 +
    1.78 +	iFlowWindowsController = CTFlowWindowsController::NewL(preload, iFileNames, iWindowSize, windowCreatorFunctions, initialPositions, ETrue);
    1.79 +    CleanupStack::PopAndDestroy(2, &initialPositions);
    1.80 +	return TestStepResult();
    1.81 +	}
    1.82 +
    1.83 +void CTSmallWindowsTest::ComputeSmallWindows()
    1.84 +    {
    1.85 +    TReal sqrtWindowsAcross;
    1.86 +    Math::Sqrt(sqrtWindowsAcross, iFileNames.Count());
    1.87 +    iWindowsAcross = sqrtWindowsAcross;
    1.88 +
    1.89 +    RFs fs;
    1.90 +    TESTNOERRORL(fs.Connect());
    1.91 +    CleanupClosePushL(fs);
    1.92 +    CImageDecoder* decoder = CImageDecoder::FileNewL(fs, iFileNames[0], CImageDecoder::EOptionAlwaysThread);
    1.93 +    TFrameInfo info = decoder->FrameInfo();
    1.94 +    TReal imageAspectRatio = (TReal)info.iOverallSizeInPixels.iWidth/(TReal)info.iOverallSizeInPixels.iHeight;
    1.95 +    delete decoder;
    1.96 +    CleanupStack::PopAndDestroy();
    1.97 +    
    1.98 +    // set window size to create required grid
    1.99 +    iWindowSize.iHeight = iScreenSize.iHeight / iWindowsAcross;
   1.100 +    iWindowSize.iWidth = iScreenSize.iWidth / iWindowsAcross;
   1.101 +    TReal windowAspectRatio = (TReal)iWindowSize.iWidth / (TReal)iWindowSize.iHeight;
   1.102 +    
   1.103 +    // adjust window size to maintain image aspect ratio
   1.104 +    if (iWindowSize.iWidth > iWindowSize.iHeight)
   1.105 +        {
   1.106 +        iWindowSize.iWidth /= windowAspectRatio / imageAspectRatio;
   1.107 +        }
   1.108 +    else
   1.109 +        {
   1.110 +        iWindowSize.iHeight *= windowAspectRatio / imageAspectRatio;
   1.111 +        }
   1.112 +        
   1.113 +    // run the test enough frames to see bounce the grid twice
   1.114 +    if (iScreenSize.iHeight > iScreenSize.iWidth)
   1.115 +        {
   1.116 +        iIterationsToTest = KNumberOfBounces * (iScreenSize.iHeight - iWindowSize.iHeight * iWindowsAcross);
   1.117 +        }
   1.118 +    else 
   1.119 +        {
   1.120 +        iIterationsToTest = KNumberOfBounces * (iScreenSize.iWidth - iWindowSize.iWidth * iWindowsAcross);
   1.121 +        }
   1.122 +    }
   1.123 +
   1.124 +
   1.125 +/**
   1.126 +    Override of base class pure virtual
   1.127 +    Our implementation only gets called if the base class doTestStepPreambleL() did
   1.128 +    not leave.
   1.129 +    
   1.130 +    @return - TVerdict code
   1.131 +*/
   1.132 +TVerdict CTSmallWindowsTest::doTestStepL()
   1.133 +    {
   1.134 +    SetTestStepID(KTestStep0012);
   1.135 +    FlowWindowsL();
   1.136 +    //RecordTestResultL(); // todo: not possible because of heap alloc panic
   1.137 +    return TestStepResult();
   1.138 +    }
   1.139 +
   1.140 +/**
   1.141 +@SYMTestCaseID
   1.142 +GRAPHICS-UI-BENCH-S60-0012
   1.143 +
   1.144 +@SYMTestCaseDesc
   1.145 +Tests how long it takes to move small windows over the screen.
   1.146 +
   1.147 +@SYMTestActions
   1.148 +Creates small windows which draw bitmaps and moves them over the screen.
   1.149 +
   1.150 +@SYMTestExpectedResults
   1.151 +Test should pass and write the average framerate of the test to a log file.
   1.152 +*/
   1.153 +void CTSmallWindowsTest::FlowWindowsL()
   1.154 +    {
   1.155 +    iProfiler->InitResults();
   1.156 +    iIterationsToTest = 10;
   1.157 +    for (TInt i = 0; i <= iIterationsToTest; ++i)
   1.158 +        {
   1.159 +        iFlowWindowsController->MoveL();        
   1.160 +        }
   1.161 +    iProfiler->MarkResultSetL();
   1.162 +    TInt drawingRect = iWindowSize.iHeight * iWindowSize.iWidth * iWindowsAcross * iWindowsAcross;
   1.163 +    iProfiler->ResultsAnalysisFrameRate(KTestStep0012, 0, 0, 0, iIterationsToTest, drawingRect);    
   1.164 +    }
   1.165 +
   1.166 +