Messages read as you tab through discord again.

This commit is contained in:
lilmike committed 2026-11-01 14:52:44 -08:00
1 parent 6ed0e36960
commit 9374b5a2e5
10 files changed
+162 -3

No files matched your search

+38
View File
@@ -94,3 +94,41 @@ func TestReviewContextSuppressedOutsideBrowseMode(t *testing.T) {
}
}
}
func TestMessageArticleAnnouncedOnceWhenTabbingIntoControls(t *testing.T) {
for name, mode := range map[string]review.DocumentMode{"browse": review.BrowseMode, "focus": review.FocusMode, "resolving": review.InactiveMode} {
t.Run(name, func(t *testing.T) {
logger := slog.New(slog.DiscardHandler)
queue := &fakeSpeechQueue{spoken: make(chan string, 16), requests: make(chan speechRequest, 16)}
speaker := &spellingTestSpeaker{}
worker := newSpeechWorker(logger, speaker)
worker.reading = func() config.ReadingSettings { return config.DefaultSettings().Reading }
browser := &browserModeController{ready: mode != review.InactiveMode, mode: mode, document: atspi.NewObjectID(":1.42", "/document")}
state := &eventLoopState{}
state.presentationOptions = presentation.DefaultOptions()
presenter := eventPresenter{state: state, logger: logger, speech: queue, browser: browser}
article := atspi.Snapshot{BusName: ":1.42", Path: "/message1", Role: "article", Name: "Author: First message"}
check := func(path, name string, ancestors []atspi.Snapshot, want []string) {
t.Helper()
control := atspi.Snapshot{BusName: ":1.42", Path: path, Role: "button", Name: name, SpeechContext: ancestors}
presenter.speak(atspi.NewEvent(atspi.FocusEvent, control))
speaker.parts = nil
if len(queue.requests) != 1 {
t.Fatalf("queued %d requests", len(queue.requests))
}
if err := worker.deliver(context.Background(), <-queue.requests); err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(speaker.parts, want) {
t.Fatalf("speech = %q, want %q", speaker.parts, want)
}
}
check("/reply1", "Reply", []atspi.Snapshot{article}, []string{"Author: First message article", "Reply", "button"})
check("/forward1", "Forward", []atspi.Snapshot{article}, []string{"Forward", "button"})
article.Path, article.Name = "/message2", "Author: Second message"
check("/reply2", "Reply", []atspi.Snapshot{article}, []string{"Author: Second message article", "Reply", "button"})
check("/outside", "Outside", []atspi.Snapshot{}, []string{"Outside", "button"})
check("/reply2", "Reply", []atspi.Snapshot{article}, []string{"Author: Second message article", "Reply", "button"})
})
}
}