Chromium Code Reviews| 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 0362e76c1a38bacd32209561e452ec555ebdc02f..5788e8906b0794c781d0ef8a8b17142fa24ee5a0 100644 |
| --- a/ios/chrome/browser/ui/settings/passwords_settings_egtest.mm |
| +++ b/ios/chrome/browser/ui/settings/passwords_settings_egtest.mm |
| @@ -68,9 +68,50 @@ id<GREYMatcher> EditButton() { |
| return ButtonWithAccessibilityLabelId(IDS_IOS_NAVIGATION_BAR_EDIT_BUTTON); |
| } |
| -// Matcher for the Copy password button in Password Details view. |
| +// Copy buttons are challenging: they have both the same label ("Copy"), and |
| +// what is to be copied is indicated by which section they are in. To match the |
| +// correct button, the relative position to the section header needs to be |
| +// captured. The scheme of the vertical order is: |
| +// Username header |
| +// Copy (username) button |
| +// Password header |
| +// Copy (password) button |
| +// Therefore to match the correct copy button, one needs to apply grey_layout |
| +// to express its relative vertical position to the "Password" header. |
|
lpromero
2017/05/02 15:04:52
You could also use accessibility identifiers (acce
vabr (Chromium)
2017/05/02 15:29:09
My understanding was that if I could not write a r
|
| + |
| +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( |
| + ButtonWithAccessibilityLabelId(IDS_IOS_SETTINGS_USERNAME_COPY_BUTTON), |
| + grey_layout(@[ above ], PasswordHeader()), nullptr); |
|
lpromero
2017/05/02 15:04:52
I didn't know about this feature, that's a nice on
vabr (Chromium)
2017/05/02 15:29:09
I had a lot of educational time in front of the AP
|
| +} |
| + |
| +// 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( |
| + ButtonWithAccessibilityLabelId(IDS_IOS_SETTINGS_PASSWORD_COPY_BUTTON), |
| + grey_layout(@[ below ], PasswordHeader()), nullptr); |
| } |
| } // namespace |
| @@ -302,4 +343,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 |