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

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

Issue 24883002: Uses and returns the fractional width in text eliding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix round-down problems Created 7 years, 2 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.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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 TEST_F(FontTest, DeriveFontKeepsOriginalSizeIfHeightOk) { 136 TEST_F(FontTest, DeriveFontKeepsOriginalSizeIfHeightOk) {
137 Font cf("Arial", 8); 137 Font cf("Arial", 8);
138 // The minimum font size is set to 5 in browser_main.cc. 138 // The minimum font size is set to 5 in browser_main.cc.
139 ScopedMinimumFontSizeCallback minimum_size(5); 139 ScopedMinimumFontSizeCallback minimum_size(5);
140 140
141 Font derived_font = cf.DeriveFont(-2); 141 Font derived_font = cf.DeriveFont(-2);
142 EXPECT_EQ(6, derived_font.GetFontSize()); 142 EXPECT_EQ(6, derived_font.GetFontSize());
143 } 143 }
144 #endif // defined(OS_WIN) 144 #endif // defined(OS_WIN)
145 145
146 #if defined(OS_MACOSX)
147 // TODO(ios): This test fails on iOS because iOS version of gfx::GetStringWidth
148 // that calls [NSString sizeWithFont] returns the rounded string width.
149 #if defined(OS_IOS)
150 #define MAYBE_FractionalWidth DISABLED_FractionalWidth
151 #else
152 #define MAYBE_FractionalWidth FractionalWidth
153 #endif
154 TEST_F(FontTest, MAYBE_FractionalWidth) {
155 Font cf("Arial", 16);
156
157 float width = cf.GetAverageCharacterWidth();
158 EXPECT_GT(width - static_cast<int>(width), 0);
159
160 width = cf.GetExpectedTextWidth(1);
161 EXPECT_GT(width - static_cast<int>(width), 0);
162
163 width = cf.GetStringWidth(ASCIIToUTF16("This is a test"));
164 EXPECT_GT(width - static_cast<int>(width), 0);
165 }
166 #endif
167
146 } // namespace 168 } // namespace
147 } // namespace gfx 169 } // namespace gfx
OLDNEW
« ui/gfx/canvas.h ('K') | « ui/gfx/font_list.cc ('k') | ui/gfx/platform_font.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698