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

Side by Side Diff: ui/gfx/render_text_unittest.cc

Issue 79263004: Enables font-related unittests again. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed a test breakage on Windows. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/render_text.h" 5 #include "ui/gfx/render_text.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string_util.h"
11 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/gfx/break_list.h" 15 #include "ui/gfx/break_list.h"
15 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
16 17
17 #if defined(OS_WIN) 18 #if defined(OS_WIN)
18 #include "base/win/windows_version.h" 19 #include "base/win/windows_version.h"
19 #include "ui/gfx/render_text_win.h" 20 #include "ui/gfx/render_text_win.h"
20 #endif 21 #endif
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 EXPECT_EQ(font_list.GetHeight(), render_text->GetStringSize().height()); 1150 EXPECT_EQ(font_list.GetHeight(), render_text->GetStringSize().height());
1150 EXPECT_EQ(0, render_text->GetStringSize().width()); 1151 EXPECT_EQ(0, render_text->GetStringSize().width());
1151 EXPECT_EQ(font_list.GetBaseline(), render_text->GetBaseline()); 1152 EXPECT_EQ(font_list.GetBaseline(), render_text->GetBaseline());
1152 1153
1153 render_text->SetText(UTF8ToUTF16(" ")); 1154 render_text->SetText(UTF8ToUTF16(" "));
1154 EXPECT_EQ(font_list.GetHeight(), render_text->GetStringSize().height()); 1155 EXPECT_EQ(font_list.GetHeight(), render_text->GetStringSize().height());
1155 EXPECT_EQ(font_list.GetBaseline(), render_text->GetBaseline()); 1156 EXPECT_EQ(font_list.GetBaseline(), render_text->GetBaseline());
1156 } 1157 }
1157 #endif // !defined(OS_MACOSX) 1158 #endif // !defined(OS_MACOSX)
1158 1159
1159 // Disabled. http://crbug.com/316955 1160 TEST_F(RenderTextTest, StringSizeRespectsFontListMetrics) {
1160 TEST_F(RenderTextTest, DISABLED_StringSizeRespectsFontListMetrics) {
1161 // Check that Arial and Symbol have different font metrics. 1161 // Check that Arial and Symbol have different font metrics.
1162 Font arial_font("Arial", 16); 1162 Font arial_font("Arial", 16);
1163 ASSERT_EQ("arial", StringToLowerASCII(arial_font.GetActualFontName()));
1163 Font symbol_font("Symbol", 16); 1164 Font symbol_font("Symbol", 16);
1165 ASSERT_EQ("symbol", StringToLowerASCII(symbol_font.GetActualFontName()));
1164 EXPECT_NE(arial_font.GetHeight(), symbol_font.GetHeight()); 1166 EXPECT_NE(arial_font.GetHeight(), symbol_font.GetHeight());
1165 EXPECT_NE(arial_font.GetBaseline(), symbol_font.GetBaseline()); 1167 EXPECT_NE(arial_font.GetBaseline(), symbol_font.GetBaseline());
1166 // "a" should be rendered with Arial, not with Symbol. 1168 // "a" should be rendered with Arial, not with Symbol.
1167 const char* arial_font_text = "a"; 1169 const char* arial_font_text = "a";
1168 // "®" (registered trademark symbol) should be rendered with Symbol, 1170 // "®" (registered trademark symbol) should be rendered with Symbol,
1169 // not with Arial. 1171 // not with Arial.
1170 const char* symbol_font_text = "\xC2\xAE"; 1172 const char* symbol_font_text = "\xC2\xAE";
1171 1173
1172 Font smaller_font = arial_font; 1174 Font smaller_font = arial_font;
1173 Font larger_font = symbol_font; 1175 Font larger_font = symbol_font;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 EXPECT_EQ(font_list.GetBaseline(), render_text->GetBaseline()); 1208 EXPECT_EQ(font_list.GetBaseline(), render_text->GetBaseline());
1207 } 1209 }
1208 1210
1209 TEST_F(RenderTextTest, SetFont) { 1211 TEST_F(RenderTextTest, SetFont) {
1210 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); 1212 scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
1211 render_text->SetFont(Font("Arial", 12)); 1213 render_text->SetFont(Font("Arial", 12));
1212 EXPECT_EQ("Arial", render_text->GetPrimaryFont().GetFontName()); 1214 EXPECT_EQ("Arial", render_text->GetPrimaryFont().GetFontName());
1213 EXPECT_EQ(12, render_text->GetPrimaryFont().GetFontSize()); 1215 EXPECT_EQ(12, render_text->GetPrimaryFont().GetFontSize());
1214 } 1216 }
1215 1217
1216 // Disabled. http://crbug.com/316955 1218 TEST_F(RenderTextTest, SetFontList) {
1217 TEST_F(RenderTextTest, DISABLED_SetFontList) {
1218 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); 1219 scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
1219 render_text->SetFontList(FontList("Arial,Symbol, 13px")); 1220 render_text->SetFontList(FontList("Arial,Symbol, 13px"));
1220 const std::vector<Font>& fonts = render_text->font_list().GetFonts(); 1221 const std::vector<Font>& fonts = render_text->font_list().GetFonts();
1221 ASSERT_EQ(2U, fonts.size()); 1222 ASSERT_EQ(2U, fonts.size());
1222 EXPECT_EQ("Arial", fonts[0].GetFontName()); 1223 EXPECT_EQ("Arial", fonts[0].GetFontName());
1223 EXPECT_EQ("Symbol", fonts[1].GetFontName()); 1224 EXPECT_EQ("Symbol", fonts[1].GetFontName());
1224 EXPECT_EQ(13, render_text->GetPrimaryFont().GetFontSize()); 1225 EXPECT_EQ(13, render_text->GetPrimaryFont().GetFontSize());
1225 } 1226 }
1226 1227
1227 TEST_F(RenderTextTest, StringSizeBoldWidth) { 1228 TEST_F(RenderTextTest, StringSizeBoldWidth) {
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 render_text->SetText(WideToUTF16(L"x \x25B6 y")); 1796 render_text->SetText(WideToUTF16(L"x \x25B6 y"));
1796 render_text->EnsureLayout(); 1797 render_text->EnsureLayout();
1797 ASSERT_EQ(3U, render_text->runs_.size()); 1798 ASSERT_EQ(3U, render_text->runs_.size());
1798 EXPECT_EQ(Range(0, 2), render_text->runs_[0]->range); 1799 EXPECT_EQ(Range(0, 2), render_text->runs_[0]->range);
1799 EXPECT_EQ(Range(2, 3), render_text->runs_[1]->range); 1800 EXPECT_EQ(Range(2, 3), render_text->runs_[1]->range);
1800 EXPECT_EQ(Range(3, 5), render_text->runs_[2]->range); 1801 EXPECT_EQ(Range(3, 5), render_text->runs_[2]->range);
1801 } 1802 }
1802 #endif // defined(OS_WIN) 1803 #endif // defined(OS_WIN)
1803 1804
1804 } // namespace gfx 1805 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698