graphicstest/uibench/s60/src/tests_flowwindow/tsmallwindowstest.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 "tsmallwindowstest.h"
       
    23 #include "tsmallwindowraster.h"
       
    24 #include "tflowwindowscontroller.h"
       
    25 
       
    26 #include <imageconversion.h>
       
    27 
       
    28 
       
    29 const TInt KNumberOfBounces = 3;
       
    30 
       
    31 _LIT(KTestStep0012,"GRAPHICS-UI-BENCH-S60-0012");
       
    32 
       
    33 
       
    34 CTSmallWindowsTest::CTSmallWindowsTest()
       
    35 	{
       
    36 	SetTestStepName(KTSmallWindows);
       
    37 	}
       
    38 
       
    39 CTSmallWindowsTest::~CTSmallWindowsTest()
       
    40 	{
       
    41 	delete iFlowWindowsController;
       
    42     iFileNames.Close();
       
    43     }
       
    44 
       
    45 TVerdict CTSmallWindowsTest::doTestStepPreambleL()
       
    46 	{
       
    47 	CTe_graphicsperformanceSuiteStepBase::doTestStepPreambleL();
       
    48 	iScreenSize = CTWindow::GetDisplaySizeInPixels();	
       
    49 	TBool preload = EFalse;
       
    50 	GetBoolFromConfig(_L("FlowTests"), _L("Preload"), preload);
       
    51 
       
    52 	TPtrC fileNameList;
       
    53 	TEST(GetStringFromConfig(_L("FlowTests"), _L("Files"), fileNameList));
       
    54 	ExtractListL(fileNameList, iFileNames);
       
    55 
       
    56 	ComputeSmallWindows();
       
    57 
       
    58 	TPoint initialPosition(0, 0);
       
    59 	RArray<TPoint> initialPositions;
       
    60     RArray<pTWindowCreatorFunction> windowCreatorFunctions;
       
    61     CleanupClosePushL(initialPositions);
       
    62     CleanupClosePushL(windowCreatorFunctions);
       
    63 	for (TInt i = 0; i < iWindowsAcross; i++)
       
    64 		{
       
    65 		initialPosition.iY = 0;
       
    66 		for (TInt j = 0; j < iWindowsAcross; j++)
       
    67 			{
       
    68 			windowCreatorFunctions.AppendL(CTSmallWindowRaster::NewL);
       
    69 			initialPositions.AppendL(initialPosition);
       
    70 			initialPosition.iY += iWindowSize.iHeight;
       
    71 			}
       
    72 		initialPosition.iX += iWindowSize.iWidth;
       
    73 		}
       
    74 
       
    75 	iFlowWindowsController = CTFlowWindowsController::NewL(preload, iFileNames, iWindowSize, windowCreatorFunctions, initialPositions, ETrue);
       
    76     CleanupStack::PopAndDestroy(2, &initialPositions);
       
    77 	return TestStepResult();
       
    78 	}
       
    79 
       
    80 void CTSmallWindowsTest::ComputeSmallWindows()
       
    81     {
       
    82     TReal sqrtWindowsAcross;
       
    83     Math::Sqrt(sqrtWindowsAcross, iFileNames.Count());
       
    84     iWindowsAcross = sqrtWindowsAcross;
       
    85 
       
    86     RFs fs;
       
    87     TESTNOERRORL(fs.Connect());
       
    88     CleanupClosePushL(fs);
       
    89     CImageDecoder* decoder = CImageDecoder::FileNewL(fs, iFileNames[0], CImageDecoder::EOptionAlwaysThread);
       
    90     TFrameInfo info = decoder->FrameInfo();
       
    91     TReal imageAspectRatio = (TReal)info.iOverallSizeInPixels.iWidth/(TReal)info.iOverallSizeInPixels.iHeight;
       
    92     delete decoder;
       
    93     CleanupStack::PopAndDestroy();
       
    94     
       
    95     // set window size to create required grid
       
    96     iWindowSize.iHeight = iScreenSize.iHeight / iWindowsAcross;
       
    97     iWindowSize.iWidth = iScreenSize.iWidth / iWindowsAcross;
       
    98     TReal windowAspectRatio = (TReal)iWindowSize.iWidth / (TReal)iWindowSize.iHeight;
       
    99     
       
   100     // adjust window size to maintain image aspect ratio
       
   101     if (iWindowSize.iWidth > iWindowSize.iHeight)
       
   102         {
       
   103         iWindowSize.iWidth /= windowAspectRatio / imageAspectRatio;
       
   104         }
       
   105     else
       
   106         {
       
   107         iWindowSize.iHeight *= windowAspectRatio / imageAspectRatio;
       
   108         }
       
   109         
       
   110     // run the test enough frames to see bounce the grid twice
       
   111     if (iScreenSize.iHeight > iScreenSize.iWidth)
       
   112         {
       
   113         iIterationsToTest = KNumberOfBounces * (iScreenSize.iHeight - iWindowSize.iHeight * iWindowsAcross);
       
   114         }
       
   115     else 
       
   116         {
       
   117         iIterationsToTest = KNumberOfBounces * (iScreenSize.iWidth - iWindowSize.iWidth * iWindowsAcross);
       
   118         }
       
   119     }
       
   120 
       
   121 
       
   122 /**
       
   123     Override of base class pure virtual
       
   124     Our implementation only gets called if the base class doTestStepPreambleL() did
       
   125     not leave.
       
   126     
       
   127     @return - TVerdict code
       
   128 */
       
   129 TVerdict CTSmallWindowsTest::doTestStepL()
       
   130     {
       
   131     SetTestStepID(KTestStep0012);
       
   132     FlowWindowsL();
       
   133     //RecordTestResultL(); // todo: not possible because of heap alloc panic
       
   134     return TestStepResult();
       
   135     }
       
   136 
       
   137 /**
       
   138 @SYMTestCaseID
       
   139 GRAPHICS-UI-BENCH-S60-0012
       
   140 
       
   141 @SYMTestCaseDesc
       
   142 Tests how long it takes to move small windows over the screen.
       
   143 
       
   144 @SYMTestActions
       
   145 Creates small windows which draw bitmaps and moves them over the screen.
       
   146 
       
   147 @SYMTestExpectedResults
       
   148 Test should pass and write the average framerate of the test to a log file.
       
   149 */
       
   150 void CTSmallWindowsTest::FlowWindowsL()
       
   151     {
       
   152     iProfiler->InitResults();
       
   153     iIterationsToTest = 10;
       
   154     for (TInt i = 0; i <= iIterationsToTest; ++i)
       
   155         {
       
   156         iFlowWindowsController->MoveL();        
       
   157         }
       
   158     iProfiler->MarkResultSetL();
       
   159     TInt drawingRect = iWindowSize.iHeight * iWindowSize.iWidth * iWindowsAcross * iWindowsAcross;
       
   160     iProfiler->ResultsAnalysisFrameRate(KTestStep0012, 0, 0, 0, iIterationsToTest, drawingRect);    
       
   161     }
       
   162 
       
   163