26 lines
1.1 KiB
Swift
26 lines
1.1 KiB
Swift
import AppKit
|
|
import Testing
|
|
@testable import Conjure
|
|
|
|
@Test @MainActor
|
|
func launcherFadesStayAtViewportEdgesAfterScrollingAndResizing() throws {
|
|
_ = NSApplication.shared
|
|
let scroll = LauncherScrollView(frame: NSRect(x: 0, y: 0, width: 200, height: 120))
|
|
scroll.documentView = NSView(frame: NSRect(x: 0, y: 0, width: 200, height: 600))
|
|
for height in [120, 240] {
|
|
scroll.frame.size.height = CGFloat(height)
|
|
scroll.contentView.scroll(to: NSPoint(x: 0, y: 80))
|
|
scroll.layoutSubtreeIfNeeded()
|
|
let mask = try #require(scroll.layer?.mask)
|
|
let context = try #require(CGContext(data: nil, width: 200, height: height,
|
|
bitsPerComponent: 8, bytesPerRow: 800, space: CGColorSpaceCreateDeviceRGB(),
|
|
bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue))
|
|
mask.render(in: context)
|
|
let pixels = try #require(context.data?.assumingMemoryBound(to: UInt8.self))
|
|
func alpha(_ y: Int) -> UInt8 { pixels[y * 800 + 100 * 4 + 3] }
|
|
#expect(alpha(0) < 20)
|
|
#expect(alpha(height / 2) == 255)
|
|
#expect(alpha(height - 1) < 20)
|
|
}
|
|
}
|