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

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: Added baseline breaklist test 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..9627f7d8b0c2d34a940128d441577f812c205218 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -352,6 +352,41 @@ TEST_F(RenderTextTest, ApplyStyles) {
#endif // OS_MACOSX
}
+TEST_F(RenderTextTest, AppendText) {
+ // Ensure AppendText maintains current text styles.
+ scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
+ const SkColor color = SK_ColorRED;
+ render_text->SetColor(color);
+ render_text->SetBaselineStyle(SUPERSCRIPT);
+ render_text->SetStyle(BOLD, true);
+ render_text->SetStyle(UNDERLINE, false);
+ const wchar_t* const cases[] = {L"Hello", L"", L" ", L"world"};
+ size_t total_length = 0;
+ for (size_t i = 0; i < arraysize(cases); ++i) {
+ EXPECT_TRUE(render_text->colors().EqualsValueForTesting(color));
+ EXPECT_TRUE(render_text->baselines().EqualsValueForTesting(SUPERSCRIPT));
+ EXPECT_TRUE(render_text->styles()[BOLD].EqualsValueForTesting(true));
+ EXPECT_TRUE(render_text->styles()[UNDERLINE].EqualsValueForTesting(false));
+ EXPECT_EQ(total_length, render_text->GetDisplayText().length());
+ base::string16 str = WideToUTF16(cases[i]);
+ render_text->AppendText(str);
+ total_length += str.length();
+ EXPECT_EQ(total_length, render_text->GetDisplayText().length());
+ std::vector<std::pair<size_t, SkColor>> expected_color;
+ expected_color.push_back(std::pair<size_t, SkColor>(0, color));
msw 2015/03/24 20:06:03 None of this makes sense... Call ApplyStyle / Appl
dschuyler 2015/03/24 20:54:08 Done.
+ EXPECT_TRUE(render_text->colors().EqualsForTesting(expected_color));
+ std::vector<std::pair<size_t, bool>> expected_bold;
+ expected_bold.push_back(std::pair<size_t, bool>(0, true));
+ EXPECT_TRUE(render_text->styles()[BOLD].EqualsForTesting(expected_bold));
+ std::vector<std::pair<size_t, BaselineStyle>> expected_baseline;
+ expected_baseline.push_back(
+ std::pair<size_t, BaselineStyle>(0, SUPERSCRIPT));
+ EXPECT_TRUE(render_text->baselines().EqualsForTesting(expected_baseline));
+ }
+ const base::string16 result_string = ASCIIToUTF16("Hello world");
+ EXPECT_EQ(render_text->GetDisplayText(), result_string);
+}
+
// 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