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

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

Issue 2441343003: Allow the default generic font family settings to find the first available font (Closed)
Patch Set: Code shared in ui/gfx Created 4 years, 1 month 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
« ui/gfx/font.cc ('K') | « ui/gfx/font.cc ('k') | no next file » | 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/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"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 TEST_F(FontTest, DeriveKeepsOriginalSizeIfHeightOk) { 188 TEST_F(FontTest, DeriveKeepsOriginalSizeIfHeightOk) {
189 Font cf("Arial", 8); 189 Font cf("Arial", 8);
190 // 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.
191 ScopedMinimumFontSizeCallback minimum_size(5); 191 ScopedMinimumFontSizeCallback minimum_size(5);
192 192
193 Font derived_font = cf.Derive(-2, cf.GetStyle(), cf.GetWeight()); 193 Font derived_font = cf.Derive(-2, cf.GetStyle(), cf.GetWeight());
194 EXPECT_EQ(6, derived_font.GetFontSize()); 194 EXPECT_EQ(6, derived_font.GetFontSize());
195 } 195 }
196 #endif // defined(OS_WIN) 196 #endif // defined(OS_WIN)
197 197
198 TEST_F(FontTest, FirstAvailableOrFirst) {
199 EXPECT_TRUE(Font::FirstAvailableOrFirst("").empty());
200 EXPECT_TRUE(Font::FirstAvailableOrFirst(std::string()).empty());
201
202 EXPECT_EQ("Arial", Font::FirstAvailableOrFirst("Arial"));
203 EXPECT_EQ("not exist", Font::FirstAvailableOrFirst("not exist"));
204
205 EXPECT_EQ("Arial", Font::FirstAvailableOrFirst("Arial, not exist"));
206 EXPECT_EQ("Arial", Font::FirstAvailableOrFirst("not exist, Arial"));
207 EXPECT_EQ("Arial",
208 Font::FirstAvailableOrFirst("not exist, Arial, not exist"));
209
210 EXPECT_EQ("not exist", Font::FirstAvailableOrFirst("not exist, not exist 2"));
211
212 EXPECT_EQ("Arial", Font::FirstAvailableOrFirst(", not exist, Arial"));
213 EXPECT_EQ("not exist", Font::FirstAvailableOrFirst(", not exist, not exist"));
214 }
215
198 } // namespace 216 } // namespace
199 } // namespace gfx 217 } // namespace gfx
OLDNEW
« ui/gfx/font.cc ('K') | « ui/gfx/font.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698