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

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

Issue 79263004: Enables font-related unittests again. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced. 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
« no previous file with comments | « ui/gfx/font.cc ('k') | ui/gfx/font_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/font_list.h" 5 #include "ui/gfx/font_list.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace { 15 namespace {
15 16
16 // Helper function for comparing fonts for equality. 17 // Helper function for comparing fonts for equality.
17 std::string FontToString(const gfx::Font& font) { 18 std::string FontToString(const gfx::Font& font) {
18 std::string font_string = font.GetFontName(); 19 std::string font_string = font.GetFontName();
19 font_string += "|"; 20 font_string += "|";
20 font_string += base::IntToString(font.GetFontSize()); 21 font_string += base::IntToString(font.GetFontSize());
21 int style = font.GetStyle(); 22 int style = font.GetStyle();
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 283
283 FontList derived = 284 FontList derived =
284 font_list.DeriveFontListWithSizeDeltaAndStyle(5, Font::BOLD); 285 font_list.DeriveFontListWithSizeDeltaAndStyle(5, Font::BOLD);
285 const std::vector<Font>& derived_fonts = derived.GetFonts(); 286 const std::vector<Font>& derived_fonts = derived.GetFonts();
286 287
287 EXPECT_EQ(2U, derived_fonts.size()); 288 EXPECT_EQ(2U, derived_fonts.size());
288 EXPECT_EQ("Arial|13|bold", FontToString(derived_fonts[0])); 289 EXPECT_EQ("Arial|13|bold", FontToString(derived_fonts[0]));
289 EXPECT_EQ("Sans serif|13|bold", FontToString(derived_fonts[1])); 290 EXPECT_EQ("Sans serif|13|bold", FontToString(derived_fonts[1]));
290 } 291 }
291 292
292 // Disabled. http://crbug.com/316955 293 TEST(FontListTest, Fonts_GetHeight_GetBaseline) {
293 TEST(FontListTest, DISABLED_Fonts_GetHeight_GetBaseline) {
294 // If a font list has only one font, the height and baseline must be the same. 294 // If a font list has only one font, the height and baseline must be the same.
295 Font font1("Arial", 16); 295 Font font1("Arial", 16);
296 ASSERT_EQ("arial", StringToLowerASCII(font1.GetActualFontNameForTesting()));
296 FontList font_list1("Arial, 16px"); 297 FontList font_list1("Arial, 16px");
297 EXPECT_EQ(font1.GetHeight(), font_list1.GetHeight()); 298 EXPECT_EQ(font1.GetHeight(), font_list1.GetHeight());
298 EXPECT_EQ(font1.GetBaseline(), font_list1.GetBaseline()); 299 EXPECT_EQ(font1.GetBaseline(), font_list1.GetBaseline());
299 300
300 // If there are two different fonts, the font list returns the max value 301 // If there are two different fonts, the font list returns the max value
301 // for ascent and descent. 302 // for ascent and descent.
302 Font font2("Symbol", 16); 303 Font font2("Symbol", 16);
304 ASSERT_EQ("symbol", StringToLowerASCII(font2.GetActualFontNameForTesting()));
303 EXPECT_NE(font1.GetBaseline(), font2.GetBaseline()); 305 EXPECT_NE(font1.GetBaseline(), font2.GetBaseline());
304 EXPECT_NE(font1.GetHeight() - font1.GetBaseline(), 306 EXPECT_NE(font1.GetHeight() - font1.GetBaseline(),
305 font2.GetHeight() - font2.GetBaseline()); 307 font2.GetHeight() - font2.GetBaseline());
306 std::vector<Font> fonts; 308 std::vector<Font> fonts;
307 fonts.push_back(font1); 309 fonts.push_back(font1);
308 fonts.push_back(font2); 310 fonts.push_back(font2);
309 FontList font_list_mix(fonts); 311 FontList font_list_mix(fonts);
310 // ascent of FontList == max(ascent of Fonts) 312 // ascent of FontList == max(ascent of Fonts)
311 EXPECT_EQ(std::max(font1.GetHeight() - font1.GetBaseline(), 313 EXPECT_EQ(std::max(font1.GetHeight() - font1.GetBaseline(),
312 font2.GetHeight() - font2.GetBaseline()), 314 font2.GetHeight() - font2.GetBaseline()),
313 font_list_mix.GetHeight() - font_list_mix.GetBaseline()); 315 font_list_mix.GetHeight() - font_list_mix.GetBaseline());
314 // descent of FontList == max(descent of Fonts) 316 // descent of FontList == max(descent of Fonts)
315 EXPECT_EQ(std::max(font1.GetBaseline(), font2.GetBaseline()), 317 EXPECT_EQ(std::max(font1.GetBaseline(), font2.GetBaseline()),
316 font_list_mix.GetBaseline()); 318 font_list_mix.GetBaseline());
317 } 319 }
318 320
319 } // namespace gfx 321 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/font.cc ('k') | ui/gfx/font_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698