use super::*;
#[test]
fn portal_crop_maps_logical_bounds_to_screenshot_pixels() {
let mut image = image::RgbaImage::new(100, 50);
image.put_pixel(20, 10, image::Rgba([1, 2, 3, 4]));
let cropped = crop_portal_screenshot_to_region(image, Rect::new(0.0, 0.0, 200.0, 100.0), Rect::new(40.0, 20.0, 20.0, 20.0))
.expect("portal crop maps through source bounds");
assert_eq!(cropped.width(), 10);
assert_eq!(cropped.height(), 10);
assert_eq!(*cropped.get_pixel(0, 0), image::Rgba([1, 2, 3, 4]));
}
#[test]
fn fallback_failure_preserves_the_primary_capture_error() {
let primary = backend("screencast timed out");
let error = capture_fallback::<()>("portal.screencast", &primary, || Err(backend("screenshot returned no URI")))
.expect_err("both capture paths fail");
assert_eq!(error.to_string(), "portal.screencast failed: screencast timed out; fallback capture also failed: screenshot returned no URI");
}