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

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 Created 5 years, 10 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
« ui/gfx/render_text_mac.cc ('K') | « 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 542939ea3081369af9a50fdf080f3490eaa7d3d8..f009a7b3126ec1e30e8a445632c8fe4111416760 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;
@@ -2608,4 +2614,25 @@ 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);
+ 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);
+ gfx::Size string_size = render_text.GetStringSize();
+ string_size.set_width(string_size.width() / 2);
+ render_text.SetDisplayRect(gfx::Rect(string_size));
+ render_text.EnsureLayout();
tapted 2015/03/05 06:32:49 are these EnsureLayout calls needed? (and would th
Jun Mukai 2015/03/05 18:01:38 They can be replaced by Draw() with gfx::Canvas, b
+ 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
« ui/gfx/render_text_mac.cc ('K') | « ui/gfx/render_text_mac.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698