rightkit-qa 0.2.6

Rust QA harness for Right Suite apps: engine black-box scenarios, hidden native UI driving through rightkit-control, Rust-test scenario wrapper, dynamic paid-provider mocks, loudness/WAV/PNG/frame validators, run lock, orphan sweep, hashed evidence.
Documentation
//! Audio is always muted during QA. Apps are told through `RIGHTKIT_QA_MUTE=1`
//! and Chrome gets `--mute-audio`; on macOS the system output can additionally
//! be muted for the run and restored afterwards (opt-in, restored on drop).
//! Playback is asserted from DOM/engine state, never from sound.
#[cfg(target_os = "macos")]
use std::process::{Command, Stdio};

pub struct SystemMute {
    restore: Option<bool>,
}

impl SystemMute {
    /// Mute system output (macOS only). A no-op elsewhere; `active()` reports it.
    pub fn engage() -> Self {
        #[cfg(target_os = "macos")]
        {
            let was = Command::new("osascript")
                .args(["-e", "output muted of (get volume settings)"])
                .output()
                .ok()
                .map(|o| String::from_utf8_lossy(&o.stdout).trim() == "true");
            if let Some(was_muted) = was {
                if !was_muted {
                    let _ = Command::new("osascript")
                        .args(["-e", "set volume with output muted"])
                        .stdout(Stdio::null())
                        .stderr(Stdio::null())
                        .status();
                }
                return Self {
                    restore: Some(was_muted),
                };
            }
        }
        Self { restore: None }
    }
    pub fn active(&self) -> bool {
        self.restore.is_some()
    }
}

impl Drop for SystemMute {
    fn drop(&mut self) {
        // Only the macOS path ever records a mute to restore.
        #[cfg(target_os = "macos")]
        if self.restore == Some(false) {
            let _ = Command::new("osascript")
                .args(["-e", "set volume without output muted"])
                .stdout(Stdio::null())
                .stderr(Stdio::null())
                .status();
        }
    }
}