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

Unified Diff: ui/gfx/render_text_unittest.cc

Issue 371413002: Don't split text runs on underline style change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoid applying style change mid-grapheme Created 6 years, 3 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.cc ('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 79476c47603ad46289802e1f89adb9b22d5cf784..5d377e74f89b748981f132f5c4a5c858b56a3fca 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -171,17 +171,35 @@ TEST_F(RenderTextTest, ApplyColorAndStyle) {
expected_italic.push_back(std::pair<size_t, bool>(7, true));
EXPECT_TRUE(render_text->styles()[ITALIC].EqualsForTesting(expected_italic));
- // Truncating the text should trim any corresponding breaks.
+ // Changing the text should clear any breaks except for the first one.
render_text->SetText(ASCIIToUTF16("0123456"));
- expected_italic.resize(4);
+ expected_italic.resize(1);
EXPECT_TRUE(render_text->styles()[ITALIC].EqualsForTesting(expected_italic));
- render_text->SetText(ASCIIToUTF16("01234"));
- expected_italic.resize(3);
+ render_text->ApplyStyle(ITALIC, false, Range(2, 4));
+ render_text->SetText(ASCIIToUTF16("012345678"));
EXPECT_TRUE(render_text->styles()[ITALIC].EqualsForTesting(expected_italic));
-
- // Appending text should extend the terminal styles without changing breaks.
+ render_text->ApplyStyle(ITALIC, false, Range(0, 1));
+ render_text->SetText(ASCIIToUTF16("0123456"));
+ expected_italic.begin()->second = false;
+ EXPECT_TRUE(render_text->styles()[ITALIC].EqualsForTesting(expected_italic));
+ render_text->ApplyStyle(ITALIC, true, Range(2, 4));
render_text->SetText(ASCIIToUTF16("012345678"));
EXPECT_TRUE(render_text->styles()[ITALIC].EqualsForTesting(expected_italic));
+
+ // TODO(tmoniuszko): Enable when RenderTextMac::IsValidCursorIndex is
+ // implemented.
+#if !defined(OS_MACOSX)
+ // Styles shouldn't be changed mid-grapheme.
+ render_text->SetText(WideToUTF16(
+ L"0" L"\x0915\x093f" L"1" L"\x0915\x093f" L"2"));
+ render_text->ApplyStyle(UNDERLINE, true, Range(2, 5));
+ std::vector<std::pair<size_t, bool> > expected_underline;
+ expected_underline.push_back(std::pair<size_t, bool>(0, false));
+ expected_underline.push_back(std::pair<size_t, bool>(1, true));
+ expected_underline.push_back(std::pair<size_t, bool>(6, false));
+ EXPECT_TRUE(render_text->styles()[UNDERLINE].EqualsForTesting(
+ expected_underline));
+#endif // OS_MACOSX
}
#if defined(OS_LINUX) && !defined(USE_OZONE)
« no previous file with comments | « ui/gfx/render_text.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698