From 48fce15d41b9c5f10a29c55a0808b11aa14ef345 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 28 Jan 2021 16:54:44 +0000 Subject: [PATCH] wdt: Use new w_move extension method This necessitates using our branch of thirtyfour_sync until Make action_chain module pub https://github.com/stevepryde/thirtyfour_sync/pull/4 Signed-off-by: Ian Jackson --- Cargo.lock.example | 2 -- Cargo.nail | 1 + wdriver.rs | 17 ++++++++++++++++- wdriver/wdt-simple.rs | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Cargo.lock.example b/Cargo.lock.example index ba6ec6ac..87acd25b 100644 --- a/Cargo.lock.example +++ b/Cargo.lock.example @@ -2692,8 +2692,6 @@ dependencies = [ [[package]] name = "thirtyfour_sync" version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5892bf1e39a0d08bd28417363ab1e810c64d8c0a21c06a4fc21298fcbaf04772" dependencies = [ "base64 0.13.0", "log 0.4.13", diff --git a/Cargo.nail b/Cargo.nail index 32ef8c3e..bf2dcfca 100644 --- a/Cargo.nail +++ b/Cargo.nail @@ -5,6 +5,7 @@ subdirs = """ server bundle-sources +thirtyfour_sync """ [arch] diff --git a/wdriver.rs b/wdriver.rs index cf032a18..cdcdf55f 100644 --- a/wdriver.rs +++ b/wdriver.rs @@ -1103,7 +1103,7 @@ impl Drop for FinalInfoCollection { } } -trait IntoInWindow { +pub trait IntoInWindow { fn w_into<'g>(self, w: &'g WindowGuard) -> Result; } @@ -1119,6 +1119,21 @@ impl IntoInWindow for Pos { } } +pub trait ActionChainExt: Sized { + fn w_move<'g, P: IntoInWindow> + (self, w: &'g WindowGuard, pos: P) -> Result; +} + +impl<'a> ActionChainExt for t4::action_chain::ActionChain<'a> { + #[throws(AE)] + fn w_move<'g, P: IntoInWindow> + (self, w: &'g WindowGuard, pos: P) -> Self + { + let (px,py) = pos.w_into(w)?; + self.move_to(px,py) + } +} + impl Drop for Setup { fn drop(&mut self) { (||{ diff --git a/wdriver/wdt-simple.rs b/wdriver/wdt-simple.rs index bbde0b71..66e39e1f 100644 --- a/wdriver/wdt-simple.rs +++ b/wdriver/wdt-simple.rs @@ -26,7 +26,7 @@ impl Ctx { let (p2x,p2y) = p2.posw()?; w.action_chain() - .move_to(p1x, p1y) + .w_move(&w, p1.posw()?)? .click_and_hold() .move_to(p2x + 5, p2y + 10) .release() -- 2.30.2