Index: content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java |
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java b/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java |
index e95e71b9b3adea526501668b7e4f5eed981ce6bd..991b605d19aa56f6781c6887365109f86360eed7 100644 |
--- a/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java |
+++ b/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java |
@@ -27,6 +27,7 @@ import org.chromium.content.browser.test.util.CriteriaHelper; |
import org.chromium.content.browser.test.util.DOMUtils; |
import org.chromium.content.browser.test.util.TestCallbackHelperContainer; |
import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper; |
+import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper.Range; |
import org.chromium.content_public.browser.WebContents; |
import org.chromium.content_shell_apk.ContentShellTestBase; |
@@ -85,7 +86,7 @@ public class ImeTest extends ContentShellTestBase { |
mConnection = (TestAdapterInputConnection) getAdapterInputConnection(); |
mImeAdapter = getImeAdapter(); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
assertEquals(1, mInputMethodManagerWrapper.getShowSoftInputCounter()); |
assertEquals(0, mInputMethodManagerWrapper.getEditorInfo().initialSelStart); |
assertEquals(0, mInputMethodManagerWrapper.getEditorInfo().initialSelEnd); |
@@ -95,11 +96,11 @@ public class ImeTest extends ContentShellTestBase { |
@Feature({"TextInput", "Main"}) |
public void testKeyboardDismissedAfterClickingGo() throws Throwable { |
setComposingText(mConnection, "hello", 1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, 0, 5); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, 0, 5); |
performGo(getAdapterInputConnection(), mCallbackContainer); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "", 0, 0, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 2, "", 0, 0, -1, -1); |
assertWaitForKeyboardStatus(false); |
} |
@@ -108,19 +109,19 @@ public class ImeTest extends ContentShellTestBase { |
@RerunWithUpdatedContainerView |
public void testGetTextUpdatesAfterEnteringText() throws Throwable { |
setComposingText(mConnection, "h", 1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "h", 1, 1, 0, 1); |
+ waitAndVerifyStates(mConnection.mImeUpdateQueue, 1, "h", 1, 1, 0, 1); |
assertEquals(1, mInputMethodManagerWrapper.getShowSoftInputCounter()); |
setComposingText(mConnection, "he", 1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "he", 2, 2, 0, 2); |
+ waitAndVerifyStates(mConnection.mImeUpdateQueue, 2, "he", 2, 2, 0, 2); |
assertEquals(1, mInputMethodManagerWrapper.getShowSoftInputCounter()); |
setComposingText(mConnection, "hel", 1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 3, "hel", 3, 3, 0, 3); |
+ waitAndVerifyStates(mConnection.mImeUpdateQueue, 3, "hel", 3, 3, 0, 3); |
assertEquals(1, mInputMethodManagerWrapper.getShowSoftInputCounter()); |
commitText(mConnection, "hel", 1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 4, "hel", 3, 3, -1, -1); |
+ waitAndVerifyStates(mConnection.mImeUpdateQueue, 4, "hel", 3, 3, -1, -1); |
assertEquals(1, mInputMethodManagerWrapper.getShowSoftInputCounter()); |
} |
@@ -129,10 +130,10 @@ public class ImeTest extends ContentShellTestBase { |
@RerunWithUpdatedContainerView |
public void testImeCopy() throws Exception { |
commitText(mConnection, "hello", 1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, -1, -1); |
+ waitAndVerifyStates(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, -1, -1); |
setSelection(mConnection, 2, 5); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "hello", 2, 5, -1, -1); |
+ waitAndVerifyStates(mConnection.mImeUpdateQueue, 2, "hello", 2, 5, -1, -1); |
copy(mImeAdapter); |
assertClipboardContents(getActivity(), "llo"); |
@@ -142,7 +143,7 @@ public class ImeTest extends ContentShellTestBase { |
@Feature({"TextInput"}) |
public void testEnterTextAndRefocus() throws Exception { |
commitText(mConnection, "hello", 1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, -1, -1); |
DOMUtils.clickNode(this, mContentViewCore, "input_radio"); |
assertWaitForKeyboardStatus(false); |
@@ -157,8 +158,7 @@ public class ImeTest extends ContentShellTestBase { |
@Feature({"TextInput"}) |
public void testKeyboardNotDismissedAfterCopySelection() throws Exception { |
commitText(mConnection, "Sample Text", 1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, |
- "Sample Text", 11, 11, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 1, "Sample Text", 11, 11, -1, -1); |
DOMUtils.clickNode(this, mContentViewCore, "input_text"); |
assertWaitForKeyboardStatus(true); |
DOMUtils.longPressNode(this, mContentViewCore, "input_text"); |
@@ -172,8 +172,7 @@ public class ImeTest extends ContentShellTestBase { |
@Feature({"TextInput"}) |
public void testImeNotDismissedAfterCutSelection() throws Exception { |
commitText(mConnection, "Sample Text", 1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, |
- "Sample Text", 11, 11, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 1, "Sample Text", 11, 11, -1, -1); |
DOMUtils.longPressNode(this, mContentViewCore, "input_text"); |
assertWaitForSelectActionBarStatus(true); |
assertWaitForKeyboardStatus(true); |
@@ -257,13 +256,13 @@ public class ImeTest extends ContentShellTestBase { |
@Feature({"TextInput"}) |
public void testImeCut() throws Exception { |
commitText(mConnection, "snarful", 1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "snarful", 7, 7, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 1, "snarful", 7, 7, -1, -1); |
setSelection(mConnection, 1, 5); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "snarful", 1, 5, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 2, "snarful", 1, 5, -1, -1); |
cut(mImeAdapter); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 3, "sul", 1, 1, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 3, "sul", 1, 1, -1, -1); |
assertClipboardContents(getActivity(), "narf"); |
} |
@@ -282,18 +281,18 @@ public class ImeTest extends ContentShellTestBase { |
}); |
paste(mImeAdapter); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "blarg", 5, 5, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 1, "blarg", 5, 5, -1, -1); |
setSelection(mConnection, 3, 5); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "blarg", 3, 5, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 2, "blarg", 3, 5, -1, -1); |
paste(mImeAdapter); |
// Paste is a two step process when there is a non-zero selection. |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 3, "bla", 3, 3, -1, -1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 4, "blablarg", 8, 8, -1, -1); |
+ waitAndVerifyStates(mConnection.mImeUpdateQueue, 3, "bla", 3, 3, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 4, "blablarg", 8, 8, -1, -1); |
paste(mImeAdapter); |
- waitAndVerifyEditableCallback( |
+ waitAndVerifyStatesAndCalls( |
mConnection.mImeUpdateQueue, 5, "blablargblarg", 13, 13, -1, -1); |
} |
@@ -301,13 +300,13 @@ public class ImeTest extends ContentShellTestBase { |
@Feature({"TextInput"}) |
public void testImeSelectAndUnSelectAll() throws Exception { |
commitText(mConnection, "hello", 1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, -1, -1); |
selectAll(mImeAdapter); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "hello", 0, 5, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 2, "hello", 0, 5, -1, -1); |
unselect(mImeAdapter); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 3, "", 0, 0, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 3, "", 0, 0, -1, -1); |
assertWaitForKeyboardStatus(false); |
} |
@@ -343,25 +342,25 @@ public class ImeTest extends ContentShellTestBase { |
})); |
mConnection = (TestAdapterInputConnection) getAdapterInputConnection(); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
commitText(mConnection, "hllo", 1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hllo", 4, 4, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 1, "hllo", 4, 4, -1, -1); |
commitText(mConnection, " ", 1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "hllo ", 5, 5, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 2, "hllo ", 5, 5, -1, -1); |
setSelection(mConnection, 1, 1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 3, "hllo ", 1, 1, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 3, "hllo ", 1, 1, -1, -1); |
setComposingRegion(mConnection, 0, 4); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 4, "hllo ", 1, 1, 0, 4); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 4, "hllo ", 1, 1, 0, 4); |
finishComposingText(mConnection); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 5, "hllo ", 1, 1, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 5, "hllo ", 1, 1, -1, -1); |
commitText(mConnection, "\n", 1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 6, "h\nllo ", 2, 2, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 6, "h\nllo ", 2, 2, -1, -1); |
} |
private int getTypedKeycodeGuess(String before, String after) { |
@@ -426,7 +425,7 @@ public class ImeTest extends ContentShellTestBase { |
// that the test reflects reality. If this test breaks, it's possible that code has |
// changed and different calls need to be made instead. |
mConnection = (TestAdapterInputConnection) getAdapterInputConnection(); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
// H |
expectUpdateStateCall(mConnection); |
@@ -500,7 +499,7 @@ public class ImeTest extends ContentShellTestBase { |
// that the test reflects reality. If this test breaks, it's possible that code has |
// changed and different calls need to be made instead. |
mConnection = (TestAdapterInputConnection) getAdapterInputConnection(); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
// "three" |
expectUpdateStateCall(mConnection); |
@@ -530,12 +529,47 @@ public class ImeTest extends ContentShellTestBase { |
@SmallTest |
@Feature({"TextInput", "Main"}) |
+ public void testDeleteMultiCharacterCodepoint() throws Throwable { |
+ DOMUtils.focusNode(mWebContents, "textarea"); |
+ assertWaitForKeyboardStatus(true); |
+ |
+ mConnection = (TestAdapterInputConnection) getAdapterInputConnection(); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
+ |
+ // This smiley is a multi character codepoint. |
+ final String smiley = "\uD83D\uDE0A"; |
+ |
+ commitText(mConnection, smiley, 1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 1, smiley, 2, 2, -1, -1); |
+ |
+ // DEL, sent via dispatchKeyEvent like it is in Android WebView or a physical keyboard. |
+ getInstrumentation().runOnMainSync(new Runnable() { |
+ @Override |
+ public void run() { |
+ mContentViewCore.dispatchKeyEvent( |
+ new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)); |
+ mContentViewCore.dispatchKeyEvent( |
+ new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DEL)); |
+ } |
+ }); |
+ |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 2, "", 0, 0, -1, -1); |
+ |
+ // Make sure that we accept further typing after deleting the smiley. |
+ setComposingText(mConnection, "s", 1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 3, "s", 1, 1, 0, 1); |
+ setComposingText(mConnection, "sm", 1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 4, "sm", 2, 2, 0, 2); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput", "Main"}) |
public void testBackspaceKeycode() throws Throwable { |
DOMUtils.focusNode(mWebContents, "textarea"); |
assertWaitForKeyboardStatus(true); |
mConnection = (TestAdapterInputConnection) getAdapterInputConnection(); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
// H |
expectUpdateStateCall(mConnection); |
@@ -578,7 +612,7 @@ public class ImeTest extends ContentShellTestBase { |
assertWaitForKeyboardStatus(true); |
mConnection = (TestAdapterInputConnection) getAdapterInputConnection(); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
// H |
expectUpdateStateCall(mConnection); |
@@ -628,7 +662,7 @@ public class ImeTest extends ContentShellTestBase { |
// key is touched on screen. Exercise care when altering to make sure that the test |
// reflects reality. |
mConnection = (TestAdapterInputConnection) getAdapterInputConnection(); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
// H |
expectUpdateStateCall(mConnection); |
@@ -707,7 +741,7 @@ public class ImeTest extends ContentShellTestBase { |
assertWaitForKeyboardStatus(true); |
mConnection = (TestAdapterInputConnection) getAdapterInputConnection(); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
// h |
dispatchKeyEvent(mConnection, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_H)); |
@@ -787,7 +821,7 @@ public class ImeTest extends ContentShellTestBase { |
assertWaitForKeyboardStatus(true); |
mConnection = (TestAdapterInputConnection) getAdapterInputConnection(); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
setComposingText(mConnection, "hello", 1); |
setComposingRegion(mConnection, 0, 0); |
@@ -814,10 +848,10 @@ public class ImeTest extends ContentShellTestBase { |
})); |
mConnection = (TestAdapterInputConnection) getAdapterInputConnection(); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
setComposingText(mConnection, "hello", 1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, 0, 5); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, 0, 5); |
getInstrumentation().runOnMainSync(new Runnable() { |
@Override |
@@ -829,10 +863,13 @@ public class ImeTest extends ContentShellTestBase { |
}); |
// TODO(aurimas): remove this workaround when crbug.com/278584 is fixed. |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "hello", 5, 5, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 2, "hello", 5, 5, -1, -1); |
// The second new line is not a user visible/editable one, it is a side-effect of Blink |
// using <br> internally. |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 3, "hello\n\n", 6, 6, -1, -1); |
+ // TODO(changwan): [ 6, 6 ] is different from what we report to |
+ // InputMethodManager#updateSelection(). |
+ // Uncomment this once it's fixed. |
+ waitAndVerifyStates(mConnection.mImeUpdateQueue, 3, "hello\n\n", 6, 6, -1, -1); |
} |
@SmallTest |
@@ -842,7 +879,7 @@ public class ImeTest extends ContentShellTestBase { |
assertWaitForKeyboardStatus(true); |
mConnection = (TestAdapterInputConnection) getAdapterInputConnection(); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
// DPAD_CENTER should cause keyboard to appear |
expectUpdateStateCall(mConnection); |
@@ -858,7 +895,7 @@ public class ImeTest extends ContentShellTestBase { |
assertWaitForKeyboardStatus(true); |
mConnection = (TestAdapterInputConnection) getAdapterInputConnection(); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
// H |
// Since autocomplete="on" by default, COMPOSITION_KEY_CODE is emitted as key code |
@@ -882,7 +919,7 @@ public class ImeTest extends ContentShellTestBase { |
assertWaitForKeyboardStatus(true); |
mConnection = (TestAdapterInputConnection) getAdapterInputConnection(); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
// H |
// Although autocomplete="off", we still emit COMPOSITION_KEY_CODE since synthesized |
@@ -904,13 +941,13 @@ public class ImeTest extends ContentShellTestBase { |
@Feature({"TextInput"}) |
public void testPastePopupShowOnLongPress() throws Throwable { |
commitText(mConnection, "hello", 1); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, -1, -1); |
selectAll(mImeAdapter); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "hello", 0, 5, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 2, "hello", 0, 5, -1, -1); |
cut(mImeAdapter); |
- waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
+ waitAndVerifyStatesAndCalls(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
DOMUtils.longPressNode(this, mContentViewCore, "input_text"); |
final PastePopupMenu pastePopup = mContentViewCore.getPastePopupForTest(); |
@@ -974,9 +1011,11 @@ public class ImeTest extends ContentShellTestBase { |
})); |
} |
- private void waitAndVerifyEditableCallback(final ArrayList<TestImeState> states, |
- final int index, String text, int selectionStart, int selectionEnd, |
- int compositionStart, int compositionEnd) throws InterruptedException { |
+ // TODO(changwan): replace calls to this by waitAndVerifyStatesAndCalls once |
+ // we figure out why updateSelection is called with incorrect values. |
+ private void waitAndVerifyStates(final ArrayList<TestImeState> states, final int index, |
+ String text, final int selectionStart, final int selectionEnd, |
+ final int compositionStart, final int compositionEnd) throws InterruptedException { |
assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { |
@Override |
public boolean isSatisfied() { |
@@ -987,6 +1026,27 @@ public class ImeTest extends ContentShellTestBase { |
text, selectionStart, selectionEnd, compositionStart, compositionEnd); |
} |
+ private void waitAndVerifyStatesAndCalls(final ArrayList<TestImeState> states, final int index, |
+ String text, final int selectionStart, final int selectionEnd, |
+ final int compositionStart, final int compositionEnd) throws InterruptedException { |
+ waitAndVerifyStates(states, index, text, selectionStart, selectionEnd, compositionStart, |
+ compositionEnd); |
+ |
+ // Wait and verify calls to InputMethodManager. |
+ final Range selection = new Range(selectionStart, selectionEnd); |
+ final Range composition = new Range(compositionStart, compositionEnd); |
+ assertTrue("Actual selection was: " + mInputMethodManagerWrapper.getSelection() |
+ + ", and actual composition was: " |
+ + mInputMethodManagerWrapper.getComposition(), |
+ CriteriaHelper.pollForCriteria(new Criteria() { |
+ @Override |
+ public boolean isSatisfied() { |
+ return mInputMethodManagerWrapper.getSelection().equals(selection) |
+ && mInputMethodManagerWrapper.getComposition().equals(composition); |
+ } |
+ })); |
+ } |
+ |
private void expectUpdateStateCall(final TestAdapterInputConnection connection) { |
connection.mImeUpdateQueue.clear(); |
} |