aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-12-04 22:08:47 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-12-07 19:38:48 +0300
commit396089ef0e9c8722876d5ed870021ddbce4ae31f (patch)
treecd166e326ccfdbd473741cae9473a313006117e4
parentdf98b5021db6dc4a6d776da8ba8884f4290a2584 (diff)
downloadniri-396089ef0e9c8722876d5ed870021ddbce4ae31f.tar.gz
niri-396089ef0e9c8722876d5ed870021ddbce4ae31f.tar.bz2
niri-396089ef0e9c8722876d5ed870021ddbce4ae31f.zip
layout: Extract Tile::verify_invariants()
-rw-r--r--src/layout/scrolling.rs9
-rw-r--r--src/layout/tile.rs11
2 files changed, 12 insertions, 8 deletions
diff --git a/src/layout/scrolling.rs b/src/layout/scrolling.rs
index 124a61db..8434c0fd 100644
--- a/src/layout/scrolling.rs
+++ b/src/layout/scrolling.rs
@@ -3772,8 +3772,6 @@ impl<W: LayoutElement> Column<W> {
#[cfg(test)]
fn verify_invariants(&self) {
- use approx::assert_abs_diff_eq;
-
assert!(!self.tiles.is_empty(), "columns can't be empty");
assert!(self.active_tile_idx < self.tiles.len());
assert_eq!(self.tiles.len(), self.data.len());
@@ -3800,17 +3798,12 @@ impl<W: LayoutElement> Column<W> {
assert_eq!(self.clock, tile.clock);
assert_eq!(self.scale, tile.scale());
assert_eq!(self.is_fullscreen, tile.window().is_pending_fullscreen());
+ tile.verify_invariants();
let mut data2 = *data;
data2.update(tile);
assert_eq!(data, &data2, "tile data must be up to date");
- let scale = tile.scale();
- let size = tile.tile_size();
- let rounded = size.to_physical_precise_round(scale).to_logical(scale);
- assert_abs_diff_eq!(size.w, rounded.w, epsilon = 1e-5);
- assert_abs_diff_eq!(size.h, rounded.h, epsilon = 1e-5);
-
if matches!(data.height, WindowHeight::Fixed(_)) {
assert!(
!found_fixed,
diff --git a/src/layout/tile.rs b/src/layout/tile.rs
index 6646999f..83080870 100644
--- a/src/layout/tile.rs
+++ b/src/layout/tile.rs
@@ -922,4 +922,15 @@ impl<W: LayoutElement> Tile<W> {
pub fn take_unmap_snapshot(&mut self) -> Option<TileRenderSnapshot> {
self.unmap_snapshot.take()
}
+
+ #[cfg(test)]
+ pub fn verify_invariants(&self) {
+ use approx::assert_abs_diff_eq;
+
+ let scale = self.scale;
+ let size = self.tile_size();
+ let rounded = size.to_physical_precise_round(scale).to_logical(scale);
+ assert_abs_diff_eq!(size.w, rounded.w, epsilon = 1e-5);
+ assert_abs_diff_eq!(size.h, rounded.h, epsilon = 1e-5);
+ }
}