Commit 060d3ad5 authored by Friedrich Horschig's avatar Friedrich Horschig Committed by Commit Bot

[Android] Prevent Accessory from forcing InfoBar open

Before the keyboard accessory was visible on password fields only,
it was correct to suppress the InfobarContainer until the accessory
disappeared.

Now that the accessory can disappear while keeping the keyboard open,
the Infobar would be shown with an open keyboard. This CL fixes this
unwanted state by checking keyboard visibility explicitly.

This is an intermediate solution until crrev/c/1286426 lands.

Bug: 895779
Change-Id: I1d24b5c71ce094102e9860cd415277d9570c19df
Reviewed-on: https://chromium-review.googlesource.com/c/1286820
Commit-Queue: Friedrich Horschig [CEST] <fhorschig@chromium.org>
Reviewed-by: default avatarIoana Pandele <ioanap@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600777}
parent cfd9f565
......@@ -435,8 +435,13 @@ class ManualFillingMediator
*/
private void updateInfobarState(boolean shouldBeHidden) {
if (mActiveBrowserTab == null) return;
if (InfoBarContainer.get(mActiveBrowserTab) == null) return;
InfoBarContainer.get(mActiveBrowserTab).setHidden(shouldBeHidden);
InfoBarContainer infobarContainer = InfoBarContainer.get(mActiveBrowserTab);
if (infobarContainer == null) return;
boolean suppressedByKeyboardOrAccessory = shouldBeHidden;
ViewGroup contentView = getContentView();
suppressedByKeyboardOrAccessory |= contentView != null
&& mWindowAndroid.getKeyboardDelegate().isKeyboardShowing(mActivity, contentView);
infobarContainer.setHidden(suppressedByKeyboardOrAccessory);
}
@VisibleForTesting
......
......@@ -343,31 +343,58 @@ public class ManualFillingIntegrationTest {
mHelper.waitToBeHidden(withId(R.id.keyboard_accessory));
}
@Test
@SmallTest
public void testInfobarStaysHiddenWhileChangingFieldsWithOpenKeybaord()
throws InterruptedException, TimeoutException {
mHelper.loadTestPage(false);
InfoBarTestAnimationListener listener = new InfoBarTestAnimationListener();
mActivityTestRule.getInfoBarContainer().addAnimationListener(listener);
final String kInfoBarText = "SomeInfoBar";
ThreadUtils.runOnUiThread(() -> {
SimpleConfirmInfoBarBuilder.create(mActivityTestRule.getActivity().getActivityTab(),
InfoBarIdentifier.DUPLICATE_DOWNLOAD_INFOBAR_DELEGATE_ANDROID, kInfoBarText,
false);
});
listener.addInfoBarAnimationFinished("InfoBar not added.");
mHelper.createTestTab();
whenDisplayed(withText(kInfoBarText));
// Focus the field to bring up the accessory.
mHelper.clickPasswordField();
mHelper.waitForKeyboard();
assertThat(mActivityTestRule.getInfoBarContainer().getVisibility(), is(not(View.VISIBLE)));
// Clicking another field hides the accessory, but the InfoBar should remain invisible.
mHelper.clickEmailField(false);
assertThat(mActivityTestRule.getInfoBarContainer().getVisibility(), is(not(View.VISIBLE)));
// Close the keyboard to bring back the InfoBar.
mActivityTestRule.getKeyboardDelegate().hideKeyboard(null);
mHelper.waitForKeyboardToDisappear();
mHelper.waitToBeHidden(withId(R.id.keyboard_accessory));
whenDisplayed(withText(kInfoBarText));
}
@Test
@SmallTest
public void testInfobarStaysHiddenWhenOpeningSheet()
throws InterruptedException, TimeoutException {
mHelper.loadTestPage(false);
// TODO Create an infobar
InfoBarTestAnimationListener mListener = new InfoBarTestAnimationListener();
mActivityTestRule.getInfoBarContainer().addAnimationListener(mListener);
final SimpleConfirmInfoBarBuilder.Listener testListener =
new SimpleConfirmInfoBarBuilder.Listener() {
@Override
public void onInfoBarDismissed() {}
@Override
public boolean onInfoBarButtonClicked(boolean isPrimary) {
return false;
}
};
InfoBarTestAnimationListener listener = new InfoBarTestAnimationListener();
mActivityTestRule.getInfoBarContainer().addAnimationListener(listener);
final String kInfoBarText = "SomeInfoBar";
ThreadUtils.runOnUiThread(() -> {
SimpleConfirmInfoBarBuilder.create(mActivityTestRule.getActivity().getActivityTab(),
testListener, InfoBarIdentifier.DUPLICATE_DOWNLOAD_INFOBAR_DELEGATE_ANDROID, 0,
kInfoBarText, null, null, false);
InfoBarIdentifier.DUPLICATE_DOWNLOAD_INFOBAR_DELEGATE_ANDROID, kInfoBarText,
false);
});
mListener.addInfoBarAnimationFinished("InfoBar not added.");
listener.addInfoBarAnimationFinished("InfoBar not added.");
mHelper.createTestTab();
whenDisplayed(withText(kInfoBarText));
......
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