From b36d424d3653f8ecc85553d514b2aea1d52c97ab Mon Sep 17 00:00:00 2001 From: hborawski Date: Fri, 31 May 2024 15:17:35 -0700 Subject: [PATCH] check registry type instead of player type --- .../swiftui/Sources/ReferenceAssetsPlugin.swift | 12 ++++++------ .../ViewInspector/SwiftUI/ActionAssetTests.swift | 5 +---- .../ViewInspector/SwiftUI/CollectionAssetTests.swift | 5 +---- .../ViewInspector/SwiftUI/InfoAssetTests.swift | 6 +----- .../ViewInspector/SwiftUI/InputAssetTests.swift | 5 +---- .../ViewInspector/SwiftUI/TextAssetTests.swift | 5 ++--- 6 files changed, 12 insertions(+), 26 deletions(-) diff --git a/plugins/reference-assets/swiftui/Sources/ReferenceAssetsPlugin.swift b/plugins/reference-assets/swiftui/Sources/ReferenceAssetsPlugin.swift index 10dadb749..59860bc55 100644 --- a/plugins/reference-assets/swiftui/Sources/ReferenceAssetsPlugin.swift +++ b/plugins/reference-assets/swiftui/Sources/ReferenceAssetsPlugin.swift @@ -15,12 +15,12 @@ public class ReferenceAssetsPlugin: JSBasePlugin, NativePlugin { - player: The `HeadlessPlayer` that is applying this plugin */ public func apply

(player: P) where P: HeadlessPlayer { - if let player = player as? SwiftUIPlayer { - player.assetRegistry.register("action", asset: ActionAsset.self) - player.assetRegistry.register("text", asset: TextAsset.self) - player.assetRegistry.register("collection", asset: CollectionAsset.self) - player.assetRegistry.register("input", asset: InputAsset.self) - player.assetRegistry.register("info", asset: InfoAsset.self) + if let registry = player.assetRegistry as? SwiftUIRegistry { + registry.register("action", asset: ActionAsset.self) + registry.register("text", asset: TextAsset.self) + registry.register("collection", asset: CollectionAsset.self) + registry.register("input", asset: InputAsset.self) + registry.register("info", asset: InfoAsset.self) } } /** diff --git a/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/ActionAssetTests.swift b/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/ActionAssetTests.swift index 04f5ca9fa..0dafbfe2b 100644 --- a/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/ActionAssetTests.swift +++ b/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/ActionAssetTests.swift @@ -18,10 +18,7 @@ import ViewInspector @testable import PlayerUIBeaconPlugin class ActionAssetTests: SwiftUIAssetUnitTestCase { - override func register(registry: SwiftUIRegistry) { - registry.register("action", asset: ActionAsset.self) - registry.register("text", asset: TextAsset.self) - } + override open func plugins() -> [NativePlugin] { [ReferenceAssetsPlugin()] } func setup() { XCUIApplication().terminate() diff --git a/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/CollectionAssetTests.swift b/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/CollectionAssetTests.swift index bd5dbb563..b2d6f48ad 100644 --- a/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/CollectionAssetTests.swift +++ b/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/CollectionAssetTests.swift @@ -17,10 +17,7 @@ import SwiftUI @testable import PlayerUISwiftUI class CollectionAssetTests: SwiftUIAssetUnitTestCase { - override func register(registry: SwiftUIRegistry) { - registry.register("collection", asset: CollectionAsset.self) - registry.register("text", asset: TextAsset.self) - } + override open func plugins() -> [NativePlugin] { [ReferenceAssetsPlugin()] } func testDecoding() async throws { let json = """ diff --git a/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/InfoAssetTests.swift b/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/InfoAssetTests.swift index ad793daa2..a534b95b0 100644 --- a/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/InfoAssetTests.swift +++ b/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/InfoAssetTests.swift @@ -17,11 +17,7 @@ import XCTest @testable import PlayerUISwiftUI class InfoAssetTests: SwiftUIAssetUnitTestCase { - override func register(registry: SwiftUIRegistry) { - registry.register("info", asset: InfoAsset.self) - registry.register("text", asset: TextAsset.self) - registry.register("action", asset: ActionAsset.self) - } + override open func plugins() -> [NativePlugin] { [ReferenceAssetsPlugin()] } func testDecoding() async throws { let json = """ diff --git a/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/InputAssetTests.swift b/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/InputAssetTests.swift index d57b6a474..7c50fb691 100644 --- a/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/InputAssetTests.swift +++ b/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/InputAssetTests.swift @@ -20,10 +20,7 @@ import JavaScriptCore class InputAssetTests: SwiftUIAssetUnitTestCase { - override func register(registry: SwiftUIRegistry) { - registry.register("input", asset: InputAsset.self) - registry.register("text", asset: TextAsset.self) - } + override open func plugins() -> [NativePlugin] { [ReferenceAssetsPlugin()] } func testDecoding() async throws { let json = """ diff --git a/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/TextAssetTests.swift b/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/TextAssetTests.swift index 688d340b8..2d6e53bfe 100644 --- a/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/TextAssetTests.swift +++ b/plugins/reference-assets/swiftui/ViewInspector/SwiftUI/TextAssetTests.swift @@ -16,9 +16,8 @@ import SwiftUI @testable import PlayerUITestUtilities class TextAssetTests: SwiftUIAssetUnitTestCase { - override func register(registry: SwiftUIRegistry) { - registry.register("text", asset: TextAsset.self) - } + override open func plugins() -> [NativePlugin] { [ReferenceAssetsPlugin()] } + func testAssetDecoding() async throws { let json = """ {