windowing/windowserver/tdynamicres/inc/wsdynamicresbase.h
changeset 110 7f25ef56562d
parent 98 bf7481649c98
child 111 29ddb8a72f0e
equal deleted inserted replaced
98:bf7481649c98 110:7f25ef56562d
     1 // Copyright (c) 2008-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 #ifndef WSDYNAMICRESBASE_H_
       
    17 #define WSDYNAMICRESBASE_H_
       
    18 
       
    19 #include "t_wsdynamicreswinbase.h"
       
    20 #include <graphics/surface.h>
       
    21 #include "surfaceutility.h"
       
    22 
       
    23 //************************************
       
    24 //
       
    25 // Asserting wrapper around dereferencing a pointer that might be NULL.
       
    26 // I don't want to fill the test code with checks that this pointer is not null before calling surface utility methods....
       
    27 //
       
    28 //************************************
       
    29 
       
    30 template <class Referee,class LoggerOwner>
       
    31 class	SafePointer
       
    32 	{
       
    33 public:
       
    34 	SafePointer(LoggerOwner* aOwner,Referee* aReferee=NULL):
       
    35 		iOwner(aOwner),	iReferee(aReferee)
       
    36 		{}
       
    37 	Referee*	operator=(Referee* aReferee)
       
    38 		{
       
    39 		return iReferee=aReferee;
       
    40 		}
       
    41 	Referee*&	operator()()
       
    42 		{
       
    43 		return iReferee;
       
    44 		}
       
    45 	Referee*	operator->()
       
    46 		{
       
    47 		if (iReferee==NULL)
       
    48 			{
       
    49 			iOwner -> INFO_PRINTF1(_L("Tried to dereference a pointer that is null!"));
       
    50 			User::Panic(_L("null pointer"),__LINE__);
       
    51 			}
       
    52 		return iReferee;
       
    53 		}
       
    54 private:
       
    55 	LoggerOwner* iOwner;
       
    56 	Referee* iReferee;
       
    57 	};
       
    58 	
       
    59 /**
       
    60  * Base class test harness that provides facilities for windowing and surface testing
       
    61  * 
       
    62  **/
       
    63 class CWsDynamicResBase : public CWsDynamicResWinBase
       
    64 {
       
    65 public:
       
    66 	CWsDynamicResBase();
       
    67 	virtual ~CWsDynamicResBase();
       
    68 	
       
    69 	virtual void SetupL();
       
    70 	virtual void SetupL(TBool aUseOtherScreenForInfo);
       
    71 	virtual void TearDownL();
       
    72 	virtual void TearDownFromDeleteL();
       
    73 	/* Note that each derived test class needs to declare a static function to register tests.
       
    74 	 * This should match the following prototype:
       
    75 	static CTestSuite* CreateSuiteL( const TDesC& aName );
       
    76 	*/ 
       
    77 
       
    78 	protected:
       
    79 	void UISurfaceL(TSurfaceId& aSurfaceId) const;
       
    80 	void CommonSurfaceWindowSetupL(RWindow& aWindow, TSurfaceId& aSurface, const TRgb& aColor);
       
    81 	void CommonOverlayWindowSetupL(RWindow& aWindow, const TRgb& aColor);
       
    82 	void ResizeTestCommonSetupL(RWindow& aWindow, const TRgb& aColor);
       
    83 
       
    84 	void MakeTestWindowPairL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor);
       
    85 	void LargerTestWindow(TInt aPercentOfBack=80);
       
    86 	void DestroyTestWindowPair(TBool aKillTestBack=ETrue,TBool aKillTestFront=ETrue,TBool aKillTestChildren=ETrue);
       
    87 	void MakeTestWindowTripleL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor,TRect aSecondChildRect,TRgb aSecondChildColor);
       
    88 	void CreateTestWindowQuadL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor,TRect aSecondChildRect,TRgb aSecondChildColor);
       
    89 	void MakeTestWindowTripleL(TRect aOuterRect,TRgb aOuterColor,TRect aInnerRect,TRgb aInnerColor,TRect aChildRect,TRgb aChildColor);
       
    90 	void MakeExtraChildWindowL(const RWindowBase& aFromParent,TRect aChildRect,TRgb aChildColor);
       
    91 	struct LoopingGcPtr;
       
    92 	LoopingGcPtr	LoopBeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor);
       
    93 	CWindowGc*	BeginActivateWithWipe(TBool aInvalidate,RWindow& aWin,TRgb aColor=TRgb(0,0));
       
    94 	CWindowGc*	BeginActivateWithWipe(TBool aInvalidate,TRect aRect,RWindow& aWin,TRgb aColor=TRgb(0,0));
       
    95 	CWindowGc*	BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor);
       
    96 	static CFbsBitmap* RotateBitmapLC(const CFbsBitmap* aSrcBitmap);
       
    97 
       
    98 	void Pause(TInt aMilliseconds);
       
    99 	TInt	RegionDiffForUiLayer(TInt aUiLayer);	//returns values from TRegionExtend::TOverlapFlags enumeration
       
   100 	enum	 FastPathMode
       
   101 		{	//Tereat this as bit flags or distinct states as you wish.
       
   102 			EFpExternalOpaque=0,
       
   103 			EFpUiOpaque=1,
       
   104 			EFpUiBlended=2,
       
   105 			EFpUiComplex=3,			//If ony this is set then both blended and opaque are full=screen
       
   106 			EFpUiRegions=4,			//If this FLAG is set then the regions are less than full-screen. Never occurs on its own
       
   107 			EFpUiRegionsOpaque=5,			//If this is set then the regions are less than full-screen
       
   108 			EFpUiRegionsBlended=6,			//If this is set then the regions are less than full-screen
       
   109 			EFpUiRegionsComplex=7	//This is the expected setting for windowed cr1108 optimisation. 
       
   110 		};
       
   111 	FastPathMode	DeduceUiFastPathMode();
       
   112 protected:
       
   113 	SafePointer<CSurfaceUtility,CWsDynamicResBase> iUtility;
       
   114 	class TPostTestCleanup
       
   115 		{
       
   116 		protected:
       
   117 		TPostTestCleanup()	{}
       
   118 		public:
       
   119 		mutable CSurfaceUtility*	iSharedUtility;
       
   120 		mutable TBool				iCleanedUpOnExit;
       
   121 		void				CreateSharedUtilityL()const ;
       
   122 		};
       
   123 	static const TPostTestCleanup& PostTestCleanupInstance();
       
   124 	RWindow	iTestBack;
       
   125 	RWindow	iTestFront;
       
   126 	RWindow	iTestChild;
       
   127 	RWindow	iTestSecondChild;
       
   128 	static const TUidPixelFormat KSurfaceFormat = EUidPixelFormatXRGB_8888;
       
   129 	static const TInt KBytesPerPixel = 4;	// Four bytes per pixel for the format above.
       
   130 private:
       
   131 
       
   132 };
       
   133 
       
   134 struct CWsDynamicResBase::LoopingGcPtr
       
   135 	{
       
   136 	LoopingGcPtr(const TRegion& aRegion,RWindow& aWin,TRgb aColor,CWindowGc *aGc)
       
   137 		:	iRegion(aRegion),	iWin(aWin),	iColor(aColor), iGc(aGc), iPass(-1)	
       
   138 		{ operator++();	}
       
   139 	LoopingGcPtr(const LoopingGcPtr& aRhs)
       
   140 		:	iRegion(aRhs.iRegion),	iWin(aRhs.iWin),	
       
   141 			iColor(aRhs.iColor), iGc(aRhs.iGc),
       
   142 			iPass(aRhs.iPass)	
       
   143 		{}
       
   144 	void operator ++();	
       
   145 	operator bool()		{ return iPass>=0?iGc:(CWindowGc *)NULL;	}
       
   146 	CWindowGc * operator ->()	{ return iPass>=0?iGc:(CWindowGc *)NULL;	}
       
   147 	const TRegion& iRegion;
       
   148 	RWindow& iWin;
       
   149 	TRgb iColor;
       
   150 	CWindowGc *iGc;
       
   151 	TInt iPass;
       
   152 	};
       
   153 
       
   154 #define LOG_AND_PANIC_IF_NOT_GCE											\
       
   155 		{																	\
       
   156 		if (!GCEIsSupported())												\
       
   157 			{																\
       
   158 			INFO_PRINTF1(_L("Test skipped: GCE support is not loaded"));	\
       
   159 			User::Panic(_L("GCE.Wrong.Mode"),1);							\
       
   160 			return;															\
       
   161 			}																\
       
   162 		}
       
   163 
       
   164 #endif /*WSDYNAMICRESBASE_H_*/