Chromium Code Reviews| 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.h" | 5 #include "ui/gfx/font.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 EXPECT_EQ("arial", base::ToLowerASCII(cf.GetActualFontNameForTesting())); | 63 EXPECT_EQ("arial", base::ToLowerASCII(cf.GetActualFontNameForTesting())); |
| 64 } | 64 } |
| 65 | 65 |
| 66 #if defined(OS_ANDROID) | 66 #if defined(OS_ANDROID) |
| 67 #define MAYBE_LoadArialBold DISABLED_LoadArialBold | 67 #define MAYBE_LoadArialBold DISABLED_LoadArialBold |
| 68 #else | 68 #else |
| 69 #define MAYBE_LoadArialBold LoadArialBold | 69 #define MAYBE_LoadArialBold LoadArialBold |
| 70 #endif | 70 #endif |
| 71 TEST_F(FontTest, MAYBE_LoadArialBold) { | 71 TEST_F(FontTest, MAYBE_LoadArialBold) { |
| 72 Font cf("Arial", 16); | 72 Font cf("Arial", 16); |
| 73 Font bold(cf.Derive(0, Font::BOLD)); | 73 Font bold(cf.Derive(0, Font::NORMAL, Font::WEIGHT_BOLD)); |
|
msw
2016/03/22 18:24:11
Update the enum values in this file.
Mikus
2016/03/23 17:53:21
Done.
| |
| 74 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_IOS) | 74 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_IOS) |
| 75 EXPECT_TRUE(bold.GetNativeFont()); | 75 EXPECT_TRUE(bold.GetNativeFont()); |
| 76 #endif | 76 #endif |
| 77 EXPECT_EQ(bold.GetStyle(), Font::BOLD); | 77 EXPECT_EQ(bold.GetStyle(), Font::NORMAL); |
| 78 EXPECT_EQ(bold.GetWeight(), Font::WEIGHT_BOLD); | |
| 78 EXPECT_EQ("arial", base::ToLowerASCII(cf.GetActualFontNameForTesting())); | 79 EXPECT_EQ("arial", base::ToLowerASCII(cf.GetActualFontNameForTesting())); |
| 79 } | 80 } |
| 80 | 81 |
| 81 #if defined(OS_ANDROID) | 82 #if defined(OS_ANDROID) |
| 82 #define MAYBE_Ascent DISABLED_Ascent | 83 #define MAYBE_Ascent DISABLED_Ascent |
| 83 #else | 84 #else |
| 84 #define MAYBE_Ascent Ascent | 85 #define MAYBE_Ascent Ascent |
| 85 #endif | 86 #endif |
| 86 TEST_F(FontTest, MAYBE_Ascent) { | 87 TEST_F(FontTest, MAYBE_Ascent) { |
| 87 Font cf("Arial", 16); | 88 Font cf("Arial", 16); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 EXPECT_NE(invalid_font_name, | 157 EXPECT_NE(invalid_font_name, |
| 157 base::ToLowerASCII(fallback_font.GetActualFontNameForTesting())); | 158 base::ToLowerASCII(fallback_font.GetActualFontNameForTesting())); |
| 158 } | 159 } |
| 159 | 160 |
| 160 #if defined(OS_WIN) | 161 #if defined(OS_WIN) |
| 161 TEST_F(FontTest, DeriveResizesIfSizeTooSmall) { | 162 TEST_F(FontTest, DeriveResizesIfSizeTooSmall) { |
| 162 Font cf("Arial", 8); | 163 Font cf("Arial", 8); |
| 163 // The minimum font size is set to 5 in browser_main.cc. | 164 // The minimum font size is set to 5 in browser_main.cc. |
| 164 ScopedMinimumFontSizeCallback minimum_size(5); | 165 ScopedMinimumFontSizeCallback minimum_size(5); |
| 165 | 166 |
| 166 Font derived_font = cf.Derive(-4, cf.GetStyle()); | 167 Font derived_font = cf.Derive(-4, cf.GetStyle(), cf.GetWeight()); |
| 167 EXPECT_EQ(5, derived_font.GetFontSize()); | 168 EXPECT_EQ(5, derived_font.GetFontSize()); |
| 168 } | 169 } |
| 169 | 170 |
| 170 TEST_F(FontTest, DeriveKeepsOriginalSizeIfHeightOk) { | 171 TEST_F(FontTest, DeriveKeepsOriginalSizeIfHeightOk) { |
| 171 Font cf("Arial", 8); | 172 Font cf("Arial", 8); |
| 172 // The minimum font size is set to 5 in browser_main.cc. | 173 // The minimum font size is set to 5 in browser_main.cc. |
| 173 ScopedMinimumFontSizeCallback minimum_size(5); | 174 ScopedMinimumFontSizeCallback minimum_size(5); |
| 174 | 175 |
| 175 Font derived_font = cf.Derive(-2, cf.GetStyle()); | 176 Font derived_font = cf.Derive(-2, cf.GetStyle(), cf.GetWeight()); |
| 176 EXPECT_EQ(6, derived_font.GetFontSize()); | 177 EXPECT_EQ(6, derived_font.GetFontSize()); |
| 177 } | 178 } |
| 178 #endif // defined(OS_WIN) | 179 #endif // defined(OS_WIN) |
| 179 | 180 |
| 180 } // namespace | 181 } // namespace |
| 181 } // namespace gfx | 182 } // namespace gfx |
| OLD | NEW |