Commit 28da9ffb authored by ckocagil's avatar ckocagil Committed by Commit bot

RenderText: Add a test to ensure strings fit their own widths

This CL tests against regressions of http://crbug.com/402347

BUG=402347

Review URL: https://codereview.chromium.org/652573002

Cr-Commit-Position: refs/heads/master@{#299997}
parent 535c75f4
...@@ -581,6 +581,7 @@ class GFX_EXPORT RenderText { ...@@ -581,6 +581,7 @@ class GFX_EXPORT RenderText {
FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SameFontForParentheses); FRIEND_TEST_ALL_PREFIXES(RenderTextTest, SameFontForParentheses);
FRIEND_TEST_ALL_PREFIXES(RenderTextTest, BreakRunsByUnicodeBlocks); FRIEND_TEST_ALL_PREFIXES(RenderTextTest, BreakRunsByUnicodeBlocks);
FRIEND_TEST_ALL_PREFIXES(RenderTextTest, PangoAttributes); FRIEND_TEST_ALL_PREFIXES(RenderTextTest, PangoAttributes);
FRIEND_TEST_ALL_PREFIXES(RenderTextTest, StringFitsOwnWidth);
// Creates a platform-specific RenderText instance. // Creates a platform-specific RenderText instance.
static RenderText* CreateNativeInstance(); static RenderText* CreateNativeInstance();
......
...@@ -2309,4 +2309,19 @@ TEST_F(RenderTextTest, HarfBuzz_EmptyRun) { ...@@ -2309,4 +2309,19 @@ TEST_F(RenderTextTest, HarfBuzz_EmptyRun) {
EXPECT_EQ(Range(0, 0), glyphs); 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());
const base::string16 kString = ASCIIToUTF16("www.example.com");
render_text->SetText(kString);
render_text->ApplyStyle(BOLD, true, Range(0, 3));
render_text->SetElideBehavior(ELIDE_TAIL);
render_text->SetDisplayRect(Rect(0, 0, 500, 100));
EXPECT_EQ(kString, render_text->GetLayoutText());
render_text->SetDisplayRect(Rect(0, 0, render_text->GetContentWidth(), 100));
EXPECT_EQ(kString, render_text->GetLayoutText());
}
} // namespace gfx } // namespace gfx
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment