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