(device: DeviceInfo)
| 34 | import { snapshotCaptureAnnotationsFrom } from '../../snapshot-capture-annotations.ts'; |
| 35 | |
| 36 | export function createAndroidInteractor(device: DeviceInfo): Interactor { |
| 37 | return { |
| 38 | open: (app, options) => |
| 39 | openAndroidApp(device, app, { |
| 40 | activity: options?.activity, |
| 41 | appBundleId: options?.appBundleId, |
| 42 | launchArgs: options?.launchArgs, |
| 43 | url: options?.url, |
| 44 | }), |
| 45 | openDevice: () => openAndroidDevice(device), |
| 46 | close: (app) => closeAndroidApp(device, app), |
| 47 | tap: (x, y) => pressAndroid(device, x, y), |
| 48 | doubleTap: async (x, y) => { |
| 49 | await pressAndroid(device, x, y); |
| 50 | await pressAndroid(device, x, y); |
| 51 | }, |
| 52 | swipe: (x1, y1, x2, y2, durationMs) => |
| 53 | swipeGestureAndroid(device, { x1, y1, x2, y2, durationMs }), |
| 54 | pan: (x1, y1, x2, y2, durationMs) => |
| 55 | swipeGestureAndroid(device, { x1, y1, x2, y2, durationMs }), |
| 56 | fling: (x1, y1, x2, y2, durationMs) => |
| 57 | swipeGestureAndroid(device, { x1, y1, x2, y2, durationMs }), |
| 58 | longPress: (x, y, durationMs) => longPressAndroid(device, x, y, durationMs), |
| 59 | focus: (x, y) => focusAndroid(device, x, y), |
| 60 | type: (text, delayMs) => typeAndroid(device, text, delayMs), |
| 61 | fill: (x, y, text, delayMs) => fillAndroid(device, x, y, text, delayMs), |
| 62 | scroll: (direction, options) => scrollAndroid(device, direction, options), |
| 63 | pinch: (scale, x, y) => pinchAndroid(device, { scale, x, y }), |
| 64 | screenshot: (outPath, options) => screenshotAndroid(device, outPath, options), |
| 65 | snapshot: async (options) => { |
| 66 | const result = await withDiagnosticTimer( |
| 67 | 'snapshot_capture', |
| 68 | async () => |
| 69 | await snapshotAndroid(device, { |
| 70 | appBundleId: options?.appBundleId, |
| 71 | interactiveOnly: options?.interactiveOnly, |
| 72 | depth: options?.depth, |
| 73 | scope: options?.scope, |
| 74 | raw: options?.raw, |
| 75 | // appBundleId is present for app-backed daemon sessions; keep the helper warm there, |
| 76 | // but release it after standalone device snapshots so UiAutomation is not squatted. |
| 77 | helperSessionScope: options?.appBundleId ? 'daemon-session' : 'command', |
| 78 | }), |
| 79 | { backend: 'android' }, |
| 80 | ); |
| 81 | return { |
| 82 | nodes: result.nodes ?? [], |
| 83 | truncated: result.truncated ?? false, |
| 84 | backend: 'android', |
| 85 | ...snapshotCaptureAnnotationsFrom(result), |
| 86 | }; |
| 87 | }, |
| 88 | back: (_mode) => backAndroid(device), |
| 89 | home: () => homeAndroid(device), |
| 90 | rotate: (orientation) => rotateAndroid(device, orientation), |
| 91 | rotateGesture: (degrees, x, y, velocity) => |
| 92 | rotateGestureAndroid(device, { degrees, x, y, velocity }), |
| 93 | transformGesture: (options) => transformGestureAndroid(device, options), |
no test coverage detected