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

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

Issue 2839993002: [Android] Adding Smart GO/NEXT feature in Chrome (Closed)
Patch Set: Added inputType check in ImeTest Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 mRule.commitText("hello", 1); 409 mRule.commitText("hello", 1);
410 mRule.waitAndVerifyUpdateSelection(0, 5, 5, -1, -1); 410 mRule.waitAndVerifyUpdateSelection(0, 5, 5, -1, -1);
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 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.
420 return mRule.getInputMethodManagerWrapper().getImeOptions() & EditorInfo .IME_MASK_ACTION;
421 }
422
423 private int getInputType() {
Changwan Ryu 2017/05/11 22:57:13 remove
AKVT 2017/05/12 13:26:25 Done.
424 return mRule.getInputMethodManagerWrapper().getInputType();
425 }
426
427 @Test
428 @SmallTest
429 @Feature({"TextInput", "Main"})
430 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.
431 // Forward and backward focus in form2
432 mRule.focusElement("textarea");
433 Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeActions());
434 Assert.assertTrue((EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE & getInputType() ) != 0);
435
436 // Forward direction focus
437 mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT);
438 Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeActions());
439 mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT);
440 Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeActions());
441 mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT);
442 Assert.assertTrue((EditorInfo.IME_ACTION_NEXT & getImeActions()) != 0);
443 mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT);
444 Assert.assertTrue((EditorInfo.IME_ACTION_NEXT & getImeActions()) != 0);
445 mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT);
446 // We have reached a multi-line contenteditable element now.
447 Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeActions());
448 Assert.assertTrue((EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE & getInputType() ) != 0);
449 // Now we have reached the last element of the form, hence focus won't c hange after issuing
450 // NEXT.
451 mRule.performEditorAction(EditorInfo.IME_ACTION_NEXT);
452 Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeActions());
453 Assert.assertTrue((EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE & getInputType() ) != 0);
454
455 // Backward direction focus
456 mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS);
457 Assert.assertTrue((EditorInfo.IME_ACTION_NEXT & getImeActions()) != 0);
458 mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS);
459 Assert.assertTrue((EditorInfo.IME_ACTION_NEXT & getImeActions()) != 0);
460 mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS);
461 Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeActions());
462 mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS);
463 // We have reached a multi-line textarea element now.
464 Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeActions());
465 Assert.assertTrue((EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE & getInputType() ) != 0);
466 // Now we have reached the first element of the form, hence focus won't change after issuing
467 // PREVIOUS.
468 mRule.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS);
469 Assert.assertEquals(EditorInfo.IME_ACTION_NONE, getImeActions());
470 Assert.assertTrue((EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE & getInputType() ) != 0);
471 }
472
419 @Test 473 @Test
420 @SmallTest 474 @SmallTest
421 @DisabledTest(message = "crbug.com/694812") 475 @DisabledTest(message = "crbug.com/694812")
422 @Feature({"TextInput"}) 476 @Feature({"TextInput"})
423 public void testShowAndHideSoftInput() throws Exception { 477 public void testShowAndHideSoftInput() throws Exception {
424 mRule.focusElement("input_radio", false); 478 mRule.focusElement("input_radio", false);
425 479
426 // hideSoftKeyboard(), mRule.restartInput() 480 // hideSoftKeyboard(), mRule.restartInput()
427 mRule.waitForKeyboardStates(0, 1, 1, new Integer[] {}); 481 mRule.waitForKeyboardStates(0, 1, 1, new Integer[] {});
428 482
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 }); 1543 });
1490 Assert.assertEquals("abc", mRule.runBlockingOnImeThread(new Callable<Cha rSequence>() { 1544 Assert.assertEquals("abc", mRule.runBlockingOnImeThread(new Callable<Cha rSequence>() {
1491 @Override 1545 @Override
1492 public CharSequence call() throws Exception { 1546 public CharSequence call() throws Exception {
1493 return connection.getTextBeforeCursor(5, 0); 1547 return connection.getTextBeforeCursor(5, 0);
1494 } 1548 }
1495 })); 1549 }));
1496 } 1550 }
1497 1551
1498 } 1552 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698