| Index: content/public/android/javatests/src/org/chromium/content/browser/input/AdapterInputConnectionTest.java
|
| diff --git a/content/public/android/javatests/src/org/chromium/content/browser/input/AdapterInputConnectionTest.java b/content/public/android/javatests/src/org/chromium/content/browser/input/AdapterInputConnectionTest.java
|
| index 69be5f86e2a3188019a90775fb7c741e001f5025..9dcce92d8072259dc004439dc0256de4ee284a4c 100644
|
| --- a/content/public/android/javatests/src/org/chromium/content/browser/input/AdapterInputConnectionTest.java
|
| +++ b/content/public/android/javatests/src/org/chromium/content/browser/input/AdapterInputConnectionTest.java
|
| @@ -44,25 +44,40 @@ public class AdapterInputConnectionTest extends ContentShellTestBase {
|
| public void testSetComposingText() throws Throwable {
|
| mConnection.setComposingText("t", 1);
|
| assertCorrectState("t", 1, 1, 0, 1, mConnection.getImeStateForTesting());
|
| - mConnection.setEditableText("t", 1, 1, 0, 1);
|
| mWrapper.verifyUpdateSelectionCall(0, 1, 1, 0 ,1);
|
|
|
| mConnection.setComposingText("te", 1);
|
| assertCorrectState("te", 2, 2, 0, 2, mConnection.getImeStateForTesting());
|
| - mConnection.setEditableText("te", 2, 2, 0, 2);
|
| mWrapper.verifyUpdateSelectionCall(1, 2, 2, 0 ,2);
|
|
|
| mConnection.setComposingText("tes", 1);
|
| assertCorrectState("tes", 3, 3, 0, 3, mConnection.getImeStateForTesting());
|
| - mConnection.setEditableText("tes", 3, 3, 0, 3);
|
| mWrapper.verifyUpdateSelectionCall(2, 3, 3, 0, 3);
|
|
|
| mConnection.setComposingText("test", 1);
|
| assertCorrectState("test", 4, 4, 0, 4, mConnection.getImeStateForTesting());
|
| - mConnection.setEditableText("test", 4, 4, 0, 4);
|
| mWrapper.verifyUpdateSelectionCall(3, 4, 4, 0, 4);
|
| }
|
|
|
| + @MediumTest
|
| + @Feature({"TextInput", "Main"})
|
| + public void testSelectionUpdatesDuringBatch() throws Throwable {
|
| + mConnection.beginBatchEdit();
|
| + mConnection.setComposingText("t", 1);
|
| + assertEquals(0, mWrapper.getUpdateSelectionCallCount());
|
| + mConnection.setComposingText("te", 1);
|
| + assertEquals(0, mWrapper.getUpdateSelectionCallCount());
|
| + mConnection.beginBatchEdit();
|
| + mConnection.setComposingText("tes", 1);
|
| + assertEquals(0, mWrapper.getUpdateSelectionCallCount());
|
| + mConnection.endBatchEdit();
|
| + mConnection.setComposingText("test", 1);
|
| + assertEquals(0, mWrapper.getUpdateSelectionCallCount());
|
| + mConnection.endBatchEdit();
|
| + assertEquals(1, mWrapper.getUpdateSelectionCallCount());
|
| + mWrapper.verifyUpdateSelectionCall(0, 4, 4, 0 ,4);
|
| + }
|
| +
|
| private static class TestImeAdapter extends ImeAdapter {
|
| public TestImeAdapter(InputMethodManagerWrapper wrapper, ImeAdapterDelegate embedder) {
|
| super(wrapper, embedder);
|
| @@ -99,6 +114,10 @@ public class AdapterInputConnectionTest extends ContentShellTestBase {
|
| mUpdates.add(new ImeState("", selStart, selEnd, candidatesStart, candidatesEnd));
|
| }
|
|
|
| + public int getUpdateSelectionCallCount() {
|
| + return mUpdates.size();
|
| + }
|
| +
|
| public void verifyUpdateSelectionCall(int index, int selectionStart, int selectionEnd,
|
| int compositionStart, int compositionEnd) {
|
| ImeState state = mUpdates.get(index);
|
|
|