Announce the initial row in unselected GTK menus

This commit is contained in:
ak47 committed 2026-11-10 21:26:17 -05:00
1 parent 090ac9dbeb
commit ae53f23c63
6 files changed
+190 -3

No files matched your search

+60
View File
@@ -448,3 +448,63 @@ func TestTerminalTextChangeSuppressesPromptReplayButPreservesNavigation(t *testi
cancel()
<-completed
}
// Replay YAD's stdin-fed menu sequence: initial unselected row, stale active
// descendant for that row on Down, then the actual new selection.
func TestListPromptInitialRowAndFirstArrow(t *testing.T) {
speech := &fakeSpeechQueue{spoken: make(chan string, 16), requests: make(chan speechRequest, 16)}
adapter := &fakeAdapter{events: make(chan atspi.Event, 16)}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
completed := make(chan struct{})
go func() {
processEvents(ctx, slog.New(slog.DiscardHandler), speech, adapter, 0)
close(completed)
}()
window := atspi.NewObjectID(":1.9", "/menu")
list := atspi.NewSnapshot("/menu/list", "", "tree table", "", "")
list.BusName = window.BusName
activation := atspi.NewEvent(atspi.WindowActivatedEvent, list)
activation.Window, activation.WindowTitle, activation.WindowMessage = window, "Action menu", "Please select an action"
adapter.events <- activation
cell := atspi.NewSnapshot("/menu/play", "Play", "table cell", "", "")
cell.BusName, cell.TablePath = window.BusName, list.Path
cell.GUITable, cell.TablePositionKnown = true, true
cell.TableRowText = "Play"
focus := atspi.NewEvent(atspi.FocusedStateEvent, cell)
focus.Window, focus.Detail1 = window, 1
adapter.events <- focus
expect := func(text string, appendSpeech bool) {
t.Helper()
select {
case request := <-speech.requests:
if request.Text != text || request.Append != appendSpeech {
t.Fatalf("got %q append=%v; want %q append=%v", request.Text, request.Append, text, appendSpeech)
}
case <-time.After(time.Second):
t.Fatalf("missing %q", text)
}
}
expect("Action menu, Please select an action", false)
expect("Play", true)
adapter.events <- focus // Duplicate container focus must not repeat Play.
adapter.events <- atspi.NewManagedDescendantEvent(atspi.ActiveDescendantEvent, list.Path, cell)
second := cell
second.Path, second.Name, second.TableRowText = "/menu/install", "Install", "Install"
second.TableRowIndex, second.Selected, second.Focused = 1, true, true
adapter.events <- atspi.NewManagedDescendantEvent(atspi.SelectionChangedEvent, list.Path, second)
expect("Install", false)
adapter.events <- atspi.NewManagedDescendantEvent(atspi.ActiveDescendantEvent, list.Path, second)
cell.Selected, cell.Focused = true, true
adapter.events <- atspi.NewManagedDescendantEvent(atspi.SelectionChangedEvent, list.Path, cell)
expect("Play", false)
cancel()
select {
case <-completed:
case <-time.After(time.Second):
t.Fatal("event loop did not stop")
}
if len(speech.requests) != 0 {
t.Fatal("unexpected duplicate menu speech")
}
}