os/graphics/graphicsdeviceinterface/bitgdi/tbit/toutlineandshadowfonts.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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".
     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 __T_OUTLINEANDSHADOWFONTS_H__
    23 #define __T_OUTLINEANDSHADOWFONTS_H__
    24 
    25 #include "TGraphicsHarness.h"
    26 #include <hash.h>
    27 #include <test/tefunit.h>
    28 #include <test/thashreferenceimages.h>
    29 
    30 #define KDefaultOutlinePenColor KRgbBlack
    31 #define KDefaultShadowColor KRgbGray
    32 #define KDefaultFillColor KRgbWhite
    33 
    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
    38 
    39 const TInt KInvalidBitmapType = -10; //Used in negative test to set invalid glyph bitmap type
    40 const TInt KHeight = 30; //Font height
    41 
    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
    47 
    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");
    52 
    53 //List of typefaces
    54 const TInt KNumOfFontFaces = 3;
    55 const TPtrC KFontFace[KNumOfFontFaces] = 
    56 	{
    57 	_L("DejaVu Sans Condensed"),
    58 	_L("DejaVu Sans Mono"),
    59 	_L("DejaVu Serif Condensed")
    60 	};
    61 // A short name (no spaces) version of KFontFace used for filenames and hash indexes.
    62 const TPtrC KFontFaceShortName[KNumOfFontFaces] = 
    63 	{
    64 	_L("DVSans"),
    65 	_L("DVMono"),
    66 	_L("DVSerif")
    67 	};
    68 
    69 // List of display modes. Used in INFO_PRINTF's
    70 const TInt KNumOfDisplayModes = 12;
    71 const TPtrC KDisplayModeNames[KNumOfDisplayModes] = 
    72 	{
    73 	_L("EGray2"),
    74 	_L("EGray4"),
    75 	_L("EGray16"),
    76 	_L("EGray256"),
    77 	_L("EColor16"),
    78 	_L("EColor256"),
    79 	_L("EColor64K"),
    80 	_L("EColor16M"),
    81 	_L("EColor4K"),
    82 	_L("EColor16MU"),
    83 	_L("EColor16MA"),
    84 	_L("EColor16MAP"),
    85 	};
    86 
    87 //List of display modes used for creating screen devices
    88 const TDisplayMode KDisplayModes[KNumOfDisplayModes] = 
    89 	{
    90 	EGray2,
    91 	EGray4,
    92 	EGray16,
    93 	EGray256,
    94 	EColor16,
    95 	EColor256,
    96 	EColor64K,
    97 	EColor16M,
    98 	EColor4K,
    99 	EColor16MU,
   100 	EColor16MA,
   101 	EColor16MAP,
   102  	};
   103 
   104 /**	
   105 Enumeration for the attributes to be set in fontspec and gc.
   106 See CTOutlineAndShadowFonts::PrepareTestEnvironment()
   107 */
   108 enum TFontEffectsFlags
   109 	{
   110 	EDropShadowOn = 0x1,
   111 	EOutlineOn = 0x2,
   112 	ESetMonochromeGlyphBitmap  = 0x4,
   113 	ESetAntiAliasedGlyphBitmap = 0x8,
   114 	ESetFourColourBlendGlyphBitmap = 0x10,
   115 	EVerticalDraw = 0x20,
   116 	ERotate90Degrees = 0x40,
   117 	EIsStrikethroughOn = 0x80,
   118 	EIsUnderlineOn = 0x100,
   119 	ESoftEdgeOn = 0x200,
   120 	EAlgorithmicBoldOn = 0x400
   121 	};
   122 
   123 /**
   124 Structure to hold the flags of the attributes in fontspec and gc to be enabled.
   125 */
   126 typedef struct
   127 	{
   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;
   134 
   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}};
   146 
   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] =
   153 	{
   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},
   164 
   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},
   186 	
   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)}
   194 	};
   195 
   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] =
   202 	{
   203 	{EDropShadowOn | EOutlineOn | EIsStrikethroughOn | ESetAntiAliasedGlyphBitmap},
   204 	{EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap},
   205 	{EAlgorithmicBoldOn | ESoftEdgeOn | EIsUnderlineOn | ESetAntiAliasedGlyphBitmap},
   206 	{ESetAntiAliasedGlyphBitmap}
   207 	};
   208 
   209 //Structure to store bitmap device and font, can be used to clean in case of a leave
   210 //See CleanUpFont()
   211 typedef struct
   212 	{
   213 	CBitmapDevice* device;
   214 	CFont* font;
   215 	} SCleanFont;
   216 
   217 class CTOutlineAndShadowFontsStep : public CTGraphicsStep
   218 	{
   219 public:
   220 	CTOutlineAndShadowFontsStep();
   221 protected:
   222 	virtual CTGraphicsBase* CreateTestL();
   223 	};
   224 
   225 /**
   226  Class defines all the API's which are used to test outline and shadow effects
   227  */
   228 class CTOutlineAndShadowFonts : public CTGraphicsBase
   229 	{
   230 public:
   231 	CTOutlineAndShadowFonts(CTestStep* aStep);
   232 	virtual ~CTOutlineAndShadowFonts();
   233 private:
   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();
   249 	void TestOOML();
   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);
   257 protected:
   258 	virtual void RunTestCaseL(TInt aCurTestCase);
   259 	virtual void ConstructL();
   260 private:
   261 	CFbsBitGc* iGc;
   262 	CFbsDevice* iBitmapDevice;
   263 	RFbsSession* iFbs;
   264 	CFbsBitmap* iBitmap;
   265 	CTestStep* iStep;
   266 	CTHashReferenceImages *iHashUtil;
   267 	};
   268 
   269 _LIT(KTOutlineAndShadowFontsStep,"TOutlineAndShadowFonts");
   270 #endif