From 5e308b9131983116f89cf5610821c3dbdfa574d6 Mon Sep 17 00:00:00 2001 From: Jerry Kingsbury Date: Thu, 17 Apr 2025 22:02:06 -0500 Subject: [PATCH] test(wm): add window handle to move based on workspace rules test Created a simple test for the add_window_handle_to_move_based_on_workspace_rules function. The test creates mock data representing window and the movement details. The test will call the function with an empty vector to hold the workspace rules and then check that the workspace rules are in the vector. --- komorebi/src/window_manager.rs | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index 116f9a17..99399021 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -5534,4 +5534,43 @@ mod tests { } } } + + #[test] + fn test_add_window_handle_to_move_based_on_workspace_rule() { + let (wm, _context) = setup_window_manager(); + + // Mock Data representing a window and its workspace/movement details + let window_title = String::from("TestWindow"); + let hwnd = 12345; + let origin_monitor_idx = 0; + let origin_workspace_idx = 0; + let target_monitor_idx = 2; + let target_workspace_idx = 3; + let floating = false; + + // Empty vector to hold workspace rule enforcement operations + let mut to_move: Vec = Vec::new(); + + // Call the function to add a window movement operation based on workspace rules + wm.add_window_handle_to_move_based_on_workspace_rule( + &window_title, + hwnd, + origin_monitor_idx, + origin_workspace_idx, + target_monitor_idx, + target_workspace_idx, + floating, + &mut to_move, + ); + + // Verify that the vector contains the expected operation with the correct values + assert_eq!(to_move.len(), 1); + let op = &to_move[0]; + assert_eq!(op.hwnd, hwnd); // 12345 + assert_eq!(op.origin_monitor_idx, origin_monitor_idx); // 0 + assert_eq!(op.origin_workspace_idx, origin_workspace_idx); // 0 + assert_eq!(op.target_monitor_idx, target_monitor_idx); // 2 + assert_eq!(op.target_workspace_idx, target_workspace_idx); // 3 + assert_eq!(op.floating, floating); // false + } }