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 |