Commit c24619b2 authored by changwan's avatar changwan Committed by Commit bot

Stop hiding soft input from CompositorViewHolder

CompositorViewHolder hides keyboard on switching tabs. We found that it
is causing a StrictMode violation error in KK (due to a flaw in Android
framework).

But CVH removes ContentView, which eventually calls
ImeAdapter#onViewFocusChanged(false) and then we hide the keyboard anyways.

Therefore, removing the redundant code from CVH and adding a test to
future-proof the behavior.

BUG=623256
TBR=dtrainor@chromium.org

Review-Url: https://codereview.chromium.org/2108203003
Cr-Commit-Position: refs/heads/master@{#403325}
parent 004c0486
......@@ -24,7 +24,6 @@ import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.inputmethod.InputMethodManager;
import android.widget.FrameLayout;
import org.chromium.base.SysUtils;
......@@ -819,14 +818,6 @@ public class CompositorViewHolder extends CoordinatorLayout
ContentViewCore content = sCachedCVCList.get(i);
if (content.isAlive()) content.getContainerView().setVisibility(View.INVISIBLE);
}
if (hasFocus()) {
InputMethodManager manager = (InputMethodManager) getContext().getSystemService(
Context.INPUT_METHOD_SERVICE);
if (manager.isActive(this)) {
manager.hideSoftInputFromWindow(getWindowToken(), 0, null);
}
}
removeView(mView);
}
}
......
......@@ -22,6 +22,10 @@ import org.chromium.chrome.test.util.ChromeRestriction;
import org.chromium.chrome.test.util.ChromeTabUtils;
import org.chromium.chrome.test.util.TabStripUtils;
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.ui.UiUtils;
import org.chromium.ui.base.LocalizationUtils;
import java.util.concurrent.TimeoutException;
......@@ -656,6 +660,29 @@ public class TabStripTest extends ChromeTabbedActivityTestBase {
assertTabVisibility(true, tab);
}
/**
* Tests that switching tabs hides keyboard.
*/
@LargeTest
@Restriction(ChromeRestriction.RESTRICTION_TYPE_TABLET)
@Feature({"TabStrip", "IME"})
public void testSwitchingTabsHidesKeyboard() throws Throwable {
loadUrl("data:text/html;charset=utf-8,<html><head></head><body><form>"
+ "<input type='text' id='input0'></form></body></html>");
DOMUtils.clickNode(this, getActivity().getActivityTab().getContentViewCore(), "input0");
assertWaitForKeyboardStatus(true);
getInstrumentation().waitForIdleSync();
ChromeTabUtils.clickNewTabButton(this, this);
getInstrumentation().waitForIdleSync();
assertEquals("Expected two tabs to exist",
getActivity().getTabModelSelector().getModel(false).getCount(), 2);
assertWaitForKeyboardStatus(false);
}
/**
* Test that the draw positions for tabs match expectations at various scroll positions
* when using the ScrollingStripStacker.
......@@ -1027,4 +1054,21 @@ public class TabStripTest extends ChromeTabbedActivityTestBase {
private void assertTabDrawX(float expectedDrawX, StripLayoutTab tabView) {
assertEquals("Incorrect draw position for tab.", expectedDrawX, tabView.getDrawX());
}
/**
* Asserts that we get the keyboard status to be shown or hidden.
* @param expectsShown Whether shown status is expected.
* @throws InterruptedException
*/
private void assertWaitForKeyboardStatus(final boolean expectsShown)
throws InterruptedException {
CriteriaHelper.pollInstrumentationThread(new Criteria() {
@Override
public boolean isSatisfied() {
updateFailureReason("expectsShown: " + expectsShown);
return expectsShown == UiUtils.isKeyboardShowing(getActivity(),
getActivity().getActivityTab().getView());
}
});
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment