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

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java

Issue 1999423002: tyrbot test for commitText (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SetHasCompositionTextToTrue Created 4 years, 3 months 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 side-by-side diff with in-line comments
Download patch
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 c931600cd206190a7f6b75ae2c69beb930b47502..eb0a58c412a470cc51d8236ece23f919ddc90bf0 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
@@ -155,7 +155,7 @@ public class ImeTest extends ContentShellTestBase {
@CommandLineFlags.Add("enable-features=ImeThread")
@SmallTest
@Feature({"TextInput", "Main"})
- public void testSetComposingTextForDifferentnewCursorPositions() throws Throwable {
+ public void testSetComposingTextForNewCursorPositions() throws Throwable {
// Cursor is on the right of composing text when newCursorPosition > 0.
setComposingText("ab", 1);
waitAndVerifyUpdateSelection(0, 2, 2, 0, 2);
@@ -199,6 +199,45 @@ public class ImeTest extends ContentShellTestBase {
waitAndVerifyUpdateSelection(10, 8, 8, 2, 6);
}
+ // When newCursorPosition != 1, commitText doesn't work for ReplicaInputConnection
+ // because there is a bug in BaseInputConnection.
+ @CommandLineFlags.Add("enable-features=ImeThread")
+ @SmallTest
+ @Feature({"TextInput", "Main"})
+ public void testCommitTextForNewCursorPositions() throws Throwable {
+ // Cursor is on the left of committing text.
+ commitText("ab", 0);
+ waitAndVerifyUpdateSelection(0, 0, 0, -1, -1);
+
+ // Cursor is on the right of committing text.
+ commitText("cd", 1);
+ waitAndVerifyUpdateSelection(1, 2, 2, -1, -1);
+
+ // Cursor is between the committing text and the right boundary.
+ commitText("ef", 2);
+ waitAndVerifyUpdateSelection(2, 5, 5, -1, -1);
+
+ // Cursor is between the left boundary and the committing text.
+ commitText("gh", -3);
+ waitAndVerifyUpdateSelection(3, 2, 2, -1, -1);
+
+ // Cursor is on the right boundary.
+ commitText("ij", 7);
+ waitAndVerifyUpdateSelection(4, 10, 10, -1, -1);
+
+ // Cursor is on the left boundary.
+ commitText("kl", -10);
+ waitAndVerifyUpdateSelection(5, 0, 0, -1, -1);
+
+ // Cursor exceeds the right boundary.
+ commitText("mn", 100);
+ waitAndVerifyUpdateSelection(6, 14, 14, -1, -1);
+
+ // Cursor exceeds the left boundary.
+ commitText("op", -100);
+ waitAndVerifyUpdateSelection(7, 0, 0, -1, -1);
+ }
+
@SmallTest
@Feature({"TextInput", "Main"})
public void testSetComposingTextWithEmptyText() throws Throwable {
@@ -221,6 +260,25 @@ public class ImeTest extends ContentShellTestBase {
@SmallTest
@Feature({"TextInput", "Main"})
+ public void testCommitTextWithEmptyText() throws Throwable {
+ commitText("hello", 1);
+ waitAndVerifyUpdateSelection(0, 5, 5, -1, -1);
+ setSelection(2, 2);
+ waitAndVerifyUpdateSelection(1, 2, 2, -1, -1);
+
+ setComposingText("world", 1);
+ waitAndVerifyUpdateSelection(2, 7, 7, 2, 7);
+ // With previous composition.
+ commitText("", 2);
+ waitAndVerifyUpdateSelection(3, 3, 3, -1, -1);
+
+ // Without previous composition.
+ commitText("", -1);
+ waitAndVerifyUpdateSelection(4, 2, 2, -1, -1);
+ }
+
+ @SmallTest
+ @Feature({"TextInput", "Main"})
public void testCommitWhileComposingText() throws Throwable {
setComposingText("h", 1);
waitAndVerifyUpdateSelection(0, 1, 1, 0, 1);

Powered by Google App Engine
This is Rietveld 408576698