| 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" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // integration tests and features which are not currently unittestable should | 39 // integration tests and features which are not currently unittestable should |
| 40 // go here, the rest into the unittest. | 40 // go here, the rest into the unittest. |
| 41 // This test only uses the new UI which allows viewing passwords. | 41 // This test only uses the new UI which allows viewing passwords. |
| 42 // 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 |
| 43 // default one. | 43 // default one. |
| 44 | 44 |
| 45 using autofill::PasswordForm; | 45 using autofill::PasswordForm; |
| 46 using chrome_test_util::ButtonWithAccessibilityLabel; | 46 using chrome_test_util::ButtonWithAccessibilityLabel; |
| 47 using chrome_test_util::ButtonWithAccessibilityLabelId; | 47 using chrome_test_util::ButtonWithAccessibilityLabelId; |
| 48 using chrome_test_util::NavigationBarDoneButton; | 48 using chrome_test_util::NavigationBarDoneButton; |
| 49 using chrome_test_util::SettingsMenuButton; |
| 49 | 50 |
| 50 namespace { | 51 namespace { |
| 51 | 52 |
| 52 // How many points to scroll at a time when searching for an element. Setting it | 53 // 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 // 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 // it too high could result in scrolling way past the searched element. |
| 55 constexpr int kScrollAmount = 150; | 56 constexpr int kScrollAmount = 150; |
| 56 | 57 |
| 57 // Matcher for the Settings button in the tools menu. | |
| 58 id<GREYMatcher> SettingsButton() { | |
| 59 return grey_accessibilityID(kToolsMenuSettingsId); | |
| 60 } | |
| 61 | |
| 62 // Matcher for the Save Passwords cell on the main Settings screen. | 58 // Matcher for the Save Passwords cell on the main Settings screen. |
| 63 id<GREYMatcher> PasswordsButton() { | 59 id<GREYMatcher> PasswordsButton() { |
| 64 return ButtonWithAccessibilityLabelId(IDS_IOS_SAVE_PASSWORDS); | 60 return ButtonWithAccessibilityLabelId(IDS_IOS_SAVE_PASSWORDS); |
| 65 } | 61 } |
| 66 | 62 |
| 67 // Matcher for a password entry for |username|. | 63 // Matcher for a password entry for |username|. |
| 68 id<GREYMatcher> Entry(NSString* username) { | 64 id<GREYMatcher> Entry(NSString* username) { |
| 69 return ButtonWithAccessibilityLabel(username); | 65 return ButtonWithAccessibilityLabel(username); |
| 70 } | 66 } |
| 71 | 67 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 [self passwordStore]->RemoveLoginsCreatedBetween(base::Time(), base::Time(), | 276 [self passwordStore]->RemoveLoginsCreatedBetween(base::Time(), base::Time(), |
| 281 base::Closure()); | 277 base::Closure()); |
| 282 // Allow the PasswordStore to process this on the DB thread. | 278 // Allow the PasswordStore to process this on the DB thread. |
| 283 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 279 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 284 } | 280 } |
| 285 | 281 |
| 286 // Opens the passwords page from the NTP. It requires no menus to be open. | 282 // Opens the passwords page from the NTP. It requires no menus to be open. |
| 287 - (void)openPasswordSettings { | 283 - (void)openPasswordSettings { |
| 288 // Open settings and verify data in the view controller. | 284 // Open settings and verify data in the view controller. |
| 289 [ChromeEarlGreyUI openToolsMenu]; | 285 [ChromeEarlGreyUI openToolsMenu]; |
| 290 [[EarlGrey selectElementWithMatcher:SettingsButton()] | 286 [[EarlGrey selectElementWithMatcher:SettingsMenuButton()] |
| 291 performAction:grey_tap()]; | 287 performAction:grey_tap()]; |
| 292 [[EarlGrey selectElementWithMatcher:PasswordsButton()] | 288 [[EarlGrey selectElementWithMatcher:PasswordsButton()] |
| 293 performAction:grey_tap()]; | 289 performAction:grey_tap()]; |
| 294 | 290 |
| 295 // Wait for UI components to finish loading. | 291 // Wait for UI components to finish loading. |
| 296 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 292 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 297 } | 293 } |
| 298 | 294 |
| 299 // Tap back arrow, to get one level higher in settings. | 295 // Tap back arrow, to get one level higher in settings. |
| 300 - (void)tapBackArrow { | 296 - (void)tapBackArrow { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 // Wait until the fade-out animation completes. | 481 // Wait until the fade-out animation completes. |
| 486 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 482 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
| 487 | 483 |
| 488 [self tapBackArrow]; | 484 [self tapBackArrow]; |
| 489 [self tapBackArrow]; | 485 [self tapBackArrow]; |
| 490 [self tapDone]; | 486 [self tapDone]; |
| 491 [self clearPasswordStore]; | 487 [self clearPasswordStore]; |
| 492 } | 488 } |
| 493 | 489 |
| 494 @end | 490 @end |
| OLD | NEW |