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

Unified Diff: ui/gfx/render_text_unittest.cc

Issue 1024543006: [RenderText] added test for AppendText (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes for review nits 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
« 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 42825579ec6cb0b68fe701de431a2c1444d5c1f7..9ece279f9f05586717a4945e94a4dce57ebb1d04 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -352,6 +352,39 @@ TEST_F(RenderTextTest, ApplyStyles) {
#endif // OS_MACOSX
}
+TEST_F(RenderTextTest, AppendTextKeepsStyles) {
+ scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
+ // Setup basic functionality.
+ render_text->SetText(ASCIIToUTF16("abc"));
+ render_text->ApplyColor(SK_ColorRED, Range(0, 1));
+ render_text->ApplyBaselineStyle(SUPERSCRIPT, Range(1, 2));
+ render_text->ApplyStyle(UNDERLINE, true, Range(2, 3));
+ // Verify basic functionality.
+ std::vector<std::pair<size_t, SkColor>> expected_color;
+ expected_color.push_back(std::pair<size_t, SkColor>(0, SK_ColorRED));
+ expected_color.push_back(std::pair<size_t, SkColor>(1, 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>(2, true));
+ EXPECT_TRUE(
+ render_text->styles()[UNDERLINE].EqualsForTesting(expected_style));
+ // Ensure AppendText maintains current text styles.
+ 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)
« 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