os/graphics/windowing/windowserver/test/tcsc/cwsgcecscbase.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/tcsc/cwsgcecscbase.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,181 @@
     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 +//
    1.18 +
    1.19 +#ifndef TCWGCECSCBASE_H_
    1.20 +#define TCWGCECSCBASE_H_
    1.21 +
    1.22 +#include <test/tefunit.h>
    1.23 +#include <w32debug.h>
    1.24 +#include "surfaceutility.h"
    1.25 +#include <e32property.h>
    1.26 +
    1.27 +class TPerfProperties
    1.28 +{
    1.29 +public:
    1.30 +	TBool GetValue(TUint aKey);
    1.31 +	void PrintAllL(CTestFixture& aLogger);
    1.32 +	TBool ResetValue(TUint aKey);
    1.33 +	void UpdateAll();
    1.34 +	void ResetAll();
    1.35 +private:
    1.36 +#ifdef GCE_BACKEND_PROFILING
    1.37 +	TInt iValue[EPerfLastKey];
    1.38 +	TInt iPrevValue[EPerfLastKey];
    1.39 +	const static TBuf<100> propertyKeysTxt[EPerfLastKey];
    1.40 +#endif
    1.41 +};
    1.42 +
    1.43 +class CWsGceCscBase: public CTestFixture
    1.44 +{
    1.45 +
    1.46 +public:
    1.47 +	template <class Referee,class LoggerOwner>
    1.48 +	class	SafePointer
    1.49 +		{
    1.50 +	public:
    1.51 +		SafePointer(LoggerOwner* aOwner,Referee* aReferee=NULL):
    1.52 +			iOwner(aOwner),	iReferee(aReferee)
    1.53 +			{}
    1.54 +		Referee*	operator=(Referee* aReferee)
    1.55 +			{
    1.56 +			return iReferee=aReferee;
    1.57 +			}
    1.58 +		Referee*&	operator()()
    1.59 +			{
    1.60 +			return iReferee;
    1.61 +			}
    1.62 +		Referee*	operator->()
    1.63 +			{
    1.64 +			if (iReferee==NULL)
    1.65 +				{
    1.66 +				iOwner -> INFO_PRINTF1(_L("Tried to dereference a pointer that is null!"));
    1.67 +				User::Panic(_L("null pointer"),__LINE__);
    1.68 +				}
    1.69 +			return iReferee;
    1.70 +			}
    1.71 +	private:
    1.72 +		LoggerOwner* iOwner;
    1.73 +		Referee* iReferee;
    1.74 +		};
    1.75 +	
    1.76 +public:
    1.77 +	CWsGceCscBase();
    1.78 +	virtual ~CWsGceCscBase();
    1.79 +	virtual void SetupL();
    1.80 +	virtual void TearDownL();
    1.81 +	virtual void TearDownFromDeleteL();
    1.82 +
    1.83 +protected:
    1.84 +	typedef TBuf<KMaxTestName> TTestName;
    1.85 +	
    1.86 +	class TPostTestCleanup
    1.87 +		{
    1.88 +		protected:
    1.89 +		TPostTestCleanup()	{}
    1.90 +		public:
    1.91 +		CSurfaceUtility*	iSharedUtility;
    1.92 +		TBool				iCleanedUpOnExit;
    1.93 +		};
    1.94 +
    1.95 +
    1.96 +	typedef enum TOptimizationLevel
    1.97 +		{
    1.98 +		EDisable,
    1.99 +		EDetectFrontmostFullScreenOpaqueLayer,
   1.100 +		EMaximum,
   1.101 +		} TOptimizationLevel;
   1.102 +
   1.103 +		
   1.104 +protected:
   1.105 +	void SetCompositionMode(RWindow& aWindow, TDisplayMode aMode);
   1.106 +	
   1.107 +	TBool Compare(CFbsBitmap& aBitmap1, CFbsBitmap& aBitmap2);
   1.108 +
   1.109 +	void ConstructOpaqueWindowLC(RWindow& aWindow, 
   1.110 +			                     const TRgb& aColor,
   1.111 +			                     TInt aPos,
   1.112 +			                     const TPoint& aPoint,
   1.113 +			                     const TSize& aSize);
   1.114 +	
   1.115 +	void ConstructOpaqueWindowL(RWindow& aWindow, 
   1.116 +			                    const TRgb& aColor,
   1.117 +			                    TInt aPos,
   1.118 +			                    const TPoint& aPoint,
   1.119 +			                    const TSize& aSize);
   1.120 +	
   1.121 +	void SetBackgroundColorWindow(RWindow& aWindow, const TRgb& aColor);
   1.122 +	
   1.123 +	void ConstructOpaqueSurfacedWindowLC(RWindow& aWindow,
   1.124 +		                                 const TRgb& aColor,
   1.125 +		                                 TInt aPos,
   1.126 +		                                 const TPoint& aPoint,
   1.127 +		                                 const TSize& aSize,
   1.128 +		                                 TSurfaceId& aSurfaceID);
   1.129 +	void ConstructOpaqueSurfacedWindowL(RWindow& aWindow,
   1.130 +		                                const TRgb& aColor,
   1.131 +		                                TInt aPos,
   1.132 +		                                const TPoint& aPoint,
   1.133 +		                                const TSize& aSize,
   1.134 +		                                const TSurfaceId& aSurfaceID);
   1.135 +	
   1.136 +protected:
   1.137 +	inline TInt ObjIndScr(TInt aScreen,TInt aWin=0,TInt aLayer=0,TInt aExtra=0);
   1.138 +	template <class DataType>	// DataType may be TSurfaceId, TInt,TRect, TSurfaceConfiguration (not TRegion)
   1.139 +	TInt	DebugInfo(TWsDebugInfoFunc aFunction, TInt aObjectIndex, TDes8& aHostBuffer,const DataType*&aReturnedObject)const
   1.140 +	{
   1.141 +	return DebugInfo(aFunction,aObjectIndex,aHostBuffer,(const void*&)aReturnedObject,sizeof(DataType));
   1.142 +	}
   1.143 +	TInt DebugInfo(TWsDebugInfoFunc aFunction, 
   1.144 +			       TInt aParam, 
   1.145 +			       TDes8& aHostBuffer,
   1.146 +			       const void*&aReturnedObject,
   1.147 +			       TInt aObjectSize)const;
   1.148 +	void TefUnitFailLeaveL();
   1.149 +	static void Pause(TInt aMilliseconds=200);
   1.150 +	TBool GCEIsSupported() const;
   1.151 +	static TBool GCEIsSupportedStatic();
   1.152 +	static TPostTestCleanup& PostTestCleanupInstance();
   1.153 +	
   1.154 +protected:
   1.155 +	TBool	iDoTearDown;
   1.156 +	RWsSession iSession;
   1.157 +	RWindowGroup iGroup;
   1.158 +	CWsScreenDevice* iScreenDevice;
   1.159 +	CWindowGc* iGc;
   1.160 +	TInt iWindowHandle;
   1.161 +	TBool	iTransparencyEnabled;
   1.162 +	TRgb iRed, iGreen, iBlue, iCyan, iMagenta, iYellow, iWhite;
   1.163 +	TDisplayMode iDisplayMode;
   1.164 +	SafePointer<CSurfaceUtility,CWsGceCscBase> iUtility;
   1.165 +	static const TInt KMaxInfoLines=5;
   1.166 +	TTestName iTestInfo[KMaxInfoLines];
   1.167 +	TTestName iTestName;
   1.168 +	static const TUidPixelFormat KSurfaceFormat = EUidPixelFormatXRGB_8888;
   1.169 +	static const TInt KBytesPerPixel = 4;	// Four bytes per pixel for the format above.
   1.170 +	TPerfProperties iProperties;
   1.171 +};
   1.172 +
   1.173 +inline TInt CWsGceCscBase::ObjIndScr(TInt aScreen,
   1.174 +		                                     TInt aWin,
   1.175 +		                                     TInt aLayer,
   1.176 +		                                     TInt aExtra)
   1.177 +	{
   1.178 +	return 	(aScreen<<EWsDebugArgScreenShift)
   1.179 +		|	(aWin<<EWsDebugArgWindowShift)
   1.180 +		|	(aLayer<<EWsDebugArgLayerShift)
   1.181 +		|	(aExtra<<EWsDebugArgExtraShift);
   1.182 +	}
   1.183 +
   1.184 +#endif /*TCWGCECSCBASE_H_*/