Commit b2a6b60d authored by Nohemi Fernandez's avatar Nohemi Fernandez Committed by Commit Bot

[iOS] Dismiss views on top of Settings UI after authentication.

Currently the sign out UI is dismissed conditionally when the
authentication flow is complete. Remove the conditional since we expect
the sign out UI every time authentication completes.

Bug: 1125631
Change-Id: Ide9805e5490377f9ec3cf5d3625622ab08e876a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2472005
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817863}
parent 92c9b113
......@@ -23,8 +23,8 @@
#error "This file requires ARC support."
#endif
using chrome_test_util::AddAccountButton;
using chrome_test_util::ButtonWithAccessibilityLabel;
using chrome_test_util::ButtonWithAccessibilityLabelId;
using chrome_test_util::PrimarySignInButton;
using chrome_test_util::SettingsAccountButton;
using chrome_test_util::SettingsDoneButton;
......@@ -153,6 +153,27 @@ id<GREYMatcher> NoBookmarksLabel() {
performAction:grey_tap()];
}
// Tests that the Settings screen is displayed after the user signs in through
// the add account flow from the account list screen entrypoint.
- (void)testSSOAddAccount {
FakeChromeIdentity* fakeIdentity = [SigninEarlGrey fakeIdentity1];
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity];
[ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI tapSettingsMenuButton:SettingsAccountButton()];
[[EarlGrey selectElementWithMatcher:AddAccountButton()]
performAction:grey_tap()];
[[EarlGrey
selectElementWithMatcher:grey_allOf(
ButtonWithAccessibilityLabel(@"Sign in"),
grey_sufficientlyVisible(), nil)]
performAction:grey_tap()];
[ChromeEarlGreyUI waitForAppToIdle];
[[EarlGrey selectElementWithMatcher:SettingsAccountButton()]
assertWithMatcher:grey_sufficientlyVisible()];
}
// Tests that the Account Settings screen is popped and the user signed out
// when the account is removed.
- (void)testSignOutOnRemoveAccount {
......
......@@ -389,9 +389,16 @@ typedef NS_ENUM(NSInteger, ItemType) {
- (void)onEndBatchOfRefreshTokenStateChanges {
[self reloadData];
[self popViewIfSignedOut];
if (![self authService] -> IsAuthenticated() &&
_dimissAccountDetailsViewControllerBlock) {
if (self.authService->IsAuthenticated() ||
_authenticationOperationInProgress) {
// The signed out state might be temporary (e.g. account switch, ...).
// Don't pop this view based on intermediary values.
return;
}
[self dismissSelfAnimated:NO];
if (_dimissAccountDetailsViewControllerBlock) {
_dimissAccountDetailsViewControllerBlock(/*animated=*/YES);
_dimissAccountDetailsViewControllerBlock = nil;
}
......@@ -418,8 +425,12 @@ typedef NS_ENUM(NSInteger, ItemType) {
}
- (void)handleDidAddAccount:(BOOL)success {
if (!success) {
return;
}
[self handleAuthenticationOperationDidFinish];
if (success && _closeSettingsOnAddAccount) {
if (_closeSettingsOnAddAccount) {
[self.dispatcher closeSettingsUI];
}
}
......@@ -569,23 +580,10 @@ typedef NS_ENUM(NSInteger, ItemType) {
}
}
// Sets |_authenticationOperationInProgress| to NO and pops this accounts
// table view controller if the user is signed out.
// Finishes the authentication flow and dismisses the accounts view.
- (void)handleAuthenticationOperationDidFinish {
DCHECK(_authenticationOperationInProgress);
_authenticationOperationInProgress = NO;
[self popViewIfSignedOut];
}
- (void)popViewIfSignedOut {
if ([self authService] -> IsAuthenticated()) {
return;
}
if (_authenticationOperationInProgress) {
// The signed out state might be temporary (e.g. account switch, ...).
// Don't pop this view based on intermediary values.
return;
}
[self dismissSelfAnimated:NO];
}
......
......@@ -125,8 +125,12 @@
}
- (void)addAccountViewControllerDidTapSignIn {
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()
->AddIdentity(_fakeIdentity);
// Fake sign-in is used to show a fake add an account screen. In this
// case _fakeIdentity will be nil.
if (_fakeIdentity) {
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()
->AddIdentity(_fakeIdentity);
}
[self dismissAndRunCompletionCallbackWithError:nil
animated:YES
completion:nil];
......
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