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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 << "Your test environment seems to be missing Symbol font, which is " | 151 << "Your test environment seems to be missing Symbol font, which is " |
| 152 << "needed for unittests. Check if Symbol font is installed.\n" | 152 << "needed for unittests. Check if Symbol font is installed.\n" |
| 153 << "********"; | 153 << "********"; |
| 154 | 154 |
| 155 const char* const invalid_font_name = "no_such_font_name"; | 155 const char* const invalid_font_name = "no_such_font_name"; |
| 156 Font fallback_font(invalid_font_name, 16); | 156 Font fallback_font(invalid_font_name, 16); |
| 157 EXPECT_NE(invalid_font_name, | 157 EXPECT_NE(invalid_font_name, |
| 158 base::ToLowerASCII(fallback_font.GetActualFontNameForTesting())); | 158 base::ToLowerASCII(fallback_font.GetActualFontNameForTesting())); |
| 159 } | 159 } |
| 160 | 160 |
| 161 TEST_F(FontTest, DeriveFont) { | |
|
karandeepb
2016/08/05 11:03:07
All the other tests seem to be disabled on Android
Avi (use Gerrit)
2016/08/05 14:54:58
Perhaps you'll find out on the trybots :)
| |
| 162 Font cf("Arial", 8); | |
| 163 const int kSizeDelta = 2; | |
| 164 Font cf_underlined = | |
| 165 cf.Derive(0, cf.GetStyle() | gfx::Font::UNDERLINE, cf.GetWeight()); | |
| 166 Font cf_underlined_resized = cf_underlined.Derive( | |
| 167 kSizeDelta, cf_underlined.GetStyle(), cf_underlined.GetWeight()); | |
| 168 EXPECT_EQ(cf.GetStyle() | gfx::Font::UNDERLINE, | |
|
karandeepb
2016/08/05 11:03:07
This fails on Mac currently. The derived font does
Avi (use Gerrit)
2016/08/05 14:54:59
As long as it passes with the other changes in the
| |
| 169 cf_underlined_resized.GetStyle()); | |
| 170 EXPECT_EQ(cf.GetFontSize() + kSizeDelta, cf_underlined_resized.GetFontSize()); | |
| 171 EXPECT_EQ(cf.GetWeight(), cf_underlined_resized.GetWeight()); | |
| 172 } | |
| 173 | |
| 161 #if defined(OS_WIN) | 174 #if defined(OS_WIN) |
| 162 TEST_F(FontTest, DeriveResizesIfSizeTooSmall) { | 175 TEST_F(FontTest, DeriveResizesIfSizeTooSmall) { |
| 163 Font cf("Arial", 8); | 176 Font cf("Arial", 8); |
| 164 // The minimum font size is set to 5 in browser_main.cc. | 177 // The minimum font size is set to 5 in browser_main.cc. |
| 165 ScopedMinimumFontSizeCallback minimum_size(5); | 178 ScopedMinimumFontSizeCallback minimum_size(5); |
| 166 | 179 |
| 167 Font derived_font = cf.Derive(-4, cf.GetStyle(), cf.GetWeight()); | 180 Font derived_font = cf.Derive(-4, cf.GetStyle(), cf.GetWeight()); |
| 168 EXPECT_EQ(5, derived_font.GetFontSize()); | 181 EXPECT_EQ(5, derived_font.GetFontSize()); |
| 169 } | 182 } |
| 170 | 183 |
| 171 TEST_F(FontTest, DeriveKeepsOriginalSizeIfHeightOk) { | 184 TEST_F(FontTest, DeriveKeepsOriginalSizeIfHeightOk) { |
| 172 Font cf("Arial", 8); | 185 Font cf("Arial", 8); |
| 173 // The minimum font size is set to 5 in browser_main.cc. | 186 // The minimum font size is set to 5 in browser_main.cc. |
| 174 ScopedMinimumFontSizeCallback minimum_size(5); | 187 ScopedMinimumFontSizeCallback minimum_size(5); |
| 175 | 188 |
| 176 Font derived_font = cf.Derive(-2, cf.GetStyle(), cf.GetWeight()); | 189 Font derived_font = cf.Derive(-2, cf.GetStyle(), cf.GetWeight()); |
| 177 EXPECT_EQ(6, derived_font.GetFontSize()); | 190 EXPECT_EQ(6, derived_font.GetFontSize()); |
| 178 } | 191 } |
| 179 #endif // defined(OS_WIN) | 192 #endif // defined(OS_WIN) |
| 180 | 193 |
| 181 } // namespace | 194 } // namespace |
| 182 } // namespace gfx | 195 } // namespace gfx |
| OLD | NEW |