FakePermissionController


@ExperimentalTestingApi
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 constructors

FakePermissionController

Added in 1.0.0-alpha01
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-alpha01
fun grantPermission(permission: String): Unit

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

grantPermissions

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

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

replaceGrantedPermissions

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

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

revokeAllPermissions

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

Clears the set of permissions returned by getGrantedPermissions.

revokePermission

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

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