1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicsdeviceinterface/directgdi/test/tglyphimagecache.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1084 @@
1.4 +// Copyright (c) 2007-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 +// This test is designed to run in environment with monotype font support.
1.18 +// To set up environment launch ityperast.cmd from epoc32\winscw\, and
1.19 +// then follow instruction on the screen.
1.20 +//
1.21 +//
1.22 +
1.23 +#include "tglyphimagecache.h"
1.24 +#include <graphics/directgdiengine.h>
1.25 +#include <e32base.h>
1.26 +#include <VG/openvg.h>
1.27 +
1.28 +// The size of the target in pixels to use for these tests
1.29 +const TSize KGlyphCacheWindowSize(400, 400);
1.30 +
1.31 +enum TFontParam
1.32 + {
1.33 + ENormal,
1.34 + EUnderline = 0x1,
1.35 + EStrikeThrough = 0x2,
1.36 + EBold = 0x4,
1.37 + EUnderlineBold = 0x5,
1.38 + EItalic = 0x8,
1.39 + EItalicStrikeThrough = 0xa,
1.40 + };
1.41 +
1.42 +class TFontType
1.43 + {
1.44 +public:
1.45 + TInt iFontSize;
1.46 + TFontParam iFontParam;
1.47 + };
1.48 +
1.49 +LOCAL_C void CleanCache(TAny* aPtr)
1.50 + {
1.51 + MFontGlyphImageStorage* glyphImageStorage = reinterpret_cast<MFontGlyphImageStorage*> (aPtr);
1.52 + glyphImageStorage->CleanGlyphImageCache();
1.53 + }
1.54 +
1.55 +CTGlyphImageCache::CTGlyphImageCache()
1.56 + {
1.57 + SetTestStepName(KTGlyphImageCacheStep);
1.58 + }
1.59 +
1.60 +CTGlyphImageCache::~CTGlyphImageCache()
1.61 + {
1.62 + }
1.63 +
1.64 +/**
1.65 +@SYMTestCaseID
1.66 + GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0001
1.67 +
1.68 +@SYMPREQ
1.69 + PREQ39
1.70 +
1.71 +@SYMREQ
1.72 + REQ9195
1.73 + REQ9201
1.74 + REQ9202
1.75 + REQ9222
1.76 + REQ9223
1.77 + REQ9236
1.78 + REQ9237
1.79 +
1.80 +@SYMTestCaseDesc
1.81 + Test requests Glyph Image elements from storage according their Glyph Key.
1.82 +
1.83 +@SYMTestStatus
1.84 + Implemented
1.85 +
1.86 +@SYMTestPriority
1.87 + High
1.88 +
1.89 +@SYMTestActions
1.90 + Create Font Image Storage. In the cycle request aGlyph Image entry for a particular Glyph
1.91 + code and a font ID.
1.92 + Delete Glyph Storage.
1.93 +
1.94 +@SYMTestExpectedResults
1.95 + GlyphImage function must succeed; foreground, shadow and outlined images (if applicable) must be created
1.96 +*/
1.97 +void CTGlyphImageCache::TestRetrieveEntryL(MFontGlyphImageStorage* aGlyphStorage, TGlyphBitmapType aGlyphType)
1.98 + {
1.99 + if(!aGlyphStorage)
1.100 + return;
1.101 + _LIT(KTestName, "GlyphCache_RetrieveEntry");
1.102 + if(!iRunningOomTests)
1.103 + {
1.104 + INFO_PRINTF1(KTestName);
1.105 + }
1.106 +
1.107 + TSize size(20, 30);
1.108 + TInt bufferLength = size.iWidth * size.iHeight;
1.109 + TUint8* buffer = (TUint8*)User::AllocL(bufferLength);
1.110 + CleanupStack::PushL(buffer);
1.111 + if(aGlyphType == EMonochromeGlyphBitmap)
1.112 + {//to make decoding mechanizm work properly we need to fill the buffer
1.113 + Mem::Fill(buffer, bufferLength, 0x1);
1.114 + }
1.115 +
1.116 + TInt fontListId[] =
1.117 + {
1.118 + 1, 5, 3, 5
1.119 + };
1.120 + TInt numFont = sizeof(fontListId) / sizeof(fontListId[0]);
1.121 + TUint charCodeList[] =
1.122 + {
1.123 + 1, 2, 3, 2, 3,
1.124 + };
1.125 + TInt numGlyphCode = sizeof(charCodeList) / sizeof(charCodeList[0]);
1.126 +
1.127 + for(TInt jj = 0; jj < numFont; jj++)
1.128 + {
1.129 + TInt fontId = fontListId[jj];
1.130 + for(TInt ii = 0; ii < numGlyphCode; ii++)
1.131 + {
1.132 + TChar glyphCode = TChar(charCodeList[ii]);
1.133 + VGImage foregroundImg = VG_INVALID_HANDLE;
1.134 + VGImage shadowImg = VG_INVALID_HANDLE;
1.135 + VGImage outlineImg = VG_INVALID_HANDLE;
1.136 + TBool res = aGlyphStorage->GlyphImage(fontId, glyphCode, aGlyphType, buffer, size, &foregroundImg, &shadowImg, &outlineImg);
1.137 + TESTNOERROR(res);
1.138 + if(res != KErrNone)
1.139 + {
1.140 + User::Leave(res);
1.141 + }
1.142 + else
1.143 + {
1.144 + TEST(foregroundImg);
1.145 + if(aGlyphType == EFourColourBlendGlyphBitmap)
1.146 + {
1.147 + TEST(shadowImg);
1.148 + TEST(outlineImg);
1.149 + }
1.150 + }
1.151 + }
1.152 + }
1.153 + CleanupStack::PopAndDestroy(buffer);
1.154 + }
1.155 +
1.156 +/**
1.157 +@SYMTestCaseID
1.158 + GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0002
1.159 +
1.160 +@SYMPREQ
1.161 + PREQ39
1.162 +
1.163 +@SYMREQ
1.164 + REQ9195
1.165 + REQ9201
1.166 + REQ9202
1.167 + REQ9222
1.168 + REQ9223
1.169 + REQ9236
1.170 + REQ9237
1.171 +
1.172 +@SYMTestCaseDesc
1.173 + Drawing monochrome, anti-aliased and four colour fonts with different styles
1.174 +
1.175 +@SYMTestStatus
1.176 + Implemented
1.177 +
1.178 +@SYMTestPriority
1.179 + High
1.180 +
1.181 +@SYMTestActions
1.182 + Text is output with different effects (strikethrough, underline) and orientation
1.183 + (horizontal, vertical up, vertical down) and at different sizes and positions.
1.184 + Clip region is also specified.
1.185 +
1.186 +@SYMTestExpectedResults
1.187 + Test and reference images must match
1.188 +*/
1.189 +void CTGlyphImageCache::TestDrawGlyphL(MFontGlyphImageStorage* aGlyphStorage, TGlyphBitmapType aGlyphBitmapType, DrawTextDirection aDirection, DrawTextAdjustment aDrawAdjustment, TBool aClipText)
1.190 + {
1.191 + _LIT(KTestNameTemplate, "DrawGlyph%S_Dir%d_Clip%d_Adjust%d");
1.192 + TBuf<128> testName;
1.193 + _LIT(KTextOutput, "Hello world! Hello world! Hello world! Hello world! Hello world! Hello world!");
1.194 +
1.195 + switch(aGlyphBitmapType)
1.196 + {
1.197 + case EMonochromeGlyphBitmap:
1.198 + _LIT(KMonochromeName, "Monochrome");
1.199 + testName.Format(KTestNameTemplate, &KMonochromeName, aDirection, aClipText, aDrawAdjustment);
1.200 + break;
1.201 + case EAntiAliasedGlyphBitmap:
1.202 + _LIT(KAntiAliasedName, "AntiAliased");
1.203 + testName.Format(KTestNameTemplate, &KAntiAliasedName, aDirection, aClipText, aDrawAdjustment);
1.204 + break;
1.205 + case EFourColourBlendGlyphBitmap:
1.206 + _LIT(KFourColourName, "FourColour");
1.207 + testName.Format(KTestNameTemplate, &KFourColourName, aDirection, aClipText, aDrawAdjustment);
1.208 + break;
1.209 + default:
1.210 + User::Leave(KErrNotSupported);
1.211 + break;
1.212 + }
1.213 +
1.214 + if(!iRunningOomTests)
1.215 + {
1.216 + INFO_PRINTF1(testName);
1.217 + }
1.218 +
1.219 + ResetGc();
1.220 + _LIT(KTestFontTypefaceName,"DejaVu Sans Condensed");
1.221 + const TFontType fontType[] =
1.222 + {
1.223 + 18, EStrikeThrough, 48, EUnderline, 16, EItalic, 78, EItalicStrikeThrough,
1.224 +
1.225 + 18, EStrikeThrough, 48, EUnderlineBold, 16, ENormal, 78, EStrikeThrough, 78, EBold,
1.226 + };
1.227 +
1.228 + TPoint pt(5, 5);
1.229 + TInt *coord = & (pt.iY);
1.230 +
1.231 + TSize size = iGdiTarget->SizeInPixels();
1.232 + TRect rect = size;
1.233 + rect.Shrink(20, 5);
1.234 + RRegion region(rect);
1.235 + TRect rect1;
1.236 + if(aDirection == EDrawTextHorizontal)
1.237 + {
1.238 + rect1 = TRect(size.iWidth / 2 - 40, 40, size.iWidth / 2 + 40, size.iHeight - 40);
1.239 + }
1.240 + else
1.241 + {
1.242 + rect1 = TRect(20, size.iHeight / 2 - 40, size.iWidth - 20, size.iHeight / 2 + 40);
1.243 + }
1.244 + region.SubRect(rect1);
1.245 +
1.246 + if(aDirection == EDrawTextVerticalUp || aDirection == EDrawTextVerticalDown)
1.247 + {
1.248 + if(aDirection == EDrawTextVerticalUp)
1.249 + {
1.250 + pt.iY = size.iHeight - 5;
1.251 + }
1.252 + coord = &(pt.iX);
1.253 + }
1.254 +
1.255 + TInt arraySize = sizeof(fontType) / sizeof(fontType[0]);
1.256 +
1.257 + for(TInt ii = 0; ii < arraySize; ii++)
1.258 + {
1.259 + CFont *font = NULL;
1.260 + TFontSpec fspec(KTestFontTypefaceName, fontType[ii].iFontSize);
1.261 + fspec.iFontStyle.SetBitmapType(aGlyphBitmapType);
1.262 +
1.263 + iGc->Reset();
1.264 +
1.265 + if(aClipText)
1.266 + {
1.267 + iGc->SetClippingRegion(region);
1.268 + }
1.269 +
1.270 + if(aGlyphBitmapType == EFourColourBlendGlyphBitmap)
1.271 + {
1.272 + fspec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
1.273 + fspec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue);
1.274 + fspec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue);
1.275 + TRgb shadowColor = TRgb(0, 0, 255);
1.276 + iGc->SetTextShadowColor(shadowColor);
1.277 + TEST(shadowColor == iGc->TextShadowColor());
1.278 + iGc->SetBrushColor(TRgb(255, 0, 0));
1.279 + TEST(TRgb(255, 0, 0) == iGc->BrushColor());
1.280 + }
1.281 + else
1.282 + {
1.283 + iGc->SetBrushStyle(DirectGdi::ENullBrush);
1.284 + iGc->SetPenStyle(DirectGdi::ESolidPen);
1.285 + }
1.286 + iGc->SetPenColor(TRgb(0, 255, 0));
1.287 + if(fontType[ii].iFontParam & EItalic)
1.288 + {
1.289 + fspec.iFontStyle.SetPosture(EPostureItalic);
1.290 + }
1.291 + if(fontType[ii].iFontParam & EBold)
1.292 + {
1.293 + fspec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
1.294 + }
1.295 +
1.296 + User::LeaveIfError(iFontStore->GetNearestFontToDesignHeightInPixels((CFont*&) font, fspec));
1.297 + if(iUseDirectGdi)
1.298 + {
1.299 + if(ii == 2)
1.300 + {
1.301 + iGc->SetFontNoDuplicate(font);
1.302 + (reinterpret_cast <CTestDirectGdiContext*> (iGc))->NoJustifyAutoUpdate();
1.303 + }
1.304 + else
1.305 + {
1.306 + iGc->SetFont(font);
1.307 + iGc->SetFontNoDuplicate(font);//shoudn't have any impact
1.308 + (reinterpret_cast <CTestDirectGdiContext*> (iGc))->SetJustifyAutoUpdate();
1.309 + }
1.310 + }
1.311 + else
1.312 + {
1.313 + iGc->SetFont(font);
1.314 + iGc->SetFontNoDuplicate(font);//shoudn't have any impact
1.315 + }
1.316 + TEST(iGc->HasFont());
1.317 +
1.318 + TFontSpec fontSpec = font->FontSpecInTwips();
1.319 + TGlyphBitmapType glyphBitmapType = fontSpec.iFontStyle.BitmapType();
1.320 +
1.321 + TEST(glyphBitmapType == aGlyphBitmapType);
1.322 + if(fontType[ii].iFontParam & EUnderline)
1.323 + {
1.324 + iGc->SetUnderlineStyle(DirectGdi::EUnderlineOn);
1.325 + }
1.326 + else if(fontType[ii].iFontParam & EStrikeThrough)
1.327 + {
1.328 + iGc->SetStrikethroughStyle(DirectGdi::EStrikethroughOn);
1.329 + }
1.330 +
1.331 + if(EDrawTextVerticalDown != aDirection)
1.332 + {
1.333 + *coord += font->HeightInPixels() + 5;
1.334 + }
1.335 +
1.336 + if(aGlyphStorage && (ii == 0) && (arraySize > 1))
1.337 + {
1.338 + aGlyphStorage->CleanGlyphImageCache();
1.339 + aGlyphStorage->EnforceOOMFailure(ETrue);
1.340 + }
1.341 + DrawText(KTextOutput, pt, aDirection, aDrawAdjustment, ii == 1);
1.342 + if(aGlyphStorage)
1.343 + {
1.344 + aGlyphStorage->EnforceOOMFailure(EFalse);
1.345 + }
1.346 +
1.347 + if(EDrawTextVerticalDown == aDirection)
1.348 + {
1.349 + *coord += font->HeightInPixels() + 5;
1.350 + }
1.351 +
1.352 + if(fontType[ii].iFontParam == ENormal)
1.353 + {
1.354 + iGc->SetUnderlineStyle(DirectGdi::EUnderlineOff);
1.355 + iGc->SetStrikethroughStyle(DirectGdi::EStrikethroughOff);
1.356 + }
1.357 + iGc->ResetFont();
1.358 + iFontStore->ReleaseFont(font);
1.359 +
1.360 + TEST(!iGc->HasFont());
1.361 + }
1.362 + region.Close();
1.363 + if(aClipText)
1.364 + {
1.365 + iGc->ResetClippingRegion();
1.366 + }
1.367 +
1.368 + // Write the output to file.
1.369 + //
1.370 + TESTNOERROR(WriteTargetOutput(iTestParams, testName));
1.371 + }
1.372 +
1.373 +/**
1.374 +@SYMTestCaseID
1.375 + GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0003
1.376 +
1.377 +@SYMPREQ
1.378 + PREQ39
1.379 +
1.380 +@SYMREQ
1.381 + REQ9195
1.382 + REQ9201
1.383 + REQ9202
1.384 + REQ9222
1.385 + REQ9223
1.386 + REQ9236
1.387 + REQ9237
1.388 +
1.389 +@SYMTestCaseDesc
1.390 + Filling up the glyph image cache
1.391 +
1.392 +@SYMTestStatus
1.393 + Implemented
1.394 +
1.395 +@SYMTestPriority
1.396 + High
1.397 +
1.398 +@SYMTestActions
1.399 + 1. Fill glyph image storage with the same font but different glyphs until it exceeds its limit and resets the cache.
1.400 + Repeat this operation for other glyph types
1.401 +
1.402 + 2. Fill glyph image storage with different font and different glyph codes
1.403 +
1.404 +@SYMTestExpectedResults
1.405 + Check that Glyph cache storage increments cache size correctly and deletes the least
1.406 + usable tree.
1.407 +*/
1.408 +void CTGlyphImageCache::FillUpCacheL(MFontGlyphImageStorage* aGlyphStorage)
1.409 + {
1.410 + if(!aGlyphStorage)
1.411 + return;
1.412 +
1.413 + aGlyphStorage->CleanGlyphImageCache();
1.414 + TBuf<128> testName;
1.415 + _LIT(KTestName, "GlyphCache_FillUpCache");
1.416 + if(!iRunningOomTests)
1.417 + {
1.418 + INFO_PRINTF1(KTestName);
1.419 + }
1.420 +
1.421 + const TSize size(12, 16);
1.422 + TUint8* buffer = (TUint8*)User::AllocL(size.iWidth * size.iHeight);
1.423 + CleanupStack::PushL(buffer);
1.424 + TInt fontId = 10;
1.425 + TGlyphBitmapType glyphTypeList[] =
1.426 + {
1.427 + EMonochromeGlyphBitmap,
1.428 + EAntiAliasedGlyphBitmap,
1.429 + EFourColourBlendGlyphBitmap,
1.430 + };
1.431 + const TInt numGlyphType = sizeof(glyphTypeList) / sizeof(glyphTypeList[0]);
1.432 + TESTL(aGlyphStorage->GlyphCacheSize() == 0);
1.433 +
1.434 + TInt glyphSizeInByte = 0;
1.435 + TInt expectedSize = 0;
1.436 + TUint32 glyphCode = 1;
1.437 +
1.438 + VGImage foregroundImg = VG_INVALID_HANDLE;
1.439 + VGImage shadowImg = VG_INVALID_HANDLE;
1.440 + VGImage outlineImg = VG_INVALID_HANDLE;
1.441 + for(TInt ii = 0; ii < numGlyphType; ii++)
1.442 + {
1.443 + TGlyphBitmapType glyphType = glyphTypeList[ii];
1.444 + //calculate the actual size of the glyph
1.445 + glyphSizeInByte = GlyphImageSizeInByte(glyphType, size);
1.446 +
1.447 + TUint maxGlyphSize = aGlyphStorage->MaxGlyphCacheSize() + glyphSizeInByte;
1.448 + do
1.449 + {
1.450 + TEST(expectedSize == aGlyphStorage->GlyphCacheSize());
1.451 + TBool res = aGlyphStorage->GlyphImage(fontId, TChar(glyphCode), (TGlyphBitmapType)glyphType, buffer, size, &foregroundImg, &shadowImg, &outlineImg);
1.452 + TESTNOERRORL(res);
1.453 + glyphCode++;
1.454 + expectedSize+= glyphSizeInByte;
1.455 + foregroundImg = VG_INVALID_HANDLE;
1.456 + shadowImg = VG_INVALID_HANDLE;
1.457 + outlineImg = VG_INVALID_HANDLE;
1.458 + }while(expectedSize <= maxGlyphSize);
1.459 + glyphCode = 1;
1.460 + expectedSize = 0;
1.461 + TEST(glyphSizeInByte == aGlyphStorage->GlyphCacheSize());
1.462 + aGlyphStorage->CleanGlyphImageCache();
1.463 + }
1.464 +
1.465 + //now try to filling cache with different fonts and check that last usable font wont be removed
1.466 + TUint maxGlyphSize = aGlyphStorage->MaxGlyphCacheSize();
1.467 + glyphSizeInByte = GlyphImageSizeInByte(EMonochromeGlyphBitmap, size);
1.468 + do
1.469 + {
1.470 + TEST(expectedSize == aGlyphStorage->GlyphCacheSize());
1.471 + TBool res = aGlyphStorage->GlyphImage(fontId, TChar(glyphCode), EMonochromeGlyphBitmap, buffer, size, &foregroundImg, &shadowImg, &outlineImg);
1.472 + TESTNOERRORL(res);
1.473 + glyphCode++;
1.474 + expectedSize+= glyphSizeInByte;
1.475 + foregroundImg = VG_INVALID_HANDLE;
1.476 + shadowImg = VG_INVALID_HANDLE;
1.477 + outlineImg = VG_INVALID_HANDLE;
1.478 + }while(expectedSize <= maxGlyphSize);
1.479 +
1.480 + fontId += 10;
1.481 + glyphCode = 1;
1.482 +
1.483 + TBool res = aGlyphStorage->GlyphImage(fontId, TChar(glyphCode), EMonochromeGlyphBitmap, buffer, size, &foregroundImg, &shadowImg, &outlineImg);
1.484 + TEST(glyphSizeInByte == aGlyphStorage->GlyphCacheSize());
1.485 + TESTNOERROR(res);
1.486 +
1.487 + RArray<TUint32> listFontId;
1.488 + aGlyphStorage->FontIdInOrder(listFontId);
1.489 + TESTL(listFontId.Count() == 1);
1.490 + TEST(listFontId[0] == fontId);
1.491 + listFontId.Reset();
1.492 +
1.493 + CleanupStack::PopAndDestroy(buffer);
1.494 + }
1.495 +
1.496 +/**
1.497 +@SYMTestCaseID
1.498 + GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0004
1.499 +
1.500 +@SYMPREQ
1.501 + PREQ39
1.502 +
1.503 +@SYMREQ
1.504 + REQ9195
1.505 + REQ9201
1.506 + REQ9202
1.507 + REQ9222
1.508 + REQ9223
1.509 + REQ9236
1.510 + REQ9237
1.511 +
1.512 +@SYMTestCaseDesc
1.513 + Tests filling the glyph image cache with different glyph images
1.514 +
1.515 +@SYMTestStatus
1.516 + Implemented
1.517 +
1.518 +@SYMTestPriority
1.519 + High
1.520 +
1.521 +@SYMTestActions
1.522 + Specify glyphs which correspond to different fonts, glyph codes.
1.523 + Request related VGImages.
1.524 + Test the cache size is correct after each operation.
1.525 + Get the driver's MDirectGdiDriverCacheSize interface.
1.526 + Attempt to set the maximum size of the glyph cache to a size smaller than
1.527 + the existing cache size.
1.528 + Attempt to set the maximum size of the glyph cache to a size the same as
1.529 + the existing cache size.
1.530 +
1.531 +
1.532 +@SYMTestExpectedResults
1.533 + Obtained glyph code and cache size must be correct each time.
1.534 + Setting the maximum glyph cache size to a smaller size than the existing cache
1.535 + size should fail with error KErrArgument.
1.536 + Setting the maximum glyph cache size to a size the same as the existing cache
1.537 + size should pass.
1.538 +*/
1.539 +void CTGlyphImageCache::FillCacheL(MFontGlyphImageStorage* aGlyphStorage)
1.540 + {
1.541 + ASSERT(aGlyphStorage);
1.542 +
1.543 + aGlyphStorage->CleanGlyphImageCache();
1.544 + TBuf<128> testName;
1.545 + _LIT(KTestName, "GlyphCache_FillCache");
1.546 + if(!iRunningOomTests)
1.547 + {
1.548 + INFO_PRINTF1(KTestName);
1.549 + }
1.550 +
1.551 + const TSize smallFontSize = TSize(12, 16);
1.552 + const TSize smallFont1Size = TSize(10, 14);
1.553 + const TSize bigFontSize = TSize(18, 24);
1.554 + const TSize bigFont1Size = TSize(20, 26);
1.555 + const TInt smallFontId = 10;
1.556 + const TInt bigFontId = 20;
1.557 + const TInt smallFont1Id = 30;
1.558 + const TInt bigFont1Id = 40;
1.559 + VGImage foregroundImg = VG_INVALID_HANDLE;
1.560 + VGImage shadowImg = VG_INVALID_HANDLE;
1.561 + VGImage outlineImg = VG_INVALID_HANDLE;
1.562 +
1.563 + TUint8* buffer = (TUint8*)User::AllocL(bigFontSize.iWidth * bigFontSize.iHeight);
1.564 + CleanupStack::PushL(buffer);
1.565 + TESTL(aGlyphStorage->GlyphCacheSize() == 0);
1.566 +
1.567 + TInt expectedCacheSize = 0;
1.568 + TChar glyphCode = TChar(1);
1.569 + TGlyphBitmapType glyphType = EMonochromeGlyphBitmap;
1.570 + TBool res = aGlyphStorage->GlyphImage(smallFontId, glyphCode, glyphType, buffer, smallFontSize, &foregroundImg, &shadowImg, &outlineImg);
1.571 + TESTNOERRORL(res);
1.572 + expectedCacheSize = GlyphImageSizeInByte(glyphType, smallFontSize);
1.573 + TEST(expectedCacheSize == aGlyphStorage->GlyphCacheSize());
1.574 +
1.575 + //try to retrieve the same glyph
1.576 + res = aGlyphStorage->GlyphImage(smallFontId, glyphCode, glyphType, buffer, smallFontSize, &foregroundImg, &shadowImg, &outlineImg);
1.577 + TESTNOERRORL(res);
1.578 + //the size should be the same
1.579 + TEST(expectedCacheSize == aGlyphStorage->GlyphCacheSize());
1.580 +
1.581 + //now retrieving the same glyphCode but for the different font
1.582 + res = aGlyphStorage->GlyphImage(bigFontId, glyphCode, glyphType, buffer, bigFontSize, &foregroundImg, &shadowImg, &outlineImg);
1.583 + TESTNOERRORL(res);
1.584 + expectedCacheSize += GlyphImageSizeInByte(glyphType, bigFontSize);
1.585 + TEST(expectedCacheSize == aGlyphStorage->GlyphCacheSize());
1.586 +
1.587 + //last font but different glyphCode
1.588 + glyphCode = TChar(2);
1.589 + res = aGlyphStorage->GlyphImage(bigFontId, glyphCode, glyphType, buffer, bigFontSize, &foregroundImg, &shadowImg, &outlineImg);
1.590 + TESTNOERRORL(res);
1.591 + expectedCacheSize += GlyphImageSizeInByte(glyphType, bigFontSize);
1.592 + TEST(expectedCacheSize == aGlyphStorage->GlyphCacheSize());
1.593 +
1.594 + //small font and last glyphCode
1.595 + res = aGlyphStorage->GlyphImage(smallFontId, glyphCode, glyphType, buffer, smallFontSize, &foregroundImg, &shadowImg, &outlineImg);
1.596 + TESTNOERRORL(res);
1.597 + expectedCacheSize += GlyphImageSizeInByte(glyphType, smallFontSize);
1.598 + TEST(expectedCacheSize == aGlyphStorage->GlyphCacheSize());
1.599 +
1.600 + //now change the type
1.601 + glyphType = EAntiAliasedGlyphBitmap;
1.602 + res = aGlyphStorage->GlyphImage(smallFont1Id, glyphCode, glyphType, buffer, smallFont1Size, &foregroundImg, &shadowImg, &outlineImg);
1.603 + TESTNOERRORL(res);
1.604 + expectedCacheSize += GlyphImageSizeInByte(glyphType, smallFont1Size);
1.605 + TEST(expectedCacheSize == aGlyphStorage->GlyphCacheSize());
1.606 + //try again
1.607 + res = aGlyphStorage->GlyphImage(smallFont1Id, glyphCode, glyphType, buffer, smallFont1Size, &foregroundImg, &shadowImg, &outlineImg);
1.608 + TESTNOERRORL(res);
1.609 + TEST(expectedCacheSize == aGlyphStorage->GlyphCacheSize());
1.610 +
1.611 + //now change the type again
1.612 + glyphType = EFourColourBlendGlyphBitmap;
1.613 + res = aGlyphStorage->GlyphImage(bigFont1Id, glyphCode, glyphType, buffer, bigFont1Size, &foregroundImg, &shadowImg, &outlineImg);
1.614 + TESTNOERRORL(res);
1.615 + expectedCacheSize += GlyphImageSizeInByte(glyphType, bigFont1Size);
1.616 + TEST(expectedCacheSize == aGlyphStorage->GlyphCacheSize());
1.617 +
1.618 + //using initial value.
1.619 + glyphType = EMonochromeGlyphBitmap;
1.620 + glyphCode = TChar(1);
1.621 + res = aGlyphStorage->GlyphImage(smallFontId, glyphCode, glyphType, buffer, smallFontSize, &foregroundImg, &shadowImg, &outlineImg);
1.622 + TESTNOERRORL(res);
1.623 + TEST(expectedCacheSize == aGlyphStorage->GlyphCacheSize());
1.624 +
1.625 + //get the driver's MDirectGdiDriverCacheSize extension interface and attempt
1.626 + //to set the maximum cache size to be smaller than the existing cache size
1.627 + CDirectGdiDriver* driver = CDirectGdiDriver::Static();
1.628 + TESTL(driver != NULL);
1.629 + MDirectGdiDriverCacheSize* driverCacheSize = NULL;
1.630 + res = driver->GetInterface(TUid::Uid(KDirectGdiDriverCacheSizeUid), (TAny*&)driverCacheSize);
1.631 + TESTNOERRORL(res);
1.632 + //save the original cache size
1.633 + TInt originalCacheSize = driverCacheSize->MaxGlyphCacheSize();
1.634 + //setting the cache size to a size smaller than the existing cache should fail
1.635 + res = driverCacheSize->SetMaxGlyphCacheSize(aGlyphStorage->GlyphCacheSize()-1);
1.636 + TEST(res == KErrArgument);
1.637 + //setting the cache size to the same size as the existing cache should pass
1.638 + res = driverCacheSize->SetMaxGlyphCacheSize(aGlyphStorage->GlyphCacheSize());
1.639 + TESTNOERROR(res);
1.640 + TEST(aGlyphStorage->GlyphCacheSize() == driverCacheSize->MaxGlyphCacheSize());
1.641 + //reset the original driver cache size
1.642 + res = driverCacheSize->SetMaxGlyphCacheSize(originalCacheSize);
1.643 + TESTNOERROR(res);
1.644 +
1.645 + CleanupStack::PopAndDestroy(buffer);
1.646 + }
1.647 +
1.648 +/**
1.649 +@SYMTestCaseID
1.650 + GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0005
1.651 +
1.652 +@SYMPREQ
1.653 + PREQ39
1.654 +
1.655 +@SYMREQ
1.656 + REQ9195
1.657 + REQ9201
1.658 + REQ9202
1.659 + REQ9222
1.660 + REQ9223
1.661 + REQ9236
1.662 + REQ9237
1.663 +
1.664 +@SYMTestCaseDesc
1.665 + Tests the ordering font IDs in the glyph image cache.
1.666 +
1.667 +@SYMTestStatus
1.668 + Implemented
1.669 +
1.670 +@SYMTestPriority
1.671 + High
1.672 +
1.673 +@SYMTestActions
1.674 + Request glyph images for different fonts.
1.675 +
1.676 +@SYMTestExpectedResults
1.677 + List of glyph cache trees must be arranged in order from most used to least used.
1.678 +*/
1.679 +void CTGlyphImageCache::FontListIdOrderL(MFontGlyphImageStorage* aGlyphStorage)
1.680 + {
1.681 + if(!aGlyphStorage)
1.682 + return;
1.683 +
1.684 + aGlyphStorage->CleanGlyphImageCache();
1.685 + TBuf<128> testName;
1.686 + _LIT(KTestName, "GlyphCache_FontListIdOrder");
1.687 + if(!iRunningOomTests)
1.688 + {
1.689 + INFO_PRINTF1(KTestName);
1.690 + }
1.691 +
1.692 + const TSize fontSize = TSize(12, 16);
1.693 + TUint8* buffer = (TUint8*)User::AllocL(fontSize.iWidth * fontSize.iHeight);
1.694 + CleanupStack::PushL(buffer);
1.695 +
1.696 + TChar glyphCode = TChar(10);
1.697 + TInt fontId = 10;
1.698 + VGImage foregroundImg = VG_INVALID_HANDLE;
1.699 + VGImage shadowImg = VG_INVALID_HANDLE;
1.700 + VGImage outlineImg = VG_INVALID_HANDLE;
1.701 +
1.702 + TGlyphBitmapType glyphType = EMonochromeGlyphBitmap;
1.703 + TInt res = aGlyphStorage->GlyphImage(fontId, glyphCode, glyphType, buffer, fontSize, &foregroundImg, &shadowImg, &outlineImg);
1.704 + TESTNOERRORL(res);
1.705 +
1.706 + fontId = 20;
1.707 + res = aGlyphStorage->GlyphImage(fontId, glyphCode, glyphType, buffer, fontSize, &foregroundImg, &shadowImg, &outlineImg);
1.708 + TESTNOERRORL(res);
1.709 +
1.710 + fontId = 30;
1.711 + res = aGlyphStorage->GlyphImage(fontId, glyphCode, glyphType, buffer, fontSize, &foregroundImg, &shadowImg, &outlineImg);
1.712 + TESTNOERRORL(res);
1.713 +
1.714 + RArray<TUint32> fontListId;
1.715 + res = aGlyphStorage->FontIdInOrder(fontListId);
1.716 + if(res != KErrNone)
1.717 + {
1.718 + fontListId.Reset();
1.719 + User::Leave(res);
1.720 + }
1.721 +
1.722 + TESTL(fontListId.Count() == 3);
1.723 + TEST(fontListId[0] == 30);
1.724 + TEST(fontListId[1] == 20);
1.725 + TEST(fontListId[2] == 10);
1.726 + fontListId.Reset();
1.727 +
1.728 + //call entries again to reorder font id list
1.729 + fontId = 30;
1.730 + res = aGlyphStorage->GlyphImage(fontId, glyphCode, glyphType, buffer, fontSize, &foregroundImg, &shadowImg, &outlineImg);
1.731 + TESTNOERRORL(res);
1.732 +
1.733 + fontId = 20;
1.734 + res = aGlyphStorage->GlyphImage(fontId, glyphCode, glyphType, buffer, fontSize, &foregroundImg, &shadowImg, &outlineImg);
1.735 + TESTNOERRORL(res);
1.736 +
1.737 + fontId = 40;
1.738 + res = aGlyphStorage->GlyphImage(fontId, glyphCode, glyphType, buffer, fontSize, &foregroundImg, &shadowImg, &outlineImg);
1.739 + TESTNOERRORL(res);
1.740 +
1.741 + fontId = 10;
1.742 + res = aGlyphStorage->GlyphImage(fontId, glyphCode, glyphType, buffer, fontSize, &foregroundImg, &shadowImg, &outlineImg);
1.743 + TESTNOERRORL(res);
1.744 +
1.745 + fontId = 50;
1.746 + res = aGlyphStorage->GlyphImage(fontId, glyphCode, glyphType, buffer, fontSize, &foregroundImg, &shadowImg, &outlineImg);
1.747 + TESTNOERRORL(res);
1.748 +
1.749 + res = aGlyphStorage->FontIdInOrder(fontListId);
1.750 + if(res != KErrNone)
1.751 + {
1.752 + fontListId.Reset();
1.753 + User::Leave(res);
1.754 + }
1.755 +
1.756 + TESTL(fontListId.Count() == 5);
1.757 + TEST(fontListId[0] == 50);
1.758 + TEST(fontListId[1] == 10);
1.759 + TEST(fontListId[2] == 40);
1.760 + TEST(fontListId[3] == 20);
1.761 + TEST(fontListId[4] == 30);
1.762 + fontListId.Reset();
1.763 +
1.764 + CleanupStack::PopAndDestroy(buffer);
1.765 + }
1.766 +
1.767 +/**
1.768 +@SYMTestCaseID
1.769 + GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0006
1.770 +
1.771 +@SYMPREQ
1.772 + PREQ39
1.773 +
1.774 +@SYMREQ
1.775 + REQ9195
1.776 + REQ9222
1.777 + REQ9223
1.778 + REQ9236
1.779 + REQ9237
1.780 +
1.781 +@SYMTestCaseDesc
1.782 + Test the operation of the glyph image cache when sent wrong parameters.
1.783 +
1.784 +@SYMTestStatus
1.785 + Implemented
1.786 +
1.787 +@SYMTestPriority
1.788 + High
1.789 +
1.790 +@SYMTestActions
1.791 + Test requesting of glyph images with invalid paramaters - test an invalid glyph type
1.792 + and test requesting a glyph image with zero height and one with zero width.
1.793 +
1.794 +@SYMTestExpectedResults
1.795 + The function must identify wrong arguments and return the expected error.
1.796 +*/
1.797 +void CTGlyphImageCache::WrongParameterL(MFontGlyphImageStorage* aGlyphStorage)
1.798 + {
1.799 + _LIT(KTestName, "GlyphCache_WrongParameters");
1.800 + if(!iRunningOomTests)
1.801 + {
1.802 + INFO_PRINTF1(KTestName);
1.803 + }
1.804 +
1.805 + aGlyphStorage->CleanGlyphImageCache();
1.806 +
1.807 + TChar glyphCode = TChar(10);
1.808 + TInt fontId = 10;
1.809 + VGImage foregroundImg = VG_INVALID_HANDLE;
1.810 + VGImage shadowImg = VG_INVALID_HANDLE;
1.811 + VGImage outlineImg = VG_INVALID_HANDLE;
1.812 + TSize fontSize = TSize(10, 12);
1.813 + TUint8* buffer = (TUint8*)User::AllocL(fontSize.iWidth * fontSize.iHeight);
1.814 + CleanupStack::PushL(buffer);
1.815 +
1.816 + TGlyphBitmapType glyphType = EDefaultGlyphBitmap; // unsupported
1.817 +
1.818 + TInt res = aGlyphStorage->GlyphImage(fontId, glyphCode, glyphType, buffer, fontSize, &foregroundImg, &shadowImg, &outlineImg);
1.819 + TEST(res == KErrNotSupported);
1.820 + TEST(foregroundImg == VG_INVALID_HANDLE);
1.821 + TEST(shadowImg == VG_INVALID_HANDLE);
1.822 + TEST(outlineImg == VG_INVALID_HANDLE);
1.823 +
1.824 + glyphType = EMonochromeGlyphBitmap; // supported
1.825 + res = aGlyphStorage->GlyphImage(fontId, glyphCode, glyphType, buffer, TSize(12, 0), &foregroundImg, &shadowImg, &outlineImg);
1.826 + TEST(res == KErrArgument);
1.827 + res = aGlyphStorage->GlyphImage(fontId, glyphCode, glyphType, buffer, TSize(0, 12), &foregroundImg, &shadowImg, &outlineImg);
1.828 + TEST(res == KErrArgument);
1.829 + TEST(foregroundImg == VG_INVALID_HANDLE);
1.830 + TEST(shadowImg == VG_INVALID_HANDLE);
1.831 + TEST(outlineImg == VG_INVALID_HANDLE);
1.832 +
1.833 + CleanupStack::PopAndDestroy(buffer);
1.834 + }
1.835 +
1.836 +TInt CTGlyphImageCache::GlyphImageSizeInByte(TGlyphBitmapType aGlyphType, const TSize& aSize) const
1.837 + {
1.838 + TInt glyphSizeInByte = 0;
1.839 + //calculate the actual size of the glyph
1.840 + switch(aGlyphType)
1.841 + {
1.842 + case EMonochromeGlyphBitmap:
1.843 + glyphSizeInByte = (((aSize.iWidth + 31) / 32) << 2) * aSize.iHeight;
1.844 + break;
1.845 + case EAntiAliasedGlyphBitmap:
1.846 + glyphSizeInByte = aSize.iWidth * aSize.iHeight;
1.847 + break;
1.848 + case EFourColourBlendGlyphBitmap:
1.849 + glyphSizeInByte = aSize.iWidth * aSize.iHeight;
1.850 + //we have to allocate memory for shadow and outline bitmap as well
1.851 + glyphSizeInByte *= 3;
1.852 + break;
1.853 + default :
1.854 + break;
1.855 + }
1.856 + return glyphSizeInByte;
1.857 + }
1.858 +/**
1.859 +Draws the text on the screen according its direction and alignment.
1.860 +*/
1.861 +void CTGlyphImageCache::DrawText(const TDesC& aText, const TPoint& aPt, DrawTextDirection aDirection, DrawTextAdjustment aDrawAdjustment, TBool aUpdateJustification)
1.862 + {
1.863 + const TSize size = iGdiTarget->SizeInPixels();
1.864 + TRect rect = size;
1.865 +
1.866 + if(aDirection == EDrawTextHorizontal)
1.867 + {
1.868 + switch(aDrawAdjustment)
1.869 + {
1.870 + case EDrawFromPoint:
1.871 + iGc->DrawText(aText, NULL, aPt);
1.872 + break;
1.873 + case EDrawInBox:
1.874 + iGc->SetOrigin(aPt);
1.875 + rect = TRect(-aPt, size);
1.876 + iGc->DrawText(aText, NULL, rect);
1.877 + break;
1.878 + case EDrawRightAlignment:
1.879 + rect.iTl = aPt;
1.880 + rect.iBr.iX -= 30;
1.881 + iGc->DrawText(aText, NULL, rect, 0, DirectGdi::ERight);
1.882 + break;
1.883 + }
1.884 + }
1.885 + else if ((aDirection == EDrawTextVerticalDown) || (aDirection == EDrawTextVerticalUp))
1.886 + {
1.887 + TBool up = (aDirection==EDrawTextVerticalUp);
1.888 + switch(aDrawAdjustment)
1.889 + {
1.890 + case EDrawFromPoint:
1.891 + iGc->DrawTextVertical(aText, NULL, aPt, up);
1.892 + break;
1.893 + case EDrawInBox:
1.894 + iGc->SetOrigin(aPt);
1.895 + rect = TRect(-aPt, size);
1.896 + if(aUpdateJustification)
1.897 + {
1.898 + iGc->SetCharJustification(80, aText.Length());
1.899 + iGc->UpdateJustificationVertical(aText, NULL, up);
1.900 + }
1.901 +
1.902 + iGc->DrawTextVertical(aText, NULL, rect, up);
1.903 + iGc->SetOrigin(TPoint());
1.904 + break;
1.905 + case EDrawRightAlignment:
1.906 + rect.iTl = aPt;
1.907 + rect.iBr.iY -= 30;
1.908 + iGc->DrawTextVertical(aText, NULL, rect, 0, DirectGdi::ERight);
1.909 + break;
1.910 + }
1.911 + }
1.912 + }
1.913 +
1.914 +/**
1.915 +Overrides of base class virtual
1.916 +@leave Gets system wide error code
1.917 +@return - TVerdict code
1.918 +*/
1.919 +TVerdict CTGlyphImageCache::doTestStepPreambleL()
1.920 + {
1.921 + CTDirectGdiStepBase::doTestStepPreambleL();
1.922 + return TestStepResult();
1.923 + }
1.924 +
1.925 +/**
1.926 +Overrides of base class pure virtual
1.927 +Our implementation only gets called if the base class doTestStepPreambleL() did
1.928 +not leave. That being the case, the current test result value will be EPass.
1.929 +@leave Gets system wide error code
1.930 +@return TVerdict code
1.931 +*/
1.932 +TVerdict CTGlyphImageCache::doTestStepL()
1.933 + {
1.934 + // Test for each pixel format
1.935 + TInt maxPixelFormat = iTargetPixelFormatArray.Count() - 1;
1.936 + for(TInt targetPixelFormatIndex = maxPixelFormat; targetPixelFormatIndex >= 0 ; targetPixelFormatIndex--)
1.937 + {
1.938 + iTestParams.iTargetPixelFormat = iTargetPixelFormatArray[targetPixelFormatIndex];
1.939 + SetTargetL(iTestParams.iTargetPixelFormat, EOneContextOneTarget, KGlyphCacheWindowSize);
1.940 +
1.941 + if(maxPixelFormat == targetPixelFormatIndex)
1.942 + {
1.943 + iMonotypeFont = DetectMonotypeFontL();
1.944 +
1.945 + if(!iMonotypeFont)
1.946 + {
1.947 + WARN_PRINTF1(_L("!! Due to running the test in environment without monotype fonts, some test cases will not \
1.948 +be executed! To set up environment with monotype font support, launch ityperast.cmd \
1.949 +from epoc32\\winscw\\c\\, and then follow the instruction on the screen!!"));
1.950 + }
1.951 + else
1.952 + {
1.953 + INFO_PRINTF1(_L("Monotype fonts have been detected"));
1.954 + }
1.955 + }
1.956 +
1.957 + RunTestsL();
1.958 + if(targetPixelFormatIndex == 0)
1.959 + {
1.960 + RunOomTestsL();
1.961 + }
1.962 + }
1.963 + CloseTMSGraphicsStep();
1.964 + return TestStepResult();
1.965 + }
1.966 +
1.967 +/**
1.968 +Overrides of base class pure virtual function
1.969 +Lists the tests to be run
1.970 +*/
1.971 +void CTGlyphImageCache::RunTestsL()
1.972 + {
1.973 + MFontGlyphImageStorage* glyphStorage = NULL;
1.974 + TBool testImageCache = (iUseDirectGdi && !iUseSwDirectGdi);
1.975 + if(testImageCache)
1.976 + {
1.977 + TInt err = iGc->GetInterface(TUid::Uid(KDirectGdiGetGlyphStorageUid), (TAny*&) glyphStorage);
1.978 + if(err != KErrNone)
1.979 + {
1.980 + ERR_PRINTF2(_L("Error while retrieving Glyph Storage Interface, err = %d"), err);
1.981 + TESTNOERRORL(err);
1.982 + }
1.983 + User::LeaveIfNull(glyphStorage);
1.984 + CleanupStack::PushL(TCleanupItem(CleanCache, glyphStorage));
1.985 + glyphStorage->CleanGlyphImageCache();
1.986 + }
1.987 +
1.988 + if(testImageCache)
1.989 + {
1.990 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0001"));
1.991 + TestRetrieveEntryL(glyphStorage, EAntiAliasedGlyphBitmap);
1.992 + RecordTestResultL();
1.993 + glyphStorage->CleanGlyphImageCache();
1.994 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0001"));
1.995 + TestRetrieveEntryL(glyphStorage, EFourColourBlendGlyphBitmap);
1.996 + RecordTestResultL();
1.997 + glyphStorage->CleanGlyphImageCache();
1.998 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0001"));
1.999 + TestRetrieveEntryL(glyphStorage, EMonochromeGlyphBitmap);
1.1000 + RecordTestResultL();
1.1001 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0006"));
1.1002 + WrongParameterL(glyphStorage);
1.1003 + RecordTestResultL();
1.1004 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0005"));
1.1005 + FontListIdOrderL(glyphStorage);
1.1006 + RecordTestResultL();
1.1007 + glyphStorage->CleanGlyphImageCache();
1.1008 + }
1.1009 +
1.1010 + if(!iRunningOomTests)//fonts are cached in the array, where memory won't be freed even if the font is released
1.1011 + {
1.1012 + if(testImageCache)
1.1013 + {
1.1014 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0004"));
1.1015 + FillCacheL(glyphStorage);
1.1016 + RecordTestResultL();
1.1017 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0003"));
1.1018 + FillUpCacheL(glyphStorage);
1.1019 + RecordTestResultL();
1.1020 + glyphStorage->CleanGlyphImageCache();
1.1021 + }
1.1022 + for(TInt ii = EDrawTextHorizontal; ii < EDrawTextLast; ii++)
1.1023 + {
1.1024 + for(TInt kk = EDrawFromPoint; kk <= EDrawInBox; kk++)
1.1025 + {
1.1026 + DrawTextDirection direction = (DrawTextDirection) ii;
1.1027 + DrawTextAdjustment adjustment = (DrawTextAdjustment) kk;
1.1028 +
1.1029 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0002"));
1.1030 + TestDrawGlyphL(glyphStorage, EMonochromeGlyphBitmap, direction, adjustment, EFalse);
1.1031 + RecordTestResultL();
1.1032 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0002"));
1.1033 + TestDrawGlyphL(glyphStorage, EMonochromeGlyphBitmap, direction, adjustment, ETrue);
1.1034 + RecordTestResultL();
1.1035 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0002"));
1.1036 + TestDrawGlyphL(glyphStorage, EAntiAliasedGlyphBitmap, direction, adjustment, EFalse);
1.1037 + RecordTestResultL();
1.1038 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0002"));
1.1039 + TestDrawGlyphL(glyphStorage, EAntiAliasedGlyphBitmap, direction, adjustment, ETrue);
1.1040 + RecordTestResultL();
1.1041 +
1.1042 + if(iMonotypeFont)
1.1043 + {
1.1044 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0002"));
1.1045 + TestDrawGlyphL(glyphStorage, EFourColourBlendGlyphBitmap, direction, adjustment, EFalse);
1.1046 + RecordTestResultL();
1.1047 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-GLYPHIMAGECACHE-0002"));
1.1048 + TestDrawGlyphL(glyphStorage, EFourColourBlendGlyphBitmap, direction, adjustment, ETrue);
1.1049 + RecordTestResultL();
1.1050 + }
1.1051 + }
1.1052 + }
1.1053 + }
1.1054 +
1.1055 + //next set of tests should start from clean cache to garantee consistent results
1.1056 + if(testImageCache)
1.1057 + {
1.1058 + glyphStorage->CleanGlyphImageCache();
1.1059 + CleanupStack::Pop(glyphStorage);
1.1060 + }
1.1061 + }
1.1062 +
1.1063 +/**
1.1064 +See if monotype font is installed on the platform we are running on. Monotype font is required
1.1065 +to run the glyph tests that use the glyph bitmap type EFourColourBlendGlyphBitmap to draw
1.1066 +outlined and shadowed fonts.
1.1067 +@return ETrue if monotype is installed, EFalse if it is not installed.
1.1068 + */
1.1069 +TBool CTGlyphImageCache::DetectMonotypeFontL()
1.1070 + {
1.1071 + CFont *font = NULL;
1.1072 + _LIT(KTestFontTypefaceName,"DejaVu Sans Condensed");
1.1073 + TFontSpec fspec(KTestFontTypefaceName, 12);
1.1074 + fspec.iFontStyle.SetBitmapType(EFourColourBlendGlyphBitmap);
1.1075 +
1.1076 + fspec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap);
1.1077 + fspec.iFontStyle.SetEffects(FontEffect::EOutline, ETrue);
1.1078 + fspec.iFontStyle.SetEffects(FontEffect::EDropShadow, ETrue);
1.1079 +
1.1080 + User::LeaveIfError(iFontStore->GetNearestFontToDesignHeightInPixels((CFont*&) font, fspec));
1.1081 +
1.1082 + TFontSpec fontSpec = font->FontSpecInTwips();
1.1083 + TGlyphBitmapType glyphBitmapType = fontSpec.iFontStyle.BitmapType();
1.1084 + iFontStore->ReleaseFont(font);
1.1085 +
1.1086 + return (EFourColourBlendGlyphBitmap==glyphBitmapType);
1.1087 + }