From: Ian Jackson Date: Wed, 27 Jan 2021 01:12:05 +0000 (+0000) Subject: wdt: wip conflict test X-Git-Tag: otter-0.4.0~664 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=5d86d817ed8a2b640f065b5619ff2959233a19eb;p=otter.git wdt: wip conflict test Signed-off-by: Ian Jackson --- diff --git a/wdriver.rs b/wdriver.rs index 3192218f..742177ce 100644 --- a/wdriver.rs +++ b/wdriver.rs @@ -38,7 +38,7 @@ pub use std::os::linux::fs::MetadataExt; // todo why linux for st_mode?? pub use std::path; pub use std::process::{self, Command, Stdio}; pub use std::thread::{self, sleep}; -pub use std::time; +pub use std::time::{self, Duration}; pub use otter::ensure_eq; pub use otter::commands::{MgmtCommand, MgmtResponse}; @@ -327,6 +327,7 @@ mod cleanup_notify { } let _ = read_await(notify_writing_end); let _ = kill(semidaemon, SIGTERM); + let _ = kill(semidaemon, SIGCONT); _exit(0); }); let _ = raise(SIGABRT); diff --git a/wdriver/wdt-simple.rs b/wdriver/wdt-simple.rs index 156643de..bbde0b71 100644 --- a/wdriver/wdt-simple.rs +++ b/wdriver/wdt-simple.rs @@ -165,6 +165,70 @@ impl Ctx { chk(&w)?; } } + + #[throws(AE)] + fn conflict(&mut self) { + let pc = "1.1"; + let su = &mut self.su; + + #[derive(Debug)] + struct Side<'s> { + window: &'s Window, + start: Pos, + try_end: Pos, + } + + let mut mk_side = |window, dx| { + let w = su.w(window)?; + let p = w.find_piece(pc)?; + let start = p.posg()?; + let try_end = start + PosC([dx, 0]); + Ok::<_,AE>(Side { window, start, try_end }) + }; + + let sides = [ + mk_side(&self.alice, -20)?, + mk_side(&self.bob, 20)?, + ]; + + dbg!(&sides); + + let pid = nix::unistd::Pid::from_raw(su.server_child.id() as nix::libc::pid_t); + nix::sys::signal::kill(pid, nix::sys::signal::SIGSTOP)?; + + for side in &sides { + let w = su.w(side.window)?; + let p = w.find_piece(pc)?; + let (sx,sy) = w.posg2posw(side.start)?; + let (ex,ey) = w.posg2posw(side.try_end)?; + + dbg!(sx,sy); + dbg!(ex,ey); + + w.action_chain() + .move_to(sx,sy) + .click_and_hold() + .move_to(ex,ey) + .release() + .perform() + .context("conflicting drag")?; + +// let mut pause = Duration::from_millis(1); +// loop { +// ensure!( pause < Duration::from_secs(1) ); +// dbg!(pause); +// sleep(pause); + let now = p.posg()?; +ensure_eq!(now, side.try_end); +// if now == side.try_end { break } +// pause *= 2; +// } + + + } + + nix::sys::signal::kill(pid, nix::sys::signal::SIGCONT)?; + } } #[throws(AE)] @@ -182,6 +246,7 @@ fn main(){ let pc = c.rotate().always_context("rotate")?; c.drag_off(pc).always_context("drag off")?; c.unselect(pc).always_context("unselect")?; + c.conflict().always_context("conflict handling")?; debug!("finishing"); }