forge
Explore
Log in

Don't you dare go Hollow

layout: Extract Tile::verify_invariants()

Browse files at this commit

396089ef0e9c8722876d5ed870021ddbce4ae31fIvan MolodetskikhParent: df98b50
src/layout/scrolling.rsmodified+1 -8
@@ -3772,8 +3772,6 @@ impl<W: LayoutElement> Column<W> {
3772 3772
3773 #[cfg(test)]3773 #[cfg(test)]
3774 fn verify_invariants(&self) {3774 fn verify_invariants(&self) {
3775- use approx::assert_abs_diff_eq;
3776-
3777 assert!(!self.tiles.is_empty(), "columns can't be empty");3775 assert!(!self.tiles.is_empty(), "columns can't be empty");
3778 assert!(self.active_tile_idx < self.tiles.len());3776 assert!(self.active_tile_idx < self.tiles.len());
3779 assert_eq!(self.tiles.len(), self.data.len());3777 assert_eq!(self.tiles.len(), self.data.len());
@@ -3800,17 +3798,12 @@ impl<W: LayoutElement> Column<W> {
3800 assert_eq!(self.clock, tile.clock);3798 assert_eq!(self.clock, tile.clock);
3801 assert_eq!(self.scale, tile.scale());3799 assert_eq!(self.scale, tile.scale());
3802 assert_eq!(self.is_fullscreen, tile.window().is_pending_fullscreen());3800 assert_eq!(self.is_fullscreen, tile.window().is_pending_fullscreen());
3801+ tile.verify_invariants();
3803 3802
3804 let mut data2 = *data;3803 let mut data2 = *data;
3805 data2.update(tile);3804 data2.update(tile);
3806 assert_eq!(data, &data2, "tile data must be up to date");3805 assert_eq!(data, &data2, "tile data must be up to date");
3807 3806
3808- let scale = tile.scale();
3809- let size = tile.tile_size();
3810- let rounded = size.to_physical_precise_round(scale).to_logical(scale);
3811- assert_abs_diff_eq!(size.w, rounded.w, epsilon = 1e-5);
3812- assert_abs_diff_eq!(size.h, rounded.h, epsilon = 1e-5);
3813-
3814 if matches!(data.height, WindowHeight::Fixed(_)) {3807 if matches!(data.height, WindowHeight::Fixed(_)) {
3815 assert!(3808 assert!(
3816 !found_fixed,3809 !found_fixed,
src/layout/tile.rsmodified+11 -0
@@ -922,4 +922,15 @@ impl<W: LayoutElement> Tile<W> {
922 pub fn take_unmap_snapshot(&mut self) -> Option<TileRenderSnapshot> {922 pub fn take_unmap_snapshot(&mut self) -> Option<TileRenderSnapshot> {
923 self.unmap_snapshot.take()923 self.unmap_snapshot.take()
924 }924 }
925+
926+ #[cfg(test)]
927+ pub fn verify_invariants(&self) {
928+ use approx::assert_abs_diff_eq;
929+
930+ let scale = self.scale;
931+ let size = self.tile_size();
932+ let rounded = size.to_physical_precise_round(scale).to_logical(scale);
933+ assert_abs_diff_eq!(size.w, rounded.w, epsilon = 1e-5);
934+ assert_abs_diff_eq!(size.h, rounded.h, epsilon = 1e-5);
935+ }
925 }936 }