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" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "ui/gfx/font_names_testing.h" | |
| 13 | 14 |
| 14 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
| 15 #include "ui/gfx/platform_font_win.h" | 16 #include "ui/gfx/platform_font_win.h" |
| 16 #endif | 17 #endif |
| 17 | 18 |
| 18 namespace gfx { | 19 namespace gfx { |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 using FontTest = testing::Test; | 22 using FontTest = testing::Test; |
| 22 | 23 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 #define MAYBE_AvgWidths AvgWidths | 121 #define MAYBE_AvgWidths AvgWidths |
| 121 #endif | 122 #endif |
| 122 TEST_F(FontTest, MAYBE_AvgWidths) { | 123 TEST_F(FontTest, MAYBE_AvgWidths) { |
| 123 Font cf("Arial", 16); | 124 Font cf("Arial", 16); |
| 124 EXPECT_EQ(cf.GetExpectedTextWidth(0), 0); | 125 EXPECT_EQ(cf.GetExpectedTextWidth(0), 0); |
| 125 EXPECT_GT(cf.GetExpectedTextWidth(1), cf.GetExpectedTextWidth(0)); | 126 EXPECT_GT(cf.GetExpectedTextWidth(1), cf.GetExpectedTextWidth(0)); |
| 126 EXPECT_GT(cf.GetExpectedTextWidth(2), cf.GetExpectedTextWidth(1)); | 127 EXPECT_GT(cf.GetExpectedTextWidth(2), cf.GetExpectedTextWidth(1)); |
| 127 EXPECT_GT(cf.GetExpectedTextWidth(3), cf.GetExpectedTextWidth(2)); | 128 EXPECT_GT(cf.GetExpectedTextWidth(3), cf.GetExpectedTextWidth(2)); |
| 128 } | 129 } |
| 129 | 130 |
| 131 | |
| 132 | |
|
Alexei Svitkine (slow)
2016/09/02 15:19:58
Remove extra added lines.
drott
2016/09/02 15:35:54
Done.
| |
| 130 #if defined(OS_WIN) || defined(OS_ANDROID) | 133 #if defined(OS_WIN) || defined(OS_ANDROID) |
| 131 #define MAYBE_GetActualFontNameForTesting DISABLED_GetActualFontNameForTesting | 134 #define MAYBE_GetActualFontNameForTesting DISABLED_GetActualFontNameForTesting |
| 132 #else | 135 #else |
| 133 #define MAYBE_GetActualFontNameForTesting GetActualFontNameForTesting | 136 #define MAYBE_GetActualFontNameForTesting GetActualFontNameForTesting |
| 134 #endif | 137 #endif |
| 135 // On Windows, Font::GetActualFontNameForTesting() doesn't work well for now. | 138 // On Windows, Font::GetActualFontNameForTesting() doesn't work well for now. |
| 136 // http://crbug.com/327287 | 139 // http://crbug.com/327287 |
| 137 // | 140 // |
| 138 // Check that fonts used for testing are installed and enabled. On Mac | 141 // Check that fonts used for testing are installed and enabled. On Mac |
| 139 // fonts may be installed but still need enabling in Font Book.app. | 142 // fonts may be installed but still need enabling in Font Book.app. |
| 140 // http://crbug.com/347429 | 143 // http://crbug.com/347429 |
| 141 TEST_F(FontTest, MAYBE_GetActualFontNameForTesting) { | 144 TEST_F(FontTest, MAYBE_GetActualFontNameForTesting) { |
| 142 Font arial("Arial", 16); | 145 Font arial("Arial", 16); |
| 143 EXPECT_EQ("arial", base::ToLowerASCII(arial.GetActualFontNameForTesting())) | 146 EXPECT_EQ("arial", base::ToLowerASCII(arial.GetActualFontNameForTesting())) |
| 144 << "********\n" | 147 << "********\n" |
| 145 << "Your test environment seems to be missing Arial font, which is " | 148 << "Your test environment seems to be missing Arial font, which is " |
| 146 << "needed for unittests. Check if Arial font is installed.\n" | 149 << "needed for unittests. Check if Arial font is installed.\n" |
| 147 << "********"; | 150 << "********"; |
| 148 Font symbol("Symbol", 16); | 151 Font symbol(symbol_font_name, 16); |
| 149 EXPECT_EQ("symbol", base::ToLowerASCII(symbol.GetActualFontNameForTesting())) | 152 EXPECT_EQ(base::ToLowerASCII(symbol_font_name), |
| 153 base::ToLowerASCII(symbol.GetActualFontNameForTesting())) | |
| 150 << "********\n" | 154 << "********\n" |
| 151 << "Your test environment seems to be missing Symbol font, which is " | 155 << "Your test environment seems to be missing the " << symbol_font_name |
| 152 << "needed for unittests. Check if Symbol font is installed.\n" | 156 << " font, which is " |
| 157 << "needed for unittests. Check if " << symbol_font_name | |
| 158 << " font is installed.\n" | |
| 153 << "********"; | 159 << "********"; |
| 154 | 160 |
| 155 const char* const invalid_font_name = "no_such_font_name"; | 161 const char* const invalid_font_name = "no_such_font_name"; |
| 156 Font fallback_font(invalid_font_name, 16); | 162 Font fallback_font(invalid_font_name, 16); |
| 157 EXPECT_NE(invalid_font_name, | 163 EXPECT_NE(invalid_font_name, |
| 158 base::ToLowerASCII(fallback_font.GetActualFontNameForTesting())); | 164 base::ToLowerASCII(fallback_font.GetActualFontNameForTesting())); |
| 159 } | 165 } |
| 160 | 166 |
| 161 TEST_F(FontTest, DeriveFont) { | 167 TEST_F(FontTest, DeriveFont) { |
| 162 Font cf("Arial", 8); | 168 Font cf("Arial", 8); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 186 // The minimum font size is set to 5 in browser_main.cc. | 192 // The minimum font size is set to 5 in browser_main.cc. |
| 187 ScopedMinimumFontSizeCallback minimum_size(5); | 193 ScopedMinimumFontSizeCallback minimum_size(5); |
| 188 | 194 |
| 189 Font derived_font = cf.Derive(-2, cf.GetStyle(), cf.GetWeight()); | 195 Font derived_font = cf.Derive(-2, cf.GetStyle(), cf.GetWeight()); |
| 190 EXPECT_EQ(6, derived_font.GetFontSize()); | 196 EXPECT_EQ(6, derived_font.GetFontSize()); |
| 191 } | 197 } |
| 192 #endif // defined(OS_WIN) | 198 #endif // defined(OS_WIN) |
| 193 | 199 |
| 194 } // namespace | 200 } // namespace |
| 195 } // namespace gfx | 201 } // namespace gfx |
| OLD | NEW |