# `BB.Camera.TestDriver`
[🔗](https://github.com/beam-bots/bb_camera/blob/main/test/support/test_driver.ex#L5)

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.

# `confirm_start`

Answer a pending `:start_capture`.

# `confirm_stop`

Answer a pending `:stop_capture`.

# `deliver`

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

# `deliver_raw`

Hand a frame to the hub exactly as given.

# `fail`

Report that capture failed.

# `report_to`

Forward every hub request to the calling process.

# `update_stream_info`

Report a new live format.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
