Commit c4870e2e authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[MF] Stop children when resetting the coordinator

Fixes stop and start.
Resetting now will stop the children.
Updates tests to also verify the children are reset.

Bug: 1007257, 1007928
Change-Id: I19f24fbf8d0bf3f5e761d394e1a357544bd9752f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1821905
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700339}
parent 65c55035
......@@ -74,40 +74,46 @@
browserState:browserState];
if (self) {
_webStateList = webStateList;
_injectionHandler = injectionHandler;
_formInputAccessoryViewController =
[[FormInputAccessoryViewController alloc]
initWithManualFillAccessoryViewControllerDelegate:self];
auto passwordStore = IOSChromePasswordStoreFactory::GetForBrowserState(
browserState, ServiceAccessType::EXPLICIT_ACCESS);
// There is no personal data manager in OTR (incognito). Get the original
// one for manual fallback.
autofill::PersonalDataManager* personalDataManager =
autofill::PersonalDataManagerFactory::GetForBrowserState(
browserState->GetOriginalChromeBrowserState());
_formInputAccessoryMediator = [[FormInputAccessoryMediator alloc]
initWithConsumer:self.formInputAccessoryViewController
delegate:self
webStateList:webStateList
personalDataManager:personalDataManager
passwordStore:passwordStore];
_dispatcher = dispatcher;
}
return self;
}
- (void)start {
_formInputAccessoryViewController = [[FormInputAccessoryViewController alloc]
initWithManualFillAccessoryViewControllerDelegate:self];
auto passwordStore = IOSChromePasswordStoreFactory::GetForBrowserState(
self.browserState, ServiceAccessType::EXPLICIT_ACCESS);
// There is no personal data manager in OTR (incognito). Get the original
// one for manual fallback.
autofill::PersonalDataManager* personalDataManager =
autofill::PersonalDataManagerFactory::GetForBrowserState(
self.browserState->GetOriginalChromeBrowserState());
_formInputAccessoryMediator = [[FormInputAccessoryMediator alloc]
initWithConsumer:self.formInputAccessoryViewController
delegate:self
webStateList:self.webStateList
personalDataManager:personalDataManager
passwordStore:passwordStore];
}
- (void)stop {
[self stopChildren];
[self.formInputAccessoryViewController restoreOriginalKeyboardView];
self.formInputAccessoryViewController = nil;
[self.formInputAccessoryMediator disconnect];
self.formInputAccessoryMediator = nil;
}
- (void)reset {
[self stopChildren];
[self.formInputAccessoryMediator enableSuggestions];
[self.formInputAccessoryViewController reset];
}
......@@ -183,23 +189,19 @@
// On iOS 13, beta 3, the popover is not dismissed when the keyboard hides.
// This explicitly dismiss any popover.
if (base::ios::IsRunningOnIOS13OrLater() && IsIPadIdiom()) {
[self stopChildren];
[self.formInputAccessoryMediator enableSuggestions];
[self.formInputAccessoryViewController reset];
[self reset];
}
}
- (void)mediatorDidDetectMovingToBackground:
(FormInputAccessoryMediator*)mediator {
[self.formInputAccessoryViewController reset];
[self reset];
}
#pragma mark - ManualFillAccessoryViewControllerDelegate
- (void)keyboardButtonPressed {
[self stopChildren];
[self.formInputAccessoryMediator enableSuggestions];
[self.formInputAccessoryViewController reset];
[self reset];
}
- (void)accountButtonPressed:(UIButton*)sender {
......@@ -227,33 +229,32 @@
- (void)fallbackCoordinatorDidDismissPopover:
(FallbackCoordinator*)fallbackCoordinator {
[self.formInputAccessoryMediator enableSuggestions];
[self.formInputAccessoryViewController reset];
[self reset];
}
#pragma mark - PasswordCoordinatorDelegate
- (void)openPasswordSettings {
[self.formInputAccessoryViewController reset];
[self reset];
[self.navigator openPasswordSettings];
}
- (void)openAllPasswordsPicker {
[self.formInputAccessoryViewController reset];
[self reset];
[self.navigator openAllPasswordsPicker];
}
#pragma mark - CardCoordinatorDelegate
- (void)openCardSettings {
[self.formInputAccessoryViewController reset];
[self reset];
[self.navigator openCreditCardSettings];
}
#pragma mark - AddressCoordinatorDelegate
- (void)openAddressSettings {
[self.formInputAccessoryViewController reset];
[self reset];
[self.navigator openAddressSettings];
}
......
......@@ -227,9 +227,9 @@ void ClearProfiles(autofill::PersonalDataManager* personalDataManager) {
assertWithMatcher:grey_sufficientlyVisible()];
}
// Tests that returning from "Manage Addresses..." leaves the icons in the right
// state.
- (void)testAddressesButtonStateAfterPresentingManageAddresses {
// Tests that returning from "Manage Addresses..." leaves the icons and keyboard
// in the right state.
- (void)testAddressesStateAfterPresentingManageAddresses {
// Bring up the keyboard.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementName)];
......@@ -269,6 +269,10 @@ void ClearProfiles(autofill::PersonalDataManager* personalDataManager) {
assertWithMatcher:grey_userInteractionEnabled()];
[[EarlGrey selectElementWithMatcher:KeyboardIconMatcher()]
assertWithMatcher:grey_not(grey_sufficientlyVisible())];
// Verify the keyboard is not cover by the profiles view.
[[EarlGrey selectElementWithMatcher:ProfilesTableViewMatcher()]
assertWithMatcher:grey_notVisible()];
}
// Tests that the Address View Controller is dismissed when tapping the
......
......@@ -301,9 +301,9 @@ BOOL WaitForJavaScriptCondition(NSString* java_script_condition) {
assertWithMatcher:grey_sufficientlyVisible()];
}
// Tests that the manual fallback view icon is not highlighted after presenting
// the manage credit cards view.
- (void)testCreditCardsButtonStateAfterPresentingCreditCardSettings {
// Tests that the manual fallback view and icon is not highlighted after
// presenting the manage credit cards view.
- (void)testCreditCardsStateAfterPresentingCreditCardSettings {
[self saveLocalCreditCard];
// Bring up the keyboard.
......@@ -341,6 +341,10 @@ BOOL WaitForJavaScriptCondition(NSString* java_script_condition) {
assertWithMatcher:grey_userInteractionEnabled()];
[[EarlGrey selectElementWithMatcher:KeyboardIconMatcher()]
assertWithMatcher:grey_not(grey_sufficientlyVisible())];
// Verify the keyboard is not cover by the cards view.
[[EarlGrey selectElementWithMatcher:CreditCardTableViewMatcher()]
assertWithMatcher:grey_notVisible()];
}
// Tests that the "Add Credit Cards..." action works.
......@@ -445,6 +449,10 @@ BOOL WaitForJavaScriptCondition(NSString* java_script_condition) {
assertWithMatcher:grey_userInteractionEnabled()];
[[EarlGrey selectElementWithMatcher:KeyboardIconMatcher()]
assertWithMatcher:grey_not(grey_sufficientlyVisible())];
// Verify the keyboard is not cover by the cards view.
[[EarlGrey selectElementWithMatcher:CreditCardTableViewMatcher()]
assertWithMatcher:grey_notVisible()];
}
// Tests that the credit card View Controller is dismissed when tapping the
......
......@@ -329,9 +329,9 @@ BOOL WaitForJavaScriptCondition(NSString* java_script_condition) {
assertWithMatcher:grey_sufficientlyVisible()];
}
// Tests that returning from "Manage Passwords..." leaves the icons in the right
// state.
- (void)testPasswordsButtonStateAfterPresentingManagePasswords {
// Tests that returning from "Manage Passwords..." leaves the keyboard and the
// icons in the right state.
- (void)testPasswordsStateAfterPresentingManagePasswords {
// Bring up the keyboard.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
performAction:TapWebElementWithId(kFormElementUsername)];
......@@ -363,6 +363,10 @@ BOOL WaitForJavaScriptCondition(NSString* java_script_condition) {
assertWithMatcher:grey_userInteractionEnabled()];
[[EarlGrey selectElementWithMatcher:KeyboardIconMatcher()]
assertWithMatcher:grey_not(grey_sufficientlyVisible())];
// Verify the keyboard is not cover by the password view.
[[EarlGrey selectElementWithMatcher:PasswordTableViewMatcher()]
assertWithMatcher:grey_notVisible()];
}
// Tests that the "Use Other Password..." action works.
......@@ -384,9 +388,9 @@ BOOL WaitForJavaScriptCondition(NSString* java_script_condition) {
assertWithMatcher:grey_sufficientlyVisible()];
}
// Tests that returning from "Use Other Password..." leaves the icons in the
// right state.
- (void)testPasswordsButtonStateAfterPresentingUseOtherPassword {
// Tests that returning from "Use Other Password..." leaves the view and icons
// in the right state.
- (void)testPasswordsStateAfterPresentingUseOtherPassword {
// Bring up the keyboard.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
performAction:TapWebElementWithId(kFormElementUsername)];
......@@ -418,6 +422,10 @@ BOOL WaitForJavaScriptCondition(NSString* java_script_condition) {
assertWithMatcher:grey_userInteractionEnabled()];
[[EarlGrey selectElementWithMatcher:KeyboardIconMatcher()]
assertWithMatcher:grey_not(grey_sufficientlyVisible())];
// Verify the keyboard is not cover by the password view.
[[EarlGrey selectElementWithMatcher:PasswordTableViewMatcher()]
assertWithMatcher:grey_notVisible()];
}
// Tests that the Password View Controller is not present when presenting UI.
......
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