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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // twsgcetestwinbase.h
18 #ifndef TWSDYNAMICRESWINBASE_H_
19 #define TWSDYNAMICRESWINBASE_H_
22 #include <test/tefunit.h>
25 #include "wsgcedebugsession.h"
26 struct TWsDebugWindowId;
29 * Base class sets up the tryptich of test windows.
33 class CWsDynamicResWinBase : public CTestFixture
36 CWsDynamicResWinBase();
37 virtual ~CWsDynamicResWinBase();
38 virtual void SetupL();
39 virtual void SetupL(TBool aUseOtherScreenForInfo);
41 virtual void TearDownL();
42 virtual void TearDownFromDeleteL();
44 static TBool ActivateWithWipe(CWindowGc* aGc,RWindow& aWin,TRgb aColor=TRgb(0,0));
46 /* Note that each derived test class needs to declare a static function to register tests.
47 * This should match the following prototype:
48 static CTestSuite* CreateSuiteL( const TDesC& aName );
52 static void Pause(TInt aMilliseconds=200);
54 TBool GCEIsSupported() const;
55 static TBool GCEIsSupportedStatic();
57 TBool DisplayHasAlpha() const;
58 TBool SelectChromaCompositionMode();
59 TBool SelectAlphaCompositionMode(TDisplayMode aMode = EColor16MA);
60 TRgb GceHoleColor(RWindowBase& aWin)const;
61 void DrawUIContent(RWindow& aWindow);
62 void DrawPlainUI(RWindow& aWindow,TBool aInvalidate,TRgb aWipeColor=TRgb(0,0));
63 void DrawCross(RWindow& aWindow, TRgb aColor, TInt aThickness=1);
64 void TestPixelL(TPoint aPt, TRgb aColor, TBool aMatch);
65 TBool TestRectL(TRect aRect,TRgb aInnerColor,TInt aOtherInnerColors,TRgb aOuterColor,TInt aOtherOuterColors,TInt aCornerSize);
66 void MakeTitleAndCompareWindowsL(TRefByValue<const TDesC16> aTitle,TRefByValue<const TDesC16> aDetail=_L(""));
67 void LargerCompareWindow(TBool aGoLarger=ETrue);
68 void UpdateTitleWindowL(TRefByValue<const TDesC16> aDetail,TInt aIndex=0);
69 void RepaintTitleWindowL();
70 void TefUnitFailLeaveL();
71 CWindowGc* GcForWindow(RWindow& aWin);
72 TBool InvalidateRegion(const TRegion& aRegion,RWindow& aWin);
73 CWindowGc* BeginActivateWithWipe(TBool aInvalidate,RWindow& aWin,TRgb aColor=TRgb(0,0));
74 CWindowGc* BeginActivateWithWipe(TBool aInvalidate,TRect aRect,RWindow& aWin,TRgb aColor=TRgb(0,0));
75 CWindowGc* BeginActivateWithWipe(const TRegion& aRegion,RWindow& aWin,TRgb aColor);
76 /** Helper method to find a named screen region
77 * start/end letter should be 'a' to 'y' (yes that includes 'i')
79 static TRect PentCellRect(const TRect& aFullRect,char aStartLetter,char aEndLetter=0);
80 void CheckAndConnectScreen();
83 static const TInt KSurfaceWidth = 50;
84 static const TInt KSurfaceHeight = 50;
86 RWsDebugSession iSession;
88 RWindowGroup iInfoGroupInstance;
89 RWindowGroup* iInfoGroup;
90 CWsScreenDevice* iScreenDevice;
91 CWsScreenDevice* iInfoScreenDevice;
95 static TBool iTransparencyEnabled;
96 TRgb iRed, iGreen, iBlue, iCyan, iMagenta, iYellow, iWhite;
97 TRgb TITLE_BACKGROUND;
98 TRgb COMPARE_BACKGROUND;
99 RBlankWindow iBackground;
103 TRect iCenteredFrontWinRect;
104 TPoint iTestPointCentre;
105 TDisplayMode iDisplayMode;
106 static const TInt KMaxTestName = 80;
107 typedef TBuf<KMaxTestName> TTestName;
108 mutable TRgb iLastGceHoleColor;
110 static const TInt KMaxInfoLines=5;
111 TTestName iTestInfo[KMaxInfoLines];
112 static CActiveScheduler iScheduler;
115 // This little helper class checks that the given bytes contain the expected pattern.
118 void Fill(void* aTrg,TInt aOffset,TInt aLength);
119 TBool Check(void* aTrg,TInt aOffset,TInt aLength);
120 TBool CheckVal(void* aTrg,TInt aOffset,TInt aLength,char val=0);
123 //This wrapper for the configuration class allows stress testing of the configuration object
125 template <class TXxxConfiguration,TInt aExtraSize,TInt aFalseSize>
126 class TestExtend: public TXxxConfiguration
129 char iExtraData[aExtraSize];
131 TXxxConfiguration(aFalseSize)
133 TXxxConfiguration::iSize=aFalseSize;
134 Pattern::Fill(this,aFalseSize,sizeof(*this)-aFalseSize);
136 void* operator new(unsigned int,TestExtend* inplace)
137 { //Use this inplace operator new to pre-initialise the memory
140 void operator delete(void*,TestExtend*)
141 { //Stops the warning!
143 TestExtend(const TXxxConfiguration&i):
146 Pattern::Check(this,sizeof(TXxxConfiguration),aExtraSize);
148 TBool WasExtraOverwritten()
150 return Pattern::Check(this,sizeof(TXxxConfiguration),aExtraSize);
152 TBool WasFalseSizeOverwritten()
154 return Pattern::Check(this,aFalseSize,sizeof(*this)-aFalseSize);
156 TBool WasFalseSizeZero()
158 return Pattern::CheckVal(this,aFalseSize,sizeof(TXxxConfiguration)-aFalseSize);
160 void StompValue(TInt aOffsetInLongs,TInt aNewValue)
162 *((TInt*)this+aOffsetInLongs)=aNewValue;
164 TInt ReadValue(TInt aOffsetInLongs)
166 return *((TInt*)this+aOffsetInLongs);
169 #endif /*TWSDYNAMICRESWINBASE_H_*/