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