os/graphics/windowing/windowserver/test/tauto/TREDRAW.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) 1996-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
/**
sl@0
    17
 @file
sl@0
    18
 @test
sl@0
    19
 @internalComponent - Internal Symbian test code
sl@0
    20
*/
sl@0
    21
sl@0
    22
#ifndef __TREDRAW_H__
sl@0
    23
#define __TREDRAW_H__
sl@0
    24
sl@0
    25
#include <e32std.h>
sl@0
    26
#include <w32std.h>
sl@0
    27
#include "../tlib/testbase.h"
sl@0
    28
#include "AUTO.H"
sl@0
    29
#include "TScreenModeScaling.h"
sl@0
    30
#include "TGraphicsHarness.h"
sl@0
    31
sl@0
    32
class CTRedrawTest;
sl@0
    33
sl@0
    34
/**
sl@0
    35
 * Abstract base class to draw a pattern into a window.
sl@0
    36
 * 
sl@0
    37
 * This provides a default Draw() implementation which
sl@0
    38
 * DOES NOT set the clipping region before drawing.
sl@0
    39
 */
sl@0
    40
class CRedrawWindow : public CTWin
sl@0
    41
	{
sl@0
    42
	friend class CTRedrawTest;
sl@0
    43
public:
sl@0
    44
	enum TDrawPattern
sl@0
    45
		{
sl@0
    46
		EDrawGraphPaperlHatched = 0,
sl@0
    47
		EDrawSlantingHatched,
sl@0
    48
		EDrawCenteredRectangle
sl@0
    49
		};
sl@0
    50
public:
sl@0
    51
	CRedrawWindow(CTRedrawTest* aTest);
sl@0
    52
	~CRedrawWindow();
sl@0
    53
public:
sl@0
    54
	/*
sl@0
    55
	 * Draw the window, counting the number of calls.
sl@0
    56
	 * @post DrawRequests() returns a value increased by 1.
sl@0
    57
	 */
sl@0
    58
	virtual void Reset();
sl@0
    59
	virtual void PrepareInvalidation(const TRect& aRect) = 0;
sl@0
    60
	virtual void PerformInvalidation() = 0;
sl@0
    61
	//Virtual function from CTBaseWin
sl@0
    62
	void Draw();
sl@0
    63
public:
sl@0
    64
	void ActivateAndDraw(TInt aPattern);
sl@0
    65
	void DrawPattern(TInt aPattern);
sl@0
    66
	void VisibleRegion(RRegion& aRegion);
sl@0
    67
	void ValidateAndClear();
sl@0
    68
	void ActivateAndDraw(TInt aPattern,TRegion* aRegion);
sl@0
    69
	TInt DrawRequests() const;
sl@0
    70
protected:
sl@0
    71
	void ReceivedDrawRequest();
sl@0
    72
	TPoint iOffset;
sl@0
    73
	RRegion iInvalid;
sl@0
    74
	CTRedrawTest *iTest;
sl@0
    75
private:
sl@0
    76
	TInt iDrawRequests;
sl@0
    77
	};
sl@0
    78
sl@0
    79
/**
sl@0
    80
 * Concrete class to draw a pattern into a window.
sl@0
    81
 * 
sl@0
    82
 */
sl@0
    83
class CReferenceComparisonRedrawWindow : public CRedrawWindow
sl@0
    84
	{
sl@0
    85
public:
sl@0
    86
	CReferenceComparisonRedrawWindow(CTRedrawTest* aTest);
sl@0
    87
public:
sl@0
    88
	// from CRedrawWindow
sl@0
    89
	void PrepareInvalidation(const TRect& aRect);
sl@0
    90
	void PerformInvalidation();
sl@0
    91
	};
sl@0
    92
sl@0
    93
class CRedrawWindow2 : public CRedrawWindow
sl@0
    94
	{
sl@0
    95
public:
sl@0
    96
	CRedrawWindow2(CTRedrawTest* aTest);
sl@0
    97
public:
sl@0
    98
	//Virtual function from CTBaseWin overridden in CRedrawWindow
sl@0
    99
	void Draw();
sl@0
   100
	//Virtual function from CRedrawWindow
sl@0
   101
	void Reset();
sl@0
   102
	// from CRedrawWindow
sl@0
   103
	void PrepareInvalidation(const TRect& aRect);
sl@0
   104
	void PerformInvalidation();
sl@0
   105
private:
sl@0
   106
	TBool iClipped;
sl@0
   107
	};
sl@0
   108
sl@0
   109
class CRedrawWindow3 : public CRedrawWindow
sl@0
   110
	{
sl@0
   111
public:
sl@0
   112
	CRedrawWindow3(CTRedrawTest* aTest);
sl@0
   113
public:
sl@0
   114
	//Virtual function from CTBaseWin overridden in CRedrawWindow
sl@0
   115
	void Draw();
sl@0
   116
	// from CRedrawWindow
sl@0
   117
	void PrepareInvalidation(const TRect& aRect);
sl@0
   118
	void PerformInvalidation();
sl@0
   119
public:
sl@0
   120
	void SetUp1L(TPoint pos,TSize size,CTWinBase* parent,CWindowGc& aGc);
sl@0
   121
	void Activate();
sl@0
   122
	void Redraw(const TRect& aRect);
sl@0
   123
protected:
sl@0
   124
	TBool isActive;
sl@0
   125
	};
sl@0
   126
sl@0
   127
class CTRedrawOrderWindow : public CTWin
sl@0
   128
	{
sl@0
   129
public:
sl@0
   130
	CTRedrawOrderWindow(TInt aOrder, CTRedrawTest *aTest);
sl@0
   131
	static CTRedrawOrderWindow* NewLC(TInt aOrder,CTWinBase* aParent,const TPoint& aPos,const TSize& aSize,CTRedrawTest* aTest);
sl@0
   132
	inline static TInt RedrawNumber() {return iRedrawNumber;}
sl@0
   133
	static void ResetRedrawNumber();
sl@0
   134
	void Redraw(const TRect& aRect);
sl@0
   135
	void Draw();
sl@0
   136
private:
sl@0
   137
	CTRedrawTest* iTest;
sl@0
   138
	TInt iOrder;
sl@0
   139
	static TInt iRedrawNumber;
sl@0
   140
	};
sl@0
   141
sl@0
   142
class CTCheckDefectWin : public CBasicWin
sl@0
   143
	{
sl@0
   144
public:
sl@0
   145
	static CTCheckDefectWin *NewL(TPoint aPos,TSize aWinSize);
sl@0
   146
private:
sl@0
   147
	CTCheckDefectWin(){}
sl@0
   148
	};
sl@0
   149
sl@0
   150
class CInvalidRegionChecker : public CBase
sl@0
   151
	{
sl@0
   152
public:
sl@0
   153
	CInvalidRegionChecker(const CTRedrawTest& aGraphicsTest);
sl@0
   154
	~CInvalidRegionChecker();
sl@0
   155
	
sl@0
   156
	TInt CheckInvalidRegions(const CTWindowGroup* aGroup);	
sl@0
   157
	TBool ExcludedWindow(const CTWinBase* aTWinBase) const;	
sl@0
   158
	TInt AddExcludedWindow(const CTWinBase* aExcludedWindow);
sl@0
   159
	void RemoveExcludedWindow(const CTWinBase* aExcludedWindow);
sl@0
   160
private:
sl@0
   161
	void ProcessWindowGroup(const CTWinBase* aTWinBase);
sl@0
   162
	void ProcessChildWindow(const CTWinBase* aTWinBase);
sl@0
   163
	void ProcessWindow(const CTWinBase* aTWinBase);
sl@0
   164
private:
sl@0
   165
	TInt iInvalidRegionCount;
sl@0
   166
	RPointerArray<const CTWinBase> iExcludedWindowArray;
sl@0
   167
	const CTRedrawTest& iGraphicsTest;
sl@0
   168
	};
sl@0
   169
sl@0
   170
class CTRedrawTest : public CTWsGraphicsBase
sl@0
   171
	{
sl@0
   172
public:
sl@0
   173
	CTRedrawTest(CTestStep* aStep);
sl@0
   174
	~CTRedrawTest();
sl@0
   175
	void doDestruct();
sl@0
   176
	void ConstructL();
sl@0
   177
	void CheckRedrawWindows();
sl@0
   178
	void ProcessBaseInvalidate();
sl@0
   179
	void SetBackground(const TRgb& aRgb);
sl@0
   180
	void DumpRegion(const TRegion& aRegion);
sl@0
   181
	inline TInt WinContent();
sl@0
   182
	void InvalidateTestWins(const TRect& aRect);
sl@0
   183
	void MoveInvalidAreaL();
sl@0
   184
	void TestGetInvalidRegionL(const CArrayFixFlat<TRect>* aRectList);
sl@0
   185
	void GetInvalidRegionTestsL();
sl@0
   186
	void CompareRegionsL(const TRegion& aRegion1,const TRegion& aRegion2);
sl@0
   187
	void Failed(TInt aOrder);
sl@0
   188
	void CheckOrderL();
sl@0
   189
	void TestRect();
sl@0
   190
	void CheckDefectINC049554L();
sl@0
   191
	void CheckDefectPDEF099892L();
sl@0
   192
	void CheckOrdinalPositionDefectL();
sl@0
   193
	void CheckDefectPDEF117784L();
sl@0
   194
	void CheckMMSDefectL(TBool aMoveBlankWindow);
sl@0
   195
	void ConstructAndSetBlankWinLC(RBlankWindow& aWindow, TSize aSize, TPoint aPoint=TPoint(),
sl@0
   196
						   TRgb aBackgroundColor=TRgb(0,0,0));
sl@0
   197
	void ConstructWindowLC(RWindow& aWindow, TSize aSize, TPoint aPoint=TPoint(),
sl@0
   198
						   TRgb aBackgroundColor=TRgb(255,255,255), TBool aTransparencyByAlpha=EFalse,
sl@0
   199
						   TDisplayMode aDisplayMode=EColor64K);
sl@0
   200
	void ActivateAndSetGc(CWindowGc& aGc, RWindow& aWindow, CGraphicsContext::TBrushStyle aBrushStyle=CGraphicsContext::ESolidBrush, TRgb aBrushColor=TRgb(0,0,0),
sl@0
   201
						  		CGraphicsContext::TPenStyle aPenStyle=CGraphicsContext::ENullPen, TRgb aPenColor=TRgb(0,0,0));
sl@0
   202
	void DrawWin(CWindowGc& aGc, RWindow& aWin, TSize winSize, TRgb aRectColor1, TRgb aRectColor2, TInt aNewOrdinalPos=0, RWindow* aWinToMove=NULL, TBool aDrawAllPixels=EFalse);
sl@0
   203
	enum TRedrawCheckType
sl@0
   204
		{
sl@0
   205
		ECheckRedrawActiveObjectOnly,
sl@0
   206
		ECheckRedrawActiveObjectAndInvalidRegions	
sl@0
   207
		};
sl@0
   208
	TInt WaitForRedrawsToFinish(TRedrawCheckType aRedrawCheckType);
sl@0
   209
protected:
sl@0
   210
//from 	CTGraphicsStep
sl@0
   211
	virtual void RunTestCaseL(TInt aCurTestCase);
sl@0
   212
private:
sl@0
   213
	void ValidateAndClear(TestWindow *aWin);
sl@0
   214
private:
sl@0
   215
	TSize iWinSize;
sl@0
   216
	TBool iDoCheck;
sl@0
   217
	TInt iRedrawNo;
sl@0
   218
	CReferenceComparisonRedrawWindow *iBaseRedrawWin;
sl@0
   219
	CRedrawWindow2 *iTestRedrawWin;
sl@0
   220
	CBlankWindow *iBaseChildWin;
sl@0
   221
	CBlankWindow *iTestChildWin;
sl@0
   222
	TInt iDrawRequestsFromTestWindow;
sl@0
   223
	TInt iWinContent;
sl@0
   224
	CInvalidRegionChecker *iInvalidRegionChecker;
sl@0
   225
	};
sl@0
   226
sl@0
   227
class CTRedrawTestStep : public CTGraphicsStep
sl@0
   228
	{
sl@0
   229
public:
sl@0
   230
	CTRedrawTestStep();
sl@0
   231
protected:	
sl@0
   232
	//from CTGraphicsStep
sl@0
   233
	virtual CTGraphicsBase* CreateTestL();
sl@0
   234
	};
sl@0
   235
sl@0
   236
_LIT(KTRedrawTestStep,"TRedrawTest");
sl@0
   237
sl@0
   238
sl@0
   239
#endif