Commit 7c6649db authored by Vaclav Brozek's avatar Vaclav Brozek Committed by Commit Bot

Improve deletion tests for iOS passwords settings

This CL adds a test for deleting passwords in the list view. It checks that the
UI is updated correctly.

The CL also enhances all deletion-based tests to check the state of the
PasswordStore.

Bug: 744058
Change-Id: Ib545312b62b5563fc284b54aa18158c68a0ef767
Reviewed-on: https://chromium-review.googlesource.com/573541
Commit-Queue: Vaclav Brozek <vabr@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488259}
parent fa1dbd91
...@@ -553,7 +553,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -553,7 +553,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
// Checks that deleting a password from password details view goes back to the // Checks that deleting a password from password details view goes back to the
// list-of-passwords view. // list-of-passwords view.
- (void)testDeletion { - (void)testDeletionInDetailView {
base::test::ScopedFeatureList scoped_feature_list; base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature( scoped_feature_list.InitAndEnableFeature(
password_manager::features::kViewPasswords); password_manager::features::kViewPasswords);
...@@ -591,6 +591,11 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -591,6 +591,11 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
grey_accessibilityTrait(UIAccessibilityTraitHeader), grey_accessibilityTrait(UIAccessibilityTraitHeader),
nullptr)] assertWithMatcher:grey_notNil()]; nullptr)] assertWithMatcher:grey_notNil()];
// Verify that the deletion was propagated to the PasswordStore.
TestStoreConsumer consumer;
GREYAssert(consumer.GetStoreResults().empty(),
@"Stored password was not removed from PasswordStore.");
// Also verify that the removed password is no longer in the list. // Also verify that the removed password is no longer in the list.
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
assertWithMatcher:grey_not(grey_sufficientlyVisible())]; assertWithMatcher:grey_not(grey_sufficientlyVisible())];
...@@ -602,7 +607,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -602,7 +607,7 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
} }
// Checks that deleting a password from password details can be cancelled. // Checks that deleting a password from password details can be cancelled.
- (void)testCancelDeletion { - (void)testCancelDeletionInDetailView {
base::test::ScopedFeatureList scoped_feature_list; base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature( scoped_feature_list.InitAndEnableFeature(
password_manager::features::kViewPasswords); password_manager::features::kViewPasswords);
...@@ -632,6 +637,11 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -632,6 +637,11 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
[[EarlGrey selectElementWithMatcher:CopyPasswordButton()] [[EarlGrey selectElementWithMatcher:CopyPasswordButton()]
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
// Verify that the deletion did not happen.
TestStoreConsumer consumer;
GREYAssertEqual(1u, consumer.GetStoreResults().size(),
@"Stored password was removed from PasswordStore.");
// Go back to the list view and verify that the password is still in the // Go back to the list view and verify that the password is still in the
// list. // list.
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
...@@ -1131,4 +1141,55 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -1131,4 +1141,55 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
TapDone(); TapDone();
} }
// Checks that deleting a password from the list view works.
- (void)testDeletionInListView {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(
password_manager::features::kViewPasswords);
// Save a password to be deleted later.
SaveExamplePasswordForm();
OpenPasswordSettings();
TapEdit();
// Select password entry to be removed.
[GetInteractionForPasswordEntry(@"example.com, concrete username")
performAction:grey_tap()];
// Selecting the "Delete" button is tricky, because its text is defined in the
// private part of MD components library. But it is the unique
// almost-completely visible element which is aligned with the bottom edge of
// the screen.
GREYLayoutConstraint* equalBottom = [GREYLayoutConstraint
layoutConstraintWithAttribute:kGREYLayoutAttributeBottom
relatedBy:kGREYLayoutRelationEqual
toReferenceAttribute:kGREYLayoutAttributeBottom
multiplier:1.0
constant:0.0];
id<GREYMatcher> wholeScreen =
grey_accessibilityID(@"SavePasswordsCollectionViewController");
[[EarlGrey
selectElementWithMatcher:grey_allOf(
grey_layout(@[ equalBottom ], wholeScreen),
grey_accessibilityTrait(
UIAccessibilityTraitButton),
grey_accessibilityElement(),
grey_minimumVisiblePercent(0.98), nil)]
performAction:grey_tap()];
// Verify that the deletion was propagated to the PasswordStore.
TestStoreConsumer consumer;
GREYAssert(consumer.GetStoreResults().empty(),
@"Stored password was not removed from PasswordStore.");
// Verify that the removed password is no longer in the list.
[GetInteractionForPasswordEntry(@"example.com, concrete username")
assertWithMatcher:grey_not(grey_sufficientlyVisible())];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
TapDone();
}
@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