Skip to content

Commit 5e308b9

Browse files
SaucePacketsLGUG2Z
authored andcommitted
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.
1 parent 1bf53b8 commit 5e308b9

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

komorebi/src/window_manager.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5534,4 +5534,43 @@ mod tests {
55345534
}
55355535
}
55365536
}
5537+
5538+
#[test]
5539+
fn test_add_window_handle_to_move_based_on_workspace_rule() {
5540+
let (wm, _context) = setup_window_manager();
5541+
5542+
// Mock Data representing a window and its workspace/movement details
5543+
let window_title = String::from("TestWindow");
5544+
let hwnd = 12345;
5545+
let origin_monitor_idx = 0;
5546+
let origin_workspace_idx = 0;
5547+
let target_monitor_idx = 2;
5548+
let target_workspace_idx = 3;
5549+
let floating = false;
5550+
5551+
// Empty vector to hold workspace rule enforcement operations
5552+
let mut to_move: Vec<EnforceWorkspaceRuleOp> = Vec::new();
5553+
5554+
// Call the function to add a window movement operation based on workspace rules
5555+
wm.add_window_handle_to_move_based_on_workspace_rule(
5556+
&window_title,
5557+
hwnd,
5558+
origin_monitor_idx,
5559+
origin_workspace_idx,
5560+
target_monitor_idx,
5561+
target_workspace_idx,
5562+
floating,
5563+
&mut to_move,
5564+
);
5565+
5566+
// Verify that the vector contains the expected operation with the correct values
5567+
assert_eq!(to_move.len(), 1);
5568+
let op = &to_move[0];
5569+
assert_eq!(op.hwnd, hwnd); // 12345
5570+
assert_eq!(op.origin_monitor_idx, origin_monitor_idx); // 0
5571+
assert_eq!(op.origin_workspace_idx, origin_workspace_idx); // 0
5572+
assert_eq!(op.target_monitor_idx, target_monitor_idx); // 2
5573+
assert_eq!(op.target_workspace_idx, target_workspace_idx); // 3
5574+
assert_eq!(op.floating, floating); // false
5575+
}
55375576
}

0 commit comments

Comments
 (0)