os/graphics/graphicstest/uibench/s60/src/tests_flowwindow/tsmallwindowstestraster.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
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
sl@0
    23
#include "tsmallwindowstestraster.h"
sl@0
    24
#include "tsmallwindowraster.h"
sl@0
    25
sl@0
    26
sl@0
    27
const TInt KWindowsAcross = 2;
sl@0
    28
const TInt KWindowsDown = 2;
sl@0
    29
sl@0
    30
const TInt KNumberOfBounces = 3;
sl@0
    31
sl@0
    32
_LIT(KSmallBitmap,"z:\\resource\\apps\\uibench_s60_small.mbm");
sl@0
    33
_LIT(KTestStep0015,"GRAPHICS-UI-BENCH-S60-0015");
sl@0
    34
sl@0
    35
sl@0
    36
CTSmallWindowsTestRaster::CTSmallWindowsTestRaster()
sl@0
    37
    {
sl@0
    38
    SetTestStepName(KTSmallWindowsRaster);  
sl@0
    39
    }
sl@0
    40
sl@0
    41
CTSmallWindowsTestRaster::~CTSmallWindowsTestRaster()
sl@0
    42
    {
sl@0
    43
    delete iFlowWindowsController;
sl@0
    44
    iFileNames.Close();
sl@0
    45
    }
sl@0
    46
sl@0
    47
TVerdict CTSmallWindowsTestRaster::doTestStepPreambleL()
sl@0
    48
    {
sl@0
    49
    CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL();
sl@0
    50
    
sl@0
    51
    TSize screenSize = CTWindow::GetDisplaySizeInPixels();
sl@0
    52
    
sl@0
    53
    // set window size to create required grid
sl@0
    54
    iWindowSize.iHeight = screenSize.iHeight / KWindowsDown;
sl@0
    55
    iWindowSize.iWidth = screenSize.iWidth / KWindowsAcross;    
sl@0
    56
    // adjust window size to maintain image aspect ratio
sl@0
    57
    if (iWindowSize.iWidth > iWindowSize.iHeight)
sl@0
    58
        {
sl@0
    59
        iWindowSize.iWidth = iWindowSize.iHeight;
sl@0
    60
        }
sl@0
    61
    else
sl@0
    62
        {
sl@0
    63
        iWindowSize.iHeight = iWindowSize.iWidth;
sl@0
    64
        }
sl@0
    65
    
sl@0
    66
    TPoint initialPosition(0, 0);
sl@0
    67
    RArray<TPoint> initialPositions;
sl@0
    68
    RArray<pTWindowCreatorFunction> windowCreatorFunctions;
sl@0
    69
    CleanupClosePushL(initialPositions);
sl@0
    70
    CleanupClosePushL(windowCreatorFunctions);
sl@0
    71
    for (TInt i = 0; i < KWindowsAcross; i++)
sl@0
    72
        {
sl@0
    73
        initialPosition.iY = 0;
sl@0
    74
        for (TInt j = 0; j < KWindowsDown; j++)
sl@0
    75
            {
sl@0
    76
            windowCreatorFunctions.AppendL(CTSmallWindowRaster::NewL);
sl@0
    77
            initialPositions.AppendL(initialPosition);
sl@0
    78
            iFileNames.AppendL(KSmallBitmap());
sl@0
    79
            initialPosition.iY += iWindowSize.iHeight;          
sl@0
    80
            }
sl@0
    81
        initialPosition.iX += iWindowSize.iWidth;
sl@0
    82
        }
sl@0
    83
    
sl@0
    84
    iFlowWindowsController = CTFlowWindowsController::NewL(ETrue, iFileNames, iWindowSize, windowCreatorFunctions, initialPositions, ETrue);
sl@0
    85
    CleanupStack::PopAndDestroy(2, &initialPositions);
sl@0
    86
    
sl@0
    87
    // run the test enough frames to see move the grid across the screen
sl@0
    88
    if (screenSize.iHeight > screenSize.iWidth)
sl@0
    89
        {
sl@0
    90
        iIterationsToTest = KNumberOfBounces * (screenSize.iHeight - iWindowSize.iHeight * KWindowsDown);
sl@0
    91
        }
sl@0
    92
    else 
sl@0
    93
        {
sl@0
    94
        iIterationsToTest = KNumberOfBounces * (screenSize.iWidth - iWindowSize.iWidth * KWindowsAcross);
sl@0
    95
        }
sl@0
    96
sl@0
    97
    return TestStepResult();
sl@0
    98
    }
sl@0
    99
sl@0
   100
/**
sl@0
   101
    Override of base class pure virtual
sl@0
   102
    Our implementation only gets called if the base class doTestStepPreambleL() did
sl@0
   103
    not leave.
sl@0
   104
    
sl@0
   105
    @return - TVerdict code
sl@0
   106
*/
sl@0
   107
TVerdict CTSmallWindowsTestRaster::doTestStepL()
sl@0
   108
    {
sl@0
   109
    SetTestStepID(KTestStep0015);
sl@0
   110
    TRAPD(err, FlowWindowsL());
sl@0
   111
    if (err != KErrNone)
sl@0
   112
        {
sl@0
   113
        SetTestStepResult(EAbort);
sl@0
   114
        }
sl@0
   115
    return TestStepResult();
sl@0
   116
    }
sl@0
   117
sl@0
   118
/**
sl@0
   119
@SYMTestCaseID
sl@0
   120
GRAPHICS-UI-BENCH-S60-0015
sl@0
   121
sl@0
   122
@SYMTestCaseDesc
sl@0
   123
Tests how long it takes to move small windows over the screen.
sl@0
   124
sl@0
   125
@SYMTestActions
sl@0
   126
Creates windows which draw Bitmaps and moves them over the screen.
sl@0
   127
sl@0
   128
@SYMTestExpectedResults
sl@0
   129
Test should pass and write the average framerate of the test to a log file.
sl@0
   130
*/
sl@0
   131
void CTSmallWindowsTestRaster::FlowWindowsL()
sl@0
   132
    {
sl@0
   133
    iProfiler->InitResults();
sl@0
   134
    iIterationsToTest = 50;
sl@0
   135
    for (TInt i = 0; i < iIterationsToTest; ++i)
sl@0
   136
        {
sl@0
   137
        iFlowWindowsController->MoveL();
sl@0
   138
        // todo: why is a pause needed to let wserv redraw the screen?
sl@0
   139
        User::After(10000); // needed, otherwise test is not waiting for wserv to redraw (10 ms)
sl@0
   140
        }
sl@0
   141
    iProfiler->MarkResultSetL();
sl@0
   142
    TInt drawingRect = iWindowSize.iHeight * iWindowSize.iWidth * KWindowsAcross * KWindowsDown;
sl@0
   143
    iProfiler->ResultsAnalysisFrameRate(KTestStep0015, 0, 0, 0, iIterationsToTest, drawingRect);
sl@0
   144
    }