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

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: Rebased the patch from TOT 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 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 13 matching lines...) Expand all
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;
34 import java.util.concurrent.Callable; 35 import java.util.concurrent.Callable;
35 36
36 /** 37 /**
37 * IME (input method editor) and text input tests. 38 * IME (input method editor) and text input tests.
38 */ 39 */
39 @RunWith(ContentJUnit4ClassRunner.class) 40 @RunWith(ContentJUnit4ClassRunner.class)
40 public class ImeTest { 41 public class ImeTest {
41 @Rule 42 @Rule
42 public ImeActivityTestRule mRule = new ImeActivityTestRule(); 43 public ImeActivityTestRule mRule = new ImeActivityTestRule();
43 44
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 mRule.commitText("hello", 1); 415 mRule.commitText("hello", 1);
415 mRule.waitAndVerifyUpdateSelection(0, 5, 5, -1, -1); 416 mRule.waitAndVerifyUpdateSelection(0, 5, 5, -1, -1);
416 mRule.restartInput(); 417 mRule.restartInput();
417 DOMUtils.clickNode(mRule.getContentViewCore(), "input_text"); 418 DOMUtils.clickNode(mRule.getContentViewCore(), "input_text");
418 mRule.assertWaitForKeyboardStatus(true); 419 mRule.assertWaitForKeyboardStatus(true);
419 420
420 Assert.assertEquals(5, mRule.getConnectionFactory().getOutAttrs().initia lSelStart); 421 Assert.assertEquals(5, mRule.getConnectionFactory().getOutAttrs().initia lSelStart);
421 Assert.assertEquals(5, mRule.getConnectionFactory().getOutAttrs().initia lSelEnd); 422 Assert.assertEquals(5, mRule.getConnectionFactory().getOutAttrs().initia lSelEnd);
422 } 423 }
423 424
425 private static int getImeAction(EditorInfo editorInfo) {
426 return editorInfo.imeOptions & EditorInfo.IME_MASK_ACTION;
427 }
428
429 @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
424 @Test 488 @Test
425 @SmallTest 489 @SmallTest
426 @Feature({"TextInput"}) 490 @Feature({"TextInput"})
427 public void testShowAndHideSoftInput() throws Exception { 491 public void testShowAndHideSoftInput() throws Exception {
428 mRule.focusElement("input_radio", false); 492 mRule.focusElement("input_radio", false);
429 493
430 // hideSoftKeyboard(), mRule.restartInput() 494 // hideSoftKeyboard(), mRule.restartInput()
431 mRule.waitForKeyboardStates(0, 1, 1, new Integer[] {}); 495 mRule.waitForKeyboardStates(0, 1, 1, new Integer[] {});
432 496
433 // When input connection is null, we still need to set flags to prevent InputMethodService 497 // When input connection is null, we still need to set flags to prevent InputMethodService
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 }); 1564 });
1501 Assert.assertEquals("abc", mRule.runBlockingOnImeThread(new Callable<Cha rSequence>() { 1565 Assert.assertEquals("abc", mRule.runBlockingOnImeThread(new Callable<Cha rSequence>() {
1502 @Override 1566 @Override
1503 public CharSequence call() throws Exception { 1567 public CharSequence call() throws Exception {
1504 return connection.getTextBeforeCursor(5, 0); 1568 return connection.getTextBeforeCursor(5, 0);
1505 } 1569 }
1506 })); 1570 }));
1507 } 1571 }
1508 1572
1509 } 1573 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698