feat: add 6 tvOS button values for mobile: pressButton#1116
feat: add 6 tvOS button values for mobile: pressButton#1116eglitise wants to merge 1 commit intoappium:masterfrom
mobile: pressButton#1116Conversation
There was a problem hiding this comment.
Pull request overview
Adds additional tvOS remote button name mappings to mobile: pressButton (via XCUIDevice helper) so Appium/WDA can trigger more Apple TV remote buttons through XCTest/WDA.
Changes:
- Map
pageUp,pageDown, andguideto the correspondingXCUIRemoteButton*enums. - Add tvOS 18.1+ button mappings (
fourColors,oneTwoThree,tvProvider) behind compile-time and runtime availability checks.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #if __clang_major__ >= 17 || (__clang_major__ == 16 && __clang_minor__ >= 3) | ||
| if (@available(tvOS 18.1, *)) { | ||
| if ([buttonName.lowercaseString isEqualToString:@"fourcolors"]) { | ||
| remoteButton = XCUIRemoteButtonFourColors; | ||
| } | ||
| [supportedButtonNames addObject:@"fourColors"]; | ||
|
|
||
| if ([buttonName.lowercaseString isEqualToString:@"onetwothree"]) { | ||
| remoteButton = XCUIRemoteButtonOneTwoThree; | ||
| } | ||
| [supportedButtonNames addObject:@"oneTwoThree"]; | ||
|
|
||
| if ([buttonName.lowercaseString isEqualToString:@"tvprovider"]) { | ||
| remoteButton = XCUIRemoteButtonTVProvider; | ||
| } | ||
| [supportedButtonNames addObject:@"tvProvider"]; | ||
| } | ||
| #endif |
There was a problem hiding this comment.
The compile-time guard #if __clang_major__ >= 17 || (__clang_major__ == 16 && __clang_minor__ >= 3) is brittle because Clang version components don’t reliably map to Xcode minor versions, which can cause these button enums to be incorrectly excluded (or included) depending on the toolchain. A more robust approach is to guard on SDK symbol availability (e.g. #if defined(XCUIRemoteButtonFourColors) / #if __has_include / __TV_OS_VERSION_MAX_ALLOWED) and keep the @available(tvOS 18.1, *) runtime check for execution.
| if (@available(tvOS 18.1, *)) { | ||
| if ([buttonName.lowercaseString isEqualToString:@"fourcolors"]) { | ||
| remoteButton = XCUIRemoteButtonFourColors; | ||
| } | ||
| [supportedButtonNames addObject:@"fourColors"]; | ||
|
|
||
| if ([buttonName.lowercaseString isEqualToString:@"onetwothree"]) { | ||
| remoteButton = XCUIRemoteButtonOneTwoThree; | ||
| } | ||
| [supportedButtonNames addObject:@"oneTwoThree"]; | ||
|
|
||
| if ([buttonName.lowercaseString isEqualToString:@"tvprovider"]) { | ||
| remoteButton = XCUIRemoteButtonTVProvider; | ||
| } | ||
| [supportedButtonNames addObject:@"tvProvider"]; | ||
| } |
There was a problem hiding this comment.
The supportedButtonNames entries for fourColors/oneTwoThree/tvProvider are only appended inside @available(tvOS 18.1, *). On tvOS < 18.1 this makes these button names appear “unknown” (and they won’t be listed as supported) rather than returning a clear "requires tvOS 18.1+" style error when users pass them. Consider always including these names in supportedButtonNames when the SDK supports the enums, and if the incoming buttonName matches but the OS is older, return an explicit availability error message.
| if (@available(tvOS 18.1, *)) { | |
| if ([buttonName.lowercaseString isEqualToString:@"fourcolors"]) { | |
| remoteButton = XCUIRemoteButtonFourColors; | |
| } | |
| [supportedButtonNames addObject:@"fourColors"]; | |
| if ([buttonName.lowercaseString isEqualToString:@"onetwothree"]) { | |
| remoteButton = XCUIRemoteButtonOneTwoThree; | |
| } | |
| [supportedButtonNames addObject:@"oneTwoThree"]; | |
| if ([buttonName.lowercaseString isEqualToString:@"tvprovider"]) { | |
| remoteButton = XCUIRemoteButtonTVProvider; | |
| } | |
| [supportedButtonNames addObject:@"tvProvider"]; | |
| } | |
| // since tvOS 18.1 | |
| if ([buttonName.lowercaseString isEqualToString:@"fourcolors"]) { | |
| if (@available(tvOS 18.1, *)) { | |
| remoteButton = XCUIRemoteButtonFourColors; | |
| } else { | |
| return [[[FBErrorBuilder builder] | |
| withDescriptionFormat:@"The button '%@' requires tvOS 18.1 or newer.", buttonName] | |
| buildError:error]; | |
| } | |
| } | |
| [supportedButtonNames addObject:@"fourColors"]; | |
| if ([buttonName.lowercaseString isEqualToString:@"onetwothree"]) { | |
| if (@available(tvOS 18.1, *)) { | |
| remoteButton = XCUIRemoteButtonOneTwoThree; | |
| } else { | |
| return [[[FBErrorBuilder builder] | |
| withDescriptionFormat:@"The button '%@' requires tvOS 18.1 or newer.", buttonName] | |
| buildError:error]; | |
| } | |
| } | |
| [supportedButtonNames addObject:@"oneTwoThree"]; | |
| if ([buttonName.lowercaseString isEqualToString:@"tvprovider"]) { | |
| if (@available(tvOS 18.1, *)) { | |
| remoteButton = XCUIRemoteButtonTVProvider; | |
| } else { | |
| return [[[FBErrorBuilder builder] | |
| withDescriptionFormat:@"The button '%@' requires tvOS 18.1 or newer.", buttonName] | |
| buildError:error]; | |
| } | |
| } | |
| [supportedButtonNames addObject:@"tvProvider"]; |
|
|
||
| // since tvOS 14.3 | ||
| if ([buttonName.lowercaseString isEqualToString:@"pageup"]) { | ||
| remoteButton = XCUIRemoteButtonPageUp; |
There was a problem hiding this comment.
I have confirmed on my XCTest header note, the blow ones were added in Xcode 15.3
- XCUIRemoteButtonPageUp
- XCUIRemoteButtonPageDown
- XCUIRemoteButtonGuide
This is since Xcode 15.3:
AppleTVOS/Frameworks/XCTest.framework/Headers/Headers/XCUIRemote.h: * @enum XCUIRemoteButton
AppleTVOS/Frameworks/XCTest.framework/Headers/Headers/XCUIRemote.h:typedef NS_ENUM(NSUInteger, XCUIRemoteButton) {
AppleTVOS/Frameworks/XCTest.framework/Headers/Headers/XCUIRemote.h: XCUIRemoteButtonUp = 0,
AppleTVOS/Frameworks/XCTest.framework/Headers/Headers/XCUIRemote.h: XCUIRemoteButtonDown = 1,
AppleTVOS/Frameworks/XCTest.framework/Headers/Headers/XCUIRemote.h: XCUIRemoteButtonLeft = 2,
AppleTVOS/Frameworks/XCTest.framework/Headers/Headers/XCUIRemote.h: XCUIRemoteButtonRight = 3,
AppleTVOS/Frameworks/XCTest.framework/Headers/Headers/XCUIRemote.h: XCUIRemoteButtonSelect = 4,
AppleTVOS/Frameworks/XCTest.framework/Headers/Headers/XCUIRemote.h: XCUIRemoteButtonMenu = 5,
AppleTVOS/Frameworks/XCTest.framework/Headers/Headers/XCUIRemote.h: XCUIRemoteButtonPlayPause = 6,
AppleTVOS/Frameworks/XCTest.framework/Headers/Headers/XCUIRemote.h: XCUIRemoteButtonHome = 7,
AppleTVOS/Frameworks/XCTest.framework/Headers/Headers/XCUIRemote.h: XCUIRemoteButtonPageUp API_AVAILABLE(tvos(14.3)) = 9,
AppleTVOS/Frameworks/XCTest.framework/Headers/Headers/XCUIRemote.h: XCUIRemoteButtonPageDown API_AVAILABLE(tvos(14.3)) = 10,
AppleTVOS/Frameworks/XCTest.framework/Headers/Headers/XCUIRemote.h: XCUIRemoteButtonGuide API_AVAILABLE(tvos(14.3)) = 11
AppleTVOS/Frameworks/XCTest.framework/Headers/Headers/XCUIRemote.h:- (void)pressButton:(XCUIRemoteButton)remoteButton;
KazuCocoa
left a comment
There was a problem hiding this comment.
I'm fine to add the Xcode version check for the page up/down and guide since our supported Xcode version is the latest two major versions - 26 and 16 for now.
| } | ||
| [supportedButtonNames addObject:@"select"]; | ||
|
|
||
| // since tvOS 14.3 |
There was a problem hiding this comment.
the method is now big and is hard to read. Consider splitting it to smaller ones
Similarly to #1115, this adds support for 6 tvOS buttons to
mobile: pressButton:pageUp(tvOS 14.3+)pageDown(tvOS 14.3+)guide(tvOS 14.3+)fourColors(tvOS 18.1+)oneTwoThree(tvOS 18.1+)tvProvider(tvOS 18.1+)Apple's docs again aren't clear on which Xcode versions added the respective enums. Since the former 3 buttons require tvOS 14.3 (which this driver doesn't even support anymore), I haven't added any guards for it, but the latter 3 use an Xcode 16.3+/tvOS 18.1+ guard similar to the one in the other PR.
Reference: https://developer.apple.com/documentation/xcuiautomation/xcuiremotebutton/home?language=objc