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 04a3bf576799cf58981a5ce499a3d66b12791fee..e3dbeee302ff0614435becc5ee154d04accc6adc 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 |
@@ -4,6 +4,9 @@ |
package org.chromium.content.browser; |
+import android.content.ClipData; |
+import android.content.ClipboardManager; |
+import android.content.Context; |
import android.test.suitebuilder.annotation.SmallTest; |
import org.chromium.base.test.util.Feature; |
@@ -42,6 +45,7 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase { |
mContentViewCore = getContentViewCore(); |
assertWaitForPageScaleFactorMatch(1.1f); |
assertWaitForSelectActionBarStatus(false); |
+ assertWaitForPastePopupStatus(false); |
} |
@SmallTest |
@@ -93,6 +97,74 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase { |
assertWaitForSelectActionBarStatus(false); |
} |
+ @SmallTest |
+ @Feature({"TextInput"}) |
+ public void testPastePopupNotShownOnLongPressingNonEmptyInput() throws Throwable { |
+ copyStringToClipboard(); |
+ DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
+ assertWaitForPastePopupStatus(true); |
+ DOMUtils.longPressNode(this, mContentViewCore, "input_text"); |
+ assertWaitForSelectActionBarStatus(true); |
+ assertWaitForPastePopupStatus(false); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput"}) |
+ public void testPastePopupClearedOnTappingEmptyInput() throws Throwable { |
+ copyStringToClipboard(); |
+ DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
+ assertWaitForPastePopupStatus(true); |
+ DOMUtils.clickNode(this, mContentViewCore, "empty_input_text"); |
+ assertWaitForPastePopupStatus(false); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput"}) |
+ public void testPastePopupClearedOnTappingNonEmptyInput() throws Throwable { |
+ copyStringToClipboard(); |
+ DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
+ assertWaitForPastePopupStatus(true); |
+ DOMUtils.clickNode(this, mContentViewCore, "input_text"); |
+ assertWaitForPastePopupStatus(false); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput"}) |
+ public void testPastePopupClearedOnTappingOutsideInput() throws Throwable { |
+ copyStringToClipboard(); |
+ DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
+ assertWaitForPastePopupStatus(true); |
+ DOMUtils.clickNode(this, mContentViewCore, "plain_text_2"); |
+ assertWaitForPastePopupStatus(false); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput"}) |
+ public void testPastePopupClearedOnLongPressingOutsideInput() throws Throwable { |
+ copyStringToClipboard(); |
+ DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
+ assertWaitForPastePopupStatus(true); |
+ DOMUtils.longPressNode(this, mContentViewCore, "plain_text_2"); |
+ assertWaitForPastePopupStatus(false); |
+ } |
+ |
+ private void copyStringToClipboard() { |
+ ClipboardManager clipboardManager = |
+ (ClipboardManager) getActivity().getSystemService( |
+ Context.CLIPBOARD_SERVICE); |
+ ClipData clip = ClipData.newPlainText("test", "Text to copy"); |
+ clipboardManager.setPrimaryClip(clip); |
+ } |
+ |
+ private void assertWaitForPastePopupStatus(final boolean show) throws InterruptedException { |
+ assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { |
+ @Override |
+ public boolean isSatisfied() { |
+ return show == mContentViewCore.getPastePopupForTest().isShowing(); |
+ } |
+ })); |
+ } |
+ |
private void assertWaitForSelectActionBarStatus( |
final boolean show) throws InterruptedException { |
assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { |