mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-16 22:01:22 +01:00
test(ghost): what a Mac can say about a ghost tile, beyond the obvious
A Mac recording has no probe to read: a ghost tile there is found from the frames komorebi read, so what counts as a frame no one can see matters more than it does on Windows, and only the plain cases were held. Added, with a Mac state of two displays, the second at negative coordinates as a display arranged to the left of the main one is: - a window filling the left display is not outside every display, and the same shape past its edge is - one read of a frame no one can see is not enough, and two are - a window on a workspace the display is not showing is not a ghost - nothing is while komorebi is paused The tests take their states from the session fixture and nothing from the host, so they run on Windows as well as on a Mac: checked to type-check there (just check-windows), not run.
This commit is contained in:
1 parent
93189eeb15
commit
d79ef03f21
1 file changed
+101
@@ -687,6 +687,107 @@ mod tests {
|
||||
assert!(found.is_empty(), "{found:#?}");
|
||||
}
|
||||
|
||||
/// A Mac with two displays, the second to the left of the main one (so at negative
|
||||
/// coordinates, as a Mac puts a display arranged that way), and one window in a tile on the
|
||||
/// second with the frame given. `showing` is whether the workspace that has it is the one the
|
||||
/// display shows; `paused` is komorebi's pause.
|
||||
fn two_displays(frame: [i64; 4], showing: bool, paused: bool) -> serde_json::Value {
|
||||
use crate::testkit::container;
|
||||
use crate::testkit::monitor;
|
||||
use crate::testkit::state;
|
||||
use crate::testkit::window;
|
||||
use crate::testkit::workspace;
|
||||
|
||||
let main = monitor(
|
||||
1,
|
||||
[0, 0, 1000, 800],
|
||||
vec![workspace("main", Vec::new(), 0, &[])],
|
||||
0,
|
||||
);
|
||||
let left = monitor(
|
||||
2,
|
||||
[-1000, 0, 1000, 800],
|
||||
vec![
|
||||
workspace(
|
||||
"away",
|
||||
vec![container("c7", vec![window(7, "Safari", Some(frame))])],
|
||||
0,
|
||||
&[[-1000, 0, 1000, 800]],
|
||||
),
|
||||
workspace("here", Vec::new(), 0, &[]),
|
||||
],
|
||||
usize::from(!showing),
|
||||
);
|
||||
let mut value = state(vec![main, left], 0);
|
||||
value["is_paused"] = json!(paused);
|
||||
value
|
||||
}
|
||||
|
||||
fn two_display_ghosts(name: &str, frames: &[[i64; 4]], showing: bool, paused: bool) -> usize {
|
||||
let mut builder = SessionBuilder::new(name);
|
||||
for (index, frame) in frames.iter().enumerate() {
|
||||
builder = builder.event(
|
||||
2.0 + index as f64,
|
||||
json!({"type": "Retile"}),
|
||||
Some(two_displays(*frame, showing, paused)),
|
||||
);
|
||||
}
|
||||
let (session, _) = builder.build();
|
||||
Analysis::open(&session.dir)
|
||||
.expect("open")
|
||||
.ghost_tiles()
|
||||
.expect("ghost tiles")
|
||||
.len()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn on_a_mac_a_window_on_a_display_at_negative_coordinates_can_be_seen() {
|
||||
// the whole of the left display: nothing about it is outside every display
|
||||
let on_it = [-1000, 0, 1000, 800];
|
||||
assert_eq!(
|
||||
two_display_ghosts("ghost-mac-left", &[on_it, on_it, on_it], true, false),
|
||||
0
|
||||
);
|
||||
|
||||
// the same shape, beyond the left display's edge, is outside all of them
|
||||
let past_it = [-3000, 0, 1000, 800];
|
||||
assert_eq!(
|
||||
two_display_ghosts("ghost-mac-past", &[past_it, past_it, past_it], true, false),
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn on_a_mac_one_read_is_not_enough_to_call_a_tile_a_ghost() {
|
||||
let nowhere = [0, 0, 0, 0];
|
||||
assert_eq!(
|
||||
two_display_ghosts("ghost-mac-once", &[nowhere], true, false),
|
||||
0
|
||||
);
|
||||
assert_eq!(
|
||||
two_display_ghosts("ghost-mac-twice", &[nowhere, nowhere], true, false),
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn on_a_mac_a_window_of_a_workspace_that_is_not_showing_is_not_a_ghost() {
|
||||
let nowhere = [0, 0, 0, 0];
|
||||
assert_eq!(
|
||||
two_display_ghosts("ghost-mac-hidden-workspace", &[nowhere; 3], false, false),
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn on_a_mac_nothing_is_a_ghost_while_komorebi_is_paused() {
|
||||
let nowhere = [0, 0, 0, 0];
|
||||
assert_eq!(
|
||||
two_display_ghosts("ghost-mac-paused", &[nowhere; 3], true, true),
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_ghost_is_about_a_bug_that_was_marked_while_it_was_there() {
|
||||
let ghost = GhostTile {
|
||||
|
||||
Reference in new issue
Block a user