os/textandloc/fontservices/fontstore/tfs/T_MatchFonts.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
// the only way to get at the local to file static function MatchFontSpecsInPixels
sl@0
    19
#include "FNTSTORE.CPP"
sl@0
    20
#include "T_MatchFonts.h"
sl@0
    21
sl@0
    22
_LIT( KDjvMono, "DejaVu Sans Mono" );
sl@0
    23
_LIT( KDjvSerif, "DejaVu Serif Condensed" );
sl@0
    24
_LIT( KDjvSans, "DejaVu Sans Condensed" );
sl@0
    25
sl@0
    26
class CTMatchFonts : public CTGraphicsBase
sl@0
    27
	{
sl@0
    28
public:
sl@0
    29
	CTMatchFonts(CTestStep* aStep);
sl@0
    30
sl@0
    31
protected:
sl@0
    32
//from 	CTGraphicsStep
sl@0
    33
	virtual void RunTestCaseL(TInt aCurTestCase);
sl@0
    34
	virtual void ConstructL();
sl@0
    35
private:
sl@0
    36
	TOpenFontSpec iIdealFontSpec1;
sl@0
    37
	TOpenFontSpec iIdealFontSpec2;
sl@0
    38
	TOpenFontSpec iIdealFontSpec3;
sl@0
    39
	TOpenFontSpec iDjvMonoFontSpec;
sl@0
    40
	TOpenFontSpec iDjvSerifFontSpec;
sl@0
    41
	TOpenFontSpec iDjvSansFontSpec;
sl@0
    42
	};
sl@0
    43
sl@0
    44
CTMatchFonts::CTMatchFonts(CTestStep* aStep) :
sl@0
    45
	CTGraphicsBase(aStep)
sl@0
    46
	{
sl@0
    47
	
sl@0
    48
	}
sl@0
    49
sl@0
    50
void CTMatchFonts::ConstructL()
sl@0
    51
	{
sl@0
    52
sl@0
    53
	iIdealFontSpec1.SetName( KNullDesC );
sl@0
    54
	iIdealFontSpec1.SetHeight( 10 );
sl@0
    55
	iIdealFontSpec1.SetItalic( EFalse );
sl@0
    56
	iIdealFontSpec1.SetSlantFactor( 0 );
sl@0
    57
	iIdealFontSpec1.SetBold( EFalse );
sl@0
    58
	iIdealFontSpec1.SetBitmapType( EMonochromeGlyphBitmap );
sl@0
    59
	iIdealFontSpec1.SetMonoWidth( ETrue );
sl@0
    60
	iIdealFontSpec1.SetSerif( ETrue );
sl@0
    61
sl@0
    62
	iDjvMonoFontSpec.SetName( KDjvMono );
sl@0
    63
	iDjvMonoFontSpec.SetHeight( 10 );
sl@0
    64
	iDjvMonoFontSpec.SetItalic( EFalse );
sl@0
    65
	iDjvMonoFontSpec.SetSlantFactor( 0 );
sl@0
    66
	iDjvMonoFontSpec.SetBold( EFalse );
sl@0
    67
	iDjvMonoFontSpec.SetBitmapType( EMonochromeGlyphBitmap );
sl@0
    68
	iDjvMonoFontSpec.SetMonoWidth( ETrue );
sl@0
    69
	iDjvMonoFontSpec.SetSerif( ETrue );
sl@0
    70
sl@0
    71
	iIdealFontSpec2.SetName( KNullDesC );
sl@0
    72
	iIdealFontSpec2.SetHeight( 10 );
sl@0
    73
	iIdealFontSpec2.SetItalic( EFalse );
sl@0
    74
	iIdealFontSpec2.SetSlantFactor( 0 );
sl@0
    75
	iIdealFontSpec2.SetBold( EFalse );
sl@0
    76
	iIdealFontSpec2.SetBitmapType( EMonochromeGlyphBitmap );
sl@0
    77
	iIdealFontSpec2.SetMonoWidth( EFalse );
sl@0
    78
	iIdealFontSpec2.SetSerif( ETrue );
sl@0
    79
sl@0
    80
	iDjvSerifFontSpec.SetName( KDjvSerif );
sl@0
    81
	iDjvSerifFontSpec.SetHeight( 10 );
sl@0
    82
	iDjvSerifFontSpec.SetItalic( EFalse );
sl@0
    83
	iDjvSerifFontSpec.SetSlantFactor( 0 );
sl@0
    84
	iDjvSerifFontSpec.SetBold( EFalse );
sl@0
    85
	iDjvSerifFontSpec.SetBitmapType( EMonochromeGlyphBitmap );
sl@0
    86
	iDjvSerifFontSpec.SetMonoWidth( EFalse );
sl@0
    87
	iDjvSerifFontSpec.SetSerif( ETrue );
sl@0
    88
sl@0
    89
	iIdealFontSpec3.SetName( KNullDesC );
sl@0
    90
	iIdealFontSpec3.SetHeight( 10 );
sl@0
    91
	iIdealFontSpec3.SetItalic( EFalse );
sl@0
    92
	iIdealFontSpec3.SetSlantFactor( 0 );
sl@0
    93
	iIdealFontSpec3.SetBold( EFalse );
sl@0
    94
	iIdealFontSpec3.SetBitmapType( EMonochromeGlyphBitmap );
sl@0
    95
	iIdealFontSpec3.SetMonoWidth( EFalse );
sl@0
    96
	iIdealFontSpec3.SetSerif( EFalse );
sl@0
    97
sl@0
    98
	iDjvSansFontSpec.SetName( KDjvSans );
sl@0
    99
	iDjvSansFontSpec.SetHeight( 10 );
sl@0
   100
	iDjvSansFontSpec.SetItalic( EFalse );
sl@0
   101
	iDjvSansFontSpec.SetSlantFactor( 0 );
sl@0
   102
	iDjvSansFontSpec.SetBold( EFalse );
sl@0
   103
	iDjvSansFontSpec.SetBitmapType( EMonochromeGlyphBitmap );
sl@0
   104
	iDjvSansFontSpec.SetMonoWidth( EFalse );
sl@0
   105
	iDjvSansFontSpec.SetSerif( EFalse );
sl@0
   106
	
sl@0
   107
	}
sl@0
   108
	
sl@0
   109
/**
sl@0
   110
	@SYMTestCaseID
sl@0
   111
	GRAPHICS-FNTSTORE-0035
sl@0
   112
sl@0
   113
	@SYMTestCaseDesc
sl@0
   114
	Creates a reference font and compares it to different fonts
sl@0
   115
	and sees which font matches the reference font the best.
sl@0
   116
	
sl@0
   117
	@SYMTestActions
sl@0
   118
	1. Reference font: monospaced serif
sl@0
   119
	   Compared fonts: DejaVu Sans Mono, DejaVu Serif Condensed, DejaVu Sans Condensed
sl@0
   120
	2. Reference font: proporional serif font
sl@0
   121
	   Compared fonts: DejaVu Sans Mono, DejaVu Serif Condensed, DejaVu Sans Condensed
sl@0
   122
	3. Reference font: proporional sans serif
sl@0
   123
	   Compared fonts: DejaVu Sans Mono, DejaVu Serif Condensed, DejaVu Sans Condensed	   
sl@0
   124
sl@0
   125
	@SYMTestExpectedResults
sl@0
   126
	1. Should choose DejaVu Sans Mono above DejaVu Serif Condensed above DejaVu Sans Condensed
sl@0
   127
	2. Should choose DejaVu Serif Condensed above DejaVu Sans Condensed above DejaVu Sans Mono
sl@0
   128
	3. Should choose DejaVu Sans Condensed above DejaVu Serif Condensed above DejaVu Sans Mono
sl@0
   129
*/
sl@0
   130
void CTMatchFonts::RunTestCaseL( TInt aCurTestCase )
sl@0
   131
	{
sl@0
   132
	TInt weighting1;
sl@0
   133
	TInt weighting2;
sl@0
   134
	TInt weighting3;
sl@0
   135
	((CTMatchFontsStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
sl@0
   136
sl@0
   137
	switch ( aCurTestCase )
sl@0
   138
		{
sl@0
   139
	case 1:
sl@0
   140
		((CTMatchFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0035"));
sl@0
   141
		// Looking for a monospaced serif font (like DejaVu Sans Mono)
sl@0
   142
		weighting1 = MatchFontSpecsInPixels( iDjvMonoFontSpec, iIdealFontSpec1 );
sl@0
   143
		weighting2 = MatchFontSpecsInPixels( iDjvSerifFontSpec, iIdealFontSpec1 );
sl@0
   144
		weighting3 = MatchFontSpecsInPixels( iDjvSansFontSpec, iIdealFontSpec1 );
sl@0
   145
		// Should choose DejaVu Sans Mono above DejaVu Serif Condensed above DejaVu Sans Condensed
sl@0
   146
		TEST( ( weighting1 > weighting2 ) && ( weighting2 > weighting3 ) );
sl@0
   147
		break;
sl@0
   148
	case 2:
sl@0
   149
		((CTMatchFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0035"));
sl@0
   150
		// Looking for a proporional serif font (like DejaVu Serif Condensed)
sl@0
   151
		weighting1 = MatchFontSpecsInPixels( iDjvMonoFontSpec, iIdealFontSpec2 );
sl@0
   152
		weighting2 = MatchFontSpecsInPixels( iDjvSerifFontSpec, iIdealFontSpec2 );
sl@0
   153
		weighting3 = MatchFontSpecsInPixels( iDjvSansFontSpec, iIdealFontSpec2 );
sl@0
   154
		// Should choose DejaVu Serif Condensed above DejaVu Sans Condensed above DejaVu Sans Mono
sl@0
   155
		TEST( ( weighting2 > weighting3 ) && ( weighting3 > weighting1 ) );
sl@0
   156
		break;
sl@0
   157
	case 3:
sl@0
   158
		((CTMatchFontsStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-0035"));
sl@0
   159
		// Looking for a proporional sans serif font (like DejaVu Sans Condensed)
sl@0
   160
		weighting1 = MatchFontSpecsInPixels( iDjvMonoFontSpec, iIdealFontSpec3 );
sl@0
   161
		weighting2 = MatchFontSpecsInPixels( iDjvSerifFontSpec, iIdealFontSpec3 );
sl@0
   162
		weighting3 = MatchFontSpecsInPixels( iDjvSansFontSpec, iIdealFontSpec3 );
sl@0
   163
		// Should choose DejaVu Sans Condensed above DejaVu Serif Condensed above DejaVu Sans Mono
sl@0
   164
		TEST( ( weighting3 > weighting2 ) && ( weighting2 > weighting1 ) );
sl@0
   165
		break;
sl@0
   166
	case 4:
sl@0
   167
		((CTMatchFontsStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
   168
		((CTMatchFontsStep*)iStep)->CloseTMSGraphicsStep();
sl@0
   169
		TestComplete();		
sl@0
   170
		break;
sl@0
   171
		}
sl@0
   172
	((CTMatchFontsStep*)iStep)->RecordTestResultL();
sl@0
   173
	}
sl@0
   174
sl@0
   175
//--------------
sl@0
   176
__CONSTRUCT_STEP__(MatchFonts)