os/textandloc/fontservices/fontstore/tfs/T_FSOPEN.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_FSOPEN.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,699 @@
     1.4 +/*
     1.5 +* Copyright (c) 2007-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 +* Tests FNTSTORE with respect to the Open Font system.
    1.19 +* Creates a dummy rasterizer and tests font file loading and unloading and
    1.20 +* font creation. This just exercises the way the Open Font system connects to the
    1.21 +* 'classic' bitmap-font-only font system.
    1.22 +*
    1.23 +*/
    1.24 +
    1.25 +
    1.26 +/**
    1.27 + @file
    1.28 + @test
    1.29 + @internalComponent Internal Symbian test code
    1.30 +*/
    1.31 +
    1.32 +#include "T_FSOPEN.H"
    1.33 +#include <e32std.h>
    1.34 +#include <graphics/shaperparams.h>
    1.35 +#include <graphics/fbsdefs.h>
    1.36 +
    1.37 +#ifdef _DEBUG
    1.38 +_LIT(KFBSERVFontDir,"\\resource\\fonts\\");
    1.39 +#endif// _DEBUG
    1.40 +
    1.41 +
    1.42 +_LIT(KFontDummy,"z:\\PlatTest\\Graphics\\TestData\\dummy_fonts\\dummy");
    1.43 +_LIT(KFontDummy_b,"z:\\PlatTest\\Graphics\\TestData\\dummy_fonts\\dummy_b");
    1.44 +_LIT(KFontDummy_i,"z:\\PlatTest\\Graphics\\TestData\\dummy_fonts\\dummy_i");
    1.45 +_LIT(KFontDummy_bi,"z:\\PlatTest\\Graphics\\TestData\\dummy_fonts\\dummy_bi");
    1.46 +
    1.47 +const TUint32 KDevanagariScriptCode = 0x64657661;
    1.48 +_LIT16(KTextToShape, "\x0915\x094D\x0937\x0924\x094D\x0930\x093F\x092F");
    1.49 +
    1.50 +
    1.51 +
    1.52 +
    1.53 +CDummyShaperFactory* CDummyShaperFactory::NewL()
    1.54 +	{
    1.55 +	CDummyShaperFactory* r = new(ELeave) CDummyShaperFactory;
    1.56 +	return r;
    1.57 +	}
    1.58 +
    1.59 +CDummyShaperFactory::CDummyShaperFactory()
    1.60 +	{
    1.61 +	}
    1.62 +
    1.63 +CDummyShaperFactory::~CDummyShaperFactory()
    1.64 +	{
    1.65 +	
    1.66 +	}
    1.67 +
    1.68 +
    1.69 +CShaper* CDummyShaperFactory::NewShaperL(CBitmapFont* aBitmapfont, TInt aScript, TInt aLanguage, RHeap* aHeap)
    1.70 +	{
    1.71 +	return CDummyShaper::NewL(aBitmapfont, aScript, aLanguage, aHeap);
    1.72 +	} 
    1.73 +
    1.74 +void* CShaperFactory::ExtendedInterface(TUid /*aInterfaceId*/)
    1.75 +	{
    1.76 +	return 0;
    1.77 +	}
    1.78 +
    1.79 +
    1.80 +CShaper * CDummyShaper::NewL(CBitmapFont* aBitmapfont, TInt aScript, TInt aLanguage, RHeap* aHeap)
    1.81 +	{
    1.82 +	CDummyShaper* newShaper = new(ELeave)CDummyShaper();
    1.83 +	CleanupStack::PushL(newShaper);
    1.84 +	TInt error = newShaper->ConstructL(aBitmapfont, aScript, aLanguage, aHeap);
    1.85 +	
    1.86 +	// if the layout engine fails to construct with this font return NULL
    1.87 +	if (error == KErrNone )
    1.88 +		{
    1.89 +		CleanupStack::Pop(); // newShaper
    1.90 +		return newShaper;
    1.91 +		}
    1.92 +	else
    1.93 +		{
    1.94 +		CleanupStack::PopAndDestroy(); 
    1.95 +		return NULL;		
    1.96 +		}		
    1.97 +	} 
    1.98 +
    1.99 +
   1.100 +/**
   1.101 +Construct an instance of CDummyShaper 	
   1.102 +@param aOpenFont The required font
   1.103 +@param aHeap The heap to be used for storage by the engine
   1.104 +@return KErrNone if successful or a system wide error code. 
   1.105 +Note that KErrGeneral may be returned in certain out of memory situations.
   1.106 +@see CShaper
   1.107 + */
   1.108 + TInt CDummyShaper::ConstructL(CBitmapFont* /*aBitmapfont*/, TInt /*aScript*/, TInt /*aLanguage*/, RHeap* /*aHeap*/ )
   1.109 +	{
   1.110 +	return KErrNone;
   1.111 +	}
   1.112 +
   1.113 +CDummyShaper::CDummyShaper()
   1.114 +	{
   1.115 +	}	
   1.116 +		
   1.117 +/** 
   1.118 + Frees all resources owned by ...
   1.119 + */
   1.120 + CDummyShaper::~CDummyShaper()
   1.121 +	{
   1.122 +	}	
   1.123 +	
   1.124 +/** This is implementation of CShaper::ShapeText for the Icu layout Engine
   1.125 + The data is taken from TInput and pass to the shaper.
   1.126 + A memory buffer is allocated on aHeapForOutput starting with TShapeHeader is allocated.
   1.127 + The results of the shaping are copied into this buffer and passed back via aOutput. 
   1.128 + @param aOutput On success a new structure containing the results allocated on aHeapForOutput.  
   1.129 + @param aInput The input text and other parameters.
   1.130 + @param aHeapForOutput On success, aOutput should be allocated from this and nothing else. 
   1.131 + 		On failure, nothing should be allocated from it.
   1.132 + @return Error value from one of the system-wide error codes on	failure, KErrNone on success.
   1.133 + @see CShaper::ShapeText
   1.134 + */		
   1.135 +TInt CDummyShaper::ShapeText(TShapeHeader*& /*aOutput*/, const TInput& /*aInput*/, RHeap* /*aHeapForOutput*/)
   1.136 +	{
   1.137 +	// This shaper doesnt return any results
   1.138 + 	return KErrNotSupported;
   1.139 +	}
   1.140 +
   1.141 +class CDummyFontFile: public COpenFontFile
   1.142 +	{
   1.143 +public:
   1.144 +	static CDummyFontFile* NewL(TInt aUid,const TDesC& aFileName);
   1.145 +	TBool GetNearestFontHelperOld(const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
   1.146 +										TInt& aFaceIndex,TOpenFontSpec& aActualFontSpec) const;
   1.147 +private:
   1.148 +	CDummyFontFile(TInt aUid,const TDesC& aFileName);
   1.149 +	void ConstructL();
   1.150 +	// From COpenFontFile
   1.151 +	void GetNearestFontInPixelsL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,
   1.152 +								 const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
   1.153 +								 COpenFont*& aFont,TOpenFontSpec& aActualFontSpec);
   1.154 +	void GetNearestFontToDesignHeightInPixelsL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,
   1.155 +								 const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
   1.156 +								 COpenFont*& aFont,TOpenFontSpec& aActualFontSpec);
   1.157 +	void GetNearestFontToMaxHeightInPixelsL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,
   1.158 +								 const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
   1.159 +								 COpenFont*& aFont,TOpenFontSpec& aActualFontSpec, TInt aMaxHeight);
   1.160 +	virtual TBool HasUnicodeCharacterL(TInt aFaceIndex,TInt aCode) const;
   1.161 +	};
   1.162 +
   1.163 +class CDummyFont: public COpenFont
   1.164 +	{
   1.165 +public:
   1.166 +	static CDummyFont* NewL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,CDummyFontFile* aFontFile,TInt aSizeInPixels);
   1.167 +private:
   1.168 +	CDummyFont(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,CDummyFontFile* aFontFile,TInt aSizeInPixels);
   1.169 +	// From COpenFont
   1.170 +	virtual void RasterizeL(TInt aCode,TOpenFontGlyphData* aGlyphData);
   1.171 +	};
   1.172 +
   1.173 +CTFsOpen::CTFsOpen(CTestStep* aStep) :
   1.174 +	CTGraphicsBase(aStep)
   1.175 +	{
   1.176 +	INFO_PRINTF1(_L("FontStore and the Open Font System"));
   1.177 +	}
   1.178 +
   1.179 +CTFsOpen::~CTFsOpen()
   1.180 +	{
   1.181 +	iFilesys.Close();
   1.182 +	delete iFontStore;
   1.183 +	iHeap->__DbgMarkEnd(0);
   1.184 +	iHeap->Close();
   1.185 +	__UHEAP_MARKEND;
   1.186 +	User::Heap().Check();
   1.187 +	}
   1.188 +
   1.189 +void CTFsOpen::ConstructL()
   1.190 +	{
   1.191 +	__UHEAP_MARK;
   1.192 +	iHeap = UserHeap::ChunkHeap(NULL,0x10000,0x10000);
   1.193 +	if (iHeap == NULL)
   1.194 +		User::Leave(KErrGeneral);
   1.195 +	iHeap->__DbgMarkStart();
   1.196 +	iFontStore = CFontStore::NewL(iHeap);
   1.197 +	
   1.198 +	// Install the dummy rasterizer.
   1.199 +	COpenFontRasterizer* r = CDummyRasterizer::NewL();
   1.200 +	CleanupStack::PushL(r);
   1.201 +	iFontStore->InstallRasterizerL(r);
   1.202 +	CleanupStack::Pop();
   1.203 +
   1.204 +	// Install the dummy shaper
   1.205 +	CShaperFactory* shaperFactory = CDummyShaperFactory::NewL();
   1.206 +	CleanupStack::PushL(shaperFactory);
   1.207 +	iFontStore->InstallShaperFactoryL(shaperFactory);
   1.208 +	CleanupStack::Pop();
   1.209 +	}
   1.210 +
   1.211 +void CTFsOpen::RunTestCaseL(TInt aCurTestCase)
   1.212 +	{
   1.213 +	((CTFsOpenStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
   1.214 +	switch(aCurTestCase)
   1.215 +		{
   1.216 +	case 1:
   1.217 +		((CTFsOpenStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0031"));
   1.218 +		AddAndRemoveFilesL();
   1.219 +		break;
   1.220 +	case 2:
   1.221 +		((CTFsOpenStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0032"));
   1.222 +		CreateAndReleaseFontsL();
   1.223 +		break;
   1.224 +	case 3:
   1.225 +		((CTFsOpenStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0033"));
   1.226 +#ifdef _DEBUG
   1.227 +		TestGetNearestFontHelperL();
   1.228 +#endif //_DEBUG
   1.229 +		break;
   1.230 +	case 4:
   1.231 +		((CTFsOpenStep*)iStep)->SetTestStepID(_L("GRAPHICS-SYSLIB-FNTSTORE-UT-1498"));
   1.232 +		CreateShaperL();
   1.233 +		break;
   1.234 +	case 5:
   1.235 +        	((CTFsOpenStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
   1.236 +		((CTFsOpenStep*)iStep)->CloseTMSGraphicsStep();
   1.237 +		TestComplete();
   1.238 +		break;
   1.239 +		}
   1.240 +	((CTFsOpenStep*)iStep)->RecordTestResultL();
   1.241 +	}
   1.242 +
   1.243 +/**
   1.244 +	@SYMTestCaseID
   1.245 +	GRAPHICS-FNTSTORE-0031
   1.246 +
   1.247 +	@SYMTestCaseDesc
   1.248 +	Tests adding and removing files from the font store.
   1.249 +
   1.250 +	@SYMTestActions
   1.251 +	1. Finds or creates a font file object to support a font file. 
   1.252 +	   If an appropriate font file object exists then no new open font file is created. 
   1.253 +	   In this case the reference count of the font file object is incremented.
   1.254 +	2. Gets the number of typefaces held in the font store.
   1.255 +	3. Checks all fonts are in the same typeface family.
   1.256 +	4. Checks all fonts have different FontStore ids.
   1.257 +	5. Tries to add a font (which has been added once already) and checks it gets 
   1.258 +	   the same id as when it was added.
   1.259 +	6. Releases four load fonts.
   1.260 +	7. Checks font that was loaded twice should still be loaded.
   1.261 +	8. Removes last reference a font and checks all fonts are unloaded correctly.
   1.262 +
   1.263 +	@SYMTestExpectedResults
   1.264 +	Test should pass
   1.265 +*/
   1.266 +void CTFsOpen::AddAndRemoveFilesL()
   1.267 +	{
   1.268 +	TEST(iFontStore->NumTypefaces() == 0);
   1.269 +
   1.270 +	INFO_PRINTF1(_L("loading dummy Open Fonts\n"));
   1.271 +	
   1.272 +	TUid id1 = iFontStore->AddFileL(KFontDummy);
   1.273 +	TUid id2 = iFontStore->AddFileL(KFontDummy_b);
   1.274 +	TUid id3 = iFontStore->AddFileL(KFontDummy_i);
   1.275 +	TUid id4 = iFontStore->AddFileL(KFontDummy_bi);
   1.276 +
   1.277 +	// all fonts are in the same typeface family
   1.278 +	INFO_PRINTF1(_L("increasing reference count for for an Open Font file\n"));
   1.279 +	TEST(iFontStore->NumTypefaces() == 1);
   1.280 +
   1.281 +	// ids should each be different
   1.282 +	TEST(id1 != id2);
   1.283 +	TEST(id1 != id3);
   1.284 +	TEST(id1 != id4);
   1.285 +	TEST(id2 != id3);
   1.286 +	TEST(id2 != id4);
   1.287 +	TEST(id3 != id4);
   1.288 +
   1.289 +	// ask for one of the font files again
   1.290 +	TUid id5 = iFontStore->AddFileL(KFontDummy_bi);
   1.291 +
   1.292 +	// should get the same UID as the first time
   1.293 +	TEST(id4 == id5);
   1.294 +
   1.295 +	INFO_PRINTF1(_L("unloading dummy Open Fonts\n"));
   1.296 +	iFontStore->RemoveFile(id1);
   1.297 +	iFontStore->RemoveFile(id2);
   1.298 +	iFontStore->RemoveFile(id3);
   1.299 +	iFontStore->RemoveFile(id4);
   1.300 +
   1.301 +	// font that was loaded twice should still be loaded
   1.302 +	TEST(iFontStore->NumTypefaces() == 1);
   1.303 +
   1.304 +	// remove last reference
   1.305 +	iFontStore->RemoveFile(id5);
   1.306 +
   1.307 +	// all fonts unloaded
   1.308 +	TEST(iFontStore->NumTypefaces() == 0);
   1.309 +	}
   1.310 +
   1.311 +void CTFsOpen::TestFont(const TFontSpec& aSpec)
   1.312 +	{
   1.313 +	iHeap->__DbgMarkStart();
   1.314 +
   1.315 +	CFont* font = NULL;
   1.316 +	TInt error = iFontStore->GetNearestFontToDesignHeightInTwips(font,aSpec);
   1.317 +	TEST(error == KErrNone);
   1.318 +	TEST(font != NULL);
   1.319 +	INFO_PRINTF2(_L("desired font spec: %S: "),&aSpec.iTypeface.iName);
   1.320 +	if (aSpec.iFontStyle.StrokeWeight() == EStrokeWeightBold)
   1.321 +		INFO_PRINTF1(_L("bold "));
   1.322 +	if (aSpec.iFontStyle.Posture() == EPostureItalic)
   1.323 +		INFO_PRINTF1(_L("italic "));
   1.324 +	INFO_PRINTF2(_L("%dpt"),(aSpec.iHeight + 10) / 20);
   1.325 +	INFO_PRINTF1(_L("\n"));
   1.326 +	TFontSpec actual_spec = font->FontSpecInTwips();
   1.327 +	INFO_PRINTF2(_L("actual font spec: %S: "),&actual_spec.iTypeface.iName);
   1.328 +	if (actual_spec.iFontStyle.StrokeWeight() == EStrokeWeightBold)
   1.329 +		INFO_PRINTF1(_L("bold "));
   1.330 +	if (actual_spec.iFontStyle.Posture() == EPostureItalic)
   1.331 +		INFO_PRINTF1(_L("italic "));
   1.332 +	INFO_PRINTF2(_L("%dpt"),(actual_spec.iHeight + 10) / 20);
   1.333 +	INFO_PRINTF1(_L("\n"));
   1.334 +	iFontStore->ReleaseFont(font);
   1.335 +
   1.336 +	TEST (iHeap->__DbgMarkEnd(0) == 0);
   1.337 +	}
   1.338 +
   1.339 +/**
   1.340 +	@SYMTestCaseID
   1.341 +	GRAPHICS-FNTSTORE-0032
   1.342 +
   1.343 +	@SYMTestCaseDesc
   1.344 +	Creates fonts and tests their properties
   1.345 +	and then releases them.
   1.346 +
   1.347 +	@SYMTestActions
   1.348 +	1. Adds four files to the font store.
   1.349 +	2. Retrieves number of typefaces.
   1.350 +	3. For all of the typefaces available it gets
   1.351 +	   the typeface support and retrieves its font height
   1.352 +	   in twips.
   1.353 +	4. Tests the fonts properties.
   1.354 +	5. Releases a hold on all font file objects allocated.
   1.355 +	
   1.356 +	@SYMTestExpectedResults
   1.357 +	Test should pass
   1.358 +*/
   1.359 +void CTFsOpen::CreateAndReleaseFontsL()
   1.360 +	{
   1.361 +	TUid id1 = iFontStore->AddFileL(KFontDummy);
   1.362 +	TUid id2 = iFontStore->AddFileL(KFontDummy_b);
   1.363 +	TUid id3 = iFontStore->AddFileL(KFontDummy_i);
   1.364 +	TUid id4 = iFontStore->AddFileL(KFontDummy_bi);
   1.365 +
   1.366 +	int typefaces = iFontStore->NumTypefaces();
   1.367 +	for (int typeface = 0; typeface < typefaces; typeface++)
   1.368 +		{
   1.369 +		TTypefaceSupport support;
   1.370 +		iFontStore->TypefaceSupport(support,typeface);
   1.371 +		TFontSpec fs;
   1.372 +		fs.iTypeface = support.iTypeface;
   1.373 +		for (int height = 0; height < support.iNumHeights; height++)
   1.374 +			{
   1.375 +			fs.iHeight = iFontStore->FontHeightInTwips(typeface,height);
   1.376 +			TestFont(fs);
   1.377 +			}
   1.378 +		}
   1.379 +
   1.380 +	iFontStore->RemoveFile(id1);
   1.381 +	iFontStore->RemoveFile(id2);
   1.382 +	iFontStore->RemoveFile(id3);
   1.383 +	iFontStore->RemoveFile(id4);
   1.384 +	}
   1.385 +	
   1.386 +/**
   1.387 +@file
   1.388 +@SYMTestCaseID				GRAPHICS-SYSLIB-FNTSTORE-UT-1498
   1.389 +@SYMTestCaseDesc 			Test the Shaper API  
   1.390 +@SYMTestPriority 			High
   1.391 +@SYMTestActions  			This test checks the CBitmapFont::ShapeTextL() using a dummy font and a dummy shaper
   1.392 +@SYMTestExpectedResults		The test must not fail.
   1.393 +@SYMPREQ					PREQ18
   1.394 +*/
   1.395 +void CTFsOpen::CreateShaperL()
   1.396 +	{
   1.397 +	__UHEAP_MARK;
   1.398 +	INFO_PRINTF1(_L("Creating Shaper and Shaping Text\n"));
   1.399 +	
   1.400 +	// Add fonts
   1.401 +	TUid id1 = iFontStore->AddFileL(KFontDummy);
   1.402 +	TUid id2 = iFontStore->AddFileL(KFontDummy_b);
   1.403 +	TUid id3 = iFontStore->AddFileL(KFontDummy_i);
   1.404 +	TUid id4 = iFontStore->AddFileL(KFontDummy_bi);
   1.405 +	
   1.406 +	TInt error = 0;
   1.407 +	TInt err = 0;
   1.408 +	int typefaces = iFontStore->NumTypefaces();
   1.409 +	for (TInt typeface = 0; typeface < typefaces; typeface++)
   1.410 +		{
   1.411 +		TTypefaceSupport support;
   1.412 +		iFontStore->TypefaceSupport(support,typeface);
   1.413 +		TFontSpec fs;
   1.414 +		fs.iTypeface = support.iTypeface;
   1.415 +		for (TInt height = 0; height < support.iNumHeights; height++)
   1.416 +			{
   1.417 +			//Create a font
   1.418 +			CFont* font = NULL;
   1.419 +			fs.iHeight = iFontStore->FontHeightInTwips(typeface,height);
   1.420 +			// get a COpenFont object
   1.421 +			iFontStore->GetNearestFontToDesignHeightInPixels(font, fs);	
   1.422 +			CleanupStack::PushL(font);
   1.423 +			
   1.424 +			 //do some dummy shaping
   1.425 +			TShapeHeader* shape = 0;
   1.426 +						
   1.427 +			TShapeMessageParameters params;
   1.428 +			params.iStart = 0;
   1.429 +			params.iEnd = 8;
   1.430 +			params.iScript = KDevanagariScriptCode;
   1.431 +			params.iLanguage = 0;
   1.432 +			
   1.433 +					
   1.434 +			TRAP(err, shape = ((CBitmapFont*)font)->ShapeTextL(KTextToShape, 0, params));
   1.435 +			TEST(err == KErrNotSupported);
   1.436 +					
   1.437 +			// Now do some dummy deletion of the TShapeHeader
   1.438 +			TInt dummyHandle=0;
   1.439 +			TRAP(error, ((CBitmapFont*)font)->DeleteShape(dummyHandle,shape));
   1.440 +			TEST(error == KErrNone);
   1.441 +			CleanupStack::Pop(font);
   1.442 +			iFontStore->ReleaseFont(font);
   1.443 +			}
   1.444 +		}
   1.445 +
   1.446 +	// Remove the fonts
   1.447 +	iFontStore->RemoveFile(id1);
   1.448 +	iFontStore->RemoveFile(id2);
   1.449 +	iFontStore->RemoveFile(id3);
   1.450 +	iFontStore->RemoveFile(id4);	
   1.451 +
   1.452 +	__UHEAP_MARKEND;	
   1.453 +	}
   1.454 +	
   1.455 +/** End of Shaper Tests*/
   1.456 +
   1.457 +/**
   1.458 +	@SYMTestCaseID
   1.459 +	GRAPHICS-FNTSTORE-0033
   1.460 +
   1.461 +	@SYMTestCaseDesc
   1.462 +	Tests the GetNearestFontHelper function. This function may be used by 
   1.463 +	derived classes in their GetNearestFontInPixelsL() 
   1.464 +	implementations. It finds the nearest font in the typeface attribute array, 
   1.465 +	if any, to the provided font specification. If there is a possible match it 
   1.466 +	places the face index in aFaceIndex and the actual specification (including 
   1.467 +	algorithmic effects) in aActualFontSpec.
   1.468 +
   1.469 +	@SYMTestActions
   1.470 +	1. Connects to the file system.
   1.471 +	2. Finds a specified file.
   1.472 +	3. Retrieves a font file.
   1.473 +	4. Sets different font attributes.
   1.474 +	5. Calls the GetNearestFontHelper and GetNearestFontHelperOld functions.
   1.475 +	6. Checks if the two functions give the same result.
   1.476 +		
   1.477 +	@SYMTestExpectedResults
   1.478 +	Test should pass
   1.479 +*/
   1.480 +#ifdef _DEBUG
   1.481 +void CTFsOpen::TestGetNearestFontHelperL()
   1.482 +	{
   1.483 +	INFO_PRINTF1(_L("GetNearestFontHelper\n"));
   1.484 +	User::LeaveIfError(iFilesys.Connect());
   1.485 +	TFindFile file_finder(iFilesys);
   1.486 +	CDir* file_list = NULL;
   1.487 +	_LIT(KFBSERVFontFilePattern, "*.ttf");
   1.488 +	TInt error = file_finder.FindWildByDir(KFBSERVFontFilePattern,KFBSERVFontDir,file_list);
   1.489 +	while (!error)
   1.490 +		{
   1.491 +		CleanupStack::PushL(file_list);
   1.492 +		for (int i = 0; i < file_list->Count(); i++)
   1.493 +			{
   1.494 +			TParse parse;
   1.495 +			if (parse.Set((*file_list)[i].iName,&file_finder.File(),NULL) == KErrNone)
   1.496 +				{
   1.497 +				TPtrC name = parse.Name();
   1.498 +				INFO_PRINTF2(_L("Font file: %S\r\n"), &name);
   1.499 +				CDummyFontFile* font_file = CDummyFontFile::NewL(0,parse.FullName());
   1.500 +
   1.501 +				TOpenFontSpec font_spec1;
   1.502 +				TOpenFontSpec font_spec2_new;
   1.503 +				TOpenFontSpec font_spec2_old;
   1.504 +				
   1.505 +				TInt face_index = 0;
   1.506 +
   1.507 +				font_spec1.SetName(KNullDesC);
   1.508 +				font_spec1.SetHeight(10);
   1.509 +
   1.510 +				font_spec1.SetCoverage(0,0,0,0);
   1.511 +				font_spec1.SetBold(EFalse);
   1.512 +				font_spec1.SetItalic(EFalse);
   1.513 +				font_spec1.SetSerif(EFalse);
   1.514 +				font_spec1.SetMonoWidth(EFalse);
   1.515 +				TBool res1 = font_file->GetNearestFontHelper(font_spec1,0,0,face_index,font_spec2_new);
   1.516 +				TBool res2 = font_file->GetNearestFontHelperOld(font_spec1,0,0,face_index,font_spec2_old);
   1.517 +				TEST(res2 ? res1 && (font_spec2_new == font_spec2_old) : ETrue);
   1.518 +
   1.519 +				font_spec1.SetBold(ETrue);
   1.520 +				res1 = font_file->GetNearestFontHelper(font_spec1,0,0,face_index,font_spec2_new);
   1.521 +				res2 = font_file->GetNearestFontHelperOld(font_spec1,0,0,face_index,font_spec2_old);
   1.522 +				TEST(res2 ? res1 && (font_spec2_new == font_spec2_old) : ETrue);
   1.523 +
   1.524 +				font_spec1.SetItalic(ETrue);
   1.525 +				res1 = font_file->GetNearestFontHelper(font_spec1,0,0,face_index,font_spec2_new);
   1.526 +				res2 = font_file->GetNearestFontHelperOld(font_spec1,0,0,face_index,font_spec2_old);
   1.527 +				TEST(res2 ? res1 && (font_spec2_new == font_spec2_old) : ETrue);
   1.528 +
   1.529 +				font_spec1.SetSerif(ETrue);
   1.530 +				res1 = font_file->GetNearestFontHelper(font_spec1,0,0,face_index,font_spec2_new);
   1.531 +				res2 = font_file->GetNearestFontHelperOld(font_spec1,0,0,face_index,font_spec2_old);
   1.532 +				TEST(res2 ? res1 && (font_spec2_new == font_spec2_old) : ETrue);
   1.533 +
   1.534 +				font_spec1.SetMonoWidth(ETrue);
   1.535 +				res1 = font_file->GetNearestFontHelper(font_spec1,0,0,face_index,font_spec2_new);
   1.536 +				res2 = font_file->GetNearestFontHelperOld(font_spec1,0,0,face_index,font_spec2_old);
   1.537 +				TEST(res2 ? res1 && (font_spec2_new == font_spec2_old) : ETrue);
   1.538 +
   1.539 +				font_spec1.SetCoverage(8);
   1.540 +				font_spec1.SetBold(EFalse);
   1.541 +				font_spec1.SetItalic(EFalse);
   1.542 +				font_spec1.SetSerif(EFalse);
   1.543 +				font_spec1.SetMonoWidth(EFalse);
   1.544 +				res1 = font_file->GetNearestFontHelper(font_spec1,0,0,face_index,font_spec2_new);
   1.545 +				res2 = font_file->GetNearestFontHelperOld(font_spec1,0,0,face_index,font_spec2_old);
   1.546 +				TEST(res2 ? res1 && (font_spec2_new == font_spec2_old) : ETrue);
   1.547 +
   1.548 +				delete font_file;
   1.549 +				}
   1.550 +			}
   1.551 +		CleanupStack::PopAndDestroy(); // file_list
   1.552 +		if (!error)
   1.553 +			error = file_finder.FindWild(file_list);
   1.554 +		}
   1.555 +	}
   1.556 +#endif //_DEBUG
   1.557 +
   1.558 +CDummyRasterizer* CDummyRasterizer::NewL()
   1.559 +	{
   1.560 +	return new(ELeave) CDummyRasterizer;
   1.561 +	}
   1.562 +
   1.563 +COpenFontFile* CDummyRasterizer::NewFontFileL(TInt aUid,const TDesC& aFileName,RFs& /*aFileSession*/)
   1.564 +	{
   1.565 +	// Allow 'dummy', 'dummy_b', etc. Don't actually open a file; just create a dummy font.
   1.566 +	if (aFileName.CompareF(KFontDummy) == 0 ||
   1.567 +		aFileName.CompareF(KFontDummy_b) == 0 ||
   1.568 +		aFileName.CompareF(KFontDummy_i) == 0 ||
   1.569 +		aFileName.CompareF(KFontDummy_bi) == 0)
   1.570 +		return CDummyFontFile::NewL(aUid,aFileName);
   1.571 +	return NULL;
   1.572 +	}
   1.573 +
   1.574 +CDummyFontFile::CDummyFontFile(TInt aUid,const TDesC& aFileName):
   1.575 +	COpenFontFile(aUid,aFileName)
   1.576 +	{
   1.577 +	}
   1.578 +
   1.579 +CDummyFontFile* CDummyFontFile::NewL(TInt aUid,const TDesC& aFileName)
   1.580 +	{
   1.581 +	CDummyFontFile* f = new(ELeave)CDummyFontFile(aUid,aFileName);
   1.582 +	CleanupStack::PushL(f);
   1.583 +	f->ConstructL();
   1.584 +	CleanupStack::Pop();
   1.585 +	return f;
   1.586 +	}
   1.587 +
   1.588 +TBool CDummyFontFile::GetNearestFontHelperOld(const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
   1.589 +											  TInt& aFaceIndex,TOpenFontSpec& aActualFontSpec) const
   1.590 +	{
   1.591 +	return COpenFontFile::GetNearestFontHelperOld(aDesiredFontSpec,aPixelWidth,aPixelHeight,aFaceIndex,aActualFontSpec);
   1.592 +	}
   1.593 +
   1.594 +void CDummyFontFile::ConstructL()
   1.595 +	{
   1.596 +	const TDesC& filename = FileName();
   1.597 +	TOpenFontFaceAttrib attrib;
   1.598 +
   1.599 +	if (filename.CompareF(KFontDummy) == 0)
   1.600 +		attrib.SetFullName(_L("Dummy"));
   1.601 +	else if (filename.CompareF(KFontDummy_b) == 0)
   1.602 +		{
   1.603 +		attrib.SetFullName(_L("Dummy Bold"));
   1.604 +		attrib.SetBold(TRUE);
   1.605 +		}
   1.606 +	else if (filename.CompareF(KFontDummy_i) == 0)
   1.607 +		{
   1.608 +		attrib.SetFullName(_L("Dummy Italic"));
   1.609 +		attrib.SetItalic(TRUE);
   1.610 +		}
   1.611 +	else if (filename.CompareF(KFontDummy_bi) == 0)
   1.612 +		{
   1.613 +		attrib.SetFullName(_L("Dummy Bold Italic"));
   1.614 +		attrib.SetBold(TRUE);
   1.615 +		attrib.SetItalic(TRUE);
   1.616 +		}
   1.617 +	attrib.SetFamilyName(_L("Dummy"));
   1.618 +	attrib.SetLocalFullName(attrib.FullName());
   1.619 +	attrib.SetCoverage(TOpenFontFaceAttrib::ELatinSet);
   1.620 +	attrib.SetMinSizeInPixels(8);
   1.621 +	AddFaceL(attrib);
   1.622 +	}
   1.623 +
   1.624 +void CDummyFontFile::GetNearestFontInPixelsL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,
   1.625 +											 const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
   1.626 +											 COpenFont*& aFont,TOpenFontSpec& aActualFontSpec)
   1.627 +
   1.628 +	{
   1.629 +	aFont = NULL;
   1.630 +	TInt face_index = 0;
   1.631 +	if (GetNearestFontHelper(aDesiredFontSpec,aPixelWidth,aPixelHeight,face_index,aActualFontSpec))
   1.632 +		aFont = CDummyFont::NewL(aHeap,aSessionCacheList,this,aActualFontSpec.Height());
   1.633 +	}
   1.634 +
   1.635 +void CDummyFontFile::GetNearestFontToDesignHeightInPixelsL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,
   1.636 +											 const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
   1.637 +											 COpenFont*& aFont,TOpenFontSpec& aActualFontSpec)
   1.638 +
   1.639 +	{
   1.640 +	aFont = NULL;
   1.641 +	TInt face_index = 0;
   1.642 +	if (GetNearestFontHelper(aDesiredFontSpec,aPixelWidth,aPixelHeight,face_index,aActualFontSpec))
   1.643 +		aFont = CDummyFont::NewL(aHeap,aSessionCacheList,this,aActualFontSpec.Height());
   1.644 +	}
   1.645 +
   1.646 +void CDummyFontFile::GetNearestFontToMaxHeightInPixelsL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,
   1.647 +											 const TOpenFontSpec& aDesiredFontSpec,TInt aPixelWidth,TInt aPixelHeight,
   1.648 +											 COpenFont*& aFont,TOpenFontSpec& aActualFontSpec,TInt /*aMaxHeight*/)
   1.649 +
   1.650 +	{
   1.651 +	aFont = NULL;
   1.652 +	TInt face_index = 0;
   1.653 +	if (GetNearestFontHelper(aDesiredFontSpec,aPixelWidth,aPixelHeight,face_index,aActualFontSpec))
   1.654 +		aFont = CDummyFont::NewL(aHeap,aSessionCacheList,this,aActualFontSpec.Height());
   1.655 +	}
   1.656 +
   1.657 +TBool CDummyFontFile::HasUnicodeCharacterL(TInt /*aFaceIndex*/,TInt /*aCode*/) const
   1.658 +	{
   1.659 +	return EFalse; // this dummy font has no characters
   1.660 +	}
   1.661 +
   1.662 +CDummyFont* CDummyFont::NewL(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,
   1.663 +							 CDummyFontFile* aFontFile,TInt aSizeInPixels)
   1.664 +	{
   1.665 +	CDummyFont* f = (CDummyFont*)aHeap->AllocL(sizeof(CDummyFont));
   1.666 +	new(f) CDummyFont(aHeap,aSessionCacheList,aFontFile,aSizeInPixels);
   1.667 +	return f;
   1.668 +	}
   1.669 +
   1.670 +CDummyFont::CDummyFont(RHeap* aHeap,COpenFontSessionCacheList* aSessionCacheList,CDummyFontFile* aFontFile,
   1.671 +					   TInt aSizeInPixels):
   1.672 +	COpenFont(aHeap,aSessionCacheList,aFontFile)
   1.673 +	{
   1.674 +	iMetrics.SetSize(aSizeInPixels);
   1.675 +	iMetrics.SetAscent(aSizeInPixels * 3 / 4);
   1.676 +	iMetrics.SetDescent(aSizeInPixels - iMetrics.Ascent());
   1.677 +	iMetrics.SetMaxHeight(iMetrics.Ascent());
   1.678 +	iMetrics.SetMaxDepth(iMetrics.Descent());
   1.679 +	iMetrics.SetMaxWidth(aSizeInPixels * 2);
   1.680 +	}
   1.681 +
   1.682 +void CDummyFont::RasterizeL(TInt /*aCode*/,TOpenFontGlyphData* /*aGlyphData*/)
   1.683 +	{
   1.684 +	User::Leave(KErrNotSupported); // this dummy font has no glyphs
   1.685 +	}
   1.686 +
   1.687 +static void ExpandCleanupStackL()
   1.688 +	{
   1.689 +	TInt count = 0;
   1.690 +	for (; count < 10; count++)
   1.691 +		CleanupStack::PushL((TUint32*)0x1);
   1.692 +	CleanupStack::Pop(count);
   1.693 +	}
   1.694 +
   1.695 +//--------------
   1.696 +__CONSTRUCT_STEP__(FsOpen)
   1.697 +
   1.698 +
   1.699 +void CTFsOpenStep::TestSetupL()
   1.700 +	{
   1.701 +	ExpandCleanupStackL();
   1.702 +	}