Index: content/public/android/javatests/src/org/chromium/content/browser/input/ImeLollipopTest.java |
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/input/ImeLollipopTest.java b/content/public/android/javatests/src/org/chromium/content/browser/input/ImeLollipopTest.java |
index 884efc273b51da3cdd1faa519fc10ff7bed4650e..596282165bdb65f3de786313d2b4b55c02d57bc5 100644 |
--- a/content/public/android/javatests/src/org/chromium/content/browser/input/ImeLollipopTest.java |
+++ b/content/public/android/javatests/src/org/chromium/content/browser/input/ImeLollipopTest.java |
@@ -10,10 +10,17 @@ import android.support.test.filters.MediumTest; |
import android.view.inputmethod.CursorAnchorInfo; |
import android.view.inputmethod.InputConnection; |
+import org.junit.Assert; |
+import org.junit.Before; |
+import org.junit.Rule; |
+import org.junit.Test; |
+import org.junit.runner.RunWith; |
+ |
import org.chromium.base.ThreadUtils; |
import org.chromium.base.test.util.Feature; |
import org.chromium.base.test.util.MinAndroidSdkLevel; |
import org.chromium.base.test.util.RetryOnFailure; |
+import org.chromium.content.browser.test.ContentJUnit4ClassRunner; |
import org.chromium.content.browser.test.util.Criteria; |
import org.chromium.content.browser.test.util.CriteriaHelper; |
@@ -22,9 +29,19 @@ import java.util.concurrent.Callable; |
/** |
* Integration tests for text input for Android L (or above) features. |
*/ |
+@RunWith(ContentJUnit4ClassRunner.class) |
@MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP) |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) |
-public class ImeLollipopTest extends ImeTest { |
+public class ImeLollipopTest { |
+ @Rule |
+ public ImeActivityTestRule mRule = new ImeActivityTestRule(); |
+ |
+ @Before |
+ public void setUp() throws Exception { |
+ mRule.setUp(); |
+ } |
+ |
+ @Test |
@MediumTest |
@Feature({"TextInput"}) |
@RetryOnFailure |
@@ -32,45 +49,45 @@ public class ImeLollipopTest extends ImeTest { |
requestCursorUpdates(InputConnection.CURSOR_UPDATE_MONITOR); |
// In "MONITOR" mode, the change should be notified. |
- setComposingText("ab", 1); |
+ mRule.setComposingText("ab", 1); |
waitForUpdateCursorAnchorInfoComposingText("ab"); |
- CursorAnchorInfo info = mInputMethodManagerWrapper.getLastCursorAnchorInfo(); |
- assertEquals(0, info.getComposingTextStart()); |
- assertNotNull(info.getCharacterBounds(0)); |
- assertNotNull(info.getCharacterBounds(1)); |
- assertNull(info.getCharacterBounds(2)); |
+ CursorAnchorInfo info = mRule.getInputMethodManagerWrapper().getLastCursorAnchorInfo(); |
+ Assert.assertEquals(0, info.getComposingTextStart()); |
+ Assert.assertNotNull(info.getCharacterBounds(0)); |
+ Assert.assertNotNull(info.getCharacterBounds(1)); |
+ Assert.assertNull(info.getCharacterBounds(2)); |
// Should be notified not only once. Further change should be sent, too. |
- setComposingText("abcd", 1); |
+ mRule.setComposingText("abcd", 1); |
waitForUpdateCursorAnchorInfoComposingText("abcd"); |
- info = mInputMethodManagerWrapper.getLastCursorAnchorInfo(); |
- assertEquals(0, info.getComposingTextStart()); |
- assertNotNull(info.getCharacterBounds(0)); |
- assertNotNull(info.getCharacterBounds(1)); |
- assertNotNull(info.getCharacterBounds(2)); |
- assertNotNull(info.getCharacterBounds(3)); |
- assertNull(info.getCharacterBounds(4)); |
+ info = mRule.getInputMethodManagerWrapper().getLastCursorAnchorInfo(); |
+ Assert.assertEquals(0, info.getComposingTextStart()); |
+ Assert.assertNotNull(info.getCharacterBounds(0)); |
+ Assert.assertNotNull(info.getCharacterBounds(1)); |
+ Assert.assertNotNull(info.getCharacterBounds(2)); |
+ Assert.assertNotNull(info.getCharacterBounds(3)); |
+ Assert.assertNull(info.getCharacterBounds(4)); |
// In "IMMEDIATE" mode, even when there's no change, we should be notified at least once. |
ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
@Override |
public void run() { |
- mInputMethodManagerWrapper.clearLastCursorAnchorInfo(); |
+ mRule.getInputMethodManagerWrapper().clearLastCursorAnchorInfo(); |
} |
}); |
requestCursorUpdates(InputConnection.CURSOR_UPDATE_IMMEDIATE); |
waitForUpdateCursorAnchorInfoComposingText("abcd"); |
- setComposingText("abcde", 2); |
+ mRule.setComposingText("abcde", 2); |
requestCursorUpdates(InputConnection.CURSOR_UPDATE_IMMEDIATE); |
waitForUpdateCursorAnchorInfoComposingText("abcde"); |
} |
private void requestCursorUpdates(final int cursorUpdateMode) throws Exception { |
- final InputConnection connection = mConnection; |
- runBlockingOnImeThread(new Callable<Void>() { |
+ final InputConnection connection = mRule.getConnection(); |
+ mRule.runBlockingOnImeThread(new Callable<Void>() { |
@Override |
public Void call() { |
connection.requestCursorUpdates(cursorUpdateMode); |
@@ -83,7 +100,8 @@ public class ImeLollipopTest extends ImeTest { |
CriteriaHelper.pollUiThread(new Criteria() { |
@Override |
public boolean isSatisfied() { |
- CursorAnchorInfo info = mInputMethodManagerWrapper.getLastCursorAnchorInfo(); |
+ CursorAnchorInfo info = |
+ mRule.getInputMethodManagerWrapper().getLastCursorAnchorInfo(); |
if (info != null && info.getComposingText() == null) { |
updateFailureReason("info.getCompositingText() returned null"); |
return false; |