layout: Extract Tile::verify_invariants()
Browse files at this commit396089ef0e9c8722876d5ed870021ddbce4ae31fParent: df98b502 changed files +12 -8
- src/layout/scrolling.rs +1 -8
- src/layout/tile.rs +11 -0
src/layout/scrolling.rsmodified+1 -8
| @@ -3772,8 +3772,6 @@ impl<W: LayoutElement> Column<W> { | ||
| 3772 | 3772 | |
| 3773 | 3773 | #[cfg(test)] |
| 3774 | 3774 | fn verify_invariants(&self) { |
| 3775 | - use approx::assert_abs_diff_eq; | |
| 3776 | - | |
| 3777 | 3775 | assert!(!self.tiles.is_empty(), "columns can't be empty"); |
| 3778 | 3776 | assert!(self.active_tile_idx < self.tiles.len()); |
| 3779 | 3777 | assert_eq!(self.tiles.len(), self.data.len()); |
| @@ -3800,17 +3798,12 @@ impl<W: LayoutElement> Column<W> { | ||
| 3800 | 3798 | assert_eq!(self.clock, tile.clock); |
| 3801 | 3799 | assert_eq!(self.scale, tile.scale()); |
| 3802 | 3800 | assert_eq!(self.is_fullscreen, tile.window().is_pending_fullscreen()); |
| 3801 | + tile.verify_invariants(); | |
| 3803 | 3802 | |
| 3804 | 3803 | let mut data2 = *data; |
| 3805 | 3804 | data2.update(tile); |
| 3806 | 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 | 3807 | if matches!(data.height, WindowHeight::Fixed(_)) { |
| 3815 | 3808 | assert!( |
| 3816 | 3809 | !found_fixed, |
src/layout/tile.rsmodified+11 -0
| @@ -922,4 +922,15 @@ impl<W: LayoutElement> Tile<W> { | ||
| 922 | 922 | pub fn take_unmap_snapshot(&mut self) -> Option<TileRenderSnapshot> { |
| 923 | 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 | } |