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

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

Issue 2290133002: Make WebView keep keyboard when losing focus (Closed)
Patch Set: rebase Created 4 years, 1 month 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 4dad75455237834b10fc241c89291a79c8d6caee..25427f9c01dd45dc88ed2c9e00f4d1e2bb3ca865 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
@@ -27,6 +27,7 @@ import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.RetryOnFailure;
+import org.chromium.base.test.util.UrlUtils;
import org.chromium.base.test.util.parameter.Parameter;
import org.chromium.base.test.util.parameter.ParameterizedTest;
import org.chromium.content.browser.ContentViewCore;
@@ -118,6 +119,36 @@ public class ImeTest extends ContentShellTestBase {
resetAllStates();
}
+ private void fullyLoadUrl(final String url) throws Throwable {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ getActivity().getActiveShell().loadUrl(url);
+ }
+ });
+ waitForActiveShellToBeDoneLoading();
+ }
+
+ @MediumTest
+ @Feature({"TextInput", "Main"})
+ @RetryOnFailure
+ public void testKeyboardDismissedWhenNavigating() throws Throwable {
+ assertWaitForKeyboardStatus(true);
+
+ // Hide keyboard when loading a new Url.
+ fullyLoadUrl(UrlUtils.getIsolatedTestFileUrl(INPUT_FORM_HTML));
+ assertWaitForKeyboardStatus(false);
+
+ DOMUtils.clickNode(this, mContentViewCore, "input_text");
+ assertWaitForKeyboardStatus(true);
+
+ // Hide keyboard when navigating.
+ final String code = "document.getElementById(\"link\").click()";
+ JavaScriptUtils.executeJavaScriptAndWaitForResult(
+ getContentViewCore().getWebContents(), code);
+ assertWaitForKeyboardStatus(false);
+ }
+
@MediumTest
@Feature({"TextInput", "Main"})
public void testKeyboardDismissedAfterClickingGo() throws Throwable {
@@ -636,21 +667,15 @@ public class ImeTest extends ContentShellTestBase {
});
}
- private void reloadPage() {
+ private void reloadPage() throws Throwable {
// 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);
- }
- });
+ fullyLoadUrl(getContentViewCore().getWebContents().getUrl());
}
@SmallTest
@Feature({"TextInput"})
@RetryOnFailure
- public void testPhysicalKeyboard_AttachDetach() throws Exception {
+ public void testPhysicalKeyboard_AttachDetach() throws Throwable {
attachPhysicalKeyboard();
// We still call showSoftKeyboard, which will be ignored by physical keyboard.
waitForKeyboardStates(1, 0, 1, new Integer[] {TextInputType.TEXT});

Powered by Google App Engine
This is Rietveld 408576698