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

[iOS] Add animation parameter to cancelAndDismiss in AuthenticationFlow.

Fixed: 1056634
Change-Id: I18e13be1bbee5449b865745719a9f38ea1432096
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2387765Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803816}
parent 89a048b0
......@@ -62,10 +62,10 @@ class Browser;
- (void)startSignInWithCompletion:(signin_ui::CompletionCallback)completion;
// Cancels the current sign-in operation (if any) and dismiss any UI presented
// by this authentication flow. Calls the completion callback with the sign-in
// flag set to NO.
// Does nothing if the sign in flow is already done.
- (void)cancelAndDismiss;
// by this authentication flow with animation if |animated|. Calls the
// completion callback with the sign-in flag set to NO. Does nothing if the sign
// in flow is already done.
- (void)cancelAndDismissAnimated:(BOOL)animated;
// The dispatcher used to clear browsing data.
@property(nonatomic, weak) id<BrowsingDataCommands> dispatcher;
......
......@@ -142,11 +142,11 @@ NSError* IdentityMissingError() {
[self continueSignin];
}
- (void)cancelAndDismiss {
- (void)cancelAndDismissAnimated:(BOOL)animated {
if (_state == DONE)
return;
[_performer cancelAndDismiss];
[_performer cancelAndDismissAnimated:animated];
if (_state != DONE) {
// The performer might not have been able to continue the flow if it was
// waiting for a callback (e.g. waiting for AccountReconcilor). In this
......
......@@ -27,8 +27,9 @@ class ChromeBrowserState;
- (instancetype)init NS_UNAVAILABLE;
// Cancels any outstanding work and dismisses an alert view (if shown).
- (void)cancelAndDismiss;
// Cancels any outstanding work and dismisses an alert view (if shown) using
// animation if |animated| is true.
- (void)cancelAndDismissAnimated:(BOOL)animated;
// Starts sync for |browserState|.
- (void)commitSyncForBrowserState:(ChromeBrowserState*)browserState;
......
......@@ -91,13 +91,13 @@ const int64_t kAuthenticationFlowTimeoutSeconds = 10;
return self;
}
- (void)cancelAndDismiss {
- (void)cancelAndDismissAnimated:(BOOL)animated {
[_alertCoordinator executeCancelHandler];
[_alertCoordinator stop];
if (_navigationController) {
[_navigationController cleanUpSettings];
_navigationController = nil;
[_delegate dismissPresentingViewControllerAnimated:NO completion:nil];
[_delegate dismissPresentingViewControllerAnimated:animated completion:nil];
}
[self stopWatchdogTimer];
}
......
......@@ -236,12 +236,12 @@ TEST_F(AuthenticationFlowTest, TestCancel) {
browserState:browser_state_.get()];
[[[performer_ expect] andDo:^(NSInvocation*) {
[authentication_flow_ cancelAndDismiss];
[authentication_flow_ cancelAndDismissAnimated:NO];
}] promptMergeCaseForIdentity:identity1_
browser:browser_.get()
viewController:view_controller_];
[[performer_ expect] cancelAndDismiss];
[[performer_ expect] cancelAndDismissAnimated:NO];
[authentication_flow_ startSignInWithCompletion:sign_in_completion_];
......
......@@ -459,7 +459,6 @@ const CGFloat kFadeOutAnimationDuration = 0.16f;
DCHECK(self.unifiedConsentCoordinator);
DCHECK(!self.addAccountSigninCoordinator);
DCHECK(!self.advancedSettingsSigninCoordinator);
[self.mediator cancelAndDismissAuthenticationFlow];
__weak UserSigninCoordinator* weakSelf = self;
ProceduralBlock runCompletionCallback = ^{
[weakSelf
......@@ -473,15 +472,18 @@ const CGFloat kFadeOutAnimationDuration = 0.16f;
};
switch (action) {
case SigninCoordinatorInterruptActionNoDismiss: {
[self.mediator cancelAndDismissAuthenticationFlowAnimated:NO];
runCompletionCallback();
break;
}
case SigninCoordinatorInterruptActionDismissWithAnimation: {
[self.mediator cancelAndDismissAuthenticationFlowAnimated:YES];
[self.viewController dismissViewControllerAnimated:YES
completion:runCompletionCallback];
break;
}
case SigninCoordinatorInterruptActionDismissWithoutAnimation: {
[self.mediator cancelAndDismissAuthenticationFlowAnimated:NO];
[self.viewController dismissViewControllerAnimated:NO
completion:runCompletionCallback];
break;
......
......@@ -78,8 +78,9 @@ class UnifiedConsentService;
// Reverts the sign-in operation.
- (void)cancelSignin;
// Cancels and dismisses the authentication flow if sign-in is in progress.
- (void)cancelAndDismissAuthenticationFlow;
// Cancels and dismisses with animation if |animated| the authentication flow
// when sign-in is in progress.
- (void)cancelAndDismissAuthenticationFlowAnimated:(BOOL)animated;
@end
......
......@@ -75,20 +75,19 @@
- (void)cancelSignin {
if (self.isAuthenticationInProgress) {
[self cancelAndDismissAuthenticationFlow];
[self cancelAndDismissAuthenticationFlowAnimated:NO];
} else {
[self.delegate userSigninMediatorSigninFinishedWithResult:
SigninCoordinatorResultCanceledByUser];
}
}
- (void)cancelAndDismissAuthenticationFlow {
- (void)cancelAndDismissAuthenticationFlowAnimated:(BOOL)animated {
if (!self.isAuthenticationInProgress) {
return;
}
// TODO(crbug.com/1056634): Support cancelAndDismiss with animation parameter.
[self.authenticationFlow cancelAndDismiss];
[self.authenticationFlow cancelAndDismissAnimated:animated];
self.authenticationService->SignOut(signin_metrics::ABORT_SIGNIN,
/*force_clear_browsing_data=*/false, nil);
}
......
......@@ -168,9 +168,9 @@ class UserSigninMediatorTest : public PlatformTest {
});
}
// Sets up the expectations for cancelAndDismiss in the
// Sets up the expectations for cancelAndDismissAnimated in the
// AuthenticationFlowPerformer.
void SetPerformerCancelAndDismissExpectations() {
void SetPerformerCancelAndDismissExpectations(BOOL animated) {
OCMExpect([performer_mock_ fetchManagedStatus:browser_state_.get()
forIdentity:identity_])
.andDo(^(NSInvocation*) {
......@@ -184,7 +184,7 @@ class UserSigninMediatorTest : public PlatformTest {
promptMergeCaseForIdentity:identity_
browser:browser_.get()
viewController:presenting_view_controller_mock_]);
OCMExpect([performer_mock_ cancelAndDismiss]);
OCMExpect([performer_mock_ cancelAndDismissAnimated:animated]);
}
void ExpectNoConsent() {
......@@ -344,7 +344,7 @@ TEST_F(UserSigninMediatorTest, CancelAuthenticationNotInProgress) {
// Tests a user sign-in operation cancel when authentication is in progress.
TEST_F(UserSigninMediatorTest, CancelWithAuthenticationInProgress) {
SetPerformerCancelAndDismissExpectations();
SetPerformerCancelAndDismissExpectations(/*animated=*/NO);
// Unsuccessful sign-in completion updates the primary button.
OCMExpect([mediator_delegate_mock_ userSigninMediatorSigninFailed]);
......@@ -358,20 +358,36 @@ TEST_F(UserSigninMediatorTest, CancelWithAuthenticationInProgress) {
// Tests a user sign-in operation cancel and dismiss when authentication has not
// begun.
TEST_F(UserSigninMediatorTest, CancelAndDismissAuthenticationNotInProgress) {
[mediator_ cancelAndDismissAuthenticationFlow];
[mediator_ cancelAndDismissAuthenticationFlowAnimated:NO];
ExpectNoConsent();
}
// Tests a user sign-in operation cancel and dismiss when authentication is in
// progress.
TEST_F(UserSigninMediatorTest, CancelAndDismissAuthenticationInProgress) {
SetPerformerCancelAndDismissExpectations();
// Tests a user sign-in operation cancel and dismiss with animation when
// authentication is in progress.
TEST_F(UserSigninMediatorTest,
CancelAndDismissAuthenticationInProgressWithAnimation) {
SetPerformerCancelAndDismissExpectations(/*animated=*/YES);
// Unsuccessful sign-in completion updates the primary button.
OCMExpect([mediator_delegate_mock_ userSigninMediatorSigninFailed]);
[mediator_ authenticateWithIdentity:identity_
authenticationFlow:authentication_flow_];
[mediator_ cancelAndDismissAuthenticationFlow];
[mediator_ cancelAndDismissAuthenticationFlowAnimated:YES];
ExpectNoConsent();
}
// Tests a user sign-in operation cancel and dismiss without animation when
// authentication is in progress.
TEST_F(UserSigninMediatorTest,
CancelAndDismissAuthenticationInProgressWithoutAnimation) {
SetPerformerCancelAndDismissExpectations(/*animated=*/NO);
// Unsuccessful sign-in completion updates the primary button.
OCMExpect([mediator_delegate_mock_ userSigninMediatorSigninFailed]);
[mediator_ authenticateWithIdentity:identity_
authenticationFlow:authentication_flow_];
[mediator_ cancelAndDismissAuthenticationFlowAnimated:NO];
ExpectNoConsent();
}
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