FakeGrantManager
An in-memory GrantManager for tests — no platform APIs, no Activity, no real permission dialog.
mockStatus and mockRequestResult are the defaults checkStatus/request return for any permission that hasn't been individually configured via setStatus/setRequestResult/ configure. Every call is recorded (checkStatusCalls, requestedGrants, requestCalled, openSettingsCalled, capturedLauncher) so a test can assert on interactions, not just return values.
val manager = FakeGrantManager(mockStatus = GrantStatus.DENIED)
manager.configure(AppGrant.CAMERA, status = GrantStatus.GRANTED)
val handler = GrantHandler(manager, AppGrant.CAMERA, testScope)
handler.requestSuspend() // GRANTED — CAMERA was configured; everything else defaults to DENIEDThis is the same fake that used to be duplicated, with small drifts, inside seven different modules' own commonTest source sets — consolidated here so external consumers of Grant get an official test double instead of writing their own, and so this project stops maintaining near-identical copies of it.
Constructors
Properties
The launcher passed to setLauncher, if any — null until a real one is captured.
Every permission checkStatus has been called with, in call order.
True once openSettings has been called.
True once request has been called at least once, for any permission.
Every permission request has been called with, in call order (duplicates included).
When non-null, checkStatus/request throw this instead of returning.
Simulates a slow platform call — checkStatus/request suspend for this long first.
Functions
Sets both checkStatus and request's return value for grant in one call.
Sets what request returns for grant specifically, overriding mockRequestResult.
Alias for setRequestResult — kept for source compatibility with pre-consolidation call sites.
Sets what checkStatus returns for grant specifically, overriding mockStatus.