From: Ian Jackson Date: Thu, 28 Jan 2021 17:37:32 +0000 (+0000) Subject: wdt: Tidy up new facilities X-Git-Tag: otter-0.4.0~658 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=ee2d4c67aabb18b3e37ba98e686c98f4cd5f1d22;p=otter.git wdt: Tidy up new facilities Signed-off-by: Ian Jackson --- diff --git a/wdriver.rs b/wdriver.rs index 31d948a8..2c370433 100644 --- a/wdriver.rs +++ b/wdriver.rs @@ -1128,26 +1128,37 @@ impl IntoInWindow for Pos { } pub trait ActionChainExt: Sized { - fn w_move<'g, P: IntoInWindow> + fn move_w<'g, P: Debug + Copy + IntoInWindow> (self, w: &'g WindowGuard, pos: P) -> Result; - fn move_pos<'g, P: TryInto> - (self, pos: P) -> Result; + fn move_pos<'g, + E, + P: TryInto> + (self, pos: P) -> Result + where Result: anyhow::Context; } impl<'a> ActionChainExt for t4::action_chain::ActionChain<'a> { #[throws(AE)] - fn w_move<'g, P: IntoInWindow> - (self, w: &'g WindowGuard, pos: P) -> Self + fn move_pos<'g, + E, + P: TryInto> + (self, pos: P) -> Self + where Result: anyhow::Context { - let (px,py) = pos.w_into(w)?; + let (px,py) = pos.try_into().context("convert")?; + trace!("move_pos: ({}, {})", px, py); self.move_to(px,py) } #[throws(AE)] - fn move_pos<'g, P: TryInto> (self, pos: P) -> Self { - let (px,py) = pos.try_into()?; - self.move_to(px,py) + fn move_w<'g, P: Debug + Copy + IntoInWindow> + (self, w: &'g WindowGuard, pos: P) -> Self + { + let pos: WebPos = pos.w_into(w) + .with_context(|| format!("{:?}", pos)) + .context("find coordinate")?; + self.move_pos(pos)? } } diff --git a/wdriver/wdt-simple.rs b/wdriver/wdt-simple.rs index 8a6dbc59..d277780e 100644 --- a/wdriver/wdt-simple.rs +++ b/wdriver/wdt-simple.rs @@ -105,9 +105,9 @@ impl Ctx { let try_end = end(10); let exp_end = end(0); w.action_chain() - .w_move(&w, start)? + .move_w(&w, start)? .click_and_hold() - .w_move(&w, try_end)? + .move_w(&w, try_end)? .release() .perform() .always_context("drag off")?; @@ -197,9 +197,9 @@ impl Ctx { let p = w.find_piece(pc)?; w.action_chain() - .w_move(&w, side.start)? + .move_w(&w, side.start)? .click_and_hold() - .w_move(&w, side.try_end)? + .move_w(&w, side.try_end)? .release() .perform() .context("conflicting drag")?;