From dd83eaeb6ff67ca5bccbc72580568757dc66d05d Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 31 Dec 2020 00:39:58 +0000 Subject: [PATCH] wip pos thing Signed-off-by: Ian Jackson --- wdriver.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/wdriver.rs b/wdriver.rs index 4cd4f438..5665af38 100644 --- a/wdriver.rs +++ b/wdriver.rs @@ -735,6 +735,45 @@ impl Debug for WindowGuard<'_> { } } +impl<'g> WindowGuard<'g> { + #[throws(AE)] + fn find_piece(&'g self, pieceid: &'g str) -> PieceElement<'g> { + let id = format!("use{}", pieceid); + let elem = self.su.driver.find_element(By::Id(&id))?; + PieceElement { + pieceid, elem, + pos: None, + w: self, + } + } +} + +pub type WebCoord = i32; +pub type WebPos = (WebCoord, WebCoord); + +pub struct PieceElement<'g> { + pieceid: &'g str, + w: &'g WindowGuard<'g>, + elem: t4::WebElement<'g>, + pos: Option, +} + +impl<'g> Deref for PieceElement<'g> { + type Target = t4::WebElement<'g>; + fn deref<'i>(&'i self) -> &'i t4::WebElement<'g> { &self.elem } +} + +impl<'g> PieceElement<'g> { + #[throws(AE)] + fn pos(&self) -> WebPos { + (||{ + Ok::<_,AE>( todo!() ) + })() + .with_context(|| self.pieceid.to_owned()) + .context("find piece position")? + } +} + #[throws(AE)] fn check_window_name_sanity(name: &str) -> &str { let e = || anyhow!("bad window name {:?}", &name); -- 2.30.2