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

[iOS][MF] Keyboard dismissal

This CL presents the popover in the same window as the accessory button.
By doing this it won't be hidden by the keyboard and it will dissapear
when the user interacts with the keyboard.

Bug: 845472
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I5ab3243cb8d6281105d77387b384692086e260b9
Reviewed-on: https://chromium-review.googlesource.com/c/1268342
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600191}
parent faf0b7f8
...@@ -106,9 +106,14 @@ initWithBaseViewController:(UIViewController*)viewController ...@@ -106,9 +106,14 @@ initWithBaseViewController:(UIViewController*)viewController
self.passwordViewController.modalPresentationStyle = self.passwordViewController.modalPresentationStyle =
UIModalPresentationPopover; UIModalPresentationPopover;
[self.baseViewController presentViewController:self.passwordViewController // The |button.window.rootViewController| is used in order to present above
animated:YES // the keyboard. This way the popover will be dismissed on keyboard
completion:nil]; // interaction and it won't be covered when the keyboard is near the top of
// the screen.
[button.window.rootViewController
presentViewController:self.passwordViewController
animated:YES
completion:nil];
UIPopoverPresentationController* popoverPresentationController = UIPopoverPresentationController* popoverPresentationController =
self.passwordViewController.popoverPresentationController; self.passwordViewController.popoverPresentationController;
......
...@@ -14,6 +14,7 @@ namespace manual_fill { ...@@ -14,6 +14,7 @@ namespace manual_fill {
extern NSString* const PasswordSearchBarAccessibilityIdentifier; extern NSString* const PasswordSearchBarAccessibilityIdentifier;
extern NSString* const PasswordTableViewAccessibilityIdentifier; extern NSString* const PasswordTableViewAccessibilityIdentifier;
extern NSString* const PasswordDoneButtonAccessibilityIdentifier;
} // namespace manual_fill } // namespace manual_fill
......
...@@ -99,6 +99,13 @@ id<GREYMatcher> PasswordSettingsSearchMatcher() { ...@@ -99,6 +99,13 @@ id<GREYMatcher> PasswordSettingsSearchMatcher() {
return grey_accessibilityID(@"SettingsSearchCellTextField"); return grey_accessibilityID(@"SettingsSearchCellTextField");
} }
// Returns a matcher for the PasswordTableView window.
id<GREYMatcher> PasswordTableViewWindowMatcher() {
id<GREYMatcher> classMatcher = grey_kindOfClass([UIWindow class]);
id<GREYMatcher> parentMatcher = grey_descendant(PasswordTableViewMatcher());
return grey_allOf(classMatcher, parentMatcher, nil);
}
// Gets the current password store. // Gets the current password store.
scoped_refptr<password_manager::PasswordStore> GetPasswordStore() { scoped_refptr<password_manager::PasswordStore> GetPasswordStore() {
// ServiceAccessType governs behaviour in Incognito: only modifications with // ServiceAccessType governs behaviour in Incognito: only modifications with
...@@ -423,7 +430,9 @@ void ClearPasswordStore() { ...@@ -423,7 +430,9 @@ void ClearPasswordStore() {
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
// Tap on a point outside of the popover. // Tap on a point outside of the popover.
[[EarlGrey selectElementWithMatcher:grey_keyWindow()] // The way EarlGrey taps doesn't go through the window hierarchy. Because of
// this, the tap needs to be done in the same window as the popover.
[[EarlGrey selectElementWithMatcher:PasswordTableViewWindowMatcher()]
performAction:grey_tapAtPoint(CGPointMake(0, 0))]; performAction:grey_tapAtPoint(CGPointMake(0, 0))];
// Verify the password controller table view and the password icon is NOT // Verify the password controller table view and the password icon is NOT
...@@ -433,4 +442,34 @@ void ClearPasswordStore() { ...@@ -433,4 +442,34 @@ void ClearPasswordStore() {
[[EarlGrey selectElementWithMatcher:KeyboardIconMatcher()] [[EarlGrey selectElementWithMatcher:KeyboardIconMatcher()]
assertWithMatcher:grey_notVisible()]; assertWithMatcher:grey_notVisible()];
} }
// Tests that the Password View Controller is dismissed when tapping the
// keyboard.
- (void)testTappingKeyboardDismissPasswordControllerPopOver {
if (!IsIPadIdiom()) {
return;
}
// Bring up the keyboard.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
performAction:chrome_test_util::TapWebElement(kFormElementUsername)];
// Tap on the passwords icon.
[[EarlGrey selectElementWithMatcher:PasswordIconMatcher()]
performAction:grey_tap()];
// Verify the password controller table view is visible.
[[EarlGrey selectElementWithMatcher:PasswordTableViewMatcher()]
assertWithMatcher:grey_sufficientlyVisible()];
[[EarlGrey selectElementWithMatcher:PasswordTableViewMatcher()]
performAction:grey_typeText(@"text")];
// Verify the password controller table view and the password icon is NOT
// visible.
[[EarlGrey selectElementWithMatcher:PasswordTableViewMatcher()]
assertWithMatcher:grey_notVisible()];
[[EarlGrey selectElementWithMatcher:KeyboardIconMatcher()]
assertWithMatcher:grey_notVisible()];
}
@end @end
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