Commit 2389811c authored by Viktor Semeniuk's avatar Viktor Semeniuk Committed by Commit Bot

[iOS][Passwords] Disabling Done button for empty password

This change disables Done button in case entered password is empty.

Bug: 1137475
Change-Id: I3e110654695c07336d6c85c01b3463d3da5c1b06
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485493
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821216}
parent 8eb33db9
...@@ -425,12 +425,7 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) { ...@@ -425,12 +425,7 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) {
} }
- (void)tableViewItemDidChange:(TableViewTextEditItem*)tableViewItem { - (void)tableViewItemDidChange:(TableViewTextEditItem*)tableViewItem {
BOOL isInputValid = YES; BOOL isInputValid = [self checkIfValidUsername] & [self checkIfValidPassword];
if (tableViewItem == self.usernameTextItem) {
isInputValid = [self checkIfValidUsername];
}
self.navigationItem.rightBarButtonItem.enabled = isInputValid; self.navigationItem.rightBarButtonItem.enabled = isInputValid;
} }
...@@ -623,6 +618,17 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) { ...@@ -623,6 +618,17 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) {
return !showUsernameAlreadyUsed; return !showUsernameAlreadyUsed;
} }
// Checks if the password is valid and updates item accordingly.
- (BOOL)checkIfValidPassword {
DCHECK(self.password.password);
BOOL passwordEmpty = [self.passwordTextItem.textFieldValue length] == 0;
self.passwordTextItem.hasValidText = !passwordEmpty;
[self reconfigureCellsForItems:@[ self.passwordTextItem ]];
return !passwordEmpty;
}
#pragma mark - Actions #pragma mark - Actions
// Called when the user tapped on the show/hide button near password. // Called when the user tapped on the show/hide button near password.
......
...@@ -1417,6 +1417,14 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -1417,6 +1417,14 @@ void CopyPasswordDetailWithID(int detail_id) {
[[EarlGrey selectElementWithMatcher:PasswordDetailPassword()] [[EarlGrey selectElementWithMatcher:PasswordDetailPassword()]
assertWithMatcher:grey_textFieldValue(@"concrete password")]; assertWithMatcher:grey_textFieldValue(@"concrete password")];
// Check that empty password is not allowed, and done button is disabled.
[[EarlGrey selectElementWithMatcher:PasswordDetailPassword()]
performAction:grey_clearText()];
[[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
assertWithMatcher:grey_allOf(grey_sufficientlyVisible(),
grey_not(grey_enabled()), nil)];
[[EarlGrey selectElementWithMatcher:PasswordDetailPassword()] [[EarlGrey selectElementWithMatcher:PasswordDetailPassword()]
performAction:grey_replaceText(@"new password")]; performAction:grey_replaceText(@"new password")];
......
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