First public contribution.
1 // Copyright (c) 2006-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.
19 @internalComponent - Internal Symbian test code
22 #ifndef __T_OUTLINEANDSHADOWFONTS_H__
23 #define __T_OUTLINEANDSHADOWFONTS_H__
25 #include "TGraphicsHarness.h"
27 #include <test/tefunit.h>
28 #include <test/thashreferenceimages.h>
30 #define KDefaultOutlinePenColor KRgbBlack
31 #define KDefaultShadowColor KRgbGray
32 #define KDefaultFillColor KRgbWhite
34 //Considering the intersection of the screen size for both hw and emulator so that same
35 //baselined hash can be used to test for both
36 #define KScreenWidth 320
37 #define KScreenHeight 240
39 const TInt KInvalidBitmapType = -10; //Used in negative test to set invalid glyph bitmap type
40 const TInt KHeight = 30; //Font height
42 // These are used in pixel spacing
43 const TInt KDifferByThree = 3; // Spacing 1, 2 and 3 are acceptable
44 const TInt KDifferByTwo = 2;
45 const TInt KDifferByOne = 1;
46 const TPoint KPoint = TPoint(10,20); // Point passed as argument to DrawText
48 //Format for generating hash id
49 _LIT(KHashIDFormat, "%S_%d_%S_%S_%d");
50 const TInt KLengthOfHashValue = 256;
51 _LIT(KTextPhrase, "ShAdOW OUtLine * $ 1234");
54 const TInt KNumOfFontFaces = 3;
55 const TPtrC KFontFace[KNumOfFontFaces] =
57 _L("DejaVu Sans Condensed"),
58 _L("DejaVu Sans Mono"),
59 _L("DejaVu Serif Condensed")
61 // A short name (no spaces) version of KFontFace used for filenames and hash indexes.
62 const TPtrC KFontFaceShortName[KNumOfFontFaces] =
69 // List of display modes. Used in INFO_PRINTF's
70 const TInt KNumOfDisplayModes = 12;
71 const TPtrC KDisplayModeNames[KNumOfDisplayModes] =
87 //List of display modes used for creating screen devices
88 const TDisplayMode KDisplayModes[KNumOfDisplayModes] =
105 Enumeration for the attributes to be set in fontspec and gc.
106 See CTOutlineAndShadowFonts::PrepareTestEnvironment()
108 enum TFontEffectsFlags
112 ESetMonochromeGlyphBitmap = 0x4,
113 ESetAntiAliasedGlyphBitmap = 0x8,
114 ESetFourColourBlendGlyphBitmap = 0x10,
115 EVerticalDraw = 0x20,
116 ERotate90Degrees = 0x40,
117 EIsStrikethroughOn = 0x80,
118 EIsUnderlineOn = 0x100,
120 EAlgorithmicBoldOn = 0x400
124 Structure to hold the flags of the attributes in fontspec and gc to be enabled.
128 TUint32 fSpecAndGcSettings; //flags/effects in gc and fontspec to be enabled
129 TRgb brushColor; //brush colour will set the colour of the fill of the font
130 TRgb penColor; //pen colour which will set the colour of the outline
131 TRgb shadowColor; //shadow colour which will set the colour of the shadow
132 TRgb backgroundColor; //colour of the target that the text is rendered onto
133 } STestFontParameters;
135 // Test setting for TestOutlineandShadowFontsMetricsL() i.e. for test case 8
136 // All the test case conditions are defined here and are called to test font metrics
137 // STestFontParameters Format: outline | shadow | bitmaptype, BrushColor, PenColor, ShadowColor
138 const TInt KNumberOfSubTestsInTest0008 = 6;
139 const STestFontParameters KTestSettingsToTestFontMetrics[KNumberOfSubTestsInTest0008] =
140 {{ESetMonochromeGlyphBitmap},
141 {EOutlineOn | ESetMonochromeGlyphBitmap},
142 {EOutlineOn | ESetAntiAliasedGlyphBitmap},
143 {EDropShadowOn | ESetAntiAliasedGlyphBitmap},
144 {EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap},
145 {EAntiAliasedGlyphBitmap}};
147 // Test setting for TestDrawTextWithOutlineAndShadowL() i.e. for test case 10
148 // All test case conditions are defined here and are called to test outline and shadow effects
149 // STestFontParameters Format: outline | shadow | bitmaptype, BrushColor, PenColor, ShadowColor, BackgroundColor
150 const TInt KNumberOfSubTestsInTest0010 = 35;
151 _LIT(KTestName0010, "OutlineShadowWithDrawTextNormalAndVertical");//test case name to used to generate test case id
152 const STestFontParameters KTestSettingsToTestOutlineAndShadow[KNumberOfSubTestsInTest0010] =
154 // test with EMonochromeGlyphBitmap and alpha value 255
155 {EDropShadowOn | ESetMonochromeGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
156 {EOutlineOn | ESetMonochromeGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
157 {EDropShadowOn | EOutlineOn | ESetMonochromeGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
158 {EDropShadowOn | ESetMonochromeGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
159 {EOutlineOn | ESetMonochromeGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
160 {EDropShadowOn | EOutlineOn | ESetMonochromeGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
161 {EDropShadowOn | ESetMonochromeGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
162 {EOutlineOn | ESetMonochromeGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
163 {EDropShadowOn | EOutlineOn | ESetMonochromeGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
165 // test with EAntiAliasedGlyphBitmap and alpha value 255
166 {EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
167 {EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
168 {EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
169 {EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
170 {EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
171 {EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
172 {EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbBlue, KRgbBlack, KRgbYellow, KRgbWhite},
173 {EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbBlue, KRgbBlack, KRgbYellow, KRgbWhite},
174 {EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbBlue, KRgbBlack, KRgbYellow, KRgbWhite},
175 {EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbBlue, KRgbBlack, KRgbYellow, KRgbWhite},
176 {EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbBlue, KRgbBlack, KRgbYellow, KRgbWhite},
177 {EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbBlue, KRgbBlack, KRgbYellow, KRgbWhite},
178 {EDropShadowOn | ESetAntiAliasedGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
179 {EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
180 {EDropShadowOn |EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
181 {EDropShadowOn | ESetAntiAliasedGlyphBitmap, KRgbBlue, KRgbGreen, KRgbYellow, KRgbWhite},
182 {EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbBlue, KRgbGreen, KRgbYellow, KRgbWhite},
183 {EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbBlue, KRgbGreen, KRgbYellow, KRgbWhite},
184 {ESetAntiAliasedGlyphBitmap, KRgbBlue, KRgbGreen, KRgbYellow, KRgbWhite},
185 {ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbBlue, KRgbGreen, KRgbYellow, KRgbWhite},
187 // test with EAntiAliasedGlyphBitmap and alpha value < 255 (transparency)
188 {EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbBlue, TRgb(128,255,100,0), KRgbMagenta, KRgbWhite},
189 {EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbGreen, TRgb(128,200,100,32), KRgbYellow, KRgbWhite},
190 {EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbYellow, TRgb(100,200,100,64), KRgbGray, KRgbWhite},
191 {EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbWhite, TRgb(128,200,50,128), KRgbYellow, KRgbWhite},
192 {EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbBlack, TRgb(12,20,50,255), KRgbWhite, KRgbWhite},
193 {EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbGreen, TRgb(255,0,0,127), KRgbYellow, TRgb(127, 127, 127, 0)}
196 // Test setting for TestDrawTextWithStrikeThroughL() i.e. for test case 11
197 // All test case conditions are defined here and are called to test outline and shadow with strikethrough and underline effects.
198 // STestFontParameters Format: outline | shadow | bitmaptype | strikethroughon | underlineon, BrushColor, PenColor, ShadowColor
199 const TInt KNumberOfSubTestsInTest0011 = 4;
200 _LIT(KTestName0011, "OutlineShadowWithStrikeThroughBoldAndUnderline");//test case name to used to generate test case id
201 const STestFontParameters KTestSettingsToTestStrikeAndUnderline[KNumberOfSubTestsInTest0011] =
203 {EDropShadowOn | EOutlineOn | EIsStrikethroughOn | ESetAntiAliasedGlyphBitmap},
204 {EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap},
205 {EAlgorithmicBoldOn | ESoftEdgeOn | EIsUnderlineOn | ESetAntiAliasedGlyphBitmap},
206 {ESetAntiAliasedGlyphBitmap}
209 //Structure to store bitmap device and font, can be used to clean in case of a leave
213 CBitmapDevice* device;
217 class CTOutlineAndShadowFontsStep : public CTGraphicsStep
220 CTOutlineAndShadowFontsStep();
222 virtual CTGraphicsBase* CreateTestL();
226 Class defines all the API's which are used to test outline and shadow effects
228 class CTOutlineAndShadowFonts : public CTGraphicsBase
231 CTOutlineAndShadowFonts(CTestStep* aStep);
232 virtual ~CTOutlineAndShadowFonts();
234 void DoOutlinePenAndShadowColor();
235 void DoOutlineandShadowFontsL();
236 void DoOOM(TInt aFontIndex, TBool aVerticalText);
237 void DoDrawTextWithOutlineAndShadowL(const STestFontParameters &aSettings, const TDesC& aHashIdString, const TInt aFontIndex);
238 void DoOutlineandShadowFontsMetrics(const STestFontParameters &aSettings, TInt aFontIndex);
239 void GetFontAndDrawOOM(TFontSpec aFontSpec, TBool aVerticalText);
240 void DoSetStrikeThroughAndDrawTestL(const STestFontParameters &aSettings, const TDesC& aHashIdString);
241 void CreateScreenDeviceL(TDisplayMode aMode);
242 void FreeScreenDevice();
243 void SetScreenMode(TDisplayMode aScreen);
244 void TestOutlineandShadowFontsMetricsL();
245 void TestOutlinePenAndShadowColorL();
246 void TestDrawTextWithOutlineAndShadowL();
247 void TestDrawTextWithStrikeThroughL();
248 void TestCheckBitmapTypesL();
250 void TestAntiAliasedOrMonochromeGlyphBitmapL();
251 void NegativeRastTestL();
252 void NegativeRastTestDrawText(const TFontSpec &aFontSpec);
253 void PrepareTestEnvironment(TFontSpec &aFontSpec, const STestFontParameters &aSettings, const TInt aFontIndex, TBool aSetEffects = ETrue, TBool aSetColors = EFalse);
254 TBool CheckMonoTypeInstalledL();
255 TBool TestRange(TInt aMin, TInt aValue, TInt aMax);
256 TBool TestLessThanOrEqual(TInt aValue, TInt aMax);
258 virtual void RunTestCaseL(TInt aCurTestCase);
259 virtual void ConstructL();
262 CFbsDevice* iBitmapDevice;
266 CTHashReferenceImages *iHashUtil;
269 _LIT(KTOutlineAndShadowFontsStep,"TOutlineAndShadowFonts");