import XCTest
@testable import Physarum
/// Pure policy for when the live player pauses and how fast it runs —
/// the thermal/ambient behavior of an always-on visual app.
final class PlayerPolicyTests: XCTestCase {
func testPauseWhenLibraryCoversCanvas() {
XCTAssertTrue(playerShouldPause(libraryVisible: true, sceneActive: true))
}
func testPauseWhenSceneInactive() {
XCTAssertTrue(playerShouldPause(libraryVisible: false, sceneActive: false))
}
func testRunsWhenVisibleAndActive() {
XCTAssertFalse(playerShouldPause(libraryVisible: false, sceneActive: true))
}
func testFullFrameRateWhenCoolAndUnconstrained() {
XCTAssertEqual(preferredFPS(thermalState: .nominal, lowPowerMode: false), 60)
}
func testHalfFrameRateUnderThermalPressure() {
XCTAssertEqual(preferredFPS(thermalState: .fair, lowPowerMode: false), 30)
XCTAssertEqual(preferredFPS(thermalState: .serious, lowPowerMode: false), 30)
XCTAssertEqual(preferredFPS(thermalState: .critical, lowPowerMode: false), 30)
}
func testHalfFrameRateInLowPowerMode() {
XCTAssertEqual(preferredFPS(thermalState: .nominal, lowPowerMode: true), 30)
}
func testDrawableScaleCappedAt2xOnNonDesktopTiers() {
XCTAssertEqual(cappedDrawableScale(3.0, tier: .phone), 2.0)
XCTAssertEqual(cappedDrawableScale(2.0, tier: .phone), 2.0)
XCTAssertEqual(cappedDrawableScale(3.0, tier: .tablet), 2.0)
XCTAssertEqual(cappedDrawableScale(3.0, tier: .desktop), 3.0)
}
}