os/graphics/graphicstest/uibench/s60/src/tests_flowwindow/tsmallwindowstest.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file
sl@0
    18
 @test
sl@0
    19
 @internalComponent - Internal Symbian test code 
sl@0
    20
*/
sl@0
    21
sl@0
    22
#include "tsmallwindowstest.h"
sl@0
    23
#include "tsmallwindowraster.h"
sl@0
    24
#include "tflowwindowscontroller.h"
sl@0
    25
sl@0
    26
#include <imageconversion.h>
sl@0
    27
sl@0
    28
sl@0
    29
const TInt KNumberOfBounces = 3;
sl@0
    30
sl@0
    31
_LIT(KTestStep0012,"GRAPHICS-UI-BENCH-S60-0012");
sl@0
    32
sl@0
    33
sl@0
    34
CTSmallWindowsTest::CTSmallWindowsTest()
sl@0
    35
	{
sl@0
    36
	SetTestStepName(KTSmallWindows);
sl@0
    37
	}
sl@0
    38
sl@0
    39
CTSmallWindowsTest::~CTSmallWindowsTest()
sl@0
    40
	{
sl@0
    41
	delete iFlowWindowsController;
sl@0
    42
    iFileNames.Close();
sl@0
    43
    }
sl@0
    44
sl@0
    45
TVerdict CTSmallWindowsTest::doTestStepPreambleL()
sl@0
    46
	{
sl@0
    47
	CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL();
sl@0
    48
	iScreenSize = CTWindow::GetDisplaySizeInPixels();	
sl@0
    49
	TBool preload = EFalse;
sl@0
    50
	GetBoolFromConfig(_L("FlowTests"), _L("Preload"), preload);
sl@0
    51
sl@0
    52
	TPtrC fileNameList;
sl@0
    53
	TEST(GetStringFromConfig(_L("FlowTests"), _L("Files"), fileNameList));
sl@0
    54
	ExtractListL(fileNameList, iFileNames);
sl@0
    55
sl@0
    56
	ComputeSmallWindows();
sl@0
    57
sl@0
    58
	TPoint initialPosition(0, 0);
sl@0
    59
	RArray<TPoint> initialPositions;
sl@0
    60
    RArray<pTWindowCreatorFunction> windowCreatorFunctions;
sl@0
    61
    CleanupClosePushL(initialPositions);
sl@0
    62
    CleanupClosePushL(windowCreatorFunctions);
sl@0
    63
	for (TInt i = 0; i < iWindowsAcross; i++)
sl@0
    64
		{
sl@0
    65
		initialPosition.iY = 0;
sl@0
    66
		for (TInt j = 0; j < iWindowsAcross; j++)
sl@0
    67
			{
sl@0
    68
			windowCreatorFunctions.AppendL(CTSmallWindowRaster::NewL);
sl@0
    69
			initialPositions.AppendL(initialPosition);
sl@0
    70
			initialPosition.iY += iWindowSize.iHeight;
sl@0
    71
			}
sl@0
    72
		initialPosition.iX += iWindowSize.iWidth;
sl@0
    73
		}
sl@0
    74
sl@0
    75
	iFlowWindowsController = CTFlowWindowsController::NewL(preload, iFileNames, iWindowSize, windowCreatorFunctions, initialPositions, ETrue);
sl@0
    76
    CleanupStack::PopAndDestroy(2, &initialPositions);
sl@0
    77
	return TestStepResult();
sl@0
    78
	}
sl@0
    79
sl@0
    80
void CTSmallWindowsTest::ComputeSmallWindows()
sl@0
    81
    {
sl@0
    82
    TReal sqrtWindowsAcross;
sl@0
    83
    Math::Sqrt(sqrtWindowsAcross, iFileNames.Count());
sl@0
    84
    iWindowsAcross = sqrtWindowsAcross;
sl@0
    85
sl@0
    86
    RFs fs;
sl@0
    87
    TESTNOERRORL(fs.Connect());
sl@0
    88
    CleanupClosePushL(fs);
sl@0
    89
    CImageDecoder* decoder = CImageDecoder::FileNewL(fs, iFileNames[0], CImageDecoder::EOptionAlwaysThread);
sl@0
    90
    TFrameInfo info = decoder->FrameInfo();
sl@0
    91
    TReal imageAspectRatio = (TReal)info.iOverallSizeInPixels.iWidth/(TReal)info.iOverallSizeInPixels.iHeight;
sl@0
    92
    delete decoder;
sl@0
    93
    CleanupStack::PopAndDestroy();
sl@0
    94
    
sl@0
    95
    // set window size to create required grid
sl@0
    96
    iWindowSize.iHeight = iScreenSize.iHeight / iWindowsAcross;
sl@0
    97
    iWindowSize.iWidth = iScreenSize.iWidth / iWindowsAcross;
sl@0
    98
    TReal windowAspectRatio = (TReal)iWindowSize.iWidth / (TReal)iWindowSize.iHeight;
sl@0
    99
    
sl@0
   100
    // adjust window size to maintain image aspect ratio
sl@0
   101
    if (iWindowSize.iWidth > iWindowSize.iHeight)
sl@0
   102
        {
sl@0
   103
        iWindowSize.iWidth /= windowAspectRatio / imageAspectRatio;
sl@0
   104
        }
sl@0
   105
    else
sl@0
   106
        {
sl@0
   107
        iWindowSize.iHeight *= windowAspectRatio / imageAspectRatio;
sl@0
   108
        }
sl@0
   109
        
sl@0
   110
    // run the test enough frames to see bounce the grid twice
sl@0
   111
    if (iScreenSize.iHeight > iScreenSize.iWidth)
sl@0
   112
        {
sl@0
   113
        iIterationsToTest = KNumberOfBounces * (iScreenSize.iHeight - iWindowSize.iHeight * iWindowsAcross);
sl@0
   114
        }
sl@0
   115
    else 
sl@0
   116
        {
sl@0
   117
        iIterationsToTest = KNumberOfBounces * (iScreenSize.iWidth - iWindowSize.iWidth * iWindowsAcross);
sl@0
   118
        }
sl@0
   119
    }
sl@0
   120
sl@0
   121
sl@0
   122
/**
sl@0
   123
    Override of base class pure virtual
sl@0
   124
    Our implementation only gets called if the base class doTestStepPreambleL() did
sl@0
   125
    not leave.
sl@0
   126
    
sl@0
   127
    @return - TVerdict code
sl@0
   128
*/
sl@0
   129
TVerdict CTSmallWindowsTest::doTestStepL()
sl@0
   130
    {
sl@0
   131
    SetTestStepID(KTestStep0012);
sl@0
   132
    FlowWindowsL();
sl@0
   133
    //RecordTestResultL(); // todo: not possible because of heap alloc panic
sl@0
   134
    return TestStepResult();
sl@0
   135
    }
sl@0
   136
sl@0
   137
/**
sl@0
   138
@SYMTestCaseID
sl@0
   139
GRAPHICS-UI-BENCH-S60-0012
sl@0
   140
sl@0
   141
@SYMTestCaseDesc
sl@0
   142
Tests how long it takes to move small windows over the screen.
sl@0
   143
sl@0
   144
@SYMTestActions
sl@0
   145
Creates small windows which draw bitmaps and moves them over the screen.
sl@0
   146
sl@0
   147
@SYMTestExpectedResults
sl@0
   148
Test should pass and write the average framerate of the test to a log file.
sl@0
   149
*/
sl@0
   150
void CTSmallWindowsTest::FlowWindowsL()
sl@0
   151
    {
sl@0
   152
    iProfiler->InitResults();
sl@0
   153
    iIterationsToTest = 10;
sl@0
   154
    for (TInt i = 0; i <= iIterationsToTest; ++i)
sl@0
   155
        {
sl@0
   156
        iFlowWindowsController->MoveL();        
sl@0
   157
        }
sl@0
   158
    iProfiler->MarkResultSetL();
sl@0
   159
    TInt drawingRect = iWindowSize.iHeight * iWindowSize.iWidth * iWindowsAcross * iWindowsAcross;
sl@0
   160
    iProfiler->ResultsAnalysisFrameRate(KTestStep0012, 0, 0, 0, iIterationsToTest, drawingRect);    
sl@0
   161
    }
sl@0
   162
sl@0
   163