Commit 055a634e authored by Yuke Liao's avatar Yuke Liao Committed by Commit Bot

Create EarlGrey matcher for settings menu privacy button

IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY is used in multiple tests,
so this CL creates a matcher in chrome_matchers.h.

Bug: 738363
Change-Id: If0ab68ce67397aa0a0819055fa147aef8f046984
Reviewed-on: https://chromium-review.googlesource.com/563473Reviewed-by: default avatarLouis Romero <lpromero@chromium.org>
Reviewed-by: default avatarMike Baxley <baxley@chromium.org>
Commit-Queue: Louis Romero <lpromero@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485389}
parent b5fa16cc
......@@ -43,6 +43,7 @@
using chrome_test_util::OpenLinkInNewTabButton;
using chrome_test_util::SettingsMenuButton;
using chrome_test_util::SettingsMenuPrivacyButton;
using tab_usage_recorder_test_util::OpenNewIncognitoTabUsingUIAndEvictMainTabs;
using tab_usage_recorder_test_util::SwitchToNormalMode;
......@@ -131,16 +132,6 @@ void CloseTabAtIndexAndSync(NSUInteger i) {
@"Waiting for tab to close");
}
// Open the settings submenu. Assumes that settings menu is visible.
void OpenSettingsSubMenuUnsynced(int submenu) {
id<GREYMatcher> settings_button_matcher =
grey_text(l10n_util::GetNSString(submenu));
[[[EarlGrey selectElementWithMatcher:settings_button_matcher]
usingSearchAction:grey_swipeSlowInDirection(kGREYDirectionUp)
onElementWithMatcher:grey_accessibilityID(kSettingsCollectionViewId)]
performAction:grey_tap()];
}
// Open the settings menu. Wait for the settings menu to appear.
void OpenSettingsMenuUnsynced() {
id<GREYMatcher> tool_menu_matcher =
......@@ -514,7 +505,7 @@ void SelectTabUsingUI(NSString* title) {
setValue:@(NO)
forConfigKey:kGREYConfigKeySynchronizationEnabled];
OpenSettingsMenuUnsynced();
OpenSettingsSubMenuUnsynced(IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY);
[ChromeEarlGreyUI tapSettingsMenuButton:SettingsMenuPrivacyButton()];
Wait(grey_accessibilityID(kPrivacyCollectionViewId),
@"Privacy settings view.");
......
......@@ -20,6 +20,7 @@
using chrome_test_util::ButtonWithAccessibilityLabel;
using chrome_test_util::ButtonWithAccessibilityLabelId;
using chrome_test_util::NavigationBarDoneButton;
using chrome_test_util::SettingsMenuPrivacyButton;
@interface ClearBrowsingDataSettingsTestCase : ChromeTestCase
@end
......@@ -28,11 +29,7 @@ using chrome_test_util::NavigationBarDoneButton;
- (void)openClearBrowsingDataDialog {
[ChromeEarlGreyUI openSettingsMenu];
NSString* settingsLabel =
l10n_util::GetNSString(IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY);
[[EarlGrey
selectElementWithMatcher:ButtonWithAccessibilityLabel(settingsLabel)]
performAction:grey_tap()];
[ChromeEarlGreyUI tapSettingsMenuButton:SettingsMenuPrivacyButton()];
NSString* clearBrowsingDataDialogLabel =
l10n_util::GetNSString(IDS_IOS_CLEAR_BROWSING_DATA_TITLE);
......
......@@ -61,6 +61,7 @@ using chrome_test_util::ClearBrowsingDataCollectionView;
using chrome_test_util::ContentSettingsButton;
using chrome_test_util::NavigationBarDoneButton;
using chrome_test_util::SettingsMenuBackButton;
using chrome_test_util::SettingsMenuPrivacyButton;
namespace {
......@@ -110,11 +111,6 @@ id<GREYMatcher> ConfirmClearBrowsingDataButton() {
id<GREYMatcher> PasswordsButton() {
return ButtonWithAccessibilityLabelId(IDS_IOS_SAVE_PASSWORDS);
}
// Matcher for the Privacy cell on the main Settings screen.
id<GREYMatcher> PrivacyButton() {
return ButtonWithAccessibilityLabelId(
IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY);
}
// Matcher for the Send Usage Data cell on the Privacy screen.
id<GREYMatcher> SendUsageDataButton() {
return ButtonWithAccessibilityLabelId(IDS_IOS_OPTIONS_SEND_USAGE_DATA);
......@@ -307,7 +303,7 @@ bool IsCertificateCleared() {
// From the NTP, clears the cookies and site data via the UI.
- (void)clearCookiesAndSiteData {
[ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI tapSettingsMenuButton:PrivacyButton()];
[ChromeEarlGreyUI tapSettingsMenuButton:SettingsMenuPrivacyButton()];
[ChromeEarlGreyUI tapPrivacyMenuButton:ClearBrowsingDataCell()];
// "Browsing history", "Cookies, Site Data" and "Cached Images and Files"
......@@ -326,7 +322,7 @@ bool IsCertificateCleared() {
// From the NTP, clears the saved passwords via the UI.
- (void)clearPasswords {
[ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI tapSettingsMenuButton:PrivacyButton()];
[ChromeEarlGreyUI tapSettingsMenuButton:SettingsMenuPrivacyButton()];
[ChromeEarlGreyUI tapPrivacyMenuButton:ClearBrowsingDataCell()];
// "Browsing history", "Cookies, Site Data" and "Cached Images and Files"
......@@ -817,7 +813,7 @@ bool IsCertificateCleared() {
// Verifies the UI elements are accessible on the Privacy Settings page.
- (void)testAccessibilityOnPrivacySettingsPage {
[ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI tapSettingsMenuButton:PrivacyButton()];
[ChromeEarlGreyUI tapSettingsMenuButton:SettingsMenuPrivacyButton()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
[self closeSubSettingsMenu];
}
......@@ -826,7 +822,7 @@ bool IsCertificateCleared() {
// page.
- (void)testAccessibilityOnPrivacyHandoffSettingsPage {
[ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI tapSettingsMenuButton:PrivacyButton()];
[ChromeEarlGreyUI tapSettingsMenuButton:SettingsMenuPrivacyButton()];
[[EarlGrey selectElementWithMatcher:PrivacyHandoffButton()]
performAction:grey_tap()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
......@@ -837,7 +833,7 @@ bool IsCertificateCleared() {
// Settings page.
- (void)testAccessibilityOnPrivacyClearBrowsingHistoryPage {
[ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI tapSettingsMenuButton:PrivacyButton()];
[ChromeEarlGreyUI tapSettingsMenuButton:SettingsMenuPrivacyButton()];
[ChromeEarlGreyUI tapPrivacyMenuButton:ClearBrowsingDataButton()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
[self closeSubSettingsMenu];
......@@ -985,7 +981,7 @@ bool IsCertificateCleared() {
// Verifies the UI elements are accessible on the Send Usage Data page.
- (void)testAccessibilityOnSendUsageData {
[ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI tapSettingsMenuButton:PrivacyButton()];
[ChromeEarlGreyUI tapSettingsMenuButton:SettingsMenuPrivacyButton()];
[ChromeEarlGreyUI tapPrivacyMenuButton:SendUsageDataButton()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
[self closeSubSettingsMenu];
......
......@@ -120,6 +120,9 @@ id<GREYMatcher> ContentSettingsButton();
// Returns matcher for the back button on a settings menu.
id<GREYMatcher> SettingsMenuBackButton();
// Returns matcher for the Privacy cell on the main Settings screen.
id<GREYMatcher> SettingsMenuPrivacyButton();
} // namespace chrome_test_util
#endif // IOS_CHROME_TEST_EARL_GREY_CHROME_MATCHERS_H_
......@@ -214,4 +214,9 @@ id<GREYMatcher> SettingsMenuBackButton() {
grey_accessibilityTrait(UIAccessibilityTraitButton), nil);
}
id<GREYMatcher> SettingsMenuPrivacyButton() {
return ButtonWithAccessibilityLabelId(
IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY);
}
} // namespace chrome_test_util
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment