FakeBluetoothRepository

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
sealed interface BondOutcome

The outcome FakeBluetoothRepository.bond produces. Fail and Security both simply throw their wrapped error; the distinct cases exist only to document caller intent (via failBondWith vs failBondWithSecurityException) and leave a seam should the fake ever need to branch on permission failures.

Properties

Link copied to clipboard

Every device passed to bond, in call order — lets tests assert that bonding was (or was not) attempted.

Link copied to clipboard

Controls what bond does. Defaults to BondOutcome.Success so existing tests that never touch this knob keep the historical "bonding always succeeds" behavior. Set it (or use the failBondWith / failBondWithSecurityException helpers) to drive the failure paths of consumers such as AndroidScannerViewModel.requestBonding.

Link copied to clipboard
open override val state: StateFlow<BluetoothState>

Functions

Link copied to clipboard
open suspend override fun bond(device: BleDevice)
Link copied to clipboard
fun FakeBluetoothRepository.failBondAfterRecording(error: Throwable = Exception("bond failed after pairing"))

Make the next FakeBluetoothRepository.bond call record the device as bonded and then throw error.

Link copied to clipboard
fun FakeBluetoothRepository.failBondWith(error: Throwable = Exception("bond failed"))

Make the next FakeBluetoothRepository.bond call throw a generic error (the flaky/interrupted-bonding path).

Link copied to clipboard
fun FakeBluetoothRepository.failBondWithSecurityException(message: String = "BLUETOOTH_CONNECT not granted")

Android-specific override: throw SecurityException (the missing-permission path on Android). This is needed because SecurityException is JVM-only and not available in commonMain.

Link copied to clipboard
open override fun isBonded(address: String): Boolean
Link copied to clipboard
open override fun isValid(bleAddress: String): Boolean
Link copied to clipboard
open override fun refreshState()
Link copied to clipboard
open suspend fun removeBond(address: String): Boolean
Link copied to clipboard
open fun reset()

Resets all registered state flows and custom actions to their initial state.

Link copied to clipboard
Link copied to clipboard
fun setHasPermissions(hasPermissions: Boolean)