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

Unified Diff: ui/gfx/font_list_unittest.cc

Issue 19352002: Fixes vertical alignment of RenderText. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes the unit test. Created 7 years, 5 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') | ui/gfx/render_text.cc » ('j') | 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 ed34a0d4dc8cfea7b2464d68e0397e09bdd6b439..170f6e8125965310a32b97268cad33e2c7369f0c 100644
--- a/ui/gfx/font_list_unittest.cc
+++ b/ui/gfx/font_list_unittest.cc
@@ -4,6 +4,7 @@
#include "ui/gfx/font_list.h"
+#include <algorithm>
#include <string>
#include <vector>
@@ -232,4 +233,30 @@ TEST(FontListTest, Fonts_DeriveFontListWithSize) {
EXPECT_EQ("Sans serif|5", 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);
+ FontList font_list1("Arial, 16px");
+ EXPECT_EQ(font1.GetHeight(), font_list1.GetHeight());
+ EXPECT_EQ(font1.GetBaseline(), font_list1.GetBaseline());
+
+ // If there are two different fonts, the font list returns the max value
+ // for ascent and descent.
+ Font font2("Symbol", 16);
+ EXPECT_NE(font1.GetBaseline(), font2.GetBaseline());
+ EXPECT_NE(font1.GetHeight() - font1.GetBaseline(),
+ font2.GetHeight() - font2.GetBaseline());
+ std::vector<Font> fonts;
+ fonts.push_back(font1);
+ fonts.push_back(font2);
+ FontList font_list_mix(fonts);
+ // ascent of FontList == max(ascent of Fonts)
msw 2013/07/19 17:30:34 nit: Capitalize 'Ascent' here and 'Descent' below.
+ EXPECT_EQ(std::max(font1.GetHeight() - font1.GetBaseline(),
+ font2.GetHeight() - font2.GetBaseline()),
+ font_list_mix.GetHeight() - font_list_mix.GetBaseline());
+ // descent of FontList == max(descent of Fonts)
+ EXPECT_EQ(std::max(font1.GetBaseline(), font2.GetBaseline()),
+ font_list_mix.GetBaseline());
+}
+
} // namespace gfx
« no previous file with comments | « ui/gfx/font_list.cc ('k') | ui/gfx/render_text.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698