From f68a709f1d5994879bf5463b98eb137fb46a23bf Mon Sep 17 00:00:00 2001 From: Jerry Kingsbury Date: Wed, 28 May 2025 16:51:18 -0500 Subject: [PATCH] test(wm): float nonexistent window Created a test to test trying to float a nonexistent window. The test ensures that we receive an error when trying to float a window in an empty container --- komorebi/src/window_manager.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 12228248..2b702d78 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -5548,6 +5548,40 @@ mod tests { } } + #[test] + fn test_float_nonexistent_window() { + 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); + } + + // Should return an error when trying to float a non-existent window + let result = wm.float_window(); + assert!( + result.is_err(), + "Expected an error when trying to float a non-existent window" + ); + } + #[test] fn test_maximize_and_unmaximize_window() { let (mut wm, _context) = setup_window_manager();