also looking at this
test(mobile-e2e): prove Android reports approximate location as granted
#214
5 files
+85
-5
| @@ -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, awaitedNeeds, DISMISS_SHARE_MENU, evaluateRun, hasTerminated, parseDriverOutput, REQUIRED_CASES, requiredCaseProblems, shareMenuInFront, ZIG_REFUSED_ACTIONS, ZIG_SERVED_ACTIONS, ZIG_TESTED_ACTIONS, zigDispatchedActions, zigHandBacks, zigRefusals } from './protocol' | |
| 4 | import { ANDROID_DECLINE_PHRASES, androidDeclines, awaitedNeeds, DISMISS_SHARE_MENU, evaluateRun, hasTerminated, parseDriverOutput, REQUIRED_CASES, requiredCaseProblems, runtimePermissionGranted, shareMenuInFront, ZIG_REFUSED_ACTIONS, ZIG_SERVED_ACTIONS, ZIG_TESTED_ACTIONS, zigDispatchedActions, zigHandBacks, zigRefusals } from './protocol' | |
| 5 | 5 | |
| 6 | 6 | const ESC = String.fromCharCode(27) |
| 7 | 7 | |
| @@ -334,6 +334,32 @@ describe('share menu', () => { | ||
| 334 | 334 | }) |
| 335 | 335 | }) |
| 336 | 336 | |
| 337 | describe('runtime permission state', () => { | |
| 338 | // As `dumpsys package` prints a coarse-only grant on Android 14. | |
| 339 | const dumpsys = [ | |
| 340 | ' runtime permissions:', | |
| 341 | ' android.permission.ACCESS_FINE_LOCATION: granted=false, flags=[ USER_SENSITIVE_WHEN_GRANTED|USER_SENSITIVE_WHEN_DENIED]', | |
| 342 | ' android.permission.ACCESS_COARSE_LOCATION: granted=true, flags=[ USER_SET|USER_SENSITIVE_WHEN_GRANTED|USER_SENSITIVE_WHEN_DENIED]', | |
| 343 | ' android.permission.ACCESS_BACKGROUND_LOCATION: granted=false, flags=[ RESTRICTION_INSTALLER_EXEMPT]', | |
| 344 | ].join('\n') | |
| 345 | ||
| 346 | it('reads granted and not granted apart', () => { | |
| 347 | expect(runtimePermissionGranted(dumpsys, 'android.permission.ACCESS_COARSE_LOCATION')).toBe(true) | |
| 348 | expect(runtimePermissionGranted(dumpsys, 'android.permission.ACCESS_FINE_LOCATION')).toBe(false) | |
| 349 | }) | |
| 350 | ||
| 351 | it('says nothing about a permission the output never mentions', () => { | |
| 352 | expect(runtimePermissionGranted(dumpsys, 'android.permission.CAMERA')).toBeUndefined() | |
| 353 | }) | |
| 354 | ||
| 355 | it('does not read one permission as another that ends the same way', () => { | |
| 356 | // A dot left unescaped would match any character, and a name without a | |
| 357 | // boundary would match inside a longer one. | |
| 358 | expect(runtimePermissionGranted(dumpsys, 'permission.ACCESS_COARSE_LOCATION')).toBeUndefined() | |
| 359 | expect(runtimePermissionGranted('androidXpermissionXCAMERA: granted=true', 'android.permission.CAMERA')).toBeUndefined() | |
| 360 | }) | |
| 361 | }) | |
| 362 | ||
| 337 | 363 | describe('android declines', () => { |
| 338 | 364 | // The lines the first Android runtime run actually produced, plus the two |
| 339 | 365 | // decline kinds it did not hit, so all three are read the way they are |