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

Unified Diff: ui/gfx/render_text_unittest.cc

Issue 652573002: RenderText: Add a test to ensure strings fit their own widths (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: only the test Created 6 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
« no previous file with comments | « ui/gfx/render_text.h ('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 5d377e74f89b748981f132f5c4a5c858b56a3fca..40f7c5cd3ba16ff1f8c2f56d8597c7adb98bc632 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -2309,4 +2309,18 @@ TEST_F(RenderTextTest, HarfBuzz_EmptyRun) {
EXPECT_EQ(Range(0, 0), glyphs);
}
+// Ensure a string fits in a display rect with a width equal to the string's.
+TEST_F(RenderTextTest, StringFitsOwnWidth) {
+ scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
+
+ render_text->SetText(ASCIIToUTF16("www.example.com"));
+ render_text->ApplyStyle(BOLD, true, Range(0, 3));
+ render_text->SetElideBehavior(ELIDE_TAIL);
+
+ render_text->SetDisplayRect(Rect(0, 0, 500, 100));
+ EXPECT_EQ(base::char16('m'), *(render_text->GetLayoutText().end() - 1));
msw 2014/10/16 20:32:21 nit: Just compare the whole string (avoid accident
ckocagil 2014/10/16 20:40:20 Done.
+ render_text->SetDisplayRect(Rect(0, 0, render_text->GetContentWidth(), 100));
+ EXPECT_EQ(base::char16('m'), *(render_text->GetLayoutText().end() - 1));
+}
+
} // namespace gfx
« no previous file with comments | « ui/gfx/render_text.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698