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/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 EXPECT_GE(cf.GetHeight(), 16); | 86 EXPECT_GE(cf.GetHeight(), 16); |
87 // TODO(akalin): Figure out why height is so large on Linux. | 87 // TODO(akalin): Figure out why height is so large on Linux. |
88 EXPECT_LE(cf.GetHeight(), 26); | 88 EXPECT_LE(cf.GetHeight(), 26); |
89 } | 89 } |
90 | 90 |
91 TEST_F(FontTest, CapHeight) { | 91 TEST_F(FontTest, CapHeight) { |
92 Font cf("Arial", 16); | 92 Font cf("Arial", 16); |
93 EXPECT_GT(cf.GetCapHeight(), 0); | 93 EXPECT_GT(cf.GetCapHeight(), 0); |
94 EXPECT_GT(cf.GetCapHeight(), cf.GetHeight() / 2); | 94 EXPECT_GT(cf.GetCapHeight(), cf.GetHeight() / 2); |
95 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | 95 #if defined(OS_CHROMEOS) || defined(OS_LINUX) |
96 EXPECT_EQ(cf.GetCapHeight(), cf.GetHeight()); | 96 EXPECT_EQ(cf.GetCapHeight(), cf.GetBaseline()); |
97 #else | 97 #else |
98 EXPECT_LT(cf.GetCapHeight(), cf.GetHeight()); | 98 EXPECT_LT(cf.GetCapHeight(), cf.GetBaseline()); |
99 #endif | 99 #endif |
100 } | 100 } |
101 | 101 |
102 TEST_F(FontTest, AvgWidths) { | 102 TEST_F(FontTest, AvgWidths) { |
103 Font cf("Arial", 16); | 103 Font cf("Arial", 16); |
104 EXPECT_EQ(cf.GetExpectedTextWidth(0), 0); | 104 EXPECT_EQ(cf.GetExpectedTextWidth(0), 0); |
105 EXPECT_GT(cf.GetExpectedTextWidth(1), cf.GetExpectedTextWidth(0)); | 105 EXPECT_GT(cf.GetExpectedTextWidth(1), cf.GetExpectedTextWidth(0)); |
106 EXPECT_GT(cf.GetExpectedTextWidth(2), cf.GetExpectedTextWidth(1)); | 106 EXPECT_GT(cf.GetExpectedTextWidth(2), cf.GetExpectedTextWidth(1)); |
107 EXPECT_GT(cf.GetExpectedTextWidth(3), cf.GetExpectedTextWidth(2)); | 107 EXPECT_GT(cf.GetExpectedTextWidth(3), cf.GetExpectedTextWidth(2)); |
108 } | 108 } |
(...skipping 29 matching lines...) Expand all Loading... |
138 // The minimum font size is set to 5 in browser_main.cc. | 138 // The minimum font size is set to 5 in browser_main.cc. |
139 ScopedMinimumFontSizeCallback minimum_size(5); | 139 ScopedMinimumFontSizeCallback minimum_size(5); |
140 | 140 |
141 Font derived_font = cf.DeriveFont(-2); | 141 Font derived_font = cf.DeriveFont(-2); |
142 EXPECT_EQ(6, derived_font.GetFontSize()); | 142 EXPECT_EQ(6, derived_font.GetFontSize()); |
143 } | 143 } |
144 #endif // defined(OS_WIN) | 144 #endif // defined(OS_WIN) |
145 | 145 |
146 } // namespace | 146 } // namespace |
147 } // namespace gfx | 147 } // namespace gfx |
OLD | NEW |