also looking at this
Android: Bluetooth heart-rate straps, and offline media on WorkManager
#370
21 files
+2307
-56
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -1,4 +1,4 @@ | ||
| 1 | import { describe, expect, it } from 'bun:test' | |
| 1 | import { afterEach, describe, expect, it } from 'bun:test' | |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | 4 | * The reply-correlation contract, exercised against the real |
| @@ -37,6 +37,27 @@ interface Harness { | ||
| 37 | 37 | * they can simply be passed in as parameters — no DOM, no jsdom, and nothing |
| 38 | 38 | * shared between tests. |
| 39 | 39 | */ |
| 40 | /** | |
| 41 | * The bridge's timers. A test that sends without answering (an id check, a | |
| 42 | * fire-and-forget) leaves its call's timeout running; left alone it rejects | |
| 43 | * during whatever test runs then, as an unhandled error that fails that one. | |
| 44 | * Each test's bridge stops when the test does. | |
| 45 | */ | |
| 46 | const timers = new Set<ReturnType<typeof setTimeout>>() | |
| 47 | const bridgeSetTimeout = (run: (...args: unknown[]) => void, ms?: number, ...args: unknown[]) => { | |
| 48 | const timer = setTimeout(() => { timers.delete(timer); run(...args) }, ms) | |
| 49 | timers.add(timer) | |
| 50 | return timer | |
| 51 | } | |
| 52 | const bridgeClearTimeout = (timer: ReturnType<typeof setTimeout>) => { | |
| 53 | timers.delete(timer) | |
| 54 | clearTimeout(timer) | |
| 55 | } | |
| 56 | afterEach(() => { | |
| 57 | for (const timer of timers) clearTimeout(timer) | |
| 58 | timers.clear() | |
| 59 | }) | |
| 60 | ||
| 40 | 61 | function loadBridge(platform: 'webkit' | 'webview2' = 'webkit'): Harness { |
| 41 | 62 | const sent: Envelope[] = [] |
| 42 | 63 | const errors: unknown[][] = [] |
| @@ -57,7 +78,7 @@ function loadBridge(platform: 'webkit' | 'webview2' = 'webkit'): Harness { | ||
| 57 | 78 | |
| 58 | 79 | // eslint-disable-next-line no-new-func |
| 59 | 80 | const run = new Function('window', 'document', 'console', 'setTimeout', 'clearTimeout', 'setInterval', BRIDGE_SRC) |
| 60 | run(win, doc, console_, setTimeout, clearTimeout, () => 0) | |
| 81 | run(win, doc, console_, bridgeSetTimeout, bridgeClearTimeout, () => 0) | |
| 61 | 82 | |
| 62 | 83 | return { |
| 63 | 84 | craft: win.craft, |