| Index: content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreSelectionTest.java
|
| diff --git a/content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreSelectionTest.java b/content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreSelectionTest.java
|
| index 7c19b9d69bd6abc3560ce396c4374ec80e095ee6..1756bc7a8b4f8d562d3b72e5d789754c10866900 100644
|
| --- a/content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreSelectionTest.java
|
| +++ b/content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreSelectionTest.java
|
| @@ -17,6 +17,7 @@ import org.junit.Rule;
|
| import org.junit.Test;
|
| import org.junit.runner.RunWith;
|
|
|
| +import org.chromium.base.BuildInfo;
|
| import org.chromium.base.ThreadUtils;
|
| import org.chromium.base.test.util.DisabledTest;
|
| import org.chromium.base.test.util.Feature;
|
| @@ -50,6 +51,7 @@ public class ContentViewCoreSelectionTest {
|
| + "<br/><p><span id=\"plain_text_1\">SamplePlainTextOne</span></p>"
|
| + "<br/><p><span id=\"plain_text_2\">SamplePlainTextTwo</span></p>"
|
| + "<br/><input id=\"disabled_text\" type=\"text\" disabled value=\"Sample Text\" />"
|
| + + "<br/><div id=\"rich_div\" contentEditable=\"true\" >Rich Editor</div>"
|
| + "</form></body></html>");
|
| private ContentViewCore mContentViewCore;
|
| private SelectionPopupController mSelectionPopupController;
|
| @@ -242,6 +244,54 @@ public class ContentViewCoreSelectionTest {
|
| Assert.assertTrue(mSelectionPopupController.canSelectAll());
|
| }
|
|
|
| + @Test
|
| + @SmallTest
|
| + @Feature({"TextInput"})
|
| + public void testPastePopupPasteAsPlainTextPlainTextRichEditor() throws Throwable {
|
| + if (!BuildInfo.isAtLeastO()) return;
|
| + copyStringToClipboard("SampleTextToCopy");
|
| + DOMUtils.longPressNode(mContentViewCore, "rich_div");
|
| + waitForPastePopupStatus(true);
|
| + waitForInsertion(true);
|
| + Assert.assertFalse(mSelectionPopupController.canPasteAsPlainText());
|
| + }
|
| +
|
| + @Test
|
| + @SmallTest
|
| + @Feature({"TextInput"})
|
| + public void testPastePopupPasteAsPlainTextPlainTextNormalEditor() throws Throwable {
|
| + if (!BuildInfo.isAtLeastO()) return;
|
| + copyStringToClipboard("SampleTextToCopy");
|
| + DOMUtils.longPressNode(mContentViewCore, "empty_input_text");
|
| + waitForPastePopupStatus(true);
|
| + waitForInsertion(true);
|
| + Assert.assertFalse(mSelectionPopupController.canPasteAsPlainText());
|
| + }
|
| +
|
| + @Test
|
| + @SmallTest
|
| + @Feature({"TextInput"})
|
| + public void testPastePopupPasteAsPlainTextHtmlTextRichEditor() throws Throwable {
|
| + if (!BuildInfo.isAtLeastO()) return;
|
| + copyHtmlToClipboard("SampleTextToCopy", "<span style=\"color: red;\">HTML</span>");
|
| + DOMUtils.longPressNode(mContentViewCore, "rich_div");
|
| + waitForPastePopupStatus(true);
|
| + waitForInsertion(true);
|
| + Assert.assertTrue(mSelectionPopupController.canPasteAsPlainText());
|
| + }
|
| +
|
| + @Test
|
| + @SmallTest
|
| + @Feature({"TextInput"})
|
| + public void testPastePopupPasteAsPlainTextHtmlTextNormalEditor() throws Throwable {
|
| + if (!BuildInfo.isAtLeastO()) return;
|
| + copyHtmlToClipboard("SampleTextToCopy", "<span style=\"color: red;\">HTML</span>");
|
| + DOMUtils.longPressNode(mContentViewCore, "empty_input_text");
|
| + waitForPastePopupStatus(true);
|
| + waitForInsertion(true);
|
| + Assert.assertFalse(mSelectionPopupController.canPasteAsPlainText());
|
| + }
|
| +
|
| /*
|
| @SmallTest
|
| @Feature({"TextInput"})
|
| @@ -790,6 +840,20 @@ public class ContentViewCoreSelectionTest {
|
| });
|
| }
|
|
|
| + private void copyHtmlToClipboard(final String plainText, final String htmlText)
|
| + throws Throwable {
|
| + mActivityTestRule.runOnUiThread(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + ClipboardManager clipboardManager =
|
| + (ClipboardManager) mActivityTestRule.getActivity().getSystemService(
|
| + Context.CLIPBOARD_SERVICE);
|
| + ClipData clip = ClipData.newHtmlText("html", plainText, htmlText);
|
| + clipboardManager.setPrimaryClip(clip);
|
| + }
|
| + });
|
| + }
|
| +
|
| private void waitForPastePopupStatus(final boolean show) {
|
| CriteriaHelper.pollUiThread(Criteria.equals(show, new Callable<Boolean>() {
|
| @Override
|
|
|