Commit 6265bc32 authored by Ted Choc's avatar Ted Choc Committed by Commit Bot

Attempt two to deflake TabModalPresenterTest[s]

With the past deflake attempt, it ensured the menu was present
except when in the overview mode.  This made tests that enter/exit
the overview mode (e.g. tab switcher) prone to continued flakes.

This removes the broad menu ID checks with explicit checks on the
browsing mode toolbar button, which is the same logic the
TabModalPresenter uses internally.  Now, the tests should not
have any dependencies on the toolbar visibility based on browser
controls offsetting logic.

BUG=1026908

Change-Id: I420d6700148abf57098ab3f88d0187cef2133bd4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1934773
Commit-Queue: Theresa  <twellington@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718925}
parent 728efa36
......@@ -10,7 +10,6 @@ import static android.support.test.espresso.assertion.ViewAssertions.doesNotExis
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.hasDescendant;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.isEnabled;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
......@@ -51,8 +50,6 @@ import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.ChromeTabUtils;
import org.chromium.chrome.test.util.OmniboxTestUtils;
import org.chromium.content_public.browser.test.util.Criteria;
import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.ui.modaldialog.DialogDismissalCause;
import org.chromium.ui.modaldialog.ModalDialogManager;
......@@ -483,30 +480,20 @@ public class TabModalPresenterTest {
}
private void checkBrowserControls(boolean restricted) {
CriteriaHelper.pollUiThread(new Criteria() {
@Override
public boolean isSatisfied() {
View menu = mActivity.getToolbarManager().getMenuButtonView();
if (menu == null) {
updateFailureReason("Menu button is null.");
return false;
}
// getMenuButtonView returns the menu button for the browsing mode toolbar view
// regardless of whether the app is in the tab switching UI. If showing the tab
// switcher, then do not force the toolbar button to be visible.
if (mActivity.isInOverviewMode()) return true;
updateFailureReason("Menu button is not shown.");
return menu.isShown();
}
boolean isViewObscuringAllTabs = TestThreadUtils.runOnUiThreadBlockingNoException(
() -> mActivity.isViewObscuringAllTabs());
boolean isMenuEnabled = TestThreadUtils.runOnUiThreadBlockingNoException(() -> {
View menu = mActivity.getToolbarManager().getMenuButtonView();
Assert.assertNotNull("Toolbar menu is incorrectly null.", menu);
return menu.isEnabled();
});
if (restricted) {
assertTrue("All tabs should be obscured", mActivity.isViewObscuringAllTabs());
onView(allOf(isDisplayed(), withId(R.id.menu_button))).check(matches(not(isEnabled())));
assertTrue("All tabs should be obscured", isViewObscuringAllTabs);
Assert.assertFalse("Menu is incorrectly enabled.", isMenuEnabled);
} else {
Assert.assertFalse("Tabs shouldn't be obscured", mActivity.isViewObscuringAllTabs());
onView(allOf(isDisplayed(), withId(R.id.menu_button))).check(matches(isEnabled()));
Assert.assertFalse("Tabs shouldn't be obscured", isViewObscuringAllTabs);
assertTrue("Menu is incorrectly disabled.", isMenuEnabled);
}
}
}
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