Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Unified Diff: ios/chrome/browser/ui/settings/passwords_settings_egtest.mm

Issue 2719023005: Provide Copy button for username in password settings (Closed)
Patch Set: Fix format string Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/ui/settings/password_details_collection_view_controller_unittest.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/settings/passwords_settings_egtest.mm
diff --git a/ios/chrome/browser/ui/settings/passwords_settings_egtest.mm b/ios/chrome/browser/ui/settings/passwords_settings_egtest.mm
index e5b7c06b231f5f08f93b023d7182a26135132a81..aba0b2483db43b8cc018a8f5165bfe3346f3fc30 100644
--- a/ios/chrome/browser/ui/settings/passwords_settings_egtest.mm
+++ b/ios/chrome/browser/ui/settings/passwords_settings_egtest.mm
@@ -68,9 +68,58 @@ id<GREYMatcher> EditButton() {
return ButtonWithAccessibilityLabelId(IDS_IOS_NAVIGATION_BAR_EDIT_BUTTON);
}
-// Matcher for the Copy password button in Password Details view.
+// Copy buttons have unique accessibility labels, but the visible text is the
+// same for multiple types of copied items (just "Copy"). Therefore the
+// matchers here check the relative position of the Copy buttons to their
+// respective section headers as well. The scheme of the vertical order is:
+// Username header
+// Copy (username) button
+// Password header
+// Copy (password) button
+
+id<GREYMatcher> PasswordHeader() {
+ return grey_allOf(
+ grey_accessibilityLabel(
+ l10n_util::GetNSString(IDS_IOS_SHOW_PASSWORD_VIEW_PASSWORD)),
+ grey_accessibilityTrait(UIAccessibilityTraitHeader), nullptr);
+}
+
+// Matcher for the Copy username button in Password Details view. This is the
+// button above the Password section header.
+id<GREYMatcher> CopyUsernameButton() {
+ GREYLayoutConstraint* above = [GREYLayoutConstraint
+ layoutConstraintWithAttribute:kGREYLayoutAttributeBottom
+ relatedBy:kGREYLayoutRelationLessThanOrEqual
+ toReferenceAttribute:kGREYLayoutAttributeTop
+ multiplier:1.0
+ constant:0.0];
+ return grey_allOf(
+ ButtonWithAccessibilityLabel([NSString
+ stringWithFormat:@"%@: %@",
+ l10n_util::GetNSString(
+ IDS_IOS_SHOW_PASSWORD_VIEW_USERNAME),
+ l10n_util::GetNSString(
+ IDS_IOS_SETTINGS_USERNAME_COPY_BUTTON)]),
+ grey_layout(@[ above ], PasswordHeader()), nullptr);
+}
+
+// Matcher for the Copy password button in Password Details view. This is the
+// button below the Password section header.
id<GREYMatcher> CopyPasswordButton() {
- return ButtonWithAccessibilityLabelId(IDS_IOS_SETTINGS_PASSWORD_COPY_BUTTON);
+ GREYLayoutConstraint* below = [GREYLayoutConstraint
+ layoutConstraintWithAttribute:kGREYLayoutAttributeTop
+ relatedBy:kGREYLayoutRelationGreaterThanOrEqual
+ toReferenceAttribute:kGREYLayoutAttributeBottom
+ multiplier:1.0
+ constant:0.0];
+ return grey_allOf(
+ ButtonWithAccessibilityLabel([NSString
+ stringWithFormat:@"%@: %@",
+ l10n_util::GetNSString(
+ IDS_IOS_SHOW_PASSWORD_VIEW_PASSWORD),
+ l10n_util::GetNSString(
+ IDS_IOS_SETTINGS_PASSWORD_COPY_BUTTON)]),
+ grey_layout(@[ below ], PasswordHeader()), nullptr);
}
} // namespace
@@ -304,4 +353,31 @@ id<GREYMatcher> CopyPasswordButton() {
[self clearPasswordStore];
}
+// Checks that attempts to copy a username provide appropriate feedback.
+- (void)testCopyUsernameToast {
+ [self scopedEnablePasswordManagementAndViewingUI];
+
+ // Saving a form is needed for using the "password details" view.
+ [self saveExamplePasswordForm];
+
+ [self openPasswordSettings];
+
+ [[EarlGrey selectElementWithMatcher:Entry(@"https://example.com, user")]
+ performAction:grey_tap()];
+
+ // Check the snackbar.
+ [[EarlGrey selectElementWithMatcher:CopyUsernameButton()]
+ performAction:grey_tap()];
+ [[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
+ NSString* snackbarLabel =
+ l10n_util::GetNSString(IDS_IOS_SETTINGS_USERNAME_WAS_COPIED_MESSAGE);
+ [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(snackbarLabel)]
+ assertWithMatcher:grey_notNil()];
+
+ [self tapBackArrow];
+ [self tapBackArrow];
+ [self tapDone];
+ [self clearPasswordStore];
+}
+
@end
« no previous file with comments | « ios/chrome/browser/ui/settings/password_details_collection_view_controller_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698