BB.Camera.V4L.Test.StubBackend (bb_camera_v4l v0.1.0)

Copy Markdown View Source

A capture backend the test drives byte by byte.

Stands in for ffmpeg so that every event capture has to cope with — a frame split across reads, a truncated image, an unexpected exit status, a consumer falling behind — is a function call in the test rather than something to wait for and hope for.

Every operation is synchronous. feed/2 returns once the data message is in the capture's mailbox, so a test can feed bytes and then assert on what came out without a sleep anywhere in between.

Summary

Functions

Returns a specification to start this module under a supervisor.

Report that the captured process exited with status.

Deliver data to the capture as one read.

Deliver each binary in turn as a separate read.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

exited(stub, status)

@spec exited(pid(), integer()) :: :ok

Report that the captured process exited with status.

feed(stub, data)

@spec feed(pid(), binary()) :: :ok

Deliver data to the capture as one read.

feed_all(stub, chunks)

@spec feed_all(pid(), [binary()]) :: :ok

Deliver each binary in turn as a separate read.