Skip to content

Commit 6a5ad20

Browse files
committed
test(desktop): simplify Linux PNG compression assertions
1 parent 59e9c48 commit 6a5ad20

2 files changed

Lines changed: 6 additions & 16 deletions

File tree

‎native/hyprland-snap-shot/src/transport_tests.rs‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,6 @@ impl Dispatch<Frame, ()> for State {
349349
}
350350
}
351351

352-
/// FLEVEL from the IDAT zlib header: 1 for levels 2-5, 2 for the slow default level 6.
353-
const FAST_ZLIB_LEVEL: u8 = 1;
354-
fn zlib_level(png: &[u8]) -> u8 {
355-
let idat = png.windows(4).position(|tag| tag == b"IDAT").unwrap();
356-
png[idat + 5] >> 6
357-
}
358-
359352
#[test]
360353
fn exports_exact_window_over_real_fd_transport() {
361354
let (fixture, connection) = Fixture::start(Mode::Success);
@@ -371,7 +364,9 @@ fn exports_exact_window_over_real_fd_transport() {
371364
reader.next_frame(&mut pixels).unwrap();
372365
assert_eq!(pixels, [10, 20, 30, 255, 40, 50, 60, 255]);
373366
let png = std::fs::read(directory.path().join("capture.png")).unwrap();
374-
assert_eq!(zlib_level(&png), FAST_ZLIB_LEVEL);
367+
let idat = png.windows(4).position(|tag| tag == b"IDAT").unwrap();
368+
// zlib FLEVEL 1 selects levels 2-5; the slow default level 6 reports 2.
369+
assert_eq!(png[idat + 5] >> 6, 1);
375370
}
376371
#[test]
377372
fn failed_export_produces_no_image_and_no_second_capture() {

‎native/kde-snap-shot/src/transport_tests.rs‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,6 @@ impl Drop for Fixture {
206206
}
207207
}
208208

209-
/// FLEVEL from the IDAT zlib header: 1 for levels 2-5, 2 for the slow default level 6.
210-
const FAST_ZLIB_LEVEL: u8 = 1;
211-
fn zlib_level(png: &[u8]) -> u8 {
212-
let idat = png.windows(4).position(|tag| tag == b"IDAT").unwrap();
213-
png[idat + 5] >> 6
214-
}
215-
216209
#[test]
217210
fn permission_probe_never_captures_and_rejects_denial() {
218211
let f = Fixture::new();
@@ -255,7 +248,9 @@ fn captures_pinned_window_through_real_fd_and_cleans_scripts() {
255248
decoder.next_frame(&mut pixels).unwrap();
256249
assert_eq!(pixels, [0x11, 0x22, 0x33, 255, 0x44, 0x55, 0x66, 255]);
257250
let png = std::fs::read(f.directory.join("capture.png")).unwrap();
258-
assert_eq!(zlib_level(&png), FAST_ZLIB_LEVEL);
251+
let idat = png.windows(4).position(|tag| tag == b"IDAT").unwrap();
252+
// zlib FLEVEL 1 selects levels 2-5; the slow default level 6 reports 2.
253+
assert_eq!(png[idat + 5] >> 6, 1);
259254
}
260255

261256
#[test]

0 commit comments

Comments
 (0)