|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // twsgcetestwinbase.h |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef TWSDYNAMICRESWINBASE_H_ |
|
19 #define TWSDYNAMICRESWINBASE_H_ |
|
20 |
|
21 #include <gdi.h> |
|
22 #include <test/tefunit.h> |
|
23 #include <w32std.h> |
|
24 #include <w32debug.h> |
|
25 #include "wsgcedebugsession.h" |
|
26 struct TWsDebugWindowId; |
|
27 |
|
28 /** |
|
29 * Base class sets up the tryptich of test windows. |
|
30 * |
|
31 * |
|
32 **/ |
|
33 class CWsDynamicResWinBase : public CTestFixture |
|
34 { |
|
35 public: |
|
36 CWsDynamicResWinBase(); |
|
37 virtual ~CWsDynamicResWinBase(); |
|
38 virtual void SetupL(); |
|
39 virtual void SetupL(TBool aUseOtherScreenForInfo); |
|
40 |
|
41 virtual void TearDownL(); |
|
42 virtual void TearDownFromDeleteL(); |
|
43 |
|
44 static TBool ActivateWithWipe(CWindowGc* aGc,RWindow& aWin,TRgb aColor=TRgb(0,0)); |
|
45 |
|
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 ); |
|
49 */ |
|
50 |
|
51 protected: |
|
52 static void Pause(TInt aMilliseconds=200); |
|
53 |
|
54 TBool GCEIsSupported() const; |
|
55 static TBool GCEIsSupportedStatic(); |
|
56 |
|
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') |
|
78 **/ |
|
79 static TRect PentCellRect(const TRect& aFullRect,char aStartLetter,char aEndLetter=0); |
|
80 void CheckAndConnectScreen(); |
|
81 |
|
82 protected: |
|
83 static const TInt KSurfaceWidth = 50; |
|
84 static const TInt KSurfaceHeight = 50; |
|
85 TBool iDoTearDown; |
|
86 RWsDebugSession iSession; |
|
87 RWindowGroup iGroup; |
|
88 RWindowGroup iInfoGroupInstance; |
|
89 RWindowGroup* iInfoGroup; |
|
90 CWsScreenDevice* iScreenDevice; |
|
91 CWsScreenDevice* iInfoScreenDevice; |
|
92 CWindowGc* iGc; |
|
93 CWindowGc* iInfoGc; |
|
94 TInt iWindowHandle; |
|
95 static TBool iTransparencyEnabled; |
|
96 TRgb iRed, iGreen, iBlue, iCyan, iMagenta, iYellow, iWhite; |
|
97 TRgb TITLE_BACKGROUND; |
|
98 TRgb COMPARE_BACKGROUND; |
|
99 RBlankWindow iBackground; |
|
100 RWindow iCompare; |
|
101 RWindow iTitle; |
|
102 TRect iTestPos; |
|
103 TRect iCenteredFrontWinRect; |
|
104 TPoint iTestPointCentre; |
|
105 TDisplayMode iDisplayMode; |
|
106 static const TInt KMaxTestName = 80; |
|
107 typedef TBuf<KMaxTestName> TTestName; |
|
108 mutable TRgb iLastGceHoleColor; |
|
109 TTestName iTestName; |
|
110 static const TInt KMaxInfoLines=5; |
|
111 TTestName iTestInfo[KMaxInfoLines]; |
|
112 static CActiveScheduler iScheduler; |
|
113 }; |
|
114 |
|
115 // This little helper class checks that the given bytes contain the expected pattern. |
|
116 namespace Pattern |
|
117 { |
|
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); |
|
121 } |
|
122 |
|
123 //This wrapper for the configuration class allows stress testing of the configuration object |
|
124 |
|
125 template <class TXxxConfiguration,TInt aExtraSize,TInt aFalseSize> |
|
126 class TestExtend: public TXxxConfiguration |
|
127 { |
|
128 public: |
|
129 char iExtraData[aExtraSize]; |
|
130 TestExtend(): |
|
131 TXxxConfiguration(aFalseSize) |
|
132 { |
|
133 TXxxConfiguration::iSize=aFalseSize; |
|
134 Pattern::Fill(this,aFalseSize,sizeof(*this)-aFalseSize); |
|
135 } |
|
136 void* operator new(unsigned int,TestExtend* inplace) |
|
137 { //Use this inplace operator new to pre-initialise the memory |
|
138 return inplace; |
|
139 } |
|
140 void operator delete(void*,TestExtend*) |
|
141 { //Stops the warning! |
|
142 } |
|
143 TestExtend(const TXxxConfiguration&i): |
|
144 TXxxConfiguration(i) |
|
145 { |
|
146 Pattern::Check(this,sizeof(TXxxConfiguration),aExtraSize); |
|
147 } |
|
148 TBool WasExtraOverwritten() |
|
149 { |
|
150 return Pattern::Check(this,sizeof(TXxxConfiguration),aExtraSize); |
|
151 } |
|
152 TBool WasFalseSizeOverwritten() |
|
153 { |
|
154 return Pattern::Check(this,aFalseSize,sizeof(*this)-aFalseSize); |
|
155 } |
|
156 TBool WasFalseSizeZero() |
|
157 { |
|
158 return Pattern::CheckVal(this,aFalseSize,sizeof(TXxxConfiguration)-aFalseSize); |
|
159 } |
|
160 void StompValue(TInt aOffsetInLongs,TInt aNewValue) |
|
161 { |
|
162 *((TInt*)this+aOffsetInLongs)=aNewValue; |
|
163 } |
|
164 TInt ReadValue(TInt aOffsetInLongs) |
|
165 { |
|
166 return *((TInt*)this+aOffsetInLongs); |
|
167 } |
|
168 }; |
|
169 #endif /*TWSDYNAMICRESWINBASE_H_*/ |