BB.Camera.TestDriver (bb_camera v0.1.1)

Copy Markdown View Source

A camera driver that does nothing until a test tells it to.

BB.Camera.Synthetic answers the hub immediately, which is what you want when exercising the ordinary path. It is useless for the races, which all live in the window between the hub asking a driver to do something and the driver confirming it did. This driver holds that window open for as long as a test wants.

Every message the hub sends is forwarded to the registered reporter process rather than acted on, and each confirmation is a separate call the test makes when it is ready:

BB.Camera.TestDriver.report_to(Robot, :eye)
{:ok, sub} = BB.Camera.subscribe(Robot, :eye)
assert_received {:driver, :start_capture}          # hub asked
BB.Camera.TestDriver.confirm_start(Robot, :eye)    # driver answers, now

Nothing here sleeps, and nothing races: a test that wants to know what happens when a subscriber arrives mid-stop simply doesn't confirm the stop until it has arrived.

Summary

Functions

Answer a pending :start_capture.

Hand a frame to the hub, with an auto-incrementing sequence.

Hand a frame to the hub exactly as given.

Report that capture failed.

Forward every hub request to the calling process.

Functions

confirm_start(robot, camera, stream_info \\ nil)

Answer a pending :start_capture.

confirm_stop(robot, camera, reason \\ :driver_stopped)

Answer a pending :stop_capture.

deliver(robot, camera, data \\ "jpeg")

Hand a frame to the hub, with an auto-incrementing sequence.

deliver_raw(robot, camera, frame)

Hand a frame to the hub exactly as given.

fail(robot, camera, error)

Report that capture failed.

report_to(robot, camera)

Forward every hub request to the calling process.

update_stream_info(robot, camera, stream_info)

Report a new live format.