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

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

Issue 2948593002: Relanding [Android] Adding Smart GO/NEXT feature in Chrome (Closed)
Patch Set: Rebased the patch Created 3 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
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 3d35612dd6f2eca19117c119ac9c5a959a9c2557..e6052cedc898ee810078b257c6812f38087fa56b 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
@@ -31,6 +31,7 @@ import org.chromium.content.browser.test.util.DOMUtils;
import org.chromium.content.browser.test.util.JavaScriptUtils;
import org.chromium.ui.base.ime.TextInputType;
+import java.util.ArrayList;
import java.util.concurrent.Callable;
/**
@@ -421,6 +422,69 @@ public class ImeTest {
Assert.assertEquals(5, mRule.getConnectionFactory().getOutAttrs().initialSelEnd);
}
+ private static int getImeAction(EditorInfo editorInfo) {
+ return editorInfo.imeOptions & EditorInfo.IME_MASK_ACTION;
+ }
+
+ @Test
+ @SmallTest
+ @Feature({"TextInput", "Main"})
+ public void testAdvanceFocusNextAndPrevious() throws Exception {
+ mRule.focusElement("textarea");
+ // Forward direction focus. Excessive focus advance should be ignored.
+ for (int i = 0; i < 10; ++i) {
+ // Forward direction focus.
+ mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT);
+ }
+ mRule.waitForKeyboardStates(7, 0, 7,
+ new Integer[] {TextInputType.TEXT_AREA, TextInputType.TEXT_AREA,
+ TextInputType.NUMBER, TextInputType.NUMBER, TextInputType.CONTENT_EDITABLE,
+ TextInputType.SEARCH, TextInputType.TEXT});
+ ArrayList<EditorInfo> editorInfoList =
+ mRule.getInputMethodManagerWrapper().getEditorInfoList();
+ Assert.assertEquals(7, editorInfoList.size());
+ // textarea.
+ Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeAction(editorInfoList.get(0)));
+ // textarea2.
+ Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeAction(editorInfoList.get(1)));
+ // input_number1.
+ Assert.assertEquals(EditorInfo.IME_ACTION_NEXT, getImeAction(editorInfoList.get(2)));
+ // input_number2.
+ Assert.assertEquals(EditorInfo.IME_ACTION_NEXT, getImeAction(editorInfoList.get(3)));
+ // content_editable1.
+ Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeAction(editorInfoList.get(4)));
+ // search1.
+ Assert.assertEquals(EditorInfo.IME_ACTION_SEARCH, getImeAction(editorInfoList.get(5)));
+ // input_text1.
+ Assert.assertEquals(EditorInfo.IME_ACTION_GO, getImeAction(editorInfoList.get(6)));
+
+ mRule.resetAllStates();
+
+ // Backward direction focus. Excessive focus advance should be ignored.
+ for (int i = 0; i < 10; ++i) {
+ // Backward direction focus.
+ mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS);
+ }
+ mRule.waitForKeyboardStates(6, 0, 6,
+ new Integer[] {TextInputType.SEARCH, TextInputType.CONTENT_EDITABLE,
+ TextInputType.NUMBER, TextInputType.NUMBER, TextInputType.TEXT_AREA,
+ TextInputType.TEXT_AREA});
+ editorInfoList = mRule.getInputMethodManagerWrapper().getEditorInfoList();
+ Assert.assertEquals(6, editorInfoList.size());
+ // search1.
+ Assert.assertEquals(EditorInfo.IME_ACTION_SEARCH, getImeAction(editorInfoList.get(0)));
+ // content_editable1.
+ Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeAction(editorInfoList.get(1)));
+ // input_number2.
+ Assert.assertEquals(EditorInfo.IME_ACTION_NEXT, getImeAction(editorInfoList.get(2)));
+ // input_number1.
+ Assert.assertEquals(EditorInfo.IME_ACTION_NEXT, getImeAction(editorInfoList.get(3)));
+ // textarea2.
+ Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeAction(editorInfoList.get(4)));
+ // textarea.
+ Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeAction(editorInfoList.get(5)));
+ }
+
@Test
@SmallTest
@Feature({"TextInput"})

Powered by Google App Engine
This is Rietveld 408576698