os/graphics/windowing/windowserver/test/tdynamicres/inc/t_wsdynamicreswinbase.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200 (2012-06-15)
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
// twsgcetestwinbase.h
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#ifndef TWSDYNAMICRESWINBASE_H_
sl@0
    19
#define TWSDYNAMICRESWINBASE_H_
sl@0
    20
sl@0
    21
#include <gdi.h>
sl@0
    22
#include <test/tefunit.h>
sl@0
    23
#include <w32std.h>
sl@0
    24
#include <w32debug.h>
sl@0
    25
#include "wsgcedebugsession.h"
sl@0
    26
struct TWsDebugWindowId;
sl@0
    27
sl@0
    28
/**
sl@0
    29
 * Base class sets up the tryptich of test windows.
sl@0
    30
 * 
sl@0
    31
 * 
sl@0
    32
 **/
sl@0
    33
class CWsDynamicResWinBase : public CTestFixture
sl@0
    34
{
sl@0
    35
public:
sl@0
    36
	CWsDynamicResWinBase();
sl@0
    37
	virtual ~CWsDynamicResWinBase();
sl@0
    38
	virtual void SetupL();
sl@0
    39
	virtual void SetupL(TBool aUseOtherScreenForInfo);
sl@0
    40
	
sl@0
    41
	virtual void TearDownL();
sl@0
    42
	virtual void TearDownFromDeleteL();
sl@0
    43
	
sl@0
    44
	static TBool	ActivateWithWipe(CWindowGc* aGc,RWindow& aWin,TRgb aColor=TRgb(0,0));
sl@0
    45
	
sl@0
    46
	/* Note that each derived test class needs to declare a static function to register tests.
sl@0
    47
	 * This should match the following prototype:
sl@0
    48
	static CTestSuite* CreateSuiteL( const TDesC& aName );
sl@0
    49
	*/ 
sl@0
    50
	
sl@0
    51
protected:
sl@0
    52
	static void Pause(TInt aMilliseconds=200);
sl@0
    53
sl@0
    54
	TBool GCEIsSupported() const;
sl@0
    55
	static TBool GCEIsSupportedStatic();
sl@0
    56
sl@0
    57
	TBool DisplayHasAlpha() const;
sl@0
    58
	TBool SelectChromaCompositionMode();
sl@0
    59
	TBool SelectAlphaCompositionMode(TDisplayMode aMode = EColor16MA);
sl@0
    60
	TRgb  GceHoleColor(RWindowBase& aWin)const;
sl@0
    61
	void DrawUIContent(RWindow& aWindow);
sl@0
    62
	void DrawPlainUI(RWindow& aWindow,TBool aInvalidate,TRgb aWipeColor=TRgb(0,0));
sl@0
    63
	void DrawCross(RWindow& aWindow, TRgb aColor, TInt aThickness=1);
sl@0
    64
	void TestPixelL(TPoint aPt, TRgb aColor, TBool aMatch);
sl@0
    65
	TBool TestRectL(TRect aRect,TRgb aInnerColor,TInt aOtherInnerColors,TRgb aOuterColor,TInt aOtherOuterColors,TInt aCornerSize);
sl@0
    66
	void MakeTitleAndCompareWindowsL(TRefByValue<const TDesC16> aTitle,TRefByValue<const TDesC16> aDetail=_L(""));
sl@0
    67
	void LargerCompareWindow(TBool aGoLarger=ETrue);
sl@0
    68
	void UpdateTitleWindowL(TRefByValue<const TDesC16> aDetail,TInt aIndex=0);
sl@0
    69
	void RepaintTitleWindowL();
sl@0
    70
	void TefUnitFailLeaveL();
sl@0
    71
	CWindowGc*	GcForWindow(RWindow& aWin);
sl@0
    72
	TBool		InvalidateRegion(const TRegion& aRegion,RWindow& aWin);
sl@0
    73
	CWindowGc*	BeginActivateWithWipe(TBool aInvalidate,RWindow& aWin,TRgb aColor=TRgb(0,0));
sl@0
    74
	CWindowGc*	BeginActivateWithWipe(TBool aInvalidate,TRect aRect,RWindow& aWin,TRgb aColor=TRgb(0,0));
sl@0
    75
	CWindowGc*	BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor);
sl@0
    76
	/** Helper method to find a named screen region
sl@0
    77
	 *	start/end letter should be 'a' to 'y' (yes that includes 'i')
sl@0
    78
	 **/
sl@0
    79
	static TRect PentCellRect(const TRect& aFullRect,char aStartLetter,char aEndLetter=0);
sl@0
    80
	void CheckAndConnectScreen();
sl@0
    81
sl@0
    82
protected:
sl@0
    83
	static const TInt KSurfaceWidth = 50;
sl@0
    84
	static const TInt KSurfaceHeight = 50;
sl@0
    85
	TBool	iDoTearDown;
sl@0
    86
	RWsDebugSession iSession;
sl@0
    87
	RWindowGroup iGroup;
sl@0
    88
	RWindowGroup iInfoGroupInstance;
sl@0
    89
	RWindowGroup* iInfoGroup;
sl@0
    90
	CWsScreenDevice* iScreenDevice;
sl@0
    91
	CWsScreenDevice* iInfoScreenDevice;
sl@0
    92
	CWindowGc* iGc;
sl@0
    93
	CWindowGc* iInfoGc;
sl@0
    94
	TInt iWindowHandle;
sl@0
    95
	static TBool	iTransparencyEnabled;
sl@0
    96
	TRgb iRed, iGreen, iBlue, iCyan, iMagenta, iYellow, iWhite;
sl@0
    97
	TRgb TITLE_BACKGROUND;
sl@0
    98
	TRgb COMPARE_BACKGROUND;
sl@0
    99
	RBlankWindow iBackground;
sl@0
   100
	RWindow iCompare;
sl@0
   101
	RWindow iTitle;
sl@0
   102
	TRect 	iTestPos;
sl@0
   103
	TRect   iCenteredFrontWinRect;
sl@0
   104
	TPoint	iTestPointCentre;
sl@0
   105
	TDisplayMode iDisplayMode;
sl@0
   106
	static const TInt KMaxTestName = 80;
sl@0
   107
	typedef TBuf<KMaxTestName> TTestName;
sl@0
   108
	mutable TRgb	iLastGceHoleColor;
sl@0
   109
	TTestName iTestName;
sl@0
   110
	static const TInt KMaxInfoLines=5;
sl@0
   111
	TTestName iTestInfo[KMaxInfoLines];
sl@0
   112
	static CActiveScheduler	iScheduler;
sl@0
   113
};
sl@0
   114
sl@0
   115
// This little helper class checks that the given bytes contain the expected pattern.
sl@0
   116
namespace Pattern
sl@0
   117
	{
sl@0
   118
		void Fill(void* aTrg,TInt aOffset,TInt aLength);
sl@0
   119
		TBool Check(void* aTrg,TInt aOffset,TInt aLength);
sl@0
   120
		TBool CheckVal(void* aTrg,TInt aOffset,TInt aLength,char val=0);
sl@0
   121
	}
sl@0
   122
sl@0
   123
//This wrapper for the configuration class allows stress testing of the configuration object
sl@0
   124
sl@0
   125
template <class TXxxConfiguration,TInt aExtraSize,TInt aFalseSize> 
sl@0
   126
class TestExtend:	public TXxxConfiguration
sl@0
   127
	{
sl@0
   128
public:
sl@0
   129
	char iExtraData[aExtraSize];
sl@0
   130
	TestExtend():
sl@0
   131
		TXxxConfiguration(aFalseSize)
sl@0
   132
		{
sl@0
   133
		TXxxConfiguration::iSize=aFalseSize;
sl@0
   134
		Pattern::Fill(this,aFalseSize,sizeof(*this)-aFalseSize);
sl@0
   135
		}
sl@0
   136
	void* operator new(unsigned int,TestExtend* inplace)
sl@0
   137
	{	//Use this inplace operator new to pre-initialise the memory
sl@0
   138
	return inplace;
sl@0
   139
	}
sl@0
   140
	void operator delete(void*,TestExtend*)
sl@0
   141
	{	//Stops the warning!
sl@0
   142
	}
sl@0
   143
	TestExtend(const TXxxConfiguration&i):
sl@0
   144
		TXxxConfiguration(i)
sl@0
   145
		{
sl@0
   146
		Pattern::Check(this,sizeof(TXxxConfiguration),aExtraSize);
sl@0
   147
		}
sl@0
   148
	TBool WasExtraOverwritten()
sl@0
   149
		{
sl@0
   150
		return Pattern::Check(this,sizeof(TXxxConfiguration),aExtraSize);
sl@0
   151
		}
sl@0
   152
	TBool WasFalseSizeOverwritten()
sl@0
   153
		{
sl@0
   154
		return Pattern::Check(this,aFalseSize,sizeof(*this)-aFalseSize);
sl@0
   155
		}
sl@0
   156
	TBool WasFalseSizeZero()
sl@0
   157
		{
sl@0
   158
		return Pattern::CheckVal(this,aFalseSize,sizeof(TXxxConfiguration)-aFalseSize);
sl@0
   159
		}
sl@0
   160
	void	StompValue(TInt aOffsetInLongs,TInt aNewValue)
sl@0
   161
		{
sl@0
   162
		*((TInt*)this+aOffsetInLongs)=aNewValue;
sl@0
   163
		}
sl@0
   164
	TInt	ReadValue(TInt aOffsetInLongs)
sl@0
   165
		{
sl@0
   166
		return *((TInt*)this+aOffsetInLongs);
sl@0
   167
		}
sl@0
   168
	};
sl@0
   169
#endif /*TWSDYNAMICRESWINBASE_H_*/