M1: X11 active-window adapter + platform fallback
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
//go:build linux
|
||||
|
||||
package evidence
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestX11SourceEmitsWhenDisplaySet(t *testing.T) {
|
||||
if os.Getenv("DISPLAY") == "" {
|
||||
t.Skip("no DISPLAY; skipping live X11 smoke test")
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer cancel()
|
||||
|
||||
got := make(chan WindowSnapshot, 1)
|
||||
go NewSource().Watch(ctx, func(s WindowSnapshot) {
|
||||
select {
|
||||
case got <- s:
|
||||
default:
|
||||
}
|
||||
})
|
||||
|
||||
select {
|
||||
case snap := <-got:
|
||||
// Either a real window or a clean Unavailable — both are valid; we only
|
||||
// assert the sensor produced an observation without panicking.
|
||||
t.Logf("first snapshot: %+v", snap)
|
||||
case <-ctx.Done():
|
||||
t.Fatal("x11 source emitted no snapshot within timeout")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user