Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1581)

Unified Diff: content/public/android/junit/src/org/chromium/content/browser/input/ThreadedInputConnectionTest.java

Issue 2464023002: Fix endBatchEdit
Patch Set: fix testBatchEdit_NoOp Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698