Skip to content

Commit

Permalink
[M106]Reland "Reland "Add Tangible sync flow for signin row in main s…
Browse files Browse the repository at this point in the history
…ettings""

This reverts commit ff9407b.

Reason for revert: The sign-in row is hidden when promos are shown if
none of SYNC_ANDROID_PROMOS_WITH_ILLUSTRATION, SYNC_ANDROID_PROMOS_WITH_SINGLE_BUTTON or SYNC_ANDROID_PROMOS_WITH_TITLE is enabled.
This cl uses one of these flags - SYNC_ANDROID_PROMOS_WITH_SINGLE_BUTTON - to fix the tests.

Original change's description:
> Revert "Reland "Add Tangible sync flow for signin row in main settings""
>
> This reverts commit df17791.
>
> Reason for revert: Failing bots for another reason
> https://bugs.chromium.org/p/chromium/issues/detail?id=1353505
>
> Original change's description:
> > Reland "Add Tangible sync flow for signin row in main settings"
> >
> > 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}
>
> Bug: 1332527, 1353505
> Change-Id: Icd2b88b2d67bf945edc006e09629633a75680541
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3838475
> Commit-Queue: Lijin Shen <lazzzis@google.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Owners-Override: Lijin Shen <lazzzis@google.com>
> Cr-Commit-Position: refs/heads/main@{#1036813}

(cherry picked from commit 0955f0f)

Bug: 1332527, 1353505
Change-Id: I0ba69c3047a91f01ac508d277a1c30797cd9a97e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3845610
Reviewed-by: Boris Sazonov <bsazonov@chromium.org>
Commit-Queue: Tanmoy Mollik <triploblastic@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1037803}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3851522
Auto-Submit: Boris Sazonov <bsazonov@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Reviewed-by: Tanmoy Mollik <triploblastic@chromium.org>
Cr-Commit-Position: refs/branch-heads/5249@{#52}
Cr-Branched-From: 4f7bea5-refs/heads/main@{#1036826}
  • Loading branch information
Tanmoy Mollik authored and Chromium LUCI CQ committed Aug 23, 2022
1 parent cb09cce commit d9228f6
Show file tree
Hide file tree
Showing 2 changed files with 50 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,41 @@ public void tearDown() {
assertSettingsExists("about_chrome", AboutChromeSettings.class);
}

@Test
@MediumTest
@EnableFeatures(ChromeFeatureList.SYNC_ANDROID_PROMOS_WITH_SINGLE_BUTTON)
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,
ChromeFeatureList.SYNC_ANDROID_PROMOS_WITH_SINGLE_BUTTON})
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 d9228f6

Please sign in to comment.