(
state: AppState,
udid: String,
plan: ScrollInputPlan,
)
| 601 | } |
| 602 | |
| 603 | async fn perform_scroll_input( |
| 604 | state: AppState, |
| 605 | udid: String, |
| 606 | plan: ScrollInputPlan, |
| 607 | ) -> Result<(), AppError> { |
| 608 | let swipe = plan.swipe; |
| 609 | match plan.backend { |
| 610 | ScrollInputBackend::Android => { |
| 611 | run_android_action(state, move |android| { |
| 612 | android.send_swipe( |
| 613 | &udid, |
| 614 | swipe.start_x, |
| 615 | swipe.start_y, |
| 616 | swipe.end_x, |
| 617 | swipe.end_y, |
| 618 | swipe.duration_ms, |
| 619 | ) |
| 620 | }) |
| 621 | .await |
| 622 | } |
| 623 | ScrollInputBackend::Native => { |
| 624 | run_bridge_action(state, move |bridge| { |
| 625 | if bridge_simulator_is_tvos(&bridge, &udid) { |
| 626 | let key_code = tvos_remote_key_for_touch_motion( |
| 627 | swipe.start_x, |
| 628 | swipe.start_y, |
| 629 | swipe.end_x, |
| 630 | swipe.end_y, |
| 631 | ); |
| 632 | return press_tvos_remote_key(&bridge, &udid, key_code); |
| 633 | } |
| 634 | let input = bridge.create_input_session(&udid)?; |
| 635 | let delay = Duration::from_millis(swipe.duration_ms / u64::from(swipe.steps)); |
| 636 | input.send_touch(swipe.start_x, swipe.start_y, "began")?; |
| 637 | for step in 1..swipe.steps { |
| 638 | let t = f64::from(step) / f64::from(swipe.steps); |
| 639 | input.send_touch( |
| 640 | swipe.start_x + (swipe.end_x - swipe.start_x) * t, |
| 641 | swipe.start_y + (swipe.end_y - swipe.start_y) * t, |
| 642 | "moved", |
| 643 | )?; |
| 644 | std::thread::sleep(delay); |
| 645 | } |
| 646 | input.send_touch(swipe.end_x, swipe.end_y, "ended") |
| 647 | }) |
| 648 | .await |
| 649 | } |
| 650 | } |
| 651 | } |
| 652 | |
| 653 | fn normalized_scroll_coordinates( |
| 654 | direction: Option<&str>, |
no test coverage detected