Commit 4137e19e authored by David Jean's avatar David Jean Committed by Commit Bot

[ios] Fixed crash when deleting all saved password

Bug: 898678

Change-Id: Ib1fe23936b6d6196e760a50559b0895c7aaa4a0f
Reviewed-on: https://chromium-review.googlesource.com/c/1301453
Commit-Queue: David Jean <djean@chromium.org>
Reviewed-by: default avatarPeter Lee <pkl@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603441}
parent f59ad556
...@@ -1643,6 +1643,41 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -1643,6 +1643,41 @@ PasswordForm CreateSampleFormWithIndex(int index) {
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
} }
// Test search and delete all passwords and blacklisted items.
- (void)testSearchAndDeleteAllPasswords {
SaveExamplePasswordForms();
SaveExampleBlacklistedForms();
OpenPasswordSettings();
[[EarlGrey selectElementWithMatcher:SearchTextField()]
performAction:grey_typeText(@"u\n")];
TapEdit();
// Select all.
[GetInteractionForPasswordEntry(@"example11.com, user1")
performAction:grey_tap()];
[GetInteractionForPasswordEntry(@"example12.com, user2")
performAction:grey_tap()];
[GetInteractionForPasswordEntry(@"exclude1.com") performAction:grey_tap()];
[GetInteractionForPasswordEntry(@"exclude2.com") performAction:grey_tap()];
// Delete them.
[[EarlGrey selectElementWithMatcher:DeleteButtonAtBottom()]
performAction:grey_tap()];
// All should be gone.
[GetInteractionForPasswordEntry(@"example11.com, user1")
assertWithMatcher:grey_nil()];
[GetInteractionForPasswordEntry(@"example12.com, user2")
assertWithMatcher:grey_nil()];
[GetInteractionForPasswordEntry(@"exclude1.com")
assertWithMatcher:grey_nil()];
[GetInteractionForPasswordEntry(@"exclude2.com")
assertWithMatcher:grey_nil()];
}
// Test that user can't search passwords while in edit mode. // Test that user can't search passwords while in edit mode.
- (void)testCantSearchPasswordsWhileInEditMode { - (void)testCantSearchPasswordsWhileInEditMode {
SaveExamplePasswordForms(); SaveExamplePasswordForms();
......
...@@ -830,11 +830,14 @@ blacklistedFormItemWithText:(NSString*)text ...@@ -830,11 +830,14 @@ blacklistedFormItemWithText:(NSString*)text
SavePasswordsCollectionViewController* strongSelf = weakSelf; SavePasswordsCollectionViewController* strongSelf = weakSelf;
if (!strongSelf) if (!strongSelf)
return; return;
[strongSelf clearSectionWithIdentifier:SectionIdentifierSavedPasswords // Delete in reverse order of section indexes (bottom up of section
ifEmpty:strongSelf->savedForms_.empty()]; // displayed), so that indexes in model matches those in the view. if we
// don't we'll cause a crash.
[strongSelf [strongSelf
clearSectionWithIdentifier:SectionIdentifierBlacklist clearSectionWithIdentifier:SectionIdentifierBlacklist
ifEmpty:strongSelf->blacklistedForms_.empty()]; ifEmpty:strongSelf->blacklistedForms_.empty()];
[strongSelf clearSectionWithIdentifier:SectionIdentifierSavedPasswords
ifEmpty:strongSelf->savedForms_.empty()];
[strongSelf [strongSelf
clearSectionWithIdentifier:SectionIdentifierSearchPasswordsBox clearSectionWithIdentifier:SectionIdentifierSearchPasswordsBox
ifEmpty:strongSelf->savedForms_.empty() && ifEmpty:strongSelf->savedForms_.empty() &&
......
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