//! Linux GNOME-Wayland portal smoke test (RR-PTT-004).
//!
//! `cargo test -p chanora_audio --test linux_portal_smoke -- --ignored`
//! runs the cheap probe path against the active D-Bus session and
//! asserts the `org.freedesktop.portal.GlobalShortcuts` interface
//! is reachable. Marked `#[ignore]` because:
//!
//!   * It needs a live D-Bus session (CI runners typically don't
//!     have one, and our existing live tests are similarly gated).
//!   * It needs `xdg-desktop-portal-gnome` (or another backend
//!     that exposes `GlobalShortcuts`) to actually own the well-
//!     known service.
//!
//! Run from inside a GNOME-on-Wayland session.

#![cfg(target_os = "linux")]

#[test]
#[ignore = "live; needs xdg-desktop-portal with GlobalShortcuts on the user session bus"]
fn portal_global_shortcuts_reachable() {
    // We don't pull chanora_audio's private modules in directly;
    // instead we replicate the cheap version-probe call so we
    // exercise the *exact* path try_select uses. The crate's
    // `try_select` is the integration boundary the audio engine
    // depends on, so a follow-up test could be added that
    // constructs a `LinuxGnomeWaylandBackend` through the public
    // factory and asserts its descriptor.
    use zbus::blocking::{Connection, Proxy};
    let conn = Connection::session().expect("session bus");
    let proxy = Proxy::new(
        &conn,
        "org.freedesktop.portal.Desktop",
        "/org/freedesktop/portal/desktop",
        "org.freedesktop.portal.GlobalShortcuts",
    )
    .expect("proxy");
    let version: u32 = proxy
        .get_property("version")
        .expect("GlobalShortcuts.version property; portal not exposing the interface?");
    assert!(version >= 1, "portal version {version} unexpected");
    eprintln!("GlobalShortcuts portal reachable, version = {version}");
}
