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

Unified Diff: ui/gfx/render_text_unittest.cc

Issue 1015533016: Move allow_character_break property to RenderText. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
Index: ui/gfx/render_text_unittest.cc
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc
index 42825579ec6cb0b68fe701de431a2c1444d5c1f7..c9059aa9444426dd5b224285c9e7922aa051903d 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -2262,6 +2262,26 @@ TEST_F(RenderTextTest, Multiline_HorizontalAlignment) {
}
}
+TEST_F(RenderTextTest, Multiline_AllowCharacterBreak) {
+ RenderTextHarfBuzz render_text;
+ render_text.SetMultiline(true);
+ render_text.SetText(ASCIIToUTF16("foo bar baz"));
+ Size ideal_size = render_text.GetStringSize();
+
+ render_text.SetDisplayRect(
+ Rect(0, 0, ideal_size.width() / 2, ideal_size.height()));
+ render_text.SetAllowCharacterBreak(true);
+
+ Canvas canvas;
+ render_text.Draw(&canvas);
+ EXPECT_LE(2u, render_text.lines().size());
+ Range char_range = render_text.lines()[0].segments[0].char_range;
+ EXPECT_EQ(0u, char_range.start());
+ // Broken in the middle of the second word "bar".
+ EXPECT_LT(4u, char_range.end());
+ EXPECT_GT(8u, char_range.end());
+}
+
TEST_F(RenderTextTest, NewlineWithoutMultilineFlag) {
const wchar_t* kTestStrings[] = {
L"abc\ndef", L"a \n b ", L"ab\n", L"a\n\nb", L"\nab", L"\n",

Powered by Google App Engine
This is Rietveld 408576698