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

Unified Diff: ui/gfx/render_text_unittest.cc

Issue 2302313002: Configure font font names in GFX unittests (Closed)
Patch Set: Change to OpenSymbol and make test more robust Created 4 years, 3 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
« ui/gfx/font_unittest.cc ('K') | « ui/gfx/font_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_unittest.cc
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc
index d5eb931a6cf72b2fd806d89745e512b084c8e7da..bedec10911c85f20387c616a1a87048188dca5c9 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -29,6 +29,7 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/font.h"
+#include "ui/gfx/font_names_testing.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/range/range.h"
@@ -1966,7 +1967,8 @@ TEST_P(RenderTextTest, StringSizeLongStrings) {
TEST_P(RenderTextTest, StringSizeEmptyString) {
// Ascent and descent of Arial and Symbol are different on most platforms.
- const FontList font_list("Arial,Symbol, 16px");
+ const FontList font_list(
+ base::StringPrintf("Arial,%s, 16px", symbol_font_name));
RenderText* render_text = GetRenderText();
render_text->SetFontList(font_list);
render_text->SetDisplayRect(Rect(0, 0, 0, font_list.GetHeight()));
@@ -1988,16 +1990,16 @@ TEST_P(RenderTextTest, StringSizeRespectsFontListMetrics) {
Font arial_font("Arial", 16);
ASSERT_EQ("arial",
base::ToLowerASCII(arial_font.GetActualFontNameForTesting()));
- Font symbol_font("Symbol", 16);
- ASSERT_EQ("symbol",
+ Font symbol_font(symbol_font_name, 16);
+ ASSERT_EQ(base::ToLowerASCII(symbol_font_name),
base::ToLowerASCII(symbol_font.GetActualFontNameForTesting()));
EXPECT_NE(arial_font.GetHeight(), symbol_font.GetHeight());
EXPECT_NE(arial_font.GetBaseline(), symbol_font.GetBaseline());
// "a" should be rendered with Arial, not with Symbol.
const char* arial_font_text = "a";
- // "®" (registered trademark symbol) should be rendered with Symbol,
+ // "⊕" CIRCLED PLUS SIGN should be rendered with Symbol,
// not with Arial.
- const char* symbol_font_text = "\xC2\xAE";
+ const char* symbol_font_text = u8"⊕";
Font smaller_font = arial_font;
Font larger_font = symbol_font;
@@ -2017,8 +2019,9 @@ TEST_P(RenderTextTest, StringSizeRespectsFontListMetrics) {
render_text->SetFontList(FontList(smaller_font));
render_text->SetDisplayRect(Rect(0, 0, 0,
render_text->font_list().GetHeight()));
- EXPECT_EQ(smaller_font.GetHeight(), render_text->GetStringSize().height());
- EXPECT_EQ(smaller_font.GetBaseline(), render_text->GetBaseline());
+ EXPECT_STRCASEEQ(
+ render_text->GetFontSpansForTesting()[0].first.GetFontName().c_str(),
+ smaller_font.GetFontName().c_str());
// Layout the same text with mixed fonts. The text should be rendered with
// the smaller font, but the height and baseline are determined with the
@@ -2030,6 +2033,9 @@ TEST_P(RenderTextTest, StringSizeRespectsFontListMetrics) {
render_text->SetFontList(font_list);
render_text->SetDisplayRect(Rect(0, 0, 0,
render_text->font_list().GetHeight()));
+ EXPECT_STRCASEEQ(
+ render_text->GetFontSpansForTesting()[0].first.GetFontName().c_str(),
+ smaller_font.GetFontName().c_str());
EXPECT_LT(smaller_font.GetHeight(), render_text->GetStringSize().height());
EXPECT_LT(smaller_font.GetBaseline(), render_text->GetBaseline());
EXPECT_EQ(font_list.GetHeight(), render_text->GetStringSize().height());
@@ -2054,11 +2060,12 @@ TEST_P(RenderTextTest, MinLineHeight) {
TEST_P(RenderTextTest, SetFontList) {
RenderText* render_text = GetRenderText();
- render_text->SetFontList(FontList("Arial,Symbol, 13px"));
+ render_text->SetFontList(
+ FontList(base::StringPrintf("Arial,%s, 13px", symbol_font_name)));
const std::vector<Font>& fonts = render_text->font_list().GetFonts();
ASSERT_EQ(2U, fonts.size());
EXPECT_EQ("Arial", fonts[0].GetFontName());
- EXPECT_EQ("Symbol", fonts[1].GetFontName());
+ EXPECT_EQ(symbol_font_name, fonts[1].GetFontName());
EXPECT_EQ(13, render_text->font_list().GetFontSize());
}
@@ -3394,12 +3401,12 @@ TEST_P(RenderTextTest, StringFitsOwnWidth) {
// falling back to other fonts.
TEST_P(RenderTextHarfBuzzTest, HarfBuzz_FontListFallback) {
// Double-check that the requested fonts are present.
- FontList font_list("Arial, Symbol, 12px");
+ FontList font_list(base::StringPrintf("Arial, %s, 12px", symbol_font_name));
const std::vector<Font>& fonts = font_list.GetFonts();
ASSERT_EQ(2u, fonts.size());
ASSERT_EQ("arial",
base::ToLowerASCII(fonts[0].GetActualFontNameForTesting()));
- ASSERT_EQ("symbol",
+ ASSERT_EQ(base::ToLowerASCII(symbol_font_name),
base::ToLowerASCII(fonts[1].GetActualFontNameForTesting()));
// "⊕" (CIRCLED PLUS) should be rendered with Symbol rather than falling back
@@ -3410,7 +3417,7 @@ TEST_P(RenderTextHarfBuzzTest, HarfBuzz_FontListFallback) {
const std::vector<RenderText::FontSpan> spans =
render_text->GetFontSpansForTesting();
ASSERT_EQ(static_cast<size_t>(1), spans.size());
- EXPECT_EQ("Symbol", spans[0].first.GetFontName());
+ EXPECT_STRCASEEQ(symbol_font_name, spans[0].first.GetFontName().c_str());
}
#endif // !defined(OS_WIN)
« ui/gfx/font_unittest.cc ('K') | « ui/gfx/font_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698