Chromium Code Reviews| 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.test.suitebuilder.annotation.SmallTest; | 10 import android.test.suitebuilder.annotation.SmallTest; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * Integration tests for text selection-related behavior. | 24 * Integration tests for text selection-related behavior. |
| 25 */ | 25 */ |
| 26 public class ContentViewCoreSelectionTest extends ContentShellTestBase { | 26 public class ContentViewCoreSelectionTest extends ContentShellTestBase { |
| 27 private static final String DATA_URL = UrlUtils.encodeHtmlDataUri( | 27 private static final String DATA_URL = UrlUtils.encodeHtmlDataUri( |
| 28 "<html><head><meta name=\"viewport\"" | 28 "<html><head><meta name=\"viewport\"" |
| 29 + "content=\"width=device-width, initial-scale=1.1, maximum-scale=1. 5\" /></head>" | 29 + "content=\"width=device-width, initial-scale=1.1, maximum-scale=1. 5\" /></head>" |
| 30 + "<body><form action=\"about:blank\">" | 30 + "<body><form action=\"about:blank\">" |
| 31 + "<input id=\"empty_input_text\" type=\"text\" />" | 31 + "<input id=\"empty_input_text\" type=\"text\" />" |
| 32 + "<br/><input id=\"input_text\" type=\"text\" value=\"SampleInputTe xt\" />" | |
| 33 + "<br/><textarea id=\"textarea\" rows=\"2\" cols=\"20\">SampleTextA rea</textarea>" | |
| 34 + "<br/><input id=\"input_password\" type=\"password\" value=\"Sampl ePassword\" />" | |
| 32 + "<br/><p><span id=\"plain_text_1\">SamplePlainTextOne</span></p>" | 35 + "<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
| |
| 33 + "<br/><p><span id=\"plain_text_2\">SamplePlainTextTwo</span></p>" | 36 + "<br/><p><span id=\"plain_text_2\">SamplePlainTextTwo</span></p>" |
| 34 + "<br/><input id=\"empty_input_text\" type=\"text\" />" | |
| 35 + "<br/><input id=\"input_text\" type=\"text\" value=\"SampleInputTe xt\" />" | |
| 36 + "<br/><textarea id=\"empty_textarea\" rows=\"2\" cols=\"20\"></tex tarea>" | |
| 37 + "<br/><textarea id=\"textarea\" rows=\"2\" cols=\"20\">Sample Text </textarea>" | |
| 38 + "<br/><input id=\"readonly_text\" type=\"text\" readonly value=\"S ample Text\"/>" | 37 + "<br/><input id=\"readonly_text\" type=\"text\" readonly value=\"S ample Text\"/>" |
| 39 + "<br/><input id=\"disabled_text\" type=\"text\" disabled value=\"S ample Text\" />" | 38 + "<br/><input id=\"disabled_text\" type=\"text\" disabled value=\"S ample Text\" />" |
| 40 + "<br/><input id=\"input_password\" type=\"password\" value=\"Sampl ePassword\" />" | |
| 41 + "</form></body></html>"); | 39 + "</form></body></html>"); |
| 42 private ContentViewCore mContentViewCore; | 40 private ContentViewCore mContentViewCore; |
| 43 | 41 |
| 44 @Override | 42 @Override |
| 45 public void setUp() throws Exception { | 43 public void setUp() throws Exception { |
| 46 super.setUp(); | 44 super.setUp(); |
| 47 | 45 |
| 48 launchContentShellWithUrl(DATA_URL); | 46 launchContentShellWithUrl(DATA_URL); |
| 49 assertTrue("Page failed to load", waitForActiveShellToBeDoneLoading()); | 47 assertTrue("Page failed to load", waitForActiveShellToBeDoneLoading()); |
| 50 | 48 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 assertTrue(mContentViewCore.hasSelection()); | 121 assertTrue(mContentViewCore.hasSelection()); |
| 124 | 122 |
| 125 setAttachedOnUiThread(true); | 123 setAttachedOnUiThread(true); |
| 126 assertWaitForSelectActionBarVisible(true); | 124 assertWaitForSelectActionBarVisible(true); |
| 127 assertTrue(mContentViewCore.hasSelection()); | 125 assertTrue(mContentViewCore.hasSelection()); |
| 128 } | 126 } |
| 129 | 127 |
| 130 @SmallTest | 128 @SmallTest |
| 131 @Feature({"TextInput"}) | 129 @Feature({"TextInput"}) |
| 132 public void testPastePopupNotShownOnLongPressingNonEmptyInput() throws Throw able { | 130 public void testPastePopupNotShownOnLongPressingNonEmptyInput() throws Throw able { |
| 133 copyStringToClipboard(); | 131 copyStringToClipboard("SampleTextToCopy"); |
| 134 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); | 132 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
| 135 assertWaitForPastePopupStatus(true); | 133 assertWaitForPastePopupStatus(true); |
| 136 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); | 134 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); |
| 137 assertWaitForSelectActionBarVisible(true); | 135 assertWaitForSelectActionBarVisible(true); |
| 138 assertWaitForPastePopupStatus(false); | 136 assertWaitForPastePopupStatus(false); |
| 139 } | 137 } |
| 140 | 138 |
| 141 @SmallTest | 139 @SmallTest |
| 142 @Feature({"TextInput"}) | 140 @Feature({"TextInput"}) |
| 143 public void testPastePopupClearedOnTappingEmptyInput() throws Throwable { | 141 public void testPastePopupClearedOnTappingEmptyInput() throws Throwable { |
| 144 copyStringToClipboard(); | 142 copyStringToClipboard("SampleTextToCopy"); |
| 145 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); | 143 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
| 146 assertWaitForPastePopupStatus(true); | 144 assertWaitForPastePopupStatus(true); |
| 147 DOMUtils.clickNode(this, mContentViewCore, "empty_input_text"); | 145 DOMUtils.clickNode(this, mContentViewCore, "empty_input_text"); |
| 148 assertWaitForPastePopupStatus(false); | 146 assertWaitForPastePopupStatus(false); |
| 149 } | 147 } |
| 150 | 148 |
| 151 @SmallTest | 149 @SmallTest |
| 152 @Feature({"TextInput"}) | 150 @Feature({"TextInput"}) |
| 153 public void testPastePopupClearedOnTappingNonEmptyInput() throws Throwable { | 151 public void testPastePopupClearedOnTappingNonEmptyInput() throws Throwable { |
| 154 copyStringToClipboard(); | 152 copyStringToClipboard("SampleTextToCopy"); |
| 155 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); | 153 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
| 156 assertWaitForPastePopupStatus(true); | 154 assertWaitForPastePopupStatus(true); |
| 157 DOMUtils.clickNode(this, mContentViewCore, "input_text"); | 155 DOMUtils.clickNode(this, mContentViewCore, "input_text"); |
| 158 assertWaitForPastePopupStatus(false); | 156 assertWaitForPastePopupStatus(false); |
| 159 } | 157 } |
| 160 | 158 |
| 161 @SmallTest | 159 @SmallTest |
| 162 @Feature({"TextInput"}) | 160 @Feature({"TextInput"}) |
| 163 public void testPastePopupClearedOnTappingOutsideInput() throws Throwable { | 161 public void testPastePopupClearedOnTappingOutsideInput() throws Throwable { |
| 164 copyStringToClipboard(); | 162 copyStringToClipboard("SampleTextToCopy"); |
| 165 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); | 163 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
| 166 assertWaitForPastePopupStatus(true); | 164 assertWaitForPastePopupStatus(true); |
| 167 DOMUtils.clickNode(this, mContentViewCore, "plain_text_2"); | 165 DOMUtils.clickNode(this, mContentViewCore, "plain_text_2"); |
| 168 assertWaitForPastePopupStatus(false); | 166 assertWaitForPastePopupStatus(false); |
| 169 } | 167 } |
| 170 | 168 |
| 171 @SmallTest | 169 @SmallTest |
| 172 @Feature({"TextInput"}) | 170 @Feature({"TextInput"}) |
| 173 public void testPastePopupClearedOnLongPressingOutsideInput() throws Throwab le { | 171 public void testPastePopupClearedOnLongPressingOutsideInput() throws Throwab le { |
| 174 copyStringToClipboard(); | 172 copyStringToClipboard("SampleTextToCopy"); |
| 175 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); | 173 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
| 176 assertWaitForPastePopupStatus(true); | 174 assertWaitForPastePopupStatus(true); |
| 177 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_2"); | 175 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_2"); |
| 178 assertWaitForPastePopupStatus(false); | 176 assertWaitForPastePopupStatus(false); |
| 179 } | 177 } |
| 180 | 178 |
| 181 @SmallTest | 179 @SmallTest |
| 182 @Feature({"TextInput"}) | 180 @Feature({"TextInput"}) |
| 183 public void testPastePopupNotShownOnLongPressingReadOnlyInput() throws Throw able { | 181 public void testPastePopupNotShownOnLongPressingReadOnlyInput() throws Throw able { |
| 184 copyStringToClipboard(); | 182 copyStringToClipboard("SampleTextToCopy"); |
| 185 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); | 183 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
| 186 assertWaitForPastePopupStatus(true); | 184 assertWaitForPastePopupStatus(true); |
| 187 assertTrue(mContentViewCore.hasInsertion()); | 185 assertTrue(mContentViewCore.hasInsertion()); |
| 188 DOMUtils.longPressNode(this, mContentViewCore, "readonly_text"); | 186 DOMUtils.longPressNode(this, mContentViewCore, "readonly_text"); |
| 189 assertWaitForPastePopupStatus(false); | 187 assertWaitForPastePopupStatus(false); |
| 190 assertFalse(mContentViewCore.hasInsertion()); | 188 assertFalse(mContentViewCore.hasInsertion()); |
| 191 } | 189 } |
| 192 | 190 |
| 193 @SmallTest | 191 @SmallTest |
| 194 @Feature({"TextInput"}) | 192 @Feature({"TextInput"}) |
| 195 public void testPastePopupNotShownOnLongPressingDisabledInput() throws Throw able { | 193 public void testPastePopupNotShownOnLongPressingDisabledInput() throws Throw able { |
| 196 copyStringToClipboard(); | 194 copyStringToClipboard("SampleTextToCopy"); |
| 197 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); | 195 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
| 198 assertWaitForPastePopupStatus(true); | 196 assertWaitForPastePopupStatus(true); |
| 199 assertTrue(mContentViewCore.hasInsertion()); | 197 assertTrue(mContentViewCore.hasInsertion()); |
| 200 DOMUtils.longPressNode(this, mContentViewCore, "disabled_text"); | 198 DOMUtils.longPressNode(this, mContentViewCore, "disabled_text"); |
| 201 assertWaitForPastePopupStatus(false); | 199 assertWaitForPastePopupStatus(false); |
| 202 assertFalse(mContentViewCore.hasInsertion()); | 200 assertFalse(mContentViewCore.hasInsertion()); |
| 203 } | 201 } |
| 204 | 202 |
| 205 @SmallTest | 203 @SmallTest |
| 206 @Feature({"TextInput"}) | 204 @Feature({"TextInput"}) |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 230 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); | 228 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); |
| 231 assertWaitForSelectActionBarVisible(true); | 229 assertWaitForSelectActionBarVisible(true); |
| 232 assertTrue(mContentViewCore.hasSelection()); | 230 assertTrue(mContentViewCore.hasSelection()); |
| 233 assertNotNull(mContentViewCore.getSelectActionHandler()); | 231 assertNotNull(mContentViewCore.getSelectActionHandler()); |
| 234 assertFalse(mContentViewCore.getSelectActionHandler().isSelectionEditabl e()); | 232 assertFalse(mContentViewCore.getSelectActionHandler().isSelectionEditabl e()); |
| 235 assertFalse(mContentViewCore.getSelectActionHandler().isSelectionPasswor d()); | 233 assertFalse(mContentViewCore.getSelectActionHandler().isSelectionPasswor d()); |
| 236 } | 234 } |
| 237 | 235 |
| 238 @SmallTest | 236 @SmallTest |
| 239 @Feature({"TextInput"}) | 237 @Feature({"TextInput"}) |
| 238 public void testActionBarConfiguredCorrectlyForTextArea() throws Throwable { | |
| 239 DOMUtils.longPressNode(this, mContentViewCore, "textarea"); | |
| 240 assertWaitForSelectActionBarVisible(true); | |
| 241 assertTrue(mContentViewCore.hasSelection()); | |
| 242 assertNotNull(mContentViewCore.getSelectActionHandler()); | |
| 243 assertTrue(mContentViewCore.getSelectActionHandler().isSelectionEditable ()); | |
| 244 assertFalse(mContentViewCore.getSelectActionHandler().isSelectionPasswor d()); | |
| 245 } | |
| 246 | |
| 247 @SmallTest | |
| 248 @Feature({"TextInput"}) | |
| 240 public void testSelectActionBarPlainTextCopy() throws Exception { | 249 public void testSelectActionBarPlainTextCopy() throws Exception { |
| 241 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); | 250 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); |
| 242 assertWaitForSelectActionBarVisible(true); | 251 assertWaitForSelectActionBarVisible(true); |
| 243 assertTrue(mContentViewCore.hasSelection()); | 252 assertTrue(mContentViewCore.hasSelection()); |
| 244 assertNotNull(mContentViewCore.getSelectActionHandler()); | 253 assertNotNull(mContentViewCore.getSelectActionHandler()); |
| 245 selectActionBarCopy(); | 254 selectActionBarCopy(); |
| 246 assertClipboardContents(mContentViewCore.getContext(), "SamplePlainTextO ne"); | 255 assertClipboardContents(mContentViewCore.getContext(), "SamplePlainTextO ne"); |
| 247 } | 256 } |
| 248 | 257 |
| 249 @SmallTest | 258 @SmallTest |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 269 DOMUtils.longPressNode(this, mContentViewCore, "input_password"); | 278 DOMUtils.longPressNode(this, mContentViewCore, "input_password"); |
| 270 assertWaitForSelectActionBarVisible(true); | 279 assertWaitForSelectActionBarVisible(true); |
| 271 assertTrue(mContentViewCore.hasSelection()); | 280 assertTrue(mContentViewCore.hasSelection()); |
| 272 assertNotNull(mContentViewCore.getSelectActionHandler()); | 281 assertNotNull(mContentViewCore.getSelectActionHandler()); |
| 273 selectActionBarCopy(); | 282 selectActionBarCopy(); |
| 274 // Copy option won't be there for Password, hence no change in Clipboard | 283 // Copy option won't be there for Password, hence no change in Clipboard |
| 275 // Validating with previous Clipboard content | 284 // Validating with previous Clipboard content |
| 276 assertClipboardContents(mContentViewCore.getContext(), "SamplePlainTextO ne"); | 285 assertClipboardContents(mContentViewCore.getContext(), "SamplePlainTextO ne"); |
| 277 } | 286 } |
| 278 | 287 |
| 288 @SmallTest | |
| 289 @Feature({"TextInput"}) | |
| 290 public void testSelectActionBarTextAreaCopy() throws Exception { | |
| 291 DOMUtils.longPressNode(this, mContentViewCore, "textarea"); | |
| 292 assertWaitForSelectActionBarVisible(true); | |
| 293 assertTrue(mContentViewCore.hasSelection()); | |
| 294 assertNotNull(mContentViewCore.getSelectActionHandler()); | |
| 295 selectActionBarCopy(); | |
| 296 assertClipboardContents(mContentViewCore.getContext(), "SampleTextArea") ; | |
| 297 } | |
| 298 | |
| 299 @SmallTest | |
| 300 @Feature({"TextSelection"}) | |
| 301 public void testSelectActionBarPlainTextCut() throws Exception { | |
| 302 copyStringToClipboard("SampleTextToCopy"); | |
| 303 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); | |
| 304 assertWaitForSelectActionBarVisible(true); | |
| 305 assertTrue(mContentViewCore.hasSelection()); | |
| 306 assertEquals(mContentViewCore.getSelectedText(), "SamplePlainTextOne"); | |
| 307 assertNotNull(mContentViewCore.getSelectActionHandler()); | |
| 308 selectActionBarCut(); | |
| 309 assertWaitForSelectActionBarVisible(true); | |
| 310 assertTrue(mContentViewCore.hasSelection()); | |
| 311 // Cut option won't be available for plain text. | |
| 312 // Hence validating previous Clipboard content. | |
| 313 assertClipboardContents(mContentViewCore.getContext(), "SampleTextToCopy "); | |
| 314 } | |
| 315 | |
| 316 @SmallTest | |
| 317 @Feature({"TextInput"}) | |
| 318 public void testSelectActionBarInputCut() throws Exception { | |
| 319 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); | |
| 320 assertWaitForSelectActionBarVisible(true); | |
| 321 assertTrue(mContentViewCore.hasSelection()); | |
| 322 assertEquals(mContentViewCore.getSelectedText(), "SampleInputText"); | |
| 323 assertNotNull(mContentViewCore.getSelectActionHandler()); | |
| 324 selectActionBarCut(); | |
| 325 assertWaitForSelectActionBarVisible(false); | |
| 326 assertFalse(mContentViewCore.hasSelection()); | |
| 327 assertClipboardContents(mContentViewCore.getContext(), "SampleInputText" ); | |
| 328 assertEquals(mContentViewCore.getSelectedText(), ""); | |
| 329 } | |
| 330 | |
| 331 @SmallTest | |
| 332 @Feature({"TextInput"}) | |
| 333 public void testSelectActionBarPasswordCut() throws Exception { | |
| 334 copyStringToClipboard("SampleTextToCopy"); | |
| 335 DOMUtils.longPressNode(this, mContentViewCore, "input_password"); | |
| 336 assertWaitForSelectActionBarVisible(true); | |
| 337 assertTrue(mContentViewCore.hasSelection()); | |
| 338 assertNotNull(mContentViewCore.getSelectActionHandler()); | |
| 339 selectActionBarCut(); | |
| 340 assertWaitForSelectActionBarVisible(true); | |
| 341 assertTrue(mContentViewCore.hasSelection()); | |
| 342 // Cut option won't be there for Password, hence no change in Clipboard | |
| 343 // Validating with previous Clipboard content | |
| 344 assertClipboardContents(mContentViewCore.getContext(), "SampleTextToCopy "); | |
| 345 } | |
| 346 | |
| 347 @SmallTest | |
| 348 @Feature({"TextInput"}) | |
| 349 public void testSelectActionBarTextAreaCut() throws Exception { | |
| 350 DOMUtils.longPressNode(this, mContentViewCore, "textarea"); | |
| 351 assertWaitForSelectActionBarVisible(true); | |
| 352 assertTrue(mContentViewCore.hasSelection()); | |
| 353 assertEquals(mContentViewCore.getSelectedText(), "SampleTextArea"); | |
| 354 assertNotNull(mContentViewCore.getSelectActionHandler()); | |
| 355 selectActionBarCut(); | |
| 356 assertWaitForSelectActionBarVisible(false); | |
| 357 assertFalse(mContentViewCore.hasSelection()); | |
| 358 assertClipboardContents(mContentViewCore.getContext(), "SampleTextArea") ; | |
| 359 assertEquals(mContentViewCore.getSelectedText(), ""); | |
| 360 } | |
| 361 | |
| 362 @SmallTest | |
| 363 @Feature({"TextSelection"}) | |
| 364 public void testSelectActionBarPlainTextSelectAll() throws Exception { | |
| 365 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); | |
| 366 assertWaitForSelectActionBarVisible(true); | |
| 367 assertTrue(mContentViewCore.hasSelection()); | |
| 368 assertNotNull(mContentViewCore.getSelectActionHandler()); | |
| 369 selectActionBarSelectAll(); | |
| 370 assertTrue(mContentViewCore.hasSelection()); | |
| 371 assertWaitForSelectActionBarVisible(true); | |
| 372 } | |
| 373 | |
| 374 @SmallTest | |
| 375 @Feature({"TextInput"}) | |
| 376 public void testSelectActionBarInputSelectAll() throws Exception { | |
| 377 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); | |
| 378 assertWaitForSelectActionBarVisible(true); | |
| 379 assertTrue(mContentViewCore.hasSelection()); | |
| 380 assertNotNull(mContentViewCore.getSelectActionHandler()); | |
| 381 selectActionBarSelectAll(); | |
| 382 assertTrue(mContentViewCore.hasSelection()); | |
| 383 assertWaitForSelectActionBarVisible(true); | |
| 384 assertEquals(mContentViewCore.getSelectedText(), "SampleInputText"); | |
| 385 } | |
| 386 | |
| 387 @SmallTest | |
| 388 @Feature({"TextInput"}) | |
| 389 public void testSelectActionBarPasswordSelectAll() throws Exception { | |
| 390 DOMUtils.longPressNode(this, mContentViewCore, "input_password"); | |
| 391 assertWaitForSelectActionBarVisible(true); | |
| 392 assertTrue(mContentViewCore.hasSelection()); | |
| 393 assertNotNull(mContentViewCore.getSelectActionHandler()); | |
| 394 selectActionBarSelectAll(); | |
| 395 assertTrue(mContentViewCore.hasSelection()); | |
| 396 assertWaitForSelectActionBarVisible(true); | |
| 397 } | |
| 398 | |
| 399 @SmallTest | |
| 400 @Feature({"TextInput"}) | |
| 401 public void testSelectActionBarTextAreaSelectAll() throws Exception { | |
| 402 DOMUtils.longPressNode(this, mContentViewCore, "textarea"); | |
| 403 assertWaitForSelectActionBarVisible(true); | |
| 404 assertTrue(mContentViewCore.hasSelection()); | |
| 405 assertNotNull(mContentViewCore.getSelectActionHandler()); | |
| 406 selectActionBarSelectAll(); | |
| 407 assertTrue(mContentViewCore.hasSelection()); | |
| 408 assertWaitForSelectActionBarVisible(true); | |
| 409 assertEquals(mContentViewCore.getSelectedText(), "SampleTextArea"); | |
| 410 } | |
| 411 | |
| 412 @SmallTest | |
| 413 @Feature({"TextSelection"}) | |
| 414 public void testSelectActionBarPlainTextPaste() throws Exception { | |
| 415 copyStringToClipboard("SampleTextToCopy"); | |
| 416 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); | |
| 417 assertWaitForSelectActionBarVisible(true); | |
| 418 assertTrue(mContentViewCore.hasSelection()); | |
| 419 assertNotNull(mContentViewCore.getSelectActionHandler()); | |
| 420 selectActionBarPaste(); | |
| 421 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); | |
| 422 assertWaitForSelectActionBarVisible(true); | |
| 423 assertTrue(mContentViewCore.hasSelection()); | |
| 424 // Paste option won't be available for plain text. | |
| 425 // Hence content won't be changed. | |
| 426 assertNotSame(mContentViewCore.getSelectedText(), "SampleTextToCopy"); | |
| 427 } | |
| 428 | |
| 429 @SmallTest | |
| 430 @Feature({"TextInput"}) | |
| 431 public void testSelectActionBarInputPaste() throws Exception { | |
| 432 copyStringToClipboard("SampleTextToCopy"); | |
| 433 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); | |
| 434 assertWaitForSelectActionBarVisible(true); | |
| 435 assertTrue(mContentViewCore.hasSelection()); | |
| 436 assertNotNull(mContentViewCore.getSelectActionHandler()); | |
| 437 selectActionBarPaste(); | |
| 438 DOMUtils.clickNode(this, mContentViewCore, "plain_text_1"); | |
| 439 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); | |
| 440 assertWaitForSelectActionBarVisible(true); | |
| 441 assertTrue(mContentViewCore.hasSelection()); | |
| 442 assertEquals(mContentViewCore.getSelectedText(), "SampleTextToCopy"); | |
| 443 } | |
| 444 | |
| 445 @SmallTest | |
| 446 @Feature({"TextInput"}) | |
| 447 public void testSelectActionBarPasswordPaste() throws Exception { | |
| 448 copyStringToClipboard("SampleTextToCopy"); | |
| 449 DOMUtils.longPressNode(this, mContentViewCore, "input_password"); | |
| 450 assertWaitForSelectActionBarVisible(true); | |
| 451 assertTrue(mContentViewCore.hasSelection()); | |
| 452 assertNotNull(mContentViewCore.getSelectActionHandler()); | |
| 453 selectActionBarPaste(); | |
| 454 DOMUtils.clickNode(this, mContentViewCore, "plain_text_1"); | |
| 455 DOMUtils.longPressNode(this, mContentViewCore, "input_password"); | |
| 456 assertWaitForSelectActionBarVisible(true); | |
| 457 assertTrue(mContentViewCore.hasSelection()); | |
| 458 assertNotSame(mContentViewCore.getSelectedText(), "SampleTextToCopy"); | |
| 459 } | |
| 460 | |
| 461 @SmallTest | |
| 462 @Feature({"TextInput"}) | |
| 463 public void testSelectActionBarTextAreaPaste() throws Exception { | |
| 464 copyStringToClipboard("SampleTextToCopy"); | |
| 465 DOMUtils.longPressNode(this, mContentViewCore, "textarea"); | |
| 466 assertWaitForSelectActionBarVisible(true); | |
| 467 assertTrue(mContentViewCore.hasSelection()); | |
| 468 assertNotNull(mContentViewCore.getSelectActionHandler()); | |
| 469 selectActionBarPaste(); | |
| 470 DOMUtils.clickNode(this, mContentViewCore, "plain_text_1"); | |
| 471 DOMUtils.longPressNode(this, mContentViewCore, "textarea"); | |
| 472 assertWaitForSelectActionBarVisible(true); | |
| 473 assertTrue(mContentViewCore.hasSelection()); | |
| 474 assertEquals(mContentViewCore.getSelectedText(), "SampleTextToCopy"); | |
| 475 } | |
| 476 | |
| 477 private void selectActionBarPaste() { | |
| 478 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | |
| 479 @Override | |
| 480 public void run() { | |
| 481 mContentViewCore.getSelectActionHandler().paste(); | |
| 482 } | |
| 483 }); | |
| 484 } | |
| 485 | |
| 486 private void selectActionBarSelectAll() { | |
| 487 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | |
| 488 @Override | |
| 489 public void run() { | |
| 490 mContentViewCore.getSelectActionHandler().selectAll(); | |
| 491 } | |
| 492 }); | |
| 493 } | |
| 494 | |
| 495 private void selectActionBarCut() { | |
| 496 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | |
| 497 @Override | |
| 498 public void run() { | |
| 499 mContentViewCore.getSelectActionHandler().cut(); | |
| 500 } | |
| 501 }); | |
| 502 } | |
| 503 | |
| 279 private void selectActionBarCopy() { | 504 private void selectActionBarCopy() { |
| 280 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 505 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 281 @Override | 506 @Override |
| 282 public void run() { | 507 public void run() { |
| 283 mContentViewCore.getSelectActionHandler().copy(); | 508 mContentViewCore.getSelectActionHandler().copy(); |
| 284 } | 509 } |
| 285 }); | 510 }); |
| 286 } | 511 } |
| 287 | 512 |
| 288 private void assertClipboardContents(final Context context, final String exp ectedContents) | 513 private void assertClipboardContents(final Context context, final String exp ectedContents) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 private void requestFocusOnUiThread(final boolean gainFocus) { | 571 private void requestFocusOnUiThread(final boolean gainFocus) { |
| 347 final ContentViewCore contentViewCore = mContentViewCore; | 572 final ContentViewCore contentViewCore = mContentViewCore; |
| 348 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 573 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 349 @Override | 574 @Override |
| 350 public void run() { | 575 public void run() { |
| 351 contentViewCore.onFocusChanged(gainFocus); | 576 contentViewCore.onFocusChanged(gainFocus); |
| 352 } | 577 } |
| 353 }); | 578 }); |
| 354 } | 579 } |
| 355 | 580 |
| 356 private void copyStringToClipboard() { | 581 private void copyStringToClipboard(String string) { |
| 357 ClipboardManager clipboardManager = | 582 ClipboardManager clipboardManager = |
| 358 (ClipboardManager) getActivity().getSystemService( | 583 (ClipboardManager) getActivity().getSystemService( |
| 359 Context.CLIPBOARD_SERVICE); | 584 Context.CLIPBOARD_SERVICE); |
| 360 ClipData clip = ClipData.newPlainText("test", "Text to copy"); | 585 ClipData clip = ClipData.newPlainText("test", string); |
| 361 clipboardManager.setPrimaryClip(clip); | 586 clipboardManager.setPrimaryClip(clip); |
| 362 } | 587 } |
| 363 | 588 |
| 364 private void assertWaitForPastePopupStatus(final boolean show) throws Interr uptedException { | 589 private void assertWaitForPastePopupStatus(final boolean show) throws Interr uptedException { |
| 365 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { | 590 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { |
| 366 @Override | 591 @Override |
| 367 public boolean isSatisfied() { | 592 public boolean isSatisfied() { |
| 368 return show == mContentViewCore.getPastePopupForTest().isShowing (); | 593 return show == mContentViewCore.getPastePopupForTest().isShowing (); |
| 369 } | 594 } |
| 370 })); | 595 })); |
| 371 } | 596 } |
| 372 } | 597 } |
| OLD | NEW |