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

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

Issue 18848002: Shows Japanese and English mixed queries correctly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes based on review comments. Created 7 years, 5 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
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_list.h" 5 #include "ui/gfx/font_list.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 FontList font_list = FontList(fonts); 225 FontList font_list = FontList(fonts);
226 226
227 FontList derived = font_list.DeriveFontListWithSize(5); 227 FontList derived = font_list.DeriveFontListWithSize(5);
228 const std::vector<Font>& derived_fonts = derived.GetFonts(); 228 const std::vector<Font>& derived_fonts = derived.GetFonts();
229 229
230 EXPECT_EQ(2U, derived_fonts.size()); 230 EXPECT_EQ(2U, derived_fonts.size());
231 EXPECT_EQ("Arial|5", FontToString(derived_fonts[0])); 231 EXPECT_EQ("Arial|5", FontToString(derived_fonts[0]));
232 EXPECT_EQ("Sans serif|5", FontToString(derived_fonts[1])); 232 EXPECT_EQ("Sans serif|5", FontToString(derived_fonts[1]));
233 } 233 }
234 234
235 TEST(FontListTest, Fonts_GetHeight_GetBaseline) {
236 // If the font list has only one font, the height and baseline must be
237 // the same.
238 Font font_arial10("Arial", 10);
239 FontList font_list_arial10("Arial, 10px");
240 EXPECT_EQ(font_arial10.GetHeight(), font_list_arial10.GetHeight());
241 EXPECT_EQ(font_arial10.GetBaseline(), font_list_arial10.GetBaseline());
242
243 Font font_helvetica20("Helvetica", 20);
244 FontList font_list_helvetica20("Helvetica, 20px");
245 EXPECT_EQ(font_helvetica20.GetHeight(), font_list_helvetica20.GetHeight());
246 EXPECT_EQ(font_helvetica20.GetBaseline(),
247 font_list_helvetica20.GetBaseline());
248
249 // If there are two different fonts, the font list returns the max value.
250 FontList font_list_mix(font_arial10);
251 // Bypass DCHECK in a constructor of FontList which checks that all the fonts
msw 2013/07/12 09:36:04 Hmm, if FontList behavior for mixed font sizes is
Yuki 2013/07/12 10:29:24 Technically we can remove it, but I'm not sure if
252 // have the same font size.
253 font_list_mix.fonts_.push_back(font_helvetica20);
254 // Helvetica 20px must be larger than Arial 10px.
255 EXPECT_GT(font_helvetica20.GetHeight(), font_arial10.GetHeight());
256 EXPECT_EQ(font_helvetica20.GetHeight(), font_list_mix.GetHeight());
257 EXPECT_GT(font_helvetica20.GetBaseline(), font_arial10.GetBaseline());
258 EXPECT_EQ(font_helvetica20.GetBaseline(), font_list_mix.GetBaseline());
259 }
260
235 } // namespace gfx 261 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698