| 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 3bcbb37222bff9aaa5a7178398164eb00cadc172..0337e7645f72cb413b8885ce6791939af0c1fe33 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
|
| @@ -20,9 +20,6 @@ import android.view.KeyCharacterMap;
|
| import android.view.View;
|
| import android.view.inputmethod.InputMethodManager;
|
|
|
| -import org.chromium.base.ThreadUtils;
|
| -import org.chromium.base.test.util.Feature;
|
| -import org.chromium.testing.local.LocalRobolectricTestRunner;
|
| import org.junit.Before;
|
| import org.junit.Ignore;
|
| import org.junit.Test;
|
| @@ -33,6 +30,10 @@ import org.mockito.Mockito;
|
| import org.mockito.MockitoAnnotations;
|
| import org.robolectric.annotation.Config;
|
|
|
| +import org.chromium.base.ThreadUtils;
|
| +import org.chromium.base.test.util.Feature;
|
| +import org.chromium.testing.local.LocalRobolectricTestRunner;
|
| +
|
| import java.util.concurrent.Callable;
|
|
|
| /**
|
| @@ -41,13 +42,14 @@ import java.util.concurrent.Callable;
|
| @RunWith(LocalRobolectricTestRunner.class)
|
| @Config(manifest = Config.NONE)
|
| public class ThreadedInputConnectionTest {
|
| - @Mock ImeAdapter mImeAdapter;
|
| + @Mock
|
| + private ImeAdapter mImeAdapter;
|
|
|
| - ThreadedInputConnection mConnection;
|
| - InOrder mInOrder;
|
| - View mView;
|
| - Context mContext;
|
| - boolean mRunningOnUiThread;
|
| + private ThreadedInputConnection mConnection;
|
| + private InOrder mInOrder;
|
| + private View mView;
|
| + private Context mContext;
|
| + private boolean mRunningOnUiThread;
|
|
|
| @Before
|
| public void setUp() throws Exception {
|
| @@ -197,7 +199,7 @@ public class ThreadedInputConnectionTest {
|
|
|
| // State update for endBatchEdit.
|
| mConnection.updateStateOnUiThread(
|
| - "", 0, 0, -1, -1, true, false /* isNonImeChange */, false /* batchEdit */);
|
| + "", 0, 0, -1, -1, true, true /* isNonImeChange */, false /* batchEdit */);
|
| // State update for commitText.
|
| mConnection.updateStateOnUiThread(
|
| "hello", 5, 5, -1, -1, true, true, false /* batchEdit */);
|
| @@ -212,6 +214,33 @@ public class ThreadedInputConnectionTest {
|
|
|
| @Test
|
| @Feature({"TextInput"})
|
| + public void testBatchEdit_getTextAfterBatchEditStillUpdateSelection() {
|
| + assertTrue(mConnection.beginBatchEdit());
|
| + assertTrue(mConnection.commitText("hello", 1));
|
| + assertFalse(mConnection.endBatchEdit());
|
| +
|
| + // commitText: This change gets ignored.
|
| + mConnection.updateStateOnUiThread("hello", 5, 5, -1, -1, true, true, true /* batchEdit */);
|
| +
|
| + // endBatchEdit: RenderWidget force-updates selection.
|
| + mConnection.updateStateOnUiThread("hello", 5, 5, -1, -1, true, true, false /* batchEdit */);
|
| +
|
| + // getTextBeforeCursor.
|
| + mConnection.updateStateOnUiThread("hello", 5, 5, -1, -1, true, false, false);
|
| + when(mImeAdapter.requestTextInputStateUpdate()).thenReturn(true);
|
| + assertEquals("hello", mConnection.getTextBeforeCursor(20, 0));
|
| +
|
| + mInOrder.verify(mImeAdapter).beginBatchEdit();
|
| + mInOrder.verify(mImeAdapter).sendCompositionToNative("hello", 1, true, 0);
|
| + mInOrder.verify(mImeAdapter).endBatchEdit();
|
| + mInOrder.verify(mImeAdapter).updateSelection(5, 5, -1, -1);
|
| + mInOrder.verify(mImeAdapter).requestTextInputStateUpdate();
|
| + mInOrder.verifyNoMoreInteractions();
|
| + assertEquals(0, mConnection.getQueueForTest().size());
|
| + }
|
| +
|
| + @Test
|
| + @Feature({"TextInput"})
|
| @Ignore("crbug/632792")
|
| public void testFailToRequestToRenderer() {
|
| when(mImeAdapter.requestTextInputStateUpdate()).thenReturn(false);
|
|
|