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

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java

Issue 1889053003: Fix InputConnection.deleteSurroundingText() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: deleteContents doesn’t work well for multiple nodes. Created 4 years, 7 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/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java b/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java
index b1f13c08575d5a860054f159e2fcaf2d4d6f94e4..49c097c486904f126b3945990513b562ec32795d 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java
@@ -124,19 +124,64 @@ public class ImeTest extends ContentShellTestBase {
@SmallTest
@Feature({"TextInput", "Main"})
- public void testDeleteSurroundingTextWithZeroValue() throws Throwable {
+ public void testDeleteSurroundingTextWithRangeSelection() throws Throwable {
commitText("hello", 1);
waitAndVerifyUpdateSelection(0, 5, 5, -1, -1);
- deleteSurroundingText(0, 0);
- setSelection(0, 0);
- waitAndVerifyUpdateSelection(1, 0, 0, -1, -1);
+ setSelection(1, 4);
+ waitAndVerifyUpdateSelection(1, 1, 4, -1, -1);
+
deleteSurroundingText(0, 0);
+ assertTextsAroundCursor("h", "ell", "o");
+
+ deleteSurroundingText(1, 1);
+ assertTextsAroundCursor("", "ell", "");
+
+ deleteSurroundingText(1, 0);
+ assertTextsAroundCursor("", "ell", "");
+
+ deleteSurroundingText(0, 1);
+ assertTextsAroundCursor("", "ell", "");
+ }
+
+ @SmallTest
+ @Feature({"TextInput", "Main"})
+ public void testDeleteSurroundingTextWithCursorSelection() throws Throwable {
+ commitText("hello", 1);
+ waitAndVerifyUpdateSelection(0, 5, 5, -1, -1);
setSelection(2, 2);
- waitAndVerifyUpdateSelection(2, 2, 2, -1, -1);
+ waitAndVerifyUpdateSelection(1, 2, 2, -1, -1);
+
deleteSurroundingText(0, 0);
assertTextsAroundCursor("he", "", "llo");
+
+ deleteSurroundingText(1, 1);
+ assertTextsAroundCursor("h", "", "lo");
+
+ deleteSurroundingText(1, 0);
+ assertTextsAroundCursor("", "", "lo");
+
+ deleteSurroundingText(0, 10);
+ assertTextsAroundCursor("", "", "");
+
+ deleteSurroundingText(10, 10);
+ assertTextsAroundCursor("", "", "");
+ }
+
+ @SmallTest
+ @Feature({"TextInput", "Main"})
+ public void testContentEditableEvents_DeleteSurroundingText() throws Throwable {
+ focusElementAndWaitForStateUpdate("contenteditable_event");
+ setSelection(2, 6);
+ waitAndVerifyUpdateSelection(0, 2, 6, -1, -1);
+ assertTextsAroundCursor("ab", "cdef", "gh");
+ waitForEventLogs("selectionchange,selectionchange,selectionchange,selectionchange");
+
yabinh 2016/05/23 10:24:59 deleteContents can work for multiple nodes if ther
+ deleteSurroundingText(1, 1);
+ assertTextsAroundCursor("a", "cdef", "h");
+ waitForEventLogs("selectionchange,selectionchange,selectionchange,selectionchange,"
+ + "keydown(229),input,keyup(229),selectionchange");
}
// When newCursorPosition != 1, setComposingText doesn't work for ReplicaInputConnection

Powered by Google App Engine
This is Rietveld 408576698