| 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 9401829c213ade4070d443b75bc2b5dd1f073fb8..063afa5447592a73e697c8076b3b3d3710b07266 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;
|
| @@ -264,6 +265,38 @@ public class ImeTest extends ContentShellTestBase {
|
|
|
| @SmallTest
|
| @Feature({"TextInput", "Main"})
|
| + public void testDeleteSurroundingTextInCodePointsWithRangeSelection() throws Throwable {
|
| + final String trophy = "\uD83C\uDFC6";
|
| + commitText("ab" + trophy + "cdef" + trophy + "gh", 1);
|
| + waitAndVerifyUpdateSelection(0, 12, 12, -1, -1);
|
| +
|
| + setSelection(6, 8);
|
| + waitAndVerifyUpdateSelection(1, 6, 8, -1, -1);
|
| + assertTextsAroundCursor("ab" + trophy + "cd", "ef", trophy + "gh");
|
| +
|
| + deleteSurroundingTextInCodePoints(2, 2);
|
| + waitAndVerifyUpdateSelection(2, 4, 6, -1, -1);
|
| + assertTextsAroundCursor("ab" + trophy, "ef", "h");
|
| + }
|
| +
|
| + @SmallTest
|
| + @Feature({"TextInput", "Main"})
|
| + public void testDeleteSurroundingTextInCodePointsWithCursorSelection() throws Throwable {
|
| + final String trophy = "\uD83C\uDFC6";
|
| + commitText("ab" + trophy + "cd" + trophy, 1);
|
| + waitAndVerifyUpdateSelection(0, 8, 8, -1, -1);
|
| +
|
| + setSelection(4, 4);
|
| + waitAndVerifyUpdateSelection(1, 4, 4, -1, -1);
|
| + assertTextsAroundCursor("ab" + trophy, null, "cd" + trophy);
|
| +
|
| + deleteSurroundingTextInCodePoints(2, 2);
|
| + waitAndVerifyUpdateSelection(2, 1, 1, -1, -1);
|
| + assertTextsAroundCursor("a", null, trophy);
|
| + }
|
| +
|
| + @SmallTest
|
| + @Feature({"TextInput", "Main"})
|
| public void testSetComposingTextForNewCursorPositions() throws Throwable {
|
| // Cursor is on the right of composing text when newCursorPosition > 0.
|
| setComposingText("ab", 1);
|
| @@ -1354,6 +1387,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);
|
| @@ -1728,6 +1805,21 @@ public class ImeTest extends ContentShellTestBase {
|
| });
|
| }
|
|
|
| + // Note that deleteSurroundingTextInCodePoints() was introduced in Android N (Api level 24), but
|
| + // 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>() {
|
|
|