Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113import Foundationimport ParcelConfigimport ParcelCoreimport Testing
@testable import ParcelEngine
@MainActorstruct ConfigurationMergeRegressionTests { enum NonLayoutEdit: CaseIterable, Sendable { case highlights, mouse, hoverBar, hoverDelay, focusDelay, typingCooldown, privacy, accessibility, restoration, shortcuts
func apply(to configuration: inout ParcelConfiguration) { switch self { case .highlights: configuration.motion.highlight = .all case .mouse: configuration.mouse.enabled.toggle() case .hoverBar: configuration.hoverBar.enabled.toggle() case .hoverDelay: configuration.hoverBar.delay = 0.8 case .focusDelay: configuration.mouse.focusDelay = 0.8 case .typingCooldown: configuration.mouse.typingCooldown = 2 case .privacy: configuration.focusModes.noPeekBlur.toggle() case .accessibility: configuration.accessibility.announceLayoutChanges.toggle() case .restoration: configuration.memory.restoreWindows.toggle() case .shortcuts: configuration.keybindings.removeValue(forKey: .focusLeft) } } }
@Test(arguments: NonLayoutEdit.allCases) func nonLayoutEditsPreservePendingRestorationWithoutScheduling(edit: NonLayoutEdit) async throws { let harness = try EngineHarness() try await harness.start() try harness.add([1, 2]) harness.engine.send(.commandIssued(.setLayout(.rows))) try harness.scheduler.runReady() try harness.finishMotion() let before = harness.engine.snapshot let memory = try WorkspaceMemory.capture(before.state, titleSalt: Data(repeating: 7, count: 32)) harness.engine.pendingRestorationMemory = memory let passes = harness.engine.layoutPassCount let scheduled = harness.scheduler.scheduledCount let writes = harness.world.writes.count var configuration = harness.engine.configuration edit.apply(to: &configuration) try harness.engine.applyConfiguration(configuration) try harness.scheduler.runReady() #expect(harness.engine.configuration == configuration) #expect(harness.engine.snapshot == before) #expect(harness.engine.pendingRestorationMemory == memory) #expect(harness.engine.layoutPassCount == passes) #expect(harness.scheduler.scheduledCount == scheduled) #expect(harness.world.writes.count == writes) #expect(harness.engine.isIdle) await harness.engine.stop() }
@Test func hoverFocusEditUpdatesStateWithoutSchedulingLayout() async throws { let harness = try EngineHarness() try await harness.start() try harness.add([1, 2]) try harness.finishMotion() let before = harness.engine.snapshot let memory = try WorkspaceMemory.capture(before.state, titleSalt: Data(repeating: 7, count: 32)) harness.engine.pendingRestorationMemory = memory let passes = harness.engine.layoutPassCount let scheduled = harness.scheduler.scheduledCount let writes = harness.world.writes.count var configuration = harness.engine.configuration configuration.mouse.focusFollowsMouse = true try harness.engine.applyConfiguration(configuration) try harness.scheduler.runReady() var expected = before.state expected.hoverFocusEnabled = true let expectedSnapshot = EngineSnapshot( revision: before.revision, state: expected, readbackFrames: before.readbackFrames, focusedMotionPlan: before.focusedMotionPlan) #expect(harness.engine.snapshot == expectedSnapshot) #expect(harness.engine.pendingRestorationMemory == memory) #expect(harness.engine.layoutPassCount == passes) #expect(harness.scheduler.scheduledCount == scheduled) #expect(harness.world.writes.count == writes) #expect(harness.engine.isIdle) await harness.engine.stop() }
@Test func displayLayoutReloadInvalidatesOnlyItsPendingRestoration() async throws { let harness = try EngineHarness(initialState: engineInitialState(twoDisplays: true)) let second = WorkspaceKey(display: secondEngineDisplay, space: SpaceID(rawValue: 2)) try await harness.start() try harness.add([1, 2]) try harness.add([3, 4], workspace: second) try harness.finishMotion() let before = harness.engine.snapshot.state harness.engine.pendingRestorationMemory = try WorkspaceMemory.capture( before, titleSalt: Data(repeating: 7, count: 32)) let passes = harness.engine.layoutPassCount var configuration = harness.engine.configuration var values = configuration.layout.global values.defaultLayout = .rows configuration.layout.displays[try #require(UUID(uuidString: secondEngineDisplay.rawValue))] = values try harness.engine.applyConfiguration(configuration) #expect(harness.engine.pendingRestorationMemory.records.map { $0.workspace.key } == [engineWorkspace]) try harness.scheduler.runReady() #expect(harness.engine.layoutPassCount == passes + 1) #expect(harness.engine.snapshot.state.workspaces[second]?.layout == .rows) #expect(harness.engine.snapshot.state.workspaces[engineWorkspace] == before.workspaces[engineWorkspace]) #expect(harness.engine.snapshot.state.activeDisplay == before.activeDisplay) #expect(harness.engine.snapshot.focusedWindow == before.focusedWindow) await harness.engine.stop() }}