// Capture power lease manager for keeping remote capture devices awake only when needed.
#[cfg(coverage)]
use lesavka_common::lesavka::CapturePowerState;

#[cfg(not(coverage))]
include!("capture_power/lease_manager.rs");
include!("capture_power/systemd_units.rs");

#[cfg(all(test, coverage))]
mod tests {
    use super::*;

    #[tokio::test]
    async fn coverage_stub_supports_preview_and_session_leases() {
        let manager = CapturePowerManager::new();
        let _preview = manager.acquire().await;
        let _session = manager.acquire_session().await;
    }

    #[tokio::test]
    async fn coverage_stub_reports_auto_snapshot() {
        let state = CapturePowerManager::new()
            .snapshot()
            .await
            .expect("snapshot");
        assert!(state.available);
        assert!(!state.enabled);
        assert_eq!(state.mode, "auto");
    }

    #[tokio::test]
    async fn coverage_stub_toggles_manual_modes() {
        let manager = CapturePowerManager::new();
        let on = manager.set_manual(true).await.expect("on");
        assert!(on.enabled);
        assert_eq!(on.mode, "forced-on");

        let off = manager.set_manual(false).await.expect("off");
        assert!(!off.enabled);
        assert_eq!(off.mode, "forced-off");
    }

    #[tokio::test]
    async fn coverage_stub_returns_to_auto_mode() {
        let manager = CapturePowerManager::new();
        let state = manager.set_auto().await.expect("auto");
        assert!(state.available);
        assert!(!state.enabled);
        assert_eq!(state.mode, "auto");
    }
}
