mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2024-11-16 07:48:11 +01:00
Fix keyboard focus tests
Some checks failed
CI (Pinnacle) / Build (push) Waiting to run
CI (Pinnacle) / Run tests (push) Waiting to run
CI (Pinnacle) / Check formatting (push) Waiting to run
CI (Pinnacle) / Clippy check (push) Waiting to run
Build Lua Docs / Build Lua docs (push) Has been cancelled
Build Rust Docs / Build docs (push) Has been cancelled
Some checks failed
CI (Pinnacle) / Build (push) Waiting to run
CI (Pinnacle) / Run tests (push) Waiting to run
CI (Pinnacle) / Check formatting (push) Waiting to run
CI (Pinnacle) / Clippy check (push) Waiting to run
Build Lua Docs / Build Lua docs (push) Has been cancelled
Build Rust Docs / Build docs (push) Has been cancelled
Wait a bit for each window to spawn fully
This commit is contained in:
parent
eb333cb4c6
commit
8d0da8ccfc
3 changed files with 51 additions and 19 deletions
|
@ -23,6 +23,10 @@ pub fn sleep_secs(secs: u64) {
|
||||||
std::thread::sleep(Duration::from_secs(secs));
|
std::thread::sleep(Duration::from_secs(secs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn sleep_millis(millis: u64) {
|
||||||
|
std::thread::sleep(Duration::from_millis(millis));
|
||||||
|
}
|
||||||
|
|
||||||
pub fn test_api<F>(test: F) -> anyhow::Result<()>
|
pub fn test_api<F>(test: F) -> anyhow::Result<()>
|
||||||
where
|
where
|
||||||
F: FnOnce(Sender<Box<dyn FnOnce(&mut State) + Send>>) -> anyhow::Result<()>
|
F: FnOnce(Sender<Box<dyn FnOnce(&mut State) + Send>>) -> anyhow::Result<()>
|
||||||
|
|
|
@ -442,6 +442,8 @@ mod output {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
mod handle {
|
mod handle {
|
||||||
|
use common::sleep_millis;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
@ -551,16 +553,24 @@ mod output {
|
||||||
|
|
||||||
run_lua! { |Pinnacle|
|
run_lua! { |Pinnacle|
|
||||||
Pinnacle.process.spawn("foot")
|
Pinnacle.process.spawn("foot")
|
||||||
|
}
|
||||||
|
sleep_millis(250);
|
||||||
|
run_lua! { |Pinnacle|
|
||||||
Pinnacle.process.spawn("foot")
|
Pinnacle.process.spawn("foot")
|
||||||
|
}
|
||||||
|
sleep_millis(250);
|
||||||
|
run_lua! { |Pinnacle|
|
||||||
Pinnacle.process.spawn("foot")
|
Pinnacle.process.spawn("foot")
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep_secs(1);
|
sleep_millis(250);
|
||||||
|
|
||||||
run_lua! { |Pinnacle|
|
run_lua! { |Pinnacle|
|
||||||
Pinnacle.tag.get("2"):switch_to()
|
Pinnacle.tag.get("2"):switch_to()
|
||||||
|
|
||||||
Pinnacle.process.spawn("foot")
|
Pinnacle.process.spawn("foot")
|
||||||
|
}
|
||||||
|
sleep_millis(250);
|
||||||
|
run_lua! { |Pinnacle|
|
||||||
Pinnacle.process.spawn("foot")
|
Pinnacle.process.spawn("foot")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,7 +586,7 @@ mod output {
|
||||||
print(focus_stack[3].id)
|
print(focus_stack[3].id)
|
||||||
print(focus_stack[4].id)
|
print(focus_stack[4].id)
|
||||||
print(focus_stack[5].id)
|
print(focus_stack[5].id)
|
||||||
// FIXME: the below statement failed in github CI, idk why
|
|
||||||
assert(focus_stack[1].id == 0, "focus stack at 1 id != 0")
|
assert(focus_stack[1].id == 0, "focus stack at 1 id != 0")
|
||||||
assert(focus_stack[2].id == 1, "focus stack at 2 id != 1")
|
assert(focus_stack[2].id == 1, "focus stack at 2 id != 1")
|
||||||
assert(focus_stack[3].id == 2, "focus stack at 3 id != 2")
|
assert(focus_stack[3].id == 2, "focus stack at 3 id != 2")
|
||||||
|
|
|
@ -318,6 +318,7 @@ mod output {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod handle {
|
mod handle {
|
||||||
|
use common::sleep_millis;
|
||||||
use pinnacle::window::window_state::WindowId;
|
use pinnacle::window::window_state::WindowId;
|
||||||
use pinnacle_api::output::Transform;
|
use pinnacle_api::output::Transform;
|
||||||
|
|
||||||
|
@ -406,15 +407,24 @@ mod output {
|
||||||
|
|
||||||
run_rust(|api| {
|
run_rust(|api| {
|
||||||
api.process.spawn(["foot"]);
|
api.process.spawn(["foot"]);
|
||||||
|
})?;
|
||||||
|
sleep_millis(250);
|
||||||
|
run_rust(|api| {
|
||||||
api.process.spawn(["foot"]);
|
api.process.spawn(["foot"]);
|
||||||
|
})?;
|
||||||
|
sleep_millis(250);
|
||||||
|
run_rust(|api| {
|
||||||
api.process.spawn(["foot"]);
|
api.process.spawn(["foot"]);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
sleep_secs(1);
|
sleep_millis(250);
|
||||||
|
|
||||||
run_rust(|api| {
|
run_rust(|api| {
|
||||||
api.tag.get("2").unwrap().switch_to();
|
api.tag.get("2").unwrap().switch_to();
|
||||||
api.process.spawn(["foot"]);
|
api.process.spawn(["foot"]);
|
||||||
|
})?;
|
||||||
|
sleep_millis(250);
|
||||||
|
run_rust(|api| {
|
||||||
api.process.spawn(["foot"]);
|
api.process.spawn(["foot"]);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
@ -424,12 +434,12 @@ mod output {
|
||||||
api.tag.get("1").unwrap().switch_to();
|
api.tag.get("1").unwrap().switch_to();
|
||||||
|
|
||||||
let focus_stack = api.output.get_focused().unwrap().keyboard_focus_stack();
|
let focus_stack = api.output.get_focused().unwrap().keyboard_focus_stack();
|
||||||
assert!(dbg!(focus_stack.len()) == 5);
|
assert_eq!(focus_stack.len(), 5);
|
||||||
assert!(focus_stack[0].id() == 0);
|
assert_eq!(focus_stack[0].id(), 0);
|
||||||
assert!(focus_stack[1].id() == 1);
|
assert_eq!(focus_stack[1].id(), 1);
|
||||||
assert!(focus_stack[2].id() == 2);
|
assert_eq!(focus_stack[2].id(), 2);
|
||||||
assert!(focus_stack[3].id() == 3);
|
assert_eq!(focus_stack[3].id(), 3);
|
||||||
assert!(focus_stack[4].id() == 4);
|
assert_eq!(focus_stack[4].id(), 4);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// Terminate all windows related to this test
|
// Terminate all windows related to this test
|
||||||
|
@ -465,17 +475,25 @@ mod output {
|
||||||
sleep_secs(1);
|
sleep_secs(1);
|
||||||
|
|
||||||
run_rust(|api| {
|
run_rust(|api| {
|
||||||
api.tag.get("1").unwrap().switch_to();
|
|
||||||
api.process.spawn(["foot"]);
|
api.process.spawn(["foot"]);
|
||||||
|
})?;
|
||||||
|
sleep_millis(250);
|
||||||
|
run_rust(|api| {
|
||||||
api.process.spawn(["foot"]);
|
api.process.spawn(["foot"]);
|
||||||
|
})?;
|
||||||
|
sleep_millis(250);
|
||||||
|
run_rust(|api| {
|
||||||
api.process.spawn(["foot"]);
|
api.process.spawn(["foot"]);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
sleep_secs(1);
|
sleep_millis(250);
|
||||||
|
|
||||||
run_rust(|api| {
|
run_rust(|api| {
|
||||||
api.tag.get("2").unwrap().switch_to();
|
api.tag.get("2").unwrap().switch_to();
|
||||||
api.process.spawn(["foot"]);
|
api.process.spawn(["foot"]);
|
||||||
|
})?;
|
||||||
|
sleep_millis(250);
|
||||||
|
run_rust(|api| {
|
||||||
api.process.spawn(["foot"]);
|
api.process.spawn(["foot"]);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
@ -489,10 +507,10 @@ mod output {
|
||||||
.get_focused()
|
.get_focused()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.keyboard_focus_stack_visible();
|
.keyboard_focus_stack_visible();
|
||||||
assert!(focus_stack.len() == 3);
|
assert_eq!(focus_stack.len(), 3);
|
||||||
assert!(focus_stack[0].id() == 0);
|
assert_eq!(focus_stack[0].id(), 0);
|
||||||
assert!(focus_stack[1].id() == 1);
|
assert_eq!(focus_stack[1].id(), 1);
|
||||||
assert!(focus_stack[2].id() == 2);
|
assert_eq!(focus_stack[2].id(), 2);
|
||||||
|
|
||||||
api.tag.get("2").unwrap().switch_to();
|
api.tag.get("2").unwrap().switch_to();
|
||||||
|
|
||||||
|
@ -501,9 +519,9 @@ mod output {
|
||||||
.get_focused()
|
.get_focused()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.keyboard_focus_stack_visible();
|
.keyboard_focus_stack_visible();
|
||||||
assert!(focus_stack.len() == 2);
|
assert_eq!(focus_stack.len(), 2);
|
||||||
assert!(focus_stack[0].id() == 3);
|
assert_eq!(focus_stack[0].id(), 3);
|
||||||
assert!(focus_stack[1].id() == 4);
|
assert_eq!(focus_stack[1].id(), 4);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// Terminate all windows related to this test
|
// Terminate all windows related to this test
|
||||||
|
|
Loading…
Reference in a new issue