os/graphics/windowing/windowserver/test/tdynamicres/inc/wsdynamicresbase.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 LargerTestWindow(TInt aPercentOfBack=80);
    85 	void MakeExtraChildWindowL(const RWindowBase& aFromParent,TRect aChildRect,TRgb aChildColor);
    86 	struct LoopingGcPtr;
    87 	LoopingGcPtr	LoopBeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor);
    88 	CWindowGc*	BeginActivateWithWipe(TBool aInvalidate,RWindow& aWin,TRgb aColor=TRgb(0,0));
    89 	CWindowGc*	BeginActivateWithWipe(TBool aInvalidate,TRect aRect,RWindow& aWin,TRgb aColor=TRgb(0,0));
    90 	CWindowGc*	BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor);
    91 	static CFbsBitmap* RotateBitmapLC(const CFbsBitmap* aSrcBitmap);
    92 
    93 	void Pause(TInt aMilliseconds);
    94 	TInt	RegionDiffForUiLayer(TInt aUiLayer);	//returns values from TRegionExtend::TOverlapFlags enumeration
    95 	enum	 FastPathMode
    96 		{	//Tereat this as bit flags or distinct states as you wish.
    97 			EFpExternalOpaque=0,
    98 			EFpUiOpaque=1,
    99 			EFpUiBlended=2,
   100 			EFpUiComplex=3,			//If ony this is set then both blended and opaque are full=screen
   101 			EFpUiRegions=4,			//If this FLAG is set then the regions are less than full-screen. Never occurs on its own
   102 			EFpUiRegionsOpaque=5,			//If this is set then the regions are less than full-screen
   103 			EFpUiRegionsBlended=6,			//If this is set then the regions are less than full-screen
   104 			EFpUiRegionsComplex=7	//This is the expected setting for windowed cr1108 optimisation. 
   105 		};
   106 	FastPathMode	DeduceUiFastPathMode();
   107 protected:
   108 	SafePointer<CSurfaceUtility,CWsDynamicResBase> iUtility;
   109 	class TPostTestCleanup
   110 		{
   111 		protected:
   112 		TPostTestCleanup()	{}
   113 		public:
   114 		mutable CSurfaceUtility*	iSharedUtility;
   115 		mutable TBool				iCleanedUpOnExit;
   116 		void				CreateSharedUtilityL()const ;
   117 		};
   118 	static const TPostTestCleanup& PostTestCleanupInstance();
   119 	RBlankWindow	iTestBack;
   120 	RWindow	iTestFront;
   121 	RWindow	iTestChild;
   122 	RWindow	iTestSecondChild;
   123 	static const TUidPixelFormat KSurfaceFormat = EUidPixelFormatXRGB_8888;
   124 	static const TInt KBytesPerPixel = 4;	// Four bytes per pixel for the format above.
   125 private:
   126 
   127 };
   128 
   129 struct CWsDynamicResBase::LoopingGcPtr
   130 	{
   131 	LoopingGcPtr(const TRegion& aRegion,RWindow& aWin,TRgb aColor,CWindowGc *aGc)
   132 		:	iRegion(aRegion),	iWin(aWin),	iColor(aColor), iGc(aGc), iPass(-1)	
   133 		{ operator++();	}
   134 	LoopingGcPtr(const LoopingGcPtr& aRhs)
   135 		:	iRegion(aRhs.iRegion),	iWin(aRhs.iWin),	
   136 			iColor(aRhs.iColor), iGc(aRhs.iGc),
   137 			iPass(aRhs.iPass)	
   138 		{}
   139 	void operator ++();	
   140 	operator bool()		{ return iPass>=0?iGc:(CWindowGc *)NULL;	}
   141 	CWindowGc * operator ->()	{ return iPass>=0?iGc:(CWindowGc *)NULL;	}
   142 	const TRegion& iRegion;
   143 	RWindow& iWin;
   144 	TRgb iColor;
   145 	CWindowGc *iGc;
   146 	TInt iPass;
   147 	};
   148 
   149 #define LOG_AND_PANIC_IF_NOT_GCE											\
   150 		{																	\
   151 		if (!GCEIsSupported())												\
   152 			{																\
   153 			INFO_PRINTF1(_L("Test skipped: GCE support is not loaded"));	\
   154 			User::Panic(_L("GCE.Wrong.Mode"),1);							\
   155 			return;															\
   156 			}																\
   157 		}
   158 
   159 #endif /*WSDYNAMICRESBASE_H_*/