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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 TEST_F(FontTest, DeriveFontKeepsOriginalSizeIfHeightOk) { | 125 TEST_F(FontTest, DeriveFontKeepsOriginalSizeIfHeightOk) { |
126 Font cf("Arial", 8); | 126 Font cf("Arial", 8); |
127 // The minimum font size is set to 5 in browser_main.cc. | 127 // The minimum font size is set to 5 in browser_main.cc. |
128 ScopedMinimumFontSizeCallback minimum_size(5); | 128 ScopedMinimumFontSizeCallback minimum_size(5); |
129 | 129 |
130 Font derived_font = cf.DeriveFont(-2); | 130 Font derived_font = cf.DeriveFont(-2); |
131 EXPECT_EQ(6, derived_font.GetFontSize()); | 131 EXPECT_EQ(6, derived_font.GetFontSize()); |
132 } | 132 } |
133 #endif // defined(OS_WIN) | 133 #endif // defined(OS_WIN) |
134 | 134 |
| 135 #if defined(OS_MACOSX) |
| 136 TEST_F(FontTest, FractionalWidth) { |
| 137 Font cf("Arial", 16); |
| 138 |
| 139 float width = cf.GetAverageCharacterWidth(); |
| 140 EXPECT_GT(width - static_cast<int>(width), 0); |
| 141 |
| 142 width = cf.GetExpectedTextWidth(1); |
| 143 EXPECT_GT(width - static_cast<int>(width), 0); |
| 144 |
| 145 width = cf.GetStringWidth(ASCIIToUTF16("This is a test")); |
| 146 EXPECT_GT(width - static_cast<int>(width), 0); |
| 147 } |
| 148 #endif |
| 149 |
135 } // namespace | 150 } // namespace |
136 } // namespace gfx | 151 } // namespace gfx |
OLD | NEW |