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

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

Issue 1278593004: Introduce ThreadedInputConnection behind a switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed ImeTest#testDoesNotHang_rendererCrashes which does not test anything Created 4 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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; 5 package org.chromium.content.browser;
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.Intent; 10 import android.content.Intent;
11 import android.test.suitebuilder.annotation.SmallTest; 11 import android.test.suitebuilder.annotation.SmallTest;
12 import android.text.TextUtils; 12 import android.text.TextUtils;
13 13
14 import org.chromium.base.ThreadUtils; 14 import org.chromium.base.ThreadUtils;
15 import org.chromium.base.test.util.Feature; 15 import org.chromium.base.test.util.Feature;
16 import org.chromium.base.test.util.UrlUtils; 16 import org.chromium.base.test.util.UrlUtils;
17 import org.chromium.content.browser.input.ChromiumBaseInputConnection;
18 import org.chromium.content.browser.input.ImeTestUtils;
17 import org.chromium.content.browser.test.util.Criteria; 19 import org.chromium.content.browser.test.util.Criteria;
18 import org.chromium.content.browser.test.util.CriteriaHelper; 20 import org.chromium.content.browser.test.util.CriteriaHelper;
19 import org.chromium.content.browser.test.util.DOMUtils; 21 import org.chromium.content.browser.test.util.DOMUtils;
20 import org.chromium.content_shell_apk.ContentShellTestBase; 22 import org.chromium.content_shell_apk.ContentShellTestBase;
21 23
24 import java.util.concurrent.Callable;
25
22 /** 26 /**
23 * Integration tests for text selection-related behavior. 27 * Integration tests for text selection-related behavior.
24 */ 28 */
25 public class ContentViewCoreSelectionTest extends ContentShellTestBase { 29 public class ContentViewCoreSelectionTest extends ContentShellTestBase {
26 private static final String DATA_URL = UrlUtils.encodeHtmlDataUri( 30 private static final String DATA_URL = UrlUtils.encodeHtmlDataUri(
27 "<html><head><meta name=\"viewport\"" 31 "<html><head><meta name=\"viewport\""
28 + "content=\"width=device-width, initial-scale=1.1, maximum-scale=1. 5\" /></head>" 32 + "content=\"width=device-width, initial-scale=1.1, maximum-scale=1. 5\" /></head>"
29 + "<body><form action=\"about:blank\">" 33 + "<body><form action=\"about:blank\">"
30 + "<input id=\"empty_input_text\" type=\"text\" />" 34 + "<input id=\"empty_input_text\" type=\"text\" />"
31 + "<br/><input id=\"input_text\" type=\"text\" value=\"SampleInputTe xt\" />" 35 + "<br/><input id=\"input_text\" type=\"text\" value=\"SampleInputTe xt\" />"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 DOMUtils.longPressNode(this, mContentViewCore, "textarea"); 407 DOMUtils.longPressNode(this, mContentViewCore, "textarea");
404 waitForSelectActionBarVisible(true); 408 waitForSelectActionBarVisible(true);
405 assertTrue(mContentViewCore.hasSelection()); 409 assertTrue(mContentViewCore.hasSelection());
406 assertNotNull(mContentViewCore.getSelectActionHandler()); 410 assertNotNull(mContentViewCore.getSelectActionHandler());
407 selectActionBarSelectAll(); 411 selectActionBarSelectAll();
408 assertTrue(mContentViewCore.hasSelection()); 412 assertTrue(mContentViewCore.hasSelection());
409 waitForSelectActionBarVisible(true); 413 waitForSelectActionBarVisible(true);
410 assertEquals(mContentViewCore.getSelectedText(), "SampleTextArea"); 414 assertEquals(mContentViewCore.getSelectedText(), "SampleTextArea");
411 } 415 }
412 416
417 private CharSequence getTextBeforeCursor(final int length, final int flags) {
418 final ChromiumBaseInputConnection connection =
419 mContentViewCore.getImeAdapterForTest().getInputConnectionForTes t();
420 return ImeTestUtils.runBlockingOnHandlerNoException(
421 connection.getHandler(), new Callable<CharSequence>() {
422 @Override
423 public CharSequence call() throws Exception {
424 return connection.getTextBeforeCursor(length, flags);
425 }
426 });
427 }
428
413 @SmallTest 429 @SmallTest
414 @Feature({"TextSelection", "TextInput"}) 430 @Feature({"TextSelection", "TextInput"})
415 public void testCursorPositionAfterHidingActionMode() throws Exception { 431 public void testCursorPositionAfterHidingActionMode() throws Exception {
416 DOMUtils.longPressNode(this, mContentViewCore, "textarea"); 432 DOMUtils.longPressNode(this, mContentViewCore, "textarea");
417 waitForSelectActionBarVisible(true); 433 waitForSelectActionBarVisible(true);
418 assertTrue(mContentViewCore.hasSelection()); 434 assertTrue(mContentViewCore.hasSelection());
419 assertNotNull(mContentViewCore.getSelectActionHandler()); 435 assertNotNull(mContentViewCore.getSelectActionHandler());
420 selectActionBarSelectAll(); 436 selectActionBarSelectAll();
421 assertTrue(mContentViewCore.hasSelection()); 437 assertTrue(mContentViewCore.hasSelection());
422 waitForSelectActionBarVisible(true); 438 waitForSelectActionBarVisible(true);
423 assertEquals(mContentViewCore.getSelectedText(), "SampleTextArea"); 439 assertEquals(mContentViewCore.getSelectedText(), "SampleTextArea");
424 hideSelectActionMode(); 440 hideSelectActionMode();
425 waitForSelectActionBarVisible(false); 441 waitForSelectActionBarVisible(false);
426 CriteriaHelper.pollForUIThreadCriteria(new Criteria() { 442 CriteriaHelper.pollForCriteria(new Criteria() {
427 @Override 443 @Override
428 public boolean isSatisfied() { 444 public boolean isSatisfied() {
429 return "SampleTextArea".equals(mContentViewCore.getImeAdapterFor Test() 445 return "SampleTextArea".equals(getTextBeforeCursor(50, 0));
430 .getInputConnectionForTest()
431 .getTextBeforeCursor(50, 0));
432 } 446 }
433 }); 447 });
434 } 448 }
435 449
436 @SmallTest 450 @SmallTest
437 @Feature({"TextSelection"}) 451 @Feature({"TextSelection"})
438 public void testSelectActionBarPlainTextPaste() throws Exception { 452 public void testSelectActionBarPlainTextPaste() throws Exception {
439 copyStringToClipboard("SampleTextToCopy"); 453 copyStringToClipboard("SampleTextToCopy");
440 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); 454 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1");
441 waitForSelectActionBarVisible(true); 455 waitForSelectActionBarVisible(true);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 682
669 private void waitForPastePopupStatus(final boolean show) throws InterruptedE xception { 683 private void waitForPastePopupStatus(final boolean show) throws InterruptedE xception {
670 CriteriaHelper.pollForUIThreadCriteria(new Criteria() { 684 CriteriaHelper.pollForUIThreadCriteria(new Criteria() {
671 @Override 685 @Override
672 public boolean isSatisfied() { 686 public boolean isSatisfied() {
673 return show == mContentViewCore.isPastePopupShowing(); 687 return show == mContentViewCore.isPastePopupShowing();
674 } 688 }
675 }); 689 });
676 } 690 }
677 } 691 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698