Index: content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java |
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java b/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java |
index e1d56fa9c3ed0146c72d84575f722461c89d370a..49f9e88c613db936c4ce23b5aecd78d5bd775f24 100644 |
--- a/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java |
+++ b/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java |
@@ -127,19 +127,49 @@ public class ImeTest extends ContentShellTestBase { |
@SmallTest |
@Feature({"TextInput", "Main"}) |
- public void testDeleteSurroundingTextWithZeroValue() throws Throwable { |
+ public void testDeleteSurroundingTextWithRangeSelection() throws Throwable { |
commitText("hello", 1); |
waitAndVerifyUpdateSelection(0, 5, 5, -1, -1); |
- deleteSurroundingText(0, 0); |
- setSelection(0, 0); |
- waitAndVerifyUpdateSelection(1, 0, 0, -1, -1); |
+ setSelection(1, 4); |
+ waitAndVerifyUpdateSelection(1, 1, 4, -1, -1); |
+ |
deleteSurroundingText(0, 0); |
+ assertTextsAroundCursor("h", "ell", "o"); |
+ |
+ deleteSurroundingText(1, 1); |
+ assertTextsAroundCursor("", "ell", ""); |
+ |
+ deleteSurroundingText(1, 0); |
+ assertTextsAroundCursor("", "ell", ""); |
+ |
+ deleteSurroundingText(0, 1); |
+ assertTextsAroundCursor("", "ell", ""); |
+ } |
+ |
+ @SmallTest |
+ @Feature({"TextInput", "Main"}) |
+ public void testDeleteSurroundingTextWithCursorSelection() throws Throwable { |
+ commitText("hello", 1); |
+ waitAndVerifyUpdateSelection(0, 5, 5, -1, -1); |
setSelection(2, 2); |
- waitAndVerifyUpdateSelection(2, 2, 2, -1, -1); |
+ waitAndVerifyUpdateSelection(1, 2, 2, -1, -1); |
+ |
deleteSurroundingText(0, 0); |
assertTextsAroundCursor("he", "", "llo"); |
+ |
+ deleteSurroundingText(1, 1); |
+ assertTextsAroundCursor("h", "", "lo"); |
+ |
+ deleteSurroundingText(1, 0); |
+ assertTextsAroundCursor("", "", "lo"); |
+ |
+ deleteSurroundingText(0, 10); |
+ assertTextsAroundCursor("", "", ""); |
+ |
+ deleteSurroundingText(10, 10); |
+ assertTextsAroundCursor("", "", ""); |
} |
// When newCursorPosition != 1, setComposingText doesn't work for ReplicaInputConnection |
@@ -1209,29 +1239,41 @@ public class ImeTest extends ContentShellTestBase { |
waitForEventLogs("selectionchange,selectionchange"); |
clearEventLogs(); |
- commitText("a", 1); |
- waitAndVerifyUpdateSelection(0, 1, 1, -1, -1); |
+ commitText("hello", 1); |
+ waitAndVerifyUpdateSelection(0, 5, 5, -1, -1); |
waitForEventLogs("keydown(229),input,keyup(229),selectionchange"); |
clearEventLogs(); |
- deleteSurroundingText(1, 0); |
- waitAndVerifyUpdateSelection(1, 0, 0, -1, -1); |
+ setSelection(2, 2); |
+ waitAndVerifyUpdateSelection(1, 2, 2, -1, -1); |
+ waitForEventLogs("selectionchange"); |
+ clearEventLogs(); |
- waitForEventLogs("keydown(229),input,keyup(229),selectionchange,selectionchange"); |
+ deleteSurroundingText(1, 1); |
+ waitAndVerifyUpdateSelection(2, 1, 1, -1, -1); |
+ // TODO(yabinh): It should only fire 1 input and 2 selectionchange events. |
yabinh
2016/06/20 06:48:51
It will fire duplicate JS events.
Changwan Ryu
2016/06/20 10:03:24
nit: 1 selectionchange?
yabinh
2016/06/20 10:22:22
You are right.
|
+ waitForEventLogs("keydown(229),input,input,keyup(229),selectionchange,selectionchange," |
+ + "selectionchange,selectionchange"); |
} |
@MediumTest |
@Feature({"TextInput"}) |
public void testInputTextEvents_DeleteSurroundingText() throws Throwable { |
- commitText("a", 1); |
- waitAndVerifyUpdateSelection(0, 1, 1, -1, -1); |
+ commitText("hello", 1); |
+ waitAndVerifyUpdateSelection(0, 5, 5, -1, -1); |
waitForEventLogs("keydown(229),input,keyup(229),selectionchange"); |
clearEventLogs(); |
- deleteSurroundingText(1, 0); |
- waitAndVerifyUpdateSelection(1, 0, 0, -1, -1); |
+ setSelection(2, 2); |
+ waitAndVerifyUpdateSelection(1, 2, 2, -1, -1); |
+ waitForEventLogs("selectionchange"); |
+ clearEventLogs(); |
- waitForEventLogs("keydown(229),input,keyup(229),selectionchange,selectionchange"); |
+ deleteSurroundingText(1, 1); |
+ waitAndVerifyUpdateSelection(2, 1, 1, -1, -1); |
+ // TODO(yabinh): It should only fire 1 input and 2 selectionchange events. |
+ waitForEventLogs("keydown(229),input,input,keyup(229),selectionchange,selectionchange," |
+ + "selectionchange,selectionchange"); |
} |
private void clearEventLogs() throws Exception { |