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 1d84ac65dca28fcee245d7956d42b561ded01f35..73329f66461245797a6d3fd6ea33437248ace5b1 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 |
@@ -591,6 +591,45 @@ public class ImeTest extends ContentShellTestBase { |
@SmallTest |
@Feature({"TextInput", "Main"}) |
+ public void testAccentKeyCodesFromPhysicalKeyboard() throws Throwable { |
+ DOMUtils.focusNode(mWebContents, "textarea"); |
+ assertWaitForKeyboardStatus(true); |
+ |
+ // The calls below are a reflection of what a physical keyboard sends when the noted |
+ // key is pressed on the device. Exercise care when altering to make sure that the test |
+ // reflects reality. |
+ mConnection = (TestAdapterInputConnection) getAdapterInputConnection(); |
+ waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1); |
+ |
+ // H |
+ dispatchKeyEvent(mConnection, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_H)); |
+ dispatchKeyEvent(mConnection, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_H)); |
+ assertEquals("h", mConnection.getTextBeforeCursor(9, 0)); |
+ |
+ // I |
+ dispatchKeyEvent(mConnection, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_I)); |
+ dispatchKeyEvent(mConnection, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_I)); |
+ assertEquals("hi", mConnection.getTextBeforeCursor(9, 0)); |
+ |
+ // ALT-I (circomflex accent key on virtual keyboard) |
+ dispatchKeyEvent( |
+ mConnection, new KeyEvent( |
+ 0, 0, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_I, 0, KeyEvent.META_ALT_ON)); |
+ dispatchKeyEvent( |
+ mConnection, new KeyEvent( |
+ 0, 0, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_I, 0, KeyEvent.META_ALT_ON)); |
+ assertEquals("hiˆ", mConnection.getTextBeforeCursor(9, 0)); |
+ |
+ // O (accented key) |
+ dispatchKeyEvent(mConnection, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_O)); |
+ assertUpdateStateCall(mConnection, 1000); |
+ assertEquals("hi", mConnection.getTextBeforeCursor(9, 0)); |
+ dispatchKeyEvent(mConnection, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_O)); |
+ assertEquals("hiô", mConnection.getTextBeforeCursor(9, 0)); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput", "Main"}) |
public void testSetComposingRegionOutOfBounds() throws Throwable { |
DOMUtils.focusNode(mWebContents, "textarea"); |
assertWaitForKeyboardStatus(true); |
@@ -909,6 +948,15 @@ public class ImeTest extends ContentShellTestBase { |
}); |
} |
+ private void dispatchKeyEvent(final AdapterInputConnection connection, final KeyEvent event) { |
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
+ @Override |
+ public void run() { |
+ mImeAdapter.dispatchKeyEvent(event); |
+ } |
+ }); |
+ } |
+ |
private static class TestAdapterInputConnectionFactory extends |
ImeAdapter.AdapterInputConnectionFactory { |
@Override |