1use async_trait::async_trait;
7use std::time::Duration;
8
9use smix_error::ExpectationFailure;
10use smix_input::{KeyName, SwipeDirection};
11use smix_runner_client::{IncludeScope, OcrFrame, SystemPopup, TapMode};
12use smix_screen::A11yNode;
13use smix_selector::Selector;
14
15use crate::traits::{Driver, Platform};
16use crate::{IosDriver, Orientation};
17
18#[async_trait]
19impl Driver for IosDriver {
20 fn platform(&self) -> Platform {
21 Platform::Ios
22 }
23
24 fn as_ios_driver(&self) -> Option<&IosDriver> {
25 Some(self)
26 }
27
28 async fn tree(&self, include: Option<IncludeScope>) -> Result<A11yNode, ExpectationFailure> {
31 IosDriver::tree(self, include).await
32 }
33
34 async fn find(
35 &self,
36 selector: &Selector,
37 include: Option<IncludeScope>,
38 ) -> Result<bool, ExpectationFailure> {
39 IosDriver::find(self, selector, include).await
40 }
41
42 async fn find_one(
43 &self,
44 selector: &Selector,
45 include: Option<IncludeScope>,
46 ) -> Result<Option<A11yNode>, ExpectationFailure> {
47 IosDriver::find_one(self, selector, include).await
48 }
49
50 async fn find_all(
51 &self,
52 selector: &Selector,
53 include: Option<IncludeScope>,
54 ) -> Result<Vec<A11yNode>, ExpectationFailure> {
55 IosDriver::find_all(self, selector, include).await
56 }
57
58 async fn find_norm_coord(
59 &self,
60 selector: &Selector,
61 ) -> Result<Option<(f64, f64)>, ExpectationFailure> {
62 IosDriver::find_norm_coord(self, selector).await
63 }
64
65 async fn find_text_by_ocr(
66 &self,
67 text: &str,
68 locales: &[String],
69 recognition_level: &str,
70 ) -> Result<Option<OcrFrame>, ExpectationFailure> {
71 IosDriver::find_text_by_ocr(self, text, locales, recognition_level).await
72 }
73
74 async fn system_popups(
75 &self,
76 include: Option<IncludeScope>,
77 ) -> Result<Vec<SystemPopup>, ExpectationFailure> {
78 IosDriver::system_popups(self, include).await
79 }
80
81 async fn system_popup_action(
82 &self,
83 popup_id: &str,
84 button_id: &str,
85 ) -> Result<bool, ExpectationFailure> {
86 IosDriver::system_popup_action(self, popup_id, button_id).await
87 }
88
89 async fn wait_for(
90 &self,
91 selector: &Selector,
92 timeout: Duration,
93 include: Option<IncludeScope>,
94 ) -> Result<A11yNode, ExpectationFailure> {
95 IosDriver::wait_for(self, selector, timeout, include).await
96 }
97
98 async fn tap(
101 &self,
102 selector: &Selector,
103 include: Option<IncludeScope>,
104 ) -> Result<(), ExpectationFailure> {
105 IosDriver::tap(self, selector, include).await
106 }
107
108 async fn tap_with_mode(
109 &self,
110 selector: &Selector,
111 mode: TapMode,
112 include: Option<IncludeScope>,
113 ) -> Result<(), ExpectationFailure> {
114 IosDriver::tap_with_mode(self, selector, mode, include).await
115 }
116
117 async fn tap_at_norm_coord(&self, nx: f64, ny: f64) -> Result<(), ExpectationFailure> {
118 IosDriver::tap_at_norm_coord(self, nx, ny).await
119 }
120
121 async fn tap_by_id(&self, id: &str) -> Result<(), ExpectationFailure> {
122 IosDriver::tap_by_id(self, id).await
123 }
124
125 async fn double_tap(
126 &self,
127 selector: &Selector,
128 include: Option<IncludeScope>,
129 ) -> Result<(), ExpectationFailure> {
130 IosDriver::double_tap(self, selector, include).await
131 }
132
133 async fn long_press(
134 &self,
135 selector: &Selector,
136 duration: Duration,
137 include: Option<IncludeScope>,
138 ) -> Result<(), ExpectationFailure> {
139 IosDriver::long_press(self, selector, duration, include).await
140 }
141
142 async fn fill(
143 &self,
144 selector: &Selector,
145 text: &str,
146 include: Option<IncludeScope>,
147 ) -> Result<(), ExpectationFailure> {
148 IosDriver::fill(self, selector, text, include).await
149 }
150
151 async fn clear(
152 &self,
153 selector: &Selector,
154 include: Option<IncludeScope>,
155 ) -> Result<(), ExpectationFailure> {
156 IosDriver::clear(self, selector, include).await
157 }
158
159 async fn press_key(&self, key: KeyName) -> Result<(), ExpectationFailure> {
160 IosDriver::press_key(self, key).await
161 }
162
163 async fn scroll(
164 &self,
165 selector: &Selector,
166 direction: SwipeDirection,
167 ) -> Result<(), ExpectationFailure> {
168 IosDriver::scroll(self, selector, direction).await
169 }
170
171 async fn swipe_once(&self, direction: SwipeDirection) -> Result<(), ExpectationFailure> {
172 IosDriver::swipe_once(self, direction).await
173 }
174
175 async fn swipe_at_norm_coord(
176 &self,
177 from: (f64, f64),
178 to: (f64, f64),
179 ) -> Result<(), ExpectationFailure> {
180 IosDriver::swipe_at_norm_coord(self, from, to).await
181 }
182
183 async fn hide_keyboard(&self) -> Result<(), ExpectationFailure> {
184 IosDriver::hide_keyboard(self).await
185 }
186
187 async fn back(&self) -> Result<(), ExpectationFailure> {
188 IosDriver::back(self).await
189 }
190
191 async fn set_orientation(&self, orientation: Orientation) -> Result<(), ExpectationFailure> {
192 IosDriver::set_orientation(self, orientation).await
193 }
194
195 async fn foreground(&self, bundle_id: &str) -> Result<(), ExpectationFailure> {
196 IosDriver::foreground(self, bundle_id).await
197 }
198
199 async fn webview_eval(&self, js: &str) -> Result<serde_json::Value, ExpectationFailure> {
200 IosDriver::webview_eval(self, js).await
201 }
202}