feat: add expandable compact queue and sidebar shortcut
This commit is contained in:
@@ -96,11 +96,11 @@ struct CompactWindowChecks {
|
||||
|
||||
// Run the real AppKit completion callbacks. The monotonic deadline is only a hang watchdog.
|
||||
static func settled(_ controller: CompactWindowController, compact: Bool,
|
||||
checking: () throws -> Void = {}) throws {
|
||||
line: UInt = #line, checking: () throws -> Void = {}) throws {
|
||||
let deadline = ContinuousClock.now.advanced(by: .seconds(5))
|
||||
while controller.isTransitioning {
|
||||
try checking()
|
||||
try require(ContinuousClock.now < deadline, "native compact transition completes")
|
||||
try require(ContinuousClock.now < deadline, "native compact transition completes (call at line \(line), compact \(controller.isCompact), target \(compact))")
|
||||
CFRunLoopRunInMode(.defaultMode, 0.01, false)
|
||||
}
|
||||
try checking()
|
||||
@@ -504,12 +504,73 @@ struct CompactWindowChecks {
|
||||
}
|
||||
}
|
||||
|
||||
static func compactQueue() throws {
|
||||
let fixture = try WindowFixture()
|
||||
let controller = CompactWindowController(reduceMotion: { true })
|
||||
let window = fixture.window
|
||||
defer {
|
||||
controller.restore(resumeFullScreen: false, animated: false)
|
||||
window.close()
|
||||
}
|
||||
controller.attach(window)
|
||||
controller.toggle(aspect: 16.0 / 9.0)
|
||||
try require(controller.queueHeight == 0, "compact entry hides the queue")
|
||||
let videoFrame = window.frame
|
||||
let expanded = controller.queueLayout(visible: true)!
|
||||
controller.updateQueue(height: expanded.height, frame: expanded.frame)
|
||||
try require(close(window.frame.maxY, videoFrame.maxY) && close(window.frame.width, videoFrame.width)
|
||||
&& close(window.frame.height - controller.queueHeight, videoFrame.height),
|
||||
"queue expands downwards without moving or resizing the compact video")
|
||||
try require(window.aspectRatio == .zero && close(window.minSize.height, 90 + controller.queueHeight),
|
||||
"expanded queue constrains video, not the combined window aspect")
|
||||
for horizontal in [true, false] {
|
||||
let start = window.frame
|
||||
window.delegate?.windowWillStartLiveResize?(Notification(name: NSWindow.willStartLiveResizeNotification, object: window))
|
||||
for offset in [CGFloat(20), 21, 22, 21, 0, -10] {
|
||||
let proposed = NSSize(width: start.width + (horizontal ? offset : 0),
|
||||
height: start.height + (horizontal ? 0 : offset))
|
||||
let size = window.delegate!.windowWillResize!(window, to: proposed)
|
||||
try require(close(size.width / (size.height - controller.queueHeight), 16.0 / 9.0),
|
||||
"both resize axes preserve the compact video's aspect with queue open")
|
||||
try require(close(horizontal ? size.width : size.height, horizontal ? proposed.width : proposed.height),
|
||||
"queue resize follows the chosen edge continuously")
|
||||
window.setFrame(NSRect(origin: start.origin, size: size), display: false)
|
||||
}
|
||||
window.delegate?.windowDidEndLiveResize?(Notification(name: NSWindow.didEndLiveResizeNotification, object: window))
|
||||
}
|
||||
controller.updateAspect(4.0 / 3.0)
|
||||
try require(abs(window.frame.height - controller.queueHeight - window.frame.width / (4.0 / 3.0)) <= 1,
|
||||
"metadata changes aspect only in the video above the queue: \(window.frame), queue \(controller.queueHeight)")
|
||||
let hidden = controller.queueLayout(visible: false)!
|
||||
let top = window.frame.maxY
|
||||
controller.updateQueue(height: hidden.height, frame: hidden.frame)
|
||||
try require(controller.queueHeight == 0 && close(window.frame.maxY, top)
|
||||
&& abs(window.frame.height - window.frame.width / (4.0 / 3.0)) <= 1,
|
||||
"hiding the queue contracts upwards and restores native aspect locking")
|
||||
var atBottom = window.frame
|
||||
atBottom.origin.y = (window.screen ?? NSScreen.main!).visibleFrame.minY + 16
|
||||
window.setFrame(atBottom, display: false)
|
||||
let bounded = controller.queueLayout(visible: true)!
|
||||
controller.updateQueue(height: bounded.height, frame: bounded.frame)
|
||||
try require(window.frame.minY >= (window.screen ?? NSScreen.main!).visibleFrame.minY + 16
|
||||
&& abs(window.frame.height - controller.queueHeight - window.frame.width / (4.0 / 3.0)) <= 1,
|
||||
"queue remains onscreen at the lower edge without distorting the video")
|
||||
controller.restore(resumeFullScreen: false)
|
||||
try fixture.restored()
|
||||
controller.toggle(aspect: 4.0 / 3.0)
|
||||
try require(controller.queueHeight == 0, "each compact entry resets queue visibility")
|
||||
try fixture.compact(aspect: 4.0 / 3.0)
|
||||
controller.restore(resumeFullScreen: false)
|
||||
try fixture.restored()
|
||||
}
|
||||
|
||||
static func main() throws {
|
||||
try geometry()
|
||||
try windowBehavior()
|
||||
try reducedMotion()
|
||||
try rememberedSize()
|
||||
try continuousQueueResize()
|
||||
try compactQueue()
|
||||
print("Compact window checks passed")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user