1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TFLICKERFREE.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,139 @@
1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// TMULSCREENS.CPP
1.18 +// Tests the newly API function added to RWindow which enables/disables
1.19 +// the usage of Off-Screen Bitmap (OSB).
1.20 +// The test will draw squares with random colours on screen filling the
1.21 +// whole drawable area. The drawing will start first with flickering screen
1.22 +// and will switch to flicker free in 4 seconds.
1.23 +//
1.24 +//
1.25 +
1.26 +/**
1.27 + @file
1.28 + @test
1.29 + @internalComponent - Internal Symbian test code
1.30 +*/
1.31 +
1.32 +#include "TFLICKERFREE.H"
1.33 +
1.34 +//===================================================
1.35 +// CBGWin Declaration
1.36 +//===================================================
1.37 +
1.38 +CBGWin::CBGWin(): CTWin()
1.39 + {
1.40 + }
1.41 +
1.42 +CBGWin::~CBGWin()
1.43 + {
1.44 + }
1.45 +
1.46 +void CBGWin::ConstructWin(TPoint aPos, TSize aSize, TBool aVisible)
1.47 + {
1.48 + iSize = aSize;
1.49 + SetUpL(aPos,iSize,TheClient->iGroup,*TheClient->iGc, aVisible);
1.50 + BaseWin()->SetRequiredDisplayMode(EColor256);
1.51 + }
1.52 +
1.53 +void CBGWin::Draw()
1.54 + {
1.55 + iGc->Clear();
1.56 + iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.57 +
1.58 + TUint propW = iSize.iWidth/32;
1.59 + TUint propH = iSize.iHeight/12;
1.60 +
1.61 + for(TInt i = 0; i < iSize.iWidth ; i+=propW)
1.62 + {
1.63 + for(TInt j = 0; j < iSize.iHeight; j+=propH)
1.64 + {
1.65 + iGc->SetBrushColor(TRgb( (TInt)(Math::Random()%255), (TInt)(Math::Random()%255), (TInt)(Math::Random()%255) ));
1.66 + iGc->DrawRect(TRect(i, j, i+propW-1, j+propH-1));
1.67 + }
1.68 + }
1.69 + }
1.70 +
1.71 +void CBGWin::EnableOSBd(TBool aState)
1.72 + {
1.73 + iWin.EnableOSB(aState);
1.74 + }
1.75 +
1.76 +//===================================================
1.77 +// CFlickerTest Declaration
1.78 +//===================================================
1.79 +
1.80 +/* This function will be called periodically to draw the rects
1.81 + on screen.*/
1.82 +void CTFlickerFree::TestFlickering()
1.83 + {
1.84 + for( int i = 0; i < 40; ++i)
1.85 + {
1.86 + // for the first 3 seconds draw with flicker
1.87 + if(i < 20 )
1.88 + iBgWin->EnableOSBd(EFalse);
1.89 + // for the next 3 seconds draw with flicker free
1.90 + else if(i >=20 )
1.91 + iBgWin->EnableOSBd(ETrue);
1.92 +
1.93 + iBgWin->DrawNow();
1.94 +
1.95 + // this draws 20 frames per second for 4 seconds
1.96 + User::After(50000);
1.97 + }
1.98 + }
1.99 +
1.100 +CTFlickerFree::CTFlickerFree(CTestStep* aStep):
1.101 + CTWsGraphicsBase(aStep)
1.102 + {
1.103 + }
1.104 +
1.105 +CTFlickerFree::~CTFlickerFree()
1.106 + {
1.107 + delete iBgWin;
1.108 + }
1.109 +
1.110 +void CTFlickerFree::ConstructL()
1.111 + {
1.112 + // get the size of the current client to assign it to the background window
1.113 + TSize scrSize = TSize(TheClient->iScreen->SizeInPixels());
1.114 +
1.115 + // construct the window in the background
1.116 + iBgWin = new (ELeave) CBGWin();
1.117 + iBgWin->ConstructWin(TPoint(0,0), scrSize, ETrue);
1.118 + }
1.119 +
1.120 +/* Sets the windowing environment, constructs the CPeriod object and
1.121 + starts the CPeriod object.*/
1.122 +void CTFlickerFree::RunTestCaseL(TInt aCurTestCase)
1.123 + {
1.124 + ((CTFlickerFreeStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
1.125 + switch(aCurTestCase)
1.126 + {
1.127 + case 1:
1.128 +/**
1.129 +@SYMTestCaseID GRAPHICS-WSERV-0567
1.130 +*/
1.131 + ((CTFlickerFreeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0567"));
1.132 + TestFlickering();
1.133 + break;
1.134 + default:
1.135 + ((CTFlickerFreeStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1.136 + ((CTFlickerFreeStep*)iStep)->CloseTMSGraphicsStep();
1.137 + TestComplete();
1.138 + }
1.139 + ((CTFlickerFreeStep*)iStep)->RecordTestResultL();
1.140 + }
1.141 +
1.142 +__WS_CONSTRUCT_STEP__(FlickerFree)