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

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: switched to delayed onCreateInputConnection approach (tedchoc@'s other comments not resolved yet) 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;
17 import org.chromium.content.browser.test.util.Criteria; 18 import org.chromium.content.browser.test.util.Criteria;
18 import org.chromium.content.browser.test.util.CriteriaHelper; 19 import org.chromium.content.browser.test.util.CriteriaHelper;
19 import org.chromium.content.browser.test.util.DOMUtils; 20 import org.chromium.content.browser.test.util.DOMUtils;
20 import org.chromium.content_shell_apk.ContentShellTestBase; 21 import org.chromium.content_shell_apk.ContentShellTestBase;
21 22
23 import java.util.concurrent.Callable;
24
22 /** 25 /**
23 * Integration tests for text selection-related behavior. 26 * Integration tests for text selection-related behavior.
24 */ 27 */
25 public class ContentViewCoreSelectionTest extends ContentShellTestBase { 28 public class ContentViewCoreSelectionTest extends ContentShellTestBase {
26 private static final String DATA_URL = UrlUtils.encodeHtmlDataUri( 29 private static final String DATA_URL = UrlUtils.encodeHtmlDataUri(
27 "<html><head><meta name=\"viewport\"" 30 "<html><head><meta name=\"viewport\""
28 + "content=\"width=device-width, initial-scale=1.1, maximum-scale=1. 5\" /></head>" 31 + "content=\"width=device-width, initial-scale=1.1, maximum-scale=1. 5\" /></head>"
29 + "<body><form action=\"about:blank\">" 32 + "<body><form action=\"about:blank\">"
30 + "<input id=\"empty_input_text\" type=\"text\" />" 33 + "<input id=\"empty_input_text\" type=\"text\" />"
31 + "<br/><input id=\"input_text\" type=\"text\" value=\"SampleInputTe xt\" />" 34 + "<br/><input id=\"input_text\" type=\"text\" value=\"SampleInputTe xt\" />"
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 DOMUtils.longPressNode(this, mContentViewCore, "textarea"); 419 DOMUtils.longPressNode(this, mContentViewCore, "textarea");
417 waitForSelectActionBarVisible(true); 420 waitForSelectActionBarVisible(true);
418 assertTrue(mContentViewCore.hasSelection()); 421 assertTrue(mContentViewCore.hasSelection());
419 assertNotNull(mContentViewCore.getSelectActionHandler()); 422 assertNotNull(mContentViewCore.getSelectActionHandler());
420 selectActionBarSelectAll(); 423 selectActionBarSelectAll();
421 assertTrue(mContentViewCore.hasSelection()); 424 assertTrue(mContentViewCore.hasSelection());
422 waitForSelectActionBarVisible(true); 425 waitForSelectActionBarVisible(true);
423 assertEquals(mContentViewCore.getSelectedText(), "SampleTextArea"); 426 assertEquals(mContentViewCore.getSelectedText(), "SampleTextArea");
424 hideSelectActionMode(); 427 hideSelectActionMode();
425 waitForSelectActionBarVisible(false); 428 waitForSelectActionBarVisible(false);
426 CriteriaHelper.pollForUIThreadCriteria(new Criteria() { 429 CriteriaHelper.pollForCriteria(new Criteria() {
427 @Override 430 @Override
428 public boolean isSatisfied() { 431 public boolean isSatisfied() {
429 return "SampleTextArea".equals(mContentViewCore.getImeAdapterFor Test() 432 final ChromiumBaseInputConnection connection =
430 .getInputConnectionForTest() 433 mContentViewCore.getImeAdapterForTest().getInputConnecti onForTest();
431 .getTextBeforeCursor(50, 0)); 434 try {
435 CharSequence result = connection.getThreadManager().runBlock ingForTesting(
436 new Callable<CharSequence>() {
437 @Override
438 public CharSequence call() throws Exception {
439 return connection.getTextBeforeCursor(50, 0) ;
440 }
441 });
442 return "SampleTextArea".equals(result);
443 } catch (Exception e) {
444 e.printStackTrace();
445 fail();
446 return false;
447 }
432 } 448 }
433 }); 449 });
434 } 450 }
435 451
436 @SmallTest 452 @SmallTest
437 @Feature({"TextSelection"}) 453 @Feature({"TextSelection"})
438 public void testSelectActionBarPlainTextPaste() throws Exception { 454 public void testSelectActionBarPlainTextPaste() throws Exception {
439 copyStringToClipboard("SampleTextToCopy"); 455 copyStringToClipboard("SampleTextToCopy");
440 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); 456 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1");
441 waitForSelectActionBarVisible(true); 457 waitForSelectActionBarVisible(true);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 684
669 private void waitForPastePopupStatus(final boolean show) throws InterruptedE xception { 685 private void waitForPastePopupStatus(final boolean show) throws InterruptedE xception {
670 CriteriaHelper.pollForUIThreadCriteria(new Criteria() { 686 CriteriaHelper.pollForUIThreadCriteria(new Criteria() {
671 @Override 687 @Override
672 public boolean isSatisfied() { 688 public boolean isSatisfied() {
673 return show == mContentViewCore.isPastePopupShowing(); 689 return show == mContentViewCore.isPastePopupShowing();
674 } 690 }
675 }); 691 });
676 } 692 }
677 } 693 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698