Found more weird breakage on Slint. Fixed now.
This commit is contained in:
1 parent
6df27c88de
commit
7918fc02c4
14 files changed
+502
-6
No files matched your search
@@ -20,10 +20,12 @@ package app
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.stormux.org/storm/cthulhu/internal/atspi"
|
||||
"git.stormux.org/storm/cthulhu/internal/input"
|
||||
)
|
||||
|
||||
func TestProcessEventsSpeaksChangedCaretLines(t *testing.T) {
|
||||
@@ -101,6 +103,59 @@ func TestProcessEventsSuppressesCaretAfterEditableTextChange(t *testing.T) {
|
||||
<-completed
|
||||
}
|
||||
|
||||
func TestProcessEventsReadOnlyComboUsesNameInsteadOfEditorCaret(t *testing.T) {
|
||||
speech := &fakeSpeechQueue{spoken: make(chan string, 16)}
|
||||
adapter := &fakeAdapter{events: make(chan atspi.Event, 16)}
|
||||
combo := atspi.Snapshot{BusName: ":1.7", Path: "/combo", Role: "combo box", Name: "Classic Doom", Focused: true}
|
||||
adapter.events <- atspi.NewEvent(atspi.FocusEvent, combo)
|
||||
editor := atspi.Snapshot{BusName: combo.BusName, Path: "/combo/editor", Role: "text", Text: "Funny Pack - Classic Doom",
|
||||
BrailleLine: "Funny Pack - Classic Doom", TextCaretKnown: true, Editable: true, ReadOnly: true,
|
||||
Focused: true, ReadOnlyCombo: combo.ID()}
|
||||
for _, value := range []string{"Funny Pack - Classic Doom", "Toby Doom", "Classic Doom"} {
|
||||
editor.Text, editor.BrailleLine = value, value
|
||||
adapter.events <- atspi.NewEvent(atspi.CaretEvent, editor)
|
||||
combo.Name = value
|
||||
adapter.events <- atspi.NewEvent(atspi.AccessibleNameEvent, combo)
|
||||
}
|
||||
close(adapter.events)
|
||||
processEvents(context.Background(), slog.New(slog.DiscardHandler), speech, adapter, 0)
|
||||
close(speech.spoken)
|
||||
var got []string
|
||||
for text := range speech.spoken {
|
||||
got = append(got, text)
|
||||
}
|
||||
want := []string{"Classic Doom, combo box", "Funny Pack - Classic Doom", "Toby Doom", "Classic Doom"}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("combo speech = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadOnlyComboCaretRequiresExactOwnedCombo(t *testing.T) {
|
||||
combo := atspi.Snapshot{BusName: ":1.7", Path: "/combo", Role: "combo box"}
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
owner atspi.ObjectID
|
||||
skip bool
|
||||
}{
|
||||
{"owned", combo.ID(), true},
|
||||
{"different combo", atspi.NewObjectID(combo.BusName, "/other-combo"), false},
|
||||
{"different provider", atspi.NewObjectID(":1.8", combo.Path), false},
|
||||
{"ordinary editor", atspi.ObjectID{}, false},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
state := &eventLoopState{}
|
||||
state.current, state.focusedID = combo, combo.ID()
|
||||
handler := accessibilityEventHandler{state: state, logger: slog.New(slog.DiscardHandler), debounce: time.Hour}
|
||||
event := atspi.NewEvent(atspi.CaretEvent, atspi.Snapshot{BusName: combo.BusName, Path: "/editor", Role: "text", ReadOnlyCombo: test.owner})
|
||||
handler.handleCaret(event, input.Activity{}, input.NoIntent)
|
||||
defer state.pending.clear()
|
||||
if skipped := state.pending.caret.event.Type == ""; skipped != test.skip {
|
||||
t.Fatalf("caret skipped = %v, want %v", skipped, test.skip)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestProcessEventsSpeaksCaretCharacters(t *testing.T) {
|
||||
speech := &fakeSpeechQueue{spoken: make(chan string, 3)}
|
||||
adapter := &fakeAdapter{events: make(chan atspi.Event, 3)}
|
||||
|
||||
Reference in new issue
Block a user