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/string16.h" | 7 #include "base/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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 ASSERT_GT(cf.GetExpectedTextWidth(3), cf.GetExpectedTextWidth(2)); | 96 ASSERT_GT(cf.GetExpectedTextWidth(3), cf.GetExpectedTextWidth(2)); |
97 } | 97 } |
98 | 98 |
99 TEST_F(FontTest, AvgCharWidth) { | 99 TEST_F(FontTest, AvgCharWidth) { |
100 Font cf("Arial", 16); | 100 Font cf("Arial", 16); |
101 ASSERT_GT(cf.GetAverageCharacterWidth(), 0); | 101 ASSERT_GT(cf.GetAverageCharacterWidth(), 0); |
102 } | 102 } |
103 | 103 |
104 TEST_F(FontTest, Widths) { | 104 TEST_F(FontTest, Widths) { |
105 Font cf("Arial", 16); | 105 Font cf("Arial", 16); |
106 ASSERT_EQ(cf.GetStringWidth(string16()), 0); | 106 ASSERT_EQ(cf.GetStringWidth(base::string16()), 0); |
107 ASSERT_GT(cf.GetStringWidth(ASCIIToUTF16("a")), | 107 ASSERT_GT(cf.GetStringWidth(ASCIIToUTF16("a")), |
108 cf.GetStringWidth(string16())); | 108 cf.GetStringWidth(base::string16())); |
109 ASSERT_GT(cf.GetStringWidth(ASCIIToUTF16("ab")), | 109 ASSERT_GT(cf.GetStringWidth(ASCIIToUTF16("ab")), |
110 cf.GetStringWidth(ASCIIToUTF16("a"))); | 110 cf.GetStringWidth(ASCIIToUTF16("a"))); |
111 ASSERT_GT(cf.GetStringWidth(ASCIIToUTF16("abc")), | 111 ASSERT_GT(cf.GetStringWidth(ASCIIToUTF16("abc")), |
112 cf.GetStringWidth(ASCIIToUTF16("ab"))); | 112 cf.GetStringWidth(ASCIIToUTF16("ab"))); |
113 } | 113 } |
114 | 114 |
115 #if defined(OS_WIN) | 115 #if defined(OS_WIN) |
116 TEST_F(FontTest, DeriveFontResizesIfSizeTooSmall) { | 116 TEST_F(FontTest, DeriveFontResizesIfSizeTooSmall) { |
117 Font cf("Arial", 8); | 117 Font cf("Arial", 8); |
118 // The minimum font size is set to 5 in browser_main.cc. | 118 // The minimum font size is set to 5 in browser_main.cc. |
119 ScopedMinimumFontSizeCallback minimum_size(5); | 119 ScopedMinimumFontSizeCallback minimum_size(5); |
120 | 120 |
121 Font derived_font = cf.DeriveFont(-4); | 121 Font derived_font = cf.DeriveFont(-4); |
122 EXPECT_EQ(5, derived_font.GetFontSize()); | 122 EXPECT_EQ(5, derived_font.GetFontSize()); |
123 } | 123 } |
124 | 124 |
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 } // namespace | 135 } // namespace |
136 } // namespace gfx | 136 } // namespace gfx |
OLD | NEW |