OLD | NEW |
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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 fonts.push_back(Font("Courier New", 8)); | 253 fonts.push_back(Font("Courier New", 8)); |
254 FontList font_list = FontList(fonts); | 254 FontList font_list = FontList(fonts); |
255 | 255 |
256 FontList derived = font_list.Derive(5, Font::ITALIC, Font::Weight::BOLD); | 256 FontList derived = font_list.Derive(5, Font::ITALIC, Font::Weight::BOLD); |
257 const std::vector<Font>& derived_fonts = derived.GetFonts(); | 257 const std::vector<Font>& derived_fonts = derived.GetFonts(); |
258 | 258 |
259 EXPECT_EQ(2U, derived_fonts.size()); | 259 EXPECT_EQ(2U, derived_fonts.size()); |
260 EXPECT_EQ("Arial|13|italic|bold", FontToString(derived_fonts[0])); | 260 EXPECT_EQ("Arial|13|italic|bold", FontToString(derived_fonts[0])); |
261 EXPECT_EQ("Courier New|13|italic|bold", FontToString(derived_fonts[1])); | 261 EXPECT_EQ("Courier New|13|italic|bold", FontToString(derived_fonts[1])); |
262 | 262 |
263 // TODO(mboc): Linux has never supported UNDERLINE. Fix this if possible. | |
264 #if !defined(OS_LINUX) | |
265 derived = font_list.Derive(5, Font::UNDERLINE, Font::Weight::BOLD); | 263 derived = font_list.Derive(5, Font::UNDERLINE, Font::Weight::BOLD); |
266 const std::vector<Font>& underline_fonts = derived.GetFonts(); | 264 const std::vector<Font>& underline_fonts = derived.GetFonts(); |
267 | 265 |
268 EXPECT_EQ(2U, underline_fonts.size()); | 266 EXPECT_EQ(2U, underline_fonts.size()); |
269 EXPECT_EQ("Arial|13|underline|bold", FontToString(underline_fonts[0])); | 267 EXPECT_EQ("Arial|13|underline|bold", FontToString(underline_fonts[0])); |
270 EXPECT_EQ("Courier New|13|underline|bold", FontToString(underline_fonts[1])); | 268 EXPECT_EQ("Courier New|13|underline|bold", FontToString(underline_fonts[1])); |
271 #endif | |
272 } | 269 } |
273 | 270 |
274 // TODO(489354): Enable this on android. | 271 // TODO(489354): Enable this on android. |
275 #if defined(OS_ANDROID) | 272 #if defined(OS_ANDROID) |
276 #define MAYBE_Fonts_DeriveWithSizeDelta DISABLED_Fonts_DeriveWithSizeDelta | 273 #define MAYBE_Fonts_DeriveWithSizeDelta DISABLED_Fonts_DeriveWithSizeDelta |
277 #else | 274 #else |
278 #define MAYBE_Fonts_DeriveWithSizeDelta Fonts_DeriveWithSizeDelta | 275 #define MAYBE_Fonts_DeriveWithSizeDelta Fonts_DeriveWithSizeDelta |
279 #endif | 276 #endif |
280 TEST(FontListTest, MAYBE_Fonts_DeriveWithSizeDelta) { | 277 TEST(FontListTest, MAYBE_Fonts_DeriveWithSizeDelta) { |
281 std::vector<Font> fonts; | 278 std::vector<Font> fonts; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 348 |
352 // A larger upper bound should not change the height of the font list. | 349 // A larger upper bound should not change the height of the font list. |
353 const int height_2 = font_list.GetHeight() + 5; | 350 const int height_2 = font_list.GetHeight() + 5; |
354 FontList derived_2 = font_list.DeriveWithHeightUpperBound(height_2); | 351 FontList derived_2 = font_list.DeriveWithHeightUpperBound(height_2); |
355 EXPECT_LE(derived_2.GetHeight(), height_2); | 352 EXPECT_LE(derived_2.GetHeight(), height_2); |
356 EXPECT_EQ(font_list.GetHeight(), derived_2.GetHeight()); | 353 EXPECT_EQ(font_list.GetHeight(), derived_2.GetHeight()); |
357 EXPECT_EQ(font_list.GetFontSize(), derived_2.GetFontSize()); | 354 EXPECT_EQ(font_list.GetFontSize(), derived_2.GetFontSize()); |
358 } | 355 } |
359 | 356 |
360 } // namespace gfx | 357 } // namespace gfx |
OLD | NEW |