MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / wait_for_snapshot_match

Function wait_for_snapshot_match

packages/server/src/api/action_execution.rs:242–326  ·  view source on GitHub ↗
(
    state: AppState,
    udid: String,
    payload: WaitForPayload,
)

Source from the content-addressed store, hash-verified

240}
241
242async fn wait_for_snapshot_match(
243 state: AppState,
244 udid: String,
245 payload: WaitForPayload,
246) -> Result<Value, AppError> {
247 let timeout_ms = payload.timeout_ms.unwrap_or(5_000);
248 let poll_ms = payload.poll_ms.unwrap_or(100).max(10);
249 let deadline = Instant::now() + Duration::from_millis(timeout_ms);
250 let prefer_interactive = selector_prefers_interactive(&payload.selector)
251 && payload.include_hidden != Some(true)
252 && payload.selector.index.is_none()
253 && payload
254 .source
255 .as_deref()
256 .is_none_or(|source| source == "auto" || source == SOURCE_NATIVE_AX);
257 let interactive_max_depth = payload.max_depth.or(Some(8));
258 let mut prefer_cache = true;
259 loop {
260 let snapshot = if prefer_interactive {
261 if prefer_cache {
262 cached_accessibility_tree_value(
263 state.clone(),
264 udid.clone(),
265 payload.source.as_deref(),
266 interactive_max_depth,
267 false,
268 true,
269 )
270 .await?
271 } else {
272 refresh_accessibility_tree_value(
273 state.clone(),
274 udid.clone(),
275 payload.source.as_deref(),
276 interactive_max_depth,
277 false,
278 true,
279 )
280 .await?
281 }
282 } else if prefer_cache {
283 cached_accessibility_tree_value(
284 state.clone(),
285 udid.clone(),
286 payload.source.as_deref(),
287 payload.max_depth,
288 payload.include_hidden.unwrap_or(false),
289 false,
290 )
291 .await?
292 } else {
293 refresh_accessibility_tree_value(
294 state.clone(),
295 udid.clone(),
296 payload.source.as_deref(),
297 payload.max_depth,
298 payload.include_hidden.unwrap_or(false),
299 false,

Callers 2

perform_tap_payloadFunction · 0.85
run_batch_stepFunction · 0.85

Calls 7

first_matching_elementFunction · 0.85
maxMethod · 0.80
cloneMethod · 0.65
sleepFunction · 0.50

Tested by

no test coverage detected