OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.content.browser.input; | 5 package org.chromium.content.browser.input; |
6 | 6 |
7 import android.content.ClipData; | 7 import android.content.ClipData; |
8 import android.content.ClipboardManager; | 8 import android.content.ClipboardManager; |
9 import android.content.Context; | 9 import android.content.Context; |
10 import android.content.res.Configuration; | 10 import android.content.res.Configuration; |
(...skipping 13 matching lines...) Expand all Loading... |
24 import org.chromium.base.ThreadUtils; | 24 import org.chromium.base.ThreadUtils; |
25 import org.chromium.base.test.util.Feature; | 25 import org.chromium.base.test.util.Feature; |
26 import org.chromium.base.test.util.UrlUtils; | 26 import org.chromium.base.test.util.UrlUtils; |
27 import org.chromium.content.browser.test.ContentJUnit4ClassRunner; | 27 import org.chromium.content.browser.test.ContentJUnit4ClassRunner; |
28 import org.chromium.content.browser.test.util.Criteria; | 28 import org.chromium.content.browser.test.util.Criteria; |
29 import org.chromium.content.browser.test.util.CriteriaHelper; | 29 import org.chromium.content.browser.test.util.CriteriaHelper; |
30 import org.chromium.content.browser.test.util.DOMUtils; | 30 import org.chromium.content.browser.test.util.DOMUtils; |
31 import org.chromium.content.browser.test.util.JavaScriptUtils; | 31 import org.chromium.content.browser.test.util.JavaScriptUtils; |
32 import org.chromium.ui.base.ime.TextInputType; | 32 import org.chromium.ui.base.ime.TextInputType; |
33 | 33 |
34 import java.util.ArrayList; | |
35 import java.util.concurrent.Callable; | 34 import java.util.concurrent.Callable; |
36 | 35 |
37 /** | 36 /** |
38 * IME (input method editor) and text input tests. | 37 * IME (input method editor) and text input tests. |
39 */ | 38 */ |
40 @RunWith(ContentJUnit4ClassRunner.class) | 39 @RunWith(ContentJUnit4ClassRunner.class) |
41 public class ImeTest { | 40 public class ImeTest { |
42 @Rule | 41 @Rule |
43 public ImeActivityTestRule mRule = new ImeActivityTestRule(); | 42 public ImeActivityTestRule mRule = new ImeActivityTestRule(); |
44 | 43 |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 mRule.commitText("hello", 1); | 414 mRule.commitText("hello", 1); |
416 mRule.waitAndVerifyUpdateSelection(0, 5, 5, -1, -1); | 415 mRule.waitAndVerifyUpdateSelection(0, 5, 5, -1, -1); |
417 mRule.restartInput(); | 416 mRule.restartInput(); |
418 DOMUtils.clickNode(mRule.getContentViewCore(), "input_text"); | 417 DOMUtils.clickNode(mRule.getContentViewCore(), "input_text"); |
419 mRule.assertWaitForKeyboardStatus(true); | 418 mRule.assertWaitForKeyboardStatus(true); |
420 | 419 |
421 Assert.assertEquals(5, mRule.getConnectionFactory().getOutAttrs().initia
lSelStart); | 420 Assert.assertEquals(5, mRule.getConnectionFactory().getOutAttrs().initia
lSelStart); |
422 Assert.assertEquals(5, mRule.getConnectionFactory().getOutAttrs().initia
lSelEnd); | 421 Assert.assertEquals(5, mRule.getConnectionFactory().getOutAttrs().initia
lSelEnd); |
423 } | 422 } |
424 | 423 |
425 private static int getImeAction(EditorInfo editorInfo) { | |
426 return editorInfo.imeOptions & EditorInfo.IME_MASK_ACTION; | |
427 } | |
428 | |
429 @Test | 424 @Test |
430 @SmallTest | |
431 @Feature({"TextInput", "Main"}) | |
432 public void testAdvanceFocusNextAndPrevious() throws Exception { | |
433 mRule.focusElement("textarea"); | |
434 // Forward direction focus. Excessive focus advance should be ignored. | |
435 for (int i = 0; i < 10; ++i) { | |
436 // Forward direction focus. | |
437 mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT); | |
438 } | |
439 mRule.waitForKeyboardStates(7, 0, 7, | |
440 new Integer[] {TextInputType.TEXT_AREA, TextInputType.TEXT_AREA, | |
441 TextInputType.NUMBER, TextInputType.NUMBER, TextInputTyp
e.CONTENT_EDITABLE, | |
442 TextInputType.SEARCH, TextInputType.TEXT}); | |
443 ArrayList<EditorInfo> editorInfoList = | |
444 mRule.getInputMethodManagerWrapper().getEditorInfoList(); | |
445 Assert.assertEquals(7, editorInfoList.size()); | |
446 // textarea. | |
447 Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeAction(editorInfoL
ist.get(0))); | |
448 // textarea2. | |
449 Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeAction(editorInfoL
ist.get(1))); | |
450 // input_number1. | |
451 Assert.assertEquals(EditorInfo.IME_ACTION_NEXT, getImeAction(editorInfoL
ist.get(2))); | |
452 // input_number2. | |
453 Assert.assertEquals(EditorInfo.IME_ACTION_NEXT, getImeAction(editorInfoL
ist.get(3))); | |
454 // content_editable1. | |
455 Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeAction(editorInfoL
ist.get(4))); | |
456 // search1. | |
457 Assert.assertEquals(EditorInfo.IME_ACTION_SEARCH, getImeAction(editorInf
oList.get(5))); | |
458 // input_text1. | |
459 Assert.assertEquals(EditorInfo.IME_ACTION_GO, getImeAction(editorInfoLis
t.get(6))); | |
460 | |
461 mRule.resetAllStates(); | |
462 | |
463 // Backward direction focus. Excessive focus advance should be ignored. | |
464 for (int i = 0; i < 10; ++i) { | |
465 // Backward direction focus. | |
466 mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS); | |
467 } | |
468 mRule.waitForKeyboardStates(6, 0, 6, | |
469 new Integer[] {TextInputType.SEARCH, TextInputType.CONTENT_EDITA
BLE, | |
470 TextInputType.NUMBER, TextInputType.NUMBER, TextInputTyp
e.TEXT_AREA, | |
471 TextInputType.TEXT_AREA}); | |
472 editorInfoList = mRule.getInputMethodManagerWrapper().getEditorInfoList(
); | |
473 Assert.assertEquals(6, editorInfoList.size()); | |
474 // search1. | |
475 Assert.assertEquals(EditorInfo.IME_ACTION_SEARCH, getImeAction(editorInf
oList.get(0))); | |
476 // content_editable1. | |
477 Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeAction(editorInfoL
ist.get(1))); | |
478 // input_number2. | |
479 Assert.assertEquals(EditorInfo.IME_ACTION_NEXT, getImeAction(editorInfoL
ist.get(2))); | |
480 // input_number1. | |
481 Assert.assertEquals(EditorInfo.IME_ACTION_NEXT, getImeAction(editorInfoL
ist.get(3))); | |
482 // textarea2. | |
483 Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeAction(editorInfoL
ist.get(4))); | |
484 // textarea. | |
485 Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeAction(editorInfoL
ist.get(5))); | |
486 } | |
487 | |
488 @Test | |
489 @SmallTest | 425 @SmallTest |
490 @Feature({"TextInput"}) | 426 @Feature({"TextInput"}) |
491 public void testShowAndHideSoftInput() throws Exception { | 427 public void testShowAndHideSoftInput() throws Exception { |
492 mRule.focusElement("input_radio", false); | 428 mRule.focusElement("input_radio", false); |
493 | 429 |
494 // hideSoftKeyboard(), mRule.restartInput() | 430 // hideSoftKeyboard(), mRule.restartInput() |
495 mRule.waitForKeyboardStates(0, 1, 1, new Integer[] {}); | 431 mRule.waitForKeyboardStates(0, 1, 1, new Integer[] {}); |
496 | 432 |
497 // When input connection is null, we still need to set flags to prevent
InputMethodService | 433 // When input connection is null, we still need to set flags to prevent
InputMethodService |
498 // from entering fullscreen mode and from opening custom UI. | 434 // from entering fullscreen mode and from opening custom UI. |
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 }); | 1500 }); |
1565 Assert.assertEquals("abc", mRule.runBlockingOnImeThread(new Callable<Cha
rSequence>() { | 1501 Assert.assertEquals("abc", mRule.runBlockingOnImeThread(new Callable<Cha
rSequence>() { |
1566 @Override | 1502 @Override |
1567 public CharSequence call() throws Exception { | 1503 public CharSequence call() throws Exception { |
1568 return connection.getTextBeforeCursor(5, 0); | 1504 return connection.getTextBeforeCursor(5, 0); |
1569 } | 1505 } |
1570 })); | 1506 })); |
1571 } | 1507 } |
1572 | 1508 |
1573 } | 1509 } |
OLD | NEW |