diff --git a/core/src/orientation/pos.rs b/core/src/orientation/pos.rs index ae0cbc5..466022e 100644 --- a/core/src/orientation/pos.rs +++ b/core/src/orientation/pos.rs @@ -421,7 +421,7 @@ impl Display for UiRegion { } } -#[derive(Debug)] +#[derive(Debug, Clone, Copy, PartialEq)] pub struct PixelRegion { pub top_left: Vec2, pub bot_right: Vec2, diff --git a/src/harness.rs b/src/harness.rs index 8e25562..f575df6 100644 --- a/src/harness.rs +++ b/src/harness.rs @@ -22,22 +22,18 @@ impl TaskQueue> for Queue { } } -/// `assert_eq!` for where a frame put a widget, which `PixelRegion` cannot do -/// for itself: it neither compares nor prints. +/// `assert_eq!` for where a frame put a widget, written as its two corners. #[macro_export] macro_rules! assert_corners { - ($harness:expr, $id:expr, ($x0:expr, $y0:expr), ($x1:expr, $y1:expr)) => {{ - let region = $harness.region(&$id).expect("widget drew nothing"); + ($harness:expr, $id:expr, ($x0:expr, $y0:expr), ($x1:expr, $y1:expr)) => { assert_eq!( - ( - region.top_left.x, - region.top_left.y, - region.bot_right.x, - region.bot_right.y - ), - ($x0 as f32, $y0 as f32, $x1 as f32, $y1 as f32) + $harness.region(&$id).expect("widget drew nothing"), + $crate::core::PixelRegion { + top_left: $crate::core::util::Vec2::new($x0 as f32, $y0 as f32), + bot_right: $crate::core::util::Vec2::new($x1 as f32, $y1 as f32), + } ); - }}; + }; } pub use crate::assert_corners;