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

Unified Diff: ui/gfx/render_text_unittest.cc

Issue 968923004: Use GetDisplayText() instead of text() for rendering text. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo Created 5 years, 9 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
« no previous file with comments | « ui/gfx/render_text_mac.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_unittest.cc
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc
index e274a266eaa9acfd18bfbaca370a327215f5f7f8..8009305323f55cdb447e106f89ebee37fb10c133 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -28,6 +28,12 @@
#include "ui/gfx/platform_font_win.h"
#endif
+#if defined(OS_MACOSX)
+#include <ApplicationServices/ApplicationServices.h>
+
+#include "ui/gfx/render_text_mac.h"
+#endif
+
using base::ASCIIToUTF16;
using base::UTF8ToUTF16;
using base::WideToUTF16;
@@ -2626,4 +2632,26 @@ TEST_F(RenderTextTest, TextDoesntClip) {
}
}
+#if defined(OS_MACOSX)
+TEST_F(RenderTextTest, Mac_ElidedText) {
+ RenderTextMac render_text;
+ base::string16 text(ASCIIToUTF16("This is an example."));
+ render_text.SetText(text);
+ gfx::Size string_size = render_text.GetStringSize();
+ render_text.SetDisplayRect(gfx::Rect(string_size));
+ render_text.EnsureLayout();
+ // NOTE: Character and glyph counts are only comparable for simple text.
+ EXPECT_EQ(text.size(),
+ static_cast<size_t>(CTLineGetGlyphCount(render_text.line_)));
+
+ render_text.SetElideBehavior(ELIDE_TAIL);
+ string_size.set_width(string_size.width() / 2);
+ render_text.SetDisplayRect(gfx::Rect(string_size));
+ render_text.EnsureLayout();
+ CFIndex glyph_count = CTLineGetGlyphCount(render_text.line_);
+ EXPECT_GT(text.size(), static_cast<size_t>(glyph_count));
+ EXPECT_NE(0, glyph_count);
+}
+#endif
+
} // namespace gfx
« no previous file with comments | « ui/gfx/render_text_mac.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698