| Index: content/public/android/junit/src/org/chromium/content/browser/input/ThreadedInputConnectionTest.java
|
| diff --git a/content/public/android/junit/src/org/chromium/content/browser/input/ThreadedInputConnectionTest.java b/content/public/android/junit/src/org/chromium/content/browser/input/ThreadedInputConnectionTest.java
|
| index 124e3259f300fd0b7d7993d50870ee54bdd92f72..ff0853048f81b9acdf27bba1e79560f149532a29 100644
|
| --- a/content/public/android/junit/src/org/chromium/content/browser/input/ThreadedInputConnectionTest.java
|
| +++ b/content/public/android/junit/src/org/chromium/content/browser/input/ThreadedInputConnectionTest.java
|
| @@ -122,15 +122,28 @@ public class ThreadedInputConnectionTest {
|
| @Test
|
| @Feature({"TextInput"})
|
| public void testBatchEdit() {
|
| + // Type 'hello' real fast.
|
| + assertTrue(mConnection.commitText("hello ", 1));
|
| + mInOrder.verify(mImeAdapter).sendCompositionToNative("hello ", 1, true, 0);
|
| +
|
| + // Prepare to call beginBatchEdit().
|
| + mConnection.updateStateOnUiThread("hello ", 6, 6, -1, -1, true, false);
|
| + assertEquals(1, mConnection.getQueueForTest().size());
|
| + when(mImeAdapter.requestTextInputStateUpdate()).thenReturn(true);
|
| +
|
| // IME app calls beginBatchEdit().
|
| assertTrue(mConnection.beginBatchEdit());
|
| - // Type hello real fast.
|
| - mConnection.commitText("hello", 1);
|
| - mInOrder.verify(mImeAdapter).sendCompositionToNative("hello", 1, true, 0);
|
| + // Type 'world' real fast.
|
| + assertTrue(mConnection.commitText("world", 1));
|
| +
|
| + // 'hello ' is called before beginBatchEdit(), so we still need to update it.
|
| + mInOrder.verify(mImeAdapter).updateSelection(6, 6, -1, -1);
|
| + mInOrder.verify(mImeAdapter).sendCompositionToNative("world", 1, true, 0);
|
|
|
| // Renderer updates states asynchronously.
|
| - mConnection.updateStateOnUiThread("hello", 5, 5, -1, -1, true, true);
|
| - mInOrder.verify(mImeAdapter, never()).updateSelection(5, 5, -1, -1);
|
| + mConnection.updateStateOnUiThread(
|
| + "world", 11, 11, -1, -1, true, true);
|
| + mInOrder.verify(mImeAdapter, never()).updateSelection(11, 11, -1, -1);
|
| assertEquals(0, mConnection.getQueueForTest().size());
|
|
|
| {
|
| @@ -140,10 +153,14 @@ public class ThreadedInputConnectionTest {
|
| mConnection.setSelection(4, 4);
|
| assertTrue(mConnection.endBatchEdit());
|
| }
|
| + mInOrder.verify(mImeAdapter).setEditableSelectionOffsets(4, 4);
|
| + // Renderer updates state for setSelection().
|
| + mConnection.updateStateOnUiThread("hello", 4, 4, -1, -1, true, true);
|
| +
|
| // We still have one outer batch edit, so should not update selection yet.
|
| mInOrder.verify(mImeAdapter, never()).updateSelection(4, 4, -1, -1);
|
|
|
| - // Prepare to call requestTextInputStateUpdate.
|
| + // Prepare to call endBatchEdit().
|
| mConnection.updateStateOnUiThread("hello", 4, 4, -1, -1, true, false);
|
| assertEquals(1, mConnection.getQueueForTest().size());
|
| when(mImeAdapter.requestTextInputStateUpdate()).thenReturn(true);
|
|
|