| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 id<GREYMatcher> googleChromeButton() { | 138 id<GREYMatcher> googleChromeButton() { |
| 139 return buttonWithAccessibilityLabelId(IDS_IOS_PRODUCT_NAME); | 139 return buttonWithAccessibilityLabelId(IDS_IOS_PRODUCT_NAME); |
| 140 } | 140 } |
| 141 | 141 |
| 142 // Matcher for the Google Chrome cell on the main Settings screen. | 142 // Matcher for the Google Chrome cell on the main Settings screen. |
| 143 id<GREYMatcher> voiceSearchButton() { | 143 id<GREYMatcher> voiceSearchButton() { |
| 144 return grey_allOf(grey_accessibilityID(kSettingsVoiceSearchCellId), | 144 return grey_allOf(grey_accessibilityID(kSettingsVoiceSearchCellId), |
| 145 grey_accessibilityTrait(UIAccessibilityTraitButton), nil); | 145 grey_accessibilityTrait(UIAccessibilityTraitButton), nil); |
| 146 } | 146 } |
| 147 | 147 |
| 148 // Matcher for the Preload Webpages button on the bandwidth UI. |
| 149 id<GREYMatcher> BandwidthPreloadWebpagesButton() { |
| 150 return buttonWithAccessibilityLabelId(IDS_IOS_OPTIONS_PRELOAD_WEBPAGES); |
| 151 } |
| 152 |
| 153 // Matcher for the Privacy Handoff button on the privacy UI. |
| 154 id<GREYMatcher> PrivacyHandoffButton() { |
| 155 return buttonWithAccessibilityLabelId( |
| 156 IDS_IOS_OPTIONS_ENABLE_HANDOFF_TO_OTHER_DEVICES); |
| 157 } |
| 158 |
| 159 // Matcher for the Privacy Block Popups button on the privacy UI. |
| 160 id<GREYMatcher> BlockPopupsButton() { |
| 161 return buttonWithAccessibilityLabelId(IDS_IOS_BLOCK_POPUPS); |
| 162 } |
| 163 |
| 164 // Matcher for the Privacy Translate Settings button on the privacy UI. |
| 165 id<GREYMatcher> TranslateSettingsButton() { |
| 166 return buttonWithAccessibilityLabelId(IDS_IOS_TRANSLATE_SETTING); |
| 167 } |
| 168 |
| 148 // Asserts that there is no cookie in current web state. | 169 // Asserts that there is no cookie in current web state. |
| 149 void AssertNoCookieExists() { | 170 void AssertNoCookieExists() { |
| 150 NSError* error = nil; | 171 NSError* error = nil; |
| 151 chrome_test_util::ExecuteJavaScript( | 172 chrome_test_util::ExecuteJavaScript( |
| 152 base::SysUTF8ToNSString(kJavaScriptGetCookies), &error); | 173 base::SysUTF8ToNSString(kJavaScriptGetCookies), &error); |
| 153 [[EarlGrey selectElementWithMatcher:chrome_test_util::webViewContainingText( | 174 [[EarlGrey selectElementWithMatcher:chrome_test_util::webViewContainingText( |
| 154 kNoCookieText)] | 175 kNoCookieText)] |
| 155 assertWithMatcher:grey_notNil()]; | 176 assertWithMatcher:grey_notNil()]; |
| 156 } | 177 } |
| 157 | 178 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 266 |
| 246 } // namespace | 267 } // namespace |
| 247 | 268 |
| 248 // Settings tests for Chrome. | 269 // Settings tests for Chrome. |
| 249 @interface SettingsTestCase : ChromeTestCase | 270 @interface SettingsTestCase : ChromeTestCase |
| 250 @end | 271 @end |
| 251 | 272 |
| 252 @implementation SettingsTestCase | 273 @implementation SettingsTestCase |
| 253 | 274 |
| 254 // Opens the a submenu from the settings page. Must be called from the NTP. | 275 // Opens the a submenu from the settings page. Must be called from the NTP. |
| 276 // TODO(crbug.com/684619): Investigate why usingSearchAction doesn't scroll |
| 277 // until the bottom. |
| 255 - (void)openSubSettingMenu:(id<GREYMatcher>)settingToTap { | 278 - (void)openSubSettingMenu:(id<GREYMatcher>)settingToTap { |
| 256 const CGFloat kScrollDisplacement = 150.0; | 279 const CGFloat kScrollDisplacement = 150.0; |
| 257 id<GREYMatcher> toolsMenuTableViewMatcher = | 280 id<GREYMatcher> toolsMenuTableViewMatcher = |
| 258 grey_accessibilityID(kToolsMenuTableViewId); | 281 grey_accessibilityID(kToolsMenuTableViewId); |
| 259 id<GREYMatcher> settingsButtonMatcher = | 282 id<GREYMatcher> settingsButtonMatcher = |
| 260 grey_accessibilityID(kToolsMenuSettingsId); | 283 grey_accessibilityID(kToolsMenuSettingsId); |
| 261 id<GREYMatcher> settingsCollectionViewMatcher = | 284 id<GREYMatcher> settingsCollectionViewMatcher = |
| 262 grey_accessibilityID(kSettingsCollectionViewId); | 285 grey_accessibilityID(kSettingsCollectionViewId); |
| 263 | 286 |
| 264 [ChromeEarlGreyUI openToolsMenu]; | 287 [ChromeEarlGreyUI openToolsMenu]; |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 performAction:grey_tap()]; | 786 performAction:grey_tap()]; |
| 764 [[EarlGrey | 787 [[EarlGrey |
| 765 selectElementWithMatcher:grey_accessibilityID(kSettingsCollectionViewId)] | 788 selectElementWithMatcher:grey_accessibilityID(kSettingsCollectionViewId)] |
| 766 assertWithMatcher:grey_notNil()]; | 789 assertWithMatcher:grey_notNil()]; |
| 767 | 790 |
| 768 [[EarlGrey selectElementWithMatcher:navigationDoneButton()] | 791 [[EarlGrey selectElementWithMatcher:navigationDoneButton()] |
| 769 performAction:grey_tap()]; | 792 performAction:grey_tap()]; |
| 770 chrome_test_util::CloseAllIncognitoTabs(); | 793 chrome_test_util::CloseAllIncognitoTabs(); |
| 771 } | 794 } |
| 772 | 795 |
| 773 // Verifies the UI elements are accessibile on the Settings page. | 796 // Verifies the UI elements are accessible on the Settings page. |
| 774 - (void)testAccessibilityOnSettingsPage { | 797 - (void)testAccessibilityOnSettingsPage { |
| 775 [ChromeEarlGreyUI openToolsMenu]; | 798 [ChromeEarlGreyUI openToolsMenu]; |
| 776 [[EarlGrey selectElementWithMatcher:settingsButton()] | 799 [[EarlGrey selectElementWithMatcher:settingsButton()] |
| 777 performAction:grey_tap()]; | 800 performAction:grey_tap()]; |
| 778 chrome_test_util::VerifyAccessibilityForCurrentScreen(); | 801 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 779 [[EarlGrey | 802 [[EarlGrey |
| 780 selectElementWithMatcher:chrome_test_util::buttonWithAccessibilityLabelId( | 803 selectElementWithMatcher:chrome_test_util::buttonWithAccessibilityLabelId( |
| 781 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)] | 804 IDS_IOS_NAVIGATION_BAR_DONE_BUTTON)] |
| 782 performAction:grey_tap()]; | 805 performAction:grey_tap()]; |
| 783 } | 806 } |
| 784 | 807 |
| 785 // Verifies the UI elements are accessibile on the Content Settings page. | 808 // Verifies the UI elements are accessible on the Content Settings page. |
| 786 - (void)testAccessibilityOnContentSettingsPage { | 809 - (void)testAccessibilityOnContentSettingsPage { |
| 787 [self openSubSettingMenu:chrome_test_util::buttonWithAccessibilityLabelId( | 810 [self openSubSettingMenu:chrome_test_util::buttonWithAccessibilityLabelId( |
| 788 IDS_IOS_CONTENT_SETTINGS_TITLE)]; | 811 IDS_IOS_CONTENT_SETTINGS_TITLE)]; |
| 789 chrome_test_util::VerifyAccessibilityForCurrentScreen(); | 812 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 790 [self closeSubSettingsMenu]; | 813 [self closeSubSettingsMenu]; |
| 791 } | 814 } |
| 792 | 815 |
| 793 // Verifies the UI elements are accessibile on the Privacy Settings page. | 816 // Verifies the UI elements are accessible on the Content Settings |
| 817 // Block Popups page. |
| 818 - (void)testAccessibilityOnContentSettingsBlockPopupsPage { |
| 819 [self openSubSettingMenu:chrome_test_util::buttonWithAccessibilityLabelId( |
| 820 IDS_IOS_CONTENT_SETTINGS_TITLE)]; |
| 821 [[EarlGrey selectElementWithMatcher:BlockPopupsButton()] |
| 822 performAction:grey_tap()]; |
| 823 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 824 [self closeSubSettingsMenu]; |
| 825 } |
| 826 |
| 827 // Verifies the UI elements are accessible on the Content Translations Settings |
| 828 // page. |
| 829 - (void)testAccessibilityOnContentSettingsTranslatePage { |
| 830 [self openSubSettingMenu:chrome_test_util::buttonWithAccessibilityLabelId( |
| 831 IDS_IOS_CONTENT_SETTINGS_TITLE)]; |
| 832 [[EarlGrey selectElementWithMatcher:TranslateSettingsButton()] |
| 833 performAction:grey_tap()]; |
| 834 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 835 [self closeSubSettingsMenu]; |
| 836 } |
| 837 |
| 838 // Verifies the UI elements are accessible on the Privacy Settings page. |
| 794 - (void)testAccessibilityOnPrivacySettingsPage { | 839 - (void)testAccessibilityOnPrivacySettingsPage { |
| 795 [self openSubSettingMenu:chrome_test_util::buttonWithAccessibilityLabelId( | 840 [self openSubSettingMenu:chrome_test_util::buttonWithAccessibilityLabelId( |
| 796 IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY)]; | 841 IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY)]; |
| 797 chrome_test_util::VerifyAccessibilityForCurrentScreen(); | 842 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 798 [self closeSubSettingsMenu]; | 843 [self closeSubSettingsMenu]; |
| 799 } | 844 } |
| 800 | 845 |
| 801 // Verifies the UI elements are accessibile on the Bandwidth Management Settings | 846 // Verifies the UI elements are accessible on the Privacy Handoff Settings |
| 847 // page. |
| 848 - (void)testAccessibilityOnPrivacyHandoffSettingsPage { |
| 849 [self openSubSettingMenu:chrome_test_util::buttonWithAccessibilityLabelId( |
| 850 IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY)]; |
| 851 [[EarlGrey selectElementWithMatcher:PrivacyHandoffButton()] |
| 852 performAction:grey_tap()]; |
| 853 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 854 [self closeSubSettingsMenu]; |
| 855 } |
| 856 |
| 857 // Verifies the UI elements are accessible on the Privacy Clear Browsing Data |
| 858 // Settings page. |
| 859 - (void)testAccessibilityOnPrivacyClearBrowsingHistoryPage { |
| 860 [self openSubSettingMenu:chrome_test_util::buttonWithAccessibilityLabelId( |
| 861 IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY)]; |
| 862 [[EarlGrey selectElementWithMatcher:clearBrowsingDataButton()] |
| 863 performAction:grey_tap()]; |
| 864 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 865 [self closeSubSettingsMenu]; |
| 866 } |
| 867 |
| 868 // Verifies the UI elements are accessible on the Bandwidth Management Settings |
| 802 // page. | 869 // page. |
| 803 - (void)testAccessibilityOnBandwidthManagementSettingsPage { | 870 - (void)testAccessibilityOnBandwidthManagementSettingsPage { |
| 804 [self openSubSettingMenu:chrome_test_util::buttonWithAccessibilityLabelId( | 871 [self openSubSettingMenu:chrome_test_util::buttonWithAccessibilityLabelId( |
| 805 IDS_IOS_BANDWIDTH_MANAGEMENT_SETTINGS)]; | 872 IDS_IOS_BANDWIDTH_MANAGEMENT_SETTINGS)]; |
| 806 chrome_test_util::VerifyAccessibilityForCurrentScreen(); | 873 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 807 [self closeSubSettingsMenu]; | 874 [self closeSubSettingsMenu]; |
| 808 } | 875 } |
| 809 | 876 |
| 877 // Verifies the UI elements are accessible on the Bandwidth Preload Webpages |
| 878 // Settings page. |
| 879 - (void)testAccessibilityOnBandwidthPreloadWebpagesSettingsPage { |
| 880 [self openSubSettingMenu:chrome_test_util::buttonWithAccessibilityLabelId( |
| 881 IDS_IOS_BANDWIDTH_MANAGEMENT_SETTINGS)]; |
| 882 [[EarlGrey selectElementWithMatcher:BandwidthPreloadWebpagesButton()] |
| 883 performAction:grey_tap()]; |
| 884 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 885 [self closeSubSettingsMenu]; |
| 886 } |
| 887 |
| 810 // Verifies the UI elements are accessible on the Save Passwords page. | 888 // Verifies the UI elements are accessible on the Save Passwords page. |
| 811 - (void)testAccessibilityOnSavePasswords { | 889 - (void)testAccessibilityOnSavePasswords { |
| 812 [ChromeEarlGreyUI openToolsMenu]; | 890 [ChromeEarlGreyUI openToolsMenu]; |
| 813 [[EarlGrey selectElementWithMatcher:settingsButton()] | 891 [[EarlGrey selectElementWithMatcher:settingsButton()] |
| 814 performAction:grey_tap()]; | 892 performAction:grey_tap()]; |
| 815 [[EarlGrey selectElementWithMatcher:passwordsButton()] | 893 [[EarlGrey selectElementWithMatcher:passwordsButton()] |
| 816 performAction:grey_tap()]; | 894 performAction:grey_tap()]; |
| 817 chrome_test_util::VerifyAccessibilityForCurrentScreen(); | 895 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 818 [self closeSubSettingsMenu]; | 896 [self closeSubSettingsMenu]; |
| 819 } | 897 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 [ChromeEarlGreyUI openToolsMenu]; | 948 [ChromeEarlGreyUI openToolsMenu]; |
| 871 [[EarlGrey selectElementWithMatcher:settingsButton()] | 949 [[EarlGrey selectElementWithMatcher:settingsButton()] |
| 872 performAction:grey_tap()]; | 950 performAction:grey_tap()]; |
| 873 [[EarlGrey selectElementWithMatcher:passwordsButton()] | 951 [[EarlGrey selectElementWithMatcher:passwordsButton()] |
| 874 performAction:grey_tap()]; | 952 performAction:grey_tap()]; |
| 875 chrome_test_util::VerifyAccessibilityForCurrentScreen(); | 953 chrome_test_util::VerifyAccessibilityForCurrentScreen(); |
| 876 [self closeSubSettingsMenu]; | 954 [self closeSubSettingsMenu]; |
| 877 } | 955 } |
| 878 | 956 |
| 879 @end | 957 @end |
| OLD | NEW |