// Copyright (c) 2026 Storm Dragon // Authors: Storm Dragon, Angus Kola // SPDX-License-Identifier: GPL-3.0-or-later package atspi import ( "context" "os" "testing" "time" "git.stormux.org/storm/cthulhu/internal/platform/xorg" ) // A private X server represents an available Xwayland connection here. It does // not establish compositor support, only that X metadata cannot veto AT-SPI. func TestNativeWaylandForegroundPolicy(t *testing.T) { if os.Getenv("CTHULHU_NATIVE_WAYLAND_POLICY") != "1" { t.Skip("requires private Xvfb and D-Bus") } reader := xorg.OpenForegroundReader() if reader == nil { t.Fatal("private X11 display unavailable") } reader.Close() t.Setenv("XDG_SESSION_TYPE", "wayland") ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() adapter := New() if err := adapter.Start(ctx); err != nil { t.Fatal(err) } defer func() { stopCtx, stop := context.WithTimeout(context.Background(), 3*time.Second) defer stop() if err := adapter.Stop(stopCtx); err != nil { t.Error(err) } }() if adapter.Foreground().Client.Known { t.Fatal("X11 foreground used as Wayland desktop authority") } if !adapter.matchesForeground(nil, ObjectID{}) { t.Fatal("missing X11 foreground rejected Wayland accessibility") } }