Skip to content

Commit

Permalink
Reland "Add Tangible sync flow for signin row in main settings"
Browse files Browse the repository at this point in the history
This reverts commit 7935edc.

Reason for revert:
Fixes the tests. Sync promo uses the same string as the signin
preference when there are no accounts.
In order to fix the tests an account is added to the device so that
the promo has a different text.

Original change's description:
> Revert "Add Tangible sync flow for signin row in main settings"
>
> This reverts commit 4cee937.
>
> Reason for revert: newly added tests fail on bots (see
> https://crbug.com/1353505).
>
> Original change's description:
> > Add Tangible sync flow for signin row in main settings
> >
> > This cl adds the tangible sync flow launch capability to the signin
> > preference in main settings page. This flow is guarded by a flag.
> >
> > Bug: 1332527
> > Change-Id: I9222fa0512e1fcd55a012a9fa37853a9b66b0226
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3819763
> > Reviewed-by: Boris Sazonov <bsazonov@chromium.org>
> > Commit-Queue: Tanmoy Mollik <triploblastic@chromium.org>
> > Cr-Commit-Position: refs/heads/main@{#1035435}
>
> Bug: 1332527, 1353505
> Change-Id: I6e82abcd635da0999b0c7752c77d0ef08986f193
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3834451
> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Auto-Submit: Boris Sazonov <bsazonov@chromium.org>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Cr-Commit-Position: refs/heads/main@{#1035761}

Bug: 1332527, 1353505
Change-Id: I387ba7a5c31e28a8f82726af53ac68c76ced6487
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3834251
Reviewed-by: Boris Sazonov <bsazonov@chromium.org>
Commit-Queue: Tanmoy Mollik <triploblastic@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1036573}
  • Loading branch information
Tanmoy Mollik authored and Chromium LUCI CQ committed Aug 18, 2022
1 parent 97bbdb3 commit df17791
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.preferences.Pref;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.signin.SyncConsentActivityLauncherImpl;
Expand All @@ -22,6 +23,7 @@
import org.chromium.chrome.browser.signin.services.SigninManager.SignInStateObserver;
import org.chromium.chrome.browser.sync.SyncService;
import org.chromium.chrome.browser.sync.SyncService.SyncStateChangedListener;
import org.chromium.chrome.browser.ui.signin.TangibleSyncCoordinator;
import org.chromium.components.browser_ui.settings.ManagedPreferencesUtils;
import org.chromium.components.prefs.PrefService;
import org.chromium.components.signin.AccountManagerFacade;
Expand All @@ -32,6 +34,7 @@
import org.chromium.components.signin.metrics.SigninAccessPoint;
import org.chromium.components.user_prefs.UserPrefs;
import org.chromium.ui.base.ViewUtils;
import org.chromium.ui.modaldialog.ModalDialogManagerHolder;

/**
* A preference that displays "Sign in to Chrome" when the user is not sign in, and displays
Expand Down Expand Up @@ -156,9 +159,18 @@ private void setupGenericPromo() {
setFragment(null);
setIcon(AppCompatResources.getDrawable(getContext(), R.drawable.logo_avatar_anonymous));
setViewEnabled(true);
setOnPreferenceClickListener(pref
-> SyncConsentActivityLauncherImpl.get().launchActivityIfAllowed(
getContext(), SigninAccessPoint.SETTINGS_SYNC_OFF_ROW));
setOnPreferenceClickListener(pref -> {
if (ChromeFeatureList.isEnabled(ChromeFeatureList.TANGIBLE_SYNC)) {
TangibleSyncCoordinator.start(getContext(),
((ModalDialogManagerHolder) getContext()).getModalDialogManager(),
SyncConsentActivityLauncherImpl.get(),
SigninAccessPoint.SETTINGS_SYNC_OFF_ROW);
return true;
} else {
return SyncConsentActivityLauncherImpl.get().launchActivityIfAllowed(
getContext(), SigninAccessPoint.SETTINGS_SYNC_OFF_ROW);
}
});

if (!mWasGenericSigninPromoDisplayed) {
RecordUserAction.record("Signin_Impression_FromSettings");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,38 @@ public void tearDown() {
assertSettingsExists("about_chrome", AboutChromeSettings.class);
}

@Test
@MediumTest
public void testSigninRowLaunchesSignInFlowForSignedOutAccounts() {
// When there are no accounts, sync promo and the signin preference shows the same text.
mSyncTestRule.addTestAccount();
launchSettingsActivity();

onView(withText(R.string.sync_promo_turn_on_sync)).perform(click());

verify(mMockSyncConsentActivityLauncher)
.launchActivityIfAllowed(
any(Activity.class), eq(SigninAccessPoint.SETTINGS_SYNC_OFF_ROW));
}

@Test
@MediumTest
@EnableFeatures(ChromeFeatureList.TANGIBLE_SYNC)
public void testSigninRowLaunchesTangibleSignInFlowForSignedOutAccounts() {
// When there are no accounts, sync promo and the signin preference shows the same text.
mSyncTestRule.addTestAccount();
launchSettingsActivity();

onView(withText(R.string.sync_promo_turn_on_sync)).perform(click());

onView(withText(R.string.signin_account_picker_dialog_title))
.inRoot(isDialog())
.check(matches(isDisplayed()));
onView(withText(R.string.signin_add_account_to_device))
.inRoot(isDialog())
.check(matches(isDisplayed()));
}

@Test
@SmallTest
public void testSyncRowLaunchesSignInFlowForSignedInAccounts() {
Expand Down

0 comments on commit df17791

Please sign in to comment.