os/graphics/windowing/windowserver/test/tdynamicres/inc/t_wsdynamicreswinbase.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/tdynamicres/inc/t_wsdynamicreswinbase.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,169 @@
     1.4 +// Copyright (c) 2008-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 +// twsgcetestwinbase.h
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#ifndef TWSDYNAMICRESWINBASE_H_
    1.22 +#define TWSDYNAMICRESWINBASE_H_
    1.23 +
    1.24 +#include <gdi.h>
    1.25 +#include <test/tefunit.h>
    1.26 +#include <w32std.h>
    1.27 +#include <w32debug.h>
    1.28 +#include "wsgcedebugsession.h"
    1.29 +struct TWsDebugWindowId;
    1.30 +
    1.31 +/**
    1.32 + * Base class sets up the tryptich of test windows.
    1.33 + * 
    1.34 + * 
    1.35 + **/
    1.36 +class CWsDynamicResWinBase : public CTestFixture
    1.37 +{
    1.38 +public:
    1.39 +	CWsDynamicResWinBase();
    1.40 +	virtual ~CWsDynamicResWinBase();
    1.41 +	virtual void SetupL();
    1.42 +	virtual void SetupL(TBool aUseOtherScreenForInfo);
    1.43 +	
    1.44 +	virtual void TearDownL();
    1.45 +	virtual void TearDownFromDeleteL();
    1.46 +	
    1.47 +	static TBool	ActivateWithWipe(CWindowGc* aGc,RWindow& aWin,TRgb aColor=TRgb(0,0));
    1.48 +	
    1.49 +	/* Note that each derived test class needs to declare a static function to register tests.
    1.50 +	 * This should match the following prototype:
    1.51 +	static CTestSuite* CreateSuiteL( const TDesC& aName );
    1.52 +	*/ 
    1.53 +	
    1.54 +protected:
    1.55 +	static void Pause(TInt aMilliseconds=200);
    1.56 +
    1.57 +	TBool GCEIsSupported() const;
    1.58 +	static TBool GCEIsSupportedStatic();
    1.59 +
    1.60 +	TBool DisplayHasAlpha() const;
    1.61 +	TBool SelectChromaCompositionMode();
    1.62 +	TBool SelectAlphaCompositionMode(TDisplayMode aMode = EColor16MA);
    1.63 +	TRgb  GceHoleColor(RWindowBase& aWin)const;
    1.64 +	void DrawUIContent(RWindow& aWindow);
    1.65 +	void DrawPlainUI(RWindow& aWindow,TBool aInvalidate,TRgb aWipeColor=TRgb(0,0));
    1.66 +	void DrawCross(RWindow& aWindow, TRgb aColor, TInt aThickness=1);
    1.67 +	void TestPixelL(TPoint aPt, TRgb aColor, TBool aMatch);
    1.68 +	TBool TestRectL(TRect aRect,TRgb aInnerColor,TInt aOtherInnerColors,TRgb aOuterColor,TInt aOtherOuterColors,TInt aCornerSize);
    1.69 +	void MakeTitleAndCompareWindowsL(TRefByValue<const TDesC16> aTitle,TRefByValue<const TDesC16> aDetail=_L(""));
    1.70 +	void LargerCompareWindow(TBool aGoLarger=ETrue);
    1.71 +	void UpdateTitleWindowL(TRefByValue<const TDesC16> aDetail,TInt aIndex=0);
    1.72 +	void RepaintTitleWindowL();
    1.73 +	void TefUnitFailLeaveL();
    1.74 +	CWindowGc*	GcForWindow(RWindow& aWin);
    1.75 +	TBool		InvalidateRegion(const TRegion& aRegion,RWindow& aWin);
    1.76 +	CWindowGc*	BeginActivateWithWipe(TBool aInvalidate,RWindow& aWin,TRgb aColor=TRgb(0,0));
    1.77 +	CWindowGc*	BeginActivateWithWipe(TBool aInvalidate,TRect aRect,RWindow& aWin,TRgb aColor=TRgb(0,0));
    1.78 +	CWindowGc*	BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor);
    1.79 +	/** Helper method to find a named screen region
    1.80 +	 *	start/end letter should be 'a' to 'y' (yes that includes 'i')
    1.81 +	 **/
    1.82 +	static TRect PentCellRect(const TRect& aFullRect,char aStartLetter,char aEndLetter=0);
    1.83 +	void CheckAndConnectScreen();
    1.84 +
    1.85 +protected:
    1.86 +	static const TInt KSurfaceWidth = 50;
    1.87 +	static const TInt KSurfaceHeight = 50;
    1.88 +	TBool	iDoTearDown;
    1.89 +	RWsDebugSession iSession;
    1.90 +	RWindowGroup iGroup;
    1.91 +	RWindowGroup iInfoGroupInstance;
    1.92 +	RWindowGroup* iInfoGroup;
    1.93 +	CWsScreenDevice* iScreenDevice;
    1.94 +	CWsScreenDevice* iInfoScreenDevice;
    1.95 +	CWindowGc* iGc;
    1.96 +	CWindowGc* iInfoGc;
    1.97 +	TInt iWindowHandle;
    1.98 +	static TBool	iTransparencyEnabled;
    1.99 +	TRgb iRed, iGreen, iBlue, iCyan, iMagenta, iYellow, iWhite;
   1.100 +	TRgb TITLE_BACKGROUND;
   1.101 +	TRgb COMPARE_BACKGROUND;
   1.102 +	RBlankWindow iBackground;
   1.103 +	RWindow iCompare;
   1.104 +	RWindow iTitle;
   1.105 +	TRect 	iTestPos;
   1.106 +	TRect   iCenteredFrontWinRect;
   1.107 +	TPoint	iTestPointCentre;
   1.108 +	TDisplayMode iDisplayMode;
   1.109 +	static const TInt KMaxTestName = 80;
   1.110 +	typedef TBuf<KMaxTestName> TTestName;
   1.111 +	mutable TRgb	iLastGceHoleColor;
   1.112 +	TTestName iTestName;
   1.113 +	static const TInt KMaxInfoLines=5;
   1.114 +	TTestName iTestInfo[KMaxInfoLines];
   1.115 +	static CActiveScheduler	iScheduler;
   1.116 +};
   1.117 +
   1.118 +// This little helper class checks that the given bytes contain the expected pattern.
   1.119 +namespace Pattern
   1.120 +	{
   1.121 +		void Fill(void* aTrg,TInt aOffset,TInt aLength);
   1.122 +		TBool Check(void* aTrg,TInt aOffset,TInt aLength);
   1.123 +		TBool CheckVal(void* aTrg,TInt aOffset,TInt aLength,char val=0);
   1.124 +	}
   1.125 +
   1.126 +//This wrapper for the configuration class allows stress testing of the configuration object
   1.127 +
   1.128 +template <class TXxxConfiguration,TInt aExtraSize,TInt aFalseSize> 
   1.129 +class TestExtend:	public TXxxConfiguration
   1.130 +	{
   1.131 +public:
   1.132 +	char iExtraData[aExtraSize];
   1.133 +	TestExtend():
   1.134 +		TXxxConfiguration(aFalseSize)
   1.135 +		{
   1.136 +		TXxxConfiguration::iSize=aFalseSize;
   1.137 +		Pattern::Fill(this,aFalseSize,sizeof(*this)-aFalseSize);
   1.138 +		}
   1.139 +	void* operator new(unsigned int,TestExtend* inplace)
   1.140 +	{	//Use this inplace operator new to pre-initialise the memory
   1.141 +	return inplace;
   1.142 +	}
   1.143 +	void operator delete(void*,TestExtend*)
   1.144 +	{	//Stops the warning!
   1.145 +	}
   1.146 +	TestExtend(const TXxxConfiguration&i):
   1.147 +		TXxxConfiguration(i)
   1.148 +		{
   1.149 +		Pattern::Check(this,sizeof(TXxxConfiguration),aExtraSize);
   1.150 +		}
   1.151 +	TBool WasExtraOverwritten()
   1.152 +		{
   1.153 +		return Pattern::Check(this,sizeof(TXxxConfiguration),aExtraSize);
   1.154 +		}
   1.155 +	TBool WasFalseSizeOverwritten()
   1.156 +		{
   1.157 +		return Pattern::Check(this,aFalseSize,sizeof(*this)-aFalseSize);
   1.158 +		}
   1.159 +	TBool WasFalseSizeZero()
   1.160 +		{
   1.161 +		return Pattern::CheckVal(this,aFalseSize,sizeof(TXxxConfiguration)-aFalseSize);
   1.162 +		}
   1.163 +	void	StompValue(TInt aOffsetInLongs,TInt aNewValue)
   1.164 +		{
   1.165 +		*((TInt*)this+aOffsetInLongs)=aNewValue;
   1.166 +		}
   1.167 +	TInt	ReadValue(TInt aOffsetInLongs)
   1.168 +		{
   1.169 +		return *((TInt*)this+aOffsetInLongs);
   1.170 +		}
   1.171 +	};
   1.172 +#endif /*TWSDYNAMICRESWINBASE_H_*/