lesavka/testing/tests/client_camera_timing_contract.rs

58 lines
1.9 KiB
Rust

//! Include-based coverage for camera capture timing helpers.
//!
//! Scope: include `client/src/input/camera.rs` and exercise timestamp logging
//! branches without requiring a physical webcam.
//! Targets: `client/src/input/camera.rs`.
//! Why: upstream freshness diagnostics depend on stable first-packet and
//! periodic timing traces while the HEVC transport path is being tuned.
#[allow(warnings)]
mod live_capture_clock {
include!("support/live_capture_clock_shim.rs");
}
#[allow(warnings)]
mod camera_timing_contract {
include!(env!("LESAVKA_CLIENT_CAMERA_SRC"));
use temp_env::with_var;
#[test]
fn camera_timing_helpers_cover_first_packet_and_trace_enabled_paths() {
log_camera_first_packet(0, 128, 42_000);
assert!(!should_log_camera_timing_sample(11));
with_var("LESAVKA_UPSTREAM_TIMING_TRACE", Some("1"), || {
assert!(should_log_camera_timing_sample(0));
log_camera_timing_sample(
0,
crate::live_capture_clock::RebasedSourcePts {
packet_pts_us: 12_345,
capture_now_us: 12_999,
source_pts_us: Some(5_000),
source_base_us: Some(5_000),
capture_base_us: Some(7_345),
used_source_pts: true,
lag_clamped: false,
lead_clamped: false,
},
256,
);
});
log_camera_stale_source_drop(
crate::live_capture_clock::RebasedSourcePts {
packet_pts_us: 1,
capture_now_us: 1_000_000,
source_pts_us: Some(1),
source_base_us: Some(1),
capture_base_us: Some(999_999),
used_source_pts: true,
lag_clamped: true,
lead_clamped: false,
},
512,
);
}
}