Commit 55b69ae2 authored by Nohemi Fernandez's avatar Nohemi Fernandez Committed by Chromium LUCI CQ

[iOS] Dismiss unified consent screen from Recent Tabs.

Fixes a bug where the unified consent screen is not dismissed when
interrupted by a Siri search on the Recent Tabs page.

- Performs complete view controller cleanup on interrupt.
- Dismisses UnifiedConsentViewController when explicitly required.
- Does not explicitly release SigninCoordinator in scene controller,
this is already handled in the completion callback.

Bug: 1115997
Change-Id: Ib4663fe1136a394020020abc76969761c5e0f170
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2600835Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840588}
parent ac10443d
......@@ -115,6 +115,7 @@ source_set("eg2_tests") {
"//components/signin/public/base",
"//ios/chrome/app/strings",
"//ios/chrome/browser/ui/authentication:eg_test_support+eg2",
"//ios/chrome/browser/ui/authentication/unified_consent:constants",
"//ios/chrome/browser/ui/content_suggestions:feature_flags",
"//ios/chrome/browser/ui/recent_tabs:recent_tabs_ui_constants",
"//ios/chrome/browser/ui/settings:constants",
......
......@@ -8,6 +8,7 @@
#import "base/test/ios/wait_util.h"
#import "ios/chrome/browser/ui/authentication/signin_earl_grey.h"
#import "ios/chrome/browser/ui/authentication/signin_earl_grey_ui.h"
#import "ios/chrome/browser/ui/authentication/unified_consent/unified_consent_constants.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_feature.h"
#import "ios/chrome/browser/ui/recent_tabs/recent_tabs_constants.h"
#include "ios/chrome/grit/ios_strings.h"
......@@ -333,6 +334,29 @@ void ChooseImportOrKeepDataSepareteDialog(id<GREYMatcher> choiceButtonMatcher) {
tapSettingsLink:NO];
}
// Tests to dismiss sign-in by opening an URL from another app.
// Sign-in opened from: recent tabs.
// Interrupted at: identity selection in user consent.
- (void)testDismissIdentityPickerSigninFromRecentTabs {
FakeChromeIdentity* fakeIdentity = [SigninEarlGrey fakeIdentity1];
[SigninEarlGrey addFakeIdentity:fakeIdentity];
[self openSigninFromView:OpenSigninMethodFromRecentTabs tapSettingsLink:NO];
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kIdentityPickerViewIdentifier)]
performAction:grey_tap()];
// Open the URL as if it was opened from another app.
[ChromeEarlGrey simulateExternalAppURLOpening];
// Check if the URL was opened.
const GURL expectedURL("http://www.example.com/");
GREYAssertEqual(expectedURL, [ChromeEarlGrey webStateVisibleURL],
@"Didn't open new tab with example.com.");
// Should be not signed in.
[SigninEarlGrey verifySignedOut];
}
// Tests to dismiss sign-in by opening an URL from another app.
// Sign-in opened from: recent tabs.
// Interrupted at: advanced sign-in.
......
......@@ -505,10 +505,10 @@ const CGFloat kFadeOutAnimationDuration = 0.16f;
__weak UserSigninCoordinator* weakSelf = self;
ProceduralBlock runCompletionCallback = ^{
[weakSelf
runCompletionCallbackWithSigninResult:SigninCoordinatorResultInterrupted
identity:self.unifiedConsentCoordinator
.selectedIdentity
showAdvancedSettingsSignin:NO];
viewControllerDismissedWithResult:SigninCoordinatorResultInterrupted
identity:weakSelf.unifiedConsentCoordinator
.selectedIdentity
settingsLinkWasTapped:NO];
if (completion) {
completion();
}
......
......@@ -52,6 +52,11 @@
[self.unifiedConsentMediator start];
}
- (void)stop {
[self.unifiedConsentViewController dismissViewControllerAnimated:YES
completion:nil];
}
- (void)scrollToBottom {
[self.unifiedConsentViewController scrollToBottom];
}
......
......@@ -807,10 +807,10 @@ const char kMultiWindowOpenInNewWindowHistogram[] =
}
// The UI should be stopped before the models they observe are stopped.
// |self.signinCoordinator| will be released on completion.
[self.signinCoordinator
interruptWithAction:SigninCoordinatorInterruptActionNoDismiss
completion:nil];
self.signinCoordinator = nil;
[self.historyCoordinator stop];
self.historyCoordinator = 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