Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: ui/gfx/font_unittest.cc

Issue 448853002: Move StringToLowerASCII to base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/font_list_unittest.cc ('k') | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #endif // defined(OS_WIN) 57 #endif // defined(OS_WIN)
58 58
59 59
60 TEST_F(FontTest, LoadArial) { 60 TEST_F(FontTest, LoadArial) {
61 Font cf("Arial", 16); 61 Font cf("Arial", 16);
62 NativeFont native = cf.GetNativeFont(); 62 NativeFont native = cf.GetNativeFont();
63 EXPECT_TRUE(native); 63 EXPECT_TRUE(native);
64 EXPECT_EQ(cf.GetStyle(), Font::NORMAL); 64 EXPECT_EQ(cf.GetStyle(), Font::NORMAL);
65 EXPECT_EQ(cf.GetFontSize(), 16); 65 EXPECT_EQ(cf.GetFontSize(), 16);
66 EXPECT_EQ(cf.GetFontName(), "Arial"); 66 EXPECT_EQ(cf.GetFontName(), "Arial");
67 EXPECT_EQ("arial", StringToLowerASCII(cf.GetActualFontNameForTesting())); 67 EXPECT_EQ("arial",
68 base::StringToLowerASCII(cf.GetActualFontNameForTesting()));
68 FreeIfNecessary(native); 69 FreeIfNecessary(native);
69 } 70 }
70 71
71 TEST_F(FontTest, LoadArialBold) { 72 TEST_F(FontTest, LoadArialBold) {
72 Font cf("Arial", 16); 73 Font cf("Arial", 16);
73 Font bold(cf.Derive(0, Font::BOLD)); 74 Font bold(cf.Derive(0, Font::BOLD));
74 NativeFont native = bold.GetNativeFont(); 75 NativeFont native = bold.GetNativeFont();
75 EXPECT_TRUE(native); 76 EXPECT_TRUE(native);
76 EXPECT_EQ(bold.GetStyle(), Font::BOLD); 77 EXPECT_EQ(bold.GetStyle(), Font::BOLD);
77 EXPECT_EQ("arial", StringToLowerASCII(cf.GetActualFontNameForTesting())); 78 EXPECT_EQ("arial",
79 base::StringToLowerASCII(cf.GetActualFontNameForTesting()));
78 FreeIfNecessary(native); 80 FreeIfNecessary(native);
79 } 81 }
80 82
81 TEST_F(FontTest, Ascent) { 83 TEST_F(FontTest, Ascent) {
82 Font cf("Arial", 16); 84 Font cf("Arial", 16);
83 EXPECT_GT(cf.GetBaseline(), 2); 85 EXPECT_GT(cf.GetBaseline(), 2);
84 EXPECT_LE(cf.GetBaseline(), 22); 86 EXPECT_LE(cf.GetBaseline(), 22);
85 } 87 }
86 88
87 TEST_F(FontTest, Height) { 89 TEST_F(FontTest, Height) {
(...skipping 20 matching lines...) Expand all
108 110
109 #if !defined(OS_WIN) 111 #if !defined(OS_WIN)
110 // On Windows, Font::GetActualFontNameForTesting() doesn't work well for now. 112 // On Windows, Font::GetActualFontNameForTesting() doesn't work well for now.
111 // http://crbug.com/327287 113 // http://crbug.com/327287
112 // 114 //
113 // Check that fonts used for testing are installed and enabled. On Mac 115 // Check that fonts used for testing are installed and enabled. On Mac
114 // fonts may be installed but still need enabling in Font Book.app. 116 // fonts may be installed but still need enabling in Font Book.app.
115 // http://crbug.com/347429 117 // http://crbug.com/347429
116 TEST_F(FontTest, GetActualFontNameForTesting) { 118 TEST_F(FontTest, GetActualFontNameForTesting) {
117 Font arial("Arial", 16); 119 Font arial("Arial", 16);
118 EXPECT_EQ("arial", StringToLowerASCII(arial.GetActualFontNameForTesting())) 120 EXPECT_EQ("arial",
121 base::StringToLowerASCII(arial.GetActualFontNameForTesting()))
119 << "********\n" 122 << "********\n"
120 << "Your test environment seems to be missing Arial font, which is " 123 << "Your test environment seems to be missing Arial font, which is "
121 << "needed for unittests. Check if Arial font is installed.\n" 124 << "needed for unittests. Check if Arial font is installed.\n"
122 << "********"; 125 << "********";
123 Font symbol("Symbol", 16); 126 Font symbol("Symbol", 16);
124 EXPECT_EQ("symbol", StringToLowerASCII(symbol.GetActualFontNameForTesting())) 127 EXPECT_EQ("symbol",
128 base::StringToLowerASCII(symbol.GetActualFontNameForTesting()))
125 << "********\n" 129 << "********\n"
126 << "Your test environment seems to be missing Symbol font, which is " 130 << "Your test environment seems to be missing Symbol font, which is "
127 << "needed for unittests. Check if Symbol font is installed.\n" 131 << "needed for unittests. Check if Symbol font is installed.\n"
128 << "********"; 132 << "********";
129 133
130 const char* const invalid_font_name = "no_such_font_name"; 134 const char* const invalid_font_name = "no_such_font_name";
131 Font fallback_font(invalid_font_name, 16); 135 Font fallback_font(invalid_font_name, 16);
132 EXPECT_NE(invalid_font_name, 136 EXPECT_NE(invalid_font_name,
133 StringToLowerASCII(fallback_font.GetActualFontNameForTesting())); 137 base::StringToLowerASCII(
138 fallback_font.GetActualFontNameForTesting()));
134 } 139 }
135 #endif 140 #endif
136 141
137 #if defined(OS_WIN) 142 #if defined(OS_WIN)
138 TEST_F(FontTest, DeriveResizesIfSizeTooSmall) { 143 TEST_F(FontTest, DeriveResizesIfSizeTooSmall) {
139 Font cf("Arial", 8); 144 Font cf("Arial", 8);
140 // The minimum font size is set to 5 in browser_main.cc. 145 // The minimum font size is set to 5 in browser_main.cc.
141 ScopedMinimumFontSizeCallback minimum_size(5); 146 ScopedMinimumFontSizeCallback minimum_size(5);
142 147
143 Font derived_font = cf.Derive(-4, cf.GetStyle()); 148 Font derived_font = cf.Derive(-4, cf.GetStyle());
144 EXPECT_EQ(5, derived_font.GetFontSize()); 149 EXPECT_EQ(5, derived_font.GetFontSize());
145 } 150 }
146 151
147 TEST_F(FontTest, DeriveKeepsOriginalSizeIfHeightOk) { 152 TEST_F(FontTest, DeriveKeepsOriginalSizeIfHeightOk) {
148 Font cf("Arial", 8); 153 Font cf("Arial", 8);
149 // The minimum font size is set to 5 in browser_main.cc. 154 // The minimum font size is set to 5 in browser_main.cc.
150 ScopedMinimumFontSizeCallback minimum_size(5); 155 ScopedMinimumFontSizeCallback minimum_size(5);
151 156
152 Font derived_font = cf.Derive(-2, cf.GetStyle()); 157 Font derived_font = cf.Derive(-2, cf.GetStyle());
153 EXPECT_EQ(6, derived_font.GetFontSize()); 158 EXPECT_EQ(6, derived_font.GetFontSize());
154 } 159 }
155 #endif // defined(OS_WIN) 160 #endif // defined(OS_WIN)
156 161
157 } // namespace 162 } // namespace
158 } // namespace gfx 163 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/font_list_unittest.cc ('k') | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698