mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-03-24 18:31:22 +01:00
test(wm): add cycle window tests
Added a test for the cycle_window_in_direction function. The function is tested by creating 3 windows and cycling in both the next a previous direction. The test will ensure that the windows were cycled by checking the window index to ensure it is the expected window. Created a test for cycling the window by index. This test is similar to the other cycle window test and performs the same steps as that one, except it uses the test_cycle_container_index_in_direction function instead.
This commit is contained in:
@@ -4312,6 +4312,147 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cycle_container_window_in_direction() {
|
||||
let (mut wm, _context) = setup_window_manager();
|
||||
|
||||
{
|
||||
let mut m = monitor::new(
|
||||
0,
|
||||
Rect::default(),
|
||||
Rect::default(),
|
||||
"TestMonitor".to_string(),
|
||||
"TestDevice".to_string(),
|
||||
"TestDeviceID".to_string(),
|
||||
Some("TestMonitorID".to_string()),
|
||||
);
|
||||
|
||||
let workspace = m.focused_workspace_mut().unwrap();
|
||||
|
||||
{
|
||||
let mut container = Container::default();
|
||||
|
||||
for i in 0..3 {
|
||||
container.windows_mut().push_back(Window::from(i));
|
||||
}
|
||||
|
||||
// Should have 3 windows in the container
|
||||
assert_eq!(container.windows().len(), 3);
|
||||
|
||||
// Add container to workspace
|
||||
workspace.add_container_to_back(container);
|
||||
}
|
||||
|
||||
// Add monitor to the window manager
|
||||
wm.monitors_mut().push_back(m);
|
||||
}
|
||||
|
||||
// Cycle to the next window
|
||||
wm.cycle_container_window_in_direction(CycleDirection::Next)
|
||||
.ok();
|
||||
|
||||
{
|
||||
// Should be on Window 1
|
||||
let workspace = wm.focused_workspace_mut().unwrap();
|
||||
let container = workspace.focused_container_mut().unwrap();
|
||||
println!("Window: {:?}", container.focused_window());
|
||||
assert_eq!(container.focused_window_idx(), 1);
|
||||
}
|
||||
|
||||
// Cycle to the next window
|
||||
wm.cycle_container_window_in_direction(CycleDirection::Next)
|
||||
.ok();
|
||||
|
||||
{
|
||||
// Should be on Window 2
|
||||
let workspace = wm.focused_workspace_mut().unwrap();
|
||||
let container = workspace.focused_container_mut().unwrap();
|
||||
println!("Window: {:?}", container.focused_window());
|
||||
assert_eq!(container.focused_window_idx(), 2);
|
||||
}
|
||||
|
||||
// Cycle to the previous window
|
||||
wm.cycle_container_window_in_direction(CycleDirection::Previous)
|
||||
.ok();
|
||||
|
||||
{
|
||||
// Should be on Window 1
|
||||
let workspace = wm.focused_workspace_mut().unwrap();
|
||||
let container = workspace.focused_container_mut().unwrap();
|
||||
println!("Window: {:?}", container.focused_window());
|
||||
assert_eq!(container.focused_window_idx(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cycle_container_window_index_in_direction() {
|
||||
let (mut wm, _context) = setup_window_manager();
|
||||
|
||||
{
|
||||
let mut m = monitor::new(
|
||||
0,
|
||||
Rect::default(),
|
||||
Rect::default(),
|
||||
"TestMonitor".to_string(),
|
||||
"TestDevice".to_string(),
|
||||
"TestDeviceID".to_string(),
|
||||
Some("TestMonitorID".to_string()),
|
||||
);
|
||||
|
||||
let workspace = m.focused_workspace_mut().unwrap();
|
||||
|
||||
{
|
||||
let mut container = Container::default();
|
||||
|
||||
for i in 0..3 {
|
||||
container.windows_mut().push_back(Window::from(i));
|
||||
}
|
||||
|
||||
// Should have 3 windows in the container
|
||||
assert_eq!(container.windows().len(), 3);
|
||||
|
||||
// Add container to workspace
|
||||
workspace.add_container_to_back(container);
|
||||
}
|
||||
|
||||
// Add monitor to the window manager
|
||||
wm.monitors_mut().push_back(m);
|
||||
}
|
||||
|
||||
// Cycle to the next window
|
||||
wm.cycle_container_window_index_in_direction(CycleDirection::Next)
|
||||
.ok();
|
||||
|
||||
{
|
||||
// Should be on Window 1
|
||||
let workspace = wm.focused_workspace_mut().unwrap();
|
||||
let container = workspace.focused_container_mut().unwrap();
|
||||
assert_eq!(container.focused_window_idx(), 1);
|
||||
}
|
||||
|
||||
// Cycle to the next window
|
||||
wm.cycle_container_window_index_in_direction(CycleDirection::Next)
|
||||
.ok();
|
||||
|
||||
{
|
||||
// Should be on Window 2
|
||||
let workspace = wm.focused_workspace_mut().unwrap();
|
||||
let container = workspace.focused_container_mut().unwrap();
|
||||
assert_eq!(container.focused_window_idx(), 2);
|
||||
}
|
||||
|
||||
// Cycle to the Previous window
|
||||
wm.cycle_container_window_index_in_direction(CycleDirection::Previous)
|
||||
.ok();
|
||||
|
||||
{
|
||||
// Should be on Window 1
|
||||
let workspace = wm.focused_workspace_mut().unwrap();
|
||||
let container = workspace.focused_container_mut().unwrap();
|
||||
assert_eq!(container.focused_window_idx(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_swap_containers() {
|
||||
let (mut wm, _context) = setup_window_manager();
|
||||
|
||||
Reference in New Issue
Block a user