graphicstest/uibench/s60/src/tests_flowwindow/tsmallwindowstestopenvg.cpp
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     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 "tsmallwindowstestopenvg.h"
       
    23 #include "tsmallwindowopenvg.h"
       
    24 
       
    25 #include <imageconversion.h>
       
    26 
       
    27 
       
    28 const TInt KNumberOfBounces = 3;
       
    29 
       
    30 _LIT(KDummy, "dummy");
       
    31 _LIT(KTestStep0014,"GRAPHICS-UI-BENCH-S60-0014");
       
    32 
       
    33 const TInt KWindowsAcross = 2;
       
    34 const TInt KWindowsDown = 2;
       
    35 
       
    36 
       
    37 CTSmallWindowsTestOpenVG::CTSmallWindowsTestOpenVG()
       
    38     {
       
    39     SetTestStepName(KTSmallWindowsOpenVG);  
       
    40     }
       
    41 
       
    42 CTSmallWindowsTestOpenVG::~CTSmallWindowsTestOpenVG()
       
    43     {
       
    44     delete iFlowWindowsController;
       
    45     iFileNames.Close();
       
    46     }
       
    47 
       
    48 TVerdict CTSmallWindowsTestOpenVG::doTestStepPreambleL()
       
    49     {
       
    50     CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL();
       
    51     
       
    52     TSize screenSize = CTWindow::GetDisplaySizeInPixels();
       
    53     
       
    54     // set window size to create required grid
       
    55     iWindowSize.iHeight = screenSize.iHeight / KWindowsDown;
       
    56     iWindowSize.iWidth = screenSize.iWidth / KWindowsAcross;    
       
    57     // adjust window size to maintain image aspect ratio
       
    58     if (iWindowSize.iWidth > iWindowSize.iHeight)
       
    59         {
       
    60         iWindowSize.iWidth = iWindowSize.iHeight;
       
    61         }
       
    62     else
       
    63         {
       
    64         iWindowSize.iHeight = iWindowSize.iWidth;
       
    65         }
       
    66     
       
    67     TPoint initialPosition(0, 0);
       
    68     RArray<TPoint> initialPositions;
       
    69     RArray<pTWindowCreatorFunction> windowCreatorFunctions;
       
    70     CleanupClosePushL(initialPositions);
       
    71     CleanupClosePushL(windowCreatorFunctions);
       
    72     for (TInt i = 0; i < KWindowsAcross; i++)
       
    73         {
       
    74         initialPosition.iY = 0;
       
    75         for (TInt j = 0; j < KWindowsDown; j++)
       
    76             {
       
    77             windowCreatorFunctions.AppendL(CTSmallWindowOpenVG::NewL);
       
    78             initialPositions.AppendL(initialPosition);
       
    79             iFileNames.AppendL(KDummy());
       
    80             initialPosition.iY += iWindowSize.iHeight;          
       
    81             }
       
    82         initialPosition.iX += iWindowSize.iWidth;
       
    83         }
       
    84     
       
    85     iFlowWindowsController = CTFlowWindowsController::NewL(ETrue, iFileNames, iWindowSize, windowCreatorFunctions, initialPositions, ETrue);
       
    86     CleanupStack::PopAndDestroy(2, &initialPositions);
       
    87     
       
    88     // run the test enough frames to see move the grid across the screen
       
    89     if (screenSize.iHeight > screenSize.iWidth)
       
    90         {
       
    91         iIterationsToTest = KNumberOfBounces * (screenSize.iHeight - iWindowSize.iHeight * KWindowsDown);
       
    92         }
       
    93     else 
       
    94         {
       
    95         iIterationsToTest = KNumberOfBounces * (screenSize.iWidth - iWindowSize.iWidth * KWindowsAcross);
       
    96         }
       
    97 
       
    98     return TestStepResult();
       
    99     }
       
   100 
       
   101 /**
       
   102     Override of base class pure virtual
       
   103     Our implementation only gets called if the base class doTestStepPreambleL() did
       
   104     not leave.
       
   105     
       
   106     @return - TVerdict code
       
   107 */
       
   108 TVerdict CTSmallWindowsTestOpenVG::doTestStepL()
       
   109     {
       
   110     SetTestStepID(KTestStep0014);
       
   111     FlowWindowsL();
       
   112     //RecordTestResultL(); // todo: not possible because of heap alloc panic
       
   113     return TestStepResult();
       
   114     }
       
   115 
       
   116 /**
       
   117 @SYMTestCaseID
       
   118 GRAPHICS-UI-BENCH-S60-0014
       
   119 
       
   120 @SYMTestCaseDesc
       
   121 Tests how long it takes to move small OpenVG windows over the screen.
       
   122 
       
   123 @SYMTestActions
       
   124 Creates windows which draw OpenVG content and moves them over the screen.
       
   125 
       
   126 @SYMTestExpectedResults
       
   127 Test should pass and write the average framerate of the test to a log file.
       
   128 */
       
   129 void CTSmallWindowsTestOpenVG::FlowWindowsL()
       
   130     {
       
   131     iProfiler->InitResults();
       
   132     iIterationsToTest = 10;
       
   133     for (TInt i = 0; i <= iIterationsToTest; ++i)
       
   134         {
       
   135         iFlowWindowsController->MoveL();
       
   136         }
       
   137     iProfiler->MarkResultSetL();
       
   138     TInt drawingRect = iWindowSize.iHeight * iWindowSize.iWidth * KWindowsAcross * KWindowsDown;  
       
   139     iProfiler->ResultsAnalysisFrameRate(KTestStep0014, 0, 0, 0, iIterationsToTest, drawingRect);    
       
   140     }