Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149import Testing
@testable import ParcelAnimation
@Suite struct MotionTokenTests { @Test func defaultsArePlayfulAndNormalSpeed() { #expect(MotionSettings().level == .playful) #expect(MotionSettings().speedMultiplier == 1) }
@Test func settleAndFadeCurves() { let settle = MotionToken.settle.spec() #expect(settle.duration == 0.20) #expect(settle.bounce == 0) #expect(settle.overshootLimit == 0) #expect(settle.curve == .glide) let fade = MotionToken.fade.spec() #expect(fade.duration == 0.12) #expect(fade.bounce == 0) #expect(fade.curve == .fade) #expect(fade.accent == .none) }
@Test func popAndDropBounce() { let pop = MotionToken.pop.spec() #expect(pop.duration == 0.25) #expect(pop.bounce == 0.15) #expect(pop.accent == .scale(from: 0.98)) let drop = MotionToken.drop.spec() #expect(drop.duration == 0.30) #expect(drop.bounce == 0.25) }
@Test func nudgeAndStackOffsets() { let nudge = MotionToken.nudge.spec() #expect(nudge.duration == 0.18) #expect(nudge.bounce == 0.5) #expect(nudge.accent == .offset(horizontal: 4, vertical: 0)) let stack = MotionToken.stack.spec() #expect(stack.duration == 0.28) #expect(stack.bounce == 0.12) #expect(stack.accent == .offset(horizontal: 2, vertical: 0)) }
@Test func shuffleAndGlanceLimits() { let shuffle = MotionToken.shuffle.spec() #expect(shuffle.duration == 0.24) #expect(shuffle.bounce == 0.1) #expect(shuffle.stagger == 0.012) #expect(shuffle.maximumStagger == 0.048) let glance = MotionToken.glance.spec() #expect(glance.duration == 0.15) #expect(glance.bounce == 0) #expect(glance.maximumRedraws == 10) }
@Test func staggerStartsImmediatelyAndCapsLateItems() { let spec = MotionToken.shuffle.spec() #expect(spec.delay(for: 0) == 0) #expect(spec.delay(for: 2) == 0.024) #expect(spec.delay(for: 4) == 0.048) #expect(spec.delay(for: 10_000) == 0.048) }
@Test(arguments: MotionToken.allCases) func speedDoublesWithoutChangingPersonality(_ token: MotionToken) { let normal = token.spec() let faster = token.spec(settings: MotionSettings(speedMultiplier: 2)) #expect(near(faster.duration, normal.duration / 2)) #expect(near(faster.stagger, normal.stagger / 2)) #expect(near(faster.maximumStagger, normal.maximumStagger / 2)) #expect(faster.bounce == normal.bounce) #expect(faster.accent == normal.accent) #expect(faster.overshootLimit == normal.overshootLimit) }
@Test func slowerSpeedLengthensMotion() { #expect(MotionToken.pop.spec(settings: MotionSettings(speedMultiplier: 0.5)).duration == 0.5) }
@Test(arguments: MotionToken.allCases.filter { $0 != .fade }) func calmUsesSettleWithoutAccents(_ token: MotionToken) { let spec = token.spec(settings: MotionSettings(level: .calm)) #expect(spec.duration == 0.2) #expect(spec.bounce == 0) #expect(spec.stagger == 0) #expect(spec.accent == .none) #expect(spec.curve == .spring) }
@Test func calmKeepsFadeShort() { #expect(MotionToken.fade.spec(settings: MotionSettings(level: .calm)).duration == 0.12) }
@Test func extraAddsSelectedBounceAndScalesStagger() { let settings = MotionSettings(level: .extra) #expect(near(MotionToken.pop.spec(settings: settings).bounce, 0.25)) #expect(near(MotionToken.drop.spec(settings: settings).bounce, 0.35)) #expect(near(MotionToken.shuffle.spec(settings: settings).bounce, 0.2)) #expect(MotionToken.nudge.spec(settings: settings).bounce == 0.5) #expect(MotionToken.stack.spec(settings: settings).bounce == 0.12) #expect(MotionToken.settle.spec(settings: settings).bounce == 0) let spec = MotionToken.shuffle.spec(settings: settings) #expect(near(spec.stagger, 0.018)) #expect(near(spec.maximumStagger, 0.072)) }
@Test func allSpringTokensHavePhysicalParameters() { for token in MotionToken.allCases { let spec = token.spec() #expect(spec.spring.stiffness > 0) #expect(spec.spring.damping > 0) #expect(spec.overshootLimit <= 0.25) } }}
@Suite struct MotionPolicyTests { @Test func enabledByDefault() { #expect(MotionPolicy().enabled) #expect(!MotionPolicy().reduceMotion) }
@Test(arguments: [MotionSurface.window, .overlay, .miniMap]) func offDisablesEverySurface(_ surface: MotionSurface) { #expect(MotionPolicy(enabled: false).behavior(for: surface) == .instant) }
@Test func offOverridesReduceMotionFade() { #expect(MotionPolicy(enabled: false, reduceMotion: true).behavior(for: .overlay) == .instant) }
@Test func reduceMotionOnlyFadesOverlays() { #expect(MotionPolicy(reduceMotion: true).behavior(for: .window) == .instant) #expect(MotionPolicy(reduceMotion: true).behavior(for: .overlay) == .fade(duration: 0.12)) #expect(MotionPolicy(reduceMotion: true).behavior(for: .miniMap) == .instant) }
@Test func calmSnapsWindowsButAnimatesChrome() { #expect(MotionPolicy().behavior(for: .window, level: .calm) == .instant) #expect(MotionPolicy().behavior(for: .overlay, level: .calm) == .animate) }
@Test func systemSettingOverridesExtra() { #expect(MotionPolicy(reduceMotion: true).behavior(for: .window, level: .extra) == .instant) #expect(MotionPolicy(reduceMotion: true).behavior(for: .overlay, level: .extra) == .fade(duration: 0.12)) }}