(
bridge: &NativeBridge,
udid: &str,
x: f64,
y: f64,
normalized: bool,
)
| 5783 | } |
| 5784 | |
| 5785 | fn resolve_touch_point( |
| 5786 | bridge: &NativeBridge, |
| 5787 | udid: &str, |
| 5788 | x: f64, |
| 5789 | y: f64, |
| 5790 | normalized: bool, |
| 5791 | ) -> Result<(f64, f64), crate::error::AppError> { |
| 5792 | if !x.is_finite() || !y.is_finite() || x < 0.0 || y < 0.0 { |
| 5793 | return Err(crate::error::AppError::bad_request( |
| 5794 | "Touch coordinates must be finite non-negative numbers.", |
| 5795 | )); |
| 5796 | } |
| 5797 | if normalized { |
| 5798 | return Ok((x.clamp(0.0, 1.0), y.clamp(0.0, 1.0))); |
| 5799 | } |
| 5800 | let (width, height) = accessibility_root_size(bridge, udid) |
| 5801 | .or_else(|| chrome_screen_size(bridge, udid)) |
| 5802 | .unwrap_or((1.0, 1.0)); |
| 5803 | Ok(((x / width).clamp(0.0, 1.0), (y / height).clamp(0.0, 1.0))) |
| 5804 | } |
| 5805 | |
| 5806 | fn accessibility_root_size(bridge: &NativeBridge, udid: &str) -> Option<(f64, f64)> { |
| 5807 | let snapshot = bridge.accessibility_snapshot(udid, None).ok()?; |
no test coverage detected