Skip to content

Commit e203a44

Browse files
committed
revert(nsview): use layoutSubtreeIfNeeded
This reverts commit 26e915d. Because it breaks recursiveDescription test
1 parent 55fbc66 commit e203a44

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Sources/SnapshotTesting/Snapshotting/NSView.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ extension Snapshotting where Value == NSView, Format == NSImage {
3131

3232
let initialFrame = view.frame
3333
if let size = size { view.frame.size = size }
34-
view.layoutSubtreeIfNeeded()
3534
guard view.frame.width > 0, view.frame.height > 0 else {
3635
fatalError("View not renderable to image at size \(view.frame.size)")
3736
}
@@ -73,8 +72,11 @@ extension Snapshotting where Value == NSView, Format == NSImage {
7372

7473
}
7574

76-
// This is to maintain compatibility with `recursiveDescription`
77-
view.layoutSubtreeIfNeeded()
75+
// This is to maintain compatibility with `recursiveDescription` because the current
76+
// test snapshots expect `.needsLayout = false` and for some apple magic reason
77+
// `view.needsLayout = false` does not do anything, but this does.
78+
let bitmapRep2 = view.bitmapImageRepForCachingDisplay(in: view.bounds)!
79+
view.cacheDisplay(in: view.bounds, to: bitmapRep2)
7880
}
7981

8082
}

0 commit comments

Comments
 (0)