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