//! Contract tests for launcher-owned relay process lifetime. //! //! Scope: static guardrails around launcher runtime process management. //! Targets: `client/src/launcher/ui_runtime.rs`. //! Why: the launcher is the owner of the live relay. If it crashes, audio, //! video, and input streams must not keep running as leaked child processes. const UI_RUNTIME_SRC: &str = include_str!("../../client/src/launcher/ui_runtime.rs"); const UI_SRC: &str = include_str!("../../client/src/launcher/ui.rs"); const LAUNCHER_MOD_SRC: &str = include_str!("../../client/src/launcher/mod.rs"); const MAIN_SRC: &str = include_str!("../../client/src/main.rs"); #[test] fn relay_child_gets_parent_identity_from_launcher() { assert!(UI_RUNTIME_SRC.contains("\"LESAVKA_LAUNCHER_PARENT_PID\"")); assert!(UI_RUNTIME_SRC.contains("std::process::id().to_string()")); assert!(UI_RUNTIME_SRC.contains("LESAVKA_LAUNCHER_PARENT_START_TICKS")); assert!(UI_RUNTIME_SRC.contains("launcher_parent_start_ticks()")); } #[test] fn relay_child_starts_safe_parent_watchdog_on_boot() { assert!(MAIN_SRC.contains("launcher::start_launcher_child_parent_watchdog_from_env();")); assert!(LAUNCHER_MOD_SRC.contains("start_launcher_child_parent_watchdog_from_env")); assert!(LAUNCHER_MOD_SRC.contains("launcher-parent-watchdog")); assert!(LAUNCHER_MOD_SRC.contains("std::process::exit(0);")); assert!(LAUNCHER_MOD_SRC.contains("proc_stat_start_ticks")); } #[test] fn relay_address_entry_is_locked_while_relay_is_live() { assert!(UI_RUNTIME_SRC.contains("widgets.server_entry.set_sensitive(!relay_live);")); assert!(UI_RUNTIME_SRC.contains("\"Connect\"")); assert!(UI_RUNTIME_SRC.contains("\"Disconnect\"")); } #[test] fn audio_gain_slider_callback_never_panics_on_refresh_reentry() { assert!(UI_SRC.contains("fn apply_audio_gain_change(")); assert!(UI_SRC.contains("state.try_borrow_mut()")); assert!(UI_SRC.contains("return false;")); assert!(UI_SRC.contains("glib::idle_add_local_once")); assert!(!UI_SRC.contains("let mut state = state.borrow_mut();\n if state.audio_gain_percent == percent")); }