Commit 8308b9ba authored by Friedrich Horschig's avatar Friedrich Horschig Committed by Commit Bot

[Android] Reduce Manual Filling test flakiness

This CL applies small fixes th the tests that make them less flaky:
 * use a small keyboard height but reduce the threshold to make it
   display-independent
 * ensure the tab overview is present for tests that need it
 * dismiss keyboards with a library function instead of the more flaky
   back press

Bug: 857460
Change-Id: Id460847bdc2df7f8bbc0d1a04c96f151e3dff0ae
Reviewed-on: https://chromium-review.googlesource.com/c/1225767
Commit-Queue: Friedrich Horschig [CEST] <fhorschig@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597548}
parent 3f520fed
......@@ -31,6 +31,7 @@ import org.junit.runner.RunWith;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.ChromeSwitches;
......@@ -44,6 +45,7 @@ import org.chromium.chrome.test.util.InfoBarTestAnimationListener;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.ui.DropdownPopupWindowInterface;
import org.chromium.ui.test.util.UiRestriction;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
......@@ -229,6 +231,7 @@ public class ManualFillingIntegrationTest {
@Test
@SmallTest
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE)
public void testInvokingTabSwitcherHidesAccessory()
throws InterruptedException, TimeoutException {
mHelper.loadTestPage(false);
......@@ -243,10 +246,10 @@ public class ManualFillingIntegrationTest {
mHelper.waitForKeyboardToDisappear();
whenDisplayed(withId(R.id.keyboard_accessory_sheet));
ThreadUtils.runOnUiThreadBlocking(() -> {
mActivityTestRule.getActivity().getLayoutManager().showOverview(false);
mActivityTestRule.getActivity().getLayoutManager().hideOverview(false);
});
ThreadUtils.runOnUiThreadBlocking(
() -> { mActivityTestRule.getActivity().getLayoutManager().showOverview(false); });
ThreadUtils.runOnUiThreadBlocking(
() -> { mActivityTestRule.getActivity().getLayoutManager().hideOverview(false); });
mHelper.waitToBeHidden(withId(R.id.keyboard_accessory_sheet));
}
......@@ -280,8 +283,8 @@ public class ManualFillingIntegrationTest {
ThreadUtils.runOnUiThreadBlocking(
() -> { mActivityTestRule.getActivity().onResumeWithNative(); });
// Clicking the field should bring it back up
mHelper.clickPasswordField();
// Clicking the field should bring the accessory back up.
mHelper.clickEmailField();
mHelper.waitForKeyboard();
// Click the tab to show the sheet and hide the keyboard.
......@@ -351,7 +354,11 @@ public class ManualFillingIntegrationTest {
mHelper.waitForKeyboardToDisappear();
whenDisplayed(withId(R.id.keyboard_accessory_sheet));
assertThat(mActivityTestRule.getInfoBarContainer().getVisibility(), is(not(View.VISIBLE)));
Espresso.pressBack();
// Reopen the keyboard, then close it.
whenDisplayed(withId(R.id.tabs)).perform(selectTabAtPosition(0));
mHelper.waitForKeyboard();
mActivityTestRule.getKeyboardDelegate().hideKeyboard(null);
mHelper.waitToBeHidden(withId(R.id.keyboard_accessory_sheet));
mHelper.waitToBeHidden(withId(R.id.keyboard_accessory));
......
......@@ -59,7 +59,8 @@ public class ManualFillingTestHelper {
private TestInputMethodManagerWrapper mInputMethodManagerWrapper;
private class FakeKeyboard extends KeyboardVisibilityDelegate {
static final int KEYBOARD_HEIGHT = 400;
static final int KEYBOARD_HEIGHT = 234;
private boolean mIsShowing;
@Override
......@@ -91,6 +92,11 @@ public class ManualFillingTestHelper {
return mIsShowing ? KEYBOARD_HEIGHT : 0;
}
@Override
protected int calculateKeyboardDetectionThreshold(Context context, View rootView) {
return 0;
}
/**
* Creates an inset observer view calculating the bottom inset based on the fake keyboard.
* @param context Context used to instantiate this view.
......
......@@ -160,7 +160,7 @@ public class KeyboardVisibilityDelegate {
return bottomMargin; // This might include a bottom navigation.
}
private int calculateKeyboardDetectionThreshold(Context context, View rootView) {
protected int calculateKeyboardDetectionThreshold(Context context, View rootView) {
Rect appRect = new Rect();
rootView.getWindowVisibleDisplayFrame(appRect);
......
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