Chromium Code Reviews| Index: ui/gfx/font_list_unittest.cc |
| diff --git a/ui/gfx/font_list_unittest.cc b/ui/gfx/font_list_unittest.cc |
| index ed34a0d4dc8cfea7b2464d68e0397e09bdd6b439..bad8767f5920e87c15ab4ac4ec0c339d27782c2a 100644 |
| --- a/ui/gfx/font_list_unittest.cc |
| +++ b/ui/gfx/font_list_unittest.cc |
| @@ -9,6 +9,7 @@ |
| #include "base/strings/string_number_conversions.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| +#include "ui/gfx/platform_font_fake.h" |
| namespace { |
| @@ -232,4 +233,35 @@ TEST(FontListTest, Fonts_DeriveFontListWithSize) { |
| EXPECT_EQ("Sans serif|5", FontToString(derived_fonts[1])); |
| } |
| +TEST(FontListTest, Fonts_GetHeight_GetBaseline) { |
| + // Arial: ascent = 8, descent = 2 |
| + PlatformFontFake* pf_arial = new PlatformFontFake("Arial", 10); |
|
msw
2013/07/16 09:32:36
Rather than creating a fake font class, why not ju
Yuki
2013/07/17 07:16:04
Done.
|
| + pf_arial->SetHeight(10); |
| + pf_arial->SetBaseline(8); |
| + Font font_arial(pf_arial); |
| + |
| + // Helvetica: ascent = 6, descent = 4 |
| + PlatformFontFake* pf_helvetica = new PlatformFontFake("Helvetica", 10); |
| + pf_helvetica->SetHeight(10); |
| + pf_helvetica->SetBaseline(6); |
| + Font font_helvetica(pf_helvetica); |
| + |
| + // If the font list has only one font, the height and baseline must be |
| + // the same. |
| + FontList font_list_arial(font_arial); |
| + EXPECT_EQ(font_arial.GetHeight(), font_list_arial.GetHeight()); |
| + EXPECT_EQ(font_arial.GetBaseline(), font_list_arial.GetBaseline()); |
| + |
| + // If there are two different fonts, the font list returns the max value |
| + // for ascent and descent. |
| + std::vector<Font> fonts; |
| + fonts.push_back(font_arial); |
| + fonts.push_back(font_helvetica); |
| + FontList font_list_mix(fonts); |
| + // font_list_mix: ascent = max(8, 6) = 8, descent = max(2, 4) = 4 |
| + // height = 8 + 4 = 12, baseline = 8 |
| + EXPECT_EQ(12, font_list_mix.GetHeight()); |
| + EXPECT_EQ(8, font_list_mix.GetBaseline()); |
| +} |
| + |
| } // namespace gfx |