windowing/windowserver/test/tauto/TFLICKERFREE.CPP
author hgs
Tue, 22 Jun 2010 15:21:29 +0300
changeset 103 2717213c588a
permissions -rw-r--r--
201024
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
103
hgs
parents:
diff changeset
     1
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     2
// All rights reserved.
hgs
parents:
diff changeset
     3
// This component and the accompanying materials are made available
hgs
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     5
// which accompanies this distribution, and is available
hgs
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     7
//
hgs
parents:
diff changeset
     8
// Initial Contributors:
hgs
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    10
//
hgs
parents:
diff changeset
    11
// Contributors:
hgs
parents:
diff changeset
    12
//
hgs
parents:
diff changeset
    13
// Description:
hgs
parents:
diff changeset
    14
// TMULSCREENS.CPP
hgs
parents:
diff changeset
    15
// Tests the newly API function added to RWindow which enables/disables
hgs
parents:
diff changeset
    16
// the usage of Off-Screen Bitmap (OSB).
hgs
parents:
diff changeset
    17
// The test will draw squares with random colours on screen filling the
hgs
parents:
diff changeset
    18
// whole drawable area. The drawing will start first with flickering screen
hgs
parents:
diff changeset
    19
// and will switch to flicker free in 4 seconds.
hgs
parents:
diff changeset
    20
// 
hgs
parents:
diff changeset
    21
//
hgs
parents:
diff changeset
    22
hgs
parents:
diff changeset
    23
/**
hgs
parents:
diff changeset
    24
 @file
hgs
parents:
diff changeset
    25
 @test
hgs
parents:
diff changeset
    26
 @internalComponent - Internal Symbian test code
hgs
parents:
diff changeset
    27
*/
hgs
parents:
diff changeset
    28
hgs
parents:
diff changeset
    29
#include "TFLICKERFREE.H"
hgs
parents:
diff changeset
    30
hgs
parents:
diff changeset
    31
//===================================================
hgs
parents:
diff changeset
    32
// CBGWin Declaration
hgs
parents:
diff changeset
    33
//===================================================
hgs
parents:
diff changeset
    34
hgs
parents:
diff changeset
    35
CBGWin::CBGWin(): CTWin()
hgs
parents:
diff changeset
    36
	{
hgs
parents:
diff changeset
    37
	}
hgs
parents:
diff changeset
    38
hgs
parents:
diff changeset
    39
CBGWin::~CBGWin()
hgs
parents:
diff changeset
    40
	{
hgs
parents:
diff changeset
    41
	}
hgs
parents:
diff changeset
    42
hgs
parents:
diff changeset
    43
void CBGWin::ConstructWin(TPoint aPos, TSize aSize, TBool aVisible)
hgs
parents:
diff changeset
    44
	{
hgs
parents:
diff changeset
    45
	iSize = aSize;
hgs
parents:
diff changeset
    46
	SetUpL(aPos,iSize,TheClient->iGroup,*TheClient->iGc, aVisible);
hgs
parents:
diff changeset
    47
	BaseWin()->SetRequiredDisplayMode(EColor256);
hgs
parents:
diff changeset
    48
	}
hgs
parents:
diff changeset
    49
hgs
parents:
diff changeset
    50
void CBGWin::Draw()
hgs
parents:
diff changeset
    51
	{
hgs
parents:
diff changeset
    52
	iGc->Clear();
hgs
parents:
diff changeset
    53
	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
hgs
parents:
diff changeset
    54
hgs
parents:
diff changeset
    55
	TUint propW = iSize.iWidth/32;
hgs
parents:
diff changeset
    56
	TUint propH = iSize.iHeight/12;
hgs
parents:
diff changeset
    57
hgs
parents:
diff changeset
    58
	for(TInt i = 0; i < iSize.iWidth ; i+=propW)
hgs
parents:
diff changeset
    59
		{
hgs
parents:
diff changeset
    60
		for(TInt j = 0; j < iSize.iHeight; j+=propH)
hgs
parents:
diff changeset
    61
			{
hgs
parents:
diff changeset
    62
			iGc->SetBrushColor(TRgb( (TInt)(Math::Random()%255), (TInt)(Math::Random()%255), (TInt)(Math::Random()%255) ));
hgs
parents:
diff changeset
    63
			iGc->DrawRect(TRect(i, j, i+propW-1, j+propH-1));
hgs
parents:
diff changeset
    64
			}
hgs
parents:
diff changeset
    65
		}
hgs
parents:
diff changeset
    66
	}
hgs
parents:
diff changeset
    67
hgs
parents:
diff changeset
    68
void CBGWin::EnableOSBd(TBool aState)
hgs
parents:
diff changeset
    69
	{
hgs
parents:
diff changeset
    70
	iWin.EnableOSB(aState);
hgs
parents:
diff changeset
    71
	}
hgs
parents:
diff changeset
    72
hgs
parents:
diff changeset
    73
//===================================================
hgs
parents:
diff changeset
    74
// CFlickerTest Declaration
hgs
parents:
diff changeset
    75
//===================================================
hgs
parents:
diff changeset
    76
hgs
parents:
diff changeset
    77
/* This function will be called periodically to draw the rects
hgs
parents:
diff changeset
    78
   on screen.*/
hgs
parents:
diff changeset
    79
void CTFlickerFree::TestFlickering()
hgs
parents:
diff changeset
    80
	{
hgs
parents:
diff changeset
    81
	for( int i = 0; i < 40; ++i)
hgs
parents:
diff changeset
    82
		{
hgs
parents:
diff changeset
    83
		// for the first 3 seconds draw with flicker
hgs
parents:
diff changeset
    84
		if(i < 20 )
hgs
parents:
diff changeset
    85
			iBgWin->EnableOSBd(EFalse);
hgs
parents:
diff changeset
    86
		// for the next 3 seconds draw with flicker free
hgs
parents:
diff changeset
    87
		else if(i >=20 )
hgs
parents:
diff changeset
    88
			iBgWin->EnableOSBd(ETrue);
hgs
parents:
diff changeset
    89
hgs
parents:
diff changeset
    90
		iBgWin->DrawNow();
hgs
parents:
diff changeset
    91
hgs
parents:
diff changeset
    92
		// this draws 20 frames per second for 4 seconds
hgs
parents:
diff changeset
    93
		User::After(50000);
hgs
parents:
diff changeset
    94
		}
hgs
parents:
diff changeset
    95
	}
hgs
parents:
diff changeset
    96
hgs
parents:
diff changeset
    97
CTFlickerFree::CTFlickerFree(CTestStep* aStep):
hgs
parents:
diff changeset
    98
	CTWsGraphicsBase(aStep)
hgs
parents:
diff changeset
    99
	{
hgs
parents:
diff changeset
   100
	}
hgs
parents:
diff changeset
   101
hgs
parents:
diff changeset
   102
CTFlickerFree::~CTFlickerFree()
hgs
parents:
diff changeset
   103
	{
hgs
parents:
diff changeset
   104
	delete iBgWin;
hgs
parents:
diff changeset
   105
	}
hgs
parents:
diff changeset
   106
hgs
parents:
diff changeset
   107
void CTFlickerFree::ConstructL()
hgs
parents:
diff changeset
   108
	{
hgs
parents:
diff changeset
   109
	// get the size of the current client to assign it to the background window
hgs
parents:
diff changeset
   110
	TSize scrSize = TSize(TheClient->iScreen->SizeInPixels());
hgs
parents:
diff changeset
   111
hgs
parents:
diff changeset
   112
	// construct the window in the background
hgs
parents:
diff changeset
   113
	iBgWin = new (ELeave) CBGWin();
hgs
parents:
diff changeset
   114
	iBgWin->ConstructWin(TPoint(0,0), scrSize, ETrue);
hgs
parents:
diff changeset
   115
	}
hgs
parents:
diff changeset
   116
hgs
parents:
diff changeset
   117
/* Sets the windowing environment, constructs the CPeriod object and
hgs
parents:
diff changeset
   118
	starts the CPeriod object.*/
hgs
parents:
diff changeset
   119
void CTFlickerFree::RunTestCaseL(TInt aCurTestCase)
hgs
parents:
diff changeset
   120
	{
hgs
parents:
diff changeset
   121
	((CTFlickerFreeStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
hgs
parents:
diff changeset
   122
	switch(aCurTestCase)
hgs
parents:
diff changeset
   123
		{
hgs
parents:
diff changeset
   124
		case 1:
hgs
parents:
diff changeset
   125
/**
hgs
parents:
diff changeset
   126
@SYMTestCaseID		GRAPHICS-WSERV-0567
hgs
parents:
diff changeset
   127
*/
hgs
parents:
diff changeset
   128
			((CTFlickerFreeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0567"));
hgs
parents:
diff changeset
   129
			TestFlickering();
hgs
parents:
diff changeset
   130
			break;
hgs
parents:
diff changeset
   131
		default:
hgs
parents:
diff changeset
   132
			((CTFlickerFreeStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
hgs
parents:
diff changeset
   133
			((CTFlickerFreeStep*)iStep)->CloseTMSGraphicsStep();
hgs
parents:
diff changeset
   134
			TestComplete();
hgs
parents:
diff changeset
   135
		}
hgs
parents:
diff changeset
   136
	((CTFlickerFreeStep*)iStep)->RecordTestResultL();
hgs
parents:
diff changeset
   137
	}
hgs
parents:
diff changeset
   138
hgs
parents:
diff changeset
   139
__WS_CONSTRUCT_STEP__(FlickerFree)