Commit dd9fc29c authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Android][Test] Refactor AccountPickerBottomSheetTest

This CL refactors AccountPickerBottomSheetTest by extracting the method
clickContinueButtonAndWaitForErrorSheet() and add two more checks in
checkCollapsedAccountList() method.

Bug: 1121536
Change-Id: Id7a890ad66b244ea171c7a24d583c402600fca83
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2383029Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804150}
parent 5881c1ad
...@@ -283,14 +283,7 @@ public class AccountPickerBottomSheetTest { ...@@ -283,14 +283,7 @@ public class AccountPickerBottomSheetTest {
any()); any());
buildAndShowCollapsedBottomSheet(); buildAndShowCollapsedBottomSheet();
View bottomSheetView = mCoordinator.getBottomSheetViewForTesting(); clickContinueButtonAndWaitForErrorSheet();
ThreadUtils.runOnUiThread(
bottomSheetView.findViewById(R.id.account_picker_continue_as_button)::performClick);
CriteriaHelper.pollUiThread(() -> {
return !bottomSheetView.findViewById(R.id.account_picker_selected_account).isShown()
&& bottomSheetView.findViewById(R.id.account_picker_bottom_sheet_subtitle)
.isShown();
});
onView(withText(R.string.signin_account_picker_bottom_sheet_error_title)) onView(withText(R.string.signin_account_picker_bottom_sheet_error_title))
.check(matches(isDisplayed())); .check(matches(isDisplayed()));
onView(withText(R.string.signin_account_picker_general_error_subtitle)) onView(withText(R.string.signin_account_picker_general_error_subtitle))
...@@ -318,14 +311,7 @@ public class AccountPickerBottomSheetTest { ...@@ -318,14 +311,7 @@ public class AccountPickerBottomSheetTest {
.signIn(eq(coreAccountInfo), any()); .signIn(eq(coreAccountInfo), any());
buildAndShowCollapsedBottomSheet(); buildAndShowCollapsedBottomSheet();
View bottomSheetView = mCoordinator.getBottomSheetViewForTesting(); clickContinueButtonAndWaitForErrorSheet();
ThreadUtils.runOnUiThread(
bottomSheetView.findViewById(R.id.account_picker_continue_as_button)::performClick);
CriteriaHelper.pollUiThread(() -> {
return !bottomSheetView.findViewById(R.id.account_picker_selected_account).isShown()
&& bottomSheetView.findViewById(R.id.account_picker_bottom_sheet_subtitle)
.isShown();
});
onView(withText(R.string.signin_account_picker_bottom_sheet_error_title)) onView(withText(R.string.signin_account_picker_bottom_sheet_error_title))
.check(matches(isDisplayed())); .check(matches(isDisplayed()));
onView(withText(R.string.signin_account_picker_auth_error_subtitle)) onView(withText(R.string.signin_account_picker_auth_error_subtitle))
...@@ -351,14 +337,7 @@ public class AccountPickerBottomSheetTest { ...@@ -351,14 +337,7 @@ public class AccountPickerBottomSheetTest {
.signIn(eq(coreAccountInfo), any()); .signIn(eq(coreAccountInfo), any());
buildAndShowCollapsedBottomSheet(); buildAndShowCollapsedBottomSheet();
View bottomSheetView = mCoordinator.getBottomSheetViewForTesting(); clickContinueButtonAndWaitForErrorSheet();
ThreadUtils.runOnUiThread(
bottomSheetView.findViewById(R.id.account_picker_continue_as_button)::performClick);
CriteriaHelper.pollUiThread(() -> {
return !bottomSheetView.findViewById(R.id.account_picker_selected_account).isShown()
&& bottomSheetView.findViewById(R.id.account_picker_bottom_sheet_subtitle)
.isShown();
});
doNothing().when(mAccountPickerDelegateMock).signIn(eq(coreAccountInfo), any()); doNothing().when(mAccountPickerDelegateMock).signIn(eq(coreAccountInfo), any());
// Clicking on the |Try again| button should perform the sign-in again and opens the sign-in // Clicking on the |Try again| button should perform the sign-in again and opens the sign-in
// in progress page. // in progress page.
...@@ -414,10 +393,21 @@ public class AccountPickerBottomSheetTest { ...@@ -414,10 +393,21 @@ public class AccountPickerBottomSheetTest {
.check(matches(not(isDisplayed()))); .check(matches(not(isDisplayed())));
onView(withId(R.id.account_picker_horizontal_divider)).check(matches(not(isDisplayed()))); onView(withId(R.id.account_picker_horizontal_divider)).check(matches(not(isDisplayed())));
onView(withId(R.id.account_picker_account_list)).check(matches(not(isDisplayed()))); onView(withId(R.id.account_picker_account_list)).check(matches(not(isDisplayed())));
onView(withId(R.id.incognito_interstitial_bottom_sheet_view)).check(matches(isDisplayed())); onView(withId(R.id.incognito_interstitial_bottom_sheet_view)).check(matches(isDisplayed()));
} }
private void clickContinueButtonAndWaitForErrorSheet() {
View bottomSheetView = mCoordinator.getBottomSheetViewForTesting();
TestThreadUtils.runOnUiThreadBlocking(() -> {
bottomSheetView.findViewById(R.id.account_picker_continue_as_button).performClick();
});
CriteriaHelper.pollUiThread(() -> {
return !bottomSheetView.findViewById(R.id.account_picker_selected_account).isShown()
&& bottomSheetView.findViewById(R.id.account_picker_bottom_sheet_subtitle)
.isShown();
});
}
private void clickContinueButtonAndCheckSignInInProgressSheet() { private void clickContinueButtonAndCheckSignInInProgressSheet() {
View bottomSheetView = mCoordinator.getBottomSheetViewForTesting(); View bottomSheetView = mCoordinator.getBottomSheetViewForTesting();
ThreadUtils.runOnUiThread( ThreadUtils.runOnUiThread(
...@@ -465,6 +455,9 @@ public class AccountPickerBottomSheetTest { ...@@ -465,6 +455,9 @@ public class AccountPickerBottomSheetTest {
CriteriaHelper.pollUiThread(mCoordinator.getBottomSheetViewForTesting().findViewById( CriteriaHelper.pollUiThread(mCoordinator.getBottomSheetViewForTesting().findViewById(
R.id.account_picker_selected_account)::isShown); R.id.account_picker_selected_account)::isShown);
onView(withText(R.string.signin_account_picker_dialog_title)).check(matches(isDisplayed())); onView(withText(R.string.signin_account_picker_dialog_title)).check(matches(isDisplayed()));
onView(withText(R.string.signin_account_picker_bottom_sheet_subtitle))
.check(matches(isDisplayed()));
onView(withId(R.id.account_picker_horizontal_divider)).check(matches(isDisplayed()));
onView(allOf(withText(profileData.getAccountName()), withEffectiveVisibility(VISIBLE))) onView(allOf(withText(profileData.getAccountName()), withEffectiveVisibility(VISIBLE)))
.check(matches(isDisplayed())); .check(matches(isDisplayed()));
if (profileData.getFullName() != null) { if (profileData.getFullName() != null) {
......
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