(
state: AppState,
udid: String,
message: ControlMessage,
)
| 2753 | } |
| 2754 | |
| 2755 | async fn run_android_control_message( |
| 2756 | state: AppState, |
| 2757 | udid: String, |
| 2758 | message: ControlMessage, |
| 2759 | ) -> Result<(), AppError> { |
| 2760 | match message { |
| 2761 | ControlMessage::Touch { x, y, phase } => { |
| 2762 | handle_android_control_touch(state, udid, x, y, phase).await |
| 2763 | } |
| 2764 | ControlMessage::EdgeTouch { x, y, phase, .. } => { |
| 2765 | handle_android_control_touch(state, udid, x, y, phase).await |
| 2766 | } |
| 2767 | ControlMessage::MultiTouch { x1, y1, phase, .. } => { |
| 2768 | handle_android_control_touch(state, udid, x1, y1, phase).await |
| 2769 | } |
| 2770 | other => { |
| 2771 | run_android_action(state, move |android| match other { |
| 2772 | ControlMessage::Key { |
| 2773 | key_code, |
| 2774 | modifiers, |
| 2775 | } => android.send_key(&udid, key_code, modifiers.unwrap_or(0)), |
| 2776 | ControlMessage::Button { |
| 2777 | button, |
| 2778 | duration_ms, |
| 2779 | phase, |
| 2780 | .. |
| 2781 | } => match phase.as_deref() { |
| 2782 | Some("down" | "began") => Ok(()), |
| 2783 | Some("up" | "ended" | "cancelled") | None => { |
| 2784 | android.press_button(&udid, &button, duration_ms.unwrap_or(0)) |
| 2785 | } |
| 2786 | Some(_) => Err(AppError::bad_request( |
| 2787 | "`phase` must be `down`, `up`, `began`, `ended`, or `cancelled`.", |
| 2788 | )), |
| 2789 | }, |
| 2790 | ControlMessage::DismissKeyboard => android.dismiss_keyboard(&udid), |
| 2791 | ControlMessage::ToggleSoftwareKeyboard => Err(AppError::bad_request( |
| 2792 | "Software keyboard toggle is only available for iOS simulators.", |
| 2793 | )), |
| 2794 | ControlMessage::Home => android.press_home(&udid), |
| 2795 | ControlMessage::AppSwitcher => android.open_app_switcher(&udid), |
| 2796 | ControlMessage::RotateLeft => android.rotate_left(&udid), |
| 2797 | ControlMessage::RotateRight => android.rotate_right(&udid), |
| 2798 | ControlMessage::Crown { .. } => Err(AppError::bad_request( |
| 2799 | "Digital Crown rotation is only available for Apple Watch simulators.", |
| 2800 | )), |
| 2801 | ControlMessage::ToggleAppearance => android.toggle_appearance(&udid), |
| 2802 | ControlMessage::Touch { .. } |
| 2803 | | ControlMessage::EdgeTouch { .. } |
| 2804 | | ControlMessage::MultiTouch { .. } => Ok(()), |
| 2805 | }) |
| 2806 | .await |
| 2807 | } |
| 2808 | } |
| 2809 | } |
| 2810 | |
| 2811 | async fn handle_android_control_touch( |
| 2812 | state: AppState, |
no test coverage detected