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