Commit b89c289e authored by Kristi Park's avatar Kristi Park Committed by Commit Bot

Revert "Reland "[iOS][Password Check] Rewriting Passwords test with new details screen""

This reverts commit bd7b15d0.

Reason for revert: PasswordViewControllerTestCase failures for ios_chrome_integration_eg2tests_module_*
https://ci.chromium.org/p/chromium/builders/ci/ios-simulator-noncq/12479

Original change's description:
> Reland "[iOS][Password Check] Rewriting Passwords test with new details screen"
>
> This is a reland of 7b693e30
>
> Fixed failing tests:
> testStoredEntriesAlwaysShown
> testCancelDeletionInDetailView
> testSearchPasswords
>
> Original change's description:
> > [iOS][Password Check] Rewriting Passwords test with new details screen
> >
> > This change rewrites Passwords tests with new Password Details screen.
> > Obsolete tests are deleted. Fixed flakiness for
> > testSearchAndDeleteAllPasswords.
> >
> > Bug: 1075494, 1129441
> > Change-Id: Id6d44a2f77c20edb1788f1d3dcaa04e9e645cdb5
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2418853
> > Commit-Queue: Viktor Semeniuk <vsemeniuk@google.com>
> > Reviewed-by: Gauthier Ambard <gambard@chromium.org>
> > Reviewed-by: Eugene But <eugenebut@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#811668}
>
> Bug: 1075494
> Bug: 1129441
> Change-Id: Ibfe28ea3ee68f9fb69fcb50085da9c1c558f86d2
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2438380
> Commit-Queue: Viktor Semeniuk <vsemeniuk@google.com>
> Reviewed-by: Gauthier Ambard <gambard@chromium.org>
> Reviewed-by: Eugene But <eugenebut@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#813660}

TBR=eugenebut@chromium.org,gambard@chromium.org,vsemeniuk@google.com

Change-Id: Ia803bf926c7dc689daf0a25abb49008e8fd92aef
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1075494
Bug: 1129441
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2450409Reviewed-by: default avatarKristi Park <kristipark@chromium.org>
Commit-Queue: Kristi Park <kristipark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813765}
parent 13c9a810
...@@ -268,9 +268,6 @@ BOOL WaitForJavaScriptCondition(NSString* java_script_condition) { ...@@ -268,9 +268,6 @@ BOOL WaitForJavaScriptCondition(NSString* java_script_condition) {
// Verify keyboard is shown without the password controller. // Verify keyboard is shown without the password controller.
GREYAssertTrue([ChromeEarlGrey isKeyboardShownWithError:nil], GREYAssertTrue([ChromeEarlGrey isKeyboardShownWithError:nil],
@"Keyboard Should be Shown"); @"Keyboard Should be Shown");
[[EarlGrey
selectElementWithMatcher:chrome_test_util::NavigationBarCancelButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:ManualFallbackPasswordTableViewMatcher()] [[EarlGrey selectElementWithMatcher:ManualFallbackPasswordTableViewMatcher()]
assertWithMatcher:grey_notVisible()]; assertWithMatcher:grey_notVisible()];
} }
......
...@@ -233,7 +233,6 @@ source_set("eg2_tests") { ...@@ -233,7 +233,6 @@ source_set("eg2_tests") {
":password_constants", ":password_constants",
"//base:base", "//base:base",
"//base/test:test_support", "//base/test:test_support",
"//components/password_manager/core/common",
"//components/strings:components_strings_grit", "//components/strings:components_strings_grit",
"//ios/chrome/app/strings:ios_strings_grit", "//ios/chrome/app/strings:ios_strings_grit",
"//ios/chrome/browser/ui/settings:settings_root_constants", "//ios/chrome/browser/ui/settings:settings_root_constants",
......
...@@ -9,4 +9,4 @@ ...@@ -9,4 +9,4 @@
#endif #endif
NSString* const kPasswordDetailsViewControllerId = NSString* const kPasswordDetailsViewControllerId =
@"PasswordDetailsTableViewId"; @"kPasswordDetailsViewControllerId";
...@@ -210,8 +210,6 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) { ...@@ -210,8 +210,6 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) {
item.identifyingIcon = [[UIImage imageNamed:image] item.identifyingIcon = [[UIImage imageNamed:image]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
item.identifyingIconEnabled = YES; item.identifyingIconEnabled = YES;
item.identifyingIconAccessibilityLabel =
l10n_util::GetNSString(IDS_IOS_SETTINGS_PASSWORD_SHOW_BUTTON);
} }
return item; return item;
} }
......
...@@ -8,9 +8,7 @@ ...@@ -8,9 +8,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/ios/ios_util.h" #include "base/ios/ios_util.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/ui/settings/password/passwords_settings_app_interface.h" #include "ios/chrome/browser/ui/settings/password/passwords_settings_app_interface.h"
#import "ios/chrome/browser/ui/settings/password/passwords_table_view_constants.h" #import "ios/chrome/browser/ui/settings/password/passwords_table_view_constants.h"
...@@ -48,7 +46,6 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(PasswordSettingsAppInterface); ...@@ -48,7 +46,6 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(PasswordSettingsAppInterface);
// go here, the rest into the unittest. // go here, the rest into the unittest.
using chrome_test_util::ButtonWithAccessibilityLabel; using chrome_test_util::ButtonWithAccessibilityLabel;
using chrome_test_util::ButtonWithAccessibilityLabelId;
using chrome_test_util::NavigationBarDoneButton; using chrome_test_util::NavigationBarDoneButton;
using chrome_test_util::SettingsDoneButton; using chrome_test_util::SettingsDoneButton;
using chrome_test_util::SettingsMenuBackButton; using chrome_test_util::SettingsMenuBackButton;
...@@ -61,11 +58,6 @@ namespace { ...@@ -61,11 +58,6 @@ namespace {
// it too high could result in scrolling way past the searched element. // it too high could result in scrolling way past the searched element.
constexpr int kScrollAmount = 150; constexpr int kScrollAmount = 150;
NSString* GetTextFieldForID(int category_id) {
return [NSString
stringWithFormat:@"%@_textField", l10n_util::GetNSString(category_id)];
}
// Returns the GREYElementInteraction* for the item on the password list with // Returns the GREYElementInteraction* for the item on the password list with
// the given |matcher|. It scrolls in |direction| if necessary to ensure that // the given |matcher|. It scrolls in |direction| if necessary to ensure that
// the matched item is interactable. // the matched item is interactable.
...@@ -92,10 +84,20 @@ GREYElementInteraction* GetInteractionForPasswordDetailItem( ...@@ -92,10 +84,20 @@ GREYElementInteraction* GetInteractionForPasswordDetailItem(
id<GREYMatcher> matcher) { id<GREYMatcher> matcher) {
return [[EarlGrey return [[EarlGrey
selectElementWithMatcher:grey_allOf(matcher, grey_interactable(), nil)] selectElementWithMatcher:grey_allOf(matcher, grey_interactable(), nil)]
usingSearchAction:grey_scrollToContentEdge(kGREYContentEdgeTop) usingSearchAction:grey_scrollInDirection(kGREYDirectionDown,
kScrollAmount)
onElementWithMatcher:grey_accessibilityID(kPasswordDetailsTableViewId)]; onElementWithMatcher:grey_accessibilityID(kPasswordDetailsTableViewId)];
} }
// Returns the GREYElementInteraction* for the item on the deletion alert
// identified with the given |matcher|.
GREYElementInteraction* GetInteractionForPasswordDetailDeletionAlert(
id<GREYMatcher> matcher) {
return [[EarlGrey
selectElementWithMatcher:grey_allOf(matcher, grey_interactable(), nil)]
inRoot:grey_accessibilityID(kPasswordDetailsDeletionAlertViewId)];
}
// Returns the GREYElementInteraction* for the item on the deletion alert // Returns the GREYElementInteraction* for the item on the deletion alert
// identified with the given |matcher|. // identified with the given |matcher|.
GREYElementInteraction* GetInteractionForPasswordsExportConfirmAlert( GREYElementInteraction* GetInteractionForPasswordsExportConfirmAlert(
...@@ -118,6 +120,34 @@ id<GREYMatcher> SearchTextField() { ...@@ -118,6 +120,34 @@ id<GREYMatcher> SearchTextField() {
return grey_accessibilityID(kPasswordsSearchBarId); return grey_accessibilityID(kPasswordsSearchBarId);
} }
id<GREYMatcher> SiteHeader() {
return grey_allOf(
grey_accessibilityLabel(
l10n_util::GetNSString(IDS_IOS_SHOW_PASSWORD_VIEW_SITE)),
grey_accessibilityTrait(UIAccessibilityTraitHeader), nullptr);
}
id<GREYMatcher> UsernameHeader() {
return grey_allOf(
grey_accessibilityLabel(
l10n_util::GetNSString(IDS_IOS_SHOW_PASSWORD_VIEW_USERNAME)),
grey_accessibilityTrait(UIAccessibilityTraitHeader), nullptr);
}
id<GREYMatcher> PasswordHeader() {
return grey_allOf(
grey_accessibilityLabel(
l10n_util::GetNSString(IDS_IOS_SHOW_PASSWORD_VIEW_PASSWORD)),
grey_accessibilityTrait(UIAccessibilityTraitHeader), nullptr);
}
id<GREYMatcher> FederationHeader() {
return grey_allOf(
grey_accessibilityLabel(
l10n_util::GetNSString(IDS_IOS_SHOW_PASSWORD_VIEW_FEDERATION)),
grey_accessibilityTrait(UIAccessibilityTraitHeader), nullptr);
}
GREYLayoutConstraint* Below() { GREYLayoutConstraint* Below() {
return [GREYLayoutConstraint return [GREYLayoutConstraint
layoutConstraintWithAttribute:kGREYLayoutAttributeTop layoutConstraintWithAttribute:kGREYLayoutAttributeTop
...@@ -128,24 +158,39 @@ GREYLayoutConstraint* Below() { ...@@ -128,24 +158,39 @@ GREYLayoutConstraint* Below() {
} }
// Matcher for the Copy site button in Password Details view. // Matcher for the Copy site button in Password Details view.
id<GREYMatcher> PasswordDetailWebsite() { id<GREYMatcher> CopySiteButton() {
return grey_allOf( return grey_allOf(
grey_accessibilityID(GetTextFieldForID(IDS_IOS_SHOW_PASSWORD_VIEW_SITE)), ButtonWithAccessibilityLabel(
grey_kindOfClassName(@"UITextField"), nil); [NSString stringWithFormat:@"%@: %@",
l10n_util::GetNSString(
IDS_IOS_SHOW_PASSWORD_VIEW_SITE),
l10n_util::GetNSString(
IDS_IOS_SETTINGS_SITE_COPY_BUTTON)]),
grey_interactable(), nullptr);
} }
// Matcher for the Copy username button in Password Details view. // Matcher for the Copy username button in Password Details view.
id<GREYMatcher> PasswordDetailUsername() { id<GREYMatcher> CopyUsernameButton() {
return grey_allOf(grey_accessibilityID( return grey_allOf(
GetTextFieldForID(IDS_IOS_SHOW_PASSWORD_VIEW_USERNAME)), ButtonWithAccessibilityLabel([NSString
grey_kindOfClassName(@"UITextField"), nil); stringWithFormat:@"%@: %@",
l10n_util::GetNSString(
IDS_IOS_SHOW_PASSWORD_VIEW_USERNAME),
l10n_util::GetNSString(
IDS_IOS_SETTINGS_USERNAME_COPY_BUTTON)]),
grey_interactable(), nullptr);
} }
// Matcher for the Copy password button in Password Details view. // Matcher for the Copy password button in Password Details view.
id<GREYMatcher> PasswordDetailPassword() { id<GREYMatcher> CopyPasswordButton() {
return grey_allOf(grey_accessibilityID( return grey_allOf(
GetTextFieldForID(IDS_IOS_SHOW_PASSWORD_VIEW_PASSWORD)), ButtonWithAccessibilityLabel([NSString
grey_kindOfClassName(@"UITextField"), nil); stringWithFormat:@"%@: %@",
l10n_util::GetNSString(
IDS_IOS_SHOW_PASSWORD_VIEW_PASSWORD),
l10n_util::GetNSString(
IDS_IOS_SETTINGS_PASSWORD_COPY_BUTTON)]),
grey_interactable(), nullptr);
} }
// Matcher for the Show password button in Password Details view. // Matcher for the Show password button in Password Details view.
...@@ -157,16 +202,8 @@ id<GREYMatcher> ShowPasswordButton() { ...@@ -157,16 +202,8 @@ id<GREYMatcher> ShowPasswordButton() {
// Matcher for the Delete button in Password Details view. // Matcher for the Delete button in Password Details view.
id<GREYMatcher> DeleteButton() { id<GREYMatcher> DeleteButton() {
return grey_allOf(
ButtonWithAccessibilityLabelId(IDS_IOS_SETTINGS_TOOLBAR_DELETE),
grey_not(grey_accessibilityTrait(UIAccessibilityTraitNotEnabled)),
nullptr);
}
// Matcher for the Delete button in Confirmation Alert for password deletion.
id<GREYMatcher> DeleteConfirmationButton() {
return grey_allOf(ButtonWithAccessibilityLabel(l10n_util::GetNSString( return grey_allOf(ButtonWithAccessibilityLabel(l10n_util::GetNSString(
IDS_IOS_CONFIRM_PASSWORD_DELETION)), IDS_IOS_SETTINGS_PASSWORD_DELETE_BUTTON)),
grey_interactable(), nullptr); grey_interactable(), nullptr);
} }
...@@ -263,24 +300,10 @@ void TapEdit() { ...@@ -263,24 +300,10 @@ void TapEdit() {
performAction:grey_tap()]; performAction:grey_tap()];
} }
void CopyPasswordDetailWithID(int detail_id) {
[GetInteractionForPasswordDetailItem(grey_allOf(
grey_accessibilityID(GetTextFieldForID(detail_id)),
grey_kindOfClassName(@"UITextField"), nil)) performAction:grey_tap()];
// Tap the context menu item for copying.
[[EarlGrey selectElementWithMatcher:PopUpMenuItemWithLabel(
IDS_IOS_SETTINGS_SITE_COPY_MENU_ITEM)]
performAction:grey_tap()];
}
} // namespace } // namespace
// Various tests for the Save Passwords section of the settings. // Various tests for the Save Passwords section of the settings.
@interface PasswordsSettingsTestCase : ChromeTestCase { @interface PasswordsSettingsTestCase : ChromeTestCase
base::test::ScopedFeatureList _featureList;
}
@end @end
@implementation PasswordsSettingsTestCase @implementation PasswordsSettingsTestCase
...@@ -296,18 +319,6 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -296,18 +319,6 @@ void CopyPasswordDetailWithID(int detail_id) {
[super tearDown]; [super tearDown];
} }
- (AppLaunchConfiguration)appConfigurationForTestCase {
AppLaunchConfiguration config;
// Password Check Feature is enabled for all tests. This is done because it
// is inefficient to use ensureAppLaunchedWithConfiguration for each test.
// This should be removed once test config is modified.
// TODO(crbug.com/1075494): Remove this once feature is launched.
config.features_enabled.push_back(password_manager::features::kPasswordCheck);
return config;
}
// Verifies the UI elements are accessible on the Passwords page. // Verifies the UI elements are accessible on the Passwords page.
- (void)testAccessibilityOnPasswords { - (void)testAccessibilityOnPasswords {
// Saving a form is needed for using the "password details" view. // Saving a form is needed for using the "password details" view.
...@@ -345,12 +356,13 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -345,12 +356,13 @@ void CopyPasswordDetailWithID(int detail_id) {
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
performAction:grey_tap()]; performAction:grey_tap()];
// Check the snackbar in case of successful reauthentication.
[PasswordSettingsAppInterface setUpMockReauthenticationModule]; [PasswordSettingsAppInterface setUpMockReauthenticationModule];
[PasswordSettingsAppInterface mockReauthenticationModuleExpectedResult: [PasswordSettingsAppInterface mockReauthenticationModuleExpectedResult:
ReauthenticationResult::kSuccess]; ReauthenticationResult::kSuccess];
CopyPasswordDetailWithID(IDS_IOS_SHOW_PASSWORD_VIEW_PASSWORD); // Check the snackbar in case of successful reauthentication.
[GetInteractionForPasswordDetailItem(CopyPasswordButton())
performAction:grey_tap()];
NSString* snackbarLabel = NSString* snackbarLabel =
l10n_util::GetNSString(IDS_IOS_SETTINGS_PASSWORD_WAS_COPIED_MESSAGE); l10n_util::GetNSString(IDS_IOS_SETTINGS_PASSWORD_WAS_COPIED_MESSAGE);
...@@ -361,8 +373,8 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -361,8 +373,8 @@ void CopyPasswordDetailWithID(int detail_id) {
// Check the snackbar in case of failed reauthentication. // Check the snackbar in case of failed reauthentication.
[PasswordSettingsAppInterface mockReauthenticationModuleExpectedResult: [PasswordSettingsAppInterface mockReauthenticationModuleExpectedResult:
ReauthenticationResult::kFailure]; ReauthenticationResult::kFailure];
[GetInteractionForPasswordDetailItem(CopyPasswordButton())
CopyPasswordDetailWithID(IDS_IOS_SHOW_PASSWORD_VIEW_PASSWORD); performAction:grey_tap()];
snackbarLabel = snackbarLabel =
l10n_util::GetNSString(IDS_IOS_SETTINGS_PASSWORD_WAS_NOT_COPIED_MESSAGE); l10n_util::GetNSString(IDS_IOS_SETTINGS_PASSWORD_WAS_NOT_COPIED_MESSAGE);
...@@ -380,7 +392,7 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -380,7 +392,7 @@ void CopyPasswordDetailWithID(int detail_id) {
// Checks that an attempt to show a password provides an appropriate feedback // Checks that an attempt to show a password provides an appropriate feedback
// when reauthentication succeeds. // when reauthentication succeeds.
- (void)testShowPasswordAuthSucceeded { - (void)testShowPasswordToastAuthSucceeded {
// Saving a form is needed for using the "password details" view. // Saving a form is needed for using the "password details" view.
SaveExamplePasswordForm(); SaveExamplePasswordForm();
...@@ -393,12 +405,14 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -393,12 +405,14 @@ void CopyPasswordDetailWithID(int detail_id) {
[PasswordSettingsAppInterface mockReauthenticationModuleExpectedResult: [PasswordSettingsAppInterface mockReauthenticationModuleExpectedResult:
ReauthenticationResult::kSuccess]; ReauthenticationResult::kSuccess];
// Check the snackbar in case of successful reauthentication.
[GetInteractionForPasswordDetailItem(ShowPasswordButton()) [GetInteractionForPasswordDetailItem(ShowPasswordButton())
performAction:grey_tap()]; performAction:grey_tap()];
// Ensure that password is shown. // Check that the password is displayed.
[GetInteractionForPasswordDetailItem(grey_textFieldValue( [[EarlGrey
@"concrete password")) assertWithMatcher:grey_notNil()]; selectElementWithMatcher:grey_accessibilityLabel(@"concrete password")]
assertWithMatcher:grey_sufficientlyVisible()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -428,7 +442,8 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -428,7 +442,8 @@ void CopyPasswordDetailWithID(int detail_id) {
performAction:grey_tap()]; performAction:grey_tap()];
// Check that the password is not displayed. // Check that the password is not displayed.
[[EarlGrey selectElementWithMatcher:grey_textFieldValue(@"concrete password")] [[EarlGrey
selectElementWithMatcher:grey_accessibilityLabel(@"concrete password")]
assertWithMatcher:grey_nil()]; assertWithMatcher:grey_nil()];
// Note that there is supposed to be no message (cf. the case of the copy // Note that there is supposed to be no message (cf. the case of the copy
...@@ -453,7 +468,8 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -453,7 +468,8 @@ void CopyPasswordDetailWithID(int detail_id) {
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
performAction:grey_tap()]; performAction:grey_tap()];
CopyPasswordDetailWithID(IDS_IOS_SHOW_PASSWORD_VIEW_USERNAME); [GetInteractionForPasswordDetailItem(CopyUsernameButton())
performAction:grey_tap()];
NSString* snackbarLabel = NSString* snackbarLabel =
l10n_util::GetNSString(IDS_IOS_SETTINGS_USERNAME_WAS_COPIED_MESSAGE); l10n_util::GetNSString(IDS_IOS_SETTINGS_USERNAME_WAS_COPIED_MESSAGE);
// The tap checks the existence of the snackbar and also closes it. // The tap checks the existence of the snackbar and also closes it.
...@@ -478,8 +494,8 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -478,8 +494,8 @@ void CopyPasswordDetailWithID(int detail_id) {
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
performAction:grey_tap()]; performAction:grey_tap()];
CopyPasswordDetailWithID(IDS_IOS_SHOW_PASSWORD_VIEW_SITE); [GetInteractionForPasswordDetailItem(CopySiteButton())
performAction:grey_tap()];
NSString* snackbarLabel = NSString* snackbarLabel =
l10n_util::GetNSString(IDS_IOS_SETTINGS_SITE_WAS_COPIED_MESSAGE); l10n_util::GetNSString(IDS_IOS_SETTINGS_SITE_WAS_COPIED_MESSAGE);
// The tap checks the existence of the snackbar and also closes it. // The tap checks the existence of the snackbar and also closes it.
...@@ -505,16 +521,11 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -505,16 +521,11 @@ void CopyPasswordDetailWithID(int detail_id) {
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
performAction:grey_tap()]; performAction:grey_tap()];
[PasswordSettingsAppInterface setUpMockReauthenticationModule]; [GetInteractionForPasswordDetailItem(DeleteButton())
[PasswordSettingsAppInterface mockReauthenticationModuleExpectedResult:
ReauthenticationResult::kSuccess];
[[EarlGrey selectElementWithMatcher:NavigationBarEditButton()]
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:DeleteButton()] performAction:grey_tap()]; [GetInteractionForPasswordDetailDeletionAlert(ButtonWithAccessibilityLabel(
l10n_util::GetNSString(IDS_IOS_CONFIRM_PASSWORD_DELETION)))
[[EarlGrey selectElementWithMatcher:DeleteConfirmationButton()]
performAction:grey_tap()]; performAction:grey_tap()];
// Wait until the alert and the detail view are dismissed. // Wait until the alert and the detail view are dismissed.
...@@ -565,16 +576,11 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -565,16 +576,11 @@ void CopyPasswordDetailWithID(int detail_id) {
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
performAction:grey_tap()]; performAction:grey_tap()];
[PasswordSettingsAppInterface setUpMockReauthenticationModule]; [GetInteractionForPasswordDetailItem(DeleteButton())
[PasswordSettingsAppInterface mockReauthenticationModuleExpectedResult:
ReauthenticationResult::kSuccess];
[[EarlGrey selectElementWithMatcher:NavigationBarEditButton()]
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:DeleteButton()] performAction:grey_tap()]; [GetInteractionForPasswordDetailDeletionAlert(ButtonWithAccessibilityLabel(
l10n_util::GetNSString(IDS_IOS_CONFIRM_PASSWORD_DELETION)))
[[EarlGrey selectElementWithMatcher:DeleteConfirmationButton()]
performAction:grey_tap()]; performAction:grey_tap()];
// Wait until the alert and the detail view are dismissed. // Wait until the alert and the detail view are dismissed.
...@@ -617,12 +623,11 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -617,12 +623,11 @@ void CopyPasswordDetailWithID(int detail_id) {
[GetInteractionForPasswordEntry(@"blocked.com") performAction:grey_tap()]; [GetInteractionForPasswordEntry(@"blocked.com") performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:NavigationBarEditButton()] [GetInteractionForPasswordDetailItem(DeleteButton())
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:DeleteButton()] performAction:grey_tap()]; [GetInteractionForPasswordDetailDeletionAlert(ButtonWithAccessibilityLabel(
l10n_util::GetNSString(IDS_IOS_CONFIRM_PASSWORD_DELETION)))
[[EarlGrey selectElementWithMatcher:DeleteConfirmationButton()]
performAction:grey_tap()]; performAction:grey_tap()];
// Wait until the alert and the detail view are dismissed. // Wait until the alert and the detail view are dismissed.
...@@ -666,17 +671,11 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -666,17 +671,11 @@ void CopyPasswordDetailWithID(int detail_id) {
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
performAction:grey_tap()]; performAction:grey_tap()];
[PasswordSettingsAppInterface setUpMockReauthenticationModule]; [GetInteractionForPasswordDetailItem(DeleteButton())
[PasswordSettingsAppInterface mockReauthenticationModuleExpectedResult:
ReauthenticationResult::kSuccess];
[[EarlGrey selectElementWithMatcher:NavigationBarEditButton()]
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:DeleteButton()] performAction:grey_tap()];
// Tap the alert's Cancel button to cancel. // Tap the alert's Cancel button to cancel.
if ([ChromeEarlGrey isIPadIdiom]) { if (base::ios::IsRunningOnOrLater(13, 2, 0) && [ChromeEarlGrey isIPadIdiom]) {
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kPasswordDetailsTableViewId)] kPasswordDetailsTableViewId)]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -690,10 +689,10 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -690,10 +689,10 @@ void CopyPasswordDetailWithID(int detail_id) {
performAction:grey_tap()]; performAction:grey_tap()];
} }
// Check that the current view is still the detail view. // Check that the current view is still the detail view, by locating the Copy
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( // button.
kPasswordDetailsTableViewId)] [[EarlGrey selectElementWithMatcher:CopyPasswordButton()]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_sufficientlyVisible()];
// Verify that the deletion did not happen. // Verify that the deletion did not happen.
GREYAssertEqual(1u, [PasswordSettingsAppInterface passwordStoreResultsCount], GREYAssertEqual(1u, [PasswordSettingsAppInterface passwordStoreResultsCount],
...@@ -733,7 +732,7 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -733,7 +732,7 @@ void CopyPasswordDetailWithID(int detail_id) {
// Check that the current view is not the detail view, by failing to locate // Check that the current view is not the detail view, by failing to locate
// the Copy button. // the Copy button.
[[EarlGrey selectElementWithMatcher:PasswordDetailPassword()] [[EarlGrey selectElementWithMatcher:CopyPasswordButton()]
assertWithMatcher:grey_nil()]; assertWithMatcher:grey_nil()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
...@@ -742,6 +741,77 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -742,6 +741,77 @@ void CopyPasswordDetailWithID(int detail_id) {
performAction:grey_tap()]; performAction:grey_tap()];
} }
// Checks that attempts to copy the site via the context menu item provide an
// appropriate feedback.
- (void)testCopySiteMenuItem {
// Saving a form is needed for using the "password details" view.
SaveExamplePasswordForm();
OpenPasswordSettings();
[GetInteractionForPasswordEntry(@"example.com, concrete username")
performAction:grey_tap()];
// Tap the site cell to display the context menu.
[GetInteractionForPasswordDetailItem(grey_accessibilityLabel(
@"https://example.com/")) performAction:grey_tap()];
// Tap the context menu item for copying.
[[EarlGrey selectElementWithMatcher:PopUpMenuItemWithLabel(
IDS_IOS_SETTINGS_SITE_COPY_MENU_ITEM)]
performAction:grey_tap()];
// Check the snackbar.
NSString* snackbarLabel =
l10n_util::GetNSString(IDS_IOS_SETTINGS_SITE_WAS_COPIED_MESSAGE);
// The tap checks the existence of the snackbar and also closes it.
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(snackbarLabel)]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()];
}
// Checks that attempts to copy the username via the context menu item provide
// an appropriate feedback.
- (void)testCopyUsernameMenuItem {
// Saving a form is needed for using the "password details" view.
SaveExamplePasswordForm();
OpenPasswordSettings();
[GetInteractionForPasswordEntry(@"example.com, concrete username")
performAction:grey_tap()];
// Tap the username cell to display the context menu.
[GetInteractionForPasswordDetailItem(
grey_accessibilityLabel(@"concrete username")) performAction:grey_tap()];
// Tap the context menu item for copying.
[[EarlGrey
selectElementWithMatcher:PopUpMenuItemWithLabel(
IDS_IOS_SETTINGS_USERNAME_COPY_MENU_ITEM)]
performAction:grey_tap()];
// Check the snackbar.
NSString* snackbarLabel =
l10n_util::GetNSString(IDS_IOS_SETTINGS_USERNAME_WAS_COPIED_MESSAGE);
// The tap checks the existence of the snackbar and also closes it.
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(snackbarLabel)]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()];
}
// Checks that attempts to copy the password via the context menu item provide // Checks that attempts to copy the password via the context menu item provide
// an appropriate feedback. // an appropriate feedback.
- (void)testCopyPasswordMenuItem { - (void)testCopyPasswordMenuItem {
...@@ -790,6 +860,62 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -790,6 +860,62 @@ void CopyPasswordDetailWithID(int detail_id) {
performAction:grey_tap()]; performAction:grey_tap()];
} }
// Checks that attempts to show and hide the password via the context menu item
// provide an appropriate feedback.
- (void)testShowHidePasswordMenuItem {
if (![ChromeEarlGrey isIPadIdiom]) {
// TODO(crbug.com/1109644): Enable the test on iPhone once the bug is fixed.
EARL_GREY_TEST_DISABLED(@"Disabled for iPhone.");
}
// Saving a form is needed for using the "password details" view.
SaveExamplePasswordForm();
OpenPasswordSettings();
[GetInteractionForPasswordEntry(@"example.com, concrete username")
performAction:grey_tap()];
// Tap the password cell to display the context menu.
[GetInteractionForPasswordDetailItem(grey_text(kMaskedPassword))
performAction:grey_tap()];
// Make sure to capture the reauthentication module in a variable until the
// end of the test, otherwise it might get deleted too soon and break the
// functionality of copying and viewing passwords.
[PasswordSettingsAppInterface setUpMockReauthenticationModule];
[PasswordSettingsAppInterface mockReauthenticationModuleExpectedResult:
ReauthenticationResult::kSuccess];
// Tap the context menu item for showing.
[[EarlGrey
selectElementWithMatcher:PopUpMenuItemWithLabel(
IDS_IOS_SETTINGS_PASSWORD_SHOW_MENU_ITEM)]
performAction:grey_tap()];
// Tap the password cell to display the context menu again, and to check that
// the password was unmasked.
[GetInteractionForPasswordDetailItem(
grey_accessibilityLabel(@"concrete password")) performAction:grey_tap()];
// Tap the context menu item for hiding.
[[EarlGrey
selectElementWithMatcher:PopUpMenuItemWithLabel(
IDS_IOS_SETTINGS_PASSWORD_HIDE_MENU_ITEM)]
performAction:grey_tap()];
// Check that the password is masked again.
[GetInteractionForPasswordDetailItem(grey_text(kMaskedPassword))
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()];
}
// Checks that federated credentials have no password but show the federation. // Checks that federated credentials have no password but show the federation.
- (void)testFederated { - (void)testFederated {
GREYAssert([PasswordSettingsAppInterface GREYAssert([PasswordSettingsAppInterface
...@@ -803,26 +929,24 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -803,26 +929,24 @@ void CopyPasswordDetailWithID(int detail_id) {
[GetInteractionForPasswordEntry(@"example.com, federated username") [GetInteractionForPasswordEntry(@"example.com, federated username")
performAction:grey_tap()]; performAction:grey_tap()];
// Check that the Site and Username are present and correct. // Check that the Site, Username, Federation and Delete Saved Password
[[EarlGrey selectElementWithMatcher:PasswordDetailWebsite()] // sections are there.
assertWithMatcher:grey_textFieldValue(@"https://example.com/")]; [GetInteractionForPasswordDetailItem(SiteHeader())
[[EarlGrey selectElementWithMatcher:PasswordDetailUsername()] assertWithMatcher:grey_notNil()];
assertWithMatcher:grey_textFieldValue(@"federated username")]; [GetInteractionForPasswordDetailItem(UsernameHeader())
assertWithMatcher:grey_notNil()];
// For federation check both the section header and content.
[GetInteractionForPasswordDetailItem(FederationHeader())
assertWithMatcher:grey_notNil()];
[GetInteractionForPasswordDetailItem(grey_text(@"famous.provider.net"))
assertWithMatcher:grey_notNil()];
[GetInteractionForPasswordDetailItem(DeleteButton())
assertWithMatcher:grey_notNil()];
// Check that the password is not present. // Check that the password is not present.
[[EarlGrey selectElementWithMatcher:PasswordDetailPassword()] [GetInteractionForPasswordDetailItem(PasswordHeader())
assertWithMatcher:grey_nil()]; assertWithMatcher:grey_nil()];
// Check that editing doesn't require reauth.
[PasswordSettingsAppInterface setUpMockReauthenticationModule];
[PasswordSettingsAppInterface mockReauthenticationModuleExpectedResult:
ReauthenticationResult::kFailure];
[[EarlGrey selectElementWithMatcher:NavigationBarEditButton()]
performAction:grey_tap()];
// Ensure delete button is present after entering editing mode.
[[EarlGrey selectElementWithMatcher:DeleteButton()]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
...@@ -841,17 +965,44 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -841,17 +965,44 @@ void CopyPasswordDetailWithID(int detail_id) {
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:PasswordDetailWebsite()] [GetInteractionForPasswordDetailItem(SiteHeader())
assertWithMatcher:grey_textFieldValue(@"https://example.com/")]; assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:PasswordDetailUsername()] id<GREYMatcher> siteCell = grey_accessibilityLabel(@"https://example.com/");
assertWithMatcher:grey_textFieldValue(@"concrete username")]; [GetInteractionForPasswordDetailItem(siteCell)
[[EarlGrey selectElementWithMatcher:PasswordDetailPassword()] assertWithMatcher:grey_layout(@[ Below() ], SiteHeader())];
assertWithMatcher:grey_textFieldValue(kMaskedPassword)]; [GetInteractionForPasswordDetailItem(CopySiteButton())
assertWithMatcher:grey_layout(@[ Below() ], siteCell)];
[GetInteractionForPasswordDetailItem(UsernameHeader())
assertWithMatcher:grey_layout(@[ Below() ], CopySiteButton())];
id<GREYMatcher> usernameCell = grey_accessibilityLabel(@"concrete username");
[GetInteractionForPasswordDetailItem(usernameCell)
assertWithMatcher:grey_layout(@[ Below() ], UsernameHeader())];
[GetInteractionForPasswordDetailItem(CopyUsernameButton())
assertWithMatcher:grey_layout(@[ Below() ], usernameCell)];
id<GREYMatcher> passwordHeader =
grey_allOf(PasswordHeader(),
grey_kindOfClassName(@"UITableViewHeaderFooterView"), nil);
[GetInteractionForPasswordDetailItem(passwordHeader)
assertWithMatcher:grey_layout(@[ Below() ], CopyUsernameButton())];
id<GREYMatcher> passwordCell = grey_accessibilityLabel(
l10n_util::GetNSString(IDS_IOS_SETTINGS_PASSWORD_HIDDEN_LABEL));
[GetInteractionForPasswordDetailItem(passwordCell)
assertWithMatcher:grey_layout(@[ Below() ], passwordHeader)];
[GetInteractionForPasswordDetailItem(CopyPasswordButton())
assertWithMatcher:grey_layout(@[ Below() ], passwordCell)];
[GetInteractionForPasswordDetailItem(ShowPasswordButton())
assertWithMatcher:grey_layout(@[ Below() ], CopyPasswordButton())];
[GetInteractionForPasswordDetailItem(DeleteButton())
assertWithMatcher:grey_layout(@[ Below() ], ShowPasswordButton())];
[GetInteractionForPasswordDetailItem(PasswordDetailPassword()) // Check that the federation block is not present. Match directly to also
assertWithMatcher:grey_layout(@[ Below() ], PasswordDetailUsername())]; // catch the case where the block would be present but not currently visible
[GetInteractionForPasswordDetailItem(PasswordDetailUsername()) // due to the scrolling state.
assertWithMatcher:grey_layout(@[ Below() ], PasswordDetailWebsite())]; [[EarlGrey selectElementWithMatcher:FederationHeader()]
assertWithMatcher:grey_nil()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -872,11 +1023,25 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -872,11 +1023,25 @@ void CopyPasswordDetailWithID(int detail_id) {
[GetInteractionForPasswordEntry(@"example.com") performAction:grey_tap()]; [GetInteractionForPasswordEntry(@"example.com") performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:PasswordDetailWebsite()] [GetInteractionForPasswordDetailItem(SiteHeader())
assertWithMatcher:grey_textFieldValue(@"https://example.com/")]; assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:PasswordDetailUsername()] id<GREYMatcher> siteCell = grey_accessibilityLabel(@"https://example.com/");
[GetInteractionForPasswordDetailItem(siteCell)
assertWithMatcher:grey_layout(@[ Below() ], SiteHeader())];
[GetInteractionForPasswordDetailItem(CopySiteButton())
assertWithMatcher:grey_layout(@[ Below() ], siteCell)];
[GetInteractionForPasswordDetailItem(DeleteButton())
assertWithMatcher:grey_layout(@[ Below() ], CopySiteButton())];
// Check that the other blocks are not present. Match directly to also catch
// the case where those blocks would be present but not currently visible due
// to the scrolling state.
[[EarlGrey selectElementWithMatcher:UsernameHeader()]
assertWithMatcher:grey_nil()];
[[EarlGrey selectElementWithMatcher:PasswordHeader()]
assertWithMatcher:grey_nil()]; assertWithMatcher:grey_nil()];
[[EarlGrey selectElementWithMatcher:PasswordDetailPassword()] [[EarlGrey selectElementWithMatcher:FederationHeader()]
assertWithMatcher:grey_nil()]; assertWithMatcher:grey_nil()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
...@@ -901,16 +1066,37 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -901,16 +1066,37 @@ void CopyPasswordDetailWithID(int detail_id) {
[GetInteractionForPasswordEntry(@"example.com, federated username") [GetInteractionForPasswordEntry(@"example.com, federated username")
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:PasswordDetailWebsite()] [GetInteractionForPasswordDetailItem(SiteHeader())
assertWithMatcher:grey_textFieldValue(@"https://example.com/")]; assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:PasswordDetailUsername()] id<GREYMatcher> siteCell = grey_accessibilityLabel(@"https://example.com/");
assertWithMatcher:grey_textFieldValue(@"federated username")]; [GetInteractionForPasswordDetailItem(siteCell)
[[EarlGrey selectElementWithMatcher:PasswordDetailPassword()] assertWithMatcher:grey_layout(@[ Below() ], SiteHeader())];
[GetInteractionForPasswordDetailItem(CopySiteButton())
assertWithMatcher:grey_layout(@[ Below() ], siteCell)];
[GetInteractionForPasswordDetailItem(UsernameHeader())
assertWithMatcher:grey_layout(@[ Below() ], CopySiteButton())];
id<GREYMatcher> usernameCell = grey_accessibilityLabel(@"federated username");
[GetInteractionForPasswordDetailItem(usernameCell)
assertWithMatcher:grey_layout(@[ Below() ], UsernameHeader())];
[GetInteractionForPasswordDetailItem(CopyUsernameButton())
assertWithMatcher:grey_layout(@[ Below() ], usernameCell)];
[GetInteractionForPasswordDetailItem(FederationHeader())
assertWithMatcher:grey_layout(@[ Below() ], CopyUsernameButton())];
id<GREYMatcher> federationCell = grey_text(@"famous.provider.net");
[GetInteractionForPasswordDetailItem(federationCell)
assertWithMatcher:grey_layout(@[ Below() ], FederationHeader())];
[GetInteractionForPasswordDetailItem(DeleteButton())
assertWithMatcher:grey_layout(@[ Below() ], federationCell)];
// Check that the password is not present. Match directly to also catch the
// case where the password header would be present but not currently visible
// due to the scrolling state.
[[EarlGrey selectElementWithMatcher:PasswordHeader()]
assertWithMatcher:grey_nil()]; assertWithMatcher:grey_nil()];
[GetInteractionForPasswordDetailItem(PasswordDetailUsername())
assertWithMatcher:grey_layout(@[ Below() ], PasswordDetailWebsite())];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
...@@ -924,13 +1110,15 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -924,13 +1110,15 @@ void CopyPasswordDetailWithID(int detail_id) {
- (void)testStoredEntriesAlwaysShown { - (void)testStoredEntriesAlwaysShown {
SaveExamplePasswordForm(); SaveExamplePasswordForm();
GREYAssert([PasswordSettingsAppInterface
saveExampleBlockedOrigin:@"https://blocked.com"],
@"Stored form was not found in the PasswordStore results.");
OpenPasswordSettings(); OpenPasswordSettings();
// Toggle the "Save Passwords" control off and back on and check that stored // Toggle the "Save Passwords" control off and back on and check that stored
// items are still present. // items are still present.
BOOL isSwitchEnabled = constexpr BOOL kExpectedState[] = {YES, NO};
[PasswordSettingsAppInterface isCredentialsServiceEnabled];
BOOL kExpectedState[] = {isSwitchEnabled, !isSwitchEnabled};
for (BOOL expected_state : kExpectedState) { for (BOOL expected_state : kExpectedState) {
// Toggle the switch. It is located near the top, so if not interactable, // Toggle the switch. It is located near the top, so if not interactable,
// try scrolling up. // try scrolling up.
...@@ -948,6 +1136,8 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -948,6 +1136,8 @@ void CopyPasswordDetailWithID(int detail_id) {
// Check the stored items. Scroll down if needed. // Check the stored items. Scroll down if needed.
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
[GetInteractionForPasswordEntry(@"blocked.com")
assertWithMatcher:grey_notNil()];
} }
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
...@@ -1024,7 +1214,8 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -1024,7 +1214,8 @@ void CopyPasswordDetailWithID(int detail_id) {
[PasswordSettingsAppInterface setUpMockReauthenticationModule]; [PasswordSettingsAppInterface setUpMockReauthenticationModule];
[PasswordSettingsAppInterface mockReauthenticationModuleCanAttempt:NO]; [PasswordSettingsAppInterface mockReauthenticationModuleCanAttempt:NO];
CopyPasswordDetailWithID(IDS_IOS_SHOW_PASSWORD_VIEW_PASSWORD); [GetInteractionForPasswordDetailItem(CopyPasswordButton())
performAction:grey_tap()];
NSString* title = NSString* title =
l10n_util::GetNSString(IDS_IOS_SETTINGS_SET_UP_SCREENLOCK_TITLE); l10n_util::GetNSString(IDS_IOS_SETTINGS_SET_UP_SCREENLOCK_TITLE);
...@@ -1032,10 +1223,6 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -1032,10 +1223,6 @@ void CopyPasswordDetailWithID(int detail_id) {
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::OKButton()] [[EarlGrey selectElementWithMatcher:chrome_test_util::OKButton()]
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()] [[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()]; performAction:grey_tap()];
} }
...@@ -1116,12 +1303,12 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -1116,12 +1303,12 @@ void CopyPasswordDetailWithID(int detail_id) {
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
// Aim at an entry almost at the end of the list. // Aim at an entry almost at the end of the list.
constexpr int kRemoteIndex = kPasswordsCount - 4; constexpr int kRemoteIndex = kPasswordsCount - 2;
// The scrolling in GetInteractionForPasswordEntry has too fine steps to // The scrolling in GetInteractionForPasswordEntry has too fine steps to
// reach the desired part of the list quickly. The following gives it a head // reach the desired part of the list quickly. The following gives it a head
// start of the desired position, counting 30 points per entry and // start of almost the desired position, counting 30 points per entry and
// aiming at |kRemoteIndex|. // aiming 3 entries before |kRemoteIndex|.
constexpr int kJump = kRemoteIndex * 30 + 150; constexpr int kJump = (kRemoteIndex - 3) * 30;
[[EarlGrey [[EarlGrey
selectElementWithMatcher:grey_accessibilityID(kPasswordsTableViewId)] selectElementWithMatcher:grey_accessibilityID(kPasswordsTableViewId)]
performAction:grey_scrollInDirection(kGREYDirectionDown, kJump)]; performAction:grey_scrollInDirection(kGREYDirectionDown, kJump)];
...@@ -1130,10 +1317,10 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -1130,10 +1317,10 @@ void CopyPasswordDetailWithID(int detail_id) {
kRemoteIndex, kRemoteIndex]) performAction:grey_tap()]; kRemoteIndex, kRemoteIndex]) performAction:grey_tap()];
// Check that the detail view loaded correctly by verifying the site content. // Check that the detail view loaded correctly by verifying the site content.
[[EarlGrey selectElementWithMatcher:PasswordDetailWebsite()] id<GREYMatcher> siteCell = grey_accessibilityLabel([NSString
assertWithMatcher:grey_textFieldValue([NSString stringWithFormat:@"https://www%02d.example.com/", kRemoteIndex]);
stringWithFormat:@"https://www%02d.example.com/", [GetInteractionForPasswordDetailItem(siteCell)
kRemoteIndex])]; assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -1282,17 +1469,15 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -1282,17 +1469,15 @@ void CopyPasswordDetailWithID(int detail_id) {
assertWithMatcher:grey_nil()]; assertWithMatcher:grey_nil()];
[GetInteractionForPasswordEntry(@"exclude2.com") [GetInteractionForPasswordEntry(@"exclude2.com")
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
[[EarlGrey
selectElementWithMatcher:ButtonWithAccessibilityLabelId(IDS_CANCEL)]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()];
} }
// Test search and delete all passwords and blocked items. // Test search and delete all passwords and blocked items.
- (void)testSearchAndDeleteAllPasswords { - (void)testSearchAndDeleteAllPasswords {
// TODO(crbug.com/1129441): This is failing regularly downstream on iOS14.
if (@available(iOS 14, *)) {
EARL_GREY_TEST_DISABLED(@"Test disabled on iOS14.");
}
SaveExamplePasswordForms(); SaveExamplePasswordForms();
SaveExampleBlockedForms(); SaveExampleBlockedForms();
...@@ -1304,10 +1489,6 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -1304,10 +1489,6 @@ void CopyPasswordDetailWithID(int detail_id) {
// [[EarlGrey selectElementWithMatcher:SearchTextField()] // [[EarlGrey selectElementWithMatcher:SearchTextField()]
// performAction:grey_typeText(@"u\n")]; // performAction:grey_typeText(@"u\n")];
[[EarlGrey
selectElementWithMatcher:grey_accessibilityID(kPasswordsTableViewId)]
performAction:grey_scrollToContentEdge(kGREYContentEdgeBottom)];
TapEdit(); TapEdit();
// Select all. // Select all.
...@@ -1315,7 +1496,6 @@ void CopyPasswordDetailWithID(int detail_id) { ...@@ -1315,7 +1496,6 @@ void CopyPasswordDetailWithID(int detail_id) {
performAction:grey_tap()]; performAction:grey_tap()];
[GetInteractionForPasswordEntry(@"example12.com, user2") [GetInteractionForPasswordEntry(@"example12.com, user2")
performAction:grey_tap()]; performAction:grey_tap()];
[GetInteractionForPasswordEntry(@"exclude1.com") performAction:grey_tap()]; [GetInteractionForPasswordEntry(@"exclude1.com") performAction:grey_tap()];
[GetInteractionForPasswordEntry(@"exclude2.com") performAction:grey_tap()]; [GetInteractionForPasswordEntry(@"exclude2.com") performAction:grey_tap()];
......
...@@ -43,7 +43,6 @@ source_set("test_support") { ...@@ -43,7 +43,6 @@ source_set("test_support") {
"//components/keyed_service/core", "//components/keyed_service/core",
"//components/metrics", "//components/metrics",
"//components/metrics:demographics_test_support", "//components/metrics:demographics_test_support",
"//components/password_manager/core/common",
"//components/prefs", "//components/prefs",
"//components/signin/public/base", "//components/signin/public/base",
"//components/sync:test_support_nigori", "//components/sync:test_support_nigori",
...@@ -71,7 +70,6 @@ source_set("test_support") { ...@@ -71,7 +70,6 @@ source_set("test_support") {
"//ios/chrome/browser/signin", "//ios/chrome/browser/signin",
"//ios/chrome/browser/sync", "//ios/chrome/browser/sync",
"//ios/chrome/browser/tabs", "//ios/chrome/browser/tabs",
"//ios/chrome/browser/ui:feature_flags",
"//ios/chrome/browser/ui/authentication/cells", "//ios/chrome/browser/ui/authentication/cells",
"//ios/chrome/browser/ui/browser_view", "//ios/chrome/browser/ui/browser_view",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
...@@ -83,7 +81,6 @@ source_set("test_support") { ...@@ -83,7 +81,6 @@ source_set("test_support") {
"//ios/chrome/browser/ui/settings/password", "//ios/chrome/browser/ui/settings/password",
"//ios/chrome/browser/ui/settings/password:password_ui", "//ios/chrome/browser/ui/settings/password:password_ui",
"//ios/chrome/browser/ui/settings/password:test_support", "//ios/chrome/browser/ui/settings/password:test_support",
"//ios/chrome/browser/ui/settings/password/password_details:password_details_ui",
"//ios/chrome/browser/ui/tab_grid", "//ios/chrome/browser/ui/tab_grid",
"//ios/chrome/browser/ui/tabs", "//ios/chrome/browser/ui/tabs",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
......
...@@ -6,10 +6,8 @@ ...@@ -6,10 +6,8 @@
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#import "ios/chrome/browser/ui/settings/password/legacy_password_details_table_view_controller+testing.h" #import "ios/chrome/browser/ui/settings/password/legacy_password_details_table_view_controller+testing.h"
#import "ios/chrome/browser/ui/settings/password/password_details/password_details_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/password/passwords_table_view_controller.h" #import "ios/chrome/browser/ui/settings/password/passwords_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/settings_navigation_controller.h" #import "ios/chrome/browser/ui/settings/settings_navigation_controller.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/util/top_view_controller.h" #import "ios/chrome/browser/ui/util/top_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -55,11 +53,12 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() { ...@@ -55,11 +53,12 @@ MockReauthenticationModule* SetUpAndReturnMockReauthenticationModule() {
SettingsNavigationController* settings_navigation_controller = SettingsNavigationController* settings_navigation_controller =
base::mac::ObjCCastStrict<SettingsNavigationController>( base::mac::ObjCCastStrict<SettingsNavigationController>(
top_view_controller::TopPresentedViewController()); top_view_controller::TopPresentedViewController());
PasswordDetailsTableViewController* password_details_table_view_controller = LegacyPasswordDetailsTableViewController*
base::mac::ObjCCastStrict<PasswordDetailsTableViewController>( password_details_table_view_controller =
settings_navigation_controller.topViewController); base::mac::ObjCCastStrict<LegacyPasswordDetailsTableViewController>(
password_details_table_view_controller.reauthModule = settings_navigation_controller.topViewController);
mock_reauthentication_module; [password_details_table_view_controller
setReauthenticationModule:mock_reauthentication_module];
return mock_reauthentication_module; return mock_reauthentication_module;
} }
......
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