Commit 4909fb1c authored by huangs's avatar huangs Committed by Commit bot

[IME] Use proper const in ImeAdaptor for autocomplete, updating tests.

This is a follow-up clean up to
https://chromiumcodereview.appspot.com/842493004/
so we can:
- Use the appropriate constant to detect autocomplete="off".
- Add test case for autocomplete="off" (returns key code rather than 229).

Review URL: https://codereview.chromium.org/848223003

Cr-Commit-Position: refs/heads/master@{#311773}
parent 6718114f
......@@ -426,13 +426,9 @@ public class ImeAdapter {
KeyEvent.changeAction(keyEvent, KeyEvent.ACTION_UP), 0);
}
// FIXME: Use WebTextInputFlags.AutocompleteOff. We need this hack to enable merge into
// into Beta to fix http://crbug.com/422685 .
final int textInputFlagAutocompleteOff = 1 << 1;
// If we do not have autocomplete=off, then always send compose events rather than a
// guessed keyCode. This addresses http://crbug.com/422685 .
if ((mTextInputFlags & textInputFlagAutocompleteOff) == 0) {
if ((mTextInputFlags & WebTextInputFlags.AutocompleteOff) == 0) {
keyCode = COMPOSITION_KEY_CODE;
modifiers = 0;
}
......
......@@ -45,6 +45,8 @@ public class ImeTest extends ContentShellTestBase {
+ "<input id=\"input_text\" type=\"text\" /><br/>"
+ "<input id=\"input_radio\" type=\"radio\" style=\"width:50px;height:50px\" />"
+ "<br/><textarea id=\"textarea\" rows=\"4\" cols=\"20\"></textarea>"
+ "<br/><textarea id=\"textarea2\" rows=\"4\" cols=\"20\" autocomplete=\"off\">"
+ "</textarea>"
+ "<br/><p><span id=\"plain_text\">This is Plain Text One</span></p>"
+ "</form></body></html>");
private static final int COMPOSITION_KEY_CODE = 229;
......@@ -700,13 +702,14 @@ public class ImeTest extends ContentShellTestBase {
@SmallTest
@Feature({"TextInput", "Main"})
public void testTransitionsWhileComposingText() throws Throwable {
DOMUtils.focusNode(mWebContents, "textarea");
DOMUtils.focusNode(mWebContents, "textarea"); // Default with autocomplete="on"
assertWaitForKeyboardStatus(true);
mConnection = (TestAdapterInputConnection) getAdapterInputConnection();
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1);
// H
// Since autocomplete="on" by default, COMPOSITION_KEY_CODE is emitted as key code
expectUpdateStateCall(mConnection);
setComposingText(mConnection, "h", 1);
assertEquals(COMPOSITION_KEY_CODE, mImeAdapter.mLastSyntheticKeyCode);
......@@ -720,6 +723,30 @@ public class ImeTest extends ContentShellTestBase {
assertEquals(COMPOSITION_KEY_CODE, mImeAdapter.mLastSyntheticKeyCode);
}
@SmallTest
@Feature({"TextInput", "Main"})
public void testTransitionsWhileEmittingKeyCode() throws Throwable {
DOMUtils.focusNode(mWebContents, "textarea2"); // autocomplete="off"
assertWaitForKeyboardStatus(true);
mConnection = (TestAdapterInputConnection) getAdapterInputConnection();
waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1);
// H
// Since autocomplete="off", regular key codes are emitted.
expectUpdateStateCall(mConnection);
setComposingText(mConnection, "h", 1);
assertEquals(KeyEvent.KEYCODE_H, mImeAdapter.mLastSyntheticKeyCode);
// Simulate switch of input fields.
finishComposingText(mConnection);
// H
expectUpdateStateCall(mConnection);
setComposingText(mConnection, "h", 1);
assertEquals(KeyEvent.KEYCODE_H, mImeAdapter.mLastSyntheticKeyCode);
}
@SmallTest
@Feature({"TextInput"})
public void testPastePopupShowOnLongPress() throws Throwable {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment