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 edf7101d03a303cd8b575a15d08d6ac4c4517249..886d3a9a83ab98b4826ec3fa382b0d660bc00715 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 |
@@ -416,6 +416,60 @@ public class ImeTest { |
Assert.assertEquals(5, mRule.getConnectionFactory().getOutAttrs().initialSelEnd); |
} |
+ private int getImeActions() { |
Changwan Ryu
2017/05/11 22:57:13
private static int getImeAction(EditorInfo editorI
AKVT
2017/05/12 13:26:25
Done.
|
+ return mRule.getInputMethodManagerWrapper().getImeOptions() & EditorInfo.IME_MASK_ACTION; |
+ } |
+ |
+ private int getInputType() { |
Changwan Ryu
2017/05/11 22:57:13
remove
AKVT
2017/05/12 13:26:25
Done.
|
+ return mRule.getInputMethodManagerWrapper().getInputType(); |
+ } |
+ |
+ @Test |
+ @SmallTest |
+ @Feature({"TextInput", "Main"}) |
+ public void testAdvanceFocusNextAndPrevious() throws Exception { |
Changwan Ryu
2017/05/11 22:57:13
I suggest the following structure:
public voi
AKVT
2017/05/12 13:26:25
Done. Thanks for the detailed code.
|
+ // Forward and backward focus in form2 |
+ mRule.focusElement("textarea"); |
+ Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeActions()); |
+ Assert.assertTrue((EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE & getInputType()) != 0); |
+ |
+ // Forward direction focus |
+ mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT); |
+ Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeActions()); |
+ mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT); |
+ Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeActions()); |
+ mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT); |
+ Assert.assertTrue((EditorInfo.IME_ACTION_NEXT & getImeActions()) != 0); |
+ mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT); |
+ Assert.assertTrue((EditorInfo.IME_ACTION_NEXT & getImeActions()) != 0); |
+ mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT); |
+ // We have reached a multi-line contenteditable element now. |
+ Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeActions()); |
+ Assert.assertTrue((EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE & getInputType()) != 0); |
+ // Now we have reached the last element of the form, hence focus won't change after issuing |
+ // NEXT. |
+ mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT); |
+ Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeActions()); |
+ Assert.assertTrue((EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE & getInputType()) != 0); |
+ |
+ // Backward direction focus |
+ mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS); |
+ Assert.assertTrue((EditorInfo.IME_ACTION_NEXT & getImeActions()) != 0); |
+ mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS); |
+ Assert.assertTrue((EditorInfo.IME_ACTION_NEXT & getImeActions()) != 0); |
+ mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS); |
+ Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeActions()); |
+ mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS); |
+ // We have reached a multi-line textarea element now. |
+ Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeActions()); |
+ Assert.assertTrue((EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE & getInputType()) != 0); |
+ // Now we have reached the first element of the form, hence focus won't change after issuing |
+ // PREVIOUS. |
+ mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS); |
+ Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeActions()); |
+ Assert.assertTrue((EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE & getInputType()) != 0); |
+ } |
+ |
@Test |
@SmallTest |
@DisabledTest(message = "crbug.com/694812") |