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 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 finishComposingText(); | 912 finishComposingText(); |
913 | 913 |
914 // H | 914 // H |
915 expectUpdateStateCall(); | 915 expectUpdateStateCall(); |
916 setComposingText("h", 1); | 916 setComposingText("h", 1); |
917 assertEquals(COMPOSITION_KEY_CODE, mImeAdapter.mLastSyntheticKeyCode); | 917 assertEquals(COMPOSITION_KEY_CODE, mImeAdapter.mLastSyntheticKeyCode); |
918 } | 918 } |
919 | 919 |
920 @SmallTest | 920 @SmallTest |
921 @Feature({"TextInput"}) | 921 @Feature({"TextInput"}) |
922 public void testPastePopupShowOnLongPress() throws Throwable { | 922 public void testPastePopupShowAndHide() throws Throwable { |
923 commitText("hello", 1); | 923 commitText("hello", 1); |
924 waitAndVerifyStatesAndCalls(1, "hello", 5, 5, -1, -1); | 924 waitAndVerifyStatesAndCalls(1, "hello", 5, 5, -1, -1); |
925 | 925 |
926 selectAll(); | 926 selectAll(); |
927 waitAndVerifyStatesAndCalls(2, "hello", 0, 5, -1, -1); | 927 waitAndVerifyStatesAndCalls(2, "hello", 0, 5, -1, -1); |
928 | 928 |
929 cut(); | 929 cut(); |
930 waitAndVerifyStatesAndCalls(0, "", 0, 0, -1, -1); | 930 waitAndVerifyStatesAndCalls(0, "", 0, 0, -1, -1); |
931 | 931 |
932 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); | 932 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); |
933 final PastePopupMenu pastePopup = mContentViewCore.getPastePopupForTest(
); | 933 final PastePopupMenu pastePopup = mContentViewCore.getPastePopupForTest(
); |
934 assertTrue(CriteriaHelper.pollForUIThreadCriteria(new Criteria() { | 934 assertTrue(CriteriaHelper.pollForUIThreadCriteria(new Criteria() { |
935 @Override | 935 @Override |
936 public boolean isSatisfied() { | 936 public boolean isSatisfied() { |
937 return pastePopup.isShowing(); | 937 return pastePopup.isShowing(); |
938 } | 938 } |
939 })); | 939 })); |
| 940 |
| 941 DOMUtils.clickNode(this, mContentViewCore, "input_text"); |
| 942 assertWaitForKeyboardStatus(true); |
| 943 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); |
| 944 setComposingText("h", 1); |
| 945 assertTrue(CriteriaHelper.pollForUIThreadCriteria(new Criteria() { |
| 946 @Override |
| 947 public boolean isSatisfied() { |
| 948 return !pastePopup.isShowing(); |
| 949 } |
| 950 })); |
| 951 assertFalse(mContentViewCore.hasInsertion()); |
940 } | 952 } |
941 | 953 |
942 @SmallTest | 954 @SmallTest |
| 955 @Feature({"TextInput"}) |
| 956 public void testSelectionClearedOnKeyEvent() throws Throwable { |
| 957 commitText("hello", 1); |
| 958 waitAndVerifyStatesAndCalls(1, "hello", 5, 5, -1, -1); |
| 959 |
| 960 DOMUtils.clickNode(this, mContentViewCore, "input_text"); |
| 961 assertWaitForKeyboardStatus(true); |
| 962 |
| 963 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); |
| 964 assertWaitForSelectActionBarStatus(true); |
| 965 |
| 966 setComposingText("h", 1); |
| 967 assertWaitForSelectActionBarStatus(false); |
| 968 assertFalse(mContentViewCore.hasSelection()); |
| 969 } |
| 970 |
| 971 @SmallTest |
943 @Feature({"TextInput"}) | 972 @Feature({"TextInput"}) |
944 public void testTextHandlesPreservedWithDpadNavigation() throws Throwable { | 973 public void testTextHandlesPreservedWithDpadNavigation() throws Throwable { |
945 DOMUtils.longPressNode(this, mContentViewCore, "plain_text"); | 974 DOMUtils.longPressNode(this, mContentViewCore, "plain_text"); |
946 assertWaitForSelectActionBarStatus(true); | 975 assertWaitForSelectActionBarStatus(true); |
947 assertTrue(mContentViewCore.hasSelection()); | 976 assertTrue(mContentViewCore.hasSelection()); |
948 | 977 |
949 dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPA
D_DOWN)); | 978 dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPA
D_DOWN)); |
950 assertWaitForSelectActionBarStatus(true); | 979 assertWaitForSelectActionBarStatus(true); |
951 assertTrue(mContentViewCore.hasSelection()); | 980 assertTrue(mContentViewCore.hasSelection()); |
952 } | 981 } |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 public void assertEqualState(String text, int selectionStart, int select
ionEnd, | 1271 public void assertEqualState(String text, int selectionStart, int select
ionEnd, |
1243 int compositionStart, int compositionEnd) { | 1272 int compositionStart, int compositionEnd) { |
1244 assertEquals("Text did not match", text, mText); | 1273 assertEquals("Text did not match", text, mText); |
1245 assertEquals("Selection start did not match", selectionStart, mSelec
tionStart); | 1274 assertEquals("Selection start did not match", selectionStart, mSelec
tionStart); |
1246 assertEquals("Selection end did not match", selectionEnd, mSelection
End); | 1275 assertEquals("Selection end did not match", selectionEnd, mSelection
End); |
1247 assertEquals("Composition start did not match", compositionStart, mC
ompositionStart); | 1276 assertEquals("Composition start did not match", compositionStart, mC
ompositionStart); |
1248 assertEquals("Composition end did not match", compositionEnd, mCompo
sitionEnd); | 1277 assertEquals("Composition end did not match", compositionEnd, mCompo
sitionEnd); |
1249 } | 1278 } |
1250 } | 1279 } |
1251 } | 1280 } |
OLD | NEW |