Commit c9d9423e authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Commit Bot

[iOS] Manage sync should not commit sync when being closed

When kMobileIdentityConsistency flag is disabled, the sync should be
confirmed or disabled by GoogleServicesCoordinator.

Bug introduced: crrev.com/c/2463306

Fixed: 1141961
Change-Id: I2bd01a0c43458758f0088a17594bf5291900c510
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2498525
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarNohemi Fernandez <fernandex@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821317}
parent b5e9435f
......@@ -35,6 +35,8 @@ using chrome_test_util::AddAccountButton;
using chrome_test_util::ButtonWithAccessibilityLabelId;
using chrome_test_util::GoogleServicesSettingsButton;
using chrome_test_util::SettingsDoneButton;
using chrome_test_util::SettingsMenuBackButton;
using chrome_test_util::SyncSettingsConfirmButton;
// Integration tests using the Google services settings screen.
@interface GoogleServicesSettingsTestCase : ChromeTestCase
......@@ -349,6 +351,47 @@ using chrome_test_util::SettingsDoneButton;
@"Failed to toggle-on password leak checks");
}
// Tests the following steps:
// + Opens sign-in from Google services
// + Taps on the settings link to open the advanced sign-in settings
// + Opens "Manage Sync" twice
// The "Manage Sync" should not be disabled when closing "Manage Sync" view.
- (void)testOpenManageSyncSettings {
FakeChromeIdentity* fakeIdentity = [SigninEarlGrey fakeIdentity1];
[SigninEarlGrey addFakeIdentity:fakeIdentity];
[ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI
tapSettingsMenuButton:chrome_test_util::PrimarySignInButton()];
[SigninEarlGreyUI tapSettingsLink];
// Open "Manage Sync" settings.
id<GREYMatcher> manageSyncMatcher =
[self cellMatcherWithTitleID:IDS_IOS_MANAGE_SYNC_SETTINGS_TITLE
detailTextID:0];
[[EarlGrey selectElementWithMatcher:manageSyncMatcher]
performAction:grey_tap()];
id<GREYMatcher> backButtonMatcher =
grey_allOf(SettingsMenuBackButton(),
grey_descendant(grey_kindOfClass([UIImageView class])), nil);
// Back to the Google services settings view.
[[EarlGrey selectElementWithMatcher:backButtonMatcher]
performAction:grey_tap()];
// Open "Manage Sync" settings, again.
[[EarlGrey selectElementWithMatcher:manageSyncMatcher]
performAction:grey_tap()];
// Back to the Google services settings view.
[[EarlGrey selectElementWithMatcher:backButtonMatcher]
performAction:grey_tap()];
// Close the advance settings.
[[EarlGrey selectElementWithMatcher:SyncSettingsConfirmButton()]
performAction:grey_tap()];
// Test the user is signed in.
[SigninEarlGrey verifySignedInWithFakeIdentity:fakeIdentity];
}
#pragma mark - Helpers
// Opens the Google services settings.
......
......@@ -113,9 +113,16 @@ using signin_metrics::PromoAction;
}
- (void)stop {
// If kMobileIdentityConsistency is disabled,
// GoogleServicesSettingsCoordinator is in charge to enable sync or not when
// being closed. This coordinator displays a sub view.
// With kMobileIdentityConsistency enabled:
// This coordinator displays the main view and it is in charge to enable sync
// or not when being closed.
// Sync changes should only be commited if the user is authenticated and
// the sign-in has not been interrupted.
if (self.authService->IsAuthenticated() || !self.signinInterrupted) {
if (base::FeatureList::IsEnabled(signin::kMobileIdentityConsistency) &&
(self.authService->IsAuthenticated() || !self.signinInterrupted)) {
SyncSetupService* syncSetupService =
SyncSetupServiceFactory::GetForBrowserState(
self.browser->GetBrowserState());
......
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