chiark / gitweb /
wdt: Tidy up new facilities
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 28 Jan 2021 17:37:32 +0000 (17:37 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 28 Jan 2021 17:58:12 +0000 (17:58 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
wdriver.rs
wdriver/wdt-simple.rs

index 31d948a8b74f1537f53de59d9706e6b7d630600d..2c3704335edcc6af192d150c017f3b75ad71dc5d 100644 (file)
@@ -1128,26 +1128,37 @@ impl IntoInWindow<WebPos> for Pos {
 }
 
 pub trait ActionChainExt: Sized {
-  fn w_move<'g, P: IntoInWindow<WebPos>>
+  fn move_w<'g, P: Debug + Copy + IntoInWindow<WebPos>>
     (self, w: &'g WindowGuard, pos: P) -> Result<Self,AE>;
 
-  fn move_pos<'g, P: TryInto<WebPos, Error=AE>>
-    (self, pos: P) -> Result<Self,AE>;
+  fn move_pos<'g,
+              E,
+              P: TryInto<WebPos, Error=E>>
+    (self, pos: P) -> Result<Self,AE>
+    where Result<WebPos,E>: anyhow::Context<WebPos,E>;
 }
 
 impl<'a> ActionChainExt for t4::action_chain::ActionChain<'a> {
   #[throws(AE)]
-  fn w_move<'g, P: IntoInWindow<WebPos>>
-    (self, w: &'g WindowGuard, pos: P) -> Self
+  fn move_pos<'g,
+              E,
+              P: TryInto<WebPos, Error=E>>
+    (self, pos: P) -> Self
+    where Result<WebPos,E>: anyhow::Context<WebPos,E>
   {
-    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<WebPos, Error=AE>> (self, pos: P) -> Self {
-    let (px,py) = pos.try_into()?;
-    self.move_to(px,py)
+  fn move_w<'g, P: Debug + Copy + IntoInWindow<WebPos>>
+    (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)?
   }
 }
 
index 8a6dbc5974dd2af0be7c1c667a9e3809b8715423..d277780e5d4abb26bccd68abe6934f41516e1ff7 100644 (file)
@@ -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")?;