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 } | |
101 // Matcher for the Settings button in the tools menu. | 97 // Matcher for the Settings button in the tools menu. |
102 id<GREYMatcher> SettingsButton() { | 98 id<GREYMatcher> SettingsButton() { |
103 return grey_accessibilityID(kToolsMenuSettingsId); | 99 return grey_accessibilityID(kToolsMenuSettingsId); |
104 } | 100 } |
105 // Matcher for the Save Passwords cell on the main Settings screen. | 101 // Matcher for the Save Passwords cell on the main Settings screen. |
106 id<GREYMatcher> PasswordsButton() { | 102 id<GREYMatcher> PasswordsButton() { |
107 return ButtonWithAccessibilityLabelId(IDS_IOS_SAVE_PASSWORDS); | 103 return ButtonWithAccessibilityLabelId(IDS_IOS_SAVE_PASSWORDS); |
108 } | 104 } |
109 // Matcher for the Privacy cell on the main Settings screen. | 105 // Matcher for the Privacy cell on the main Settings screen. |
110 id<GREYMatcher> PrivacyButton() { | 106 id<GREYMatcher> PrivacyButton() { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] | 276 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] |
281 performAction:grey_tap()]; | 277 performAction:grey_tap()]; |
282 } | 278 } |
283 | 279 |
284 // Performs the steps to clear browsing data. Must be called on the | 280 // Performs the steps to clear browsing data. Must be called on the |
285 // Clear Browsing Data settings screen, after having selected the data types | 281 // Clear Browsing Data settings screen, after having selected the data types |
286 // scheduled for removal. | 282 // scheduled for removal. |
287 - (void)clearBrowsingData { | 283 - (void)clearBrowsingData { |
288 [[EarlGrey selectElementWithMatcher:ClearBrowsingDataButton()] | 284 [[EarlGrey selectElementWithMatcher:ClearBrowsingDataButton()] |
289 performAction:grey_tap()]; | 285 performAction:grey_tap()]; |
290 [[EarlGrey selectElementWithMatcher:ConfirmClearBrowsingDataButton()] | 286 |
291 performAction:grey_tap()]; | 287 // There is not currently a matcher for accessibilityElementIsFocused or |
| 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()]; |
292 } | 295 } |
293 | 296 |
294 // Exits Settings by clicking on the Done button. | 297 // Exits Settings by clicking on the Done button. |
295 - (void)dismissSettings { | 298 - (void)dismissSettings { |
296 // Dismiss the settings. | 299 // Dismiss the settings. |
297 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] | 300 [[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()] |
298 performAction:grey_tap()]; | 301 performAction:grey_tap()]; |
299 | 302 |
300 // Wait for UI components to finish loading. | 303 // Wait for UI components to finish loading. |
301 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; | 304 [[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 | 699 |
697 cookies = [ChromeEarlGrey cookies]; | 700 cookies = [ChromeEarlGrey cookies]; |
698 GREYAssertEqual(0U, cookies.count, @"No cookie should be found."); | 701 GREYAssertEqual(0U, cookies.count, @"No cookie should be found."); |
699 | 702 |
700 chrome_test_util::CloseAllTabs(); | 703 chrome_test_util::CloseAllTabs(); |
701 } | 704 } |
702 | 705 |
703 // Verifies that logging into a form on a web page allows the user to save and | 706 // Verifies that logging into a form on a web page allows the user to save and |
704 // then clear a password. | 707 // then clear a password. |
705 - (void)testClearPasswords { | 708 - (void)testClearPasswords { |
| 709 |
706 ios::ChromeBrowserState* browserState = | 710 ios::ChromeBrowserState* browserState = |
707 chrome_test_util::GetOriginalBrowserState(); | 711 chrome_test_util::GetOriginalBrowserState(); |
708 PrefService* preferences = browserState->GetPrefs(); | 712 PrefService* preferences = browserState->GetPrefs(); |
709 bool defaultPasswordManagerSavingPref = preferences->GetBoolean( | 713 bool defaultPasswordManagerSavingPref = preferences->GetBoolean( |
710 password_manager::prefs::kPasswordManagerSavingEnabled); | 714 password_manager::prefs::kPasswordManagerSavingEnabled); |
711 | 715 |
712 [self enablePasswordManagement]; | 716 [self enablePasswordManagement]; |
713 [self setTearDownHandler:^{ | 717 [self setTearDownHandler:^{ |
714 [self passwordsTearDown:defaultPasswordManagerSavingPref]; | 718 [self passwordsTearDown:defaultPasswordManagerSavingPref]; |
715 }]; | 719 }]; |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 performAction:grey_tap()]; | 1038 performAction:grey_tap()]; |
1035 [[EarlGrey selectElementWithMatcher:PrivacyButton()] | 1039 [[EarlGrey selectElementWithMatcher:PrivacyButton()] |
1036 performAction:grey_tap()]; | 1040 performAction:grey_tap()]; |
1037 [[EarlGrey selectElementWithMatcher:SendUsageDataButton()] | 1041 [[EarlGrey selectElementWithMatcher:SendUsageDataButton()] |
1038 performAction:grey_tap()]; | 1042 performAction:grey_tap()]; |
1039 chrome_test_util::VerifyAccessibilityForCurrentScreen(); | 1043 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
1040 [self closeSubSettingsMenu]; | 1044 [self closeSubSettingsMenu]; |
1041 } | 1045 } |
1042 | 1046 |
1043 @end | 1047 @end |
OLD | NEW |