os/textandloc/fontservices/fontstore/tfs/t_linkedfontsmemory.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/fontstore/tfs/t_linkedfontsmemory.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1072 @@
     1.4 +/*
     1.5 +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#include "FNTSTD.H"
    1.23 +#include "t_linkedfontsmemory.h"
    1.24 +#include "T_LinkedFonts2.h"
    1.25 +#include "fbsmessage.h"
    1.26 +#include <hal.h>
    1.27 +#include <linkedfonts.h>
    1.28 +
    1.29 +class CTLinkedFontsMemory : public CTLinkedFonts2
    1.30 +	{
    1.31 +public:
    1.32 +	CTLinkedFontsMemory(CTestStep* aStep);
    1.33 +	~CTLinkedFontsMemory();
    1.34 +	//base class static void TestPanic(TInt aPanic);
    1.35 +protected:
    1.36 +// From CTGraphicsStep
    1.37 +	virtual void RunTestCaseL(TInt aCurTestCase);
    1.38 +private:
    1.39 +	
    1.40 +	TInt TestLinkedFontsMemory1L(TInt aTypefaces);
    1.41 +	void TestLinkedFontsMemory1L();
    1.42 +	TInt TestLinkedFontsCreateLinkedTypefacesL(const TDesC& aName,TInt aTypefaces);
    1.43 +	TInt TestLinkedFontsMemory_Part2(const TDesC& aName);
    1.44 +	void TestLinkedFontsMemory2();
    1.45 +	void TestLinkedFontsMemory3();
    1.46 +	void TestLinkedFontsMemory4();
    1.47 +	void TestMemoryUsage();
    1.48 +	
    1.49 +	void SetHeapFail(RFbsSession::THeapFailType aType, TInt aFailures);
    1.50 +	TInt HeapCount(RFbsSession::THeapFailType aType);
    1.51 +	void SetHeapReset(RFbsSession::THeapFailType aType);
    1.52 +	void SetHeapCheck(RFbsSession::THeapFailType aType);
    1.53 +	void TestCompareText();
    1.54 +	TInt FontAndBitmapServerSharedHeap();
    1.55 +	void DisplayRamInfo(const TDesC &aTextInfo) const;
    1.56 +	TBool CheckRasterizerInstalledL();
    1.57 +	};
    1.58 +
    1.59 +CTLinkedFontsMemory::CTLinkedFontsMemory(CTestStep* aStep)
    1.60 +	:	CTLinkedFonts2(aStep)
    1.61 +	{
    1.62 +	}	
    1.63 +
    1.64 +CTLinkedFontsMemory::~CTLinkedFontsMemory()
    1.65 +	{
    1.66 +	}
    1.67 +
    1.68 +void CTLinkedFontsMemory::SetHeapFail(RFbsSession::THeapFailType aType, TInt aFailures)
    1.69 +	{
    1.70 +	__ASSERT_ALWAYS(iFbs, TestPanic(KErrGeneral));
    1.71 +	iFbs->SendCommand(EFbsMessSetHeapFail, aType, aFailures);
    1.72 +	}
    1.73 +
    1.74 +TInt CTLinkedFontsMemory::HeapCount(RFbsSession::THeapFailType aType)
    1.75 +	{
    1.76 +	__ASSERT_ALWAYS(iFbs, TestPanic(KErrGeneral));
    1.77 +	return iFbs->SendCommand(EFbsMessHeapCount, aType);
    1.78 +	}
    1.79 +
    1.80 +void CTLinkedFontsMemory::SetHeapReset(RFbsSession::THeapFailType aType)
    1.81 +	{
    1.82 +	__ASSERT_ALWAYS(iFbs, TestPanic(KErrGeneral));
    1.83 +	iFbs->SendCommand(EFbsMessSetHeapReset, aType);
    1.84 +	}
    1.85 +
    1.86 +void CTLinkedFontsMemory::SetHeapCheck(RFbsSession::THeapFailType aType)
    1.87 +	{
    1.88 +	__ASSERT_ALWAYS(iFbs, TestPanic(KErrGeneral));
    1.89 +	iFbs->SendCommand(EFbsMessSetHeapCheck, aType);
    1.90 +	}
    1.91 +
    1.92 +TInt CTLinkedFontsMemory::FontAndBitmapServerSharedHeap()
    1.93 +	{
    1.94 +	__ASSERT_ALWAYS(iFbs, TestPanic(KErrGeneral));
    1.95 +	return iFbs->SendCommand(EFbsMessHeap);
    1.96 +	}
    1.97 +
    1.98 +_LIT(KLinkedFontsMemoryTestFont,"MemTestLinkedFnt");
    1.99 +TBool CTLinkedFontsMemory::CheckRasterizerInstalledL()
   1.100 +	{
   1.101 +	CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(iDev);
   1.102 +	CleanupStack::PushL(store);
   1.103 +	
   1.104 +	// Create typeface to be linked
   1.105 +	CLinkedTypefaceSpecification *typefaceSpec;
   1.106 +	typefaceSpec = CLinkedTypefaceSpecification::NewLC(KLinkedFontsMemoryTestFont);
   1.107 +	
   1.108 +	CLinkedTypefaceGroup* group1 = CLinkedTypefaceGroup::NewLC(1);
   1.109 +	typefaceSpec->AddLinkedTypefaceGroupL(*group1);
   1.110 +	CleanupStack::Pop();
   1.111 +	
   1.112 +	// Add first typeface
   1.113 +	CLinkedTypefaceElementSpec *elementSpec1;
   1.114 +	_LIT(KLinkedTypefaceTT, "DejaVu Sans Condensed");
   1.115 +	elementSpec1 = CLinkedTypefaceElementSpec::NewLC(KLinkedTypefaceTT, 1);
   1.116 +	elementSpec1->SetCanonical(ETrue);
   1.117 +		
   1.118 +	typefaceSpec->AddTypefaceAtBackL(*elementSpec1);
   1.119 +	CleanupStack::Pop(1, elementSpec1);
   1.120 +	
   1.121 +	// Now try regstering the linked typeface
   1.122 +	TRAPD(ret, typefaceSpec->RegisterLinkedTypefaceL(*store));
   1.123 +	CleanupStack::PopAndDestroy(2, store);
   1.124 +
   1.125 +	switch (ret)
   1.126 +		{
   1.127 +		case KErrAlreadyExists:
   1.128 +		case KErrNone:
   1.129 +			return ETrue;
   1.130 +		default:
   1.131 +			INFO_PRINTF1(_L("Linked fonts memory: no linked fonts rasterizer found"));
   1.132 +			return EFalse;
   1.133 +		}
   1.134 +	}
   1.135 +
   1.136 +_LIT(KDrawMe, "lInKED FOnTS");
   1.137 +
   1.138 +void CTLinkedFontsMemory::TestCompareText()
   1.139 +	{
   1.140 +	_LIT(KWithout, "WithoutLinkedFontTT");
   1.141 +	TTypeface typeface;
   1.142 +	typeface.iName = KWithout;
   1.143 +	TFontSpec fs;
   1.144 +	fs.iTypeface = typeface;
   1.145 +	fs.iHeight = 20;
   1.146 +	CFbsFont* font = NULL;
   1.147 +	TInt err1 = iDev->GetNearestFontToDesignHeightInPixels(font, fs);
   1.148 +
   1.149 +	if (font && err1 == KErrNone)
   1.150 +		{
   1.151 +		// Use the font
   1.152 +		TSize scrSize = iDev->SizeInPixels();
   1.153 +		iGc->UseFont(font);
   1.154 +		iGc->DrawText(KDrawMe, TPoint((scrSize.iWidth / 2) + 50, 50));
   1.155 +		iGc->DiscardFont();
   1.156 +		iDev->ReleaseFont(font);
   1.157 +		TPoint left(0, 0);
   1.158 +		TPoint right(scrSize.iWidth / 2, 0);
   1.159 +		TBool val = iDev->RectCompare(TRect(left, TPoint(scrSize.iWidth / 2, scrSize.iHeight)), *iDev,TRect(right, TPoint(scrSize.iWidth, scrSize.iHeight)));
   1.160 +		if (!val)
   1.161 +			{
   1.162 +			iGc->DrawRect(TRect(left, TPoint(scrSize.iWidth / 2, scrSize.iHeight)));
   1.163 +			iGc->DrawRect(TRect(right, TPoint(scrSize.iWidth, scrSize.iHeight)));
   1.164 +			}
   1.165 +		TEST(val);
   1.166 +		
   1.167 +		}
   1.168 +	else
   1.169 +		{
   1.170 +		TEST(0);  //there is a failure
   1.171 +		}
   1.172 +	}
   1.173 +
   1.174 +/** these fonts need to be provided, and are used for creating linked typefaces
   1.175 +TLinkedFont1.ttf
   1.176 +Typeface name: LinkedFont1
   1.177 +This will be the dominant font. It contains 178 characters.
   1.178 +Some of the characters (13) are deleted from this file and separated in to other three files.
   1.179 +Characters missing are F, D, J, M, P, S, V, X, Z, a, n, l, y.
   1.180 +
   1.181 +TLinkedFont2.ttf
   1.182 +Typeface name: LinkedFont2
   1.183 +Characters available (7):	F, J, M, S, Z, a, y.
   1.184 +
   1.185 +TLinkedFont3.ttf
   1.186 +Typeface name: LinkedFont3
   1.187 +Characters available (4):	D, P, x, l
   1.188 +
   1.189 +TLinkedFont4.ttf
   1.190 +Typeface name: LinkedFont4
   1.191 +Characters available (2):	V, n
   1.192 +
   1.193 +TWithoutLinkedFont.ttf
   1.194 +Typeface name: WithoutLinkedFont
   1.195 +Characters available:	It contains 191 characters U+0020-U+007E and U+00A0-U+00FF
   1.196 +*/	
   1.197 +
   1.198 +_LIT(KLinkedFont1, "LinkedFont1TT");
   1.199 +_LIT(KLinkedFont2, "LinkedFont2TT");
   1.200 +_LIT(KLinkedFont3, "LinkedFont3TT");
   1.201 +_LIT(KLinkedFont4, "LinkedFont4TT");
   1.202 +
   1.203 +/** Memory test helper function to create different typefaces.  Function adds from 1 to four
   1.204 + typefaces.
   1.205 +*/
   1.206 +TInt CTLinkedFontsMemory::TestLinkedFontsCreateLinkedTypefacesL(const TDesC &aName,TInt aTypefaces)
   1.207 +	{
   1.208 +	TInt ret = KErrNone;
   1.209 +
   1.210 +	CLinkedTypefaceSpecification *typefaceSpec;
   1.211 +
   1.212 +	typefaceSpec = CLinkedTypefaceSpecification::NewLC(aName);
   1.213 +	
   1.214 +	CLinkedTypefaceGroup* group1;
   1.215 +
   1.216 +	group1 = CLinkedTypefaceGroup::NewLC(1); //may well leave, function trapped, groupID = 1
   1.217 +	typefaceSpec->AddLinkedTypefaceGroupL(*group1);
   1.218 +	CleanupStack::Pop(); //pop the group, now referenced via typeface
   1.219 +	
   1.220 +	CLinkedTypefaceElementSpec *elementSpec1;
   1.221 +	elementSpec1 = CLinkedTypefaceElementSpec::NewLC(KLinkedFont1, 1);	
   1.222 +	elementSpec1->SetCanonical(ETrue);
   1.223 +	typefaceSpec->AddTypefaceAtBackL(*elementSpec1);
   1.224 +	CleanupStack::Pop();  //pop the element, now referenced via typeface
   1.225 +
   1.226 +	// Create and add second linked typeface
   1.227 +	if (aTypefaces>=2)
   1.228 +		{
   1.229 +		CLinkedTypefaceElementSpec *elementSpec2;
   1.230 +		elementSpec2 = CLinkedTypefaceElementSpec::NewLC(KLinkedFont2, 1);	
   1.231 +		typefaceSpec->AddTypefaceAtBackL(*elementSpec2);
   1.232 +		CleanupStack::Pop();  //pop the element, now referenced via typeface
   1.233 +		}
   1.234 +
   1.235 +	// Create and add third typeface to be linked
   1.236 +	if (aTypefaces>=3)
   1.237 +		{
   1.238 +		CLinkedTypefaceElementSpec *elementSpec3;
   1.239 +		elementSpec3 = CLinkedTypefaceElementSpec::NewLC(KLinkedFont3, 1);	
   1.240 +		typefaceSpec->AddTypefaceAtBackL(*elementSpec3);
   1.241 +		CleanupStack::Pop();  //pop the element, now referenced via typeface
   1.242 +		}
   1.243 +
   1.244 +	// Create and add fourth typeface to be linked
   1.245 +	if (aTypefaces>=4)
   1.246 +		{
   1.247 +		CLinkedTypefaceElementSpec *elementSpec4;
   1.248 +		elementSpec4 = CLinkedTypefaceElementSpec::NewLC(KLinkedFont4, 1);	
   1.249 +		TRAP(ret,typefaceSpec->AddTypefaceAtBackL(*elementSpec4));
   1.250 +		CleanupStack::Pop();  //pop the element, now referenced via typeface
   1.251 +		}
   1.252 +
   1.253 +	// Try registering the typeface
   1.254 +	CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(iDev);
   1.255 +	CleanupStack::PushL(store);
   1.256 +	typefaceSpec->RegisterLinkedTypefaceL(*store);
   1.257 +	CleanupStack::PopAndDestroy(2, typefaceSpec); //store and typefaceSpec
   1.258 +	return ret;
   1.259 +	}
   1.260 +
   1.261 +/** This is the function which does the operations which are tested, called from OOM loop
   1.262 + * in general the function does not return a low memory error; the function just leaves.
   1.263 + * An exception may be for registration.
   1.264 +*/
   1.265 +TInt CTLinkedFontsMemory::TestLinkedFontsMemory1L(TInt aTypefaces)
   1.266 +	{
   1.267 +	TInt ret = KErrNone;
   1.268 +	
   1.269 +	//these are for the linked typefaces
   1.270 +	_LIT(KLinkedTypeface1, "LinkedMem1-1"); //has LinkedFont1
   1.271 +	_LIT(KLinkedTypeface2, "LinkedMem1-2"); //has LinkedFont1, LinkedFont2
   1.272 +	_LIT(KLinkedTypeface3, "LinkedMem1-3"); //has LinkedFont1, LinkedFont2, LinkedFont3
   1.273 +	_LIT(KLinkedTypeface4, "LinkedMem1-4"); //has LinkedFont1, LinkedFont2, LinkedFont3, LinkedFont4	
   1.274 +	
   1.275 +	// Create canonical typeface to be linked
   1.276 +
   1.277 +	switch (aTypefaces)
   1.278 +		{
   1.279 +		case 1:
   1.280 +			ret = TestLinkedFontsCreateLinkedTypefacesL(KLinkedTypeface1,1);
   1.281 +			break;
   1.282 +		case 2:
   1.283 +			ret = TestLinkedFontsCreateLinkedTypefacesL(KLinkedTypeface2,2);
   1.284 +			break;
   1.285 +		case 3:
   1.286 +			ret = TestLinkedFontsCreateLinkedTypefacesL(KLinkedTypeface3,3);
   1.287 +			break;
   1.288 +		case 4:
   1.289 +			ret = TestLinkedFontsCreateLinkedTypefacesL(KLinkedTypeface4,4);
   1.290 +			break;
   1.291 +		default:
   1.292 +			__ASSERT_ALWAYS(ETrue,Panic(EFntTypefaceIndexOutOfRange));
   1.293 +			break;
   1.294 +		}
   1.295 +	
   1.296 +	RDebug::Printf("%d TestLinkedFontsMemory1L(%d)", ret, aTypefaces);
   1.297 +	return ret;
   1.298 +	}
   1.299 +
   1.300 +/**
   1.301 +   @SYMTestCaseID			GRAPHICS-FNTSTORE-LINKEDFONTS-0102
   1.302 +
   1.303 +   @SYMPREQ					PREQ2146
   1.304 +
   1.305 +   @SYMREQ					REQ10924, REQ10925, REQ10926
   1.306 +
   1.307 +   @SYMTestCaseDesc			To ensure that a linked typeface can be created and registered 
   1.308 +   							without memory leaks, under low memory conditions. 
   1.309 +
   1.310 +   @SYMTestPriority			Critical
   1.311 +
   1.312 +   @SYMTestStatus			Implemented
   1.313 +
   1.314 +   @SYMTestActions			(1) Create an OOM loop,	setting this process's heap memory to fail.
   1.315 +   								testing the client side heap memory allocation.
   1.316 +								In the loop create and register a linked typeface with 1-4
   1.317 +								typefaces
   1.318 +
   1.319 +   @SYMTestExpectedResults	(1) - There are no memory leaks, and the test exits the OOM loop.
   1.320 +*/
   1.321 +void CTLinkedFontsMemory::TestLinkedFontsMemory1L()
   1.322 +	{
   1.323 +	TInt failures;
   1.324 +
   1.325 +	INFO_PRINTF1(_L("TestLinkedFontsMemory"));
   1.326 +	TInt steps;
   1.327 +	for (steps=1;steps<=4;steps++)
   1.328 +		{
   1.329 +
   1.330 +		for (failures = 1; ; failures++)
   1.331 +			{
   1.332 +			__UHEAP_SETFAIL(RHeap::EDeterministic,failures);
   1.333 +			__UHEAP_MARK;
   1.334 +
   1.335 +			// Test steps
   1.336 +			TInt err;
   1.337 +			TInt val = KErrNone;
   1.338 +			TRAP(err, val= TestLinkedFontsMemory1L(steps));
   1.339 +			__UHEAP_CHECK(0);
   1.340 +			__UHEAP_RESET;
   1.341 +			__UHEAP_MARKEND;
   1.342 +
   1.343 +			if (err == KErrNotFound)
   1.344 +				{
   1.345 +				INFO_PRINTF3(_L("Failure below occurred on Step %i; failure=%i"), steps, failures);
   1.346 +				TEST(EFalse);
   1.347 +				break;
   1.348 +				}
   1.349 +			
   1.350 +			if ((err == KErrNone) && (val == KErrNone))
   1.351 +				{
   1.352 +				break;
   1.353 +				}
   1.354 +			}
   1.355 +		}
   1.356 +	}
   1.357 +
   1.358 +/**
   1.359 +   @SYMTestCaseID			GRAPHICS-FNTSTORE-LINKEDFONTS-0103
   1.360 +
   1.361 +   @SYMPREQ					PREQ2146
   1.362 +
   1.363 +   @SYMREQ					REQ10924, REQ10925, REQ10926
   1.364 +
   1.365 +   @SYMTestCaseDesc			To ensure that a linked typeface can be created and fonts created
   1.366 +							and used without memory leaks, under low memory conditions
   1.367 +
   1.368 +   @SYMTestPriority			Critical
   1.369 +
   1.370 +   @SYMTestStatus			Implemented
   1.371 +
   1.372 +   @SYMTestActions			(1) Create an OOM loop, setting the server's heap memory to fail.
   1.373 +								In the loop create and register a linked typeface with 1-4
   1.374 +								typefaces.  
   1.375 +							(2) Draw text with the four linked fonts from the four
   1.376 +								linked typefaces.  
   1.377 +							(3) Compare the text output against an unlinked font with the same 
   1.378 +								character forms.
   1.379 +
   1.380 +   @SYMTestExpectedResults	(1) - There are no memory leaks, and the test exits the OOM loop.
   1.381 +   							(2) - The text is draw successfully
   1.382 +   							(3) - The text compares identically.
   1.383 +*/	
   1.384 +void CTLinkedFontsMemory::TestLinkedFontsMemory2()
   1.385 +	{
   1.386 +	TInt failures;
   1.387 +
   1.388 +	INFO_PRINTF1(_L("TestLinkedFontsMemory Server Heap"));
   1.389 +
   1.390 +	// Initially test for linked typeface creation
   1.391 +	_LIT(name1, "typefaceNameMem2-1");
   1.392 +	_LIT(name2, "typefaceNameMem2-2");
   1.393 +	_LIT(name3, "typefaceNameMem2-3");
   1.394 +	_LIT(name4, "typefaceNameMem2-4");
   1.395 +
   1.396 +	TInt steps;
   1.397 +	for (steps=1;steps<=4;steps++)
   1.398 +		{
   1.399 +		INFO_PRINTF2(_L("Testing creating linked typeface %d typefaces"),steps);
   1.400 +		for (failures = 1;;failures++)
   1.401 +			{
   1.402 +			// Try creating the typeface
   1.403 +
   1.404 +			TInt err;
   1.405 +			TInt val = KErrNone;
   1.406 +
   1.407 +			SetHeapFail(RFbsSession::EHeapFailTypeServerMemory, failures);
   1.408 +			SetHeapCheck(RFbsSession::EHeapFailTypeServerMemory); //on
   1.409 +			SetHeapCheck(RFbsSession::EHeapFailTypeHeapMemory); //on
   1.410 +
   1.411 +			switch(steps)
   1.412 +				{
   1.413 +				case 1:
   1.414 +					TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name1, steps));
   1.415 +					break;
   1.416 +				case 2:
   1.417 +					TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name2, steps));
   1.418 +					break;
   1.419 +				case 3:
   1.420 +					TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name3, steps));
   1.421 +					break;
   1.422 +				case 4:
   1.423 +					TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name4, steps));
   1.424 +					break;
   1.425 +				}
   1.426 +
   1.427 +			SetHeapReset(RFbsSession::EHeapFailTypeServerMemory);
   1.428 +			SetHeapCheck(RFbsSession::EHeapFailTypeServerMemory); //off
   1.429 +			SetHeapCheck(RFbsSession::EHeapFailTypeHeapMemory); //off
   1.430 +
   1.431 +			//If the linked font cannot be created because the typefaces are not present or
   1.432 +			//it has already been created then fail the test.
   1.433 +			if (err == KErrNotFound || err == KErrAlreadyExists)
   1.434 +				{
   1.435 +				INFO_PRINTF1(_L("Failure below caused by missing linked font element file or linked font file already being generated."));
   1.436 +				TEST(EFalse);
   1.437 +				break;
   1.438 +				}
   1.439 +			
   1.440 +			if ((val >= 0) && (err == KErrNone))
   1.441 +				break;
   1.442 +			}
   1.443 +		}
   1.444 +
   1.445 +	INFO_PRINTF1(_L("Testing linked typeface font creation and usage"));
   1.446 +	for(steps=1;steps<=4;steps++)
   1.447 +		{
   1.448 +		INFO_PRINTF2(_L("Testing font usage: linked font with %d fonts"),steps);
   1.449 +		for (failures = 1; ; failures++)
   1.450 +			{
   1.451 +			TInt val = 0;
   1.452 +#ifdef _DEBUG
   1.453 +			TInt serverBefore=HeapCount(RFbsSession::EHeapFailTypeServerMemory);
   1.454 +			TInt countBefore =0;
   1.455 +
   1.456 +			RHeap *heap = (RHeap*)FontAndBitmapServerSharedHeap();
   1.457 +			
   1.458 +			if (heap)
   1.459 +				{
   1.460 +				__RHEAP_MARK(heap);
   1.461 +				countBefore = heap->Count();
   1.462 +				}
   1.463 +			SetHeapFail(RFbsSession::EHeapFailTypeServerMemory, failures);
   1.464 +			SetHeapCheck(RFbsSession::EHeapFailTypeServerMemory); //on
   1.465 +#endif
   1.466 +
   1.467 +			switch(steps)
   1.468 +				{
   1.469 +				case 1:
   1.470 +					val=TestLinkedFontsMemory_Part2(name1);
   1.471 +					break;
   1.472 +				case 2:
   1.473 +					val=TestLinkedFontsMemory_Part2(name2);
   1.474 +					break;
   1.475 +				case 3:
   1.476 +					val=TestLinkedFontsMemory_Part2(name3);
   1.477 +					break;
   1.478 +				case 4:
   1.479 +					val=TestLinkedFontsMemory_Part2(name4);
   1.480 +					break;
   1.481 +				}
   1.482 +#ifdef _DEBUG
   1.483 +			TInt serverAfter = HeapCount(RFbsSession::EHeapFailTypeServerMemory);
   1.484 +			TInt countAfter=0;
   1.485 +			TInt badCell=0;
   1.486 +			if (heap)
   1.487 +				{
   1.488 +				countAfter = heap->Count();
   1.489 +				badCell = __RHEAP_MARKEND(heap);
   1.490 +				}
   1.491 +
   1.492 +			SetHeapReset(RFbsSession::EHeapFailTypeServerMemory);
   1.493 +			SetHeapCheck(RFbsSession::EHeapFailTypeServerMemory); //off
   1.494 +#endif
   1.495 +			if (val == KErrNone)
   1.496 +				{
   1.497 +				if (steps == 4)
   1.498 +					{
   1.499 +					//do a comparison of the text
   1.500 +					TestCompareText();
   1.501 +					}
   1.502 +				break;
   1.503 +				}
   1.504 +#ifdef _DEBUG
   1.505 +			TEST(badCell == 0);
   1.506 +			TEST(countBefore == countAfter);
   1.507 +			TEST(serverBefore == serverAfter);
   1.508 +#endif
   1.509 +			}
   1.510 +		}
   1.511 +	}
   1.512 +
   1.513 +TInt CTLinkedFontsMemory::TestLinkedFontsMemory_Part2(const TDesC &aName)
   1.514 +	{
   1.515 +
   1.516 +	TTypeface Typeface;
   1.517 +	Typeface.iName = aName;
   1.518 +	TFontSpec fs;
   1.519 +	fs.iTypeface = Typeface;
   1.520 +	fs.iHeight = 20;
   1.521 +	CFbsFont* font = NULL;
   1.522 +	TInt err1 = iDev->GetNearestFontToDesignHeightInPixels(font, fs);
   1.523 +
   1.524 +	if (font && err1 == KErrNone)
   1.525 +		{
   1.526 +		// Use the font
   1.527 +		iGc->UseFont(font);
   1.528 +		iGc->Clear();
   1.529 +		iGc->DrawText(KDrawMe, TPoint(50, 50));
   1.530 +		iGc->DiscardFont();
   1.531 +		iDev->ReleaseFont(font);
   1.532 +		}
   1.533 +	else if (font == NULL)
   1.534 +		{
   1.535 +		TEST(err1==KErrNoMemory);
   1.536 +		if (err1==KErrNone)
   1.537 +			{
   1.538 +			err1 = KErrGeneral;
   1.539 +			}
   1.540 +		}
   1.541 +
   1.542 +	return err1;
   1.543 +	}
   1.544 +
   1.545 +/**
   1.546 +   @SYMTestCaseID			GRAPHICS-FNTSTORE-LINKEDFONTS-0104
   1.547 +
   1.548 +   @SYMPREQ					PREQ2146
   1.549 +
   1.550 +   @SYMREQ					REQ10924, REQ10925, REQ10926
   1.551 +
   1.552 +   @SYMTestCaseDesc			To ensure that a linked typeface can be created and fonts created
   1.553 +							and used under low memory conditions
   1.554 +
   1.555 +   @SYMTestPriority			Critical
   1.556 +
   1.557 +   @SYMTestStatus			Implemented
   1.558 +
   1.559 +   @SYMTestActions			(1) This function checks that no memory has been retained from the
   1.560 +								usage of a linked font.  This tests server heap and shared heap
   1.561 +								memory.
   1.562 +
   1.563 +   @SYMTestExpectedResults	(1) - There are no memory leaks.
   1.564 +*/
   1.565 +void CTLinkedFontsMemory::TestLinkedFontsMemory3()
   1.566 +	{
   1.567 +	_LIT( KTest1, "typefaceNameMem2-1");
   1.568 +	_LIT( KTest2, "typefaceNameMem2-2");
   1.569 +	_LIT( KTest3, "typefaceNameMem2-3");
   1.570 +	_LIT( KTest4, "typefaceNameMem2-4");
   1.571 +
   1.572 +#if _DEBUG
   1.573 +		TInt serverBefore = HeapCount(RFbsSession::EHeapFailTypeServerMemory);
   1.574 +		// need to get heap from client side.
   1.575 +		RHeap *heap = (RHeap*)FontAndBitmapServerSharedHeap();
   1.576 +		TInt countBefore=0;
   1.577 +		if (heap)
   1.578 +			{
   1.579 +			__RHEAP_MARK(heap);
   1.580 +			countBefore = heap->Count();
   1.581 +			}
   1.582 +		TInt serverAfter;
   1.583 +#endif
   1.584 +	for (TInt numRuns = 0 ; numRuns <= 50 ; numRuns++)
   1.585 +		{
   1.586 +		for (TInt steps=1;steps<=4;steps++)
   1.587 +			{
   1.588 +			TTypeface Typeface;
   1.589 +			switch (steps)
   1.590 +				{
   1.591 +				case 1:
   1.592 +					Typeface.iName = KTest1;
   1.593 +					break;
   1.594 +				case 2:
   1.595 +					Typeface.iName = KTest2;
   1.596 +					break;
   1.597 +				case 3:
   1.598 +					Typeface.iName = KTest3;
   1.599 +					break;
   1.600 +				case 4:
   1.601 +					Typeface.iName = KTest4;
   1.602 +					break;
   1.603 +				}
   1.604 +			TFontSpec fs;
   1.605 +			fs.iTypeface = Typeface;
   1.606 +			fs.iHeight = 50;
   1.607 +			TInt count;
   1.608 +			CFbsFont *fnt[10];
   1.609 +	
   1.610 +			TInt err;
   1.611 +			for (count = 0; count < 10; count++)
   1.612 +				{
   1.613 +				err = iDev->GetNearestFontToDesignHeightInPixels(fnt[count], fs);
   1.614 +				//now try getting the same font twice, if count is 5
   1.615 +				if(count!=5)
   1.616 +					fs.iHeight++;
   1.617 +				TEST(err == KErrNone);
   1.618 +				}
   1.619 +			for (count = 0; count < 10; count++)
   1.620 +				{
   1.621 +				iDev->ReleaseFont(fnt[count]);
   1.622 +				}
   1.623 +			}
   1.624 +		}
   1.625 +#ifdef _DEBUG
   1.626 +		serverAfter = HeapCount(RFbsSession::EHeapFailTypeServerMemory);
   1.627 +		TInt countAfter=0;
   1.628 +		TInt badCell=0;
   1.629 +		if (heap)
   1.630 +			{
   1.631 +			countAfter = heap->Count();
   1.632 +			badCell = __RHEAP_MARKEND(heap);
   1.633 +			}
   1.634 +		TEST(badCell == 0);
   1.635 +		TEST (countAfter <= countBefore);
   1.636 +
   1.637 +			RDebug::Printf("serverAfter(%i) <= serverBefore(%i)", serverAfter, serverBefore);
   1.638 +			INFO_PRINTF3(_L("serverAfter(%i) <= serverBefore(%i)"), serverAfter, serverBefore);
   1.639 +
   1.640 +		TEST(serverAfter <= serverBefore); // Note some true type tables are freed.
   1.641 +#endif
   1.642 +	}
   1.643 +
   1.644 +/**
   1.645 +   @SYMTestCaseID			GRAPHICS-FNTSTORE-LINKEDFONTS-0105
   1.646 +
   1.647 +   @SYMPREQ					PREQ2146
   1.648 +
   1.649 +   @SYMREQ					REQ10924, REQ10925, REQ10926
   1.650 +
   1.651 +   @SYMTestCaseDesc			To ensure that a linked typeface can be created and fonts created
   1.652 +							and used under low memory conditions of the font and bitmap
   1.653 +							server shared heap.
   1.654 +
   1.655 +   @SYMTestPriority			Critical
   1.656 +
   1.657 +   @SYMTestStatus			Implemented
   1.658 +
   1.659 +   @SYMTestActions			(1) Create an OOM loop, setting the shared heap memory to fail.
   1.660 +								In the loop create and register a linked typeface with 1-4
   1.661 +								typefaces.  Draw text with the four linked fonts from the four
   1.662 +								linked typefaces.
   1.663 +
   1.664 +   @SYMTestExpectedResults	(1) - There are no memory leaks, and the test exits the OOM loop.
   1.665 +*/
   1.666 +void CTLinkedFontsMemory::TestLinkedFontsMemory4()
   1.667 +	{
   1.668 +
   1.669 +	TInt failures;
   1.670 +
   1.671 +	INFO_PRINTF1(_L("TestLinkedFontsMemory Shared Heap"));
   1.672 +
   1.673 +	// Initially test for linked typeface creation
   1.674 +	// Initially test for linked typeface creation
   1.675 +	_LIT(name1, "typefaceNameMem4-1");
   1.676 +	_LIT(name2, "typefaceNameMem4-2");
   1.677 +	_LIT(name3, "typefaceNameMem4-3");
   1.678 +	_LIT(name4, "typefaceNameMem4-4");
   1.679 +
   1.680 +	TInt steps;
   1.681 +	for(steps=1;steps<=4;steps++)
   1.682 +		{
   1.683 +		INFO_PRINTF2(_L("Testing creating linked typeface %d typefaces"),steps);
   1.684 +		for (failures = 1; ; failures++)
   1.685 +			{
   1.686 +			// Try creating the typeface
   1.687 +
   1.688 +			TInt err;
   1.689 +			TInt val = KErrNone;
   1.690 +
   1.691 +			SetHeapFail(RFbsSession::EHeapFailTypeHeapMemory, failures);
   1.692 +			SetHeapCheck(RFbsSession::EHeapFailTypeServerMemory); //on
   1.693 +			SetHeapCheck(RFbsSession::EHeapFailTypeHeapMemory); //on
   1.694 +
   1.695 +			switch(steps)
   1.696 +				{
   1.697 +				case 1:
   1.698 +					TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name1, 1));
   1.699 +					break;
   1.700 +				case 2:
   1.701 +					TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name2, 2));
   1.702 +					break;
   1.703 +				case 3:
   1.704 +					TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name3, 3));
   1.705 +					break;
   1.706 +				case 4:
   1.707 +					TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name4, 4));
   1.708 +					break;
   1.709 +				}
   1.710 +
   1.711 +			SetHeapReset(RFbsSession::EHeapFailTypeHeapMemory);
   1.712 +			SetHeapCheck(RFbsSession::EHeapFailTypeServerMemory); //off
   1.713 +			SetHeapCheck(RFbsSession::EHeapFailTypeHeapMemory); //off
   1.714 +
   1.715 +			//If the linked font cannot be created because the typefaces are not present or
   1.716 +			//it has already been created then fail the test.
   1.717 +			if (err == KErrNotFound || err == KErrAlreadyExists)
   1.718 +				{
   1.719 +				INFO_PRINTF1(_L("Failure below caused by missing linked font element file or linked font file already being generated."));
   1.720 +				TEST(EFalse);
   1.721 +				break;
   1.722 +				}
   1.723 +			
   1.724 +			if ((val >= 0) && (err == KErrNone))
   1.725 +				break;
   1.726 +			}
   1.727 +		}
   1.728 +
   1.729 +	INFO_PRINTF1(_L("Testing linked typeface font creation and usage"));
   1.730 +	for (steps=1;steps<=4;steps++)
   1.731 +		{
   1.732 +		INFO_PRINTF2(_L("Testing font usage: linked font with %d fonts"), steps);
   1.733 +		for (failures = 1; ; failures++)
   1.734 +			{
   1.735 +			TInt val = 0;
   1.736 +#ifdef _DEBUG
   1.737 +			TInt serverBefore=HeapCount(RFbsSession::EHeapFailTypeServerMemory);
   1.738 +			RHeap *heap=(RHeap*)FontAndBitmapServerSharedHeap();
   1.739 +			TInt countBefore = 0;
   1.740 +			if (heap)
   1.741 +				{
   1.742 +				__RHEAP_MARK(heap);
   1.743 +			 	countBefore = heap->Count();
   1.744 +				}
   1.745 +			SetHeapFail(RFbsSession::EHeapFailTypeHeapMemory, failures);
   1.746 +			SetHeapCheck(RFbsSession::EHeapFailTypeServerMemory); //on
   1.747 +#endif
   1.748 +			switch (steps)
   1.749 +				{
   1.750 +				case 1:
   1.751 +					val = TestLinkedFontsMemory_Part2(name1);
   1.752 +					break;
   1.753 +				case 2:
   1.754 +					val = TestLinkedFontsMemory_Part2(name2);
   1.755 +					break;
   1.756 +				case 3:
   1.757 +					val = TestLinkedFontsMemory_Part2(name3);
   1.758 +					break;
   1.759 +				case 4:
   1.760 +					val = TestLinkedFontsMemory_Part2(name4);
   1.761 +					break;
   1.762 +				}
   1.763 +#ifdef _DEBUG
   1.764 +			TInt serverAfter = HeapCount(RFbsSession::EHeapFailTypeServerMemory);
   1.765 +			TInt countAfter =0;
   1.766 +			TInt badCell = 0;
   1.767 +			if (heap)
   1.768 +				{
   1.769 +				countAfter = heap->Count();
   1.770 +				badCell = __RHEAP_MARKEND(heap);
   1.771 +				}
   1.772 +			SetHeapReset(RFbsSession::EHeapFailTypeHeapMemory);
   1.773 +			SetHeapCheck(RFbsSession::EHeapFailTypeServerMemory); //off
   1.774 +#endif
   1.775 +			if (val == KErrNone)
   1.776 +				{
   1.777 +				if (steps == 4)
   1.778 +					{
   1.779 +					TestCompareText();
   1.780 +					}
   1.781 +				break;
   1.782 +				}
   1.783 +#ifdef _DEBUG
   1.784 +			TEST(badCell == 0);
   1.785 +			TEST (countBefore == countAfter);
   1.786 +			TEST(serverBefore == serverAfter);
   1.787 +#endif
   1.788 +			}
   1.789 +		}
   1.790 +	}
   1.791 +
   1.792 +void CTLinkedFontsMemory::DisplayRamInfo(const TDesC& aTextInfo) const
   1.793 +	{
   1.794 +	TInt val;
   1.795 +	HAL::Get(HALData::EMemoryRAMFree, val);
   1.796 +	TBuf <80> buf;
   1.797 +	_LIT(KTotalRamText, "RAM free: %d ");
   1.798 +	buf.Format(KTotalRamText,val);
   1.799 +	buf.Append(aTextInfo);
   1.800 +	iStep->INFO_PRINTF1(buf);
   1.801 +	}
   1.802 +
   1.803 +/**
   1.804 +   @SYMTestCaseID			GRAPHICS-FNTSTORE-LINKEDFONTS-0106
   1.805 +
   1.806 +   @SYMPREQ					PREQ2146
   1.807 +
   1.808 +   @SYMREQ					REQ10924, REQ10925, REQ10926
   1.809 +
   1.810 +   @SYMTestCaseDesc			To test memory usage performance of linked font creation. 
   1.811 +   							Test memory usage performance of linked font character access.
   1.812 +
   1.813 +   @SYMTestPriority			High
   1.814 +
   1.815 +   @SYMTestStatus			Implemented
   1.816 +
   1.817 +   @SYMTestActions			(1) Display available ram.  Create a linked typeface with 1-4 linked typeface
   1.818 +								and display ram available.
   1.819 +							(2) Create four linked fonts from the four linked typefaces.  After each step
   1.820 +								display the available RAM.
   1.821 +							(3) Use each of the four linked fonts in turn for drawing text, and at each
   1.822 +								step display the available RAM.	
   1.823 +
   1.824 +   @SYMTestExpectedResults	(1) (2) (3) RAM usage is displayed.  
   1.825 +   							There are no memory leaks.
   1.826 +*/
   1.827 +void CTLinkedFontsMemory::TestMemoryUsage()
   1.828 +	{
   1.829 +
   1.830 +	INFO_PRINTF1(_L("Test Memory Usage 1"));
   1.831 +
   1.832 +	// Initially test for linked typeface creation
   1.833 +	// Initially test for linked typeface creation
   1.834 +	_LIT(name0, "WithoutLinkedFontTT");
   1.835 +	_LIT(name1, "typefaceMemUse-1");
   1.836 +	_LIT(name2, "typefaceMemUse-2");
   1.837 +	_LIT(name3, "typefaceMemUse-3");
   1.838 +	_LIT(name4, "typefaceMemUse-4");
   1.839 +
   1.840 +	TInt steps;
   1.841 +	_LIT(KPriorToTesting, "Prior to testing");
   1.842 +
   1.843 +	DisplayRamInfo(KPriorToTesting);
   1.844 +
   1.845 +	TInt err=KErrNone;
   1.846 +	TInt val=KErrNone;
   1.847 +	//get memory after registering a typeface
   1.848 +	for(steps=1;steps<=4;steps++)
   1.849 +		{
   1.850 +		switch(steps)
   1.851 +			{
   1.852 +			case 1:
   1.853 +				TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name1, 1));
   1.854 +				_LIT(KOneTypeface, "Typeface with one typeface created");
   1.855 +				DisplayRamInfo(KOneTypeface);
   1.856 +				break;
   1.857 +			case 2:
   1.858 +				TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name2, 2));
   1.859 +				_LIT(KTwoTypeface, "Typeface with two typefaces created");
   1.860 +				DisplayRamInfo(KTwoTypeface);
   1.861 +				break;
   1.862 +			case 3:
   1.863 +				TRAP(err, val = TestLinkedFontsCreateLinkedTypefacesL(name3, 3));
   1.864 +				_LIT(KThreeTypeface, "Typeface with three typefaces created");
   1.865 +				DisplayRamInfo(KThreeTypeface);
   1.866 +				break;
   1.867 +			case 4:
   1.868 +				TRAP(err,val = TestLinkedFontsCreateLinkedTypefacesL(name4, 4));
   1.869 +				_LIT(KFourTypeface, "Typeface with four typefaces created");
   1.870 +				DisplayRamInfo(KFourTypeface);
   1.871 +				break;
   1.872 +			}
   1.873 +		TEST(err == KErrNone);
   1.874 +		TEST(val == KErrNone);
   1.875 +		}
   1.876 +
   1.877 +	CFont* font[5];
   1.878 +	memset (font,0, sizeof(CFont*)*5);
   1.879 +
   1.880 +	_LIT(KGettingFonts, "Now getting 5 fonts, the first one of which is not linked");
   1.881 +	DisplayRamInfo(KGettingFonts);
   1.882 +	//get memory after retrieving a font
   1.883 +	for (steps=0;steps<5;steps++)
   1.884 +		{
   1.885 +		switch (steps)
   1.886 +			{
   1.887 +			case 0:
   1.888 +				{
   1.889 +				TTypeface typeface;
   1.890 +				typeface.iName = name0;
   1.891 +				TFontSpec fs;
   1.892 +				fs.iTypeface = typeface;
   1.893 +				fs.iHeight = 20;
   1.894 +				err = iDev->GetNearestFontToDesignHeightInPixels(font[steps], fs);
   1.895 +				TEST(err==KErrNone);
   1.896 +				_LIT(KOneFont, "Non linked font typeface");
   1.897 +				DisplayRamInfo(KOneFont);
   1.898 +				}
   1.899 +			break;
   1.900 +
   1.901 +			case 1:
   1.902 +				{
   1.903 +				TTypeface typeface;
   1.904 +				typeface.iName = name1;
   1.905 +				TFontSpec fs;
   1.906 +				fs.iTypeface = typeface;
   1.907 +				fs.iHeight = 20;
   1.908 +				err = iDev->GetNearestFontToDesignHeightInPixels(font[steps], fs);
   1.909 +				TEST(err==KErrNone);
   1.910 +				_LIT(KOneFont, "LinkedFont one typeface");
   1.911 +				DisplayRamInfo(KOneFont);
   1.912 +				}
   1.913 +			break;
   1.914 +			case 2:
   1.915 +				{
   1.916 +				TTypeface typeface;
   1.917 +				typeface.iName = name2;
   1.918 +				TFontSpec fs;
   1.919 +				fs.iTypeface = typeface;
   1.920 +				fs.iHeight = 20;
   1.921 +				err = iDev->GetNearestFontToDesignHeightInPixels(font[steps], fs);
   1.922 +				TEST(err==KErrNone);
   1.923 +				_LIT(KTwoFont, "LinkedFont two typefaces");
   1.924 +				DisplayRamInfo(KTwoFont);
   1.925 +				}
   1.926 +			break;
   1.927 +			case 3:
   1.928 +				{
   1.929 +				TTypeface typeface;
   1.930 +				typeface.iName = name3;
   1.931 +				TFontSpec fs;
   1.932 +				fs.iTypeface = typeface;
   1.933 +				fs.iHeight = 20;
   1.934 +				err = iDev->GetNearestFontToDesignHeightInPixels(font[steps], fs);
   1.935 +				TEST(err==KErrNone);
   1.936 +				_LIT(KThreeFont, "LinkedFont three typefaces");
   1.937 +				DisplayRamInfo(KThreeFont);
   1.938 +				}
   1.939 +			break;
   1.940 +			case 4:
   1.941 +				{
   1.942 +				TTypeface typeface;
   1.943 +				typeface.iName = name4;
   1.944 +				TFontSpec fs;
   1.945 +				fs.iTypeface = typeface;
   1.946 +				fs.iHeight = 20;
   1.947 +				err = iDev->GetNearestFontToDesignHeightInPixels(font[steps], fs);
   1.948 +				TEST(err==KErrNone);
   1.949 +				_LIT(KFourFont, "LinkedFont four typefaces");
   1.950 +				DisplayRamInfo(KFourFont);
   1.951 +				}
   1.952 +			break;
   1.953 +			}
   1.954 +		}
   1.955 +
   1.956 +	//get memory after font usage
   1.957 +	const TDesC* string[5];
   1.958 +	_LIT(KString0,"A");
   1.959 +	_LIT(KString1,"B");
   1.960 +	_LIT(KString2,"F");
   1.961 +	_LIT(KString3,"D");
   1.962 +	_LIT(KString4,"V");
   1.963 +	string[0]=&KString0();
   1.964 +	string[1]=&KString1();
   1.965 +	string[2]=&KString2();
   1.966 +	string[3]=&KString3();
   1.967 +	string[4]=&KString4();
   1.968 +
   1.969 +	_LIT(KWritingCharacter,"Now outputing a single character from each of the five fonts");
   1.970 +	DisplayRamInfo(KWritingCharacter);
   1.971 +	for (steps=0;steps<5;steps++)
   1.972 +		{
   1.973 +		// Use the font
   1.974 +		iGc->UseFont(font[steps]);
   1.975 +		iGc->Clear();
   1.976 +		_LIT(KNowUsingFont,"Now using font");
   1.977 +		DisplayRamInfo(KNowUsingFont);
   1.978 +		iGc->DrawText(*string[steps], TPoint(100, 100));
   1.979 +		TBuf <80> buf;
   1.980 +		_LIT(KNumberOfSteps,"The font in use has %d linked fonts");
   1.981 +		buf.Format(KNumberOfSteps, steps);
   1.982 +		DisplayRamInfo(buf);
   1.983 +		iGc->DiscardFont();
   1.984 +		}
   1.985 +
   1.986 +	//release the fonts
   1.987 +	for (steps=0;steps<5;steps++)
   1.988 +		{
   1.989 +		iDev->ReleaseFont(font[steps]);
   1.990 +		}
   1.991 +	_LIT(KTestEnd,"At the end of the memory test");
   1.992 +	DisplayRamInfo(KTestEnd);
   1.993 +	}
   1.994 +
   1.995 +void CTLinkedFontsMemory::RunTestCaseL( TInt aCurTestCase )
   1.996 +	{
   1.997 +		
   1.998 +	((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
   1.999 +	switch ( aCurTestCase )
  1.1000 +		{
  1.1001 +	case 1:
  1.1002 +		((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.1003 +		StartServer();
  1.1004 +		if (!CheckRasterizerInstalledL())
  1.1005 +			{
  1.1006 +			TestComplete();
  1.1007 +			return;
  1.1008 +			}
  1.1009 +		break;
  1.1010 +	case 2:
  1.1011 +		((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0102"));
  1.1012 +#ifdef _DEBUG
  1.1013 +		//memory tests are not valid under DEBUG/ urel, and they will fail
  1.1014 +		__UHEAP_MARK;
  1.1015 +		// This is for client side memory
  1.1016 +		TestLinkedFontsMemory1L();
  1.1017 +		__UHEAP_MARKEND;
  1.1018 +		__UHEAP_RESET;
  1.1019 +#endif
  1.1020 +		break;
  1.1021 +	case 3:
  1.1022 +		((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.1023 +#ifdef _DEBUG
  1.1024 +		__UHEAP_MARK;
  1.1025 +		//((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0103"));
  1.1026 +		// This is for server side memory
  1.1027 +		//TestLinkedFontsMemory2(); //- test crashes the server (from the rasterizer)
  1.1028 +		//TEST(EFalse);
  1.1029 +		__UHEAP_MARKEND;
  1.1030 +		__UHEAP_RESET;
  1.1031 +#endif
  1.1032 +		break;
  1.1033 +	case 4:
  1.1034 +		((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0104"));
  1.1035 +#ifdef _DEBUG
  1.1036 +		__UHEAP_MARK;
  1.1037 +		// This is to check that there are no leaks getting and releasing fonts
  1.1038 +		//TestLinkedFontsMemory3();
  1.1039 +		__UHEAP_MARKEND;
  1.1040 +		__UHEAP_RESET;
  1.1041 +#endif
  1.1042 +		break;
  1.1043 +	case 5:
  1.1044 +		((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0105"));
  1.1045 +#ifdef _DEBUG
  1.1046 +		__UHEAP_MARK;
  1.1047 +		// This is for heap memory
  1.1048 +		//TestLinkedFontsMemory4();
  1.1049 +		__UHEAP_MARKEND;
  1.1050 +		__UHEAP_RESET;
  1.1051 +#endif
  1.1052 +		break;
  1.1053 +
  1.1054 +	case 6:
  1.1055 +#ifdef _DEBUG
  1.1056 +		__UHEAP_MARK;
  1.1057 +#endif		
  1.1058 +		((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0106"));
  1.1059 +		TestMemoryUsage();
  1.1060 +#ifdef _DEBUG		
  1.1061 +		__UHEAP_MARKEND;
  1.1062 +		__UHEAP_RESET;
  1.1063 +#endif		
  1.1064 +		break;	
  1.1065 +	case 7:
  1.1066 +		((CTLinkedFontsMemoryStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.1067 +		((CTLinkedFontsMemoryStep*)iStep)->CloseTMSGraphicsStep();
  1.1068 +		TestComplete();
  1.1069 +		break;
  1.1070 +		}
  1.1071 +	((CTLinkedFontsMemoryStep*)iStep)->RecordTestResultL();
  1.1072 +	}
  1.1073 +
  1.1074 +// --------------
  1.1075 +__CONSTRUCT_STEP__(LinkedFontsMemory)