graphicsdeviceinterface/bitgdi/tbit/toutlineandshadowfonts.h
changeset 0 5d03bc08d59c
child 70 5e51caaeeb72
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     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 	} STestFontParameters;
       
   133 
       
   134 // Test setting for TestOutlineandShadowFontsMetricsL() i.e. for test case 8
       
   135 // All the test case conditions are defined here and are called to test font metrics
       
   136 // STestFontParameters Format: outline | shadow | bitmaptype, BrushColor, PenColor, ShadowColor
       
   137 const TInt KNumberOfSubTestsInTest0008 = 6;
       
   138 const STestFontParameters KTestSettingsToTestFontMetrics[KNumberOfSubTestsInTest0008] =
       
   139 	{{ESetMonochromeGlyphBitmap},
       
   140 	{EOutlineOn | ESetMonochromeGlyphBitmap},
       
   141 	{EOutlineOn | ESetAntiAliasedGlyphBitmap},
       
   142 	{EDropShadowOn | ESetAntiAliasedGlyphBitmap},
       
   143 	{EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap},
       
   144 	{EAntiAliasedGlyphBitmap}};
       
   145 
       
   146 // Test setting for TestDrawTextWithOutlineAndShadowL() i.e. for test case 10
       
   147 // All test case conditions are defined here and are called to test outline and shadow effects
       
   148 // STestFontParameters Format: outline | shadow | bitmaptype, BrushColor, PenColor, ShadowColor
       
   149 const TInt KNumberOfSubTestsInTest0010 = 34;
       
   150 _LIT(KTestName0010, "OutlineShadowWithDrawTextNormalAndVertical");//test case name to used to generate test case id
       
   151 const STestFontParameters KTestSettingsToTestOutlineAndShadow[KNumberOfSubTestsInTest0010] =
       
   152 	{
       
   153 	// test with EMonochromeGlyphBitmap and alpha value 255
       
   154 	{EDropShadowOn | ESetMonochromeGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue},
       
   155 	{EOutlineOn | ESetMonochromeGlyphBitmap |  EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue},
       
   156 	{EDropShadowOn | EOutlineOn | ESetMonochromeGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue},
       
   157 	{EDropShadowOn | ESetMonochromeGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue},
       
   158 	{EOutlineOn | ESetMonochromeGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue},
       
   159 	{EDropShadowOn | EOutlineOn | ESetMonochromeGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue},
       
   160 	{EDropShadowOn | ESetMonochromeGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue},
       
   161 	{EOutlineOn | ESetMonochromeGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue},
       
   162 	{EDropShadowOn | EOutlineOn | ESetMonochromeGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue},
       
   163 
       
   164 	// test with EAntiAliasedGlyphBitmap and alpha value 255
       
   165 	{EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue},
       
   166 	{EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue},
       
   167 	{EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue},
       
   168 	{EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue},
       
   169 	{EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue},
       
   170 	{EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue},
       
   171 	{EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbBlue, KRgbBlack, KRgbYellow},
       
   172 	{EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbBlue, KRgbBlack, KRgbYellow},
       
   173 	{EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbBlue, KRgbBlack, KRgbYellow},
       
   174 	{EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbBlue, KRgbBlack, KRgbYellow},
       
   175 	{EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbBlue, KRgbBlack, KRgbYellow},
       
   176 	{EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbBlue, KRgbBlack, KRgbYellow},
       
   177 	{EDropShadowOn | ESetAntiAliasedGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue},
       
   178 	{EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue},
       
   179 	{EDropShadowOn |EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue},
       
   180 	{EDropShadowOn | ESetAntiAliasedGlyphBitmap, KRgbBlue, KRgbGreen, KRgbYellow},
       
   181 	{EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbBlue, KRgbGreen, KRgbYellow},
       
   182 	{EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbBlue, KRgbGreen, KRgbYellow},
       
   183 	{ESetAntiAliasedGlyphBitmap, KRgbBlue, KRgbGreen, KRgbYellow},
       
   184 	{ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbBlue, KRgbGreen, KRgbYellow},
       
   185 	
       
   186 	// test with EAntiAliasedGlyphBitmap and alpha value < 255 (transparency)
       
   187 	{EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbBlue, TRgb(128,255,100,0), KRgbMagenta},
       
   188 	{EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbGreen, TRgb(128,200,100,32), KRgbYellow},
       
   189 	{EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbYellow, TRgb(100,200,100,64), KRgbGray},
       
   190 	{EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbWhite, TRgb(128,200,50,128), KRgbYellow},
       
   191 	{EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbBlack, TRgb(12,20,50,255), KRgbWhite}
       
   192 	};
       
   193 
       
   194 // Test setting for TestDrawTextWithStrikeThroughL() i.e. for test case 11
       
   195 // All test case conditions are defined here and are called to test outline and shadow with strikethrough and underline effects.
       
   196 // STestFontParameters Format: outline | shadow | bitmaptype | strikethroughon | underlineon, BrushColor, PenColor, ShadowColor
       
   197 const TInt KNumberOfSubTestsInTest0011 = 4;
       
   198 _LIT(KTestName0011, "OutlineShadowWithStrikeThroughBoldAndUnderline");//test case name to used to generate test case id
       
   199 const STestFontParameters KTestSettingsToTestStrikeAndUnderline[KNumberOfSubTestsInTest0011] =
       
   200 	{
       
   201 	{EDropShadowOn | EOutlineOn | EIsStrikethroughOn | ESetAntiAliasedGlyphBitmap},
       
   202 	{EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap},
       
   203 	{EAlgorithmicBoldOn | ESoftEdgeOn | EIsUnderlineOn | ESetAntiAliasedGlyphBitmap},
       
   204 	{ESetAntiAliasedGlyphBitmap}
       
   205 	};
       
   206 
       
   207 //Structure to store bitmap device and font, can be used to clean in case of a leave
       
   208 //See CleanUpFont()
       
   209 typedef struct
       
   210 	{
       
   211 	CBitmapDevice* device;
       
   212 	CFont* font;
       
   213 	} SCleanFont;
       
   214 
       
   215 class CTOutlineAndShadowFontsStep : public CTGraphicsStep
       
   216 	{
       
   217 public:
       
   218 	CTOutlineAndShadowFontsStep();
       
   219 protected:
       
   220 	virtual CTGraphicsBase* CreateTestL();
       
   221 	};
       
   222 
       
   223 /**
       
   224  Class defines all the API's which are used to test outline and shadow effects
       
   225  */
       
   226 class CTOutlineAndShadowFonts : public CTGraphicsBase
       
   227 	{
       
   228 public:
       
   229 	CTOutlineAndShadowFonts(CTestStep* aStep);
       
   230 	virtual ~CTOutlineAndShadowFonts();
       
   231 private:
       
   232 	void DoOutlinePenAndShadowColor();
       
   233 	void DoOutlineandShadowFontsL();
       
   234 	void DoOOM(TInt aFontIndex, TBool aVerticalText);
       
   235 	void DoDrawTextWithOutlineAndShadowL(const STestFontParameters &aSettings, const TDesC& aHashIdString, const TInt aFontIndex);
       
   236 	void DoOutlineandShadowFontsMetrics(const STestFontParameters &aSettings, TInt aFontIndex);
       
   237 	void GetFontAndDrawOOM(TFontSpec aFontSpec, TBool aVerticalText);
       
   238 	void DoSetStrikeThroughAndDrawTestL(const STestFontParameters &aSettings, const TDesC& aHashIdString);
       
   239 	void CreateScreenDeviceL(TDisplayMode aMode);
       
   240 	void FreeScreenDevice();
       
   241 	void SetScreenMode(TDisplayMode aScreen);
       
   242 	void TestOutlineandShadowFontsMetricsL();
       
   243 	void TestOutlinePenAndShadowColorL();
       
   244 	void TestDrawTextWithOutlineAndShadowL();
       
   245 	void TestDrawTextWithStrikeThroughL();
       
   246 	void TestCheckBitmapTypesL();
       
   247 	void TestOOML();
       
   248 	void TestAntiAliasedOrMonochromeGlyphBitmapL();
       
   249 	void NegativeRastTestL();
       
   250 	void NegativeRastTestDrawText(const TFontSpec &aFontSpec);
       
   251 	void PrepareTestEnvironment(TFontSpec &aFontSpec, const STestFontParameters &aSettings, const TInt aFontIndex, TBool aSetEffects = ETrue, TBool aSetColors = EFalse);
       
   252 	TBool CheckMonoTypeInstalledL();
       
   253 	TBool TestRange(TInt aMin, TInt aValue, TInt aMax);
       
   254 	TBool TestLessThanOrEqual(TInt aValue, TInt aMax);
       
   255 protected:
       
   256 	virtual void RunTestCaseL(TInt aCurTestCase);
       
   257 	virtual void ConstructL();
       
   258 private:
       
   259 	CFbsBitGc* iGc;
       
   260 	CFbsDevice* iBitmapDevice;
       
   261 	RFbsSession* iFbs;
       
   262 	CFbsBitmap* iBitmap;
       
   263 	CTestStep* iStep;
       
   264 	CTHashReferenceImages *iHashUtil;
       
   265 	};
       
   266 
       
   267 _LIT(KTOutlineAndShadowFontsStep,"TOutlineAndShadowFonts");
       
   268 #endif