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 ed1a535d73d151946fd7a7668864f5241978dfe5..387b1ccd24e0ec11e5a7ea60f2b200841869ed21 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 |
@@ -4,6 +4,7 @@ |
package org.chromium.content.browser.input; |
+import android.annotation.TargetApi; |
import android.app.Activity; |
import android.content.ClipData; |
import android.content.ClipboardManager; |
@@ -214,6 +215,53 @@ public class ImeTest extends ContentShellTestBase { |
@SmallTest |
@Feature({"TextInput", "Main"}) |
+ public void testDeleteSurroundingTextInCodePointsWithRangeSelection() throws Throwable { |
+ commitText("hello", 1); |
Changwan Ryu
2017/01/11 02:00:27
could you use an example where the text contains a
yabinh
2017/01/24 11:39:56
Done.
|
+ waitAndVerifyUpdateSelection(0, 5, 5, -1, -1); |
+ |
+ setSelection(1, 4); |
+ waitAndVerifyUpdateSelection(1, 1, 4, -1, -1); |
+ |
+ deleteSurroundingTextInCodePoints(0, 0); |
+ assertTextsAroundCursor("h", "ell", "o"); |
+ |
+ deleteSurroundingTextInCodePoints(1, 1); |
+ assertTextsAroundCursor("", "ell", ""); |
+ |
+ deleteSurroundingTextInCodePoints(1, 0); |
+ assertTextsAroundCursor("", "ell", ""); |
+ |
+ deleteSurroundingTextInCodePoints(0, 1); |
+ assertTextsAroundCursor("", "ell", ""); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput", "Main"}) |
+ public void testDeleteSurroundingTextInCodePointsWithCursorSelection() throws Throwable { |
+ commitText("hello", 1); |
+ waitAndVerifyUpdateSelection(0, 5, 5, -1, -1); |
+ |
+ setSelection(2, 2); |
+ waitAndVerifyUpdateSelection(1, 2, 2, -1, -1); |
+ |
+ deleteSurroundingTextInCodePoints(0, 0); |
+ assertTextsAroundCursor("he", null, "llo"); |
+ |
+ deleteSurroundingTextInCodePoints(1, 1); |
+ assertTextsAroundCursor("h", null, "lo"); |
+ |
+ deleteSurroundingTextInCodePoints(1, 0); |
+ assertTextsAroundCursor("", null, "lo"); |
+ |
+ deleteSurroundingTextInCodePoints(0, 10); |
+ assertTextsAroundCursor("", null, ""); |
+ |
+ deleteSurroundingTextInCodePoints(10, 10); |
+ assertTextsAroundCursor("", null, ""); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput", "Main"}) |
public void testSetComposingTextForNewCursorPositions() throws Throwable { |
// Cursor is on the right of composing text when newCursorPosition > 0. |
setComposingText("ab", 1); |
@@ -1302,6 +1350,50 @@ public class ImeTest extends ContentShellTestBase { |
@MediumTest |
@Feature({"TextInput"}) |
+ public void testContentEditableEvents_DeleteSurroundingTextInCodePoints() throws Throwable { |
+ focusElementAndWaitForStateUpdate("contenteditable_event"); |
+ waitForEventLogs("selectionchange,selectionchange"); |
+ clearEventLogs(); |
+ |
+ commitText("hello", 1); |
+ waitAndVerifyUpdateSelection(0, 5, 5, -1, -1); |
+ waitForEventLogs("keydown(229),input,keyup(229),selectionchange"); |
+ clearEventLogs(); |
+ |
+ setSelection(2, 2); |
+ waitAndVerifyUpdateSelection(1, 2, 2, -1, -1); |
+ waitForEventLogs("selectionchange"); |
+ clearEventLogs(); |
+ |
+ deleteSurroundingTextInCodePoints(1, 1); |
+ waitAndVerifyUpdateSelection(2, 1, 1, -1, -1); |
+ // TODO(yabinh): It should only fire 1 input and 1 selectionchange events. |
+ waitForEventLogs("keydown(229),input,input,keyup(229),selectionchange,selectionchange," |
+ + "selectionchange,selectionchange"); |
+ } |
+ |
+ @MediumTest |
+ @Feature({"TextInput"}) |
+ public void testInputTextEvents_DeleteSurroundingTextInCodePoints() throws Throwable { |
+ commitText("hello", 1); |
+ waitAndVerifyUpdateSelection(0, 5, 5, -1, -1); |
+ waitForEventLogs("keydown(229),input,keyup(229),selectionchange"); |
+ clearEventLogs(); |
+ |
+ setSelection(2, 2); |
+ waitAndVerifyUpdateSelection(1, 2, 2, -1, -1); |
+ waitForEventLogs("selectionchange"); |
+ clearEventLogs(); |
+ |
+ deleteSurroundingTextInCodePoints(1, 1); |
+ waitAndVerifyUpdateSelection(2, 1, 1, -1, -1); |
+ // TODO(yabinh): It should only fire 1 input and 1 selectionchange events. |
+ waitForEventLogs("keydown(229),input,input,keyup(229),selectionchange,selectionchange," |
+ + "selectionchange,selectionchange"); |
+ } |
+ |
+ @MediumTest |
+ @Feature({"TextInput"}) |
public void testGetCursorCapsMode() throws Throwable { |
focusElementAndWaitForStateUpdate("contenteditable_event"); |
commitText("Hello World", 1); |
@@ -1676,6 +1768,21 @@ public class ImeTest extends ContentShellTestBase { |
}); |
} |
+ // Note that deleteSurroundingTextInCodePoints() was introduced in Android N (Api level 24), but |
aelias_OOO_until_Jul13
2017/01/04 23:18:13
As of https://chromium-review.googlesource.com/#/c
yabinh
2017/01/05 01:38:50
There is no deleteSurroundingTextInCodePoints() in
yabinh
2017/01/05 02:04:55
It seems that only 'sdk/build-tools' was updated t
|
+ // the Android repository used in Chrome is behind that (level 23). So this function can't be |
+ // called by keyboard apps currently. |
+ @TargetApi(24) |
+ private boolean deleteSurroundingTextInCodePoints(final int before, final int after) |
+ throws Exception { |
+ final ThreadedInputConnection connection = (ThreadedInputConnection) mConnection; |
+ return runBlockingOnImeThread(new Callable<Boolean>() { |
+ @Override |
+ public Boolean call() { |
+ return connection.deleteSurroundingTextInCodePoints(before, after); |
+ } |
+ }); |
+ } |
+ |
private CharSequence getTextBeforeCursor(final int length, final int flags) throws Exception { |
final ChromiumBaseInputConnection connection = mConnection; |
return runBlockingOnImeThread(new Callable<CharSequence>() { |