mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-03-25 10:51:39 +01:00
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.
This commit is contained in:
@@ -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<EnforceWorkspaceRuleOp> = 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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user