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

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

Issue 2801003004: Add "Paste as plain text" into text selection toolbar overflow (Closed)
Patch Set: add comments Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698