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> {
37723772
37733773 #[cfg(test)]
37743774 fn verify_invariants(&self) {
3775- use approx::assert_abs_diff_eq;
3776-
37773775 assert!(!self.tiles.is_empty(), "columns can't be empty");
37783776 assert!(self.active_tile_idx < self.tiles.len());
37793777 assert_eq!(self.tiles.len(), self.data.len());
@@ -3800,17 +3798,12 @@ impl<W: LayoutElement> Column<W> {
38003798 assert_eq!(self.clock, tile.clock);
38013799 assert_eq!(self.scale, tile.scale());
38023800 assert_eq!(self.is_fullscreen, tile.window().is_pending_fullscreen());
3801+ tile.verify_invariants();
38033802
38043803 let mut data2 = *data;
38053804 data2.update(tile);
38063805 assert_eq!(data, &data2, "tile data must be up to date");
38073806
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-
38143807 if matches!(data.height, WindowHeight::Fixed(_)) {
38153808 assert!(
38163809 !found_fixed,
src/layout/tile.rsmodified+11 -0
@@ -922,4 +922,15 @@ impl<W: LayoutElement> Tile<W> {
922922 pub fn take_unmap_snapshot(&mut self) -> Option<TileRenderSnapshot> {
923923 self.unmap_snapshot.take()
924924 }
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+ }
925936 }