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

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: Changes a font and fixes the unit test again. 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..a2a4eed025f1a6a44e2341bfbba612fdde87566b 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,27 @@ 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(),
msw 2013/07/17 17:30:32 Should this also EXPECT_NE(font1.GetHeight(), font
Yuki 2013/07/19 14:40:59 Since we specified the same font size, it's possib
+ font2.GetHeight() - font2.GetBaseline());
+ std::vector<Font> fonts;
+ fonts.push_back(font1);
+ fonts.push_back(font2);
+ FontList font_list_mix(fonts);
+ EXPECT_LE(std::max(font1.GetHeight(), font2.GetHeight()),
msw 2013/07/17 17:30:32 Should the height be calculated the same here as i
Yuki 2013/07/19 14:40:59 Done.
msw 2013/07/19 17:30:33 nit: it'd be okay to keep this EXPECT_LE too, perh
+ font_list_mix.GetHeight());
+ 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