Skip to content

Commit

Permalink
Adjust test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
STREGA committed Jul 30, 2023
1 parent 50a2887 commit 971b5df
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
6 changes: 4 additions & 2 deletions Sources/GateEngine/System/Platforms/WASI/WASIPlatform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ public final class WASIPlatform: Platform, InternalPlatform {
state.name = name
return state
}catch{
if let error = error as? String, error != "No such file or directory." {
if case GateEngineError.failedToLocate = error {
// Do nothing
}else{
Log.error("Game State \"\(name)\" failed to restore:", error)
}
return Game.State(name: name)
Expand Down Expand Up @@ -306,7 +308,7 @@ extension WASIPlatform {
}
}

fileprivate final class WASIUserActivationRenderingSystem: RenderingSystem {
internal final class WASIUserActivationRenderingSystem: RenderingSystem {
let text = Text(string: "Click to Start", pointSize: 64, style: .bold, color: .white)
let banner = Sprite(texture: Texture(path: "GateEngine/Branding/Banner Logo Transparent.png", sizeHint: Size2(1200, 244)), bounds: Rect(size: Size2(1200, 244)), sampleFilter: .linear)

Expand Down
19 changes: 12 additions & 7 deletions Tests/GateEngineTests/_GateEngineXCTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@ open class GateEngineXCTestCase: XCTestCase {
}

@MainActor open override func setUp() async throws {
if Game.shared == nil {
let delegate = TestGameDelegate()
let platform = CurrentPlatform(delegate: delegate)
Game.shared = Game(delegate: delegate, currentPlatform: platform)

await Game.shared.didFinishLaunching()
}
guard Game.shared == nil else {return}

let delegate = TestGameDelegate()
let platform = CurrentPlatform(delegate: delegate)
Game.shared = Game(delegate: delegate, currentPlatform: platform)

await Game.shared.didFinishLaunching()

#if os(WASI)
// Removing the system finishes startup as if the user had clicked
Game.shared.removeSystem(WASIUserActivationRenderingSystem.self)
#endif
}
}
19 changes: 12 additions & 7 deletions Tests/GravityTests/_GravityXCTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,17 @@ open class GravityXCTestCase: XCTestCase {
}

@MainActor open override func setUp() async throws {
if Game.shared == nil {
let delegate = TestGameDelegate()
let platform = CurrentPlatform(delegate: delegate)
Game.shared = Game(delegate: delegate, currentPlatform: platform)

await Game.shared.didFinishLaunching()
}
guard Game.shared == nil else {return}

let delegate = TestGameDelegate()
let platform = CurrentPlatform(delegate: delegate)
Game.shared = Game(delegate: delegate, currentPlatform: platform)

await Game.shared.didFinishLaunching()

#if os(WASI)
// Removing the system finishes startup as if the user had clicked
Game.shared.removeSystem(WASIUserActivationRenderingSystem.self)
#endif
}
}

0 comments on commit 971b5df

Please sign in to comment.