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..e34f88c0dd988ddeec7566a057d5ae7d6d682082 100644 |
--- a/ui/gfx/render_text_unittest.cc |
+++ b/ui/gfx/render_text_unittest.cc |
@@ -352,6 +352,43 @@ TEST_F(RenderTextTest, ApplyStyles) { |
#endif // OS_MACOSX |
} |
+TEST_F(RenderTextTest, AppendText) { |
msw
2015/03/24 22:20:59
nit: name AppendTextKeepsStyles
dschuyler
2015/03/24 22:38:12
Done.
|
+ // Ensure AppendText maintains current text styles. |
msw
2015/03/24 22:20:59
nit: move this comment down to replace the comment
dschuyler
2015/03/24 22:38:12
Done.
|
+ scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); |
+ // Setup basic functionality. |
+ render_text->SetText(ASCIIToUTF16("abc")); |
+ const SkColor color = SK_ColorRED; |
msw
2015/03/24 22:20:59
nit: just inline SK_ColorRED here and line 367.
dschuyler
2015/03/24 22:38:12
Done.
|
+ render_text->ApplyColor(color, Range(1, 2)); |
msw
2015/03/24 22:20:59
nit: make the text red over range 0-1 (for more co
dschuyler
2015/03/24 22:38:12
Done.
|
+ render_text->ApplyBaselineStyle(SUPERSCRIPT, Range(1, 2)); |
+ render_text->ApplyStyle(UNDERLINE, true, Range(1, 2)); |
msw
2015/03/24 22:20:59
nit: apply underline over range 2-3 (for more cove
dschuyler
2015/03/24 22:38:12
Done.
|
+ // Verify basic functionality. |
+ std::vector<std::pair<size_t, SkColor>> expected_color; |
+ expected_color.push_back(std::pair<size_t, SkColor>(0, SK_ColorBLACK)); |
+ expected_color.push_back(std::pair<size_t, SkColor>(1, color)); |
+ expected_color.push_back(std::pair<size_t, SkColor>(2, SK_ColorBLACK)); |
+ EXPECT_TRUE(render_text->colors().EqualsForTesting(expected_color)); |
+ std::vector<std::pair<size_t, BaselineStyle>> expected_baseline; |
+ expected_baseline.push_back( |
+ std::pair<size_t, BaselineStyle>(0, NORMAL_BASELINE)); |
+ expected_baseline.push_back(std::pair<size_t, BaselineStyle>(1, SUPERSCRIPT)); |
+ expected_baseline.push_back( |
+ std::pair<size_t, BaselineStyle>(2, NORMAL_BASELINE)); |
+ EXPECT_TRUE(render_text->baselines().EqualsForTesting(expected_baseline)); |
+ std::vector<std::pair<size_t, bool>> expected_style; |
+ expected_style.push_back(std::pair<size_t, bool>(0, false)); |
+ expected_style.push_back(std::pair<size_t, bool>(1, true)); |
+ expected_style.push_back(std::pair<size_t, bool>(2, false)); |
+ EXPECT_TRUE( |
+ render_text->styles()[UNDERLINE].EqualsForTesting(expected_style)); |
+ // Do the specific test (the core of this test). |
+ render_text->AppendText(ASCIIToUTF16("def")); |
+ EXPECT_EQ(render_text->GetDisplayText(), ASCIIToUTF16("abcdef")); |
+ EXPECT_TRUE(render_text->colors().EqualsForTesting(expected_color)); |
+ EXPECT_TRUE(render_text->baselines().EqualsForTesting(expected_baseline)); |
+ EXPECT_TRUE( |
+ render_text->styles()[UNDERLINE].EqualsForTesting(expected_style)); |
+} |
+ |
// TODO(asvitkine): Cursor movements tests disabled on Mac because RenderTextMac |
// does not implement this yet. http://crbug.com/131618 |
#if !defined(OS_MACOSX) |