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

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

Issue 759033002: Handle accent keys from physical keyboards. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed review comments and moved common dead-key code to public static method Created 6 years 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
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698