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

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/input/AdapterInputConnectionTest.java

Issue 24195023: Switch to sending IME selection updates early. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ted's nits Created 7 years, 3 months 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/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);

Powered by Google App Engine
This is Rietveld 408576698