test: verify IME, clipboard dialogs, quick terminal and Flatpak paths

Exercises the runtime paths that had never run (details in
docs/rewrite/notes/verification-VR.md):
- IME: replay steps drive the surface's real GtkIMContext handlers with
  a real preedit + attributes; preedit renders under the cursor and
  commits reach the pty, incl. dead-key and compose orderings.
- Paste and OSC 52 read/write confirmation dialogs: allow, deny and
  remember flows.
- Quick terminal on niri via wlr-layer-shell: positions, sizes, toggle
  and autohide. Fixes a real bug: link order could put libwayland-client
  ahead of libgtk4-layer-shell, silently disabling the quick terminal;
  apprt-gtk now loads libwayland-client via wayland-sys dlopen.
- Flatpak host commands against a zbus mock of
  org.freedesktop.Flatpak.Development under dbus-run-session: spawn,
  exit status, cwd/env/fd forwarding and SIGHUP on stop, both directly
  and through termio Exec (flatpak-info path seam added).
- Horizontal-scroll tab switching thresholds and reset.

tests/gtk_replay.rs runs the real binary against the session display
(skips without one).

Test Plan:
- cargo test --test gtk_replay (needs a Wayland/X11 display)
- cargo test -p ghostty-os --test flatpak_mock; -p ghostty-termio
  --test flatpak_exec
This commit is contained in:
ddidderr committed 2026-10-12 06:02:28 +02:00
1 parent a714fd9a65
commit 42cb8796da
7 files changed
+1567 -12

No files matched your search

+19 -3
View File
@@ -17,7 +17,23 @@ const INTERFACE: &str = "org.freedesktop.Flatpak.Development";
/// Returns true if we're running in a Flatpak environment.
pub fn is_flatpak() -> bool {
std::path::Path::new("/.flatpak-info").exists()
std::path::Path::new(
FLATPAK_INFO_OVERRIDE
.get()
.map_or(std::path::Path::new(FLATPAK_INFO), |p| p.as_path()),
)
.exists()
}
const FLATPAK_INFO: &str = "/.flatpak-info";
static FLATPAK_INFO_OVERRIDE: std::sync::OnceLock<std::path::PathBuf> = std::sync::OnceLock::new();
/// Injection seam for integration tests: make [`is_flatpak`] look at `path`
/// instead of `/.flatpak-info`. Can be set once per process; returns false if
/// it was already set. Not used by the application.
pub fn set_flatpak_info_path(path: impl Into<std::path::PathBuf>) -> bool {
FLATPAK_INFO_OVERRIDE.set(path.into()).is_ok()
}
/// Errors that are possible from us.
@@ -76,8 +92,8 @@ impl Shared {
/// pipes, /dev/null, etc.) but this was purpose built for a specific need so
/// it doesn't have all of those.
///
/// NOTE: this can't be exercised in the test environment (needs a Flatpak
/// session bus with the Development interface); it is a best-effort port.
/// The DBus path is exercised against a mock `org.freedesktop.Flatpak`
/// service in `tests/flatpak_mock.rs` (run under `dbus-run-session`).
pub struct FlatpakHostCommand {
/// Argv are the arguments to call on the host with argv[0] being
/// the command to execute.