Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ struct SidebarInsertWhileDisplayAsleepTests {
return (model, sidebar, window)
}

/// A closing row whose completion ran: the list recycled it, which parks it hidden in place
/// (dea9671b35d5/5763d7372701) or, out of the list, takes it out.
private static func recycled(_ row: SidebarRowView) -> Bool { row.superview == nil || row.isHidden }

/// Shows the workspaces `ids` (the selection stays, so new rows open with motion) and
/// returns the last one's row.
private static func show(_ ids: [Int], in model: SidebarModel, _ sidebar: SidebarView) throws -> SidebarRowView {
Expand Down Expand Up @@ -88,7 +92,7 @@ struct SidebarInsertWhileDisplayAsleepTests {
let opening = try Self.show([1, 3, 4], in: model, sidebar)
let shown = Set(list.rowViews.values.map(ObjectIdentifier.init))
let leaving = list.subviews.compactMap { $0 as? SidebarRowView }
.filter { before.contains(ObjectIdentifier($0)) && !shown.contains(ObjectIdentifier($0)) }
.filter { before.contains(ObjectIdentifier($0)) && !shown.contains(ObjectIdentifier($0)) && !Self.recycled($0) }
try #require(opening.alphaValue < 1, "the new row appeared in one frame with the display awake")
try #require(leaving.count == 1, "the removed row did not stay to close its slot")

Expand All @@ -100,7 +104,7 @@ struct SidebarInsertWhileDisplayAsleepTests {
// No frame draws from here: what was moving must be final now.
#expect(opening.alphaValue == 1, "the opening row stopped at alpha \(opening.alphaValue)")
#expect(opening.frame.height > 0, "the opening row stopped at height \(opening.frame.height)")
#expect(leaving.allSatisfy { $0.superview == nil }, "the closing row stays in the list: its completion never ran")
#expect(leaving.allSatisfy(Self.recycled), "the closing row stays in the list: its completion never ran")
}

/// A change replayed at sleep never puts back what a newer reload changed: here the rows a
Expand Down Expand Up @@ -155,12 +159,12 @@ struct SidebarInsertWhileDisplayAsleepTests {
_ = try Self.show([1, 3], in: model, sidebar)
let shown = Set(list.rowViews.values.map(ObjectIdentifier.init))
let leaving = list.subviews.compactMap { $0 as? SidebarRowView }
.filter { before.contains(ObjectIdentifier($0)) && !shown.contains(ObjectIdentifier($0)) }
.filter { before.contains(ObjectIdentifier($0)) && !shown.contains(ObjectIdentifier($0)) && !Self.recycled($0) }
try #require(leaving.count == 1, "the removed row did not stay to close its slot")
_ = try Self.show([1, 3, 4], in: model, sidebar)

try await Task.sleep(for: .seconds(1.5))
#expect(leaving.allSatisfy { $0.superview == nil }, "the closed row stays in the list: its completion was dropped")
#expect(leaving.allSatisfy(Self.recycled), "the closed row stays in the list: its completion was dropped")
}

/// The look with the display awake is unchanged: the new row still opens with motion.
Expand Down
Loading