Skip to content

Commit

Permalink
Make testID work for iOS tabs
Browse files Browse the repository at this point in the history
Reviewed By: shergin

Differential Revision: D6455054

fbshipit-source-id: 3c667b585e9332a1dbfff1fd3325f2c95985a5be
  • Loading branch information
frantic authored and facebook-github-bot committed Dec 4, 2017
1 parent ca10604 commit e19d9de
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions React/Views/RCTTabBarItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
@property (nonatomic, assign, getter=isSelected) BOOL selected;
@property (nonatomic, readonly) UITabBarItem *barItem;
@property (nonatomic, copy) RCTBubblingEventBlock onPress;
@property (nonatomic, strong) NSString *testID;

#if TARGET_OS_TV
@property (nonatomic, assign) BOOL wasSelectedInJS;
Expand Down
5 changes: 5 additions & 0 deletions React/Views/RCTTabBarItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ - (UITabBarItem *)barItem
return _barItem;
}

- (void)setTestID:(NSString *)testID
{
self.barItem.accessibilityIdentifier = testID;
}

- (void)setBadge:(id)badge
{
_badge = [badge copy];
Expand Down
1 change: 1 addition & 0 deletions React/Views/RCTTabBarItemManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ - (UIView *)view
RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(badgeColor, UIColor)
RCT_EXPORT_VIEW_PROPERTY(isTVSelectable, BOOL)
RCT_EXPORT_VIEW_PROPERTY(testID, NSString)
RCT_CUSTOM_VIEW_PROPERTY(title, NSString, RCTTabBarItem)
{
view.barItem.title = json ? [RCTConvert NSString:json] : defaultView.barItem.title;
Expand Down

0 comments on commit e19d9de

Please sign in to comment.