| OLD | NEW |
| 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 |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 const std::vector<Font>& derived_fonts = derived.GetFonts(); | 252 const std::vector<Font>& derived_fonts = derived.GetFonts(); |
| 253 | 253 |
| 254 EXPECT_EQ(2U, derived_fonts.size()); | 254 EXPECT_EQ(2U, derived_fonts.size()); |
| 255 EXPECT_EQ("Arial|13|italic", FontToString(derived_fonts[0])); | 255 EXPECT_EQ("Arial|13|italic", FontToString(derived_fonts[0])); |
| 256 EXPECT_EQ("Sans serif|13|italic", FontToString(derived_fonts[1])); | 256 EXPECT_EQ("Sans serif|13|italic", FontToString(derived_fonts[1])); |
| 257 } | 257 } |
| 258 | 258 |
| 259 TEST(FontListTest, Fonts_GetHeight_GetBaseline) { | 259 TEST(FontListTest, Fonts_GetHeight_GetBaseline) { |
| 260 // If a font list has only one font, the height and baseline must be the same. | 260 // If a font list has only one font, the height and baseline must be the same. |
| 261 Font font1("Arial", 16); | 261 Font font1("Arial", 16); |
| 262 ASSERT_EQ("arial", StringToLowerASCII(font1.GetActualFontNameForTesting())); | 262 ASSERT_EQ("arial", |
| 263 base::StringToLowerASCII(font1.GetActualFontNameForTesting())); |
| 263 FontList font_list1("Arial, 16px"); | 264 FontList font_list1("Arial, 16px"); |
| 264 EXPECT_EQ(font1.GetHeight(), font_list1.GetHeight()); | 265 EXPECT_EQ(font1.GetHeight(), font_list1.GetHeight()); |
| 265 EXPECT_EQ(font1.GetBaseline(), font_list1.GetBaseline()); | 266 EXPECT_EQ(font1.GetBaseline(), font_list1.GetBaseline()); |
| 266 | 267 |
| 267 // If there are two different fonts, the font list returns the max value | 268 // If there are two different fonts, the font list returns the max value |
| 268 // for ascent and descent. | 269 // for ascent and descent. |
| 269 Font font2("Symbol", 16); | 270 Font font2("Symbol", 16); |
| 270 ASSERT_EQ("symbol", StringToLowerASCII(font2.GetActualFontNameForTesting())); | 271 ASSERT_EQ("symbol", |
| 272 base::StringToLowerASCII(font2.GetActualFontNameForTesting())); |
| 271 EXPECT_NE(font1.GetBaseline(), font2.GetBaseline()); | 273 EXPECT_NE(font1.GetBaseline(), font2.GetBaseline()); |
| 272 EXPECT_NE(font1.GetHeight() - font1.GetBaseline(), | 274 EXPECT_NE(font1.GetHeight() - font1.GetBaseline(), |
| 273 font2.GetHeight() - font2.GetBaseline()); | 275 font2.GetHeight() - font2.GetBaseline()); |
| 274 std::vector<Font> fonts; | 276 std::vector<Font> fonts; |
| 275 fonts.push_back(font1); | 277 fonts.push_back(font1); |
| 276 fonts.push_back(font2); | 278 fonts.push_back(font2); |
| 277 FontList font_list_mix(fonts); | 279 FontList font_list_mix(fonts); |
| 278 // ascent of FontList == max(ascent of Fonts) | 280 // ascent of FontList == max(ascent of Fonts) |
| 279 EXPECT_EQ(std::max(font1.GetHeight() - font1.GetBaseline(), | 281 EXPECT_EQ(std::max(font1.GetHeight() - font1.GetBaseline(), |
| 280 font2.GetHeight() - font2.GetBaseline()), | 282 font2.GetHeight() - font2.GetBaseline()), |
| 281 font_list_mix.GetHeight() - font_list_mix.GetBaseline()); | 283 font_list_mix.GetHeight() - font_list_mix.GetBaseline()); |
| 282 // descent of FontList == max(descent of Fonts) | 284 // descent of FontList == max(descent of Fonts) |
| 283 EXPECT_EQ(std::max(font1.GetBaseline(), font2.GetBaseline()), | 285 EXPECT_EQ(std::max(font1.GetBaseline(), font2.GetBaseline()), |
| 284 font_list_mix.GetBaseline()); | 286 font_list_mix.GetBaseline()); |
| 285 } | 287 } |
| 286 | 288 |
| 287 } // namespace gfx | 289 } // namespace gfx |
| OLD | NEW |