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

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

Issue 2355483006: Allow some InputConnection methods to be called on UI thread (Closed)
Patch Set: 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 31470aab1a1654c5bd795d7d563196155a781809..981df309e45b35428fafe08ae177ee696fca8b49 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
@@ -1254,7 +1254,6 @@ public class ImeTest extends ContentShellTestBase {
@MediumTest
@Feature({"TextInput"})
- @RetryOnFailure
public void testGetCursorCapsMode() throws Throwable {
commitText("Hello World", 1);
waitAndVerifyUpdateSelection(0, 11, 11, -1, -1);
@@ -1333,28 +1332,57 @@ public class ImeTest extends ContentShellTestBase {
}));
}
- // Tests that the method call order is kept.
- // See crbug.com/601707 for details.
+ // Tests that the method call order is kept and get updates correctly.
+ // crbug.com/601707, crbug.com/643473
@MediumTest
@Feature({"TextInput"})
- public void testSetSelectionCommitTextOrder() throws Exception {
+ public void testAsynchronousSequence() throws Exception {
final ChromiumBaseInputConnection connection = mConnection;
runBlockingOnImeThread(new Callable<Void>() {
@Override
public Void call() {
+ connection.commitText("hi ", 1);
connection.beginBatchEdit();
connection.commitText("hello world", 1);
- connection.setSelection(6, 6);
- connection.deleteSurroundingText(0, 5);
+ connection.setSelection(9, 9);
+ connection.deleteSurroundingText(3, 8);
connection.commitText("'", 1);
connection.commitText("world", 1);
- connection.setSelection(7, 7);
+ connection.setSelection(10, 10);
connection.setComposingText("", 1);
connection.endBatchEdit();
return null;
}
});
- waitAndVerifyUpdateSelection(0, 7, 7, -1, -1);
+ waitAndVerifyUpdateSelection(0, 3, 3, -1, -1);
+ waitAndVerifyUpdateSelection(1, 10, 10, -1, -1);
+ }
+
+ // crbug.com/643477
+ @MediumTest
+ @Feature({"TextInput"})
+ public void testUiThreadAccess() throws Exception {
+ final ChromiumBaseInputConnection connection = mConnection;
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ assertTrue(connection.commitText("a", 1));
+ assertTrue(connection.beginBatchEdit());
+ assertTrue(connection.setComposingText("b", 1));
+ // Note that the result of this function may not be up-to-date.
+ connection.getTextBeforeCursor(10, 0);
+
+ assertTrue(connection.setComposingText("bc", 1));
+ assertFalse(connection.endBatchEdit()); // returns false if no more batch edit.
+ assertTrue(connection.finishComposingText());
+ }
+ });
+ assertEquals("abc", runBlockingOnImeThread(new Callable<CharSequence>() {
+ @Override
+ public CharSequence call() throws Exception {
+ return connection.getTextBeforeCursor(5, 0);
+ }
+ }));
}
private void performGo(TestCallbackHelperContainer testCallbackHelperContainer)

Powered by Google App Engine
This is Rietveld 408576698