mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-01 18:51:36 +02:00
test(wm): monocle on and off test
Created a test for the monocle_on and monocle_off functions. The test checks to ensure that the focused workspace container becomes a monocle container when calling the monocle_on function. The test will also ensure that the container is moved to the workspace's container ring when the monocle_off function is called.
This commit is contained in:
@@ -5263,4 +5263,75 @@ mod tests {
|
|||||||
assert_eq!(*maximized_window, None);
|
assert_eq!(*maximized_window, None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_monocle_on_and_monocle_off() {
|
||||||
|
let (mut wm, _context) = setup_window_manager();
|
||||||
|
|
||||||
|
{
|
||||||
|
// Create a monitor
|
||||||
|
let mut m = monitor::new(
|
||||||
|
0,
|
||||||
|
Rect::default(),
|
||||||
|
Rect::default(),
|
||||||
|
"TestMonitor".to_string(),
|
||||||
|
"TestDevice".to_string(),
|
||||||
|
"TestDeviceID".to_string(),
|
||||||
|
Some("TestMonitorID".to_string()),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create a container
|
||||||
|
let mut container = Container::default();
|
||||||
|
|
||||||
|
// Add a window to the container
|
||||||
|
container.windows_mut().push_back(Window::from(1));
|
||||||
|
|
||||||
|
// Should have 1 window in the container
|
||||||
|
assert_eq!(container.windows().len(), 1);
|
||||||
|
|
||||||
|
// Add the container to the workspace
|
||||||
|
let workspace = m.focused_workspace_mut().unwrap();
|
||||||
|
workspace.add_container_to_back(container);
|
||||||
|
|
||||||
|
// Add monitor to the window manager
|
||||||
|
wm.monitors_mut().push_back(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move container to monocle container
|
||||||
|
wm.monocle_on().ok();
|
||||||
|
|
||||||
|
{
|
||||||
|
// Container should be a monocle container
|
||||||
|
let monocle_container = wm
|
||||||
|
.focused_workspace()
|
||||||
|
.unwrap()
|
||||||
|
.monocle_container()
|
||||||
|
.as_ref()
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(monocle_container.windows().len(), 1);
|
||||||
|
assert_eq!(monocle_container.windows()[0].hwnd, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Should not have any containers
|
||||||
|
let container = wm.focused_workspace().unwrap();
|
||||||
|
assert_eq!(container.containers().len(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move monocle container to regular container
|
||||||
|
wm.monocle_off().ok();
|
||||||
|
|
||||||
|
{
|
||||||
|
// Should have 1 container in the workspace
|
||||||
|
let container = wm.focused_workspace().unwrap();
|
||||||
|
assert_eq!(container.containers().len(), 1);
|
||||||
|
assert_eq!(container.containers()[0].windows()[0].hwnd, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// No windows should be in the monocle container
|
||||||
|
let monocle_container = wm.focused_workspace().unwrap().monocle_container();
|
||||||
|
assert_eq!(*monocle_container, None);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user