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

Unified Diff: third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp

Issue 2372493002: Workaround for setComposition styling clobber (Closed)
Patch Set: Fix a layout test Created 4 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
Index: third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp b/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
index cfce7ed4321ce2a651f7a175a04aecf55e470121..e851100e2666b8eb85cb95f3528b5257a1a067b1 100644
--- a/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
+++ b/third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp
@@ -115,6 +115,30 @@ TEST_F(InputMethodControllerTest, SetCompositionFromExistingText)
PlainTextRange plainTextRange(PlainTextRange::create(*div, *range));
EXPECT_EQ(0u, plainTextRange.start());
EXPECT_EQ(5u, plainTextRange.end());
+
+ controller().setComposition(String("hellobar"), underlines, 8, 8);
+ range = controller().compositionRange();
+ EXPECT_EQ(0, range->startOffset());
+ EXPECT_EQ(8, range->endOffset());
+}
+
+TEST_F(InputMethodControllerTest, SetCompositionKeepingStyle)
+{
+ // 0xac00 = "가", 0xb098="나", 0xb2e4 = "다", 0xb77c = "라"
+ Element* div = insertHTMLElement(
+ "<div id='sample' contenteditable='true'><b>&#xac00&#xb098</b>&#xb2e4&#xb77c</div>", "sample");
+
+ Vector<CompositionUnderline> underlines;
+ underlines.append(CompositionUnderline(0, 4, Color(255, 0, 0), false, 0));
+ controller().setCompositionFromExistingText(underlines, 0, 4);
+
+ // 0xEAB080 = "가", 0xEB8298="나", 0xEB8BA4 = "다", 0xEB9E8C = "람"
+ controller().setComposition(String::fromUTF8("\xea\xb0\x80\xeb\x82\x98\xeb\x8b\xa4\xeb\x9e\x8c"), underlines, 4, 4);
+ EXPECT_STREQ("<b>가나</b>다람", div->innerHTML().utf8().data());
+
+ // 0xeb9dbc = "라"
+ controller().setComposition(String::fromUTF8("\xea\xb0\x80\xeb\x82\x98\xeb\x8b\xa4\xeb\x9d\xbc"), underlines, 4, 4);
+ EXPECT_STREQ("<b>가나</b>다라", div->innerHTML().utf8().data());
}
TEST_F(InputMethodControllerTest, SelectionOnConfirmExistingText)
@@ -485,7 +509,7 @@ TEST_F(InputMethodControllerTest, CompositionInputEventData)
document().setTitle(emptyString());
controller().setComposition("ni", underlines, 0, 1);
- EXPECT_STREQ("beforeinput.data:ni;input.data:ni;", document().title().utf8().data());
+ EXPECT_STREQ("beforeinput.data:i;input.data:i;", document().title().utf8().data());
document().setTitle(emptyString());
controller().finishComposingText(InputMethodController::KeepSelection);

Powered by Google App Engine
This is Rietveld 408576698