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

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: 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
« ui/gfx/render_text.h ('K') | « 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..aa937ab5b95fbd9f71d0d32aa731babd88daf49b 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -216,6 +216,31 @@ class TestRectangleBuffer {
class RenderTextTest : public testing::Test {
};
+TEST_F(RenderTextTest, AppendText) {
msw 2015/03/24 01:47:16 Move this test below ApplyStyles.
dschuyler 2015/03/24 19:37:08 Done.
+ // Ensure AppendText maintains current text styles.
+ scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
+ const SkColor color = SK_ColorRED;
+ render_text->SetColor(color);
msw 2015/03/24 01:47:16 This test should also ensure ranged values from Ap
+ 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());
+ }
+ const base::string16 result_string = ASCIIToUTF16("Hello world");
+ EXPECT_EQ(render_text->GetDisplayText(), result_string);
+}
+
TEST_F(RenderTextTest, DefaultStyles) {
// Check the default styles applied to new instances and adjusted text.
scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
« ui/gfx/render_text.h ('K') | « ui/gfx/render_text.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698