test(resize): cover the top edge of the lower tile of a BSP layout

Dragging the edge two stacked tiles share moves it by the same amount from
either tile, in the layout and in the window manager. A drag of the top edge
of the lower tile that moves nothing is not for want of this.
This commit is contained in:
LGUG2Z committed 2026-10-30 15:45:37 -07:00
1 parent dc9b2e9539
commit a4e03e3d76
2 files changed
+82

No files matched your search

+31
View File
@@ -1843,3 +1843,34 @@ mod flip_resize_adjacency_tests {
}
}
}
// The edge that win2 and win3 share is moved the same way whichever of the two it is dragged
// from, in a BSP layout with a tile on the left and two stacked on the right
#[test]
fn bsp_shared_edge_moves_the_same_dragged_from_either_tile() {
let area = test_area();
let len = NonZeroUsize::new(3).unwrap();
let layout = |dimensions: &[Option<Rect>]| {
DefaultLayout::BSP.calculate(&area, len, None, None, dimensions, 0, None, &[])
};
let rect = |left, top, right, bottom| Rect {
left,
top,
right,
bottom,
};
let before = layout(&[None, None, None]);
let shared_edge = before[1].top + before[1].bottom;
assert_eq!(shared_edge, before[2].top);
// the bottom edge of the tile above, taken down by 72 (a request of 144, as a shared edge
// is moved by half of what the layout is given)
let from_above = layout(&[None, Some(rect(0, 0, 0, 144)), None]);
assert_eq!(from_above[2].top, shared_edge + 72);
// the top edge of the tile below, taken up by 72
let from_below = layout(&[None, None, Some(rect(0, -144, 0, 0))]);
assert_eq!(from_below[2].top, shared_edge - 72);
assert_eq!(from_below[1].top + from_below[1].bottom, shared_edge - 72);
}
+51
View File
@@ -6077,4 +6077,55 @@ mod tests {
assert_eq!(wm.focused_monitor().unwrap().workspaces().len(), 1);
assert_eq!(wm.focused_workspace().unwrap().containers().len(), 3);
}
/// What dragging the edge that two stacked tiles share, from either of them, gives the
/// tile that is dragged: three tiles laid out as BSP, one on the left and two on the right
fn dragged_dimensions(
focused: usize,
edge: OperationDirection,
sizing: Sizing,
) -> Vec<Option<Rect>> {
let (mut wm, _context) = setup_window_manager();
let area = Rect {
left: 0,
top: 0,
right: 1000,
bottom: 800,
};
let mut monitor = monitor::new(
0,
area,
area,
"TestMonitor".to_string(),
"TestDevice".to_string(),
"TestDeviceID".to_string(),
Some("TestMonitorID".to_string()),
);
let workspace = monitor.focused_workspace_mut().unwrap();
workspace.layout = Layout::Default(DefaultLayout::BSP);
for _ in 0..3 {
workspace.containers_mut().push_back(Container::default());
}
workspace.resize_dimensions = vec![None; 3];
workspace.focus_container(focused);
wm.monitors_mut().push_back(monitor);
wm.resize_window(edge, sizing, 144, false).unwrap();
wm.focused_workspace().unwrap().resize_dimensions.clone()
}
#[test]
fn test_resize_the_top_edge_of_the_lower_tile() {
let dragged_up = dragged_dimensions(2, OperationDirection::Up, Sizing::Increase);
assert!(
dragged_up[2].is_some() || dragged_up[1].is_some(),
"dragging the top edge of the lower tile up changed nothing: {dragged_up:?}"
);
// the same edge from the tile above
let dragged_down = dragged_dimensions(1, OperationDirection::Down, Sizing::Increase);
assert!(dragged_down[1].is_some(), "{dragged_down:?}");
}
}