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 @@ ...@@ -28,6 +28,7 @@
using chrome_test_util::ButtonWithAccessibilityLabel; using chrome_test_util::ButtonWithAccessibilityLabel;
using chrome_test_util::ButtonWithAccessibilityLabelId; using chrome_test_util::ButtonWithAccessibilityLabelId;
using chrome_test_util::NavigationBarDoneButton; using chrome_test_util::NavigationBarDoneButton;
using chrome_test_util::SettingsMenuBackButton;
using chrome_test_util::SettingsDoneButton; using chrome_test_util::SettingsDoneButton;
namespace { namespace {
...@@ -61,17 +62,6 @@ id<GREYMatcher> BottomToolbar() { ...@@ -61,17 +62,6 @@ id<GREYMatcher> BottomToolbar() {
return grey_accessibilityID(kAutofillPaymentMethodsToolbarId); 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 } // namespace
// Various tests for the Autofill credit cards section of the settings. // Various tests for the Autofill credit cards section of the settings.
...@@ -125,9 +115,7 @@ id<GREYMatcher> SettingsMenuBackButton(NSString* backItemTitle) { ...@@ -125,9 +115,7 @@ id<GREYMatcher> SettingsMenuBackButton(NSString* backItemTitle) {
// Close the settings. // Close the settings.
- (void)exitSettingsMenu { - (void)exitSettingsMenu {
[[EarlGrey [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
selectElementWithMatcher:SettingsMenuBackButton(l10n_util::GetNSString(
IDS_IOS_SETTINGS_TITLE))]
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()] [[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -152,9 +140,7 @@ id<GREYMatcher> SettingsMenuBackButton(NSString* backItemTitle) { ...@@ -152,9 +140,7 @@ id<GREYMatcher> SettingsMenuBackButton(NSString* backItemTitle) {
} }
// Go back to the list view page. // Go back to the list view page.
[[EarlGrey [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
selectElementWithMatcher:SettingsMenuBackButton(l10n_util::GetNSString(
IDS_AUTOFILL_PAYMENT_METHODS))]
performAction:grey_tap()]; performAction:grey_tap()];
[self exitSettingsMenu]; [self exitSettingsMenu];
...@@ -168,9 +154,7 @@ id<GREYMatcher> SettingsMenuBackButton(NSString* backItemTitle) { ...@@ -168,9 +154,7 @@ id<GREYMatcher> SettingsMenuBackButton(NSString* backItemTitle) {
[ChromeEarlGrey verifyAccessibilityForCurrentScreen]; [ChromeEarlGrey verifyAccessibilityForCurrentScreen];
// Go back to the list view page. // Go back to the list view page.
[[EarlGrey [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
selectElementWithMatcher:SettingsMenuBackButton(l10n_util::GetNSString(
IDS_AUTOFILL_PAYMENT_METHODS))]
performAction:grey_tap()]; performAction:grey_tap()];
[self exitSettingsMenu]; [self exitSettingsMenu];
...@@ -187,9 +171,7 @@ id<GREYMatcher> SettingsMenuBackButton(NSString* backItemTitle) { ...@@ -187,9 +171,7 @@ id<GREYMatcher> SettingsMenuBackButton(NSString* backItemTitle) {
[ChromeEarlGrey verifyAccessibilityForCurrentScreen]; [ChromeEarlGrey verifyAccessibilityForCurrentScreen];
// Go back to the list view page. // Go back to the list view page.
[[EarlGrey [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
selectElementWithMatcher:SettingsMenuBackButton(l10n_util::GetNSString(
IDS_AUTOFILL_PAYMENT_METHODS))]
performAction:grey_tap()]; performAction:grey_tap()];
[self exitSettingsMenu]; [self exitSettingsMenu];
......
...@@ -53,12 +53,10 @@ id<GREYMatcher> AddLanguageTableView() { ...@@ -53,12 +53,10 @@ id<GREYMatcher> AddLanguageTableView() {
return grey_accessibilityID(kAddLanguageTableViewAccessibilityIdentifier); return grey_accessibilityID(kAddLanguageTableViewAccessibilityIdentifier);
} }
#ifndef CHROME_EARL_GREY_2
// Matcher for the Language Settings's Language Details page table view. // Matcher for the Language Settings's Language Details page table view.
id<GREYMatcher> LanguageDetailsTableView() { id<GREYMatcher> LanguageDetailsTableView() {
return grey_accessibilityID(kLanguageDetailsTableViewAccessibilityIdentifier); return grey_accessibilityID(kLanguageDetailsTableViewAccessibilityIdentifier);
} }
#endif
// Matcher for the Language Settings's general Settings menu entry. // Matcher for the Language Settings's general Settings menu entry.
id<GREYMatcher> LanguageSettingsButton() { id<GREYMatcher> LanguageSettingsButton() {
...@@ -180,9 +178,6 @@ id<GREYMatcher> NavigationBarEditButton() { ...@@ -180,9 +178,6 @@ id<GREYMatcher> NavigationBarEditButton() {
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
[ChromeEarlGrey verifyAccessibilityForCurrentScreen]; [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. // Navigate back.
[[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()] [[EarlGrey selectElementWithMatcher:SettingsMenuBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -196,7 +191,6 @@ id<GREYMatcher> NavigationBarEditButton() { ...@@ -196,7 +191,6 @@ id<GREYMatcher> NavigationBarEditButton() {
[[EarlGrey selectElementWithMatcher:LanguageDetailsTableView()] [[EarlGrey selectElementWithMatcher:LanguageDetailsTableView()]
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
[ChromeEarlGrey verifyAccessibilityForCurrentScreen]; [ChromeEarlGrey verifyAccessibilityForCurrentScreen];
#endif
} }
// Tests that the Translate Switch enables/disables Translate and the UI gets // Tests that the Translate Switch enables/disables Translate and the UI gets
......
...@@ -546,9 +546,8 @@ UIView* SubviewWithAccessibilityIdentifier(NSString* accessibility_id, ...@@ -546,9 +546,8 @@ UIView* SubviewWithAccessibilityIdentifier(NSString* accessibility_id,
SubviewWithAccessibilityIdentifier( SubviewWithAccessibilityIdentifier(
@"SettingNavigationBar", @"SettingNavigationBar",
[[UIApplication sharedApplication] keyWindow])); [[UIApplication sharedApplication] keyWindow]));
return grey_allOf(grey_anyOf(grey_accessibilityLabel(navBar.backItem.title), return grey_allOf(grey_anyOf(grey_buttonTitle(navBar.backItem.title),
grey_accessibilityLabel(@"Back"), nil), grey_buttonTitle(@"Back"), nil),
grey_kindOfClass([UIButton class]),
grey_ancestor(grey_kindOfClass([UINavigationBar class])), grey_ancestor(grey_kindOfClass([UINavigationBar class])),
nil); 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