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, nowNothing 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.
Answer a pending :stop_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.
Report a new live format.
Functions
Answer a pending :start_capture.
Answer a pending :stop_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.
Report a new live format.