os/textandloc/fontservices/fontstore/tfs/T_MatchFonts.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_MatchFonts.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,176 @@
     1.4 +/*
     1.5 +* Copyright (c) 2004-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 +// the only way to get at the local to file static function MatchFontSpecsInPixels
    1.22 +#include "FNTSTORE.CPP"
    1.23 +#include "T_MatchFonts.h"
    1.24 +
    1.25 +_LIT( KDjvMono, "DejaVu Sans Mono" );
    1.26 +_LIT( KDjvSerif, "DejaVu Serif Condensed" );
    1.27 +_LIT( KDjvSans, "DejaVu Sans Condensed" );
    1.28 +
    1.29 +class CTMatchFonts : public CTGraphicsBase
    1.30 +	{
    1.31 +public:
    1.32 +	CTMatchFonts(CTestStep* aStep);
    1.33 +
    1.34 +protected:
    1.35 +//from 	CTGraphicsStep
    1.36 +	virtual void RunTestCaseL(TInt aCurTestCase);
    1.37 +	virtual void ConstructL();
    1.38 +private:
    1.39 +	TOpenFontSpec iIdealFontSpec1;
    1.40 +	TOpenFontSpec iIdealFontSpec2;
    1.41 +	TOpenFontSpec iIdealFontSpec3;
    1.42 +	TOpenFontSpec iDjvMonoFontSpec;
    1.43 +	TOpenFontSpec iDjvSerifFontSpec;
    1.44 +	TOpenFontSpec iDjvSansFontSpec;
    1.45 +	};
    1.46 +
    1.47 +CTMatchFonts::CTMatchFonts(CTestStep* aStep) :
    1.48 +	CTGraphicsBase(aStep)
    1.49 +	{
    1.50 +	
    1.51 +	}
    1.52 +
    1.53 +void CTMatchFonts::ConstructL()
    1.54 +	{
    1.55 +
    1.56 +	iIdealFontSpec1.SetName( KNullDesC );
    1.57 +	iIdealFontSpec1.SetHeight( 10 );
    1.58 +	iIdealFontSpec1.SetItalic( EFalse );
    1.59 +	iIdealFontSpec1.SetSlantFactor( 0 );
    1.60 +	iIdealFontSpec1.SetBold( EFalse );
    1.61 +	iIdealFontSpec1.SetBitmapType( EMonochromeGlyphBitmap );
    1.62 +	iIdealFontSpec1.SetMonoWidth( ETrue );
    1.63 +	iIdealFontSpec1.SetSerif( ETrue );
    1.64 +
    1.65 +	iDjvMonoFontSpec.SetName( KDjvMono );
    1.66 +	iDjvMonoFontSpec.SetHeight( 10 );
    1.67 +	iDjvMonoFontSpec.SetItalic( EFalse );
    1.68 +	iDjvMonoFontSpec.SetSlantFactor( 0 );
    1.69 +	iDjvMonoFontSpec.SetBold( EFalse );
    1.70 +	iDjvMonoFontSpec.SetBitmapType( EMonochromeGlyphBitmap );
    1.71 +	iDjvMonoFontSpec.SetMonoWidth( ETrue );
    1.72 +	iDjvMonoFontSpec.SetSerif( ETrue );
    1.73 +
    1.74 +	iIdealFontSpec2.SetName( KNullDesC );
    1.75 +	iIdealFontSpec2.SetHeight( 10 );
    1.76 +	iIdealFontSpec2.SetItalic( EFalse );
    1.77 +	iIdealFontSpec2.SetSlantFactor( 0 );
    1.78 +	iIdealFontSpec2.SetBold( EFalse );
    1.79 +	iIdealFontSpec2.SetBitmapType( EMonochromeGlyphBitmap );
    1.80 +	iIdealFontSpec2.SetMonoWidth( EFalse );
    1.81 +	iIdealFontSpec2.SetSerif( ETrue );
    1.82 +
    1.83 +	iDjvSerifFontSpec.SetName( KDjvSerif );
    1.84 +	iDjvSerifFontSpec.SetHeight( 10 );
    1.85 +	iDjvSerifFontSpec.SetItalic( EFalse );
    1.86 +	iDjvSerifFontSpec.SetSlantFactor( 0 );
    1.87 +	iDjvSerifFontSpec.SetBold( EFalse );
    1.88 +	iDjvSerifFontSpec.SetBitmapType( EMonochromeGlyphBitmap );
    1.89 +	iDjvSerifFontSpec.SetMonoWidth( EFalse );
    1.90 +	iDjvSerifFontSpec.SetSerif( ETrue );
    1.91 +
    1.92 +	iIdealFontSpec3.SetName( KNullDesC );
    1.93 +	iIdealFontSpec3.SetHeight( 10 );
    1.94 +	iIdealFontSpec3.SetItalic( EFalse );
    1.95 +	iIdealFontSpec3.SetSlantFactor( 0 );
    1.96 +	iIdealFontSpec3.SetBold( EFalse );
    1.97 +	iIdealFontSpec3.SetBitmapType( EMonochromeGlyphBitmap );
    1.98 +	iIdealFontSpec3.SetMonoWidth( EFalse );
    1.99 +	iIdealFontSpec3.SetSerif( EFalse );
   1.100 +
   1.101 +	iDjvSansFontSpec.SetName( KDjvSans );
   1.102 +	iDjvSansFontSpec.SetHeight( 10 );
   1.103 +	iDjvSansFontSpec.SetItalic( EFalse );
   1.104 +	iDjvSansFontSpec.SetSlantFactor( 0 );
   1.105 +	iDjvSansFontSpec.SetBold( EFalse );
   1.106 +	iDjvSansFontSpec.SetBitmapType( EMonochromeGlyphBitmap );
   1.107 +	iDjvSansFontSpec.SetMonoWidth( EFalse );
   1.108 +	iDjvSansFontSpec.SetSerif( EFalse );
   1.109 +	
   1.110 +	}
   1.111 +	
   1.112 +/**
   1.113 +	@SYMTestCaseID
   1.114 +	GRAPHICS-FNTSTORE-0035
   1.115 +
   1.116 +	@SYMTestCaseDesc
   1.117 +	Creates a reference font and compares it to different fonts
   1.118 +	and sees which font matches the reference font the best.
   1.119 +	
   1.120 +	@SYMTestActions
   1.121 +	1. Reference font: monospaced serif
   1.122 +	   Compared fonts: DejaVu Sans Mono, DejaVu Serif Condensed, DejaVu Sans Condensed
   1.123 +	2. Reference font: proporional serif font
   1.124 +	   Compared fonts: DejaVu Sans Mono, DejaVu Serif Condensed, DejaVu Sans Condensed
   1.125 +	3. Reference font: proporional sans serif
   1.126 +	   Compared fonts: DejaVu Sans Mono, DejaVu Serif Condensed, DejaVu Sans Condensed	   
   1.127 +
   1.128 +	@SYMTestExpectedResults
   1.129 +	1. Should choose DejaVu Sans Mono above DejaVu Serif Condensed above DejaVu Sans Condensed
   1.130 +	2. Should choose DejaVu Serif Condensed above DejaVu Sans Condensed above DejaVu Sans Mono
   1.131 +	3. Should choose DejaVu Sans Condensed above DejaVu Serif Condensed above DejaVu Sans Mono
   1.132 +*/
   1.133 +void CTMatchFonts::RunTestCaseL( TInt aCurTestCase )
   1.134 +	{
   1.135 +	TInt weighting1;
   1.136 +	TInt weighting2;
   1.137 +	TInt weighting3;
   1.138 +	((CTMatchFontsStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
   1.139 +
   1.140 +	switch ( aCurTestCase )
   1.141 +		{
   1.142 +	case 1:
   1.143 +		((CTMatchFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0035"));
   1.144 +		// Looking for a monospaced serif font (like DejaVu Sans Mono)
   1.145 +		weighting1 = MatchFontSpecsInPixels( iDjvMonoFontSpec, iIdealFontSpec1 );
   1.146 +		weighting2 = MatchFontSpecsInPixels( iDjvSerifFontSpec, iIdealFontSpec1 );
   1.147 +		weighting3 = MatchFontSpecsInPixels( iDjvSansFontSpec, iIdealFontSpec1 );
   1.148 +		// Should choose DejaVu Sans Mono above DejaVu Serif Condensed above DejaVu Sans Condensed
   1.149 +		TEST( ( weighting1 > weighting2 ) && ( weighting2 > weighting3 ) );
   1.150 +		break;
   1.151 +	case 2:
   1.152 +		((CTMatchFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0035"));
   1.153 +		// Looking for a proporional serif font (like DejaVu Serif Condensed)
   1.154 +		weighting1 = MatchFontSpecsInPixels( iDjvMonoFontSpec, iIdealFontSpec2 );
   1.155 +		weighting2 = MatchFontSpecsInPixels( iDjvSerifFontSpec, iIdealFontSpec2 );
   1.156 +		weighting3 = MatchFontSpecsInPixels( iDjvSansFontSpec, iIdealFontSpec2 );
   1.157 +		// Should choose DejaVu Serif Condensed above DejaVu Sans Condensed above DejaVu Sans Mono
   1.158 +		TEST( ( weighting2 > weighting3 ) && ( weighting3 > weighting1 ) );
   1.159 +		break;
   1.160 +	case 3:
   1.161 +		((CTMatchFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0035"));
   1.162 +		// Looking for a proporional sans serif font (like DejaVu Sans Condensed)
   1.163 +		weighting1 = MatchFontSpecsInPixels( iDjvMonoFontSpec, iIdealFontSpec3 );
   1.164 +		weighting2 = MatchFontSpecsInPixels( iDjvSerifFontSpec, iIdealFontSpec3 );
   1.165 +		weighting3 = MatchFontSpecsInPixels( iDjvSansFontSpec, iIdealFontSpec3 );
   1.166 +		// Should choose DejaVu Sans Condensed above DejaVu Serif Condensed above DejaVu Sans Mono
   1.167 +		TEST( ( weighting3 > weighting2 ) && ( weighting2 > weighting1 ) );
   1.168 +		break;
   1.169 +	case 4:
   1.170 +		((CTMatchFontsStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
   1.171 +		((CTMatchFontsStep*)iStep)->CloseTMSGraphicsStep();
   1.172 +		TestComplete();		
   1.173 +		break;
   1.174 +		}
   1.175 +	((CTMatchFontsStep*)iStep)->RecordTestResultL();
   1.176 +	}
   1.177 +
   1.178 +//--------------
   1.179 +__CONSTRUCT_STEP__(MatchFonts)