os/graphics/graphicsdeviceinterface/bitgdi/tbit/toutlineandshadowfonts.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicsdeviceinterface/bitgdi/tbit/toutlineandshadowfonts.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,270 @@
     1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @file
    1.21 + @test
    1.22 + @internalComponent - Internal Symbian test code
    1.23 +*/
    1.24 +
    1.25 +#ifndef __T_OUTLINEANDSHADOWFONTS_H__
    1.26 +#define __T_OUTLINEANDSHADOWFONTS_H__
    1.27 +
    1.28 +#include "TGraphicsHarness.h"
    1.29 +#include <hash.h>
    1.30 +#include <test/tefunit.h>
    1.31 +#include <test/thashreferenceimages.h>
    1.32 +
    1.33 +#define KDefaultOutlinePenColor KRgbBlack
    1.34 +#define KDefaultShadowColor KRgbGray
    1.35 +#define KDefaultFillColor KRgbWhite
    1.36 +
    1.37 +//Considering the intersection of the screen size for both hw and emulator so that same
    1.38 +//baselined hash can be used to test for both
    1.39 +#define	KScreenWidth 320
    1.40 +#define	KScreenHeight 240
    1.41 +
    1.42 +const TInt KInvalidBitmapType = -10; //Used in negative test to set invalid glyph bitmap type
    1.43 +const TInt KHeight = 30; //Font height
    1.44 +
    1.45 +// These are used in pixel spacing
    1.46 +const TInt KDifferByThree = 3; // Spacing 1, 2 and 3 are acceptable
    1.47 +const TInt KDifferByTwo = 2; 
    1.48 +const TInt KDifferByOne = 1;
    1.49 +const TPoint KPoint = TPoint(10,20); // Point passed as argument to DrawText
    1.50 +
    1.51 +//Format for generating hash id
    1.52 +_LIT(KHashIDFormat, "%S_%d_%S_%S_%d");
    1.53 +const TInt KLengthOfHashValue = 256;
    1.54 +_LIT(KTextPhrase, "ShAdOW OUtLine * $ 1234");
    1.55 +
    1.56 +//List of typefaces
    1.57 +const TInt KNumOfFontFaces = 3;
    1.58 +const TPtrC KFontFace[KNumOfFontFaces] = 
    1.59 +	{
    1.60 +	_L("DejaVu Sans Condensed"),
    1.61 +	_L("DejaVu Sans Mono"),
    1.62 +	_L("DejaVu Serif Condensed")
    1.63 +	};
    1.64 +// A short name (no spaces) version of KFontFace used for filenames and hash indexes.
    1.65 +const TPtrC KFontFaceShortName[KNumOfFontFaces] = 
    1.66 +	{
    1.67 +	_L("DVSans"),
    1.68 +	_L("DVMono"),
    1.69 +	_L("DVSerif")
    1.70 +	};
    1.71 +
    1.72 +// List of display modes. Used in INFO_PRINTF's
    1.73 +const TInt KNumOfDisplayModes = 12;
    1.74 +const TPtrC KDisplayModeNames[KNumOfDisplayModes] = 
    1.75 +	{
    1.76 +	_L("EGray2"),
    1.77 +	_L("EGray4"),
    1.78 +	_L("EGray16"),
    1.79 +	_L("EGray256"),
    1.80 +	_L("EColor16"),
    1.81 +	_L("EColor256"),
    1.82 +	_L("EColor64K"),
    1.83 +	_L("EColor16M"),
    1.84 +	_L("EColor4K"),
    1.85 +	_L("EColor16MU"),
    1.86 +	_L("EColor16MA"),
    1.87 +	_L("EColor16MAP"),
    1.88 +	};
    1.89 +
    1.90 +//List of display modes used for creating screen devices
    1.91 +const TDisplayMode KDisplayModes[KNumOfDisplayModes] = 
    1.92 +	{
    1.93 +	EGray2,
    1.94 +	EGray4,
    1.95 +	EGray16,
    1.96 +	EGray256,
    1.97 +	EColor16,
    1.98 +	EColor256,
    1.99 +	EColor64K,
   1.100 +	EColor16M,
   1.101 +	EColor4K,
   1.102 +	EColor16MU,
   1.103 +	EColor16MA,
   1.104 +	EColor16MAP,
   1.105 + 	};
   1.106 +
   1.107 +/**	
   1.108 +Enumeration for the attributes to be set in fontspec and gc.
   1.109 +See CTOutlineAndShadowFonts::PrepareTestEnvironment()
   1.110 +*/
   1.111 +enum TFontEffectsFlags
   1.112 +	{
   1.113 +	EDropShadowOn = 0x1,
   1.114 +	EOutlineOn = 0x2,
   1.115 +	ESetMonochromeGlyphBitmap  = 0x4,
   1.116 +	ESetAntiAliasedGlyphBitmap = 0x8,
   1.117 +	ESetFourColourBlendGlyphBitmap = 0x10,
   1.118 +	EVerticalDraw = 0x20,
   1.119 +	ERotate90Degrees = 0x40,
   1.120 +	EIsStrikethroughOn = 0x80,
   1.121 +	EIsUnderlineOn = 0x100,
   1.122 +	ESoftEdgeOn = 0x200,
   1.123 +	EAlgorithmicBoldOn = 0x400
   1.124 +	};
   1.125 +
   1.126 +/**
   1.127 +Structure to hold the flags of the attributes in fontspec and gc to be enabled.
   1.128 +*/
   1.129 +typedef struct
   1.130 +	{
   1.131 +	TUint32 fSpecAndGcSettings; //flags/effects in gc and fontspec to be enabled
   1.132 +	TRgb brushColor; //brush colour will set the colour of the fill of the font
   1.133 +	TRgb penColor; //pen colour which will set the colour of the outline
   1.134 +	TRgb shadowColor; //shadow colour which will set the colour of the shadow
   1.135 +	TRgb backgroundColor; //colour of the target that the text is rendered onto
   1.136 +	} STestFontParameters;
   1.137 +
   1.138 +// Test setting for TestOutlineandShadowFontsMetricsL() i.e. for test case 8
   1.139 +// All the test case conditions are defined here and are called to test font metrics
   1.140 +// STestFontParameters Format: outline | shadow | bitmaptype, BrushColor, PenColor, ShadowColor
   1.141 +const TInt KNumberOfSubTestsInTest0008 = 6;
   1.142 +const STestFontParameters KTestSettingsToTestFontMetrics[KNumberOfSubTestsInTest0008] =
   1.143 +	{{ESetMonochromeGlyphBitmap},
   1.144 +	{EOutlineOn | ESetMonochromeGlyphBitmap},
   1.145 +	{EOutlineOn | ESetAntiAliasedGlyphBitmap},
   1.146 +	{EDropShadowOn | ESetAntiAliasedGlyphBitmap},
   1.147 +	{EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap},
   1.148 +	{EAntiAliasedGlyphBitmap}};
   1.149 +
   1.150 +// Test setting for TestDrawTextWithOutlineAndShadowL() i.e. for test case 10
   1.151 +// All test case conditions are defined here and are called to test outline and shadow effects
   1.152 +// STestFontParameters Format: outline | shadow | bitmaptype, BrushColor, PenColor, ShadowColor, BackgroundColor
   1.153 +const TInt KNumberOfSubTestsInTest0010 = 35;
   1.154 +_LIT(KTestName0010, "OutlineShadowWithDrawTextNormalAndVertical");//test case name to used to generate test case id
   1.155 +const STestFontParameters KTestSettingsToTestOutlineAndShadow[KNumberOfSubTestsInTest0010] =
   1.156 +	{
   1.157 +	// test with EMonochromeGlyphBitmap and alpha value 255
   1.158 +	{EDropShadowOn | ESetMonochromeGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.159 +	{EOutlineOn | ESetMonochromeGlyphBitmap |  EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.160 +	{EDropShadowOn | EOutlineOn | ESetMonochromeGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.161 +	{EDropShadowOn | ESetMonochromeGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.162 +	{EOutlineOn | ESetMonochromeGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.163 +	{EDropShadowOn | EOutlineOn | ESetMonochromeGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.164 +	{EDropShadowOn | ESetMonochromeGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.165 +	{EOutlineOn | ESetMonochromeGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.166 +	{EDropShadowOn | EOutlineOn | ESetMonochromeGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.167 +
   1.168 +	// test with EAntiAliasedGlyphBitmap and alpha value 255
   1.169 +	{EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.170 +	{EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.171 +	{EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.172 +	{EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.173 +	{EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.174 +	{EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.175 +	{EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbBlue, KRgbBlack, KRgbYellow, KRgbWhite},
   1.176 +	{EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbBlue, KRgbBlack, KRgbYellow, KRgbWhite},
   1.177 +	{EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbBlue, KRgbBlack, KRgbYellow, KRgbWhite},
   1.178 +	{EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbBlue, KRgbBlack, KRgbYellow, KRgbWhite},
   1.179 +	{EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbBlue, KRgbBlack, KRgbYellow, KRgbWhite},
   1.180 +	{EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbBlue, KRgbBlack, KRgbYellow, KRgbWhite},
   1.181 +	{EDropShadowOn | ESetAntiAliasedGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.182 +	{EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.183 +	{EDropShadowOn |EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbGreen, KRgbBlack, KRgbBlue, KRgbWhite},
   1.184 +	{EDropShadowOn | ESetAntiAliasedGlyphBitmap, KRgbBlue, KRgbGreen, KRgbYellow, KRgbWhite},
   1.185 +	{EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbBlue, KRgbGreen, KRgbYellow, KRgbWhite},
   1.186 +	{EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbBlue, KRgbGreen, KRgbYellow, KRgbWhite},
   1.187 +	{ESetAntiAliasedGlyphBitmap, KRgbBlue, KRgbGreen, KRgbYellow, KRgbWhite},
   1.188 +	{ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbBlue, KRgbGreen, KRgbYellow, KRgbWhite},
   1.189 +	
   1.190 +	// test with EAntiAliasedGlyphBitmap and alpha value < 255 (transparency)
   1.191 +	{EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbBlue, TRgb(128,255,100,0), KRgbMagenta, KRgbWhite},
   1.192 +	{EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbGreen, TRgb(128,200,100,32), KRgbYellow, KRgbWhite},
   1.193 +	{EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw, KRgbYellow, TRgb(100,200,100,64), KRgbGray, KRgbWhite},
   1.194 +	{EDropShadowOn | ESetAntiAliasedGlyphBitmap | EVerticalDraw | ERotate90Degrees, KRgbWhite, TRgb(128,200,50,128), KRgbYellow, KRgbWhite},
   1.195 +	{EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbBlack, TRgb(12,20,50,255), KRgbWhite, KRgbWhite},
   1.196 +	{EOutlineOn | ESetAntiAliasedGlyphBitmap, KRgbGreen, TRgb(255,0,0,127), KRgbYellow, TRgb(127, 127, 127, 0)}
   1.197 +	};
   1.198 +
   1.199 +// Test setting for TestDrawTextWithStrikeThroughL() i.e. for test case 11
   1.200 +// All test case conditions are defined here and are called to test outline and shadow with strikethrough and underline effects.
   1.201 +// STestFontParameters Format: outline | shadow | bitmaptype | strikethroughon | underlineon, BrushColor, PenColor, ShadowColor
   1.202 +const TInt KNumberOfSubTestsInTest0011 = 4;
   1.203 +_LIT(KTestName0011, "OutlineShadowWithStrikeThroughBoldAndUnderline");//test case name to used to generate test case id
   1.204 +const STestFontParameters KTestSettingsToTestStrikeAndUnderline[KNumberOfSubTestsInTest0011] =
   1.205 +	{
   1.206 +	{EDropShadowOn | EOutlineOn | EIsStrikethroughOn | ESetAntiAliasedGlyphBitmap},
   1.207 +	{EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap},
   1.208 +	{EAlgorithmicBoldOn | ESoftEdgeOn | EIsUnderlineOn | ESetAntiAliasedGlyphBitmap},
   1.209 +	{ESetAntiAliasedGlyphBitmap}
   1.210 +	};
   1.211 +
   1.212 +//Structure to store bitmap device and font, can be used to clean in case of a leave
   1.213 +//See CleanUpFont()
   1.214 +typedef struct
   1.215 +	{
   1.216 +	CBitmapDevice* device;
   1.217 +	CFont* font;
   1.218 +	} SCleanFont;
   1.219 +
   1.220 +class CTOutlineAndShadowFontsStep : public CTGraphicsStep
   1.221 +	{
   1.222 +public:
   1.223 +	CTOutlineAndShadowFontsStep();
   1.224 +protected:
   1.225 +	virtual CTGraphicsBase* CreateTestL();
   1.226 +	};
   1.227 +
   1.228 +/**
   1.229 + Class defines all the API's which are used to test outline and shadow effects
   1.230 + */
   1.231 +class CTOutlineAndShadowFonts : public CTGraphicsBase
   1.232 +	{
   1.233 +public:
   1.234 +	CTOutlineAndShadowFonts(CTestStep* aStep);
   1.235 +	virtual ~CTOutlineAndShadowFonts();
   1.236 +private:
   1.237 +	void DoOutlinePenAndShadowColor();
   1.238 +	void DoOutlineandShadowFontsL();
   1.239 +	void DoOOM(TInt aFontIndex, TBool aVerticalText);
   1.240 +	void DoDrawTextWithOutlineAndShadowL(const STestFontParameters &aSettings, const TDesC& aHashIdString, const TInt aFontIndex);
   1.241 +	void DoOutlineandShadowFontsMetrics(const STestFontParameters &aSettings, TInt aFontIndex);
   1.242 +	void GetFontAndDrawOOM(TFontSpec aFontSpec, TBool aVerticalText);
   1.243 +	void DoSetStrikeThroughAndDrawTestL(const STestFontParameters &aSettings, const TDesC& aHashIdString);
   1.244 +	void CreateScreenDeviceL(TDisplayMode aMode);
   1.245 +	void FreeScreenDevice();
   1.246 +	void SetScreenMode(TDisplayMode aScreen);
   1.247 +	void TestOutlineandShadowFontsMetricsL();
   1.248 +	void TestOutlinePenAndShadowColorL();
   1.249 +	void TestDrawTextWithOutlineAndShadowL();
   1.250 +	void TestDrawTextWithStrikeThroughL();
   1.251 +	void TestCheckBitmapTypesL();
   1.252 +	void TestOOML();
   1.253 +	void TestAntiAliasedOrMonochromeGlyphBitmapL();
   1.254 +	void NegativeRastTestL();
   1.255 +	void NegativeRastTestDrawText(const TFontSpec &aFontSpec);
   1.256 +	void PrepareTestEnvironment(TFontSpec &aFontSpec, const STestFontParameters &aSettings, const TInt aFontIndex, TBool aSetEffects = ETrue, TBool aSetColors = EFalse);
   1.257 +	TBool CheckMonoTypeInstalledL();
   1.258 +	TBool TestRange(TInt aMin, TInt aValue, TInt aMax);
   1.259 +	TBool TestLessThanOrEqual(TInt aValue, TInt aMax);
   1.260 +protected:
   1.261 +	virtual void RunTestCaseL(TInt aCurTestCase);
   1.262 +	virtual void ConstructL();
   1.263 +private:
   1.264 +	CFbsBitGc* iGc;
   1.265 +	CFbsDevice* iBitmapDevice;
   1.266 +	RFbsSession* iFbs;
   1.267 +	CFbsBitmap* iBitmap;
   1.268 +	CTestStep* iStep;
   1.269 +	CTHashReferenceImages *iHashUtil;
   1.270 +	};
   1.271 +
   1.272 +_LIT(KTOutlineAndShadowFontsStep,"TOutlineAndShadowFonts");
   1.273 +#endif