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 73fd4101aca53c94fe8112eda8dcc4881600954f..75809c5eed25af2fe6f5d46f93d4f5d330b78796 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 |
@@ -23,11 +23,11 @@ |
import org.chromium.base.ThreadUtils; |
import org.chromium.base.test.util.Feature; |
import org.chromium.base.test.util.FlakyTest; |
+import org.chromium.base.test.util.UrlUtils; |
import org.chromium.content.browser.ContentViewCore; |
import org.chromium.content.browser.test.util.Criteria; |
import org.chromium.content.browser.test.util.CriteriaHelper; |
import org.chromium.content.browser.test.util.DOMUtils; |
-import org.chromium.content.browser.test.util.JavaScriptUtils; |
import org.chromium.content.browser.test.util.TestCallbackHelperContainer; |
import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper; |
import org.chromium.content_public.browser.WebContents; |
@@ -45,12 +45,23 @@ |
* Integration tests for text input using cases based on fixed regressions. |
*/ |
public class ImeTest extends ContentShellTestBase { |
+ private static final String DATA_URL = UrlUtils.encodeHtmlDataUri( |
+ "<html><head><meta name=\"viewport\"" |
+ + "content=\"width=device-width\" /></head>" |
+ + "<body><form action=\"about:blank\">" |
+ + "<input id=\"input_text\" type=\"text\" /><br/></form><form>" |
+ + "<br/><input id=\"input_radio\" type=\"radio\" style=\"width:50px;height:50px\" />" |
+ + "<br/><textarea id=\"textarea\" rows=\"4\" cols=\"20\"></textarea>" |
+ + "<br/><textarea id=\"textarea2\" rows=\"4\" cols=\"20\" autocomplete=\"off\">" |
+ + "</textarea>" |
+ + "<br/><input id=\"input_number1\" type=\"number\" /><br/>" |
+ + "<br/><input id=\"input_number2\" type=\"number\" /><br/>" |
+ + "<br/><p><span id=\"plain_text\">This is Plain Text One</span></p>" |
+ + "</form></body></html>"); |
+ |
protected ChromiumBaseInputConnection mConnection; |
private TestInputConnectionFactory mConnectionFactory; |
private ImeAdapter mImeAdapter; |
- |
- private static final String INPUT_FORM_HTML = |
- "content/test/data/android/input/input_forms.html"; |
private ContentViewCore mContentViewCore; |
private WebContents mWebContents; |
@@ -60,7 +71,9 @@ |
@Override |
public void setUp() throws Exception { |
super.setUp(); |
- startActivityWithTestUrl(INPUT_FORM_HTML); |
+ |
+ launchContentShellWithUrl(DATA_URL); |
+ waitForActiveShellToBeDoneLoading(); |
mContentViewCore = getContentViewCore(); |
mWebContents = getWebContents(); |
@@ -425,17 +438,6 @@ |
@Override |
public void run() { |
mContentViewCore.onConfigurationChanged(config); |
- } |
- }); |
- } |
- |
- private void reloadPage() { |
- // Reload the page, then focus will be lost and keyboard should be hidden. |
- ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
- @Override |
- public void run() { |
- final String currentUrl = getContentViewCore().getWebContents().getUrl(); |
- getActivity().getActiveShell().loadUrl(currentUrl); |
} |
}); |
} |
@@ -453,8 +455,13 @@ |
// Now we really show soft keyboard. We also call restartInput when configuration changes. |
waitForKeyboardStates(2, 0, 2, new Integer[] {TextInputType.TEXT, TextInputType.TEXT}); |
- reloadPage(); |
- |
+ // Reload the page, then focus will be lost and keyboard should be hidden. |
+ getInstrumentation().runOnMainSync(new Runnable() { |
+ @Override |
+ public void run() { |
+ getActivity().getActiveShell().loadUrl(DATA_URL); |
+ } |
+ }); |
// Depending on the timing, hideSoftInput and restartInput call counts may vary here |
// because render widget gets restarted. But the end result should be the same. |
assertWaitForKeyboardStatus(false); |
@@ -1062,79 +1069,6 @@ |
commitText("ab", 2); |
restartInput(); |
assertEquals("ab", getTextBeforeCursor(10, 0)); |
- } |
- |
- @MediumTest |
- @Feature({"TextInput"}) |
- public void testContentEditableEvents_SetComposingText() throws Throwable { |
- focusElementAndWaitForStateUpdate("contenteditable_event"); |
- beginBatchEdit(); |
- setComposingText("a", 1); |
- finishComposingText(); |
- endBatchEdit(); |
- waitAndVerifyUpdateSelection(0, 1, 1, -1, -1); |
- |
- // TODO(changwan): reduce the number of selection changes |
- waitForEventLogs("selectionchange,selectionchange,selectionchange," |
- + "keydown(229),compositionstart(),compositionupdate(a),input," |
- + "keyup(229),compositionend(a),input,selectionchange,selectionchange," |
- + "selectionchange,selectionchange,selectionchange"); |
- } |
- |
- private void waitForEventLogs(String expectedLogs) throws Throwable { |
- final String code = "getEventLogs()"; |
- final String sanitizedExpectedLogs = "\"" + expectedLogs + "\""; |
- if (usingReplicaInputConnection()) { |
- // When using replica input connection, JavaScript update will lands later. |
- CriteriaHelper.pollInstrumentationThread(new Criteria() { |
- @Override |
- public boolean isSatisfied() { |
- try { |
- String eventLogs = JavaScriptUtils.executeJavaScriptAndWaitForResult( |
- getContentViewCore().getWebContents(), code); |
- updateFailureReason(eventLogs); |
- return sanitizedExpectedLogs.equals(eventLogs); |
- } catch (InterruptedException | TimeoutException e) { |
- updateFailureReason(e.getMessage()); |
- return false; |
- } |
- } |
- }); |
- } else { |
- assertEquals(sanitizedExpectedLogs, JavaScriptUtils.executeJavaScriptAndWaitForResult( |
- getContentViewCore().getWebContents(), code)); |
- } |
- } |
- |
- @MediumTest |
- @Feature({"TextInput"}) |
- public void testCommitTextDoesNotTriggerCompositionEvents() throws Throwable { |
- if (usingReplicaInputConnection()) return; |
- focusElementAndWaitForStateUpdate("contenteditable0"); |
- commitText("a", 1); |
- waitAndVerifyUpdateSelection(0, 1, 1, -1, -1); |
- |
- final String code = "getEventLogs()"; |
- final String expectedLogs = "\"keydown(229),keyup(229),\""; |
- if (usingReplicaInputConnection()) { |
- CriteriaHelper.pollInstrumentationThread(new Criteria() { |
- @Override |
- public boolean isSatisfied() { |
- try { |
- String eventLogs = JavaScriptUtils.executeJavaScriptAndWaitForResult( |
- getContentViewCore().getWebContents(), code); |
- updateFailureReason(eventLogs); |
- return expectedLogs.equals(eventLogs); |
- } catch (InterruptedException | TimeoutException e) { |
- updateFailureReason(e.getMessage()); |
- return false; |
- } |
- } |
- }); |
- } else { |
- assertEquals(expectedLogs, JavaScriptUtils.executeJavaScriptAndWaitForResult( |
- getContentViewCore().getWebContents(), code)); |
- } |
} |
private void performGo(TestCallbackHelperContainer testCallbackHelperContainer) |
@@ -1306,26 +1240,6 @@ |
return ImeTestUtils.runBlockingOnHandler(mConnectionFactory.getHandler(), c); |
} |
- private boolean beginBatchEdit() throws Exception { |
- final ChromiumBaseInputConnection connection = mConnection; |
- return runBlockingOnImeThread(new Callable<Boolean>() { |
- @Override |
- public Boolean call() { |
- return connection.beginBatchEdit(); |
- } |
- }); |
- } |
- |
- private boolean endBatchEdit() throws Exception { |
- final ChromiumBaseInputConnection connection = mConnection; |
- return runBlockingOnImeThread(new Callable<Boolean>() { |
- @Override |
- public Boolean call() { |
- return connection.endBatchEdit(); |
- } |
- }); |
- } |
- |
private boolean commitText(final CharSequence text, final int newCursorPosition) |
throws Exception { |
final ChromiumBaseInputConnection connection = mConnection; |