Skip to main content

Module testing

Module testing 

Source
Expand description

Test harness for vision plugins.

Mirrors the Python ados.sdk.testing ergonomics for the Rust SDK: a plugin author exercises a frame-consuming plugin without a real plugin host, vision engine, shared memory, or socket. FakeVisionEngine emits synthetic frames (from an in-memory list or a directory of raw frame files) into the same FrameCallback a plugin registers with ctx.vision.subscribe_frames, and captures the DetectionBatches the plugin would publish so a test can assert against them.

The fake builds a real frame ring through the framebus contract and resolves each synthetic frame the same way the production client does (per-slot seqlock, latest-wins, torn/stale reads dropped), so a plugin’s frame-handling path is exercised end to end, only the host and the OS shared-memory are faked.

use ados_sdk::testing::FakeVisionEngine;
use ados_protocol::framebus::{FrameFormat, Detection, BoundingBox};
use std::sync::{Arc, Mutex};

let mut engine = FakeVisionEngine::new("uvc-0", 64, 48, FrameFormat::Rgb24);
let seen = Arc::new(Mutex::new(0usize));
let s = seen.clone();
engine.on_frame(move |frame| {
    // a plugin's per-frame handler runs here
    assert_eq!(frame.descriptor.camera_id, "uvc-0");
    *s.lock().unwrap() += 1;
});
engine.push_solid(0x80); // one grey frame
engine.deliver_all();
assert_eq!(*seen.lock().unwrap(), 1);

Structs§

FakeVisionEngine
In-process stand-in for the vision engine + plugin host bridge.

Type Aliases§

CapturedDetection
One captured published detection, in publish order.