test(wm): move workspace to non existent monitor

Created a test for moving the focused workspace to a monitor that hasn't
been created. The test ensures that we receive an error when moving a
workspace to a monitor that doesn't exist.
This commit is contained in:
Jerry Kingsbury
2025-05-05 17:11:57 -05:00
committed by LGUG2Z
parent 80bce4be7e
commit 76c833f661

View File

@@ -4968,7 +4968,7 @@ mod tests {
// Should have 2 workspaces
assert_eq!(m.workspaces().len(), 2);
// Add monitor to workspace
// Add monitor to window manager
wm.monitors_mut().push_back(m);
}
@@ -5015,6 +5015,42 @@ mod tests {
}
}
#[test]
fn test_move_workspace_to_nonexistent_monitor() {
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()),
);
// Add another workspace
let new_workspace_index = m.new_workspace_idx();
m.focus_workspace(new_workspace_index).unwrap();
// Should have 2 workspaces
assert_eq!(m.workspaces().len(), 2);
// Add monitor to window manager
wm.monitors_mut().push_back(m);
}
// Attempt to move a workspace to a non-existent monitor
let result = wm.move_workspace_to_monitor(1);
// Should be an error since Monitor 1 does not exist
assert!(
result.is_err(),
"Expected an error when moving to a non-existent monitor"
);
}
#[test]
fn test_toggle_tiling() {
let (mut wm, _context) = setup_window_manager();