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

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

Issue 2681833006: [Android] Restart input only once on focus change (Closed)
Patch Set: fixed nit Created 3 years, 10 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
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 aaebaf706396315786396a0836c1e3d1334bc514..e95a5233cb3d9e7ffb6ffc50a68675a053390046 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
@@ -492,16 +492,45 @@ public class ImeTest extends ContentShellTestBase {
focusElement("input_text");
// showSoftInput() on input_text. restartInput() on input_number1 due to focus change,
// and restartInput() on input_text later.
- // TODO(changwan): reduce unnecessary restart input.
- waitForKeyboardStates(3, 1, 5, new Integer[] {
- TextInputType.NUMBER, TextInputType.NUMBER, TextInputType.NUMBER,
- TextInputType.TEXT});
+ waitForKeyboardStates(3, 1, 4,
+ new Integer[] {TextInputType.NUMBER, TextInputType.NUMBER, TextInputType.TEXT});
+
+ resetUpdateSelectionList();
+ setComposingText("a", 1);
+ waitAndVerifyUpdateSelection(0, 1, 1, 0, 1);
+ resetUpdateSelectionList();
+
+ // JavaScript changes focus.
+ String code = "(function() { "
+ + "var textarea = document.getElementById('textarea');"
+ + "textarea.focus();"
+ + "})();";
+ JavaScriptUtils.executeJavaScriptAndWaitForResult(
+ getContentViewCore().getWebContents(), code);
+ waitAndVerifyUpdateSelection(0, 0, 0, -1, -1);
+ resetUpdateSelectionList();
+
+ waitForKeyboardStates(4, 1, 5, new Integer[] {
+ TextInputType.NUMBER, TextInputType.NUMBER, TextInputType.TEXT,
+ TextInputType.TEXT_AREA});
+ assertEquals(0, mConnectionFactory.getOutAttrs().initialSelStart);
+ assertEquals(0, mConnectionFactory.getOutAttrs().initialSelEnd);
+
+ setComposingText("aa", 1);
+ waitAndVerifyUpdateSelection(0, 2, 2, 0, 2);
+
+ focusElement("input_text");
+ waitForKeyboardStates(5, 1, 6, new Integer[] {
+ TextInputType.NUMBER, TextInputType.NUMBER, TextInputType.TEXT,
+ TextInputType.TEXT_AREA, TextInputType.TEXT});
+ assertEquals(1, mConnectionFactory.getOutAttrs().initialSelStart);
+ assertEquals(1, mConnectionFactory.getOutAttrs().initialSelEnd);
focusElement("input_radio", false);
// hideSoftInput(), restartInput()
- waitForKeyboardStates(3, 2, 6, new Integer[] {
- TextInputType.NUMBER, TextInputType.NUMBER, TextInputType.NUMBER,
- TextInputType.TEXT});
+ waitForKeyboardStates(5, 2, 7, new Integer[] {
+ TextInputType.NUMBER, TextInputType.NUMBER, TextInputType.TEXT,
+ TextInputType.TEXT_AREA, TextInputType.TEXT});
}
private void assertTextsAroundCursor(
@@ -1780,6 +1809,7 @@ public class ImeTest extends ContentShellTestBase {
*/
private void focusElementAndWaitForStateUpdate(String id)
throws InterruptedException, TimeoutException {
+ resetUpdateSelectionList();
focusElement(id);
waitAndVerifyUpdateSelection(0, 0, 0, -1, -1);
resetUpdateSelectionList();

Powered by Google App Engine
This is Rietveld 408576698