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

Unified Diff: ui/gfx/font_list_unittest.cc

Issue 119993002: Makes gfx::FontList carry UNDERLINE flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disabled FontListTest.FontDescString_DeriveFontListWithSizeDeltaAndStyle on Android. Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/font_list.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/font_list_unittest.cc
diff --git a/ui/gfx/font_list_unittest.cc b/ui/gfx/font_list_unittest.cc
index 6cbb41fbecda73ecb0e8b51efc395488233a54c9..66cb26065f3810eb7b3522a66dc181a722188939 100644
--- a/ui/gfx/font_list_unittest.cc
+++ b/ui/gfx/font_list_unittest.cc
@@ -24,6 +24,8 @@ std::string FontToString(const gfx::Font& font) {
font_string += "|bold";
if (style & gfx::Font::ITALIC)
font_string += "|italic";
+ if (style & gfx::Font::UNDERLINE)
+ font_string += "|underline";
return font_string;
}
@@ -43,9 +45,10 @@ TEST(FontListTest, FontDescString_FromFontNamesStyleAndSize) {
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_style = Font::BOLD | Font::ITALIC | Font::UNDERLINE;
int font_size = 11;
FontList font_list = FontList(font_names, font_style, font_size);
+ // "Underline" doesn't appear in the font description string.
EXPECT_EQ("Arial,Droid Sans serif,Bold Italic 11px",
font_list.GetFontDescriptionString());
}
@@ -65,6 +68,10 @@ TEST(FontListTest, FontDescString_FromFontWithNonNormalStyle) {
font_list = FontList(font.DeriveFont(-2, Font::ITALIC));
EXPECT_EQ("Arial,Italic 6px", font_list.GetFontDescriptionString());
+
+ // "Underline" doesn't appear in the font description string.
+ font_list = FontList(font.DeriveFont(-4, Font::UNDERLINE));
+ EXPECT_EQ("Arial,4px", font_list.GetFontDescriptionString());
}
TEST(FontListTest, FontDescString_FromFontVector) {
@@ -269,10 +276,18 @@ TEST(FontListTest, Fonts_DeriveFontListWithSizeDelta) {
TEST(FontListTest, FontDescString_DeriveFontListWithSizeDeltaAndStyle) {
FontList font_list = FontList("Arial,Sans serif,Bold Italic 8px");
- FontList derived =
- font_list.DeriveFontListWithSizeDeltaAndStyle(10, Font::ITALIC);
+ FontList derived = font_list.DeriveFontListWithSizeDeltaAndStyle(
+ 10, Font::ITALIC | Font::UNDERLINE);
EXPECT_EQ("Arial,Sans serif,Italic 18px",
derived.GetFontDescriptionString());
+ EXPECT_EQ(Font::ITALIC | Font::UNDERLINE,
+ derived.GetFontStyle());
+
+ // FontList has a special care for Font::UNDERLINE. See if the handling of
+ // Font::UNDERLINE in GetFonts() is okay or not.
+ derived.GetFonts();
+ EXPECT_EQ(Font::ITALIC | Font::UNDERLINE,
+ derived.GetFontStyle());
}
TEST(FontListTest, Fonts_DeriveFontListWithSizeDeltaAndStyle) {
@@ -281,13 +296,13 @@ TEST(FontListTest, Fonts_DeriveFontListWithSizeDeltaAndStyle) {
fonts.push_back(gfx::Font("Sans serif", 8));
FontList font_list = FontList(fonts);
- FontList derived =
- font_list.DeriveFontListWithSizeDeltaAndStyle(5, Font::BOLD);
+ FontList derived = font_list.DeriveFontListWithSizeDeltaAndStyle(
+ 5, Font::BOLD | Font::UNDERLINE);
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]));
+ EXPECT_EQ("Arial|13|bold|underline", FontToString(derived_fonts[0]));
+ EXPECT_EQ("Sans serif|13|bold|underline", FontToString(derived_fonts[1]));
}
TEST(FontListTest, Fonts_GetHeight_GetBaseline) {
« no previous file with comments | « ui/gfx/font_list.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698