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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 // Check that fonts used for testing are installed and enabled. On Mac | 139 // 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. | 140 // fonts may be installed but still need enabling in Font Book.app. |
140 // http://crbug.com/347429 | 141 // http://crbug.com/347429 |
141 TEST_F(FontTest, MAYBE_GetActualFontNameForTesting) { | 142 TEST_F(FontTest, MAYBE_GetActualFontNameForTesting) { |
142 Font arial("Arial", 16); | 143 Font arial("Arial", 16); |
143 EXPECT_EQ("arial", base::ToLowerASCII(arial.GetActualFontNameForTesting())) | 144 EXPECT_EQ("arial", base::ToLowerASCII(arial.GetActualFontNameForTesting())) |
144 << "********\n" | 145 << "********\n" |
145 << "Your test environment seems to be missing Arial font, which is " | 146 << "Your test environment seems to be missing Arial font, which is " |
146 << "needed for unittests. Check if Arial font is installed.\n" | 147 << "needed for unittests. Check if Arial font is installed.\n" |
147 << "********"; | 148 << "********"; |
148 Font symbol("Symbol", 16); | 149 Font symbol(kSymbolFontName, 16); |
149 EXPECT_EQ("symbol", base::ToLowerASCII(symbol.GetActualFontNameForTesting())) | 150 EXPECT_EQ(base::ToLowerASCII(kSymbolFontName), |
| 151 base::ToLowerASCII(symbol.GetActualFontNameForTesting())) |
150 << "********\n" | 152 << "********\n" |
151 << "Your test environment seems to be missing Symbol font, which is " | 153 << "Your test environment seems to be missing the " << kSymbolFontName |
152 << "needed for unittests. Check if Symbol font is installed.\n" | 154 << " font, which is " |
| 155 << "needed for unittests. Check if " << kSymbolFontName |
| 156 << " font is installed.\n" |
153 << "********"; | 157 << "********"; |
154 | 158 |
155 const char* const invalid_font_name = "no_such_font_name"; | 159 const char* const invalid_font_name = "no_such_font_name"; |
156 Font fallback_font(invalid_font_name, 16); | 160 Font fallback_font(invalid_font_name, 16); |
157 EXPECT_NE(invalid_font_name, | 161 EXPECT_NE(invalid_font_name, |
158 base::ToLowerASCII(fallback_font.GetActualFontNameForTesting())); | 162 base::ToLowerASCII(fallback_font.GetActualFontNameForTesting())); |
159 } | 163 } |
160 | 164 |
161 TEST_F(FontTest, DeriveFont) { | 165 TEST_F(FontTest, DeriveFont) { |
162 Font cf("Arial", 8); | 166 Font cf("Arial", 8); |
(...skipping 23 matching lines...) Expand all Loading... |
186 // The minimum font size is set to 5 in browser_main.cc. | 190 // The minimum font size is set to 5 in browser_main.cc. |
187 ScopedMinimumFontSizeCallback minimum_size(5); | 191 ScopedMinimumFontSizeCallback minimum_size(5); |
188 | 192 |
189 Font derived_font = cf.Derive(-2, cf.GetStyle(), cf.GetWeight()); | 193 Font derived_font = cf.Derive(-2, cf.GetStyle(), cf.GetWeight()); |
190 EXPECT_EQ(6, derived_font.GetFontSize()); | 194 EXPECT_EQ(6, derived_font.GetFontSize()); |
191 } | 195 } |
192 #endif // defined(OS_WIN) | 196 #endif // defined(OS_WIN) |
193 | 197 |
194 } // namespace | 198 } // namespace |
195 } // namespace gfx | 199 } // namespace gfx |
OLD | NEW |