Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: ui/gfx/font_list_unittest.cc

Issue 1145473006: Disable failing TextEliderTest.* and FontListTest.* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/pylib/gtest/filter/gfx_unittests_disabled ('k') | ui/gfx/text_elider_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/font_list.h" 5 #include "ui/gfx/font_list.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 EXPECT_FALSE(FontList::ParseDescription("Arial,12px,", &families, &style, 66 EXPECT_FALSE(FontList::ParseDescription("Arial,12px,", &families, &style,
67 &size_pixels)); 67 &size_pixels));
68 EXPECT_FALSE(FontList::ParseDescription("Arial,0px", &families, &style, 68 EXPECT_FALSE(FontList::ParseDescription("Arial,0px", &families, &style,
69 &size_pixels)); 69 &size_pixels));
70 EXPECT_FALSE(FontList::ParseDescription("Arial,-1px", &families, &style, 70 EXPECT_FALSE(FontList::ParseDescription("Arial,-1px", &families, &style,
71 &size_pixels)); 71 &size_pixels));
72 EXPECT_FALSE(FontList::ParseDescription("Arial,foo 12px", &families, &style, 72 EXPECT_FALSE(FontList::ParseDescription("Arial,foo 12px", &families, &style,
73 &size_pixels)); 73 &size_pixels));
74 } 74 }
75 75
76 TEST(FontListTest, Fonts_FromDescString) { 76 // TODO(489354): Enable this on android.
77 #if defined(OS_ANDROID)
78 #define MAYBE_Fonts_FromDescString DISABLED_Fonts_FromDescString
79 #else
80 #define MAYBE_Fonts_FromDescString Fonts_FromDescString
81 #endif
82 TEST(FontListTest, MAYBE_Fonts_FromDescString) {
77 // Test init from font name size string. 83 // Test init from font name size string.
78 FontList font_list = FontList("arial, Courier New, 13px"); 84 FontList font_list = FontList("arial, Courier New, 13px");
79 const std::vector<Font>& fonts = font_list.GetFonts(); 85 const std::vector<Font>& fonts = font_list.GetFonts();
80 ASSERT_EQ(2U, fonts.size()); 86 ASSERT_EQ(2U, fonts.size());
81 EXPECT_EQ("arial|13", FontToString(fonts[0])); 87 EXPECT_EQ("arial|13", FontToString(fonts[0]));
82 EXPECT_EQ("Courier New|13", FontToString(fonts[1])); 88 EXPECT_EQ("Courier New|13", FontToString(fonts[1]));
83 } 89 }
84 90
85 TEST(FontListTest, Fonts_FromDescStringInFlexibleFormat) { 91 // TODO(489354): Enable this on android.
92 #if defined(OS_ANDROID)
93 #define MAYBE_Fonts_FromDescStringInFlexibleFormat \
94 DISABLED_Fonts_FromDescStringInFlexibleFormat
95 #else
96 #define MAYBE_Fonts_FromDescStringInFlexibleFormat \
97 Fonts_FromDescStringInFlexibleFormat
98 #endif
99 TEST(FontListTest, MAYBE_Fonts_FromDescStringInFlexibleFormat) {
86 // Test init from font name size string with flexible format. 100 // Test init from font name size string with flexible format.
87 FontList font_list = FontList(" arial , Courier New , 13px"); 101 FontList font_list = FontList(" arial , Courier New , 13px");
88 const std::vector<Font>& fonts = font_list.GetFonts(); 102 const std::vector<Font>& fonts = font_list.GetFonts();
89 ASSERT_EQ(2U, fonts.size()); 103 ASSERT_EQ(2U, fonts.size());
90 EXPECT_EQ("arial|13", FontToString(fonts[0])); 104 EXPECT_EQ("arial|13", FontToString(fonts[0]));
91 EXPECT_EQ("Courier New|13", FontToString(fonts[1])); 105 EXPECT_EQ("Courier New|13", FontToString(fonts[1]));
92 } 106 }
93 107
94 TEST(FontListTest, Fonts_FromDescStringWithStyleInFlexibleFormat) { 108 // TODO(489354): Enable this on android.
109 #if defined(OS_ANDROID)
110 #define MAYBE_Fonts_FromDescStringWithStyleInFlexibleFormat \
111 DISABLED_Fonts_FromDescStringWithStyleInFlexibleFormat
112 #else
113 #define MAYBE_Fonts_FromDescStringWithStyleInFlexibleFormat \
114 Fonts_FromDescStringWithStyleInFlexibleFormat
115 #endif
116 TEST(FontListTest, MAYBE_Fonts_FromDescStringWithStyleInFlexibleFormat) {
95 // Test init from font name style size string with flexible format. 117 // Test init from font name style size string with flexible format.
96 FontList font_list = FontList(" arial , Courier New , Bold " 118 FontList font_list = FontList(" arial , Courier New , Bold "
97 " Italic 13px"); 119 " Italic 13px");
98 const std::vector<Font>& fonts = font_list.GetFonts(); 120 const std::vector<Font>& fonts = font_list.GetFonts();
99 ASSERT_EQ(2U, fonts.size()); 121 ASSERT_EQ(2U, fonts.size());
100 EXPECT_EQ("arial|13|bold|italic", FontToString(fonts[0])); 122 EXPECT_EQ("arial|13|bold|italic", FontToString(fonts[0]));
101 EXPECT_EQ("Courier New|13|bold|italic", FontToString(fonts[1])); 123 EXPECT_EQ("Courier New|13|bold|italic", FontToString(fonts[1]));
102 } 124 }
103 125
104 TEST(FontListTest, Fonts_FromFont) { 126 // TODO(489354): Enable this on android.
127 #if defined(OS_ANDROID)
128 #define MAYBE_Fonts_FromFont DISABLED_Fonts_FromFont
129 #else
130 #define MAYBE_Fonts_FromFont Fonts_FromFont
131 #endif
132 TEST(FontListTest, MAYBE_Fonts_FromFont) {
105 // Test init from Font. 133 // Test init from Font.
106 Font font("Arial", 8); 134 Font font("Arial", 8);
107 FontList font_list = FontList(font); 135 FontList font_list = FontList(font);
108 const std::vector<Font>& fonts = font_list.GetFonts(); 136 const std::vector<Font>& fonts = font_list.GetFonts();
109 ASSERT_EQ(1U, fonts.size()); 137 ASSERT_EQ(1U, fonts.size());
110 EXPECT_EQ("Arial|8", FontToString(fonts[0])); 138 EXPECT_EQ("Arial|8", FontToString(fonts[0]));
111 } 139 }
112 140
113 TEST(FontListTest, Fonts_FromFontWithNonNormalStyle) { 141 // TODO(489354): Enable this on android.
142 #if defined(OS_ANDROID)
143 #define MAYBE_Fonts_FromFontWithNonNormalStyle \
144 DISABLED_Fonts_FromFontWithNonNormalStyle
145 #else
146 #define MAYBE_Fonts_FromFontWithNonNormalStyle Fonts_FromFontWithNonNormalStyle
147 #endif
148 TEST(FontListTest, MAYBE_Fonts_FromFontWithNonNormalStyle) {
114 // Test init from Font with non-normal style. 149 // Test init from Font with non-normal style.
115 Font font("Arial", 8); 150 Font font("Arial", 8);
116 FontList font_list = FontList(font.Derive(2, Font::BOLD)); 151 FontList font_list = FontList(font.Derive(2, Font::BOLD));
117 std::vector<Font> fonts = font_list.GetFonts(); 152 std::vector<Font> fonts = font_list.GetFonts();
118 ASSERT_EQ(1U, fonts.size()); 153 ASSERT_EQ(1U, fonts.size());
119 EXPECT_EQ("Arial|10|bold", FontToString(fonts[0])); 154 EXPECT_EQ("Arial|10|bold", FontToString(fonts[0]));
120 155
121 font_list = FontList(font.Derive(-2, Font::ITALIC)); 156 font_list = FontList(font.Derive(-2, Font::ITALIC));
122 fonts = font_list.GetFonts(); 157 fonts = font_list.GetFonts();
123 ASSERT_EQ(1U, fonts.size()); 158 ASSERT_EQ(1U, fonts.size());
124 EXPECT_EQ("Arial|6|italic", FontToString(fonts[0])); 159 EXPECT_EQ("Arial|6|italic", FontToString(fonts[0]));
125 } 160 }
126 161
127 TEST(FontListTest, Fonts_FromFontVector) { 162 // TODO(489354): Enable this on android.
163 #if defined(OS_ANDROID)
164 #define MAYBE_Fonts_FromFontVector DISABLED_Fonts_FromFontVector
165 #else
166 #define MAYBE_Fonts_FromFontVector Fonts_FromFontVector
167 #endif
168 TEST(FontListTest, MAYBE_Fonts_FromFontVector) {
128 // Test init from Font vector. 169 // Test init from Font vector.
129 Font font("Arial", 8); 170 Font font("Arial", 8);
130 Font font_1("Courier New", 10); 171 Font font_1("Courier New", 10);
131 std::vector<Font> input_fonts; 172 std::vector<Font> input_fonts;
132 input_fonts.push_back(font.Derive(0, Font::BOLD)); 173 input_fonts.push_back(font.Derive(0, Font::BOLD));
133 input_fonts.push_back(font_1.Derive(-2, Font::BOLD)); 174 input_fonts.push_back(font_1.Derive(-2, Font::BOLD));
134 FontList font_list = FontList(input_fonts); 175 FontList font_list = FontList(input_fonts);
135 const std::vector<Font>& fonts = font_list.GetFonts(); 176 const std::vector<Font>& fonts = font_list.GetFonts();
136 ASSERT_EQ(2U, fonts.size()); 177 ASSERT_EQ(2U, fonts.size());
137 EXPECT_EQ("Arial|8|bold", FontToString(fonts[0])); 178 EXPECT_EQ("Arial|8|bold", FontToString(fonts[0]));
138 EXPECT_EQ("Courier New|8|bold", FontToString(fonts[1])); 179 EXPECT_EQ("Courier New|8|bold", FontToString(fonts[1]));
139 } 180 }
140 181
141 TEST(FontListTest, FontDescString_GetStyle) { 182 TEST(FontListTest, FontDescString_GetStyle) {
142 FontList font_list = FontList("Arial,Sans serif, 8px"); 183 FontList font_list = FontList("Arial,Sans serif, 8px");
143 EXPECT_EQ(Font::NORMAL, font_list.GetFontStyle()); 184 EXPECT_EQ(Font::NORMAL, font_list.GetFontStyle());
144 185
145 font_list = FontList("Arial,Sans serif,Bold 8px"); 186 font_list = FontList("Arial,Sans serif,Bold 8px");
146 EXPECT_EQ(Font::BOLD, font_list.GetFontStyle()); 187 EXPECT_EQ(Font::BOLD, font_list.GetFontStyle());
147 188
148 font_list = FontList("Arial,Sans serif,Italic 8px"); 189 font_list = FontList("Arial,Sans serif,Italic 8px");
149 EXPECT_EQ(Font::ITALIC, font_list.GetFontStyle()); 190 EXPECT_EQ(Font::ITALIC, font_list.GetFontStyle());
150 191
151 font_list = FontList("Arial,Italic Bold 8px"); 192 font_list = FontList("Arial,Italic Bold 8px");
152 EXPECT_EQ(Font::BOLD | Font::ITALIC, font_list.GetFontStyle()); 193 EXPECT_EQ(Font::BOLD | Font::ITALIC, font_list.GetFontStyle());
153 } 194 }
154 195
155 TEST(FontListTest, Fonts_GetStyle) { 196 // TODO(489354): Enable this on android.
197 #if defined(OS_ANDROID)
198 #define MAYBE_Fonts_GetStyle DISABLED_Fonts_GetStyle
199 #else
200 #define MAYBE_Fonts_GetStyle Fonts_GetStyle
201 #endif
202 TEST(FontListTest, MAYBE_Fonts_GetStyle) {
156 std::vector<Font> fonts; 203 std::vector<Font> fonts;
157 fonts.push_back(gfx::Font("Arial", 8)); 204 fonts.push_back(gfx::Font("Arial", 8));
158 fonts.push_back(gfx::Font("Sans serif", 8)); 205 fonts.push_back(gfx::Font("Sans serif", 8));
159 FontList font_list = FontList(fonts); 206 FontList font_list = FontList(fonts);
160 EXPECT_EQ(Font::NORMAL, font_list.GetFontStyle()); 207 EXPECT_EQ(Font::NORMAL, font_list.GetFontStyle());
161 fonts[0] = fonts[0].Derive(0, Font::ITALIC | Font::BOLD); 208 fonts[0] = fonts[0].Derive(0, Font::ITALIC | Font::BOLD);
162 fonts[1] = fonts[1].Derive(0, Font::ITALIC | Font::BOLD); 209 fonts[1] = fonts[1].Derive(0, Font::ITALIC | Font::BOLD);
163 font_list = FontList(fonts); 210 font_list = FontList(fonts);
164 EXPECT_EQ(Font::ITALIC | Font::BOLD, font_list.GetFontStyle()); 211 EXPECT_EQ(Font::ITALIC | Font::BOLD, font_list.GetFontStyle());
165 } 212 }
166 213
167 TEST(FontListTest, Fonts_Derive) { 214 // TODO(489354): Enable this on android.
215 #if defined(OS_ANDROID)
216 #define MAYBE_Fonts_Derive DISABLED_Fonts_Derive
217 #else
218 #define MAYBE_Fonts_Derive Fonts_Derive
219 #endif
220 TEST(FontListTest, MAYBE_Fonts_Derive) {
168 std::vector<Font> fonts; 221 std::vector<Font> fonts;
169 fonts.push_back(gfx::Font("Arial", 8)); 222 fonts.push_back(gfx::Font("Arial", 8));
170 fonts.push_back(gfx::Font("Courier New", 8)); 223 fonts.push_back(gfx::Font("Courier New", 8));
171 FontList font_list = FontList(fonts); 224 FontList font_list = FontList(fonts);
172 225
173 FontList derived = font_list.Derive(5, Font::BOLD | Font::UNDERLINE); 226 FontList derived = font_list.Derive(5, Font::BOLD | Font::UNDERLINE);
174 const std::vector<Font>& derived_fonts = derived.GetFonts(); 227 const std::vector<Font>& derived_fonts = derived.GetFonts();
175 228
176 EXPECT_EQ(2U, derived_fonts.size()); 229 EXPECT_EQ(2U, derived_fonts.size());
177 EXPECT_EQ("Arial|13|bold|underline", FontToString(derived_fonts[0])); 230 EXPECT_EQ("Arial|13|bold|underline", FontToString(derived_fonts[0]));
178 EXPECT_EQ("Courier New|13|bold|underline", FontToString(derived_fonts[1])); 231 EXPECT_EQ("Courier New|13|bold|underline", FontToString(derived_fonts[1]));
179 } 232 }
180 233
181 TEST(FontListTest, Fonts_DeriveWithSizeDelta) { 234 // TODO(489354): Enable this on android.
235 #if defined(OS_ANDROID)
236 #define MAYBE_Fonts_DeriveWithSizeDelta DISABLED_Fonts_DeriveWithSizeDelta
237 #else
238 #define MAYBE_Fonts_DeriveWithSizeDelta Fonts_DeriveWithSizeDelta
239 #endif
240 TEST(FontListTest, MAYBE_Fonts_DeriveWithSizeDelta) {
182 std::vector<Font> fonts; 241 std::vector<Font> fonts;
183 fonts.push_back(gfx::Font("Arial", 18).Derive(0, Font::ITALIC)); 242 fonts.push_back(gfx::Font("Arial", 18).Derive(0, Font::ITALIC));
184 fonts.push_back(gfx::Font("Courier New", 18).Derive(0, Font::ITALIC)); 243 fonts.push_back(gfx::Font("Courier New", 18).Derive(0, Font::ITALIC));
185 FontList font_list = FontList(fonts); 244 FontList font_list = FontList(fonts);
186 245
187 FontList derived = font_list.DeriveWithSizeDelta(-5); 246 FontList derived = font_list.DeriveWithSizeDelta(-5);
188 const std::vector<Font>& derived_fonts = derived.GetFonts(); 247 const std::vector<Font>& derived_fonts = derived.GetFonts();
189 248
190 EXPECT_EQ(2U, derived_fonts.size()); 249 EXPECT_EQ(2U, derived_fonts.size());
191 EXPECT_EQ("Arial|13|italic", FontToString(derived_fonts[0])); 250 EXPECT_EQ("Arial|13|italic", FontToString(derived_fonts[0]));
192 EXPECT_EQ("Courier New|13|italic", FontToString(derived_fonts[1])); 251 EXPECT_EQ("Courier New|13|italic", FontToString(derived_fonts[1]));
193 } 252 }
194 253
195 TEST(FontListTest, Fonts_GetHeight_GetBaseline) { 254 // TODO(489354): Enable this on android.
255 #if defined(OS_ANDROID)
256 #define MAYBE_Fonts_GetHeight_GetBaseline DISABLED_Fonts_GetHeight_GetBaseline
257 #else
258 #define MAYBE_Fonts_GetHeight_GetBaseline Fonts_GetHeight_GetBaseline
259 #endif
260 TEST(FontListTest, MAYBE_Fonts_GetHeight_GetBaseline) {
196 // If a font list has only one font, the height and baseline must be the same. 261 // If a font list has only one font, the height and baseline must be the same.
197 Font font1("Arial", 16); 262 Font font1("Arial", 16);
198 ASSERT_EQ("arial", 263 ASSERT_EQ("arial",
199 base::StringToLowerASCII(font1.GetActualFontNameForTesting())); 264 base::StringToLowerASCII(font1.GetActualFontNameForTesting()));
200 FontList font_list1("Arial, 16px"); 265 FontList font_list1("Arial, 16px");
201 EXPECT_EQ(font1.GetHeight(), font_list1.GetHeight()); 266 EXPECT_EQ(font1.GetHeight(), font_list1.GetHeight());
202 EXPECT_EQ(font1.GetBaseline(), font_list1.GetBaseline()); 267 EXPECT_EQ(font1.GetBaseline(), font_list1.GetBaseline());
203 268
204 // If there are two different fonts, the font list returns the max value 269 // If there are two different fonts, the font list returns the max value
205 // for the baseline (ascent) and height. 270 // for the baseline (ascent) and height.
206 Font font2("Symbol", 16); 271 Font font2("Symbol", 16);
207 ASSERT_EQ("symbol", 272 ASSERT_EQ("symbol",
208 base::StringToLowerASCII(font2.GetActualFontNameForTesting())); 273 base::StringToLowerASCII(font2.GetActualFontNameForTesting()));
209 EXPECT_NE(font1.GetBaseline(), font2.GetBaseline()); 274 EXPECT_NE(font1.GetBaseline(), font2.GetBaseline());
210 // TODO(ananta): Find a size and font pair with reliably distinct descents. 275 // TODO(ananta): Find a size and font pair with reliably distinct descents.
211 EXPECT_NE(font1.GetHeight(), font2.GetHeight()); 276 EXPECT_NE(font1.GetHeight(), font2.GetHeight());
212 std::vector<Font> fonts; 277 std::vector<Font> fonts;
213 fonts.push_back(font1); 278 fonts.push_back(font1);
214 fonts.push_back(font2); 279 fonts.push_back(font2);
215 FontList font_list_mix(fonts); 280 FontList font_list_mix(fonts);
216 // ascent of FontList == max(ascent of Fonts) 281 // ascent of FontList == max(ascent of Fonts)
217 EXPECT_EQ(std::max(font1.GetBaseline(), font2.GetBaseline()), 282 EXPECT_EQ(std::max(font1.GetBaseline(), font2.GetBaseline()),
218 font_list_mix.GetBaseline()); 283 font_list_mix.GetBaseline());
219 // descent of FontList == max(descent of Fonts) 284 // descent of FontList == max(descent of Fonts)
220 EXPECT_EQ(std::max(font1.GetHeight() - font1.GetBaseline(), 285 EXPECT_EQ(std::max(font1.GetHeight() - font1.GetBaseline(),
221 font2.GetHeight() - font2.GetBaseline()), 286 font2.GetHeight() - font2.GetBaseline()),
222 font_list_mix.GetHeight() - font_list_mix.GetBaseline()); 287 font_list_mix.GetHeight() - font_list_mix.GetBaseline());
223 } 288 }
224 289
225 TEST(FontListTest, Fonts_DeriveWithHeightUpperBound) { 290 // TODO(489354): Enable this on android.
291 #if defined(OS_ANDROID)
292 #define MAYBE_Fonts_DeriveWithHeightUpperBound \
293 DISABLED_Fonts_DeriveWithHeightUpperBound
294 #else
295 #define MAYBE_Fonts_DeriveWithHeightUpperBound Fonts_DeriveWithHeightUpperBound
296 #endif
297 TEST(FontListTest, MAYBE_Fonts_DeriveWithHeightUpperBound) {
226 std::vector<Font> fonts; 298 std::vector<Font> fonts;
227 299
228 fonts.push_back(gfx::Font("Arial", 18)); 300 fonts.push_back(gfx::Font("Arial", 18));
229 fonts.push_back(gfx::Font("Sans serif", 18)); 301 fonts.push_back(gfx::Font("Sans serif", 18));
230 fonts.push_back(gfx::Font("Symbol", 18)); 302 fonts.push_back(gfx::Font("Symbol", 18));
231 FontList font_list = FontList(fonts); 303 FontList font_list = FontList(fonts);
232 304
233 // A smaller upper bound should derive a font list with a smaller height. 305 // A smaller upper bound should derive a font list with a smaller height.
234 const int height_1 = font_list.GetHeight() - 5; 306 const int height_1 = font_list.GetHeight() - 5;
235 FontList derived_1 = font_list.DeriveWithHeightUpperBound(height_1); 307 FontList derived_1 = font_list.DeriveWithHeightUpperBound(height_1);
236 EXPECT_LE(derived_1.GetHeight(), height_1); 308 EXPECT_LE(derived_1.GetHeight(), height_1);
237 EXPECT_LT(derived_1.GetHeight(), font_list.GetHeight()); 309 EXPECT_LT(derived_1.GetHeight(), font_list.GetHeight());
238 EXPECT_LT(derived_1.GetFontSize(), font_list.GetFontSize()); 310 EXPECT_LT(derived_1.GetFontSize(), font_list.GetFontSize());
239 311
240 // A larger upper bound should not change the height of the font list. 312 // A larger upper bound should not change the height of the font list.
241 const int height_2 = font_list.GetHeight() + 5; 313 const int height_2 = font_list.GetHeight() + 5;
242 FontList derived_2 = font_list.DeriveWithHeightUpperBound(height_2); 314 FontList derived_2 = font_list.DeriveWithHeightUpperBound(height_2);
243 EXPECT_LE(derived_2.GetHeight(), height_2); 315 EXPECT_LE(derived_2.GetHeight(), height_2);
244 EXPECT_EQ(font_list.GetHeight(), derived_2.GetHeight()); 316 EXPECT_EQ(font_list.GetHeight(), derived_2.GetHeight());
245 EXPECT_EQ(font_list.GetFontSize(), derived_2.GetFontSize()); 317 EXPECT_EQ(font_list.GetFontSize(), derived_2.GetFontSize());
246 } 318 }
247 319
248 } // namespace gfx 320 } // namespace gfx
OLDNEW
« no previous file with comments | « build/android/pylib/gtest/filter/gfx_unittests_disabled ('k') | ui/gfx/text_elider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698