Commit 5a12b699 authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Android][WebSignin] Enable back-pressing on incognito interstitial

This CL enables back-pressing on incognito interstitial in web sign-in
bottom sheet to return to the expanded account list.

Bug: 1122007
Change-Id: I916e30f4a48db28316ecba37480a6d2fb4be5e01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2392456Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804726}
parent 84563d6c
......@@ -102,8 +102,13 @@ class AccountPickerBottomSheetMediator implements AccountPickerCoordinator.Liste
mModel.set(AccountPickerBottomSheetProperties.VIEW_STATE,
ViewState.COLLAPSED_ACCOUNT_LIST);
return true;
} else if (viewState == ViewState.INCOGNITO_INTERSTITIAL) {
mModel.set(
AccountPickerBottomSheetProperties.VIEW_STATE, ViewState.EXPANDED_ACCOUNT_LIST);
return true;
} else {
return false;
}
return false;
}
PropertyModel getModel() {
......
......@@ -116,10 +116,16 @@ class AccountPickerBottomSheetView implements BottomSheetContent {
* Expands the account list.
*/
void expandAccountList() {
mLogoImage.setImageResource(R.drawable.chrome_sync_logo);
mAccountPickerTitle.setText(R.string.signin_account_picker_dialog_title);
mAccountPickerSubtitle.setText(R.string.signin_account_picker_bottom_sheet_subtitle);
mAccountPickerSubtitle.setVisibility(View.VISIBLE);
mHorizontalDivider.setVisibility(View.VISIBLE);
mAccountListView.setVisibility(View.VISIBLE);
mSelectedAccountView.setVisibility(View.GONE);
mContinueAsButton.setVisibility(View.GONE);
mIncognitoInterstitialView.setVisibility(View.GONE);
}
/**
......@@ -164,7 +170,6 @@ class AccountPickerBottomSheetView implements BottomSheetContent {
mLogoImage.setImageResource(R.drawable.location_bar_incognito_badge);
mIncognitoInterstitialView.setVisibility(View.VISIBLE);
mAccountPickerTitle.setVisibility(View.GONE);
mAccountPickerSubtitle.setVisibility(View.GONE);
mHorizontalDivider.setVisibility(View.GONE);
mAccountListView.setVisibility(View.GONE);
......
......@@ -6,6 +6,8 @@ package org.chromium.chrome.browser.signin;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.pressBack;
import static androidx.test.espresso.matcher.ViewMatchers.isRoot;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static org.mockito.ArgumentMatchers.any;
......@@ -133,6 +135,21 @@ public class AccountPickerBottomSheetRenderTest {
mRenderTestRule.render(mCoordinator.getBottomSheetViewForTesting(), "expanded_sheet");
}
@Test
@MediumTest
@Feature("RenderTest")
@ParameterAnnotations.UseMethodParameter(NightModeTestUtils.NightModeParams.class)
public void testExpandedSheetShowsWhenBackpressingOnIncognitoInterstitial(
boolean nightModeEnabled) throws IOException {
mAccountManagerTestRule.addAccount(PROFILE_DATA1);
mAccountManagerTestRule.addAccount(PROFILE_DATA2);
buildAndShowCollapsedBottomSheet();
onView(withText(PROFILE_DATA1.getFullName())).perform(click());
onView(withText(R.string.signin_incognito_mode_primary)).perform(click());
onView(isRoot()).perform(pressBack());
mRenderTestRule.render(mCoordinator.getBottomSheetViewForTesting(), "expanded_sheet");
}
@Test
@MediumTest
@Feature("RenderTest")
......
......@@ -183,6 +183,28 @@ public class AccountPickerBottomSheetTest {
checkCollapsedAccountList(PROFILE_DATA1);
}
@Test
@MediumTest
public void testExpandedSheetShowsWhenBackpressingOnIncognitoInterstitial() {
buildAndShowExpandedBottomSheet();
onView(withText(R.string.signin_incognito_mode_primary)).perform(click());
onView(isRoot()).perform(pressBack());
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(PROFILE_DATA1.getAccountName()), withEffectiveVisibility(VISIBLE)))
.check(matches(isDisplayed()));
onView(allOf(withText(PROFILE_DATA1.getFullName()), withEffectiveVisibility(VISIBLE)))
.check(matches(isDisplayed()));
onView(withText(PROFILE_DATA2.getAccountName())).check(matches(isDisplayed()));
onView(withText(R.string.signin_add_account_to_device)).check(matches(isDisplayed()));
onView(withId(R.id.account_picker_selected_account)).check(matches(not(isDisplayed())));
onView(withId(R.id.account_picker_continue_as_button)).check(matches(not(isDisplayed())));
}
@Test
@MediumTest
public void testAccountDisappearedOnCollapsedSheet() {
......@@ -387,7 +409,7 @@ public class AccountPickerBottomSheetTest {
private void checkIncognitoInterstitialSheet() {
onView(withId(R.id.account_picker_bottom_sheet_logo)).check(matches(isDisplayed()));
onView(withId(R.id.account_picker_bottom_sheet_title)).check(matches(not(isDisplayed())));
onView(withId(R.id.account_picker_bottom_sheet_title)).check(matches(isDisplayed()));
onView(withId(R.id.account_picker_bottom_sheet_subtitle))
.check(matches(not(isDisplayed())));
onView(withId(R.id.account_picker_horizontal_divider)).check(matches(not(isDisplayed())));
......
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