Skip to content

Commit bfdda52

Browse files
SaucePacketsLGUG2Z
authored andcommitted
test(window_manager.rs): test monocle on and off on nonexistent container
Created a test that tests moving a nonexistent container to monocle and retreiving a nonexistent container from monocle. The test ensures we receive an error when attempting to use monocle_on or monocle_off when a container doesn't exist.
1 parent 6fcecd7 commit bfdda52

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

komorebi/src/window_manager.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5834,6 +5834,41 @@ mod tests {
58345834
}
58355835
}
58365836

5837+
#[test]
5838+
fn test_monocle_on_and_off_nonexistent_container() {
5839+
let (mut wm, _context) = setup_window_manager();
5840+
5841+
{
5842+
// Create a monitor
5843+
let m = monitor::new(
5844+
0,
5845+
Rect::default(),
5846+
Rect::default(),
5847+
"TestMonitor".to_string(),
5848+
"TestDevice".to_string(),
5849+
"TestDeviceID".to_string(),
5850+
Some("TestMonitorID".to_string()),
5851+
);
5852+
5853+
// Add monitor to the window manager
5854+
wm.monitors_mut().push_back(m);
5855+
}
5856+
5857+
// Should return an error when trying to move a non-existent container to monocle
5858+
let result = wm.monocle_on();
5859+
assert!(
5860+
result.is_err(),
5861+
"Expected an error when trying to move a non-existent container to monocle"
5862+
);
5863+
5864+
// Should return an error when trying to restore a non-existent container from monocle
5865+
let result = wm.monocle_off();
5866+
assert!(
5867+
result.is_err(),
5868+
"Expected an error when trying to restore a non-existent container from monocle"
5869+
);
5870+
}
5871+
58375872
#[test]
58385873
fn test_toggle_monocle() {
58395874
let (mut wm, _context) = setup_window_manager();

0 commit comments

Comments
 (0)