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

Unified Diff: content/renderer/render_view_browsertest.cc

Issue 2617443002: Implement ThreadedInputConnection.deleteSurroundingTextInCodePoints() (Closed)
Patch Set: Don't convert utf8 Created 3 years, 10 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: content/renderer/render_view_browsertest.cc
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index 2629721103184e7191ab460df5941463fa1657c4..823719c2d9ed8074596ef552c1edecfd3d66cc09 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -1667,6 +1667,37 @@ TEST_F(RenderViewImplTest, OnDeleteSurroundingText) {
EXPECT_EQ(0, info.selectionEnd);
}
+TEST_F(RenderViewImplTest, OnDeleteSurroundingTextInCodePoints) {
+ // Load an HTML page consisting of an input field.
+ LoadHTML(
+ "<html>"
yosin_UTC9 2017/02/09 07:19:27 Are HTML, HEAD, BODY required for test or changes
yabinh 2017/02/09 10:37:03 Done.
+ "<head>"
+ "</head>"
+ "<body>"
+ // "ab" + trophy + space + "cdef" + trophy + space + "gh".
+ "<input id=\"test1\" value=\"ab&#x1f3c6 cdef&#x1f3c6 gh\"></input>"
yosin_UTC9 2017/02/09 07:19:27 - It is better to use single quote to avoid escapi
yabinh 2017/02/09 10:37:03 Done.
+ "</body>"
+ "</html>");
+ ExecuteJavaScriptForTests("document.getElementById('test1').focus();");
+
+ frame()->SetEditableSelectionOffsets(4, 4);
+ frame()->DeleteSurroundingTextInCodePoints(2, 2);
+ blink::WebInputMethodController* controller =
+ frame()->GetWebFrame()->inputMethodController();
+ blink::WebTextInputInfo info = controller->textInputInfo();
+ // "a" + "def" + trophy + space + "gh".
+ EXPECT_EQ(WebString::fromUTF8("adef\xF0\x9F\x8F\x86 gh"), info.value);
+ EXPECT_EQ(1, info.selectionStart);
+ EXPECT_EQ(1, info.selectionEnd);
+
+ frame()->SetEditableSelectionOffsets(1, 3);
+ frame()->DeleteSurroundingTextInCodePoints(1, 4);
+ info = controller->textInputInfo();
+ EXPECT_EQ("deh", info.value);
+ EXPECT_EQ(0, info.selectionStart);
+ EXPECT_EQ(2, info.selectionEnd);
+}
+
// Test that the navigating specific frames works correctly.
TEST_F(RenderViewImplTest, NavigateSubframe) {
// Load page A.

Powered by Google App Engine
This is Rietveld 408576698