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