Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.input; | 5 package org.chromium.content.browser.input; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.ClipData; | 8 import android.content.ClipData; |
| 9 import android.content.ClipboardManager; | 9 import android.content.ClipboardManager; |
| 10 import android.content.Context; | 10 import android.content.Context; |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 DOMUtils.focusNode(mContentViewCore, "textarea"); | 237 DOMUtils.focusNode(mContentViewCore, "textarea"); |
| 238 commitText(mConnection, "Sample Text", 1); | 238 commitText(mConnection, "Sample Text", 1); |
| 239 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); | 239 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); |
| 240 assertWaitForKeyboardStatus(true); | 240 assertWaitForKeyboardStatus(true); |
| 241 DOMUtils.longPressNode(this, mContentViewCore, "textarea"); | 241 DOMUtils.longPressNode(this, mContentViewCore, "textarea"); |
| 242 assertWaitForKeyboardStatus(true); | 242 assertWaitForKeyboardStatus(true); |
| 243 } | 243 } |
| 244 | 244 |
| 245 @SmallTest | 245 @SmallTest |
| 246 @Feature({"TextInput"}) | 246 @Feature({"TextInput"}) |
| 247 public void testPastePopupNotShownOnLongPressingNonEmptyInput() throws Throw able { | |
| 248 DOMUtils.focusNode(mContentViewCore, "input_text"); | |
|
jdduke (slow)
2014/09/03 18:08:07
This behavior is only tangentially related to IME
AKVT
2014/09/03 19:23:16
Thanks for the suggestion, I had corrected it and
| |
| 249 commitText(mConnection, "Sample Text", 1); | |
| 250 selectAll(mImeAdapter); | |
| 251 cut(mImeAdapter); | |
| 252 DOMUtils.focusNode(mContentViewCore, "textarea"); | |
| 253 commitText(mConnection, "Sample Text", 1); | |
| 254 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); | |
| 255 assertWaitForPastePopupStatus(true); | |
| 256 DOMUtils.longPressNode(this, mContentViewCore, "textarea"); | |
| 257 assertWaitForSelectActionBarStatus(true); | |
| 258 assertWaitForPastePopupStatus(false); | |
| 259 } | |
| 260 | |
| 261 @SmallTest | |
| 262 @Feature({"TextInput"}) | |
| 263 public void testPastePopupClearedOnTappingEmptyInput() throws Throwable { | |
| 264 DOMUtils.focusNode(mContentViewCore, "input_text"); | |
| 265 commitText(mConnection, "Sample Text", 1); | |
| 266 selectAll(mImeAdapter); | |
| 267 cut(mImeAdapter); | |
| 268 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); | |
| 269 assertWaitForPastePopupStatus(true); | |
| 270 DOMUtils.clickNode(this, mContentViewCore, "input_text"); | |
| 271 assertWaitForKeyboardStatus(true); | |
| 272 assertWaitForPastePopupStatus(false); | |
| 273 } | |
| 274 | |
| 275 @SmallTest | |
| 276 @Feature({"TextInput"}) | |
| 277 public void testPastePopupClearedOnTappingNonEmptyInput() throws Throwable { | |
| 278 DOMUtils.focusNode(mContentViewCore, "input_text"); | |
| 279 commitText(mConnection, "Sample Text", 1); | |
| 280 selectAll(mImeAdapter); | |
| 281 cut(mImeAdapter); | |
| 282 DOMUtils.focusNode(mContentViewCore, "textarea"); | |
| 283 commitText(mConnection, "Sample Text", 1); | |
| 284 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); | |
| 285 assertWaitForPastePopupStatus(true); | |
| 286 DOMUtils.clickNode(this, mContentViewCore, "input_text"); | |
| 287 assertWaitForKeyboardStatus(true); | |
| 288 assertWaitForPastePopupStatus(false); | |
| 289 } | |
| 290 | |
| 291 @SmallTest | |
| 292 @Feature({"TextInput"}) | |
| 293 public void testPastePopupClearedOnTappingOutsideInput() throws Throwable { | |
| 294 DOMUtils.focusNode(mContentViewCore, "input_text"); | |
| 295 assertWaitForKeyboardStatus(true); | |
| 296 commitText(mConnection, "Sample Text", 1); | |
| 297 selectAll(mImeAdapter); | |
| 298 cut(mImeAdapter); | |
| 299 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); | |
| 300 assertWaitForPastePopupStatus(true); | |
| 301 DOMUtils.clickNode(this, mContentViewCore, "input_radio"); | |
| 302 assertWaitForPastePopupStatus(false); | |
| 303 } | |
| 304 | |
| 305 @SmallTest | |
| 306 @Feature({"TextInput"}) | |
| 307 public void testPastePopupClearedOnLongPressingOutsideInput() throws Throwab le { | |
| 308 DOMUtils.focusNode(mContentViewCore, "input_text"); | |
| 309 assertWaitForKeyboardStatus(true); | |
| 310 commitText(mConnection, "Sample Text", 1); | |
| 311 selectAll(mImeAdapter); | |
| 312 cut(mImeAdapter); | |
| 313 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); | |
| 314 assertWaitForPastePopupStatus(true); | |
| 315 DOMUtils.longPressNode(this, mContentViewCore, "input_radio"); | |
| 316 assertWaitForPastePopupStatus(false); | |
| 317 } | |
| 318 | |
| 319 @SmallTest | |
| 320 @Feature({"TextInput"}) | |
| 247 public void testImeCut() throws Exception { | 321 public void testImeCut() throws Exception { |
| 248 commitText(mConnection, "snarful", 1); | 322 commitText(mConnection, "snarful", 1); |
| 249 waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "snarful", 7, 7, -1, -1); | 323 waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "snarful", 7, 7, -1, -1); |
| 250 | 324 |
| 251 setSelection(mConnection, 1, 5); | 325 setSelection(mConnection, 1, 5); |
| 252 waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "snarful", 1, 5, -1, -1); | 326 waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 2, "snarful", 1, 5, -1, -1); |
| 253 | 327 |
| 254 cut(mImeAdapter); | 328 cut(mImeAdapter); |
| 255 waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 3, "sul", 1, 1, -1, -1); | 329 waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 3, "sul", 1, 1, -1, -1); |
| 256 | 330 |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 657 private void assertWaitForSelectActionBarStatus( | 731 private void assertWaitForSelectActionBarStatus( |
| 658 final boolean show) throws InterruptedException { | 732 final boolean show) throws InterruptedException { |
| 659 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { | 733 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { |
| 660 @Override | 734 @Override |
| 661 public boolean isSatisfied() { | 735 public boolean isSatisfied() { |
| 662 return show == mContentViewCore.isSelectActionBarShowing(); | 736 return show == mContentViewCore.isSelectActionBarShowing(); |
| 663 } | 737 } |
| 664 })); | 738 })); |
| 665 } | 739 } |
| 666 | 740 |
| 741 private void assertWaitForPastePopupStatus(final boolean show) throws Interr uptedException { | |
| 742 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { | |
| 743 @Override | |
| 744 public boolean isSatisfied() { | |
| 745 return show == mContentViewCore.getPastePopupForTest().isShowing (); | |
| 746 } | |
| 747 })); | |
| 748 } | |
| 749 | |
| 667 private void waitAndVerifyEditableCallback(final ArrayList<TestImeState> sta tes, | 750 private void waitAndVerifyEditableCallback(final ArrayList<TestImeState> sta tes, |
| 668 final int index, String text, int selectionStart, int selectionEnd, | 751 final int index, String text, int selectionStart, int selectionEnd, |
| 669 int compositionStart, int compositionEnd) throws InterruptedExceptio n { | 752 int compositionStart, int compositionEnd) throws InterruptedExceptio n { |
| 670 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { | 753 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { |
| 671 @Override | 754 @Override |
| 672 public boolean isSatisfied() { | 755 public boolean isSatisfied() { |
| 673 return states.size() > index; | 756 return states.size() > index; |
| 674 } | 757 } |
| 675 })); | 758 })); |
| 676 states.get(index).assertEqualState( | 759 states.get(index).assertEqualState( |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 872 public void assertEqualState(String text, int selectionStart, int select ionEnd, | 955 public void assertEqualState(String text, int selectionStart, int select ionEnd, |
| 873 int compositionStart, int compositionEnd) { | 956 int compositionStart, int compositionEnd) { |
| 874 assertEquals("Text did not match", text, mText); | 957 assertEquals("Text did not match", text, mText); |
| 875 assertEquals("Selection start did not match", selectionStart, mSelec tionStart); | 958 assertEquals("Selection start did not match", selectionStart, mSelec tionStart); |
| 876 assertEquals("Selection end did not match", selectionEnd, mSelection End); | 959 assertEquals("Selection end did not match", selectionEnd, mSelection End); |
| 877 assertEquals("Composition start did not match", compositionStart, mC ompositionStart); | 960 assertEquals("Composition start did not match", compositionStart, mC ompositionStart); |
| 878 assertEquals("Composition end did not match", compositionEnd, mCompo sitionEnd); | 961 assertEquals("Composition end did not match", compositionEnd, mCompo sitionEnd); |
| 879 } | 962 } |
| 880 } | 963 } |
| 881 } | 964 } |
| OLD | NEW |