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

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

Issue 1162863007: Translate physical keyboard accents to IME compositions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move mPendingAccent = 0 before finishComposingText early return Created 5 years, 6 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
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/input/AdapterInputConnection.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 8484bd95b9213ffe12c5c9d9eee9750aedf0eacc..e95e71b9b3adea526501668b7e4f5eed981ce6bd 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
@@ -702,6 +702,86 @@ public class ImeTest extends ContentShellTestBase {
@SmallTest
@Feature({"TextInput", "Main"})
+ public void testAccentKeyCodesFromPhysicalKeyboard() throws Throwable {
+ DOMUtils.focusNode(mWebContents, "textarea");
+ assertWaitForKeyboardStatus(true);
+
+ 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));
+
+ // ALT-i (circumflex accent key on virtual keyboard)
+ dispatchKeyEvent(
+ mConnection, new KeyEvent(
+ 0, 0, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_I, 0, KeyEvent.META_ALT_ON));
+ assertUpdateStateCall(mConnection, 1000);
+ assertEquals("hˆ", mConnection.getTextBeforeCursor(9, 0));
+ dispatchKeyEvent(
+ mConnection, new KeyEvent(
+ 0, 0, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_I, 0, KeyEvent.META_ALT_ON));
+ assertEquals("hˆ", mConnection.getTextBeforeCursor(9, 0));
+
+ // o
+ dispatchKeyEvent(mConnection, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_O));
+ assertUpdateStateCall(mConnection, 1000);
+ assertEquals("hô", mConnection.getTextBeforeCursor(9, 0));
+ dispatchKeyEvent(mConnection, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_O));
+ assertEquals("hô", mConnection.getTextBeforeCursor(9, 0));
+ assertEquals(-1, mConnection.getComposingSpanEnd(mConnection.getEditable()));
+
+ // ALT-i
+ dispatchKeyEvent(
+ mConnection, new KeyEvent(
+ 0, 0, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_I, 0, KeyEvent.META_ALT_ON));
+ assertUpdateStateCall(mConnection, 1000);
+ dispatchKeyEvent(
+ mConnection, new KeyEvent(
+ 0, 0, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_I, 0, KeyEvent.META_ALT_ON));
+ assertEquals("hôˆ", mConnection.getTextBeforeCursor(9, 0));
+
+ // ALT-i again should have no effect
+ dispatchKeyEvent(
+ mConnection, new KeyEvent(
+ 0, 0, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_I, 0, KeyEvent.META_ALT_ON));
+ assertUpdateStateCall(mConnection, 1000);
+ dispatchKeyEvent(
+ mConnection, new KeyEvent(
+ 0, 0, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_I, 0, KeyEvent.META_ALT_ON));
+ assertEquals("hôˆ", mConnection.getTextBeforeCursor(9, 0));
+
+ // b (cannot be accented, should just appear after)
+ dispatchKeyEvent(mConnection, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_B));
+ assertUpdateStateCall(mConnection, 1000);
+ assertEquals("hôˆb", mConnection.getTextBeforeCursor(9, 0));
+ dispatchKeyEvent(mConnection, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_B));
+ assertEquals("hôˆb", mConnection.getTextBeforeCursor(9, 0));
+ assertEquals(-1, mConnection.getComposingSpanEnd(mConnection.getEditable()));
+
+ // ALT-i
+ dispatchKeyEvent(
+ mConnection, new KeyEvent(
+ 0, 0, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_I, 0, KeyEvent.META_ALT_ON));
+ assertUpdateStateCall(mConnection, 1000);
+ dispatchKeyEvent(
+ mConnection, new KeyEvent(
+ 0, 0, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_I, 0, KeyEvent.META_ALT_ON));
+ assertEquals("hôˆbˆ", mConnection.getTextBeforeCursor(9, 0));
+
+ // Backspace
+ dispatchKeyEvent(mConnection, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
+ assertUpdateStateCall(mConnection, 1000);
+ assertEquals("hôˆb", mConnection.getTextBeforeCursor(9, 0));
+ dispatchKeyEvent(mConnection, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DEL));
+ assertEquals("hôˆb", mConnection.getTextBeforeCursor(9, 0));
+ assertEquals(-1, mConnection.getComposingSpanEnd(mConnection.getEditable()));
+ }
+
+ @SmallTest
+ @Feature({"TextInput", "Main"})
public void testSetComposingRegionOutOfBounds() throws Throwable {
DOMUtils.focusNode(mWebContents, "textarea");
assertWaitForKeyboardStatus(true);
@@ -1056,6 +1136,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/AdapterInputConnection.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698