test(webp): cover lossy alpha container and XMP framing

This commit is contained in:
Dylan M. Taylor
2026-11-15 03:26:23 -05:00
parent ec53d5d399
commit 80d4e2395e
+17
View File
@@ -230,6 +230,23 @@ mod tests {
assert_eq!(&file[anim + 8..anim + 14], &[1, 2, 3, 4, 0, 0]);
}
#[test]
fn lossy_container_keeps_alpha_payload_padding_and_xmp() {
// Container-only fixture: the writer must not reinterpret an encoder's VP8 bytes.
let vp8 = [11, 22, 33];
let alpha = [128];
let f = frame(Payload::Lossy { vp8: &vp8, alpha: Some(&alpha) }, 0, 0, 1, 1, 17);
let file = animation(1, 1, &[f], &AnimOptions { xmp: Some(b"xmp"), ..Default::default() }).unwrap();
let info = scan(&file, 10).unwrap();
assert!(info.alpha && info.complete);
assert_eq!(info.frames[0].duration_ms, 17);
let at = file.windows(4).position(|c| c == b"ANMF").unwrap();
let payload = at + 8 + 16;
assert_eq!(&file[payload..payload + 10], &[b'A', b'L', b'P', b'H', 2, 0, 0, 0, 0, 128]);
assert_eq!(&file[payload + 10..payload + 22], &[b'V', b'P', b'8', b' ', 3, 0, 0, 0, 11, 22, 33, 0]);
assert_eq!(&file[file.len() - 12..], &[b'X', b'M', b'P', b' ', 3, 0, 0, 0, b'x', b'm', b'p', 0]);
}
#[test]
fn what_does_not_fit_is_refused() {
let px = vp8l(2, 2, [0; 4]);