Commit f4815dd1 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Set a11y identifiers directly to UIButtons for legacy toolbar.

LegacyReadingListToolbarButton is actually a plain UIView superview of
the UIButton handling touch events, so setting the a11y identifier on
the superview was not passing touches to the underlying button in
EG tests.  This CL updates LegacyReadingListToolbarButton to take an
a11y identifier that's applied to the underlying UIButton, allowing
touches to be handled properly.

Bug: 866012
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I1e98ae482bd21e1e913d500d53f43526fadb62af
Reviewed-on: https://chromium-review.googlesource.com/1147310
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarPeter Lee <pkl@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577407}
parent 8a631993
......@@ -85,35 +85,34 @@ const CGFloat kHorizontalSpacing = 8.0f;
_deleteButton = [[LegacyReadingListToolbarButton alloc]
initWithText:l10n_util::GetNSString(IDS_IOS_READING_LIST_DELETE_BUTTON)
destructive:YES
position:Leading];
_deleteButton.accessibilityIdentifier = kReadingListToolbarDeleteButtonID;
position:Leading
identifier:kReadingListToolbarDeleteButtonID];
_deleteAllButton = [[LegacyReadingListToolbarButton alloc]
initWithText:l10n_util::GetNSString(
IDS_IOS_READING_LIST_DELETE_ALL_READ_BUTTON)
destructive:YES
position:Leading];
_deleteAllButton.accessibilityIdentifier =
kReadingListToolbarDeleteAllReadButtonID;
position:Leading
identifier:kReadingListToolbarDeleteAllReadButtonID];
_markButton = [[LegacyReadingListToolbarButton alloc]
initWithText:l10n_util::GetNSString(
IDS_IOS_READING_LIST_MARK_ALL_BUTTON)
destructive:NO
position:Centered];
_markButton.accessibilityIdentifier = kReadingListToolbarMarkButtonID;
position:Centered
identifier:kReadingListToolbarMarkButtonID];
_cancelButton = [[LegacyReadingListToolbarButton alloc]
initWithText:l10n_util::GetNSString(IDS_IOS_READING_LIST_CANCEL_BUTTON)
destructive:NO
position:Trailing];
_cancelButton.accessibilityIdentifier = kReadingListToolbarCancelButtonID;
position:Trailing
identifier:kReadingListToolbarCancelButtonID];
_editButton = [[LegacyReadingListToolbarButton alloc]
initWithText:l10n_util::GetNSString(IDS_IOS_READING_LIST_EDIT_BUTTON)
destructive:NO
position:Trailing];
_editButton.accessibilityIdentifier = kReadingListToolbarEditButtonID;
position:Trailing
identifier:kReadingListToolbarEditButtonID];
[_editButton addTarget:nil
action:@selector(enterEditingModePressed)
......
......@@ -16,7 +16,8 @@ typedef NS_ENUM(NSInteger, ButtonPositioning) { Leading, Centered, Trailing };
// Initializer.
- (instancetype)initWithText:(NSString*)labelText
destructive:(BOOL)isDestructive
position:(ButtonPositioning)position;
position:(ButtonPositioning)position
identifier:(NSString*)identifier;
// Associates a target object and action method with the UIButton.
- (void)addTarget:(id)target
......
......@@ -33,7 +33,8 @@
- (instancetype)initWithText:(NSString*)labelText
destructive:(BOOL)isDestructive
position:(ButtonPositioning)position {
position:(ButtonPositioning)position
identifier:(NSString*)identifier {
self = [super init];
if (!self) {
return self;
......@@ -43,6 +44,7 @@
destructive:isDestructive
position:position];
_button.translatesAutoresizingMaskIntoConstraints = NO;
_button.accessibilityIdentifier = identifier;
[self addSubview:_button];
NSDictionary* views = @{@"button" : _button};
......
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