graphicsdeviceinterface/bitgdi/tbit/toutlineandshadowfonts.cpp
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 #include "toutlineandshadowfonts.h"
       
    23 #include <test/testexecutestepbase.h>
       
    24 #include <openfont.h>
       
    25 #include <test/thashreferenceimages.h>
       
    26 #include <graphics/fbsdefs.h>
       
    27 #include "fbsmessage.h"
       
    28 
       
    29 //Note: This test should run with a rasterizer which supports EFourColourBlendGlyphBitmap (e.g. iType)
       
    30 //otherwise the tests will fail.
       
    31 
       
    32 //Path where reference mbm files get created, these reference bitmaps are useful when debugging.
       
    33 _LIT(KPath, "c:\\bitgditest\\%S.mbm"); 
       
    34 
       
    35 // Constructor
       
    36 CTOutlineAndShadowFonts::CTOutlineAndShadowFonts(CTestStep* aStep):CTGraphicsBase(aStep),iStep(aStep) { }
       
    37 
       
    38 void CTOutlineAndShadowFonts::ConstructL()
       
    39 	{
       
    40 	if (RFbsSession::Connect() != KErrNone)
       
    41 		{
       
    42 		FbsStartup();
       
    43 		TInt conret = RFbsSession::Connect();
       
    44 		TEST2(conret, KErrNone);
       
    45 		}
       
    46 	iFbs = RFbsSession::GetSession();
       
    47 	iHashUtil = CTHashReferenceImages::NewL(iStep,iFbs,&KPath);
       
    48 	}
       
    49 
       
    50 // Destructor
       
    51 CTOutlineAndShadowFonts::~CTOutlineAndShadowFonts()
       
    52 	{
       
    53 	FreeScreenDevice();
       
    54 	RFbsSession::Disconnect();
       
    55 	delete iHashUtil;
       
    56 	}
       
    57 
       
    58 
       
    59 /**
       
    60 Creates screen device for the given display mode if supported
       
    61 @param aMode display mode for which device has to be created
       
    62 */
       
    63 void CTOutlineAndShadowFonts::CreateScreenDeviceL(TDisplayMode aMode)
       
    64 	{
       
    65 	iBitmap = new(ELeave) CFbsBitmap;
       
    66 	//Considering the intersection of the screen size for both hw and emulator so that same
       
    67 	//baselined hash can be used to test for both
       
    68 	iBitmap->Create(TSize(KScreenWidth, KScreenHeight), aMode);
       
    69 	iBitmapDevice = CFbsBitmapDevice::NewL(iBitmap);
       
    70 	User::LeaveIfError(iBitmapDevice->CreateContext((CGraphicsContext*&)iGc));
       
    71 	iHashUtil->SetScreenDeviceAndBitmap(iBitmapDevice,iBitmap,iGc);
       
    72 	}
       
    73 
       
    74 /**
       
    75 Delete the devices created and gc.
       
    76 */
       
    77 void CTOutlineAndShadowFonts::FreeScreenDevice()
       
    78 	{
       
    79 	delete iBitmapDevice;
       
    80 	delete iBitmap;
       
    81 	delete iGc;
       
    82 	iBitmapDevice = NULL;
       
    83 	iBitmap = NULL;
       
    84 	iGc = NULL;
       
    85 	}
       
    86 
       
    87 
       
    88 /**
       
    89 Auxilary function will be called in case of a leave to release the font
       
    90 @param aCleanFont font to be released
       
    91 */
       
    92 void CleanUpFont(TAny* aCleanFont)
       
    93 	{
       
    94 	SCleanFont* cleanFont= static_cast<SCleanFont*>(aCleanFont);
       
    95 	(cleanFont->device)->ReleaseFont(cleanFont->font);
       
    96 	}
       
    97 
       
    98 TBool CTOutlineAndShadowFonts::CheckMonoTypeInstalledL()
       
    99 	{
       
   100 	CreateScreenDeviceL(EColor16MU);
       
   101 //
       
   102 	TFontSpec fontSpec;
       
   103 	fontSpec.iTypeface.iName = KFontFace[0];
       
   104 	fontSpec.iHeight = KHeight;
       
   105 	fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
       
   106 	fontSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, EDropShadowOn);
       
   107 	fontSpec.iFontStyle.SetEffects(FontEffect::EOutline, EOutlineOn);
       
   108 	CFont* font;
       
   109 	User::LeaveIfError(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font,fontSpec));
       
   110 	TBool monoTypeInstalled=font->FontSpecInTwips().iFontStyle.BitmapType()==EFourColourBlendGlyphBitmap;
       
   111 	iBitmapDevice->ReleaseFont(font);
       
   112 	if (!monoTypeInstalled)
       
   113 		{
       
   114 		INFO_PRINTF1(_L("Monotype fonts not installed, Run iType\\binaries\\ityperast.cmd to install them"));
       
   115 		TEST(EFalse);
       
   116 		TestComplete();
       
   117 		}
       
   118 	return(monoTypeInstalled);
       
   119 	}
       
   120 
       
   121 /**
       
   122 @SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0008
       
   123 
       
   124 @SYMPREQ PREQ1543
       
   125 
       
   126 @SYMTestCaseDesc Checks the fonts metrics. Tests the metrics with and without outline and shadow effects
       
   127 for different typefaces and screen modes
       
   128 
       
   129 @SYMTestPriority Critical
       
   130 
       
   131 @SYMTestStatus Implemented
       
   132 
       
   133 @SYMTestActions Create two fonts, one with and without shadow and outline effects on.
       
   134 Get the font metrics using GetNearestFontToDesignHeightInPixels
       
   135 Compare the different font metrics for both the fonts.
       
   136 API Calls:
       
   137 CTOutlineAndShadowFonts::DoOutlineandShadowFontsMetrics()
       
   138 
       
   139 @SYMTestExpectedResults font metrics with and without outline and shadow effects should not vary by more than 3.
       
   140 */
       
   141 void CTOutlineAndShadowFonts::TestOutlineandShadowFontsMetricsL()
       
   142 	{
       
   143 	INFO_PRINTF1(_L("TestOutlineandShadowFontsMetricsL()"));
       
   144 	FreeScreenDevice();
       
   145 	CreateScreenDeviceL(EColor16MU); //Create device for EColor16MU
       
   146 	for (TInt fontFaceIndex = 0; fontFaceIndex < KNumOfFontFaces; fontFaceIndex++)
       
   147 		{
       
   148 		for (TInt numOfSubTests = 0; numOfSubTests < KNumberOfSubTestsInTest0008; numOfSubTests++)
       
   149 			{
       
   150 			DoOutlineandShadowFontsMetrics(KTestSettingsToTestFontMetrics[numOfSubTests], fontFaceIndex);
       
   151 			}
       
   152 		}
       
   153 	}
       
   154 
       
   155 /** 
       
   156 Utility function to determine whether a specified value lies within a defined range of values.
       
   157 @param aMin The lower value of the range.
       
   158 @param aValue The value to be compared.
       
   159 @param aMax The higher value of the range.
       
   160 @return ETrue, if the specified value lies within the range; EFalse, otherwise.
       
   161 */
       
   162 TBool CTOutlineAndShadowFonts::TestRange(TInt aMin, TInt aValue, TInt aMax)
       
   163 	{
       
   164 	if (Rng(aMin, aValue, aMax))
       
   165 		{
       
   166 		return ETrue;
       
   167 		}
       
   168 	else
       
   169 		{
       
   170 		INFO_PRINTF4(_L("TestRange: !(%i !<= %i !<= %i)"), aMin, aValue, aMax);
       
   171 		return EFalse;
       
   172 		}
       
   173 	}
       
   174 
       
   175 /** 
       
   176 Utility function to determine whether a specified value is below a certain value.
       
   177 @param aValue The value to be compared.
       
   178 @param aMax The highest permitted value.
       
   179 @return ETrue, if the specified value is below the maximum; EFalse, otherwise.
       
   180 */
       
   181 TBool CTOutlineAndShadowFonts::TestLessThanOrEqual(TInt aValue, TInt aMax)
       
   182 	{
       
   183 	if (aValue <= aMax)
       
   184 		{
       
   185 		return ETrue;
       
   186 		}
       
   187 	else
       
   188 		{
       
   189 		INFO_PRINTF3(_L("TestLessThanOrEqual: !(%i !<= %i)"), aValue, aMax);
       
   190 		return EFalse;
       
   191 		}
       
   192 	}
       
   193 
       
   194 /**
       
   195 Auxilary function called from TestOutlineandShadowFontsMetricsL
       
   196 @param aSettings holds the effects settings (outline, shadow etc...)
       
   197 @param aFontIndex holds the font index
       
   198 */
       
   199 void CTOutlineAndShadowFonts::DoOutlineandShadowFontsMetrics(const STestFontParameters &aSettings, TInt aFontIndex)
       
   200 	{
       
   201 	TFontSpec fontSpecWithOutEffects;
       
   202 	//Create fontspec without shadow and outline effects on
       
   203 	PrepareTestEnvironment(fontSpecWithOutEffects, aSettings , aFontIndex, EFalse, EFalse);
       
   204 	CFbsFont* font1 = NULL;
       
   205 	TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font1,fontSpecWithOutEffects) == KErrNone);
       
   206 	TEST(font1 != NULL);
       
   207 
       
   208 	TFontSpec fontSpecWithEffects;
       
   209 	//Create fontspec with shadow and outline effects on if asked for
       
   210 	PrepareTestEnvironment(fontSpecWithEffects, aSettings, aFontIndex, ETrue, EFalse);
       
   211 	CFbsFont* font2 = NULL;
       
   212 	TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font2,fontSpecWithEffects) == KErrNone);
       
   213 	TEST(font2 != NULL);
       
   214 
       
   215 	//get the name of the fonts
       
   216 	TOpenFontFaceAttrib font1Attrib;
       
   217 	TBool haveFont1Attrib;
       
   218 	haveFont1Attrib = font1->GetFaceAttrib(font1Attrib);
       
   219 	INFO_PRINTF1(_L("Font names"));
       
   220 	if (haveFont1Attrib)
       
   221 		{
       
   222 		INFO_PRINTF1(font1Attrib.FullName());
       
   223 		}
       
   224 	TOpenFontFaceAttrib font2Attrib;
       
   225 	TBool haveFont2Attrib;
       
   226 	haveFont2Attrib = font2->GetFaceAttrib(font2Attrib);
       
   227 	if (haveFont2Attrib)
       
   228 		{
       
   229 		INFO_PRINTF1(font2Attrib.FullName());
       
   230 		}
       
   231 
       
   232 	//Check different font metrics with and without outline and shadow effects
       
   233 	TUid uid1 = font1->TypeUid();
       
   234 	TUid uid2 = font2->TypeUid();
       
   235 	ASSERT_EQUALS(KCFbsFontUid, uid1);
       
   236 	ASSERT_EQUALS(KCFbsFontUid, uid2);
       
   237 	TInt valueFontWithoutEffects = font1->AscentInPixels();
       
   238 	TInt valueFontWithEffects = font2->AscentInPixels();
       
   239 	TEST(valueFontWithoutEffects == valueFontWithEffects);
       
   240 
       
   241 	valueFontWithoutEffects = font1->BaselineOffsetInPixels();
       
   242 	valueFontWithEffects = font2->BaselineOffsetInPixels();
       
   243 	TEST(valueFontWithoutEffects == valueFontWithEffects);
       
   244 	for (TInt c=0;c<256;c++)
       
   245 		{
       
   246 		valueFontWithoutEffects = font1->CharWidthInPixels(c);
       
   247 		valueFontWithEffects = font2->CharWidthInPixels(c);
       
   248 		TEST(valueFontWithoutEffects == valueFontWithEffects);
       
   249 		}
       
   250 	//CharactersJoin
       
   251 	valueFontWithoutEffects = font1->DescentInPixels();
       
   252 	valueFontWithEffects = font2->DescentInPixels();
       
   253 	TEST(valueFontWithoutEffects == valueFontWithEffects);
       
   254 
       
   255 	//Extended function
       
   256 	valueFontWithoutEffects = font1->FontCapitalAscent();
       
   257 	valueFontWithEffects = font2->FontCapitalAscent();
       
   258 	TEST(valueFontWithoutEffects == valueFontWithEffects);
       
   259 
       
   260 	valueFontWithoutEffects = font1->FontLineGap();
       
   261 	valueFontWithEffects = font2->FontLineGap();
       
   262 	TEST(valueFontWithoutEffects == valueFontWithEffects);
       
   263 
       
   264 	valueFontWithoutEffects = font1->FontMaxAscent();
       
   265 	valueFontWithEffects = font2->FontMaxAscent();
       
   266 	TEST(valueFontWithoutEffects == valueFontWithEffects);
       
   267 
       
   268 	valueFontWithoutEffects = font1->FontMaxDescent();
       
   269 	valueFontWithEffects = font2->FontMaxDescent();
       
   270 	TEST(valueFontWithoutEffects == valueFontWithEffects);
       
   271 
       
   272 	valueFontWithoutEffects = font1->FontMaxHeight();
       
   273 	valueFontWithEffects = font2->FontMaxHeight();
       
   274 	TEST(valueFontWithoutEffects == valueFontWithEffects);
       
   275 
       
   276 	//FontSpecInTwips -  will be different
       
   277 	TFontSpec spec = font1->FontSpecInTwips();
       
   278 	TFontSpec spec2 = font2->FontSpecInTwips();
       
   279 	TEST(spec.iHeight == spec2.iHeight);
       
   280 	valueFontWithoutEffects = font1->FontStandardDescent();
       
   281 	valueFontWithEffects = font2->FontStandardDescent();
       
   282 	TEST(valueFontWithoutEffects+KDifferByOne >= valueFontWithEffects);
       
   283 
       
   284 	valueFontWithoutEffects = font1->HeightInPixels();
       
   285 	valueFontWithEffects = font2->HeightInPixels();
       
   286 	TEST(valueFontWithoutEffects == valueFontWithEffects);
       
   287 
       
   288 	valueFontWithoutEffects = font1->MaxCharWidthInPixels();
       
   289 	valueFontWithEffects = font2->MaxCharWidthInPixels();
       
   290 	TEST(valueFontWithoutEffects == valueFontWithEffects);
       
   291 
       
   292 	valueFontWithoutEffects = font1->MaxNormalCharWidthInPixels();
       
   293 	valueFontWithEffects = font2->MaxNormalCharWidthInPixels();
       
   294 	TEST(valueFontWithoutEffects == valueFontWithEffects);
       
   295 
       
   296 	_LIT(KMeasureText,"ABCdef456");
       
   297 	CFont::TMeasureTextOutput out1;
       
   298 	CFont::TMeasureTextOutput out2;
       
   299 	valueFontWithoutEffects = font1->MeasureText(KMeasureText,NULL,&out1);
       
   300 	valueFontWithEffects = font2->MeasureText(KMeasureText,NULL,&out2);
       
   301 	TEST(valueFontWithoutEffects == valueFontWithEffects);
       
   302 	TEST(out1.iChars == out2.iChars);
       
   303 	TEST(out1.iGlyphs == out2.iGlyphs);
       
   304 	TEST(out1.iGroups == out2.iGroups);
       
   305 	TEST(out1.iSpaces == out2.iSpaces);
       
   306 	TEST(TestLessThanOrEqual(out1.iBounds.iTl.iX-KDifferByOne, out2.iBounds.iTl.iX));
       
   307 	TEST(TestLessThanOrEqual(out1.iBounds.iTl.iY-KDifferByOne, out2.iBounds.iTl.iY));
       
   308 	TEST(TestLessThanOrEqual(out1.iBounds.iBr.iX-KDifferByOne, out2.iBounds.iBr.iX));
       
   309 	TEST(TestLessThanOrEqual(out1.iBounds.iBr.iY-KDifferByOne, out2.iBounds.iBr.iY));
       
   310 	TEST(TestLessThanOrEqual(out1.iMaxGlyphSize.iHeight-KDifferByOne, out2.iMaxGlyphSize.iHeight));
       
   311 	TEST(TestLessThanOrEqual(out1.iMaxGlyphSize.iWidth-KDifferByOne, out2.iMaxGlyphSize.iWidth));
       
   312 	valueFontWithoutEffects = font1->TextCount(KMeasureText, 30);
       
   313 	valueFontWithEffects = font2->TextCount(KMeasureText, 30);
       
   314 	TEST(valueFontWithoutEffects == valueFontWithEffects);
       
   315 	TInt val3;
       
   316 	TInt val4;
       
   317 	valueFontWithoutEffects = font1->TextCount(KMeasureText, 30, val3);
       
   318 	valueFontWithEffects = font2->TextCount(KMeasureText, 30, val4);
       
   319 	TEST(val3 == val4);
       
   320 	TEST(valueFontWithoutEffects == valueFontWithEffects);
       
   321 	valueFontWithoutEffects = font1->TextWidthInPixels(KMeasureText);
       
   322 	valueFontWithEffects = font2->TextWidthInPixels(KMeasureText);
       
   323 	TEST(TestRange(valueFontWithoutEffects, valueFontWithEffects, valueFontWithoutEffects+KDifferByThree));
       
   324 	uid1 = font1->TypeUid();
       
   325 	uid2 = font2->TypeUid();
       
   326 	TEST(uid1 == uid2);
       
   327 	for (TInt c=0;c<256;c++)
       
   328 		{
       
   329 		const TUint8 *p1 = NULL;
       
   330 		const TUint8 *p2 = NULL;
       
   331 		TCharacterMetrics m1 = font1->CharacterMetrics(c, p1);
       
   332 		TCharacterMetrics m2 = font2->CharacterMetrics(c, p2);
       
   333 		TEST(TestLessThanOrEqual(m1.iAscentInPixels-KDifferByOne, m2.iAscentInPixels));
       
   334 		TEST(TestLessThanOrEqual(m1.iHeightInPixels-KDifferByOne, m2.iHeightInPixels));
       
   335 		TEST(TestLessThanOrEqual(m1.iLeftAdjustInPixels-KDifferByTwo, m2.iLeftAdjustInPixels));
       
   336 		TEST(m1.iMoveInPixels == m2.iMoveInPixels);
       
   337 		TEST(TestLessThanOrEqual(m1.iRightAdjustInPixels-KDifferByTwo, m2.iRightAdjustInPixels));
       
   338 		}
       
   339 	TOpenFontMetrics ofm1;
       
   340 	TOpenFontMetrics ofm2;
       
   341 	TBool r1 = font1->GetFontMetrics(ofm1);
       
   342 	TBool r2 = font2->GetFontMetrics(ofm2);
       
   343 	TEST(ofm1.Size() == ofm2.Size());
       
   344 	TEST(ofm1.Ascent() == ofm2.Ascent());
       
   345 	TEST(ofm1.Descent() == ofm2.Descent());
       
   346 	TEST(ofm1.MaxHeight() == ofm2.MaxHeight());
       
   347 	TEST(ofm1.MaxDepth() == ofm2.MaxDepth());
       
   348 	TEST(ofm1.MaxWidth() == ofm2.MaxWidth());
       
   349 
       
   350 	valueFontWithoutEffects = font1->RawTextWidthInPixels(KMeasureText);
       
   351 	valueFontWithEffects = font2->RawTextWidthInPixels(KMeasureText);
       
   352 	TEST(valueFontWithoutEffects == valueFontWithEffects);
       
   353 
       
   354 	valueFontWithoutEffects = font1->TextWidthInPixels(KMeasureText);
       
   355 	valueFontWithEffects = font2->TextWidthInPixels(KMeasureText);
       
   356 	TEST(TestLessThanOrEqual(valueFontWithoutEffects, valueFontWithEffects));
       
   357 
       
   358 	SCharWidth scw1;
       
   359 	SCharWidth scw2;
       
   360 	font1->TextWidthInPixels(KMeasureText,scw1);
       
   361 	font2->TextWidthInPixels(KMeasureText,scw2);
       
   362 	TEST(TestLessThanOrEqual(scw1.iLeftAdjust-KDifferByOne, scw2.iLeftAdjust));
       
   363 	TEST(scw1.iMove == scw2.iMove);
       
   364 	TEST(TestLessThanOrEqual(scw1.iRightAdjust-KDifferByTwo, scw2.iRightAdjust));
       
   365 	TEST(TestLessThanOrEqual(scw1.iWidth-KDifferByOne, scw2.iWidth));
       
   366 	iBitmapDevice->ReleaseFont(font2);
       
   367 	iBitmapDevice->ReleaseFont(font1);
       
   368 	}
       
   369 
       
   370 /**
       
   371 @SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0009
       
   372 
       
   373 @SYMPREQ PREQ1543
       
   374 
       
   375 @SYMTestCaseDesc Test the setter and getters for pen colour, brush colour and shadow colour.
       
   376 
       
   377 @SYMTestPriority Critical
       
   378 
       
   379 @SYMTestStatus Implemented
       
   380 
       
   381 @SYMTestActions Set colors to pen, brush and shadow call SetPenColor(), SetBrushColor(), SetShadowColor() respectively
       
   382 Get colors of pen, brush and shadow using PenColor(), BrushColor() and GetShadowColor() respectively
       
   383 
       
   384 @SYMTestExpectedResults pen, brush and shadow colour should return default colours if not set,
       
   385 else should return the colour set using SetPenColor(), SetBrushColor() and SetShadowColor() respectively
       
   386 */
       
   387 void CTOutlineAndShadowFonts::TestOutlinePenAndShadowColorL()
       
   388 	{
       
   389 	INFO_PRINTF1(_L("TestOutlinePenAndShadowColorL()"));
       
   390 	for(TInt displayMode = ENone; displayMode < KNumOfDisplayModes; displayMode++)
       
   391 		{
       
   392 		FreeScreenDevice();
       
   393 		CreateScreenDeviceL(KDisplayModes[displayMode]);
       
   394 		DoOutlinePenAndShadowColor();
       
   395 		}
       
   396 	}
       
   397 
       
   398 /**
       
   399 Auxilary function called from TestOutlinePenAndShadowColorL
       
   400 API Calls:
       
   401 CFbsBitGc::PenColor()
       
   402 CFbsBitGc::SetPenColor()
       
   403 CFbsBitGc::BrushColor()
       
   404 CFbsBitGc::SetBrushColor()
       
   405 CFbsBitGc::GetShadowColor()
       
   406 CFbsBitGc::SetShadowColor()
       
   407 */
       
   408 void CTOutlineAndShadowFonts::DoOutlinePenAndShadowColor()
       
   409 	{
       
   410 	//iGc->Reset();
       
   411 	TRgb color;
       
   412 	color = iGc->PenColor();
       
   413 
       
   414 	//Pen colour is used for drawing outline
       
   415 	TEST(color == KDefaultOutlinePenColor);
       
   416 	color = iGc->BrushColor();
       
   417 
       
   418 	//Brush colour is used as fill colour
       
   419 	TEST(color == KDefaultFillColor);
       
   420 	iGc->GetShadowColor(color);
       
   421 	TEST(color == KDefaultShadowColor);
       
   422 	iGc->SetShadowColor(KRgbGreen);
       
   423 	iGc->GetShadowColor(color);
       
   424 	TEST(color == KRgbGreen);
       
   425 	iGc->SetPenColor(KRgbYellow);
       
   426 	color = iGc->PenColor();
       
   427 	TEST(color == KRgbYellow);
       
   428 	iGc->SetBrushColor(KRgbRed);
       
   429 	color = iGc->BrushColor();
       
   430 	TEST(color == KRgbRed);
       
   431 	}
       
   432 
       
   433 /**
       
   434 @SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0010
       
   435 
       
   436 @SYMPREQ PREQ1543
       
   437 
       
   438 @SYMTestCaseDesc Tests the text drawn using DrawTextVertical and DrawText with shadow and outline effects on
       
   439 with different display modes and orientations.
       
   440 
       
   441 @SYMTestPriority Critical
       
   442 
       
   443 @SYMTestStatus Implemented
       
   444 
       
   445 @SYMTestActions Call DrawTextVertical and DrawText with different effect on, display modes and orientations.
       
   446 API Calls:
       
   447 CFbsBitGc::DrawTextVertical()
       
   448 CFbsBitGc::DrawText()
       
   449 CTOutlineAndShadowFonts::CompareHashValuesL()
       
   450 
       
   451 @SYMTestExpectedResults Hash generated for the drawn text should be same with the baselined hash value.
       
   452 */
       
   453 void CTOutlineAndShadowFonts::TestDrawTextWithOutlineAndShadowL()
       
   454 	{
       
   455 	INFO_PRINTF1(_L("TestDrawTextWithOutlineAndShadowL()"));
       
   456 	for(TInt displayMode = 0; displayMode < KNumOfDisplayModes; displayMode++)
       
   457 		{
       
   458 		FreeScreenDevice();
       
   459 		CreateScreenDeviceL(KDisplayModes[displayMode]);
       
   460 		INFO_PRINTF2(_L("Display mode: %S"), &KDisplayModeNames[displayMode]);
       
   461 		for (TInt orient = CFbsBitGc::EGraphicsOrientationNormal; orient <= CFbsBitGc::EGraphicsOrientationRotated270; orient++)
       
   462 			{
       
   463 			iGc->SetOrientation((CFbsBitGc::TGraphicsOrientation)orient);
       
   464 			for (TInt fontFaceIndex = 0; fontFaceIndex < KNumOfFontFaces; fontFaceIndex++)
       
   465 				{
       
   466 				for (TInt numOfSubTests = 0; numOfSubTests < KNumberOfSubTestsInTest0010; numOfSubTests++)
       
   467 					{
       
   468 					//Test with only one display mode i.e. EColor16MU for EMonochromeGlyphBitmap to reduce test execution time
       
   469 					if ((KTestSettingsToTestOutlineAndShadow[numOfSubTests].fSpecAndGcSettings & ESetMonochromeGlyphBitmap) && (displayMode != EColor16MU))
       
   470 						{
       
   471 						continue;
       
   472 						}
       
   473 
       
   474 					//Test transparency for display mode EColor64K and above as it is not supported in other display modes
       
   475 					if (KTestSettingsToTestOutlineAndShadow[numOfSubTests].penColor.Alpha() < 255 && displayMode < 6)
       
   476 						{
       
   477 						continue;
       
   478 						}
       
   479 					HBufC* hashIdString = iHashUtil->GenerateHashIdStringLC(KTestName0010, numOfSubTests, KFontFaceShortName, fontFaceIndex, displayMode, orient);
       
   480 					DoDrawTextWithOutlineAndShadowL(KTestSettingsToTestOutlineAndShadow[numOfSubTests], *hashIdString, fontFaceIndex);
       
   481 					CleanupStack::PopAndDestroy(hashIdString);
       
   482 					}
       
   483 				}
       
   484 			}
       
   485 		}
       
   486 	iGc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal);
       
   487 	}
       
   488 
       
   489 /**
       
   490 Auxilary function called TestDrawTextWithOutlineAndShadowL.
       
   491 @param aSettings holds the effects settings (Outline, Shadow, Bitmap type etc...)
       
   492 @param aHashIdString holds the HashID string
       
   493 @param aFontIndex holds the font index
       
   494 */
       
   495 void CTOutlineAndShadowFonts::DoDrawTextWithOutlineAndShadowL(const STestFontParameters &aSettings, const TDesC& aHashIdString, const TInt aFontIndex)
       
   496 	{
       
   497 	TFontSpec fontSpec;
       
   498 	PrepareTestEnvironment(fontSpec, aSettings, aFontIndex, ETrue, ETrue);
       
   499 	CFont* font;
       
   500 	TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font, fontSpec) == KErrNone);
       
   501 	SCleanFont cleanupFont = {iBitmapDevice, font};
       
   502 	CleanupStack::PushL(TCleanupItem(CleanUpFont, &cleanupFont));
       
   503 	iGc->UseFont(font);
       
   504 	if(EVerticalDraw & aSettings.fSpecAndGcSettings)
       
   505 		{
       
   506 		iGc->DrawTextVertical(KTextPhrase, TPoint(20,60), ERotate90Degrees & aSettings.fSpecAndGcSettings);
       
   507 		}
       
   508 	else
       
   509 		{
       
   510 		iGc->DrawText(KTextPhrase, KPoint);
       
   511 		}
       
   512 	iHashUtil->CompareHashValuesL(aHashIdString);
       
   513 	CleanupStack::Pop();//font
       
   514 	iBitmapDevice->ReleaseFont(font);
       
   515 	iGc->DiscardFont();
       
   516 	}
       
   517 
       
   518 /**
       
   519 @SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0011
       
   520 
       
   521 @SYMPREQ PREQ1543
       
   522 
       
   523 @SYMTestCaseDesc Tests outline and shadow effects with strikethrough, softedge and underLine
       
   524 for different orientations.
       
   525 
       
   526 @SYMTestPriority Critical
       
   527 
       
   528 @SYMTestStatus Implemented
       
   529 
       
   530 @SYMTestActions Draw text with different effects on
       
   531 Repeat the same with all supported display modes and orientations. Generate hash key for the drawn text.
       
   532 API Calls:
       
   533 CFbsBitGc::DrawText()
       
   534 CTHashReferenceImages::CompareHashValuesL()
       
   535 
       
   536 @SYMTestExpectedResults Hash generated for the drawn text should be same with the baselined hash value.
       
   537 */
       
   538 void CTOutlineAndShadowFonts::TestDrawTextWithStrikeThroughL()
       
   539 	{
       
   540 	INFO_PRINTF1(_L("TestDrawTextWithStrikeThroughL()"));
       
   541 	for(TInt displayMode = 0; displayMode < KNumOfDisplayModes; displayMode++)
       
   542 		{
       
   543 		INFO_PRINTF2(_L("Display mode: %S"), &KDisplayModeNames[displayMode]);
       
   544 		FreeScreenDevice();
       
   545 		CreateScreenDeviceL(KDisplayModes[displayMode]);
       
   546 
       
   547 		for (TInt numOfSubTests = 0; numOfSubTests < KNumberOfSubTestsInTest0011; numOfSubTests++)
       
   548 			{
       
   549 			HBufC* hashIdString = iHashUtil->GenerateHashIdStringLC(KTestName0011, numOfSubTests, &(KFontFace[0]), 0, displayMode, 0);
       
   550 			DoSetStrikeThroughAndDrawTestL(KTestSettingsToTestStrikeAndUnderline[numOfSubTests], *hashIdString);
       
   551 			CleanupStack::PopAndDestroy(hashIdString);
       
   552 			}
       
   553 		}
       
   554 	}
       
   555 
       
   556 /**
       
   557 Auxilary function called from TestDrawTextWithStrikeThroughL API
       
   558 @SYMTestCaseDesc Tests drawn text with different effects like
       
   559 strikethrough, softedge, underLine etc for different orientations.
       
   560 @param aSettings holds font settings
       
   561 @param aHashIdString holds HashID
       
   562 */
       
   563 void CTOutlineAndShadowFonts::DoSetStrikeThroughAndDrawTestL(const STestFontParameters &aSettings, const TDesC& aHashIdString)
       
   564 	{
       
   565 	TFontSpec fontSpec;
       
   566 	//Passing 0 as font index as testing with one typeface is sufficient in this case
       
   567 	PrepareTestEnvironment(fontSpec, aSettings, 0, ETrue, EFalse);
       
   568 
       
   569 	CFont* font;
       
   570 	TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font, fontSpec) == KErrNone);
       
   571 	SCleanFont cleanupFont = {iBitmapDevice, font};
       
   572 	CleanupStack::PushL(TCleanupItem(CleanUpFont, &cleanupFont));
       
   573 	iGc->UseFont(font);
       
   574 	iGc->DrawText(KTextPhrase,KPoint);
       
   575 	iHashUtil->CompareHashValuesL(aHashIdString);
       
   576 	CleanupStack::Pop();//font
       
   577 	iBitmapDevice->ReleaseFont(font);
       
   578 	iGc->DiscardFont();
       
   579 	}
       
   580 
       
   581 /**
       
   582 @SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0012
       
   583 
       
   584 @SYMTestCaseDesc Negative tests.
       
   585 
       
   586 @SYMTestPriority Critical
       
   587 
       
   588 @SYMTestStatus Implemented
       
   589 
       
   590 @SYMTestActions Create font spec with different -ve scenarios.
       
   591 Like pass bitmap type other than valid on, -ve pen size etc.
       
   592 
       
   593 API Calls:
       
   594 CFbsBitGc::GetNearestFontToDesignHeightInPixels()
       
   595 TFontStyle::SetEffects()
       
   596 
       
   597 @SYMTestExpectedResults Tests should not panic.
       
   598 */
       
   599 void CTOutlineAndShadowFonts::NegativeRastTestL()
       
   600 	{
       
   601 	INFO_PRINTF1(_L("NegativeRastTestL()"));
       
   602 	FreeScreenDevice();
       
   603 	CreateScreenDeviceL(KDisplayModes[9]); //Create device for EColor16MU
       
   604 
       
   605 	TFontSpec fsp;
       
   606 	STestFontParameters settings;
       
   607 
       
   608 	INFO_PRINTF1(_L("Drawing empty text"));
       
   609 	settings.fSpecAndGcSettings = EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap;
       
   610 	PrepareTestEnvironment(fsp, settings, 0);
       
   611 	iGc->SetPenSize(TSize(10,10));
       
   612 	NegativeRastTestDrawText(fsp);
       
   613 
       
   614 	INFO_PRINTF1(_L("Drawing empty text with unknown typeface"));
       
   615 	fsp.iTypeface.iName=_L("ERROR FONT");  //Typeface which does not exist
       
   616 	iGc->SetPenSize(TSize(3,3));
       
   617 	NegativeRastTestDrawText(fsp);
       
   618 
       
   619 	INFO_PRINTF1(_L("Drawing empty text with invalid glyph bitmap type"));
       
   620 	fsp.iFontStyle.SetBitmapType((TGlyphBitmapType)KInvalidBitmapType); //Invalid glyph bitmap type
       
   621 	CFont* font;
       
   622 	TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font, fsp) == KErrNone);
       
   623 	iGc->UseFont(font);
       
   624 	iGc->DrawText(KTextPhrase,KPoint);
       
   625 	TEST(font->FontSpecInTwips().iFontStyle.BitmapType() == EMonochromeGlyphBitmap);
       
   626 	iBitmapDevice->ReleaseFont(font);
       
   627 	iGc->DiscardFont();
       
   628 	
       
   629 	INFO_PRINTF1(_L("Drawing text with brush style ENullBrush"));
       
   630 	iGc->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   631 	settings.fSpecAndGcSettings = EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap;
       
   632 	PrepareTestEnvironment(fsp, settings, 0);
       
   633 	NegativeRastTestDrawText(fsp);
       
   634 	
       
   635 	INFO_PRINTF1(_L("Drawing text with brush style ESolidBrush"));
       
   636 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   637 	NegativeRastTestDrawText(fsp);
       
   638 	
       
   639 	INFO_PRINTF1(_L("Drawing text with large pen size"));
       
   640 	iGc->SetPenSize(TSize(1000,1000));
       
   641 	NegativeRastTestDrawText(fsp);
       
   642 
       
   643 	INFO_PRINTF1(_L("Drawing text with -ve pen size"));
       
   644 	settings.fSpecAndGcSettings = EDropShadowOn | ESetAntiAliasedGlyphBitmap;
       
   645 	PrepareTestEnvironment(fsp, settings, 0);
       
   646 	iGc->SetPenSize(TSize(-1,-1));
       
   647 	NegativeRastTestDrawText(fsp);
       
   648 	}
       
   649 
       
   650 /**
       
   651 Auxilary function called from NegativeRastTestL
       
   652 @param aFontSpec holds fonts specifications
       
   653 */
       
   654 void CTOutlineAndShadowFonts::NegativeRastTestDrawText(const TFontSpec &aFontSpec)
       
   655 	{
       
   656 	CFont* font;
       
   657 	TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font, aFontSpec) == KErrNone);
       
   658 	iGc->UseFont(font);
       
   659 	iGc->DrawText(KTextPhrase, KPoint);
       
   660 	iGc->DrawTextVertical(KTextPhrase, KPoint, EFalse);
       
   661 	iGc->DiscardFont();
       
   662 	iBitmapDevice->ReleaseFont(font);
       
   663 	}
       
   664 
       
   665 /**
       
   666 @SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0013
       
   667 
       
   668 @SYMPREQ PREQ1543
       
   669 
       
   670 @SYMTestCaseDesc Test glyph bitmap types with outline and shadow effects on and off
       
   671 
       
   672 @SYMTestPriority Critical
       
   673 
       
   674 @SYMTestStatus Implemented
       
   675 
       
   676 @SYMTestActions Create fonts with and without specifying the bitmap type
       
   677 API Calls:
       
   678 TFontStyle::BitmapType()
       
   679 
       
   680 @SYMTestExpectedResults Glyph bitmap type should be EFourColourBlendGlyphBitmap when either of outline or shadow effect on and EAntiAliasedGlyphBitmap set in fontspec
       
   681 */
       
   682 void CTOutlineAndShadowFonts::TestCheckBitmapTypesL()
       
   683 	{
       
   684 	INFO_PRINTF1(_L("TestCheckBitmapTypesL()"));
       
   685 	FreeScreenDevice();
       
   686 	CreateScreenDeviceL(KDisplayModes[9]); //Create device for EColor16MU
       
   687 
       
   688 	CFont* font;
       
   689 	TFontSpec fontSpec;
       
   690 	STestFontParameters settings;
       
   691 
       
   692 	PrepareTestEnvironment(fontSpec, settings, 0);
       
   693 	TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font,fontSpec) == KErrNone);
       
   694 	//Check for the bitmap type to be EMonochromeGlyphBitmap when no bitmap type is set.
       
   695 	TEST(font->FontSpecInTwips().iFontStyle.BitmapType() == EMonochromeGlyphBitmap);
       
   696 	iBitmapDevice->ReleaseFont(font);
       
   697 
       
   698 	settings.fSpecAndGcSettings = EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap;
       
   699 	PrepareTestEnvironment(fontSpec, settings, 0);
       
   700 	TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font,fontSpec) == KErrNone);
       
   701 	//Check for the bitmap type to be EFourColourBlendGlyphBitmap when either or both the
       
   702 	//EDropShadow or EOutline effects are on.
       
   703 	TEST(font->FontSpecInTwips().iFontStyle.BitmapType() == EFourColourBlendGlyphBitmap);
       
   704 	iBitmapDevice->ReleaseFont(font);
       
   705 
       
   706 	settings.fSpecAndGcSettings = EDropShadowOn | ESetAntiAliasedGlyphBitmap;
       
   707 	PrepareTestEnvironment(fontSpec, settings, 0);
       
   708 	TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font,fontSpec) == KErrNone);
       
   709 	//Check for the bitmap type to be EFourColourBlendGlyphBitmap when either or both the
       
   710 	//EDropShadow or EOutline effects are on.
       
   711 	TEST(font->FontSpecInTwips().iFontStyle.BitmapType() == EFourColourBlendGlyphBitmap);
       
   712 	iBitmapDevice->ReleaseFont(font);
       
   713 
       
   714 	settings.fSpecAndGcSettings = EOutlineOn | ESetAntiAliasedGlyphBitmap;
       
   715 	PrepareTestEnvironment(fontSpec, settings, 0);
       
   716 	TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font,fontSpec) == KErrNone);
       
   717 	//Check for the bitmap type to be EFourColourBlendGlyphBitmap when either or both the
       
   718 	//EDropShadow or EOutline effects are on.
       
   719 	TEST(font->FontSpecInTwips().iFontStyle.BitmapType() == EFourColourBlendGlyphBitmap);
       
   720 	iBitmapDevice->ReleaseFont(font);
       
   721 	}
       
   722 
       
   723 /**
       
   724 @SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0014
       
   725 
       
   726 @SYMPREQ PREQ1543
       
   727 
       
   728 @SYMTestCaseDesc OOM tests, checks OOM condition for GetNearestFontToDesignHeightInPixels.
       
   729 
       
   730 @SYMTestPriority Critical
       
   731 
       
   732 @SYMTestStatus Implemented
       
   733 
       
   734 @SYMTestActions
       
   735 API Calls:
       
   736 CFbsBitGc::GetNearestFontToDesignHeightInPixels()
       
   737 TFontStyle::SetEffects()
       
   738 
       
   739 @SYMTestExpectedResults Checks the OOM condition and finds if it takes care of OOM cases for GetNearestFontToDesignHeightInPixels
       
   740 */
       
   741 void CTOutlineAndShadowFonts::TestOOML()
       
   742 	{
       
   743 	INFO_PRINTF1(_L("TestOOML()"));
       
   744 	FreeScreenDevice();
       
   745 	CreateScreenDeviceL(KDisplayModes[9]); //Create device for EColor16MU
       
   746 
       
   747 	//OOM for normal text
       
   748 	for(TInt fontFaceIndex = 0; fontFaceIndex < KNumOfFontFaces; fontFaceIndex++)
       
   749 		{
       
   750 		DoOOM(fontFaceIndex, EFalse);
       
   751 		}
       
   752 	}
       
   753 
       
   754 /**
       
   755 Auxilary function called from TestOOML API
       
   756 @SYMTestCaseDesc checks OOM condition for DrawText() and DrawTextVertical().
       
   757 @param aFontSpec holds font specifications
       
   758 @param aDrawVerticalText holds bool, if true calls DrawTextVertical else calls DrawText api's
       
   759 */
       
   760 void CTOutlineAndShadowFonts::DoOOM(TInt aFontIndex, TBool aDrawVerticalText)
       
   761 	{
       
   762 	__UHEAP_RESET;
       
   763 	TFontSpec fSpec;
       
   764 	STestFontParameters settings;
       
   765 	settings.fSpecAndGcSettings = EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap;
       
   766 	PrepareTestEnvironment(fSpec, settings, aFontIndex);
       
   767 
       
   768 	//GetNearestFontToDesignHeightInPixels
       
   769 	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
       
   770 	CFont* font = NULL;
       
   771 	TEST(iBitmapDevice->GetNearestFontToDesignHeightInPixels(font,fSpec) == KErrNone);
       
   772 	TInt ret;
       
   773 	iBitmapDevice->ReleaseFont(font);
       
   774 	for (TInt count = 1; ; count++)
       
   775 		{
       
   776 		__UHEAP_SETFAIL(RHeap::EDeterministic,count);
       
   777 		__UHEAP_MARK;
       
   778 		font=NULL;
       
   779 		ret = iBitmapDevice->GetNearestFontToDesignHeightInPixels(font,fSpec);
       
   780 		if (ret == KErrNoMemory)
       
   781 			{
       
   782 			ASSERT(!font);
       
   783 			__UHEAP_MARKEND;
       
   784 			}
       
   785 		else if (ret == KErrNone)
       
   786 			{
       
   787 			ASSERT(font);
       
   788 			iBitmapDevice->ReleaseFont(font);
       
   789 			__UHEAP_MARKEND;
       
   790 			break;
       
   791 			}
       
   792 		else
       
   793 			{
       
   794 			__UHEAP_MARKEND;
       
   795 			TEST(ret ==  KErrNone);
       
   796 			}
       
   797 		iBitmapDevice->ReleaseFont(font);
       
   798 		}
       
   799 
       
   800 	//DrawText and DrawTextVertical with EDropShadow effect on and EOutline effect off
       
   801 	settings.fSpecAndGcSettings = EDropShadowOn | ESetAntiAliasedGlyphBitmap;
       
   802 	settings.brushColor = KRgbBlack;
       
   803 	settings.penColor = KRgbGreen;
       
   804 	settings.shadowColor =  KRgbRed;
       
   805 	PrepareTestEnvironment(fSpec, settings, aFontIndex, ETrue, ETrue);
       
   806 	GetFontAndDrawOOM(fSpec, aDrawVerticalText);
       
   807 
       
   808 	//DrawText and DrawTextVertical with EDropShadow effect off and EOutline effect on
       
   809 	settings.fSpecAndGcSettings = EOutlineOn | ESetAntiAliasedGlyphBitmap;
       
   810 	PrepareTestEnvironment(fSpec, settings, aFontIndex, ETrue, ETrue);
       
   811 	GetFontAndDrawOOM(fSpec, aDrawVerticalText);
       
   812 
       
   813 	//DrawText and DrawTextVertical with EDropShadow effect on and EOutline effect on
       
   814 	settings.fSpecAndGcSettings = EDropShadowOn | EOutlineOn | ESetAntiAliasedGlyphBitmap;
       
   815 	PrepareTestEnvironment(fSpec, settings, aFontIndex, ETrue, ETrue);
       
   816 	GetFontAndDrawOOM(fSpec, aDrawVerticalText);
       
   817 
       
   818 	__UHEAP_RESET;
       
   819 	}
       
   820 
       
   821 /**
       
   822 Auxilary function called from DoOOM API
       
   823 @SYMTestCaseDesc checks OOM condition for DrawText() and DrawTextVertical().
       
   824 @param aFontSpec holds font specifications
       
   825 @param aDrawVerticalText holds bool value, if true calls DrawTextVertical else calls DrawText api's
       
   826 */
       
   827 void CTOutlineAndShadowFonts::GetFontAndDrawOOM(TFontSpec aFontSpec, TBool aDrawVerticalText)
       
   828 	{
       
   829 	__UHEAP_RESET;
       
   830 	_LIT(KDRAWME,"Outline and Shadow");
       
   831 	CFont* font = NULL;
       
   832 	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
       
   833 	TInt ret= iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)font, aFontSpec);
       
   834 	TEST(ret ==  KErrNone);
       
   835 	for (TInt count = 1; ; count++)
       
   836 		{
       
   837 		__UHEAP_SETFAIL(RHeap::EDeterministic,count);
       
   838 		__UHEAP_MARK;
       
   839 		iGc->UseFont(font);
       
   840 		if (aDrawVerticalText)
       
   841 			{
       
   842 			iGc->DrawTextVertical(KDRAWME, TPoint(3, 4), EFalse);
       
   843 			}
       
   844 		else
       
   845 			{
       
   846 			iGc->DrawText(KDRAWME, TPoint(3, 4));
       
   847 			}
       
   848 		if (ret == KErrNoMemory)
       
   849 			{
       
   850 			iGc->DrawTextVertical(KDRAWME, TPoint(3, 4), EFalse);
       
   851 			__UHEAP_MARKEND;
       
   852 			}
       
   853 		else if (ret == KErrNone)
       
   854 			{
       
   855 			ASSERT(font);
       
   856 			iBitmapDevice->ReleaseFont(font);
       
   857 			iGc->DiscardFont();
       
   858 			__UHEAP_MARKEND;
       
   859 			break;
       
   860 			}
       
   861 		else
       
   862 			{
       
   863 			__UHEAP_MARKEND;
       
   864 			TEST(ret ==  KErrNone);
       
   865 			}
       
   866 		}
       
   867 	}
       
   868 
       
   869 /**
       
   870 @SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0015
       
   871 
       
   872 @SYMPREQ PREQ2555
       
   873 
       
   874 @SYMTestCaseDesc Check bitmaptype EAntiAliasedOrMonochromeGlyphBitmap returns the correct actual
       
   875 				bitmap type. This test uses the "Series 60 Sans SemiBold" font. 
       
   876 				Sizes 0-7:monochrome; 8-16:anti-aliased; 16 and above:monochrome.  
       
   877 
       
   878 @SYMTestPriority Normal
       
   879 
       
   880 @SYMTestStatus Implemented
       
   881 
       
   882 @SYMTestActions
       
   883 Set the font size of the test font to 6, 12, 20 respectively and the bitmap type to EAntiAliasedOrMonochromeGlyphBitmap. 
       
   884 Then call CFbsDevice::GetNearestFontToDesignHeightInPixels() to return the font and draw a text string on the left side of
       
   885 the bitmap. Draw the same string using the reference font on the right side of the bitmap. Use CFbsDevice::RectCompare()
       
   886 to compare the two halves of the bitmap.
       
   887 
       
   888 @SYMTestExpectedResults The two halves should be the same.
       
   889 */
       
   890 void CTOutlineAndShadowFonts::TestAntiAliasedOrMonochromeGlyphBitmapL()
       
   891 	{
       
   892 	iGc->Reset();
       
   893 	FreeScreenDevice();
       
   894 	CreateScreenDeviceL(EColor64K);
       
   895 	_LIT(KGaspTypefaceName, "Series 60 Sans SemiBold");
       
   896 	TFontSpec testFontSpec;
       
   897 	testFontSpec.iTypeface.iName = KGaspTypefaceName;	
       
   898 	testFontSpec.iFontStyle.SetBitmapType(EAntiAliasedOrMonochromeGlyphBitmap);
       
   899 	TFontSpec refFontSpec;
       
   900 	refFontSpec.iTypeface.iName = KGaspTypefaceName;	
       
   901 	
       
   902 	TInt fontsizes[3] = {6, 12, 20};
       
   903 	CFont* testFont;
       
   904 	CFont* refFont;
       
   905 	TPoint leftMidPoint = TPoint(KScreenWidth/4, KScreenHeight/2);
       
   906 	TPoint rightMidPoint = TPoint(KScreenWidth*3/4, KScreenHeight/2);
       
   907 	_LIT(KTestString, "Abcde");
       
   908 	
       
   909 	//anti-aliased
       
   910 	testFontSpec.iHeight = fontsizes[0];
       
   911 	refFontSpec.iHeight = fontsizes[0];
       
   912 	refFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
       
   913 	User::LeaveIfError(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)testFont,testFontSpec));
       
   914 	iGc->UseFont(testFont);
       
   915 	iGc->DrawText(KTestString, leftMidPoint);
       
   916 	User::LeaveIfError(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)refFont,refFontSpec));
       
   917 	iGc->UseFont(refFont);
       
   918 	iGc->DrawText(KTestString, rightMidPoint);
       
   919 	TEST(iBitmapDevice->RectCompare(TRect(0,0,KScreenWidth>>1,KScreenHeight), *iBitmapDevice, TRect(KScreenWidth>>1,0,KScreenWidth,KScreenHeight)));
       
   920 	iBitmapDevice->ReleaseFont(testFont);
       
   921 	iBitmapDevice->ReleaseFont(refFont);
       
   922 	
       
   923 	//monochrome
       
   924 	iGc->Clear();
       
   925 	testFontSpec.iHeight = fontsizes[1];
       
   926 	refFontSpec.iHeight = fontsizes[1];
       
   927 	refFontSpec.iFontStyle.SetBitmapType(EMonochromeGlyphBitmap);
       
   928 	User::LeaveIfError(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)testFont,testFontSpec));
       
   929 	iGc->UseFont(testFont);
       
   930 	iGc->DrawText(KTestString, leftMidPoint);
       
   931 	User::LeaveIfError(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)refFont,refFontSpec));
       
   932 	iGc->UseFont(refFont);
       
   933 	iGc->DrawText(KTestString, rightMidPoint);
       
   934 	TEST(iBitmapDevice->RectCompare(TRect(0,0,KScreenWidth>>1,KScreenHeight), *iBitmapDevice, TRect(KScreenWidth>>1,0,KScreenWidth,KScreenHeight)));
       
   935 	iBitmapDevice->ReleaseFont(testFont);
       
   936 	iBitmapDevice->ReleaseFont(refFont);
       
   937 	
       
   938 	//anti-aliased
       
   939 	iGc->Clear();
       
   940 	testFontSpec.iHeight = fontsizes[2];
       
   941 	refFontSpec.iHeight = fontsizes[2];
       
   942 	refFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
       
   943 	User::LeaveIfError(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)testFont,testFontSpec));
       
   944 	iGc->UseFont(testFont);
       
   945 	iGc->DrawText(KTestString, leftMidPoint);
       
   946 	User::LeaveIfError(iBitmapDevice->GetNearestFontToDesignHeightInPixels((CFont*&)refFont,refFontSpec));
       
   947 	iGc->UseFont(refFont);
       
   948 	iGc->DrawText(KTestString, rightMidPoint);
       
   949 	TEST(iBitmapDevice->RectCompare(TRect(0,0,KScreenWidth>>1,KScreenHeight), *iBitmapDevice, TRect(KScreenWidth>>1,0,KScreenWidth,KScreenHeight)));
       
   950 	iBitmapDevice->ReleaseFont(testFont);
       
   951 	iBitmapDevice->ReleaseFont(refFont);
       
   952 	}
       
   953 /**
       
   954 Sets the fontspec and gc attributes according to the flags set in STestFontParameters for the test.
       
   955 Before setting gc attributes it is cleared and reset.
       
   956 @param aFontSpec holds all effective font settings
       
   957 @param aSettings holds the flags for setting the fontspec and gc
       
   958 @param aFontIndex the fonts index of KFontFace to be set as typeface
       
   959 @param aSetEffects ETrue will set the effects on in fontspec if their flags are enabled. By default it is ETrue.
       
   960 @param aSetColors ETrue will set the colours in gc from STestFontParameters. By default it is EFalse.
       
   961 */
       
   962 void CTOutlineAndShadowFonts::PrepareTestEnvironment(TFontSpec &aFontSpec, const STestFontParameters &aSettings, const TInt aFontIndex, TBool aSetEffects, TBool aSetColors)
       
   963 	{
       
   964 	//Set the typeface from the font face array
       
   965 	aFontSpec.iTypeface.iName = KFontFace[aFontIndex];
       
   966 	aFontSpec.iHeight = KHeight;
       
   967 
       
   968 	//Set the effects on if any of flags for the effects are set in aSettings and aSetEffects is ETrue
       
   969 	if(aSetEffects)
       
   970 		{
       
   971 		aFontSpec.iFontStyle.SetEffects(FontEffect::EDropShadow, EDropShadowOn & aSettings.fSpecAndGcSettings);
       
   972 		aFontSpec.iFontStyle.SetEffects(FontEffect::EOutline, EOutlineOn & aSettings.fSpecAndGcSettings);
       
   973 		aFontSpec.iFontStyle.SetEffects(FontEffect::ESoftEdge, ESoftEdgeOn & aSettings.fSpecAndGcSettings);
       
   974 		aFontSpec.iFontStyle.SetEffects(FontEffect::EAlgorithmicBold, EAlgorithmicBoldOn & aSettings.fSpecAndGcSettings);
       
   975 		}
       
   976 
       
   977 	iGc->Reset();
       
   978 	iGc->Clear();
       
   979 	iGc->SetStrikethroughStyle((EIsStrikethroughOn & aSettings.fSpecAndGcSettings) ? EStrikethroughOn : EStrikethroughOff);
       
   980 	iGc->SetUnderlineStyle((EIsUnderlineOn & aSettings.fSpecAndGcSettings) ? EUnderlineOn : EUnderlineOff);
       
   981 
       
   982 	//Set the glyph bitmap type
       
   983 	if(ESetMonochromeGlyphBitmap & aSettings.fSpecAndGcSettings)
       
   984 		{
       
   985 		aFontSpec.iFontStyle.SetBitmapType(EMonochromeGlyphBitmap);
       
   986 		}
       
   987 	else if(ESetAntiAliasedGlyphBitmap & aSettings.fSpecAndGcSettings)
       
   988 		{
       
   989 		aFontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
       
   990 		}
       
   991 
       
   992 	//Set the colours in gc if asked for
       
   993 	if(aSetColors)
       
   994 		{
       
   995 		iGc->SetBrushColor(aSettings.brushColor);
       
   996 		iGc->SetPenColor(aSettings.penColor);
       
   997 		iGc->SetShadowColor(aSettings.shadowColor);
       
   998 		}
       
   999 	}
       
  1000 
       
  1001 void CTOutlineAndShadowFonts::RunTestCaseL(TInt aCurTestCase)
       
  1002 	{
       
  1003 		((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
       
  1004 	switch (aCurTestCase)
       
  1005 		{
       
  1006 		case 1:
       
  1007 			{
       
  1008 /**
       
  1009 @SYMTestCaseID GRAPHICS-BITGDI-OUTLINESHA-0007
       
  1010 */
       
  1011 			((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0007"));
       
  1012 			CheckMonoTypeInstalledL();
       
  1013 			break;
       
  1014 			}
       
  1015 		case 2:
       
  1016 			{
       
  1017 			((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0008"));
       
  1018 			TestOutlineandShadowFontsMetricsL();
       
  1019 			break;
       
  1020 			}
       
  1021 		case 3:
       
  1022 			{
       
  1023 			((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0009"));
       
  1024 			TestOutlinePenAndShadowColorL();
       
  1025 			break;
       
  1026 			}
       
  1027 		case 4:
       
  1028 			{
       
  1029 			((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0010"));
       
  1030 			TestDrawTextWithOutlineAndShadowL();
       
  1031 			break;
       
  1032 			}
       
  1033 		case 5:
       
  1034 			{
       
  1035 			((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0011"));
       
  1036 			TestDrawTextWithStrikeThroughL();
       
  1037 			break;
       
  1038 			}
       
  1039 		case 6:
       
  1040 			{
       
  1041 			((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0012"));
       
  1042 			NegativeRastTestL();
       
  1043 			break;
       
  1044 			}
       
  1045 		case 7:
       
  1046 			{
       
  1047 			((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0013"));
       
  1048 			TestCheckBitmapTypesL();
       
  1049 			break;
       
  1050 			}
       
  1051 		case 8:
       
  1052 			{
       
  1053 			((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0015"));
       
  1054 			TestAntiAliasedOrMonochromeGlyphBitmapL();
       
  1055 			break;
       
  1056 			}
       
  1057 		case 9:
       
  1058 			{
       
  1059 			((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-OUTLINESHA-0014"));
       
  1060 			TestOOML();
       
  1061 			break;
       
  1062 			}
       
  1063 		default:
       
  1064 			{
       
  1065 			((CTOutlineAndShadowFontsStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
  1066 			((CTOutlineAndShadowFontsStep*)iStep)->CloseTMSGraphicsStep();
       
  1067 			TestComplete();
       
  1068 			break;
       
  1069 			}
       
  1070 		}
       
  1071 		((CTOutlineAndShadowFontsStep*)iStep)->RecordTestResultL();
       
  1072 	}
       
  1073 
       
  1074 //--------------
       
  1075 __CONSTRUCT_STEP__(OutlineAndShadowFonts)