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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/font_unittest.cc
diff --git a/ui/gfx/font_unittest.cc b/ui/gfx/font_unittest.cc
index 247b2f3f1badeceb8ea6da060a8761013c1db106..6f9324e27924bfa82d085b53ff4f69ee1be7d0bc 100644
--- a/ui/gfx/font_unittest.cc
+++ b/ui/gfx/font_unittest.cc
@@ -143,5 +143,27 @@ TEST_F(FontTest, DeriveFontKeepsOriginalSizeIfHeightOk) {
}
#endif // defined(OS_WIN)
+#if defined(OS_MACOSX)
+// TODO(ios): This test fails on iOS because iOS version of gfx::GetStringWidth
+// that calls [NSString sizeWithFont] returns the rounded string width.
+#if defined(OS_IOS)
+#define MAYBE_FractionalWidth DISABLED_FractionalWidth
+#else
+#define MAYBE_FractionalWidth FractionalWidth
+#endif
+TEST_F(FontTest, MAYBE_FractionalWidth) {
+ Font cf("Arial", 16);
+
+ float width = cf.GetAverageCharacterWidth();
+ EXPECT_GT(width - static_cast<int>(width), 0);
+
+ width = cf.GetExpectedTextWidth(1);
+ EXPECT_GT(width - static_cast<int>(width), 0);
+
+ width = cf.GetStringWidth(ASCIIToUTF16("This is a test"));
+ EXPECT_GT(width - static_cast<int>(width), 0);
+}
+#endif
+
} // namespace
} // namespace gfx
« 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