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 170f6e8125965310a32b97268cad33e2c7369f0c..d230f80364db2b37260664d2dc25dae7e7c2115e 100644 |
| --- a/ui/gfx/font_list_unittest.cc |
| +++ b/ui/gfx/font_list_unittest.cc |
| @@ -37,6 +37,18 @@ TEST(FontListTest, FontDescString_FromDescString) { |
| EXPECT_EQ("Droid Sans serif, Sans serif, 10px", font_str); |
| } |
| +TEST(FontListTest, FontDescString_FromFontNamesStyleAndSize) { |
| + // Test init from font names, style and size. |
| + std::vector<std::string> font_names; |
| + font_names.push_back("Arial"); |
| + font_names.push_back("Droid Sans serif"); |
| + int font_style = Font::BOLD | Font::ITALIC; |
| + int font_size = 11; |
| + FontList font_list = FontList(font_names, font_style, font_size); |
| + const std::string& font_str = font_list.GetFontDescriptionString(); |
|
msw
2013/08/06 05:10:14
nit: Inline font_list.GetFontDescriptionString() w
Yuki
2013/08/07 14:34:03
Done.
|
| + EXPECT_EQ("Arial,Droid Sans serif,Bold Italic 11px", font_str); |
| +} |
| + |
| TEST(FontListTest, FontDescString_FromFont) { |
| // Test init from Font. |
| Font font("Arial", 8); |
| @@ -233,6 +245,52 @@ TEST(FontListTest, Fonts_DeriveFontListWithSize) { |
| EXPECT_EQ("Sans serif|5", FontToString(derived_fonts[1])); |
| } |
| +TEST(FontListTest, FontDescString_DeriveFontListWithSizeDelta) { |
| + FontList font_list = FontList("Arial,Sans serif,Bold 18px"); |
| + |
| + FontList derived = font_list.DeriveFontListWithSizeDelta(-8); |
| + EXPECT_EQ("Arial,Sans serif,Bold 10px", |
| + derived.GetFontDescriptionString()); |
| +} |
| + |
| +TEST(FontListTest, Fonts_DeriveFontListWithSizeDelta) { |
| + std::vector<Font> fonts; |
| + fonts.push_back(gfx::Font("Arial", 18).DeriveFont(0, Font::ITALIC)); |
| + fonts.push_back(gfx::Font("Sans serif", 18).DeriveFont(0, Font::ITALIC)); |
| + FontList font_list = FontList(fonts); |
| + |
| + FontList derived = font_list.DeriveFontListWithSizeDelta(-5); |
| + const std::vector<Font>& derived_fonts = derived.GetFonts(); |
| + |
| + EXPECT_EQ(2U, derived_fonts.size()); |
| + EXPECT_EQ("Arial|13|italic", FontToString(derived_fonts[0])); |
|
msw
2013/08/06 05:10:14
nit: Check GetFontDescriptionString() instead, whe
Yuki
2013/08/07 14:34:03
I guess that the original author intended to test
msw
2013/08/07 17:13:41
Okay, that's fair; thanks for the explanation.
|
| + EXPECT_EQ("Sans serif|13|italic", FontToString(derived_fonts[1])); |
| +} |
| + |
| +TEST(FontListTest, FontDescString_DeriveFontListWithSizeDeltaAndStyle) { |
| + FontList font_list = FontList("Arial,Sans serif,Bold Italic 8px"); |
| + |
| + FontList derived = |
| + font_list.DeriveFontListWithSizeDeltaAndStyle(10, Font::ITALIC); |
| + EXPECT_EQ("Arial,Sans serif,Italic 18px", |
| + derived.GetFontDescriptionString()); |
| +} |
| + |
| +TEST(FontListTest, Fonts_DeriveFontListWithSizeDeltaAndStyle) { |
| + std::vector<Font> fonts; |
| + fonts.push_back(gfx::Font("Arial", 8)); |
| + fonts.push_back(gfx::Font("Sans serif", 8)); |
| + FontList font_list = FontList(fonts); |
| + |
| + FontList derived = |
| + font_list.DeriveFontListWithSizeDeltaAndStyle(5, Font::BOLD); |
| + const std::vector<Font>& derived_fonts = derived.GetFonts(); |
| + |
| + EXPECT_EQ(2U, derived_fonts.size()); |
| + EXPECT_EQ("Arial|13|bold", FontToString(derived_fonts[0])); |
| + EXPECT_EQ("Sans serif|13|bold", FontToString(derived_fonts[1])); |
| +} |
| + |
| TEST(FontListTest, Fonts_GetHeight_GetBaseline) { |
| // If a font list has only one font, the height and baseline must be the same. |
| Font font1("Arial", 16); |