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

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

Issue 1137673005: Deal with backspace keycodes getting sent by IME during compositions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add another test for repeat keydowns Created 5 years, 7 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/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 d1a21d26565608391b5c25db9e5ae2636fffe64b..fd3b975b9fe7d73d22f96214d42ec609a1673855 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
@@ -521,6 +521,96 @@ public class ImeTest extends ContentShellTestBase {
@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);
+
+ // H
+ expectUpdateStateCall(mConnection);
+ commitText(mConnection, "h", 1);
+ assertEquals(KeyEvent.KEYCODE_H, mImeAdapter.mLastSyntheticKeyCode);
+ assertEquals("h", mConnection.getTextBeforeCursor(9, 0));
+ assertUpdateStateCall(mConnection, 1000);
+ assertEquals("h", mConnection.getTextBeforeCursor(9, 0));
+
+ // O
+ expectUpdateStateCall(mConnection);
+ commitText(mConnection, "o", 1);
+ assertEquals(KeyEvent.KEYCODE_O, mImeAdapter.mLastSyntheticKeyCode);
+ assertEquals("ho", mConnection.getTextBeforeCursor(9, 0));
+ assertUpdateStateCall(mConnection, 1000);
+ assertEquals("ho", mConnection.getTextBeforeCursor(9, 0));
+
+ // 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));
+ }
+ });
+
+ // DEL
+ expectUpdateStateCall(mConnection);
+ assertEquals("h", mConnection.getTextBeforeCursor(9, 0));
+ assertUpdateStateCall(mConnection, 1000);
+ assertEquals("h", mConnection.getTextBeforeCursor(9, 0));
+ }
+
+ @SmallTest
+ @Feature({"TextInput", "Main"})
+ public void testRepeatBackspaceKeycode() throws Throwable {
+ DOMUtils.focusNode(mWebContents, "textarea");
+ assertWaitForKeyboardStatus(true);
+
+ mConnection = (TestAdapterInputConnection) getAdapterInputConnection();
+ waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 0, "", 0, 0, -1, -1);
+
+ // H
+ expectUpdateStateCall(mConnection);
+ commitText(mConnection, "h", 1);
+ assertEquals(KeyEvent.KEYCODE_H, mImeAdapter.mLastSyntheticKeyCode);
+ assertEquals("h", mConnection.getTextBeforeCursor(9, 0));
+ assertUpdateStateCall(mConnection, 1000);
+ assertEquals("h", mConnection.getTextBeforeCursor(9, 0));
+
+ // O
+ expectUpdateStateCall(mConnection);
+ commitText(mConnection, "o", 1);
+ assertEquals(KeyEvent.KEYCODE_O, mImeAdapter.mLastSyntheticKeyCode);
+ assertEquals("ho", mConnection.getTextBeforeCursor(9, 0));
+ assertUpdateStateCall(mConnection, 1000);
+ assertEquals("ho", mConnection.getTextBeforeCursor(9, 0));
+
+ // Multiple keydowns should each delete one character (this is for physical keyboard
+ // key-repeat).
+ getInstrumentation().runOnMainSync(new Runnable() {
+ @Override
+ public void run() {
+ mContentViewCore.dispatchKeyEvent(
+ new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
+ mContentViewCore.dispatchKeyEvent(
+ new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
+ mContentViewCore.dispatchKeyEvent(
+ new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DEL));
+ }
+ });
+
+ // DEL
+ expectUpdateStateCall(mConnection);
+ assertEquals("", mConnection.getTextBeforeCursor(9, 0));
+ assertUpdateStateCall(mConnection, 1000);
+ assertEquals("", mConnection.getTextBeforeCursor(9, 0));
+ }
+
+
+ @SmallTest
+ @Feature({"TextInput", "Main"})
public void testKeyCodesWhileTypingText() throws Throwable {
DOMUtils.focusNode(mWebContents, "textarea");
assertWaitForKeyboardStatus(true);
« 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