Skip to content

feat: add 6 tvOS button values for mobile: pressButton#1116

Open
eglitise wants to merge 1 commit intoappium:masterfrom
eglitise:tvos-pressbutton
Open

feat: add 6 tvOS button values for mobile: pressButton#1116
eglitise wants to merge 1 commit intoappium:masterfrom
eglitise:tvos-pressbutton

Conversation

@eglitise
Copy link

@eglitise eglitise commented Mar 3, 2026

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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and guide to the corresponding XCUIRemoteButton* 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.

Comment on lines +289 to +306
#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
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +290 to +305
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"];
}
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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"];

Copilot uses AI. Check for mistakes.

// since tvOS 14.3
if ([buttonName.lowercaseString isEqualToString:@"pageup"]) {
remoteButton = XCUIRemoteButtonPageUp;
Copy link
Member

@KazuCocoa KazuCocoa Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Member

@KazuCocoa KazuCocoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the method is now big and is hard to read. Consider splitting it to smaller ones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants