OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import <EarlGrey/EarlGrey.h> | 5 #import <EarlGrey/EarlGrey.h> |
6 #import <UIKit/UIKit.h> | 6 #import <UIKit/UIKit.h> |
7 #import <XCTest/XCTest.h> | 7 #import <XCTest/XCTest.h> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } | 87 } |
88 // Matcher for the clear saved passwords cell on the clear browsing data panel. | 88 // Matcher for the clear saved passwords cell on the clear browsing data panel. |
89 id<GREYMatcher> ClearSavedPasswordsButton() { | 89 id<GREYMatcher> ClearSavedPasswordsButton() { |
90 return grey_allOf(grey_accessibilityID(kClearSavedPasswordsCellId), | 90 return grey_allOf(grey_accessibilityID(kClearSavedPasswordsCellId), |
91 grey_sufficientlyVisible(), nil); | 91 grey_sufficientlyVisible(), nil); |
92 } | 92 } |
93 // Matcher for the clear browsing data button on the clear browsing data panel. | 93 // Matcher for the clear browsing data button on the clear browsing data panel. |
94 id<GREYMatcher> ClearBrowsingDataButton() { | 94 id<GREYMatcher> ClearBrowsingDataButton() { |
95 return ButtonWithAccessibilityLabelId(IDS_IOS_CLEAR_BUTTON); | 95 return ButtonWithAccessibilityLabelId(IDS_IOS_CLEAR_BUTTON); |
96 } | 96 } |
| 97 // Matcher for the clear browsing data action sheet item. |
| 98 id<GREYMatcher> ConfirmClearBrowsingDataButton() { |
| 99 return ButtonWithAccessibilityLabelId(IDS_IOS_CONFIRM_CLEAR_BUTTON); |
| 100 } |
97 // Matcher for the Settings button in the tools menu. | 101 // Matcher for the Settings button in the tools menu. |
98 id<GREYMatcher> SettingsButton() { | 102 id<GREYMatcher> SettingsButton() { |
99 return grey_accessibilityID(kToolsMenuSettingsId); | 103 return grey_accessibilityID(kToolsMenuSettingsId); |
100 } | 104 } |
101 // Matcher for the Save Passwords cell on the main Settings screen. | 105 // Matcher for the Save Passwords cell on the main Settings screen. |
102 id<GREYMatcher> PasswordsButton() { | 106 id<GREYMatcher> PasswordsButton() { |
103 return ButtonWithAccessibilityLabelId(IDS_IOS_SAVE_PASSWORDS); | 107 return ButtonWithAccessibilityLabelId(IDS_IOS_SAVE_PASSWORDS); |
104 } | 108 } |
105 // Matcher for the Privacy cell on the main Settings screen. | 109 // Matcher for the Privacy cell on the main Settings screen. |
106 id<GREYMatcher> PrivacyButton() { | 110 id<GREYMatcher> PrivacyButton() { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] | 280 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] |
277 performAction:grey_tap()]; | 281 performAction:grey_tap()]; |
278 } | 282 } |
279 | 283 |
280 // Performs the steps to clear browsing data. Must be called on the | 284 // Performs the steps to clear browsing data. Must be called on the |
281 // Clear Browsing Data settings screen, after having selected the data types | 285 // Clear Browsing Data settings screen, after having selected the data types |
282 // scheduled for removal. | 286 // scheduled for removal. |
283 - (void)clearBrowsingData { | 287 - (void)clearBrowsingData { |
284 [[EarlGrey selectElementWithMatcher:ClearBrowsingDataButton()] | 288 [[EarlGrey selectElementWithMatcher:ClearBrowsingDataButton()] |
285 performAction:grey_tap()]; | 289 performAction:grey_tap()]; |
286 | 290 [[EarlGrey selectElementWithMatcher:ConfirmClearBrowsingDataButton()] |
287 // There is not currently a matcher for accessibilityElementIsFocused or | 291 performAction:grey_tap()]; |
288 // userInteractionEnabled which could be used here instead of checking that | |
289 // the button is not a MDCCollectionViewTextCell. Use when available. | |
290 // TODO(crbug.com/638674): Evaluate if this can move to shared code. | |
291 id<GREYMatcher> confirmClear = grey_allOf( | |
292 ClearBrowsingDataButton(), | |
293 grey_not(grey_kindOfClass([MDCCollectionViewTextCell class])), nil); | |
294 [[EarlGrey selectElementWithMatcher:confirmClear] performAction:grey_tap()]; | |
295 } | 292 } |
296 | 293 |
297 // Exits Settings by clicking on the Done button. | 294 // Exits Settings by clicking on the Done button. |
298 - (void)dismissSettings { | 295 - (void)dismissSettings { |
299 // Dismiss the settings. | 296 // Dismiss the settings. |
300 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] | 297 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] |
301 performAction:grey_tap()]; | 298 performAction:grey_tap()]; |
302 | 299 |
303 // Wait for UI components to finish loading. | 300 // Wait for UI components to finish loading. |
304 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 301 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 | 696 |
700 cookies = [ChromeEarlGrey cookies]; | 697 cookies = [ChromeEarlGrey cookies]; |
701 GREYAssertEqual(0U, cookies.count, @"No cookie should be found."); | 698 GREYAssertEqual(0U, cookies.count, @"No cookie should be found."); |
702 | 699 |
703 chrome_test_util::CloseAllTabs(); | 700 chrome_test_util::CloseAllTabs(); |
704 } | 701 } |
705 | 702 |
706 // Verifies that logging into a form on a web page allows the user to save and | 703 // Verifies that logging into a form on a web page allows the user to save and |
707 // then clear a password. | 704 // then clear a password. |
708 - (void)testClearPasswords { | 705 - (void)testClearPasswords { |
709 | |
710 ios::ChromeBrowserState* browserState = | 706 ios::ChromeBrowserState* browserState = |
711 chrome_test_util::GetOriginalBrowserState(); | 707 chrome_test_util::GetOriginalBrowserState(); |
712 PrefService* preferences = browserState->GetPrefs(); | 708 PrefService* preferences = browserState->GetPrefs(); |
713 bool defaultPasswordManagerSavingPref = preferences->GetBoolean( | 709 bool defaultPasswordManagerSavingPref = preferences->GetBoolean( |
714 password_manager::prefs::kPasswordManagerSavingEnabled); | 710 password_manager::prefs::kPasswordManagerSavingEnabled); |
715 | 711 |
716 [self enablePasswordManagement]; | 712 [self enablePasswordManagement]; |
717 [self setTearDownHandler:^{ | 713 [self setTearDownHandler:^{ |
718 [self passwordsTearDown:defaultPasswordManagerSavingPref]; | 714 [self passwordsTearDown:defaultPasswordManagerSavingPref]; |
719 }]; | 715 }]; |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 performAction:grey_tap()]; | 1034 performAction:grey_tap()]; |
1039 [[EarlGrey selectElementWithMatcher:PrivacyButton()] | 1035 [[EarlGrey selectElementWithMatcher:PrivacyButton()] |
1040 performAction:grey_tap()]; | 1036 performAction:grey_tap()]; |
1041 [[EarlGrey selectElementWithMatcher:SendUsageDataButton()] | 1037 [[EarlGrey selectElementWithMatcher:SendUsageDataButton()] |
1042 performAction:grey_tap()]; | 1038 performAction:grey_tap()]; |
1043 chrome_test_util::VerifyAccessibilityForCurrentScreen(); | 1039 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
1044 [self closeSubSettingsMenu]; | 1040 [self closeSubSettingsMenu]; |
1045 } | 1041 } |
1046 | 1042 |
1047 @end | 1043 @end |
OLD | NEW |