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

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

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

Powered by Google App Engine
This is Rietveld 408576698