| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.content.ClipData; | 7 import android.content.ClipData; |
| 8 import android.content.ClipboardManager; | 8 import android.content.ClipboardManager; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.Intent; | 10 import android.content.Intent; |
| 11 import android.support.test.filters.SmallTest; | 11 import android.support.test.filters.SmallTest; |
| 12 import android.text.TextUtils; | 12 import android.text.TextUtils; |
| 13 | 13 |
| 14 import org.junit.Assert; |
| 15 import org.junit.Before; |
| 16 import org.junit.Rule; |
| 17 import org.junit.Test; |
| 18 import org.junit.runner.RunWith; |
| 19 |
| 14 import org.chromium.base.ThreadUtils; | 20 import org.chromium.base.ThreadUtils; |
| 15 import org.chromium.base.test.util.DisabledTest; | 21 import org.chromium.base.test.util.DisabledTest; |
| 16 import org.chromium.base.test.util.Feature; | 22 import org.chromium.base.test.util.Feature; |
| 17 import org.chromium.base.test.util.UrlUtils; | 23 import org.chromium.base.test.util.UrlUtils; |
| 18 import org.chromium.content.browser.input.ChromiumBaseInputConnection; | 24 import org.chromium.content.browser.input.ChromiumBaseInputConnection; |
| 19 import org.chromium.content.browser.input.ImeTestUtils; | 25 import org.chromium.content.browser.input.ImeTestUtils; |
| 26 import org.chromium.content.browser.test.ContentJUnit4ClassRunner; |
| 20 import org.chromium.content.browser.test.util.Criteria; | 27 import org.chromium.content.browser.test.util.Criteria; |
| 21 import org.chromium.content.browser.test.util.CriteriaHelper; | 28 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 22 import org.chromium.content.browser.test.util.DOMUtils; | 29 import org.chromium.content.browser.test.util.DOMUtils; |
| 23 import org.chromium.content_shell_apk.ContentShellTestBase; | 30 import org.chromium.content_shell_apk.ContentShellActivityTestRule; |
| 24 | 31 |
| 25 import java.util.concurrent.Callable; | 32 import java.util.concurrent.Callable; |
| 26 | 33 |
| 27 /** | 34 /** |
| 28 * Integration tests for text selection-related behavior. | 35 * Integration tests for text selection-related behavior. |
| 29 */ | 36 */ |
| 30 public class ContentViewCoreSelectionTest extends ContentShellTestBase { | 37 @RunWith(ContentJUnit4ClassRunner.class) |
| 38 public class ContentViewCoreSelectionTest { |
| 39 @Rule |
| 40 public ContentShellActivityTestRule mActivityTestRule = new ContentShellActi
vityTestRule(); |
| 31 private static final String DATA_URL = UrlUtils.encodeHtmlDataUri( | 41 private static final String DATA_URL = UrlUtils.encodeHtmlDataUri( |
| 32 "<html><head><meta name=\"viewport\"" | 42 "<html><head><meta name=\"viewport\"" |
| 33 + "content=\"width=device-width, initial-scale=1.1, maximum-scale=1.
5\" /></head>" | 43 + "content=\"width=device-width, initial-scale=1.1, maximum-scale=1.
5\" /></head>" |
| 34 + "<body><form action=\"about:blank\">" | 44 + "<body><form action=\"about:blank\">" |
| 35 + "<input id=\"empty_input_text\" type=\"text\" />" | 45 + "<input id=\"empty_input_text\" type=\"text\" />" |
| 36 + "<br/><input id=\"whitespace_input_text\" type=\"text\" value=\" \
" />" | 46 + "<br/><input id=\"whitespace_input_text\" type=\"text\" value=\" \
" />" |
| 37 + "<br/><input id=\"input_text\" type=\"text\" value=\"SampleInputTe
xt\" />" | 47 + "<br/><input id=\"input_text\" type=\"text\" value=\"SampleInputTe
xt\" />" |
| 38 + "<br/><textarea id=\"textarea\" rows=\"2\" cols=\"20\">SampleTextA
rea</textarea>" | 48 + "<br/><textarea id=\"textarea\" rows=\"2\" cols=\"20\">SampleTextA
rea</textarea>" |
| 39 + "<br/><input id=\"password\" type=\"password\" value=\"SamplePassw
ord\" size=\"10\"/>" | 49 + "<br/><input id=\"password\" type=\"password\" value=\"SamplePassw
ord\" size=\"10\"/>" |
| 40 + "<br/><p><span id=\"plain_text_1\">SamplePlainTextOne</span></p>" | 50 + "<br/><p><span id=\"plain_text_1\">SamplePlainTextOne</span></p>" |
| 41 + "<br/><p><span id=\"plain_text_2\">SamplePlainTextTwo</span></p>" | 51 + "<br/><p><span id=\"plain_text_2\">SamplePlainTextTwo</span></p>" |
| 42 + "<br/><input id=\"disabled_text\" type=\"text\" disabled value=\"S
ample Text\" />" | 52 + "<br/><input id=\"disabled_text\" type=\"text\" disabled value=\"S
ample Text\" />" |
| 43 + "</form></body></html>"); | 53 + "</form></body></html>"); |
| 44 private ContentViewCore mContentViewCore; | 54 private ContentViewCore mContentViewCore; |
| 45 private SelectionPopupController mSelectionPopupController; | 55 private SelectionPopupController mSelectionPopupController; |
| 46 | 56 |
| 47 @Override | 57 @Before |
| 48 public void setUp() throws Exception { | 58 public void setUp() throws Exception { |
| 49 super.setUp(); | 59 mActivityTestRule.launchContentShellWithUrl(DATA_URL); |
| 60 mActivityTestRule.waitForActiveShellToBeDoneLoading(); |
| 50 | 61 |
| 51 launchContentShellWithUrl(DATA_URL); | 62 mContentViewCore = mActivityTestRule.getContentViewCore(); |
| 52 waitForActiveShellToBeDoneLoading(); | |
| 53 | |
| 54 mContentViewCore = getContentViewCore(); | |
| 55 mSelectionPopupController = mContentViewCore.getSelectionPopupController
ForTesting(); | 63 mSelectionPopupController = mContentViewCore.getSelectionPopupController
ForTesting(); |
| 56 waitForSelectActionBarVisible(false); | 64 waitForSelectActionBarVisible(false); |
| 57 waitForPastePopupStatus(false); | 65 waitForPastePopupStatus(false); |
| 58 } | 66 } |
| 59 | 67 |
| 68 @Test |
| 60 @SmallTest | 69 @SmallTest |
| 61 @Feature({"TextSelection"}) | 70 @Feature({"TextSelection"}) |
| 62 @DisabledTest(message = "crbug.com/592428") | 71 @DisabledTest(message = "crbug.com/592428") |
| 63 public void testSelectionClearedAfterLossOfFocus() throws Throwable { | 72 public void testSelectionClearedAfterLossOfFocus() throws Throwable { |
| 64 requestFocusOnUiThread(true); | 73 requestFocusOnUiThread(true); |
| 65 | 74 |
| 66 DOMUtils.longPressNode(mContentViewCore, "textarea"); | 75 DOMUtils.longPressNode(mContentViewCore, "textarea"); |
| 67 waitForSelectActionBarVisible(true); | 76 waitForSelectActionBarVisible(true); |
| 68 | 77 |
| 69 requestFocusOnUiThread(false); | 78 requestFocusOnUiThread(false); |
| 70 waitForSelectActionBarVisible(false); | 79 waitForSelectActionBarVisible(false); |
| 71 assertFalse(mSelectionPopupController.hasSelection()); | 80 Assert.assertFalse(mSelectionPopupController.hasSelection()); |
| 72 | 81 |
| 73 requestFocusOnUiThread(true); | 82 requestFocusOnUiThread(true); |
| 74 waitForSelectActionBarVisible(false); | 83 waitForSelectActionBarVisible(false); |
| 75 assertFalse(mSelectionPopupController.hasSelection()); | 84 Assert.assertFalse(mSelectionPopupController.hasSelection()); |
| 76 } | 85 } |
| 77 | 86 |
| 87 @Test |
| 78 @SmallTest | 88 @SmallTest |
| 79 @Feature({"TextSelection"}) | 89 @Feature({"TextSelection"}) |
| 80 @DisabledTest(message = "crbug.com/592428") | 90 @DisabledTest(message = "crbug.com/592428") |
| 81 public void testSelectionPreservedAfterLossOfFocusIfRequested() throws Throw
able { | 91 public void testSelectionPreservedAfterLossOfFocusIfRequested() throws Throw
able { |
| 82 requestFocusOnUiThread(true); | 92 requestFocusOnUiThread(true); |
| 83 | 93 |
| 84 DOMUtils.longPressNode(mContentViewCore, "textarea"); | 94 DOMUtils.longPressNode(mContentViewCore, "textarea"); |
| 85 waitForSelectActionBarVisible(true); | 95 waitForSelectActionBarVisible(true); |
| 86 assertTrue(mSelectionPopupController.hasSelection()); | 96 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 87 | 97 |
| 88 mContentViewCore.preserveSelectionOnNextLossOfFocus(); | 98 mContentViewCore.preserveSelectionOnNextLossOfFocus(); |
| 89 requestFocusOnUiThread(false); | 99 requestFocusOnUiThread(false); |
| 90 waitForSelectActionBarVisible(false); | 100 waitForSelectActionBarVisible(false); |
| 91 assertTrue(mSelectionPopupController.hasSelection()); | 101 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 92 | 102 |
| 93 requestFocusOnUiThread(true); | 103 requestFocusOnUiThread(true); |
| 94 waitForSelectActionBarVisible(true); | 104 waitForSelectActionBarVisible(true); |
| 95 assertTrue(mSelectionPopupController.hasSelection()); | 105 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 96 | 106 |
| 97 // Losing focus yet again should properly clear the selection. | 107 // Losing focus yet again should properly clear the selection. |
| 98 requestFocusOnUiThread(false); | 108 requestFocusOnUiThread(false); |
| 99 waitForSelectActionBarVisible(false); | 109 waitForSelectActionBarVisible(false); |
| 100 assertFalse(mSelectionPopupController.hasSelection()); | 110 Assert.assertFalse(mSelectionPopupController.hasSelection()); |
| 101 } | 111 } |
| 102 | 112 |
| 113 @Test |
| 103 @SmallTest | 114 @SmallTest |
| 104 @Feature({"TextSelection"}) | 115 @Feature({"TextSelection"}) |
| 105 @DisabledTest(message = "crbug.com/592428") | 116 @DisabledTest(message = "crbug.com/592428") |
| 106 public void testSelectionPreservedAfterReshown() throws Throwable { | 117 public void testSelectionPreservedAfterReshown() throws Throwable { |
| 107 DOMUtils.longPressNode(mContentViewCore, "textarea"); | 118 DOMUtils.longPressNode(mContentViewCore, "textarea"); |
| 108 waitForSelectActionBarVisible(true); | 119 waitForSelectActionBarVisible(true); |
| 109 assertTrue(mSelectionPopupController.hasSelection()); | 120 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 110 | 121 |
| 111 setVisibileOnUiThread(false); | 122 setVisibileOnUiThread(false); |
| 112 waitForSelectActionBarVisible(false); | 123 waitForSelectActionBarVisible(false); |
| 113 assertTrue(mSelectionPopupController.hasSelection()); | 124 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 114 | 125 |
| 115 setVisibileOnUiThread(true); | 126 setVisibileOnUiThread(true); |
| 116 waitForSelectActionBarVisible(true); | 127 waitForSelectActionBarVisible(true); |
| 117 assertTrue(mSelectionPopupController.hasSelection()); | 128 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 118 } | 129 } |
| 119 | 130 |
| 131 @Test |
| 120 @SmallTest | 132 @SmallTest |
| 121 @Feature({"TextSelection"}) | 133 @Feature({"TextSelection"}) |
| 122 @DisabledTest(message = "crbug.com/592428") | 134 @DisabledTest(message = "crbug.com/592428") |
| 123 public void testSelectionPreservedAfterReattached() throws Throwable { | 135 public void testSelectionPreservedAfterReattached() throws Throwable { |
| 124 DOMUtils.longPressNode(mContentViewCore, "textarea"); | 136 DOMUtils.longPressNode(mContentViewCore, "textarea"); |
| 125 waitForSelectActionBarVisible(true); | 137 waitForSelectActionBarVisible(true); |
| 126 assertTrue(mSelectionPopupController.hasSelection()); | 138 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 127 | 139 |
| 128 setAttachedOnUiThread(false); | 140 setAttachedOnUiThread(false); |
| 129 waitForSelectActionBarVisible(false); | 141 waitForSelectActionBarVisible(false); |
| 130 assertTrue(mSelectionPopupController.hasSelection()); | 142 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 131 | 143 |
| 132 setAttachedOnUiThread(true); | 144 setAttachedOnUiThread(true); |
| 133 waitForSelectActionBarVisible(true); | 145 waitForSelectActionBarVisible(true); |
| 134 assertTrue(mSelectionPopupController.hasSelection()); | 146 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 135 } | 147 } |
| 136 | 148 |
| 137 /* | 149 /* |
| 138 @SmallTest | 150 @SmallTest |
| 139 @Feature({"TextInput"}) | 151 @Feature({"TextInput"}) |
| 140 */ | 152 */ |
| 153 @Test |
| 141 @DisabledTest(message = "https://crbug.com/592428") | 154 @DisabledTest(message = "https://crbug.com/592428") |
| 142 public void testPastePopupNotShownOnLongPressingNonEmptyInput() throws Throw
able { | 155 public void testPastePopupNotShownOnLongPressingNonEmptyInput() throws Throw
able { |
| 143 copyStringToClipboard("SampleTextToCopy"); | 156 copyStringToClipboard("SampleTextToCopy"); |
| 144 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); | 157 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); |
| 145 waitForPastePopupStatus(true); | 158 waitForPastePopupStatus(true); |
| 146 DOMUtils.longPressNode(mContentViewCore, "input_text"); | 159 DOMUtils.longPressNode(mContentViewCore, "input_text"); |
| 147 waitForSelectActionBarVisible(true); | 160 waitForSelectActionBarVisible(true); |
| 148 waitForPastePopupStatus(false); | 161 waitForPastePopupStatus(false); |
| 149 } | 162 } |
| 150 | 163 |
| 164 @Test |
| 151 @SmallTest | 165 @SmallTest |
| 152 @Feature({"TextInput"}) | 166 @Feature({"TextInput"}) |
| 153 public void testPastePopupClearedOnTappingEmptyInput() throws Throwable { | 167 public void testPastePopupClearedOnTappingEmptyInput() throws Throwable { |
| 154 copyStringToClipboard("SampleTextToCopy"); | 168 copyStringToClipboard("SampleTextToCopy"); |
| 155 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); | 169 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); |
| 156 waitForPastePopupStatus(true); | 170 waitForPastePopupStatus(true); |
| 157 DOMUtils.clickNode(mContentViewCore, "empty_input_text"); | 171 DOMUtils.clickNode(mContentViewCore, "empty_input_text"); |
| 158 waitForPastePopupStatus(false); | 172 waitForPastePopupStatus(false); |
| 159 } | 173 } |
| 160 | 174 |
| 175 @Test |
| 161 @SmallTest | 176 @SmallTest |
| 162 @Feature({"TextInput"}) | 177 @Feature({"TextInput"}) |
| 163 public void testPastePopupClearedOnTappingNonEmptyInput() throws Throwable { | 178 public void testPastePopupClearedOnTappingNonEmptyInput() throws Throwable { |
| 164 copyStringToClipboard("SampleTextToCopy"); | 179 copyStringToClipboard("SampleTextToCopy"); |
| 165 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); | 180 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); |
| 166 waitForPastePopupStatus(true); | 181 waitForPastePopupStatus(true); |
| 167 DOMUtils.clickNode(mContentViewCore, "input_text"); | 182 DOMUtils.clickNode(mContentViewCore, "input_text"); |
| 168 waitForPastePopupStatus(false); | 183 waitForPastePopupStatus(false); |
| 169 } | 184 } |
| 170 | 185 |
| 186 @Test |
| 171 @SmallTest | 187 @SmallTest |
| 172 @Feature({"TextInput"}) | 188 @Feature({"TextInput"}) |
| 173 public void testPastePopupClearedOnTappingOutsideInput() throws Throwable { | 189 public void testPastePopupClearedOnTappingOutsideInput() throws Throwable { |
| 174 copyStringToClipboard("SampleTextToCopy"); | 190 copyStringToClipboard("SampleTextToCopy"); |
| 175 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); | 191 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); |
| 176 waitForPastePopupStatus(true); | 192 waitForPastePopupStatus(true); |
| 177 DOMUtils.clickNode(mContentViewCore, "plain_text_2"); | 193 DOMUtils.clickNode(mContentViewCore, "plain_text_2"); |
| 178 waitForPastePopupStatus(false); | 194 waitForPastePopupStatus(false); |
| 179 } | 195 } |
| 180 | 196 |
| 197 @Test |
| 181 @SmallTest | 198 @SmallTest |
| 182 @Feature({"TextInput"}) | 199 @Feature({"TextInput"}) |
| 183 public void testPastePopupClearedOnLongPressingOutsideInput() throws Throwab
le { | 200 public void testPastePopupClearedOnLongPressingOutsideInput() throws Throwab
le { |
| 184 copyStringToClipboard("SampleTextToCopy"); | 201 copyStringToClipboard("SampleTextToCopy"); |
| 185 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); | 202 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); |
| 186 waitForPastePopupStatus(true); | 203 waitForPastePopupStatus(true); |
| 187 DOMUtils.longPressNode(mContentViewCore, "plain_text_2"); | 204 DOMUtils.longPressNode(mContentViewCore, "plain_text_2"); |
| 188 waitForPastePopupStatus(false); | 205 waitForPastePopupStatus(false); |
| 189 } | 206 } |
| 190 | 207 |
| 208 @Test |
| 191 @SmallTest | 209 @SmallTest |
| 192 @Feature({"TextInput"}) | 210 @Feature({"TextInput"}) |
| 193 public void testPastePopupNotShownOnLongPressingDisabledInput() throws Throw
able { | 211 public void testPastePopupNotShownOnLongPressingDisabledInput() throws Throw
able { |
| 194 copyStringToClipboard("SampleTextToCopy"); | 212 copyStringToClipboard("SampleTextToCopy"); |
| 195 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); | 213 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); |
| 196 waitForPastePopupStatus(true); | 214 waitForPastePopupStatus(true); |
| 197 waitForInsertion(true); | 215 waitForInsertion(true); |
| 198 DOMUtils.longPressNode(mContentViewCore, "disabled_text"); | 216 DOMUtils.longPressNode(mContentViewCore, "disabled_text"); |
| 199 waitForPastePopupStatus(false); | 217 waitForPastePopupStatus(false); |
| 200 waitForInsertion(false); | 218 waitForInsertion(false); |
| 201 } | 219 } |
| 202 | 220 |
| 221 @Test |
| 203 @SmallTest | 222 @SmallTest |
| 204 @Feature({"TextInput"}) | 223 @Feature({"TextInput"}) |
| 205 public void testPastePopupNoSelectAllEmptyInput() throws Throwable { | 224 public void testPastePopupNoSelectAllEmptyInput() throws Throwable { |
| 206 // Clipboard has to be non-empty for this test to work on SDK < M. | 225 // Clipboard has to be non-empty for this test to work on SDK < M. |
| 207 copyStringToClipboard("SampleTextToCopy"); | 226 copyStringToClipboard("SampleTextToCopy"); |
| 208 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); | 227 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); |
| 209 waitForPastePopupStatus(true); | 228 waitForPastePopupStatus(true); |
| 210 waitForInsertion(true); | 229 waitForInsertion(true); |
| 211 assertFalse(mSelectionPopupController.canSelectAll()); | 230 Assert.assertFalse(mSelectionPopupController.canSelectAll()); |
| 212 } | 231 } |
| 213 | 232 |
| 233 @Test |
| 214 @SmallTest | 234 @SmallTest |
| 215 @Feature({"TextInput"}) | 235 @Feature({"TextInput"}) |
| 216 public void testPastePopupCanSelectAllNonEmptyInput() throws Throwable { | 236 public void testPastePopupCanSelectAllNonEmptyInput() throws Throwable { |
| 217 // Clipboard has to be non-empty for this test to work on SDK < M. | 237 // Clipboard has to be non-empty for this test to work on SDK < M. |
| 218 copyStringToClipboard("SampleTextToCopy"); | 238 copyStringToClipboard("SampleTextToCopy"); |
| 219 DOMUtils.longPressNode(mContentViewCore, "whitespace_input_text"); | 239 DOMUtils.longPressNode(mContentViewCore, "whitespace_input_text"); |
| 220 waitForPastePopupStatus(true); | 240 waitForPastePopupStatus(true); |
| 221 waitForInsertion(true); | 241 waitForInsertion(true); |
| 222 assertTrue(mSelectionPopupController.canSelectAll()); | 242 Assert.assertTrue(mSelectionPopupController.canSelectAll()); |
| 223 } | 243 } |
| 224 | 244 |
| 225 /* | 245 /* |
| 226 @SmallTest | 246 @SmallTest |
| 227 @Feature({"TextInput"}) | 247 @Feature({"TextInput"}) |
| 228 */ | 248 */ |
| 249 @Test |
| 229 @DisabledTest(message = "https://crbug.com/592428") | 250 @DisabledTest(message = "https://crbug.com/592428") |
| 230 public void testPastePopupDismissedOnDestroy() throws Throwable { | 251 public void testPastePopupDismissedOnDestroy() throws Throwable { |
| 231 copyStringToClipboard("SampleTextToCopy"); | 252 copyStringToClipboard("SampleTextToCopy"); |
| 232 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); | 253 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); |
| 233 waitForPastePopupStatus(true); | 254 waitForPastePopupStatus(true); |
| 234 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 255 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 235 @Override | 256 @Override |
| 236 public void run() { | 257 public void run() { |
| 237 mContentViewCore.destroy(); | 258 mContentViewCore.destroy(); |
| 238 } | 259 } |
| 239 }); | 260 }); |
| 240 waitForPastePopupStatus(false); | 261 waitForPastePopupStatus(false); |
| 241 } | 262 } |
| 242 | 263 |
| 264 @Test |
| 243 @SmallTest | 265 @SmallTest |
| 244 @Feature({"TextInput"}) | 266 @Feature({"TextInput"}) |
| 245 @DisabledTest(message = "crbug.com/592428") | 267 @DisabledTest(message = "crbug.com/592428") |
| 246 public void testActionBarConfiguredCorrectlyForInput() throws Throwable { | 268 public void testActionBarConfiguredCorrectlyForInput() throws Throwable { |
| 247 DOMUtils.longPressNode(mContentViewCore, "input_text"); | 269 DOMUtils.longPressNode(mContentViewCore, "input_text"); |
| 248 waitForSelectActionBarVisible(true); | 270 waitForSelectActionBarVisible(true); |
| 249 assertTrue(mSelectionPopupController.hasSelection()); | 271 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 250 assertTrue(mSelectionPopupController.isActionModeValid()); | 272 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 251 assertTrue(mSelectionPopupController.isSelectionEditable()); | 273 Assert.assertTrue(mSelectionPopupController.isSelectionEditable()); |
| 252 assertFalse(mSelectionPopupController.isSelectionPassword()); | 274 Assert.assertFalse(mSelectionPopupController.isSelectionPassword()); |
| 253 } | 275 } |
| 254 | 276 |
| 277 @Test |
| 255 @SmallTest | 278 @SmallTest |
| 256 @Feature({"TextInput"}) | 279 @Feature({"TextInput"}) |
| 257 @DisabledTest(message = "crbug.com/592428") | 280 @DisabledTest(message = "crbug.com/592428") |
| 258 public void testActionBarConfiguredCorrectlyForPassword() throws Throwable { | 281 public void testActionBarConfiguredCorrectlyForPassword() throws Throwable { |
| 259 DOMUtils.longPressNode(mContentViewCore, "password"); | 282 DOMUtils.longPressNode(mContentViewCore, "password"); |
| 260 waitForSelectActionBarVisible(true); | 283 waitForSelectActionBarVisible(true); |
| 261 assertTrue(mSelectionPopupController.hasSelection()); | 284 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 262 assertTrue(mSelectionPopupController.isActionModeValid()); | 285 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 263 assertTrue(mSelectionPopupController.isSelectionEditable()); | 286 Assert.assertTrue(mSelectionPopupController.isSelectionEditable()); |
| 264 assertTrue(mSelectionPopupController.isSelectionPassword()); | 287 Assert.assertTrue(mSelectionPopupController.isSelectionPassword()); |
| 265 } | 288 } |
| 266 | 289 |
| 290 @Test |
| 267 @SmallTest | 291 @SmallTest |
| 268 @Feature({"TextInput"}) | 292 @Feature({"TextInput"}) |
| 269 @DisabledTest(message = "crbug.com/592428") | 293 @DisabledTest(message = "crbug.com/592428") |
| 270 public void testActionBarConfiguredCorrectlyForPlainText() throws Throwable
{ | 294 public void testActionBarConfiguredCorrectlyForPlainText() throws Throwable
{ |
| 271 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); | 295 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); |
| 272 waitForSelectActionBarVisible(true); | 296 waitForSelectActionBarVisible(true); |
| 273 assertTrue(mSelectionPopupController.hasSelection()); | 297 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 274 assertTrue(mSelectionPopupController.isActionModeValid()); | 298 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 275 assertFalse(mSelectionPopupController.isSelectionEditable()); | 299 Assert.assertFalse(mSelectionPopupController.isSelectionEditable()); |
| 276 assertFalse(mSelectionPopupController.isSelectionPassword()); | 300 Assert.assertFalse(mSelectionPopupController.isSelectionPassword()); |
| 277 } | 301 } |
| 278 | 302 |
| 303 @Test |
| 279 @SmallTest | 304 @SmallTest |
| 280 @Feature({"TextInput"}) | 305 @Feature({"TextInput"}) |
| 281 @DisabledTest(message = "crbug.com/592428") | 306 @DisabledTest(message = "crbug.com/592428") |
| 282 public void testActionBarConfiguredCorrectlyForTextArea() throws Throwable { | 307 public void testActionBarConfiguredCorrectlyForTextArea() throws Throwable { |
| 283 DOMUtils.longPressNode(mContentViewCore, "textarea"); | 308 DOMUtils.longPressNode(mContentViewCore, "textarea"); |
| 284 waitForSelectActionBarVisible(true); | 309 waitForSelectActionBarVisible(true); |
| 285 assertTrue(mSelectionPopupController.hasSelection()); | 310 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 286 assertTrue(mSelectionPopupController.isActionModeValid()); | 311 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 287 assertTrue(mSelectionPopupController.isSelectionEditable()); | 312 Assert.assertTrue(mSelectionPopupController.isSelectionEditable()); |
| 288 assertFalse(mSelectionPopupController.isSelectionPassword()); | 313 Assert.assertFalse(mSelectionPopupController.isSelectionPassword()); |
| 289 } | 314 } |
| 290 | 315 |
| 316 @Test |
| 291 @SmallTest | 317 @SmallTest |
| 292 @Feature({"TextInput"}) | 318 @Feature({"TextInput"}) |
| 293 @DisabledTest(message = "crbug.com/592428") | 319 @DisabledTest(message = "crbug.com/592428") |
| 294 public void testSelectActionBarPlainTextCopy() throws Exception { | 320 public void testSelectActionBarPlainTextCopy() throws Exception { |
| 295 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); | 321 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); |
| 296 waitForSelectActionBarVisible(true); | 322 waitForSelectActionBarVisible(true); |
| 297 assertTrue(mSelectionPopupController.hasSelection()); | 323 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 298 assertTrue(mSelectionPopupController.isActionModeValid()); | 324 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 299 selectActionBarCopy(); | 325 selectActionBarCopy(); |
| 300 waitForClipboardContents(mContentViewCore.getContext(), "SamplePlainText
One"); | 326 waitForClipboardContents(mContentViewCore.getContext(), "SamplePlainText
One"); |
| 301 } | 327 } |
| 302 | 328 |
| 329 @Test |
| 303 @SmallTest | 330 @SmallTest |
| 304 @Feature({"TextInput"}) | 331 @Feature({"TextInput"}) |
| 305 @DisabledTest(message = "crbug.com/592428") | 332 @DisabledTest(message = "crbug.com/592428") |
| 306 public void testSelectActionBarInputCopy() throws Exception { | 333 public void testSelectActionBarInputCopy() throws Exception { |
| 307 DOMUtils.longPressNode(mContentViewCore, "input_text"); | 334 DOMUtils.longPressNode(mContentViewCore, "input_text"); |
| 308 waitForSelectActionBarVisible(true); | 335 waitForSelectActionBarVisible(true); |
| 309 assertTrue(mSelectionPopupController.hasSelection()); | 336 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 310 assertTrue(mSelectionPopupController.isActionModeValid()); | 337 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 311 selectActionBarCopy(); | 338 selectActionBarCopy(); |
| 312 waitForClipboardContents(mContentViewCore.getContext(), "SampleInputText
"); | 339 waitForClipboardContents(mContentViewCore.getContext(), "SampleInputText
"); |
| 313 } | 340 } |
| 314 | 341 |
| 342 @Test |
| 315 @SmallTest | 343 @SmallTest |
| 316 @Feature({"TextInput"}) | 344 @Feature({"TextInput"}) |
| 317 @DisabledTest(message = "crbug.com/592428") | 345 @DisabledTest(message = "crbug.com/592428") |
| 318 public void testSelectActionBarPasswordCopy() throws Exception { | 346 public void testSelectActionBarPasswordCopy() throws Exception { |
| 319 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); | 347 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); |
| 320 waitForSelectActionBarVisible(true); | 348 waitForSelectActionBarVisible(true); |
| 321 assertTrue(mSelectionPopupController.hasSelection()); | 349 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 322 assertTrue(mSelectionPopupController.isActionModeValid()); | 350 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 323 selectActionBarCopy(); | 351 selectActionBarCopy(); |
| 324 waitForClipboardContents(mContentViewCore.getContext(), "SamplePlainText
One"); | 352 waitForClipboardContents(mContentViewCore.getContext(), "SamplePlainText
One"); |
| 325 DOMUtils.longPressNode(mContentViewCore, "password"); | 353 DOMUtils.longPressNode(mContentViewCore, "password"); |
| 326 waitForSelectActionBarVisible(true); | 354 waitForSelectActionBarVisible(true); |
| 327 assertTrue(mSelectionPopupController.hasSelection()); | 355 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 328 assertTrue(mSelectionPopupController.isActionModeValid()); | 356 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 329 selectActionBarCopy(); | 357 selectActionBarCopy(); |
| 330 // Copy option won't be there for Password, hence no change in Clipboard | 358 // Copy option won't be there for Password, hence no change in Clipboard |
| 331 // Validating with previous Clipboard content | 359 // Validating with previous Clipboard content |
| 332 waitForClipboardContents(mContentViewCore.getContext(), "SamplePlainText
One"); | 360 waitForClipboardContents(mContentViewCore.getContext(), "SamplePlainText
One"); |
| 333 } | 361 } |
| 334 | 362 |
| 363 @Test |
| 335 @SmallTest | 364 @SmallTest |
| 336 @Feature({"TextInput"}) | 365 @Feature({"TextInput"}) |
| 337 @DisabledTest(message = "crbug.com/592428") | 366 @DisabledTest(message = "crbug.com/592428") |
| 338 public void testSelectActionBarTextAreaCopy() throws Exception { | 367 public void testSelectActionBarTextAreaCopy() throws Exception { |
| 339 DOMUtils.longPressNode(mContentViewCore, "textarea"); | 368 DOMUtils.longPressNode(mContentViewCore, "textarea"); |
| 340 waitForSelectActionBarVisible(true); | 369 waitForSelectActionBarVisible(true); |
| 341 assertTrue(mSelectionPopupController.hasSelection()); | 370 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 342 assertTrue(mSelectionPopupController.isActionModeValid()); | 371 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 343 selectActionBarCopy(); | 372 selectActionBarCopy(); |
| 344 waitForClipboardContents(mContentViewCore.getContext(), "SampleTextArea"
); | 373 waitForClipboardContents(mContentViewCore.getContext(), "SampleTextArea"
); |
| 345 } | 374 } |
| 346 | 375 |
| 376 @Test |
| 347 @SmallTest | 377 @SmallTest |
| 348 @Feature({"TextSelection"}) | 378 @Feature({"TextSelection"}) |
| 349 @DisabledTest(message = "crbug.com/592428") | 379 @DisabledTest(message = "crbug.com/592428") |
| 350 public void testSelectActionBarPlainTextCut() throws Exception { | 380 public void testSelectActionBarPlainTextCut() throws Throwable { |
| 351 copyStringToClipboard("SampleTextToCopy"); | 381 copyStringToClipboard("SampleTextToCopy"); |
| 352 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); | 382 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); |
| 353 waitForSelectActionBarVisible(true); | 383 waitForSelectActionBarVisible(true); |
| 354 assertTrue(mSelectionPopupController.hasSelection()); | 384 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 355 assertEquals(mSelectionPopupController.getSelectedText(), "SamplePlainTe
xtOne"); | 385 Assert.assertEquals(mSelectionPopupController.getSelectedText(), "Sample
PlainTextOne"); |
| 356 assertTrue(mSelectionPopupController.isActionModeValid()); | 386 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 357 selectActionBarCut(); | 387 selectActionBarCut(); |
| 358 waitForSelectActionBarVisible(true); | 388 waitForSelectActionBarVisible(true); |
| 359 assertTrue(mSelectionPopupController.hasSelection()); | 389 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 360 // Cut option won't be available for plain text. | 390 // Cut option won't be available for plain text. |
| 361 // Hence validating previous Clipboard content. | 391 // Hence validating previous Clipboard content. |
| 362 waitForClipboardContents(mContentViewCore.getContext(), "SampleTextToCop
y"); | 392 waitForClipboardContents(mContentViewCore.getContext(), "SampleTextToCop
y"); |
| 363 } | 393 } |
| 364 | 394 |
| 395 @Test |
| 365 @SmallTest | 396 @SmallTest |
| 366 @Feature({"TextInput"}) | 397 @Feature({"TextInput"}) |
| 367 @DisabledTest(message = "crbug.com/592428") | 398 @DisabledTest(message = "crbug.com/592428") |
| 368 public void testSelectActionBarInputCut() throws Exception { | 399 public void testSelectActionBarInputCut() throws Exception { |
| 369 DOMUtils.longPressNode(mContentViewCore, "input_text"); | 400 DOMUtils.longPressNode(mContentViewCore, "input_text"); |
| 370 waitForSelectActionBarVisible(true); | 401 waitForSelectActionBarVisible(true); |
| 371 assertTrue(mSelectionPopupController.hasSelection()); | 402 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 372 assertEquals(mSelectionPopupController.getSelectedText(), "SampleInputTe
xt"); | 403 Assert.assertEquals(mSelectionPopupController.getSelectedText(), "Sample
InputText"); |
| 373 assertTrue(mSelectionPopupController.isActionModeValid()); | 404 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 374 selectActionBarCut(); | 405 selectActionBarCut(); |
| 375 waitForSelectActionBarVisible(false); | 406 waitForSelectActionBarVisible(false); |
| 376 assertFalse(mSelectionPopupController.hasSelection()); | 407 Assert.assertFalse(mSelectionPopupController.hasSelection()); |
| 377 waitForClipboardContents(mContentViewCore.getContext(), "SampleInputText
"); | 408 waitForClipboardContents(mContentViewCore.getContext(), "SampleInputText
"); |
| 378 assertEquals(mSelectionPopupController.getSelectedText(), ""); | 409 Assert.assertEquals(mSelectionPopupController.getSelectedText(), ""); |
| 379 } | 410 } |
| 380 | 411 |
| 381 @SmallTest | 412 @Test |
| 382 @Feature({"TextInput"}) | 413 @SmallTest |
| 383 @DisabledTest(message = "crbug.com/592428") | 414 @Feature({"TextInput"}) |
| 384 public void testSelectActionBarPasswordCut() throws Exception { | 415 @DisabledTest(message = "crbug.com/592428") |
| 416 public void testSelectActionBarPasswordCut() throws Throwable { |
| 385 copyStringToClipboard("SampleTextToCopy"); | 417 copyStringToClipboard("SampleTextToCopy"); |
| 386 DOMUtils.longPressNode(mContentViewCore, "password"); | 418 DOMUtils.longPressNode(mContentViewCore, "password"); |
| 387 waitForSelectActionBarVisible(true); | 419 waitForSelectActionBarVisible(true); |
| 388 assertTrue(mSelectionPopupController.hasSelection()); | 420 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 389 assertTrue(mSelectionPopupController.isActionModeValid()); | 421 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 390 selectActionBarCut(); | 422 selectActionBarCut(); |
| 391 waitForSelectActionBarVisible(true); | 423 waitForSelectActionBarVisible(true); |
| 392 assertTrue(mSelectionPopupController.hasSelection()); | 424 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 393 // Cut option won't be there for Password, hence no change in Clipboard | 425 // Cut option won't be there for Password, hence no change in Clipboard |
| 394 // Validating with previous Clipboard content | 426 // Validating with previous Clipboard content |
| 395 waitForClipboardContents(mContentViewCore.getContext(), "SampleTextToCop
y"); | 427 waitForClipboardContents(mContentViewCore.getContext(), "SampleTextToCop
y"); |
| 396 } | 428 } |
| 397 | 429 |
| 430 @Test |
| 398 @SmallTest | 431 @SmallTest |
| 399 @Feature({"TextInput"}) | 432 @Feature({"TextInput"}) |
| 400 @DisabledTest(message = "crbug.com/592428") | 433 @DisabledTest(message = "crbug.com/592428") |
| 401 public void testSelectActionBarTextAreaCut() throws Exception { | 434 public void testSelectActionBarTextAreaCut() throws Exception { |
| 402 DOMUtils.longPressNode(mContentViewCore, "textarea"); | 435 DOMUtils.longPressNode(mContentViewCore, "textarea"); |
| 403 waitForSelectActionBarVisible(true); | 436 waitForSelectActionBarVisible(true); |
| 404 assertTrue(mSelectionPopupController.hasSelection()); | 437 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 405 assertEquals(mSelectionPopupController.getSelectedText(), "SampleTextAre
a"); | 438 Assert.assertEquals(mSelectionPopupController.getSelectedText(), "Sample
TextArea"); |
| 406 assertTrue(mSelectionPopupController.isActionModeValid()); | 439 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 407 selectActionBarCut(); | 440 selectActionBarCut(); |
| 408 waitForSelectActionBarVisible(false); | 441 waitForSelectActionBarVisible(false); |
| 409 assertFalse(mSelectionPopupController.hasSelection()); | 442 Assert.assertFalse(mSelectionPopupController.hasSelection()); |
| 410 waitForClipboardContents(mContentViewCore.getContext(), "SampleTextArea"
); | 443 waitForClipboardContents(mContentViewCore.getContext(), "SampleTextArea"
); |
| 411 assertEquals(mSelectionPopupController.getSelectedText(), ""); | 444 Assert.assertEquals(mSelectionPopupController.getSelectedText(), ""); |
| 412 } | 445 } |
| 413 | 446 |
| 447 @Test |
| 414 @SmallTest | 448 @SmallTest |
| 415 @Feature({"TextSelection"}) | 449 @Feature({"TextSelection"}) |
| 416 @DisabledTest(message = "crbug.com/592428") | 450 @DisabledTest(message = "crbug.com/592428") |
| 417 public void testSelectActionBarPlainTextSelectAll() throws Exception { | 451 public void testSelectActionBarPlainTextSelectAll() throws Exception { |
| 418 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); | 452 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); |
| 419 waitForSelectActionBarVisible(true); | 453 waitForSelectActionBarVisible(true); |
| 420 assertTrue(mSelectionPopupController.hasSelection()); | 454 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 421 assertTrue(mSelectionPopupController.isActionModeValid()); | 455 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 422 selectActionBarSelectAll(); | 456 selectActionBarSelectAll(); |
| 423 assertTrue(mSelectionPopupController.hasSelection()); | 457 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 424 waitForSelectActionBarVisible(true); | 458 waitForSelectActionBarVisible(true); |
| 425 } | 459 } |
| 426 | 460 |
| 461 @Test |
| 427 @SmallTest | 462 @SmallTest |
| 428 @Feature({"TextInput"}) | 463 @Feature({"TextInput"}) |
| 429 @DisabledTest(message = "crbug.com/592428") | 464 @DisabledTest(message = "crbug.com/592428") |
| 430 public void testSelectActionBarInputSelectAll() throws Exception { | 465 public void testSelectActionBarInputSelectAll() throws Exception { |
| 431 DOMUtils.longPressNode(mContentViewCore, "input_text"); | 466 DOMUtils.longPressNode(mContentViewCore, "input_text"); |
| 432 waitForSelectActionBarVisible(true); | 467 waitForSelectActionBarVisible(true); |
| 433 assertTrue(mSelectionPopupController.hasSelection()); | 468 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 434 assertTrue(mSelectionPopupController.isActionModeValid()); | 469 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 435 selectActionBarSelectAll(); | 470 selectActionBarSelectAll(); |
| 436 assertTrue(mSelectionPopupController.hasSelection()); | 471 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 437 waitForSelectActionBarVisible(true); | 472 waitForSelectActionBarVisible(true); |
| 438 assertEquals(mSelectionPopupController.getSelectedText(), "SampleInputTe
xt"); | 473 Assert.assertEquals(mSelectionPopupController.getSelectedText(), "Sample
InputText"); |
| 439 } | 474 } |
| 440 | 475 |
| 476 @Test |
| 441 @SmallTest | 477 @SmallTest |
| 442 @Feature({"TextInput"}) | 478 @Feature({"TextInput"}) |
| 443 @DisabledTest(message = "crbug.com/592428") | 479 @DisabledTest(message = "crbug.com/592428") |
| 444 public void testSelectActionBarPasswordSelectAll() throws Exception { | 480 public void testSelectActionBarPasswordSelectAll() throws Exception { |
| 445 DOMUtils.longPressNode(mContentViewCore, "password"); | 481 DOMUtils.longPressNode(mContentViewCore, "password"); |
| 446 waitForSelectActionBarVisible(true); | 482 waitForSelectActionBarVisible(true); |
| 447 assertTrue(mSelectionPopupController.hasSelection()); | 483 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 448 assertTrue(mSelectionPopupController.isActionModeValid()); | 484 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 449 selectActionBarSelectAll(); | 485 selectActionBarSelectAll(); |
| 450 assertTrue(mSelectionPopupController.hasSelection()); | 486 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 451 waitForSelectActionBarVisible(true); | 487 waitForSelectActionBarVisible(true); |
| 452 } | 488 } |
| 453 | 489 |
| 490 @Test |
| 454 @SmallTest | 491 @SmallTest |
| 455 @Feature({"TextInput"}) | 492 @Feature({"TextInput"}) |
| 456 @DisabledTest(message = "crbug.com/592428") | 493 @DisabledTest(message = "crbug.com/592428") |
| 457 public void testSelectActionBarTextAreaSelectAll() throws Exception { | 494 public void testSelectActionBarTextAreaSelectAll() throws Exception { |
| 458 DOMUtils.longPressNode(mContentViewCore, "textarea"); | 495 DOMUtils.longPressNode(mContentViewCore, "textarea"); |
| 459 waitForSelectActionBarVisible(true); | 496 waitForSelectActionBarVisible(true); |
| 460 assertTrue(mSelectionPopupController.hasSelection()); | 497 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 461 assertTrue(mSelectionPopupController.isActionModeValid()); | 498 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 462 selectActionBarSelectAll(); | 499 selectActionBarSelectAll(); |
| 463 assertTrue(mSelectionPopupController.hasSelection()); | 500 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 464 waitForSelectActionBarVisible(true); | 501 waitForSelectActionBarVisible(true); |
| 465 assertEquals(mSelectionPopupController.getSelectedText(), "SampleTextAre
a"); | 502 Assert.assertEquals(mSelectionPopupController.getSelectedText(), "Sample
TextArea"); |
| 466 } | 503 } |
| 467 | 504 |
| 468 private CharSequence getTextBeforeCursor(final int length, final int flags)
{ | 505 private CharSequence getTextBeforeCursor(final int length, final int flags)
{ |
| 469 final ChromiumBaseInputConnection connection = | 506 final ChromiumBaseInputConnection connection = |
| 470 mContentViewCore.getImeAdapterForTest().getInputConnectionForTes
t(); | 507 mContentViewCore.getImeAdapterForTest().getInputConnectionForTes
t(); |
| 471 return ImeTestUtils.runBlockingOnHandlerNoException( | 508 return ImeTestUtils.runBlockingOnHandlerNoException( |
| 472 connection.getHandler(), new Callable<CharSequence>() { | 509 connection.getHandler(), new Callable<CharSequence>() { |
| 473 @Override | 510 @Override |
| 474 public CharSequence call() throws Exception { | 511 public CharSequence call() throws Exception { |
| 475 return connection.getTextBeforeCursor(length, flags); | 512 return connection.getTextBeforeCursor(length, flags); |
| 476 } | 513 } |
| 477 }); | 514 }); |
| 478 } | 515 } |
| 479 | 516 |
| 480 /** | 517 /** |
| 481 * @SmallTest | 518 * @SmallTest |
| 482 * @Feature({"TextSelection", "TextInput"}) | 519 * @Feature({"TextSelection", "TextInput"}) |
| 483 */ | 520 */ |
| 521 @Test |
| 484 @DisabledTest(message = "http://crbug.com/606942") | 522 @DisabledTest(message = "http://crbug.com/606942") |
| 485 public void testCursorPositionAfterHidingActionMode() throws Exception { | 523 public void testCursorPositionAfterHidingActionMode() throws Exception { |
| 486 DOMUtils.longPressNode(mContentViewCore, "textarea"); | 524 DOMUtils.longPressNode(mContentViewCore, "textarea"); |
| 487 waitForSelectActionBarVisible(true); | 525 waitForSelectActionBarVisible(true); |
| 488 assertTrue(mSelectionPopupController.hasSelection()); | 526 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 489 assertTrue(mSelectionPopupController.isActionModeValid()); | 527 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 490 selectActionBarSelectAll(); | 528 selectActionBarSelectAll(); |
| 491 assertTrue(mSelectionPopupController.hasSelection()); | 529 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 492 waitForSelectActionBarVisible(true); | 530 waitForSelectActionBarVisible(true); |
| 493 assertEquals(mSelectionPopupController.getSelectedText(), "SampleTextAre
a"); | 531 Assert.assertEquals(mSelectionPopupController.getSelectedText(), "Sample
TextArea"); |
| 494 hideSelectActionMode(); | 532 hideSelectActionMode(); |
| 495 waitForSelectActionBarVisible(false); | 533 waitForSelectActionBarVisible(false); |
| 496 CriteriaHelper.pollInstrumentationThread( | 534 CriteriaHelper.pollInstrumentationThread( |
| 497 Criteria.equals("SampleTextArea", new Callable<CharSequence>() { | 535 Criteria.equals("SampleTextArea", new Callable<CharSequence>() { |
| 498 @Override | 536 @Override |
| 499 public CharSequence call() { | 537 public CharSequence call() { |
| 500 return getTextBeforeCursor(50, 0); | 538 return getTextBeforeCursor(50, 0); |
| 501 } | 539 } |
| 502 })); | 540 })); |
| 503 } | 541 } |
| 504 | 542 |
| 543 @Test |
| 505 @SmallTest | 544 @SmallTest |
| 506 @Feature({"TextSelection"}) | 545 @Feature({"TextSelection"}) |
| 507 @DisabledTest(message = "crbug.com/592428") | 546 @DisabledTest(message = "crbug.com/592428") |
| 508 public void testSelectActionBarPlainTextPaste() throws Exception { | 547 public void testSelectActionBarPlainTextPaste() throws Throwable { |
| 509 copyStringToClipboard("SampleTextToCopy"); | 548 copyStringToClipboard("SampleTextToCopy"); |
| 510 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); | 549 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); |
| 511 waitForSelectActionBarVisible(true); | 550 waitForSelectActionBarVisible(true); |
| 512 assertTrue(mSelectionPopupController.hasSelection()); | 551 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 513 assertTrue(mSelectionPopupController.isActionModeValid()); | 552 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 514 selectActionBarPaste(); | 553 selectActionBarPaste(); |
| 515 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); | 554 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); |
| 516 waitForSelectActionBarVisible(true); | 555 waitForSelectActionBarVisible(true); |
| 517 assertTrue(mSelectionPopupController.hasSelection()); | 556 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 518 // Paste option won't be available for plain text. | 557 // Paste option won't be available for plain text. |
| 519 // Hence content won't be changed. | 558 // Hence content won't be changed. |
| 520 assertNotSame(mSelectionPopupController.getSelectedText(), "SampleTextTo
Copy"); | 559 Assert.assertNotSame(mSelectionPopupController.getSelectedText(), "Sampl
eTextToCopy"); |
| 521 } | 560 } |
| 522 | 561 |
| 562 @Test |
| 523 @SmallTest | 563 @SmallTest |
| 524 @Feature({"TextInput"}) | 564 @Feature({"TextInput"}) |
| 525 @DisabledTest(message = "crbug.com/592428") | 565 @DisabledTest(message = "crbug.com/592428") |
| 526 public void testSelectActionBarInputPaste() throws Exception { | 566 public void testSelectActionBarInputPaste() throws Throwable { |
| 527 copyStringToClipboard("SampleTextToCopy"); | 567 copyStringToClipboard("SampleTextToCopy"); |
| 528 | 568 |
| 529 // Select the input field. | 569 // Select the input field. |
| 530 DOMUtils.longPressNode(mContentViewCore, "input_text"); | 570 DOMUtils.longPressNode(mContentViewCore, "input_text"); |
| 531 waitForSelectActionBarVisible(true); | 571 waitForSelectActionBarVisible(true); |
| 532 assertTrue(mSelectionPopupController.hasSelection()); | 572 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 533 | 573 |
| 534 // Paste into the input field. | 574 // Paste into the input field. |
| 535 assertTrue(mSelectionPopupController.isActionModeValid()); | 575 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 536 selectActionBarPaste(); | 576 selectActionBarPaste(); |
| 537 waitForSelectActionBarVisible(false); | 577 waitForSelectActionBarVisible(false); |
| 538 assertFalse(mSelectionPopupController.hasSelection()); | 578 Assert.assertFalse(mSelectionPopupController.hasSelection()); |
| 539 | 579 |
| 540 // Ensure the new text matches the pasted text. | 580 // Ensure the new text matches the pasted text. |
| 541 DOMUtils.longPressNode(mContentViewCore, "input_text"); | 581 DOMUtils.longPressNode(mContentViewCore, "input_text"); |
| 542 waitForSelectActionBarVisible(true); | 582 waitForSelectActionBarVisible(true); |
| 543 assertTrue(mSelectionPopupController.hasSelection()); | 583 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 544 assertEquals("SampleTextToCopy", mSelectionPopupController.getSelectedTe
xt()); | 584 Assert.assertEquals("SampleTextToCopy", mSelectionPopupController.getSel
ectedText()); |
| 545 } | 585 } |
| 546 | 586 |
| 547 /* | 587 /* |
| 548 @SmallTest | 588 @SmallTest |
| 549 @Feature({"TextInput"}) | 589 @Feature({"TextInput"}) |
| 550 */ | 590 */ |
| 591 @Test |
| 551 @DisabledTest(message = "https://crbug.com/592428") | 592 @DisabledTest(message = "https://crbug.com/592428") |
| 552 public void testSelectActionBarPasswordPaste() throws Exception { | 593 public void testSelectActionBarPasswordPaste() throws Throwable { |
| 553 copyStringToClipboard("SamplePassword2"); | 594 copyStringToClipboard("SamplePassword2"); |
| 554 | 595 |
| 555 // Select the password field. | 596 // Select the password field. |
| 556 DOMUtils.longPressNode(mContentViewCore, "password"); | 597 DOMUtils.longPressNode(mContentViewCore, "password"); |
| 557 waitForSelectActionBarVisible(true); | 598 waitForSelectActionBarVisible(true); |
| 558 assertTrue(mSelectionPopupController.hasSelection()); | 599 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 559 assertEquals(mSelectionPopupController.getSelectedText().length(), | 600 Assert.assertEquals( |
| 560 "SamplePassword".length()); | 601 mSelectionPopupController.getSelectedText().length(), "SamplePas
sword".length()); |
| 561 | 602 |
| 562 // Paste "SamplePassword2" into the password field, replacing | 603 // Paste "SamplePassword2" into the password field, replacing |
| 563 // "SamplePassword". | 604 // "SamplePassword". |
| 564 assertTrue(mSelectionPopupController.isActionModeValid()); | 605 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 565 selectActionBarPaste(); | 606 selectActionBarPaste(); |
| 566 waitForSelectActionBarVisible(false); | 607 waitForSelectActionBarVisible(false); |
| 567 assertFalse(mSelectionPopupController.hasSelection()); | 608 Assert.assertFalse(mSelectionPopupController.hasSelection()); |
| 568 | 609 |
| 569 // Ensure the new text matches the pasted text. Note that we can't | 610 // Ensure the new text matches the pasted text. Note that we can't |
| 570 // actually compare strings as password field selections only provide | 611 // actually compare strings as password field selections only provide |
| 571 // a placeholder with the correct length. | 612 // a placeholder with the correct length. |
| 572 DOMUtils.longPressNode(mContentViewCore, "password"); | 613 DOMUtils.longPressNode(mContentViewCore, "password"); |
| 573 waitForSelectActionBarVisible(true); | 614 waitForSelectActionBarVisible(true); |
| 574 assertTrue(mSelectionPopupController.hasSelection()); | 615 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 575 assertEquals(mSelectionPopupController.getSelectedText().length(), | 616 Assert.assertEquals( |
| 576 "SamplePassword2".length()); | 617 mSelectionPopupController.getSelectedText().length(), "SamplePas
sword2".length()); |
| 577 } | 618 } |
| 578 | 619 |
| 620 @Test |
| 579 @SmallTest | 621 @SmallTest |
| 580 @Feature({"TextInput"}) | 622 @Feature({"TextInput"}) |
| 581 @DisabledTest(message = "crbug.com/592428") | 623 @DisabledTest(message = "crbug.com/592428") |
| 582 public void testSelectActionBarTextAreaPaste() throws Exception { | 624 public void testSelectActionBarTextAreaPaste() throws Throwable { |
| 583 copyStringToClipboard("SampleTextToCopy"); | 625 copyStringToClipboard("SampleTextToCopy"); |
| 584 DOMUtils.longPressNode(mContentViewCore, "textarea"); | 626 DOMUtils.longPressNode(mContentViewCore, "textarea"); |
| 585 waitForSelectActionBarVisible(true); | 627 waitForSelectActionBarVisible(true); |
| 586 assertTrue(mSelectionPopupController.hasSelection()); | 628 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 587 assertTrue(mSelectionPopupController.isActionModeValid()); | 629 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 588 selectActionBarPaste(); | 630 selectActionBarPaste(); |
| 589 DOMUtils.clickNode(mContentViewCore, "plain_text_1"); | 631 DOMUtils.clickNode(mContentViewCore, "plain_text_1"); |
| 590 DOMUtils.longPressNode(mContentViewCore, "textarea"); | 632 DOMUtils.longPressNode(mContentViewCore, "textarea"); |
| 591 waitForSelectActionBarVisible(true); | 633 waitForSelectActionBarVisible(true); |
| 592 assertTrue(mSelectionPopupController.hasSelection()); | 634 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 593 assertEquals(mSelectionPopupController.getSelectedText(), "SampleTextToC
opy"); | 635 Assert.assertEquals(mSelectionPopupController.getSelectedText(), "Sample
TextToCopy"); |
| 594 } | 636 } |
| 595 | 637 |
| 638 @Test |
| 596 @SmallTest | 639 @SmallTest |
| 597 @Feature({"TextInput"}) | 640 @Feature({"TextInput"}) |
| 598 @DisabledTest(message = "crbug.com/592428") | 641 @DisabledTest(message = "crbug.com/592428") |
| 599 public void testSelectActionBarSearchAndShareLaunchesNewTask() throws Except
ion { | 642 public void testSelectActionBarSearchAndShareLaunchesNewTask() throws Except
ion { |
| 600 DOMUtils.longPressNode(mContentViewCore, "textarea"); | 643 DOMUtils.longPressNode(mContentViewCore, "textarea"); |
| 601 waitForSelectActionBarVisible(true); | 644 waitForSelectActionBarVisible(true); |
| 602 assertTrue(mSelectionPopupController.hasSelection()); | 645 Assert.assertTrue(mSelectionPopupController.hasSelection()); |
| 603 assertTrue(mSelectionPopupController.isActionModeValid()); | 646 Assert.assertTrue(mSelectionPopupController.isActionModeValid()); |
| 604 selectActionBarSearch(); | 647 selectActionBarSearch(); |
| 605 Intent i = getActivity().getLastSentIntent(); | 648 Intent i = mActivityTestRule.getActivity().getLastSentIntent(); |
| 606 int new_task_flag = Intent.FLAG_ACTIVITY_NEW_TASK; | 649 int new_task_flag = Intent.FLAG_ACTIVITY_NEW_TASK; |
| 607 assertEquals(i.getFlags() & new_task_flag, new_task_flag); | 650 Assert.assertEquals(i.getFlags() & new_task_flag, new_task_flag); |
| 608 | 651 |
| 609 selectActionBarShare(); | 652 selectActionBarShare(); |
| 610 i = getActivity().getLastSentIntent(); | 653 i = mActivityTestRule.getActivity().getLastSentIntent(); |
| 611 assertEquals(i.getFlags() & new_task_flag, new_task_flag); | 654 Assert.assertEquals(i.getFlags() & new_task_flag, new_task_flag); |
| 612 } | 655 } |
| 613 | 656 |
| 614 private void selectActionBarPaste() { | 657 private void selectActionBarPaste() { |
| 615 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 658 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 616 @Override | 659 @Override |
| 617 public void run() { | 660 public void run() { |
| 618 mSelectionPopupController.paste(); | 661 mSelectionPopupController.paste(); |
| 619 } | 662 } |
| 620 }); | 663 }); |
| 621 } | 664 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 private void requestFocusOnUiThread(final boolean gainFocus) { | 770 private void requestFocusOnUiThread(final boolean gainFocus) { |
| 728 final ContentViewCore contentViewCore = mContentViewCore; | 771 final ContentViewCore contentViewCore = mContentViewCore; |
| 729 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 772 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 730 @Override | 773 @Override |
| 731 public void run() { | 774 public void run() { |
| 732 contentViewCore.onFocusChanged(gainFocus, true); | 775 contentViewCore.onFocusChanged(gainFocus, true); |
| 733 } | 776 } |
| 734 }); | 777 }); |
| 735 } | 778 } |
| 736 | 779 |
| 737 private void copyStringToClipboard(String string) { | 780 private void copyStringToClipboard(final String string) throws Throwable { |
| 738 ClipboardManager clipboardManager = | 781 mActivityTestRule.runOnUiThread(new Runnable() { |
| 739 (ClipboardManager) getActivity().getSystemService( | 782 @Override |
| 740 Context.CLIPBOARD_SERVICE); | 783 public void run() { |
| 741 ClipData clip = ClipData.newPlainText("test", string); | 784 ClipboardManager clipboardManager = |
| 742 clipboardManager.setPrimaryClip(clip); | 785 (ClipboardManager) mActivityTestRule.getActivity().getSy
stemService( |
| 786 Context.CLIPBOARD_SERVICE); |
| 787 ClipData clip = ClipData.newPlainText("test", string); |
| 788 clipboardManager.setPrimaryClip(clip); |
| 789 } |
| 790 }); |
| 743 } | 791 } |
| 744 | 792 |
| 745 private void waitForPastePopupStatus(final boolean show) { | 793 private void waitForPastePopupStatus(final boolean show) { |
| 746 CriteriaHelper.pollUiThread(Criteria.equals(show, new Callable<Boolean>(
) { | 794 CriteriaHelper.pollUiThread(Criteria.equals(show, new Callable<Boolean>(
) { |
| 747 @Override | 795 @Override |
| 748 public Boolean call() { | 796 public Boolean call() { |
| 749 return mSelectionPopupController.isPastePopupShowing(); | 797 return mSelectionPopupController.isPastePopupShowing(); |
| 750 } | 798 } |
| 751 })); | 799 })); |
| 752 } | 800 } |
| 753 | 801 |
| 754 private void waitForInsertion(final boolean show) { | 802 private void waitForInsertion(final boolean show) { |
| 755 CriteriaHelper.pollUiThread(Criteria.equals(show, new Callable<Boolean>(
) { | 803 CriteriaHelper.pollUiThread(Criteria.equals(show, new Callable<Boolean>(
) { |
| 756 @Override | 804 @Override |
| 757 public Boolean call() { | 805 public Boolean call() { |
| 758 return mSelectionPopupController.isInsertion(); | 806 return mSelectionPopupController.isInsertion(); |
| 759 } | 807 } |
| 760 })); | 808 })); |
| 761 } | 809 } |
| 762 } | 810 } |
| OLD | NEW |