Chromium Code Reviews| 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..9ae431d77b085bceb6f2073e8902489659ac069e 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 |
| @@ -34,7 +34,7 @@ public class ContentViewCoreSelectionTest extends ContentShellTestBase { |
| + "<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/><textarea id=\"textarea\" rows=\"2\" cols=\"20\">SampleTextArea</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\" />" |
| @@ -237,6 +237,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 +287,149 @@ 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(); |
| + 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(), "Text to copy"); |
| + } |
| + |
| + @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(); |
| + 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(), "Text to copy"); |
| + } |
| + |
| + @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 { |
| + copyStringToClipboard(); |
| + 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 { |
|
jdduke (slow)
2014/10/30 17:48:31
Do you have any more similar tests? I'd prefer we
|
| + DOMUtils.longPressNode(this, mContentViewCore, "textarea"); |
| + assertWaitForSelectActionBarVisible(true); |
| + assertTrue(mContentViewCore.hasSelection()); |
| + assertNotNull(mContentViewCore.getSelectActionHandler()); |
| + selectActionBarSelectAll(); |
| + assertTrue(mContentViewCore.hasSelection()); |
| + assertWaitForSelectActionBarVisible(true); |
| + assertEquals(mContentViewCore.getSelectedText(), "SampleTextArea"); |
| + } |
| + |
| + 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 |