FakePermissionController


class FakePermissionController : PermissionController


A fake PermissionController that enables full control of permissions in tests for a HealthConnectClient.

Summary

Public constructors

Public functions

open suspend Set<String>

Returns a fake set of permissions.

Unit
grantPermission(permission: String)

Adds a permission to the set of granted permissions returned by getGrantedPermissions.

Unit
grantPermissions(permission: Set<String>)

Adds permissions to the set of granted permissions returned by getGrantedPermissions.

Unit

Replaces the set of permissions returned by getGrantedPermissions with a new set.

open suspend Unit

Clears the set of permissions returned by getGrantedPermissions.

Unit
revokePermission(permission: String)

Removes a permission from the set of granted permissions returned by getGrantedPermissions.

Public properties

FakePermissionControllerOverrides

Used to override or intercept responses to emulate scenarios that FakePermissionController doesn't support directly, such as throwing an exception or applying custom logic to the responses.

Public constructors

FakePermissionController

Added in 1.0.0-alpha04
FakePermissionController(grantAll: Boolean = true)
Parameters
grantAll: Boolean = true

grants all permissions on creation

Public functions

getGrantedPermissions

open suspend fun getGrantedPermissions(): Set<String>

Returns a fake set of permissions.

grantPermission

Added in 1.0.0-alpha04
fun grantPermission(permission: String): Unit

Adds a permission to the set of granted permissions returned by getGrantedPermissions.

grantPermissions

Added in 1.0.0-alpha04
fun grantPermissions(permission: Set<String>): Unit

Adds permissions to the set of granted permissions returned by getGrantedPermissions.

replaceGrantedPermissions

Added in 1.0.0-alpha04
fun replaceGrantedPermissions(permissions: Set<String>): Unit

Replaces the set of permissions returned by getGrantedPermissions with a new set.

revokeAllPermissions

Added in 1.0.0-alpha04
open suspend fun revokeAllPermissions(): Unit

Clears the set of permissions returned by getGrantedPermissions.

revokePermission

Added in 1.0.0-alpha04
fun revokePermission(permission: String): Unit

Removes a permission from the set of granted permissions returned by getGrantedPermissions.

Public properties

overrides

Added in 1.0.0-alpha04
val overridesFakePermissionControllerOverrides

Used to override or intercept responses to emulate scenarios that FakePermissionController doesn't support directly, such as throwing an exception or applying custom logic to the responses.