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