Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS ReferenceAssetsPlugin: check registry type instead of player type #372

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public class ReferenceAssetsPlugin: JSBasePlugin, NativePlugin {
- player: The `HeadlessPlayer` that is applying this plugin
*/
public func apply<P>(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)
}
}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
{
Expand Down