Commit c51b5582 authored by Rohit Rao's avatar Rohit Rao Committed by Commit Bot

[ios] Search for abbreviated Back button labels in Bookmarks.

When the previous view controller's title is too long, iOS may choose to
label the navigation bar's back button with either the word "Back" or to
omit the label entirely. Have EG tests search for the back button using
all three potential labels.

BUG=863476

Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ic7cae966be78e63b4a26f0e2d2a1f708b43a46d0
Reviewed-on: https://chromium-review.googlesource.com/1148466
Commit-Queue: Rohit Rao <rohitrao@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577649}
parent dff51569
...@@ -108,14 +108,24 @@ id<GREYMatcher> BookmarksDeleteSwipeButton() { ...@@ -108,14 +108,24 @@ id<GREYMatcher> BookmarksDeleteSwipeButton() {
// UI. // UI.
id<GREYMatcher> NavigateBackButtonTo(NSString* previousViewControllerLabel) { id<GREYMatcher> NavigateBackButtonTo(NSString* previousViewControllerLabel) {
if (experimental_flags::IsBookmarksUIRebootEnabled()) { if (experimental_flags::IsBookmarksUIRebootEnabled()) {
// When using the stock UINavigationBar back button item, the button's label
// may be truncated to the word "Back", or to nothing at all. It is not
// possible to know which label will be used, as the OS makes that decision,
// so try to search for any of them.
id<GREYMatcher> buttonLabelMatcher =
grey_anyOf(grey_accessibilityLabel(previousViewControllerLabel),
grey_accessibilityLabel(@"Back"), nil);
if (@available(iOS 11, *)) { if (@available(iOS 11, *)) {
return grey_allOf(grey_kindOfClass([UIButton class]), return grey_allOf(
grey_accessibilityLabel(previousViewControllerLabel), grey_kindOfClass([UIButton class]),
nil); grey_ancestor(grey_kindOfClass([UINavigationBar class])),
buttonLabelMatcher, nil);
} else { } else {
return grey_allOf(grey_accessibilityTrait(UIAccessibilityTraitButton), return grey_allOf(
grey_accessibilityLabel(previousViewControllerLabel), grey_accessibilityTrait(UIAccessibilityTraitButton),
nil); grey_ancestor(grey_kindOfClass([UINavigationBar class])),
buttonLabelMatcher, nil);
} }
} else { } else {
return grey_allOf(grey_accessibilityLabel(l10n_util::GetNSString( return grey_allOf(grey_accessibilityLabel(l10n_util::GetNSString(
...@@ -178,13 +188,6 @@ id<GREYMatcher> TappableBookmarkNodeWithLabel(NSString* label) { ...@@ -178,13 +188,6 @@ id<GREYMatcher> TappableBookmarkNodeWithLabel(NSString* label) {
@implementation BookmarksTestCase @implementation BookmarksTestCase
// TODO(crbug.com/863476): Temporarily disable bookmarks on iOS12.
+ (NSArray*)testInvocations {
if (base::ios::IsRunningOnIOS12OrLater())
return @[];
return [super testInvocations];
}
- (void)setUp { - (void)setUp {
[super setUp]; [super setUp];
...@@ -1764,13 +1767,6 @@ id<GREYMatcher> TappableBookmarkNodeWithLabel(NSString* label) { ...@@ -1764,13 +1767,6 @@ id<GREYMatcher> TappableBookmarkNodeWithLabel(NSString* label) {
@implementation BookmarksTestCaseEntries @implementation BookmarksTestCaseEntries
// TODO(crbug.com/863476): Temporarily disable bookmarks on iOS12.
+ (NSArray*)testInvocations {
if (base::ios::IsRunningOnIOS12OrLater())
return @[];
return [super testInvocations];
}
- (void)setUp { - (void)setUp {
[super setUp]; [super setUp];
...@@ -2781,13 +2777,6 @@ id<GREYMatcher> TappableBookmarkNodeWithLabel(NSString* label) { ...@@ -2781,13 +2777,6 @@ id<GREYMatcher> TappableBookmarkNodeWithLabel(NSString* label) {
@implementation BookmarksTestCasePromo @implementation BookmarksTestCasePromo
// TODO(crbug.com/863476): Temporarily disable bookmarks on iOS12.
+ (NSArray*)testInvocations {
if (base::ios::IsRunningOnIOS12OrLater())
return @[];
return [super testInvocations];
}
- (void)setUp { - (void)setUp {
[super setUp]; [super setUp];
...@@ -3002,13 +2991,6 @@ id<GREYMatcher> TappableBookmarkNodeWithLabel(NSString* label) { ...@@ -3002,13 +2991,6 @@ id<GREYMatcher> TappableBookmarkNodeWithLabel(NSString* label) {
@implementation BookmarksTestCaseAccessibility @implementation BookmarksTestCaseAccessibility
// TODO(crbug.com/863476): Temporarily disable bookmarks on iOS12.
+ (NSArray*)testInvocations {
if (base::ios::IsRunningOnIOS12OrLater())
return @[];
return [super testInvocations];
}
- (void)setUp { - (void)setUp {
[super setUp]; [super setUp];
...@@ -3185,13 +3167,6 @@ id<GREYMatcher> TappableBookmarkNodeWithLabel(NSString* label) { ...@@ -3185,13 +3167,6 @@ id<GREYMatcher> TappableBookmarkNodeWithLabel(NSString* label) {
@implementation BookmarksTestCaseFolders @implementation BookmarksTestCaseFolders
// TODO(crbug.com/863476): Temporarily disable bookmarks on iOS12.
+ (NSArray*)testInvocations {
if (base::ios::IsRunningOnIOS12OrLater())
return @[];
return [super testInvocations];
}
- (void)setUp { - (void)setUp {
[super setUp]; [super setUp];
......
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