Commit 9df732f2 authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Android][Test] Improve AccountPickerBottomSheetTest stability on MM

This CL replaces waitForIdleSync() with more specific wait to improve
the AccountPickerBottomSheetTest stability on MM.

Bug: 1093050
Change-Id: I52741b71b0ef399eb84f08348cdba383618ebff5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2345307Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796396}
parent 197ceda9
......@@ -146,6 +146,7 @@ public class AccountPickerBottomSheetTest {
TestThreadUtils.runOnUiThreadBlocking(
() -> { ChromeNightModeTestUtils.setUpNightModeForChromeActivity(true); });
mRenderTestRule.setNightModeEnabled(true);
mActivityTestRule.startMainActivityOnBlankPage();
buildAndShowCollapsedBottomSheet();
mRenderTestRule.render(
mCoordinator.getBottomSheetViewForTesting(), "collapsed_sheet_with_account_dark");
......@@ -308,9 +309,14 @@ public class AccountPickerBottomSheetTest {
public void testSignInAnotherAccount() {
buildAndShowExpandedBottomSheet();
onView(withText(PROFILE_DATA2.getAccountName())).perform(click());
String continueAsText = mActivityTestRule.getActivity().getString(
R.string.signin_promo_continue_as, PROFILE_DATA2.getAccountName());
onView(withText(continueAsText)).perform(click());
View bottomSheetView = mCoordinator.getBottomSheetViewForTesting();
CriteriaHelper.pollUiThread(
bottomSheetView.findViewById(R.id.account_picker_continue_as_button)::isShown);
ThreadUtils.runOnUiThread(
bottomSheetView.findViewById(R.id.account_picker_continue_as_button)::performClick);
CriteriaHelper.pollUiThread(() -> {
return !bottomSheetView.findViewById(R.id.account_picker_continue_as_button).isShown();
});
verify(mAccountPickerDelegateMock).signIn(PROFILE_DATA2.getAccountName());
}
......@@ -393,7 +399,8 @@ public class AccountPickerBottomSheetTest {
mCoordinator = new AccountPickerBottomSheetCoordinator(mActivityTestRule.getActivity(),
getBottomSheetController(), mAccountPickerDelegateMock);
});
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
CriteriaHelper.pollUiThread(mCoordinator.getBottomSheetViewForTesting().findViewById(
R.id.account_picker_continue_as_button)::isShown);
}
private void buildAndShowExpandedBottomSheet() {
......
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