also looking at this
fix(android): resolve share() with whether the person picked an app
#210
12 files
+399
-56
| @@ -43,7 +43,19 @@ export interface ObservedEvent { | ||
| 43 | 43 | value: unknown |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | export type DriverEvent = PlanEvent | CaseEvent | DoneEvent | FatalEvent | ObservedEvent | |
| 46 | /** | |
| 47 | * The page asking the harness to do what a person would. Emitted just before | |
| 48 | * the call that needs it, because the page cannot tap the device itself. | |
| 49 | */ | |
| 50 | export interface AwaitingEvent { | |
| 51 | event: 'awaiting' | |
| 52 | /** The case that is waiting. */ | |
| 53 | name: string | |
| 54 | /** What it is waiting for, one of the needs the harness knows how to meet. */ | |
| 55 | need: string | |
| 56 | } | |
| 57 | ||
| 58 | export type DriverEvent = PlanEvent | CaseEvent | DoneEvent | FatalEvent | ObservedEvent | AwaitingEvent | |
| 47 | 59 | |
| 48 | 60 | export type MobilePlatform = 'ios' | 'android' |
| 49 | 61 | |
| @@ -74,6 +86,8 @@ export const REQUIRED_CASES: Record<MobilePlatform, string[]> = { | ||
| 74 | 86 | 'deviceInfo.isEmulator', |
| 75 | 87 | 'clipboard.roundTrip', |
| 76 | 88 | 'push.disabled.rejects', |
| 89 | 'share.empty.rejects', | |
| 90 | 'share.dismissed.resolvesFalse', | |
| 77 | 91 | ], |
| 78 | 92 | } |
| 79 | 93 | |
| @@ -303,6 +317,42 @@ export function evaluateRun(platform: MobilePlatform, text: string, expectedRun? | ||
| 303 | 317 | return { ok: failures.length === 0, failures, planned, passed, failed } |
| 304 | 318 | } |
| 305 | 319 | |
| 320 | /** The need the Android share case announces before it opens the menu. */ | |
| 321 | export const DISMISS_SHARE_MENU = 'dismiss-share-menu' | |
| 322 | ||
| 323 | /** The needs the page has announced so far, in order, without repeats. */ | |
| 324 | export function awaitedNeeds(text: string): string[] { | |
| 325 | const needs: string[] = [] | |
| 326 | for (const event of parseDriverOutput(text).events) { | |
| 327 | if (event.event === 'awaiting' && !needs.includes(event.need)) | |
| 328 | needs.push(event.need) | |
| 329 | } | |
| 330 | return needs | |
| 331 | } | |
| 332 | ||
| 333 | /** | |
| 334 | * Whether Android's share menu holds input focus, read from | |
| 335 | * `adb shell dumpsys window`. | |
| 336 | * | |
| 337 | * The harness presses Back only once this is true, because Back goes to the | |
| 338 | * focused window. Focus rather than the activity being *resumed*, which is | |
| 339 | * what this first checked: the activity manager marks the chooser resumed | |
| 340 | * before its process has even created it. On the first CI run the chooser was | |
| 341 | * resumed at 50.37s and took focus at 52.63s. Back pressed in that gap goes to | |
| 342 | * the app, which closes, and the page never reports anything. That run passed | |
| 343 | * only because the harness happened to poll late. | |
| 344 | * | |
| 345 | * Matched by class name rather than by package, because the chooser moved: | |
| 346 | * `android/com.android.internal.app.ChooserActivity` up to Android 13, and | |
| 347 | * `com.android.intentresolver/com.android.intentresolver.ChooserActivity` from | |
| 348 | * 14. | |
| 349 | */ | |
| 350 | export function shareMenuInFront(dumpsysWindow: string): boolean { | |
| 351 | return dumpsysWindow | |
| 352 | .split('\n') | |
| 353 | .some(line => /mCurrentFocus=/.test(line) && /ChooserActivity/.test(line)) | |
| 354 | } | |
| 355 | ||
| 306 | 356 | /** |
| 307 | 357 | * The actions the Zig dispatcher saw, by name. |
| 308 | 358 | * |