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

[Android][WebSignin] Add render tests for sign-in general error retry

This CL adds render tests to check that clicking on the |Try Again|
button of the sign-in general error view opens the sign-in in progress
view.

Bug: 1120308
Change-Id: If11c943987c6d722665241d26a933f90655c1c7f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2379711Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803046}
parent b24f0041
...@@ -8,6 +8,10 @@ import static androidx.test.espresso.Espresso.onView; ...@@ -8,6 +8,10 @@ import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.matcher.ViewMatchers.withText; import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.MockitoAnnotations.initMocks; import static org.mockito.MockitoAnnotations.initMocks;
import android.view.View; import android.view.View;
...@@ -22,6 +26,7 @@ import org.junit.Test; ...@@ -22,6 +26,7 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.chromium.base.Callback;
import org.chromium.base.test.params.ParameterAnnotations; import org.chromium.base.test.params.ParameterAnnotations;
import org.chromium.base.test.params.ParameterizedRunner; import org.chromium.base.test.params.ParameterizedRunner;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
...@@ -39,6 +44,9 @@ import org.chromium.chrome.test.util.browser.Features; ...@@ -39,6 +44,9 @@ import org.chromium.chrome.test.util.browser.Features;
import org.chromium.chrome.test.util.browser.signin.AccountManagerTestRule; import org.chromium.chrome.test.util.browser.signin.AccountManagerTestRule;
import org.chromium.components.browser_ui.bottomsheet.BottomSheetController; import org.chromium.components.browser_ui.bottomsheet.BottomSheetController;
import org.chromium.components.signin.ProfileDataSource; import org.chromium.components.signin.ProfileDataSource;
import org.chromium.components.signin.base.CoreAccountInfo;
import org.chromium.components.signin.base.GoogleServiceAuthError;
import org.chromium.components.signin.base.GoogleServiceAuthError.State;
import org.chromium.components.signin.test.util.FakeProfileDataSource; import org.chromium.components.signin.test.util.FakeProfileDataSource;
import org.chromium.content_public.browser.test.util.CriteriaHelper; import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
...@@ -132,6 +140,45 @@ public class AccountPickerBottomSheetRenderTest { ...@@ -132,6 +140,45 @@ public class AccountPickerBottomSheetRenderTest {
public void testSignInInProgressView(boolean nightModeEnabled) throws IOException { public void testSignInInProgressView(boolean nightModeEnabled) throws IOException {
mAccountManagerTestRule.addAccount(PROFILE_DATA1); mAccountManagerTestRule.addAccount(PROFILE_DATA1);
buildAndShowCollapsedBottomSheet(); buildAndShowCollapsedBottomSheet();
clickContinueButtonAndCheckSigninInProgressView();
}
@Test
@MediumTest
@Feature("RenderTest")
@ParameterAnnotations.UseMethodParameter(NightModeTestUtils.NightModeParams.class)
public void testTryAgainButtonOnSignInGeneralErrorSheet(boolean nightModeEnabled)
throws IOException {
mAccountManagerTestRule.addAccount(PROFILE_DATA1);
CoreAccountInfo coreAccountInfo =
mAccountManagerTestRule.toCoreAccountInfo(PROFILE_DATA1.getAccountName());
// Throws a connection error during the sign-in action
doAnswer(invocation -> {
Callback<GoogleServiceAuthError> onSignInErrorCallback = invocation.getArgument(1);
onSignInErrorCallback.onResult(new GoogleServiceAuthError(State.CONNECTION_FAILED));
return null;
})
.when(mAccountPickerDelegateMock)
.signIn(eq(coreAccountInfo), any());
buildAndShowCollapsedBottomSheet();
clickContinueButtonAndWaitForErrorView();
doNothing().when(mAccountPickerDelegateMock).signIn(eq(coreAccountInfo), any());
clickContinueButtonAndCheckSigninInProgressView();
}
private void clickContinueButtonAndWaitForErrorView() {
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 clickContinueButtonAndCheckSigninInProgressView() throws IOException {
View bottomSheetView = mCoordinator.getBottomSheetViewForTesting(); View bottomSheetView = mCoordinator.getBottomSheetViewForTesting();
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
bottomSheetView.findViewById(R.id.account_picker_continue_as_button).performClick(); bottomSheetView.findViewById(R.id.account_picker_continue_as_button).performClick();
......
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