From 7d327b21d73f76b47bb159b7bc3ddb0f0675078d Mon Sep 17 00:00:00 2001 From: Davide Date: Tue, 10 Dec 2024 18:51:51 +0100 Subject: [PATCH] Reuse some iOS code in tvOS UI tests --- .../UITests/Extensions/XCTestCase+Extensions.swift | 2 +- .../UITests/Extensions/XCUIElement+Extensions.swift | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Passepartout/UITests/Extensions/XCTestCase+Extensions.swift b/Passepartout/UITests/Extensions/XCTestCase+Extensions.swift index 6a047e9a..263b62ac 100644 --- a/Passepartout/UITests/Extensions/XCTestCase+Extensions.swift +++ b/Passepartout/UITests/Extensions/XCTestCase+Extensions.swift @@ -88,7 +88,7 @@ extension XCUIApplicationProviding where Self: XCTestCase { } private func container(for target: ScreenshotTarget) -> XCUIElement { -#if os(iOS) +#if os(iOS) || os(tvOS) app.windows.firstMatch #else switch target { diff --git a/Passepartout/UITests/Extensions/XCUIElement+Extensions.swift b/Passepartout/UITests/Extensions/XCUIElement+Extensions.swift index 19881b03..1a19a83e 100644 --- a/Passepartout/UITests/Extensions/XCUIElement+Extensions.swift +++ b/Passepartout/UITests/Extensions/XCUIElement+Extensions.swift @@ -42,14 +42,14 @@ extension XCUIElement { private extension XCUIElement { func query(for elementType: AccessibilityInfo.ElementType) -> XCUIElementQuery { -#if os(iOS) +#if os(iOS) || os(tvOS) switch elementType { case .button, .link, .menu, .menuItem: return buttons case .text: return staticTexts } -#elseif os(macOS) +#else switch elementType { case .button, .link: return buttons @@ -60,13 +60,6 @@ private extension XCUIElement { case .text: return staticTexts } -#else - switch elementType { - case .button, .link, .menu, .menuItem: - return buttons - case .text: - return staticTexts - } #endif } }