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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
411 mRule.restartInput(); | 411 mRule.restartInput(); |
412 DOMUtils.clickNode(mRule.getContentViewCore(), "input_text"); | 412 DOMUtils.clickNode(mRule.getContentViewCore(), "input_text"); |
413 mRule.assertWaitForKeyboardStatus(true); | 413 mRule.assertWaitForKeyboardStatus(true); |
414 | 414 |
415 Assert.assertEquals(5, mRule.getConnectionFactory().getOutAttrs().initia lSelStart); | 415 Assert.assertEquals(5, mRule.getConnectionFactory().getOutAttrs().initia lSelStart); |
416 Assert.assertEquals(5, mRule.getConnectionFactory().getOutAttrs().initia lSelEnd); | 416 Assert.assertEquals(5, mRule.getConnectionFactory().getOutAttrs().initia lSelEnd); |
417 } | 417 } |
418 | 418 |
419 @Test | 419 @Test |
420 @SmallTest | 420 @SmallTest |
421 @Feature({"TextInput", "Main"}) | |
422 public void testAdvanceFocusNextAndPrevious() throws Exception { | |
423 // Form1 forward and backward focus | |
Changwan Ryu
2017/05/10 16:20:58
Do we really need to test both forms? If not, coul
AKVT
2017/05/11 08:47:39
Ok. Kind of redundant. Thanks
| |
424 mRule.focusElement("input_text"); | |
425 Assert.assertTrue( | |
426 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NEXT) | |
Changwan Ryu
2017/05/10 16:20:59
Could you add a new function
private int getImeAc
AKVT
2017/05/11 08:47:39
Assert.assertEquals(EditorInfo.IME_ACTION_NEXT, ge
| |
427 != 0); | |
428 | |
429 // Forward direction focus | |
430 mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT); | |
431 Assert.assertTrue( | |
432 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NONE) | |
433 != 0); | |
434 mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT); | |
435 // Now we have reached the last element of the form, hence focus won't c hange after issuing | |
436 // NEXT. | |
437 Assert.assertTrue( | |
438 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NONE) | |
439 != 0); | |
440 | |
441 // Backward direction focus | |
442 mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS); | |
443 Assert.assertTrue( | |
444 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NONE) | |
445 != 0); | |
446 mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS); | |
447 Assert.assertTrue( | |
448 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NEXT) | |
449 != 0); | |
450 mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS); | |
451 // Now we have reached the first element of the form, hence focus won't change after issuing | |
452 // PREVIOUS. | |
453 Assert.assertTrue( | |
454 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NEXT) | |
455 != 0); | |
456 | |
457 // Form2 forward and backward focus | |
458 mRule.focusElement("textarea"); | |
459 Assert.assertTrue( | |
460 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NONE) | |
461 != 0); | |
462 | |
463 // Forward direction focus | |
464 mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT); | |
465 Assert.assertTrue( | |
466 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NONE) | |
467 != 0); | |
468 mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT); | |
469 Assert.assertTrue( | |
470 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NONE) | |
471 != 0); | |
472 mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT); | |
473 Assert.assertTrue( | |
474 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NEXT) | |
475 != 0); | |
476 mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT); | |
477 Assert.assertTrue( | |
478 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NEXT) | |
479 != 0); | |
480 mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT); | |
481 Assert.assertTrue( | |
482 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NONE) | |
483 != 0); | |
484 // Now we have reached the last element of the form, hence focus won't c hange after issuing | |
485 // NEXT. | |
486 mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT); | |
487 Assert.assertTrue( | |
488 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NONE) | |
489 != 0); | |
490 | |
491 // Backward direction focus | |
492 mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS); | |
493 Assert.assertTrue( | |
494 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NEXT) | |
495 != 0); | |
496 mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS); | |
497 Assert.assertTrue( | |
498 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NEXT) | |
499 != 0); | |
500 mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS); | |
501 Assert.assertTrue( | |
502 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NONE) | |
503 != 0); | |
504 mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS); | |
505 Assert.assertTrue( | |
506 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NONE) | |
507 != 0); | |
508 // Now we have reached the first element of the form, hence focus won't change after issuing | |
509 // PREVIOUS. | |
510 mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS); | |
511 Assert.assertTrue( | |
512 (mRule.getInputMethodManagerWrapper().getImeOptions() & EditorIn fo.IME_ACTION_NONE) | |
513 != 0); | |
514 } | |
515 | |
516 @Test | |
517 @SmallTest | |
421 @DisabledTest(message = "crbug.com/694812") | 518 @DisabledTest(message = "crbug.com/694812") |
422 @Feature({"TextInput"}) | 519 @Feature({"TextInput"}) |
423 public void testShowAndHideSoftInput() throws Exception { | 520 public void testShowAndHideSoftInput() throws Exception { |
424 mRule.focusElement("input_radio", false); | 521 mRule.focusElement("input_radio", false); |
425 | 522 |
426 // hideSoftKeyboard(), mRule.restartInput() | 523 // hideSoftKeyboard(), mRule.restartInput() |
427 mRule.waitForKeyboardStates(0, 1, 1, new Integer[] {}); | 524 mRule.waitForKeyboardStates(0, 1, 1, new Integer[] {}); |
428 | 525 |
429 // When input connection is null, we still need to set flags to prevent InputMethodService | 526 // When input connection is null, we still need to set flags to prevent InputMethodService |
430 // from entering fullscreen mode and from opening custom UI. | 527 // from entering fullscreen mode and from opening custom UI. |
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1489 }); | 1586 }); |
1490 Assert.assertEquals("abc", mRule.runBlockingOnImeThread(new Callable<Cha rSequence>() { | 1587 Assert.assertEquals("abc", mRule.runBlockingOnImeThread(new Callable<Cha rSequence>() { |
1491 @Override | 1588 @Override |
1492 public CharSequence call() throws Exception { | 1589 public CharSequence call() throws Exception { |
1493 return connection.getTextBeforeCursor(5, 0); | 1590 return connection.getTextBeforeCursor(5, 0); |
1494 } | 1591 } |
1495 })); | 1592 })); |
1496 } | 1593 } |
1497 | 1594 |
1498 } | 1595 } |
OLD | NEW |