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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/TabsTest.java

Issue 2290133002: Make WebView keep keyboard when losing focus (Closed)
Patch Set: Add some tests 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: chrome/android/javatests/src/org/chromium/chrome/browser/TabsTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/TabsTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/TabsTest.java
index 9c45b4bcb8e25002646619188b7b7532c28e23a1..ce173cb9e50b4d402d64d7818edab9b1ead10057 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/TabsTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/TabsTest.java
@@ -62,6 +62,7 @@ import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.test.util.CallbackHelper;
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.UiUtils;
import org.chromium.content.common.ContentSwitches;
@@ -85,6 +86,8 @@ public class TabsTest extends ChromeTabbedActivityTestBase {
private static final String TEST_FILE_PATH =
"/chrome/test/data/android/tabstest/tabs_test.html";
private static final String TEST_PAGE_FILE_PATH = "/chrome/test/data/google/google.html";
+ private static final String TEST_INPUT_FILE_PATH =
+ "/chrome/test/data/android/very_long_google.html";
private EmbeddedTestServer mTestServer;
@@ -278,6 +281,50 @@ public class TabsTest extends ChromeTabbedActivityTestBase {
});
}
+ private void assertWaitForKeyboardStatus(final boolean show) throws InterruptedException {
+ CriteriaHelper.pollUiThread(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ updateFailureReason("expected keyboard show: " + show);
+ return show
+ == org.chromium.ui.UiUtils.isKeyboardShowing(
+ getActivity(), getActivity().getTabsView());
+ }
+ });
+ }
+
+ /**
+ * Verify that opening a new tab, switching to an existing tab and closing current tab hide
+ * keyboard.
+ */
+ @MediumTest
+ public void testHideKeyboard() throws Exception {
+ mTestServer = EmbeddedTestServer.createAndStartFileServer(
+ getInstrumentation().getContext(), Environment.getExternalStorageDirectory());
+
+ startMainActivityWithURL(mTestServer.getURL(TEST_INPUT_FILE_PATH));
+ DOMUtils.clickNode(this, getActivity().getActivityTab().getContentViewCore(), "textField");
+ assertWaitForKeyboardStatus(true);
+
+ // Opens a new tab.
+ startMainActivityWithURL(mTestServer.getURL(TEST_INPUT_FILE_PATH));
+ assertWaitForKeyboardStatus(false);
+
+ DOMUtils.clickNode(this, getActivity().getActivityTab().getContentViewCore(), "textField");
+ assertWaitForKeyboardStatus(true);
+
+ // Switches to an existing tab.
+ ChromeTabUtils.switchTabInCurrentTabModel(getActivity(), 1);
+ assertWaitForKeyboardStatus(false);
+
+ DOMUtils.clickNode(this, getActivity().getActivityTab().getContentViewCore(), "textField");
+ assertWaitForKeyboardStatus(true);
+
+ // Closes current tab.
+ ChromeTabUtils.closeCurrentTab(getInstrumentation(), getActivity());
+ assertWaitForKeyboardStatus(false);
+ }
+
/**
* Verify that opening a new tab and navigating immediately sets a size on the newly created
* renderer. https://crbug.com/434477.

Powered by Google App Engine
This is Rietveld 408576698