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

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

Issue 560883002: Adding Paste Popup behavior Unit Test cases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ede2cddb1e932e0930a8e41d917b37084ef50473..20f5f863158a104ee786e25a696b780abc127c96 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.ThreadUtils;
@@ -43,6 +46,7 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase {
mContentViewCore = getContentViewCore();
assertWaitForPageScaleFactorMatch(1.1f);
assertWaitForSelectActionBarVisible(false);
+ assertWaitForPastePopupStatus(false);
}
@SmallTest
@@ -118,6 +122,57 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase {
assertTrue(mContentViewCore.hasSelection());
}
+ @SmallTest
+ @Feature({"TextInput"})
+ public void testPastePopupNotShownOnLongPressingNonEmptyInput() throws Throwable {
+ copyStringToClipboard();
+ DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text");
+ assertWaitForPastePopupStatus(true);
+ DOMUtils.longPressNode(this, mContentViewCore, "input_text");
+ assertWaitForSelectActionBarVisible(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 assertWaitForSelectActionBarVisible(
final boolean visible) throws InterruptedException {
assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
@@ -165,4 +220,21 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase {
}
});
}
+
+ 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();
+ }
+ }));
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698