Skip to content

Commit

Permalink
iOS ReferenceAssetsPlugin: check registry type instead of player type (
Browse files Browse the repository at this point in the history
…#372)

check registry type instead of player type
  • Loading branch information
hborawski authored Jun 4, 2024
1 parent d3863d8 commit e252f46
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 26 deletions.
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

0 comments on commit e252f46

Please sign in to comment.