FakePenSession

class FakePenSession(commitHandler: suspend (bitmap: Bitmap, destination: Rect, dirtyRegion: Rect, options: CommitOptions) -> Result<CommitReceipt> = { _, _, _, _ -> Result.failure( OnyxFailure.UnsupportedCapability( "fake.commit", null, "No commit result was configured for FakePenSession", ), ) }) : PenSession(source)

Deterministic consumer-facing test double; it performs no Android firmware calls.

Constructors

Link copied to clipboard
constructor(commitHandler: suspend (bitmap: Bitmap, destination: Rect, dirtyRegion: Rect, options: CommitOptions) -> Result<CommitReceipt> = { _, _, _, _ -> Result.failure( OnyxFailure.UnsupportedCapability( "fake.commit", null, "No commit result was configured for FakePenSession", ), ) })

Properties

Link copied to clipboard
open override val completedStrokes: Flow<InkStroke>

Strokes injected through emit.

Link copied to clipboard
open override val events: Flow<PenEvent>

Events injected through emit.

Link copied to clipboard
open override val preview: StateFlow<InkPreview?>

Latest preview derived from injected pen events.

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

Mutable test state exposed as the production session contract.

Functions

Link copied to clipboard
open override fun close()

Closes all fake streams and updates state.

Link copied to clipboard
open suspend override fun closeAndAwait(): Result<Unit>

Closes the fake synchronously and returns success.

Link copied to clipboard
open suspend override fun commit(bitmap: Bitmap, destination: Rect, dirtyRegion: Rect = destination, options: CommitOptions = CommitOptions()): Result<CommitReceipt>

Delegates a commit to the handler supplied at construction time.

Link copied to clipboard
suspend fun emit(stroke: InkStroke)

Injects a completed stroke into the fake session when it is active.

suspend fun emit(event: PenEvent)

Injects event into the fake session when it is active.

Link copied to clipboard
open suspend override fun pause(): Result<Unit>

Moves the fake session to its requested-suspension state.

Link copied to clipboard
open suspend override fun resume(): Result<Unit>

Moves an open fake session back to its active state.