Commit 327dd59f authored by zhaoyangli's avatar zhaoyangli Committed by Commit Bot

[iOS][EG2]Fix SettingsMenuBackButton matcher in EG2.

Changed from matching UIButton with a11y label to using grey_buttonTitle
API. The new API matches UIButton with titleLabel underneath.

Bug: 1036578
Change-Id: I4db291d8279aba74d6eca3a53a16a8a70784d6f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2006260Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Zhaoyang Li <zhaoyangli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732699}
parent 870bcafd
......@@ -28,6 +28,7 @@
using chrome_test_util::ButtonWithAccessibilityLabel;
using chrome_test_util::ButtonWithAccessibilityLabelId;
using chrome_test_util::NavigationBarDoneButton;
using chrome_test_util::SettingsMenuBackButton;
using chrome_test_util::SettingsDoneButton;
namespace {
......@@ -61,17 +62,6 @@ id<GREYMatcher> BottomToolbar() {
return grey_accessibilityID(kAutofillPaymentMethodsToolbarId);
}
id<GREYMatcher> SettingsMenuBackButton(NSString* backItemTitle) {
#if defined(CHROME_EARL_GREY_2)
return grey_allOf(
grey_accessibilityLabel(backItemTitle),
grey_kindOfClassName(@"UIAccessibilityBackButtonElement"),
grey_ancestor(grey_accessibilityID(@"SettingNavigationBar")), nil);
#else
return chrome_test_util::SettingsMenuBackButton();
#endif
}
} // namespace
// Various tests for the Autofill credit cards section of the settings.
......@@ -125,9 +115,7 @@ id<GREYMatcher> SettingsMenuBackButton(NSString* backItemTitle) {
// Close the settings.
- (void)exitSettingsMenu {
[[EarlGrey
selectElementWithMatcher:SettingsMenuBackButton(l10n_util::GetNSString(
IDS_IOS_SETTINGS_TITLE))]
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()];
......@@ -152,9 +140,7 @@ id<GREYMatcher> SettingsMenuBackButton(NSString* backItemTitle) {
}
// Go back to the list view page.
[[EarlGrey
selectElementWithMatcher:SettingsMenuBackButton(l10n_util::GetNSString(
IDS_AUTOFILL_PAYMENT_METHODS))]
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
[self exitSettingsMenu];
......@@ -168,9 +154,7 @@ id<GREYMatcher> SettingsMenuBackButton(NSString* backItemTitle) {
[ChromeEarlGrey verifyAccessibilityForCurrentScreen];
// Go back to the list view page.
[[EarlGrey
selectElementWithMatcher:SettingsMenuBackButton(l10n_util::GetNSString(
IDS_AUTOFILL_PAYMENT_METHODS))]
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
[self exitSettingsMenu];
......@@ -187,9 +171,7 @@ id<GREYMatcher> SettingsMenuBackButton(NSString* backItemTitle) {
[ChromeEarlGrey verifyAccessibilityForCurrentScreen];
// Go back to the list view page.
[[EarlGrey
selectElementWithMatcher:SettingsMenuBackButton(l10n_util::GetNSString(
IDS_AUTOFILL_PAYMENT_METHODS))]
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
[self exitSettingsMenu];
......
......@@ -53,12 +53,10 @@ id<GREYMatcher> AddLanguageTableView() {
return grey_accessibilityID(kAddLanguageTableViewAccessibilityIdentifier);
}
#ifndef CHROME_EARL_GREY_2
// Matcher for the Language Settings's Language Details page table view.
id<GREYMatcher> LanguageDetailsTableView() {
return grey_accessibilityID(kLanguageDetailsTableViewAccessibilityIdentifier);
}
#endif
// Matcher for the Language Settings's general Settings menu entry.
id<GREYMatcher> LanguageSettingsButton() {
......@@ -180,9 +178,6 @@ id<GREYMatcher> NavigationBarEditButton() {
assertWithMatcher:grey_notNil()];
[ChromeEarlGrey verifyAccessibilityForCurrentScreen];
// TODO(crbug.com/1036578): Enable the second part of the test when back button
// matcher is fixed in EG2.
#ifndef CHROME_EARL_GREY_2
// Navigate back.
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()];
......@@ -196,7 +191,6 @@ id<GREYMatcher> NavigationBarEditButton() {
[[EarlGrey selectElementWithMatcher:LanguageDetailsTableView()]
assertWithMatcher:grey_notNil()];
[ChromeEarlGrey verifyAccessibilityForCurrentScreen];
#endif
}
// Tests that the Translate Switch enables/disables Translate and the UI gets
......
......@@ -546,9 +546,8 @@ UIView* SubviewWithAccessibilityIdentifier(NSString* accessibility_id,
SubviewWithAccessibilityIdentifier(
@"SettingNavigationBar",
[[UIApplication sharedApplication] keyWindow]));
return grey_allOf(grey_anyOf(grey_accessibilityLabel(navBar.backItem.title),
grey_accessibilityLabel(@"Back"), nil),
grey_kindOfClass([UIButton class]),
return grey_allOf(grey_anyOf(grey_buttonTitle(navBar.backItem.title),
grey_buttonTitle(@"Back"), nil),
grey_ancestor(grey_kindOfClass([UINavigationBar class])),
nil);
}
......
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