Commit 96fb4562 authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Android][WebSignIn] Implement UI for sign-in auth error

This CL sets up the UI for sign-in auth error in the web sign-in bottom
sheet. The specific strings and auth error handling will be added in
the subsequent CLs.

Bug: 1116952
Change-Id: Ib9160d251f6c0e516af2805b2e346e08320bda96
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2366722Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800212}
parent afaee234
...@@ -21,6 +21,7 @@ import org.chromium.components.signin.AccountsChangeObserver; ...@@ -21,6 +21,7 @@ import org.chromium.components.signin.AccountsChangeObserver;
import org.chromium.components.signin.base.CoreAccountId; import org.chromium.components.signin.base.CoreAccountId;
import org.chromium.components.signin.base.CoreAccountInfo; import org.chromium.components.signin.base.CoreAccountInfo;
import org.chromium.components.signin.base.GoogleServiceAuthError; import org.chromium.components.signin.base.GoogleServiceAuthError;
import org.chromium.components.signin.base.GoogleServiceAuthError.State;
import org.chromium.ui.modelutil.PropertyModel; import org.chromium.ui.modelutil.PropertyModel;
import java.util.Collections; import java.util.Collections;
...@@ -190,8 +191,12 @@ class AccountPickerBottomSheetMediator implements AccountPickerCoordinator.Liste ...@@ -190,8 +191,12 @@ class AccountPickerBottomSheetMediator implements AccountPickerCoordinator.Liste
} }
private void onSignInError(GoogleServiceAuthError error) { private void onSignInError(GoogleServiceAuthError error) {
// TODO(https://crbug.com/1116952): Implement UI for sign-in auth error if (error.getState() == State.INVALID_GAIA_CREDENTIALS) {
mModel.set(AccountPickerBottomSheetProperties.ACCOUNT_PICKER_BOTTOM_SHEET_STATE, mModel.set(AccountPickerBottomSheetProperties.ACCOUNT_PICKER_BOTTOM_SHEET_STATE,
AccountPickerBottomSheetState.SIGNIN_GENERAL_ERROR); AccountPickerBottomSheetState.SIGNIN_AUTH_ERROR);
} else {
mModel.set(AccountPickerBottomSheetProperties.ACCOUNT_PICKER_BOTTOM_SHEET_STATE,
AccountPickerBottomSheetState.SIGNIN_GENERAL_ERROR);
}
} }
} }
...@@ -32,6 +32,7 @@ class AccountPickerBottomSheetProperties { ...@@ -32,6 +32,7 @@ class AccountPickerBottomSheetProperties {
AccountPickerBottomSheetState.SIGNIN_IN_PROGRESS, AccountPickerBottomSheetState.SIGNIN_IN_PROGRESS,
AccountPickerBottomSheetState.INCOGNITO_INTERSTITIAL, AccountPickerBottomSheetState.INCOGNITO_INTERSTITIAL,
AccountPickerBottomSheetState.SIGNIN_GENERAL_ERROR, AccountPickerBottomSheetState.SIGNIN_GENERAL_ERROR,
AccountPickerBottomSheetState.SIGNIN_AUTH_ERROR,
}) })
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@interface AccountPickerBottomSheetState { @interface AccountPickerBottomSheetState {
...@@ -88,6 +89,14 @@ class AccountPickerBottomSheetProperties { ...@@ -88,6 +89,14 @@ class AccountPickerBottomSheetProperties {
* The state can be reached when an error appears during the sign-in process. * The state can be reached when an error appears during the sign-in process.
*/ */
int SIGNIN_GENERAL_ERROR = 5; int SIGNIN_GENERAL_ERROR = 5;
/**
* When user cannot complete sign-in due to invalidate credential, the
* sign-in auth error screen will be shown.
*
* The state can be reached when an auth error appears during the sign-in process.
*/
int SIGNIN_AUTH_ERROR = 6;
} }
// PropertyKeys for the selected account view when the account list is collapsed. // PropertyKeys for the selected account view when the account list is collapsed.
......
...@@ -162,6 +162,21 @@ class AccountPickerBottomSheetView implements BottomSheetContent { ...@@ -162,6 +162,21 @@ class AccountPickerBottomSheetView implements BottomSheetContent {
mSelectedAccountView.setVisibility(View.GONE); mSelectedAccountView.setVisibility(View.GONE);
} }
/**
* Sets up the view for sign-in auth error.
* TODO(https://crbug.com/1116952): Add strings for subtitle and button for sign-in auth error
*/
void setUpSignInAuthErrorView() {
mAccountPickerTitle.setText(R.string.signin_account_picker_bottom_sheet_error_title);
mAccountPickerSubtitle.setVisibility(View.VISIBLE);
mContentView.findViewById(R.id.account_picker_signin_spinner_view)
.setVisibility(View.INVISIBLE);
mContinueAsButton.setVisibility(View.VISIBLE);
mContentView.findViewById(R.id.account_picker_horizontal_divider).setVisibility(View.GONE);
mSelectedAccountView.setVisibility(View.GONE);
}
@Override @Override
public View getContentView() { public View getContentView() {
return mContentView; return mContentView;
......
...@@ -62,6 +62,9 @@ class AccountPickerBottomSheetViewBinder { ...@@ -62,6 +62,9 @@ class AccountPickerBottomSheetViewBinder {
case AccountPickerBottomSheetState.SIGNIN_GENERAL_ERROR: case AccountPickerBottomSheetState.SIGNIN_GENERAL_ERROR:
view.setUpSignInGeneralErrorView(); view.setUpSignInGeneralErrorView();
break; break;
case AccountPickerBottomSheetState.SIGNIN_AUTH_ERROR:
view.setUpSignInAuthErrorView();
break;
default: default:
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Cannot bind AccountPickerBottomSheetView for the state:" "Cannot bind AccountPickerBottomSheetView for the state:"
......
...@@ -56,6 +56,7 @@ import org.chromium.chrome.test.util.browser.signin.AccountManagerTestRule; ...@@ -56,6 +56,7 @@ 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.AccountManagerFacadeProvider; import org.chromium.components.signin.AccountManagerFacadeProvider;
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;
import org.chromium.components.signin.base.GoogleServiceAuthError.State; import org.chromium.components.signin.base.GoogleServiceAuthError.State;
import org.chromium.components.signin.test.util.FakeAccountManagerFacade; import org.chromium.components.signin.test.util.FakeAccountManagerFacade;
...@@ -312,6 +313,37 @@ public class AccountPickerBottomSheetTest { ...@@ -312,6 +313,37 @@ public class AccountPickerBottomSheetTest {
onView(withId(R.id.account_picker_signin_spinner_view)).check(matches(not(isDisplayed()))); onView(withId(R.id.account_picker_signin_spinner_view)).check(matches(not(isDisplayed())));
} }
@Test
@MediumTest
public void testSignInAuthError() {
CoreAccountInfo coreAccountInfo =
mAccountManagerTestRule.toCoreAccountInfo(PROFILE_DATA1.getAccountName());
// Throws an auth error during the sign-in action
doAnswer(invocation -> {
Callback<GoogleServiceAuthError> onSignInErrorCallback = invocation.getArgument(1);
onSignInErrorCallback.onResult(
new GoogleServiceAuthError(State.INVALID_GAIA_CREDENTIALS));
return null;
})
.when(mAccountPickerDelegateMock)
.signIn(eq(coreAccountInfo), any());
buildAndShowCollapsedBottomSheet();
View bottomSheetView = mCoordinator.getBottomSheetViewForTesting();
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))
.check(matches(isDisplayed()));
onView(withId(R.id.account_picker_horizontal_divider)).check(matches(not(isDisplayed())));
onView(withId(R.id.account_picker_selected_account)).check(matches(not(isDisplayed())));
onView(withId(R.id.account_picker_signin_spinner_view)).check(matches(not(isDisplayed())));
}
@Test @Test
@MediumTest @MediumTest
public void testAddAccountOnExpandedSheet() { public void testAddAccountOnExpandedSheet() {
......
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