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) |