Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/callback.h" | 5 #include "base/callback.h" |
| 6 #include "base/mac/foundation_util.h" | 6 #include "base/mac/foundation_util.h" |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "components/autofill/core/common/password_form.h" | 10 #include "components/autofill/core/common/password_form.h" |
| 11 #include "components/keyed_service/core/service_access_type.h" | 11 #include "components/keyed_service/core/service_access_type.h" |
| 12 #include "components/password_manager/core/browser/password_store.h" | 12 #include "components/password_manager/core/browser/password_store.h" |
| 13 #include "components/password_manager/core/common/password_manager_pref_names.h" | 13 #include "components/password_manager/core/common/password_manager_pref_names.h" |
| 14 #include "components/prefs/pref_service.h" | 14 #include "components/prefs/pref_service.h" |
| 15 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 15 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 16 #include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h" | 16 #include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h" |
| 17 #import "ios/chrome/browser/ui/settings/password_details_collection_view_control ler_for_testing.h" | 17 #import "ios/chrome/browser/ui/settings/password_details_collection_view_control ler_for_testing.h" |
| 18 #import "ios/chrome/browser/ui/settings/reauthentication_module.h" | 18 #import "ios/chrome/browser/ui/settings/reauthentication_module.h" |
| 19 #import "ios/chrome/browser/ui/settings/settings_navigation_controller.h" | 19 #import "ios/chrome/browser/ui/settings/settings_navigation_controller.h" |
| 20 #include "ios/chrome/browser/ui/tools_menu/tools_menu_constants.h" | 20 #include "ios/chrome/browser/ui/tools_menu/tools_menu_constants.h" |
| 21 #import "ios/chrome/browser/ui/util/top_view_controller.h" | 21 #import "ios/chrome/browser/ui/util/top_view_controller.h" |
| 22 #include "ios/chrome/grit/ios_strings.h" | 22 #include "ios/chrome/grit/ios_strings.h" |
| 23 #import "ios/chrome/test/app/chrome_test_util.h" | 23 #import "ios/chrome/test/app/chrome_test_util.h" |
| 24 #include "ios/chrome/test/earl_grey/accessibility_util.h" | 24 #include "ios/chrome/test/earl_grey/accessibility_util.h" |
| 25 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" | 25 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" |
| 26 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" | 26 #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" |
| 27 #import "ios/chrome/test/earl_grey/chrome_matchers.h" | 27 #import "ios/chrome/test/earl_grey/chrome_matchers.h" |
| 28 #import "ios/chrome/test/earl_grey/chrome_test_case.h" | 28 #import "ios/chrome/test/earl_grey/chrome_test_case.h" |
| 29 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat erialSnackbar.h" | |
| 29 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 30 #include "url/gurl.h" | 31 #include "url/gurl.h" |
| 31 | 32 |
| 32 #if !defined(__has_feature) || !__has_feature(objc_arc) | 33 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 33 #error "This file requires ARC support." | 34 #error "This file requires ARC support." |
| 34 #endif | 35 #endif |
| 35 | 36 |
| 36 // This test complements | 37 // This test complements |
| 37 // password_details_collection_view_controller_unittest.mm. Very simple | 38 // password_details_collection_view_controller_unittest.mm. Very simple |
| 38 // integration tests and features which are not currently unittestable should | 39 // integration tests and features which are not currently unittestable should |
| 39 // go here, the rest into the unittest. | 40 // go here, the rest into the unittest. |
| 40 // This test only uses the new UI which allows viewing passwords. | 41 // This test only uses the new UI which allows viewing passwords. |
| 41 // TODO(crbug.com/159166): Remove the above sentence once the new UI is the | 42 // TODO(crbug.com/159166): Remove the above sentence once the new UI is the |
| 42 // default one. | 43 // default one. |
| 43 | 44 |
| 44 using autofill::PasswordForm; | 45 using autofill::PasswordForm; |
| 45 using chrome_test_util::ButtonWithAccessibilityLabel; | 46 using chrome_test_util::ButtonWithAccessibilityLabel; |
| 46 using chrome_test_util::ButtonWithAccessibilityLabelId; | 47 using chrome_test_util::ButtonWithAccessibilityLabelId; |
| 47 using chrome_test_util::NavigationBarDoneButton; | 48 using chrome_test_util::NavigationBarDoneButton; |
| 48 | 49 |
| 49 namespace { | 50 namespace { |
| 50 | 51 |
| 52 // How many points to scroll at a time when searching for an element. Setting it | |
| 53 // too low means searching takes too long and the test might time out. Setting | |
| 54 // it too high could result in scrolling way past the searched element. | |
| 55 constexpr int kScrollAmount = 150; | |
|
lpromero
2017/05/04 15:55:41
No action needed: I didn't know about constexpr.
vabr (Chromium)
2017/05/04 16:38:20
I'm also getting used to it. It is part of C++11,
| |
| 56 | |
| 51 // Matcher for the Settings button in the tools menu. | 57 // Matcher for the Settings button in the tools menu. |
| 52 id<GREYMatcher> SettingsButton() { | 58 id<GREYMatcher> SettingsButton() { |
| 53 return grey_accessibilityID(kToolsMenuSettingsId); | 59 return grey_accessibilityID(kToolsMenuSettingsId); |
| 54 } | 60 } |
| 55 | 61 |
| 56 // Matcher for the Save Passwords cell on the main Settings screen. | 62 // Matcher for the Save Passwords cell on the main Settings screen. |
| 57 id<GREYMatcher> PasswordsButton() { | 63 id<GREYMatcher> PasswordsButton() { |
| 58 return ButtonWithAccessibilityLabelId(IDS_IOS_SAVE_PASSWORDS); | 64 return ButtonWithAccessibilityLabelId(IDS_IOS_SAVE_PASSWORDS); |
| 59 } | 65 } |
| 60 | 66 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 layoutConstraintWithAttribute:kGREYLayoutAttributeTop | 120 layoutConstraintWithAttribute:kGREYLayoutAttributeTop |
| 115 relatedBy:kGREYLayoutRelationGreaterThanOrEqual | 121 relatedBy:kGREYLayoutRelationGreaterThanOrEqual |
| 116 toReferenceAttribute:kGREYLayoutAttributeBottom | 122 toReferenceAttribute:kGREYLayoutAttributeBottom |
| 117 multiplier:1.0 | 123 multiplier:1.0 |
| 118 constant:0.0]; | 124 constant:0.0]; |
| 119 } | 125 } |
| 120 | 126 |
| 121 // Matcher for the Copy site button in Password Details view. | 127 // Matcher for the Copy site button in Password Details view. |
| 122 id<GREYMatcher> CopySiteButton() { | 128 id<GREYMatcher> CopySiteButton() { |
| 123 return grey_allOf( | 129 return grey_allOf( |
| 130 grey_interactable(), | |
| 124 ButtonWithAccessibilityLabel( | 131 ButtonWithAccessibilityLabel( |
| 125 [NSString stringWithFormat:@"%@: %@", | 132 [NSString stringWithFormat:@"%@: %@", |
| 126 l10n_util::GetNSString( | 133 l10n_util::GetNSString( |
| 127 IDS_IOS_SHOW_PASSWORD_VIEW_SITE), | 134 IDS_IOS_SHOW_PASSWORD_VIEW_SITE), |
| 128 l10n_util::GetNSString( | 135 l10n_util::GetNSString( |
| 129 IDS_IOS_SETTINGS_SITE_COPY_BUTTON)]), | 136 IDS_IOS_SETTINGS_SITE_COPY_BUTTON)]), |
| 130 grey_layout(@[ Below() ], SiteHeader()), | 137 grey_layout(@[ Below() ], SiteHeader()), |
| 131 grey_layout(@[ Above() ], UsernameHeader()), | 138 grey_layout(@[ Above() ], UsernameHeader()), |
| 132 grey_layout(@[ Above() ], PasswordHeader()), nullptr); | 139 grey_layout(@[ Above() ], PasswordHeader()), nullptr); |
| 133 } | 140 } |
| 134 | 141 |
| 135 // Matcher for the Copy username button in Password Details view. | 142 // Matcher for the Copy username button in Password Details view. |
| 136 id<GREYMatcher> CopyUsernameButton() { | 143 id<GREYMatcher> CopyUsernameButton() { |
| 137 return grey_allOf( | 144 return grey_allOf( |
| 145 grey_interactable(), | |
| 138 ButtonWithAccessibilityLabel([NSString | 146 ButtonWithAccessibilityLabel([NSString |
| 139 stringWithFormat:@"%@: %@", | 147 stringWithFormat:@"%@: %@", |
| 140 l10n_util::GetNSString( | 148 l10n_util::GetNSString( |
| 141 IDS_IOS_SHOW_PASSWORD_VIEW_USERNAME), | 149 IDS_IOS_SHOW_PASSWORD_VIEW_USERNAME), |
| 142 l10n_util::GetNSString( | 150 l10n_util::GetNSString( |
| 143 IDS_IOS_SETTINGS_USERNAME_COPY_BUTTON)]), | 151 IDS_IOS_SETTINGS_USERNAME_COPY_BUTTON)]), |
| 144 grey_layout(@[ Below() ], SiteHeader()), | 152 grey_layout(@[ Below() ], SiteHeader()), |
| 145 grey_layout(@[ Below() ], UsernameHeader()), | 153 grey_layout(@[ Below() ], UsernameHeader()), |
| 146 grey_layout(@[ Above() ], PasswordHeader()), nullptr); | 154 grey_layout(@[ Above() ], PasswordHeader()), nullptr); |
| 147 } | 155 } |
| 148 | 156 |
| 149 // Matcher for the Copy password button in Password Details view. | 157 // Matcher for the Copy password button in Password Details view. |
| 150 id<GREYMatcher> CopyPasswordButton() { | 158 id<GREYMatcher> CopyPasswordButton() { |
| 151 return grey_allOf( | 159 return grey_allOf( |
| 160 grey_interactable(), | |
| 152 ButtonWithAccessibilityLabel([NSString | 161 ButtonWithAccessibilityLabel([NSString |
| 153 stringWithFormat:@"%@: %@", | 162 stringWithFormat:@"%@: %@", |
| 154 l10n_util::GetNSString( | 163 l10n_util::GetNSString( |
| 155 IDS_IOS_SHOW_PASSWORD_VIEW_PASSWORD), | 164 IDS_IOS_SHOW_PASSWORD_VIEW_PASSWORD), |
| 156 l10n_util::GetNSString( | 165 l10n_util::GetNSString( |
| 157 IDS_IOS_SETTINGS_PASSWORD_COPY_BUTTON)]), | 166 IDS_IOS_SETTINGS_PASSWORD_COPY_BUTTON)]), |
| 158 grey_layout(@[ Below() ], SiteHeader()), | 167 grey_layout(@[ Below() ], SiteHeader()), |
| 159 grey_layout(@[ Below() ], UsernameHeader()), | 168 grey_layout(@[ Below() ], UsernameHeader()), |
| 160 grey_layout(@[ Below() ], PasswordHeader()), nullptr); | 169 grey_layout(@[ Below() ], PasswordHeader()), nullptr); |
| 161 } | 170 } |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 183 } | 192 } |
| 184 | 193 |
| 185 @end | 194 @end |
| 186 | 195 |
| 187 // Various tests for the Save Passwords section of the settings. | 196 // Various tests for the Save Passwords section of the settings. |
| 188 @interface PasswordsSettingsTestCase : ChromeTestCase | 197 @interface PasswordsSettingsTestCase : ChromeTestCase |
| 189 @end | 198 @end |
| 190 | 199 |
| 191 @implementation PasswordsSettingsTestCase | 200 @implementation PasswordsSettingsTestCase |
| 192 | 201 |
| 202 - (void)tearDown { | |
| 203 // Snackbars triggered by tests stay up for a limited time even if the | |
| 204 // settings get closed. Ensure that they are closed to avoid interference with | |
| 205 // other tests. | |
| 206 [MDCSnackbarManager | |
| 207 dismissAndCallCompletionBlocksWithCategory:@"PasswordsSnackbarCategory"]; | |
| 208 [super tearDown]; | |
| 209 } | |
| 210 | |
| 193 // Return pref for saving passwords back to the passed value and restores the | 211 // Return pref for saving passwords back to the passed value and restores the |
| 194 // experimental flag for viewing passwords. | 212 // experimental flag for viewing passwords. |
| 195 - (void)passwordsTearDown:(BOOL)defaultPasswordManagementSetting | 213 - (void)passwordsTearDown:(BOOL)defaultPasswordManagementSetting |
| 196 :(NSString*)oldExperiment { | 214 :(NSString*)oldExperiment { |
| 197 ios::ChromeBrowserState* browserState = | 215 ios::ChromeBrowserState* browserState = |
| 198 chrome_test_util::GetOriginalBrowserState(); | 216 chrome_test_util::GetOriginalBrowserState(); |
| 199 PrefService* preferences = browserState->GetPrefs(); | 217 PrefService* preferences = browserState->GetPrefs(); |
| 200 preferences->SetBoolean( | 218 preferences->SetBoolean( |
| 201 password_manager::prefs::kPasswordManagerSavingEnabled, | 219 password_manager::prefs::kPasswordManagerSavingEnabled, |
| 202 defaultPasswordManagementSetting); | 220 defaultPasswordManagementSetting); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 chrome_test_util::VerifyAccessibilityForCurrentScreen(); | 350 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 333 [self tapBackArrow]; | 351 [self tapBackArrow]; |
| 334 | 352 |
| 335 [self tapBackArrow]; | 353 [self tapBackArrow]; |
| 336 [self tapDone]; | 354 [self tapDone]; |
| 337 [self clearPasswordStore]; | 355 [self clearPasswordStore]; |
| 338 } | 356 } |
| 339 | 357 |
| 340 // Checks that attempts to copy a password provide appropriate feedback, | 358 // Checks that attempts to copy a password provide appropriate feedback, |
| 341 // both when reauthentication succeeds and when it fails. | 359 // both when reauthentication succeeds and when it fails. |
| 342 // TODO(crbug.com/718043): Re-enable test. | 360 - (void)testCopyPasswordToast { |
| 343 - (void)DISABLED_testCopyPasswordToast { | |
| 344 [self scopedEnablePasswordManagementAndViewingUI]; | 361 [self scopedEnablePasswordManagementAndViewingUI]; |
| 345 | 362 |
| 346 // Saving a form is needed for using the "password details" view. | 363 // Saving a form is needed for using the "password details" view. |
| 347 [self saveExamplePasswordForm]; | 364 [self saveExamplePasswordForm]; |
| 348 | 365 |
| 349 [self openPasswordSettings]; | 366 [self openPasswordSettings]; |
| 350 | 367 |
| 351 [[EarlGrey selectElementWithMatcher:Entry(@"https://example.com, user")] | 368 [[EarlGrey selectElementWithMatcher:Entry(@"https://example.com, user")] |
| 352 performAction:grey_tap()]; | 369 performAction:grey_tap()]; |
| 353 | 370 |
| 354 // Get the PasswordDetailsCollectionViewController and replace the | 371 // Get the PasswordDetailsCollectionViewController and replace the |
| 355 // reauthentication module with a fake one to avoid being blocked with a | 372 // reauthentication module with a fake one to avoid being blocked with a |
| 356 // reauth prompt. | 373 // reauth prompt. |
| 357 MockReauthenticationModule* mock_reauthentication_module = | 374 MockReauthenticationModule* mock_reauthentication_module = |
| 358 [[MockReauthenticationModule alloc] init]; | 375 [[MockReauthenticationModule alloc] init]; |
| 359 SettingsNavigationController* settings_navigation_controller = | 376 SettingsNavigationController* settings_navigation_controller = |
| 360 base::mac::ObjCCastStrict<SettingsNavigationController>( | 377 base::mac::ObjCCastStrict<SettingsNavigationController>( |
| 361 top_view_controller::TopPresentedViewController()); | 378 top_view_controller::TopPresentedViewController()); |
| 362 PasswordDetailsCollectionViewController* | 379 PasswordDetailsCollectionViewController* |
| 363 password_details_collection_view_controller = | 380 password_details_collection_view_controller = |
| 364 base::mac::ObjCCastStrict<PasswordDetailsCollectionViewController>( | 381 base::mac::ObjCCastStrict<PasswordDetailsCollectionViewController>( |
| 365 settings_navigation_controller.topViewController); | 382 settings_navigation_controller.topViewController); |
| 366 [password_details_collection_view_controller | 383 [password_details_collection_view_controller |
| 367 setReauthenticationModule:mock_reauthentication_module]; | 384 setReauthenticationModule:mock_reauthentication_module]; |
| 368 | 385 |
| 369 // Check the snackbar in case of successful reauthentication. | 386 // Check the snackbar in case of successful reauthentication. |
| 370 mock_reauthentication_module.shouldSucceed = YES; | 387 mock_reauthentication_module.shouldSucceed = YES; |
| 371 [[EarlGrey selectElementWithMatcher:CopyPasswordButton()] | 388 [[[EarlGrey selectElementWithMatcher:CopyPasswordButton()] |
| 389 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, | |
| 390 kScrollAmount) | |
| 391 onElementWithMatcher:grey_accessibilityID( | |
| 392 @"PasswordDetailsCollectionViewController")] | |
| 372 performAction:grey_tap()]; | 393 performAction:grey_tap()]; |
| 373 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 394 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 374 NSString* snackbarLabel = | 395 NSString* snackbarLabel = |
| 375 l10n_util::GetNSString(IDS_IOS_SETTINGS_PASSWORD_WAS_COPIED_MESSAGE); | 396 l10n_util::GetNSString(IDS_IOS_SETTINGS_PASSWORD_WAS_COPIED_MESSAGE); |
| 397 // The tap checks the existence of the snackbar and also closes it. | |
| 376 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(snackbarLabel)] | 398 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(snackbarLabel)] |
| 377 assertWithMatcher:grey_notNil()]; | 399 performAction:grey_tap()]; |
| 400 // Wait until the fade-out animation completes. | |
| 401 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | |
| 378 | 402 |
| 379 // Check the snackbar in case of failed reauthentication. | 403 // Check the snackbar in case of failed reauthentication. |
| 380 mock_reauthentication_module.shouldSucceed = NO; | 404 mock_reauthentication_module.shouldSucceed = NO; |
| 381 [[EarlGrey selectElementWithMatcher:CopyPasswordButton()] | 405 [[[EarlGrey selectElementWithMatcher:CopyPasswordButton()] |
| 406 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, | |
| 407 kScrollAmount) | |
| 408 onElementWithMatcher:grey_accessibilityID( | |
| 409 @"PasswordDetailsCollectionViewController")] | |
| 382 performAction:grey_tap()]; | 410 performAction:grey_tap()]; |
| 383 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 411 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 384 snackbarLabel = | 412 snackbarLabel = |
| 385 l10n_util::GetNSString(IDS_IOS_SETTINGS_PASSWORD_WAS_NOT_COPIED_MESSAGE); | 413 l10n_util::GetNSString(IDS_IOS_SETTINGS_PASSWORD_WAS_NOT_COPIED_MESSAGE); |
| 414 // The tap checks the existence of the snackbar and also closes it. | |
| 386 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(snackbarLabel)] | 415 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(snackbarLabel)] |
| 387 assertWithMatcher:grey_notNil()]; | 416 performAction:grey_tap()]; |
| 417 // Wait until the fade-out animation completes. | |
| 418 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | |
| 388 | 419 |
| 389 [self tapBackArrow]; | 420 [self tapBackArrow]; |
| 390 [self tapBackArrow]; | 421 [self tapBackArrow]; |
| 391 [self tapDone]; | 422 [self tapDone]; |
| 392 [self clearPasswordStore]; | 423 [self clearPasswordStore]; |
| 393 } | 424 } |
| 394 | 425 |
| 395 // Checks that attempts to copy a username provide appropriate feedback. | 426 // Checks that attempts to copy a username provide appropriate feedback. |
| 396 - (void)testCopyUsernameToast { | 427 - (void)testCopyUsernameToast { |
| 397 [self scopedEnablePasswordManagementAndViewingUI]; | 428 [self scopedEnablePasswordManagementAndViewingUI]; |
| 398 | 429 |
| 399 // Saving a form is needed for using the "password details" view. | 430 // Saving a form is needed for using the "password details" view. |
| 400 [self saveExamplePasswordForm]; | 431 [self saveExamplePasswordForm]; |
| 401 | 432 |
| 402 [self openPasswordSettings]; | 433 [self openPasswordSettings]; |
| 403 | 434 |
| 404 [[EarlGrey selectElementWithMatcher:Entry(@"https://example.com, user")] | 435 [[EarlGrey selectElementWithMatcher:Entry(@"https://example.com, user")] |
| 405 performAction:grey_tap()]; | 436 performAction:grey_tap()]; |
| 406 | 437 |
| 407 // Check the snackbar. | 438 // Check the snackbar. |
| 408 [[EarlGrey selectElementWithMatcher:CopyUsernameButton()] | 439 [[[EarlGrey selectElementWithMatcher:CopyUsernameButton()] |
| 440 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, | |
| 441 kScrollAmount) | |
| 442 onElementWithMatcher:grey_accessibilityID( | |
| 443 @"PasswordDetailsCollectionViewController")] | |
| 409 performAction:grey_tap()]; | 444 performAction:grey_tap()]; |
| 410 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 445 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 411 NSString* snackbarLabel = | 446 NSString* snackbarLabel = |
| 412 l10n_util::GetNSString(IDS_IOS_SETTINGS_USERNAME_WAS_COPIED_MESSAGE); | 447 l10n_util::GetNSString(IDS_IOS_SETTINGS_USERNAME_WAS_COPIED_MESSAGE); |
| 448 // The tap checks the existence of the snackbar and also closes it. | |
| 413 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(snackbarLabel)] | 449 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(snackbarLabel)] |
| 414 assertWithMatcher:grey_notNil()]; | 450 performAction:grey_tap()]; |
| 451 // Wait until the fade-out animation completes. | |
| 452 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | |
| 415 | 453 |
| 416 [self tapBackArrow]; | 454 [self tapBackArrow]; |
| 417 [self tapBackArrow]; | 455 [self tapBackArrow]; |
| 418 [self tapDone]; | 456 [self tapDone]; |
| 419 [self clearPasswordStore]; | 457 [self clearPasswordStore]; |
| 420 } | 458 } |
| 421 | 459 |
| 422 // Checks that attempts to copy a site URL provide appropriate feedback. | 460 // Checks that attempts to copy a site URL provide appropriate feedback. |
| 423 - (void)testCopySiteToast { | 461 - (void)testCopySiteToast { |
| 424 [self scopedEnablePasswordManagementAndViewingUI]; | 462 [self scopedEnablePasswordManagementAndViewingUI]; |
| 425 | 463 |
| 426 // Saving a form is needed for using the "password details" view. | 464 // Saving a form is needed for using the "password details" view. |
| 427 [self saveExamplePasswordForm]; | 465 [self saveExamplePasswordForm]; |
| 428 | 466 |
| 429 [self openPasswordSettings]; | 467 [self openPasswordSettings]; |
| 430 | 468 |
| 431 [[EarlGrey selectElementWithMatcher:Entry(@"https://example.com, user")] | 469 [[EarlGrey selectElementWithMatcher:Entry(@"https://example.com, user")] |
| 432 performAction:grey_tap()]; | 470 performAction:grey_tap()]; |
| 433 | 471 |
| 434 // Check the snackbar. | 472 // Check the snackbar. |
| 435 [[EarlGrey selectElementWithMatcher:CopySiteButton()] | 473 [[[EarlGrey selectElementWithMatcher:CopySiteButton()] |
| 474 usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, | |
| 475 kScrollAmount) | |
| 476 onElementWithMatcher:grey_accessibilityID( | |
| 477 @"PasswordDetailsCollectionViewController")] | |
| 436 performAction:grey_tap()]; | 478 performAction:grey_tap()]; |
| 437 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 479 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 438 NSString* snackbarLabel = | 480 NSString* snackbarLabel = |
| 439 l10n_util::GetNSString(IDS_IOS_SETTINGS_SITE_WAS_COPIED_MESSAGE); | 481 l10n_util::GetNSString(IDS_IOS_SETTINGS_SITE_WAS_COPIED_MESSAGE); |
| 482 // The tap checks the existence of the snackbar and also closes it. | |
| 440 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(snackbarLabel)] | 483 [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(snackbarLabel)] |
| 441 assertWithMatcher:grey_notNil()]; | 484 performAction:grey_tap()]; |
| 485 // Wait until the fade-out animation completes. | |
| 486 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | |
| 442 | 487 |
| 443 [self tapBackArrow]; | 488 [self tapBackArrow]; |
| 444 [self tapBackArrow]; | 489 [self tapBackArrow]; |
| 445 [self tapDone]; | 490 [self tapDone]; |
| 446 [self clearPasswordStore]; | 491 [self clearPasswordStore]; |
| 447 } | 492 } |
| 448 | 493 |
| 449 @end | 494 @end |
| OLD | NEW |