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 f0044ff970828056ace1bfe3f34a66a2dfeaf0ca..6931a8e0e53aefc62b93beb3a74bea7a72d005ee 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 |
@@ -29,15 +29,13 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase { |
+ "content=\"width=device-width, initial-scale=1.1, maximum-scale=1.5\" /></head>" |
+ "<body><form action=\"about:blank\">" |
+ "<input id=\"empty_input_text\" type=\"text\" />" |
+ + "<br/><input id=\"input_text\" type=\"text\" value=\"SampleInputText\" />" |
+ + "<br/><textarea id=\"textarea\" rows=\"2\" cols=\"20\">SampleTextArea</textarea>" |
+ + "<br/><input id=\"input_password\" type=\"password\" value=\"SamplePassword\" />" |
+ "<br/><p><span id=\"plain_text_1\">SamplePlainTextOne</span></p>" |
jdduke (slow)
2014/11/07 17:14:34
Interesting, I wonder if the selection/insertion h
|
+ "<br/><p><span id=\"plain_text_2\">SamplePlainTextTwo</span></p>" |
- + "<br/><input id=\"empty_input_text\" type=\"text\" />" |
- + "<br/><input id=\"input_text\" type=\"text\" value=\"SampleInputText\" />" |
- + "<br/><textarea id=\"empty_textarea\" rows=\"2\" cols=\"20\"></textarea>" |
- + "<br/><textarea id=\"textarea\" rows=\"2\" cols=\"20\">Sample Text</textarea>" |
+ "<br/><input id=\"readonly_text\" type=\"text\" readonly value=\"Sample Text\"/>" |
+ "<br/><input id=\"disabled_text\" type=\"text\" disabled value=\"Sample Text\" />" |
- + "<br/><input id=\"input_password\" type=\"password\" value=\"SamplePassword\" />" |
+ "</form></body></html>"); |
private ContentViewCore mContentViewCore; |
@@ -130,7 +128,7 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase { |
@SmallTest |
@Feature({"TextInput"}) |
public void testPastePopupNotShownOnLongPressingNonEmptyInput() throws Throwable { |
- copyStringToClipboard(); |
+ copyStringToClipboard("SampleTextToCopy"); |
DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
assertWaitForPastePopupStatus(true); |
DOMUtils.longPressNode(this, mContentViewCore, "input_text"); |
@@ -141,7 +139,7 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase { |
@SmallTest |
@Feature({"TextInput"}) |
public void testPastePopupClearedOnTappingEmptyInput() throws Throwable { |
- copyStringToClipboard(); |
+ copyStringToClipboard("SampleTextToCopy"); |
DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
assertWaitForPastePopupStatus(true); |
DOMUtils.clickNode(this, mContentViewCore, "empty_input_text"); |
@@ -151,7 +149,7 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase { |
@SmallTest |
@Feature({"TextInput"}) |
public void testPastePopupClearedOnTappingNonEmptyInput() throws Throwable { |
- copyStringToClipboard(); |
+ copyStringToClipboard("SampleTextToCopy"); |
DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
assertWaitForPastePopupStatus(true); |
DOMUtils.clickNode(this, mContentViewCore, "input_text"); |
@@ -161,7 +159,7 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase { |
@SmallTest |
@Feature({"TextInput"}) |
public void testPastePopupClearedOnTappingOutsideInput() throws Throwable { |
- copyStringToClipboard(); |
+ copyStringToClipboard("SampleTextToCopy"); |
DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
assertWaitForPastePopupStatus(true); |
DOMUtils.clickNode(this, mContentViewCore, "plain_text_2"); |
@@ -171,7 +169,7 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase { |
@SmallTest |
@Feature({"TextInput"}) |
public void testPastePopupClearedOnLongPressingOutsideInput() throws Throwable { |
- copyStringToClipboard(); |
+ copyStringToClipboard("SampleTextToCopy"); |
DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
assertWaitForPastePopupStatus(true); |
DOMUtils.longPressNode(this, mContentViewCore, "plain_text_2"); |
@@ -181,7 +179,7 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase { |
@SmallTest |
@Feature({"TextInput"}) |
public void testPastePopupNotShownOnLongPressingReadOnlyInput() throws Throwable { |
- copyStringToClipboard(); |
+ copyStringToClipboard("SampleTextToCopy"); |
DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
assertWaitForPastePopupStatus(true); |
assertTrue(mContentViewCore.hasInsertion()); |
@@ -193,7 +191,7 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase { |
@SmallTest |
@Feature({"TextInput"}) |
public void testPastePopupNotShownOnLongPressingDisabledInput() throws Throwable { |
- copyStringToClipboard(); |
+ copyStringToClipboard("SampleTextToCopy"); |
DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
assertWaitForPastePopupStatus(true); |
assertTrue(mContentViewCore.hasInsertion()); |
@@ -237,6 +235,17 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase { |
@SmallTest |
@Feature({"TextInput"}) |
+ public void testActionBarConfiguredCorrectlyForTextArea() throws Throwable { |
+ DOMUtils.longPressNode(this, mContentViewCore, "textarea"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertNotNull(mContentViewCore.getSelectActionHandler()); |
+ assertTrue(mContentViewCore.getSelectActionHandler().isSelectionEditable()); |
+ assertFalse(mContentViewCore.getSelectActionHandler().isSelectionPassword()); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput"}) |
public void testSelectActionBarPlainTextCopy() throws Exception { |
DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); |
assertWaitForSelectActionBarVisible(true); |
@@ -276,6 +285,222 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase { |
assertClipboardContents(mContentViewCore.getContext(), "SamplePlainTextOne"); |
} |
+ @SmallTest |
+ @Feature({"TextInput"}) |
+ public void testSelectActionBarTextAreaCopy() throws Exception { |
+ DOMUtils.longPressNode(this, mContentViewCore, "textarea"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertNotNull(mContentViewCore.getSelectActionHandler()); |
+ selectActionBarCopy(); |
+ assertClipboardContents(mContentViewCore.getContext(), "SampleTextArea"); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextSelection"}) |
+ public void testSelectActionBarPlainTextCut() throws Exception { |
+ copyStringToClipboard("SampleTextToCopy"); |
+ DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertEquals(mContentViewCore.getSelectedText(), "SamplePlainTextOne"); |
+ assertNotNull(mContentViewCore.getSelectActionHandler()); |
+ selectActionBarCut(); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ // Cut option won't be available for plain text. |
+ // Hence validating previous Clipboard content. |
+ assertClipboardContents(mContentViewCore.getContext(), "SampleTextToCopy"); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput"}) |
+ public void testSelectActionBarInputCut() throws Exception { |
+ DOMUtils.longPressNode(this, mContentViewCore, "input_text"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertEquals(mContentViewCore.getSelectedText(), "SampleInputText"); |
+ assertNotNull(mContentViewCore.getSelectActionHandler()); |
+ selectActionBarCut(); |
+ assertWaitForSelectActionBarVisible(false); |
+ assertFalse(mContentViewCore.hasSelection()); |
+ assertClipboardContents(mContentViewCore.getContext(), "SampleInputText"); |
+ assertEquals(mContentViewCore.getSelectedText(), ""); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput"}) |
+ public void testSelectActionBarPasswordCut() throws Exception { |
+ copyStringToClipboard("SampleTextToCopy"); |
+ DOMUtils.longPressNode(this, mContentViewCore, "input_password"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertNotNull(mContentViewCore.getSelectActionHandler()); |
+ selectActionBarCut(); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ // Cut option won't be there for Password, hence no change in Clipboard |
+ // Validating with previous Clipboard content |
+ assertClipboardContents(mContentViewCore.getContext(), "SampleTextToCopy"); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput"}) |
+ public void testSelectActionBarTextAreaCut() throws Exception { |
+ DOMUtils.longPressNode(this, mContentViewCore, "textarea"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertEquals(mContentViewCore.getSelectedText(), "SampleTextArea"); |
+ assertNotNull(mContentViewCore.getSelectActionHandler()); |
+ selectActionBarCut(); |
+ assertWaitForSelectActionBarVisible(false); |
+ assertFalse(mContentViewCore.hasSelection()); |
+ assertClipboardContents(mContentViewCore.getContext(), "SampleTextArea"); |
+ assertEquals(mContentViewCore.getSelectedText(), ""); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextSelection"}) |
+ public void testSelectActionBarPlainTextSelectAll() throws Exception { |
+ DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertNotNull(mContentViewCore.getSelectActionHandler()); |
+ selectActionBarSelectAll(); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertWaitForSelectActionBarVisible(true); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput"}) |
+ public void testSelectActionBarInputSelectAll() throws Exception { |
+ DOMUtils.longPressNode(this, mContentViewCore, "input_text"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertNotNull(mContentViewCore.getSelectActionHandler()); |
+ selectActionBarSelectAll(); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertEquals(mContentViewCore.getSelectedText(), "SampleInputText"); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput"}) |
+ public void testSelectActionBarPasswordSelectAll() throws Exception { |
+ DOMUtils.longPressNode(this, mContentViewCore, "input_password"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertNotNull(mContentViewCore.getSelectActionHandler()); |
+ selectActionBarSelectAll(); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertWaitForSelectActionBarVisible(true); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput"}) |
+ public void testSelectActionBarTextAreaSelectAll() throws Exception { |
+ DOMUtils.longPressNode(this, mContentViewCore, "textarea"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertNotNull(mContentViewCore.getSelectActionHandler()); |
+ selectActionBarSelectAll(); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertEquals(mContentViewCore.getSelectedText(), "SampleTextArea"); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextSelection"}) |
+ public void testSelectActionBarPlainTextPaste() throws Exception { |
+ copyStringToClipboard("SampleTextToCopy"); |
+ DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertNotNull(mContentViewCore.getSelectActionHandler()); |
+ selectActionBarPaste(); |
+ DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ // Paste option won't be available for plain text. |
+ // Hence content won't be changed. |
+ assertNotSame(mContentViewCore.getSelectedText(), "SampleTextToCopy"); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput"}) |
+ public void testSelectActionBarInputPaste() throws Exception { |
+ copyStringToClipboard("SampleTextToCopy"); |
+ DOMUtils.longPressNode(this, mContentViewCore, "input_text"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertNotNull(mContentViewCore.getSelectActionHandler()); |
+ selectActionBarPaste(); |
+ DOMUtils.clickNode(this, mContentViewCore, "plain_text_1"); |
+ DOMUtils.longPressNode(this, mContentViewCore, "input_text"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertEquals(mContentViewCore.getSelectedText(), "SampleTextToCopy"); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput"}) |
+ public void testSelectActionBarPasswordPaste() throws Exception { |
+ copyStringToClipboard("SampleTextToCopy"); |
+ DOMUtils.longPressNode(this, mContentViewCore, "input_password"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertNotNull(mContentViewCore.getSelectActionHandler()); |
+ selectActionBarPaste(); |
+ DOMUtils.clickNode(this, mContentViewCore, "plain_text_1"); |
+ DOMUtils.longPressNode(this, mContentViewCore, "input_password"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertNotSame(mContentViewCore.getSelectedText(), "SampleTextToCopy"); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput"}) |
+ public void testSelectActionBarTextAreaPaste() throws Exception { |
+ copyStringToClipboard("SampleTextToCopy"); |
+ DOMUtils.longPressNode(this, mContentViewCore, "textarea"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertNotNull(mContentViewCore.getSelectActionHandler()); |
+ selectActionBarPaste(); |
+ DOMUtils.clickNode(this, mContentViewCore, "plain_text_1"); |
+ DOMUtils.longPressNode(this, mContentViewCore, "textarea"); |
+ assertWaitForSelectActionBarVisible(true); |
+ assertTrue(mContentViewCore.hasSelection()); |
+ assertEquals(mContentViewCore.getSelectedText(), "SampleTextToCopy"); |
+ } |
+ |
+ private void selectActionBarPaste() { |
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
+ @Override |
+ public void run() { |
+ mContentViewCore.getSelectActionHandler().paste(); |
+ } |
+ }); |
+ } |
+ |
+ private void selectActionBarSelectAll() { |
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
+ @Override |
+ public void run() { |
+ mContentViewCore.getSelectActionHandler().selectAll(); |
+ } |
+ }); |
+ } |
+ |
+ private void selectActionBarCut() { |
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
+ @Override |
+ public void run() { |
+ mContentViewCore.getSelectActionHandler().cut(); |
+ } |
+ }); |
+ } |
+ |
private void selectActionBarCopy() { |
ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
@Override |
@@ -353,11 +578,11 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase { |
}); |
} |
- private void copyStringToClipboard() { |
+ private void copyStringToClipboard(String string) { |
ClipboardManager clipboardManager = |
(ClipboardManager) getActivity().getSystemService( |
Context.CLIPBOARD_SERVICE); |
- ClipData clip = ClipData.newPlainText("test", "Text to copy"); |
+ ClipData clip = ClipData.newPlainText("test", string); |
clipboardManager.setPrimaryClip(clip); |
} |