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

Unified Diff: ui/gfx/font_list_unittest.cc

Issue 21868004: Supports FontList::DeriveFontListWithSizeDeltaAndStyle, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a TODO comment, updated comments. Created 7 years, 4 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 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 170f6e8125965310a32b97268cad33e2c7369f0c..a62a13db469e312edc6b85c301412109a5f396e4 100644
--- a/ui/gfx/font_list_unittest.cc
+++ b/ui/gfx/font_list_unittest.cc
@@ -33,16 +33,27 @@ namespace gfx {
TEST(FontListTest, FontDescString_FromDescString) {
// Test init from font name style size string.
FontList font_list = FontList("Droid Sans serif, Sans serif, 10px");
- const std::string& font_str = font_list.GetFontDescriptionString();
- EXPECT_EQ("Droid Sans serif, Sans serif, 10px", font_str);
+ EXPECT_EQ("Droid Sans serif, Sans serif, 10px",
+ font_list.GetFontDescriptionString());
+}
+
+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);
+ EXPECT_EQ("Arial,Droid Sans serif,Bold Italic 11px",
+ font_list.GetFontDescriptionString());
}
TEST(FontListTest, FontDescString_FromFont) {
// Test init from Font.
Font font("Arial", 8);
FontList font_list = FontList(font);
- const std::string& font_str = font_list.GetFontDescriptionString();
- EXPECT_EQ("Arial,8px", font_str);
+ EXPECT_EQ("Arial,8px", font_list.GetFontDescriptionString());
}
TEST(FontListTest, FontDescString_FromFontWithNonNormalStyle) {
@@ -63,8 +74,7 @@ TEST(FontListTest, FontDescString_FromFontVector) {
fonts.push_back(font.DeriveFont(0, Font::BOLD));
fonts.push_back(font_1.DeriveFont(-2, Font::BOLD));
FontList font_list = FontList(fonts);
- const std::string& font_str = font_list.GetFontDescriptionString();
- EXPECT_EQ("Arial,Sans serif,Bold 8px", font_str);
+ EXPECT_EQ("Arial,Sans serif,Bold 8px", font_list.GetFontDescriptionString());
}
TEST(FontListTest, Fonts_FromDescString) {
@@ -233,6 +243,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]));
+ 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);
« 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