diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-16 14:46:16 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:14 -0300 |
| commit | 717afaf3177a2e0925b18ae3445119efe808b129 (patch) | |
| tree | 45a2196711de78d8d1e2db6cb5e5c51271676c2f /test/macos_e2e.swift | |
| parent | 7cbd44dd1cfe97126e7fc996214e458525d2980c (diff) | |
| download | pardes-717afaf3177a2e0925b18ae3445119efe808b129.tar.gz pardes-717afaf3177a2e0925b18ae3445119efe808b129.zip | |
Add macOS backdrop blur and preserve PDF ink opacity
Diffstat (limited to 'test/macos_e2e.swift')
| -rw-r--r-- | test/macos_e2e.swift | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/test/macos_e2e.swift b/test/macos_e2e.swift index 5427c3ad..5efc366c 100644 --- a/test/macos_e2e.swift +++ b/test/macos_e2e.swift @@ -687,13 +687,22 @@ private final class Driver: PardesViewDelegate { throw ScriptError(message: "PDF: placement is outside its physical-pixel viewport") } let backing = CGFloat(rep.pixelsWide) / view.bounds.width - var matched = 0 - for fraction in [CGFloat(0.2), 0.4, 0.6, 0.8] { - if let c = rep.colorAt(x: Int((x + width * fraction) * backing), - y: Int((y + height * fraction) * backing)), abs(c.alphaComponent - view.backgroundAlpha) < 2.0 / 255 { matched += 1 } + guard image.paper_bg != UInt32(PARDES_COLOR_DEFAULT) else { + throw ScriptError(message: "PDF: missing separate paper background") } - guard matched == 4 else { throw ScriptError(message: "PDF: raster opacity does not match WindowOpacity") } - output += "== pdf \(label) native page opacity verified\n" + var lowest: CGFloat = 1, highest: CGFloat = 0 + for py in stride(from: Int(y * backing) + 2, to: Int((y + height) * backing) - 2, by: 2) { + for px in stride(from: Int(x * backing) + 2, to: Int((x + width) * backing) - 2, by: 2) { + if let c = rep.colorAt(x: px, y: py) { + lowest = min(lowest, c.alphaComponent) + highest = max(highest, c.alphaComponent) + } + } + } + guard abs(lowest - view.backgroundAlpha) < 2.0 / 255, highest > 0.98 else { + throw ScriptError(message: "PDF: expected translucent paper and opaque ink, got alpha \(lowest)...\(highest)") + } + output += "== pdf \(label) paper opacity and opaque ink verified\n" } // MARK: - the script |
