also looking at this
fix(android): resolve share() with whether the person picked an app
#210
12 files
+399
-56
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | import { describe, expect, it } from 'bun:test' |
| 2 | 2 | import { readFileSync } from 'node:fs' |
| 3 | 3 | import { join } from 'node:path' |
| 4 | import { ANDROID_DECLINE_PHRASES, androidDeclines, evaluateRun, hasTerminated, parseDriverOutput, REQUIRED_CASES, requiredCaseProblems, ZIG_REFUSED_ACTIONS, ZIG_TESTED_ACTIONS, zigDispatchedActions, zigRefusals } from './protocol' | |
| 4 | import { ANDROID_DECLINE_PHRASES, androidDeclines, awaitedNeeds, DISMISS_SHARE_MENU, evaluateRun, hasTerminated, parseDriverOutput, REQUIRED_CASES, requiredCaseProblems, shareMenuInFront, ZIG_REFUSED_ACTIONS, ZIG_TESTED_ACTIONS, zigDispatchedActions, zigRefusals } from './protocol' | |
| 5 | 5 | |
| 6 | 6 | const ESC = String.fromCharCode(27) |
| 7 | 7 | |
| @@ -283,6 +283,42 @@ describe('zig attribution', () => { | ||
| 283 | 283 | }) |
| 284 | 284 | }) |
| 285 | 285 | |
| 286 | describe('share menu', () => { | |
| 287 | it('reads what the page is waiting for, once, from either log channel', () => { | |
| 288 | const awaiting = JSON.stringify({ event: 'awaiting', name: 'share.dismissed.resolvesFalse', need: DISMISS_SHARE_MENU }) | |
| 289 | const text = [ | |
| 290 | `09-16 11:29:25.000 2611 2611 I CraftBridge: CRAFT-E2E ${awaiting}`, | |
| 291 | `09-16 11:29:25.001 2611 2611 I chromium: [INFO:CONSOLE(1)] "CRAFT-E2E ${awaiting}", source: https://appassets.androidplatform.net/ (1)`, | |
| 292 | ].join('\n') | |
| 293 | ||
| 294 | expect(awaitedNeeds(text)).toEqual([DISMISS_SHARE_MENU]) | |
| 295 | expect(awaitedNeeds('CRAFT-E2E {"event":"case","name":"a","status":"pass"}')).toEqual([]) | |
| 296 | }) | |
| 297 | ||
| 298 | // Both spellings the chooser has had, as `dumpsys window` prints them. | |
| 299 | it('sees the menu holding focus on Android 14 and on 13', () => { | |
| 300 | expect(shareMenuInFront([ | |
| 301 | ' mCurrentFocus=Window{56c630c u0 com.android.intentresolver/com.android.intentresolver.ChooserActivity}', | |
| 302 | ' mFocusedApp=ActivityRecord{144007559 u0 com.android.intentresolver/.ChooserActivity t7}', | |
| 303 | ].join('\n'))).toBe(true) | |
| 304 | ||
| 305 | expect(shareMenuInFront( | |
| 306 | ' mCurrentFocus=Window{2b7a1f u0 android/com.android.internal.app.ChooserActivity}', | |
| 307 | )).toBe(true) | |
| 308 | }) | |
| 309 | ||
| 310 | it('does not see a menu that is resumed but not yet focused', () => { | |
| 311 | // The gap the first CI run fell into. The activity manager already calls | |
| 312 | // the chooser the focused app while the probe's window still has input | |
| 313 | // focus, so Back here would close the app rather than the menu. | |
| 314 | const dumpsys = [ | |
| 315 | ' mCurrentFocus=Window{77aa u0 dev.craft.e2e.probe/dev.craft.e2e.probe.MainActivity}', | |
| 316 | ' mFocusedApp=ActivityRecord{144007559 u0 com.android.intentresolver/.ChooserActivity t7}', | |
| 317 | ].join('\n') | |
| 318 | expect(shareMenuInFront(dumpsys)).toBe(false) | |
| 319 | }) | |
| 320 | }) | |
| 321 | ||
| 286 | 322 | describe('android declines', () => { |
| 287 | 323 | // The lines the first Android runtime run actually produced, plus the two |
| 288 | 324 | // decline kinds it did not hit, so all three are read the way they are |