Code cleanup.
This commit is contained in:
1 parent
92fd479336
commit
86cb2edb05
49 files changed
+433
-1020
No files matched your search
@@ -13,7 +13,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.stormux.org/storm/fenrir/internal/control"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
func TestApplicationAliasesShellCheck(t *testing.T) {
|
||||
@@ -131,17 +131,17 @@ func TestApplicationsMenuCopiesAliasWithoutSelecting(t *testing.T) {
|
||||
a, voice := persistenceApplication(t, true)
|
||||
overrideRead(t, a, overrideScreen(1, "ninjam"))
|
||||
a.openApplications()
|
||||
a.ui.handle(interaction.Key{Name: "tab"})
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "tab"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
if got := voice.messages[len(voice.messages)-1]; got != "Default has no application alias" {
|
||||
t.Fatal(got)
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "tab", Shift: true})
|
||||
a.ui.handle(internalui.Key{Name: "tab", Shift: true})
|
||||
// Use the list's prefix search, then Tab to the copy button.
|
||||
a.ui.handle(interaction.Key{Text: "n"})
|
||||
a.ui.handle(interaction.Key{Text: "i"})
|
||||
a.ui.handle(interaction.Key{Name: "tab"})
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Text: "n"})
|
||||
a.ui.handle(internalui.Key{Text: "i"})
|
||||
a.ui.handle(internalui.Key{Name: "tab"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
if !a.ui.active || len(a.overrides) != 0 {
|
||||
t.Fatal("copy closed menu or selected an override")
|
||||
}
|
||||
@@ -149,5 +149,5 @@ func TestApplicationsMenuCopiesAliasWithoutSelecting(t *testing.T) {
|
||||
if !ok || text != applicationAlias("ninjam", "") {
|
||||
t.Fatal("wrong clipboard contents", text)
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "escape"})
|
||||
a.ui.handle(internalui.Key{Name: "escape"})
|
||||
}
|
||||
@@ -15,11 +15,11 @@ import (
|
||||
"git.stormux.org/storm/fenrir/internal/applicationoverrides/rogue"
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/i18n"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/presentation"
|
||||
"git.stormux.org/storm/fenrir/internal/prompt"
|
||||
"git.stormux.org/storm/fenrir/internal/reader"
|
||||
"git.stormux.org/storm/fenrir/internal/screen"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
type overrideSnapshot struct {
|
||||
@@ -362,10 +362,10 @@ func (a *application) openApplications() {
|
||||
if selected := a.overrides[a.lastTerminal]; selected != nil {
|
||||
position = slices.Index(ids, selected.id)
|
||||
}
|
||||
session, err := interaction.NewSession(interaction.Form{Type: interaction.TabForm, Title: "Applications", Tabs: []interaction.Tab{{ID: "applications", Label: "Applications", Controls: []interaction.Control{
|
||||
{ID: "application", Label: "Application", Kind: interaction.List, Items: items, Selected: position, Action: "activate"},
|
||||
{ID: "copy_alias", Label: "Copy alias to clipboard", Kind: interaction.Button, Action: "copy_alias"},
|
||||
{ID: "cancel", Label: "Cancel", Kind: interaction.Button, Action: "cancel"},
|
||||
session, err := newInternalUISession(internalui.Form{Type: internalui.TabForm, Title: "Applications", Tabs: []internalui.Tab{{ID: "applications", Label: "Applications", Controls: []internalui.Control{
|
||||
{ID: "application", Label: "Application", Kind: internalui.List, Items: items, Selected: position, Action: "activate"},
|
||||
{ID: "copy_alias", Label: "Copy alias to clipboard", Kind: internalui.Button, Action: "copy_alias"},
|
||||
{ID: "cancel", Label: "Cancel", Kind: internalui.Button, Action: "cancel"},
|
||||
}}}})
|
||||
if err != nil {
|
||||
a.ui.failed("Could not open Applications: {0}", err)
|
||||
@@ -375,9 +375,9 @@ func (a *application) openApplications() {
|
||||
a.ui.failed("Could not open Applications: {0}", err)
|
||||
return
|
||||
}
|
||||
session.Handle(interaction.Key{Name: "tab"}) // Start on the list, not its tab strip.
|
||||
session.Handle(internalui.Key{Name: "tab"}) // Start on the list, not its tab strip.
|
||||
a.ui.session = session
|
||||
a.ui.action = func(action string, session *interaction.Session) {
|
||||
a.ui.action = func(action string, session *internalui.Session) {
|
||||
if action == "cancel" {
|
||||
a.ui.close()
|
||||
return
|
||||
|
||||
@@ -17,9 +17,9 @@ import (
|
||||
"git.stormux.org/storm/fenrir/internal/command"
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/input"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/screen"
|
||||
"git.stormux.org/storm/fenrir/internal/speech"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
func overrideScreen(terminal int, kind string) screen.Snapshot {
|
||||
@@ -49,11 +49,11 @@ func TestRogueMenuSelectionNamedReadProfileAndShellExit(t *testing.T) {
|
||||
a, voice := persistenceApplication(t, true)
|
||||
overrideRead(t, a, overrideScreen(1, "rogue"))
|
||||
a.openApplications()
|
||||
a.ui.handle(interaction.Key{Text: "r"})
|
||||
a.ui.handle(internalui.Key{Text: "r"})
|
||||
if got := voice.messages[len(voice.messages)-1]; got != "Rogue" {
|
||||
t.Fatal(got)
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
overrideRead(t, a, overrideScreen(1, "rogue"))
|
||||
if a.overrideCurrent == nil || a.overrideCurrent.id != "rogue" {
|
||||
t.Fatal("Rogue not activated")
|
||||
@@ -228,7 +228,7 @@ func TestApplicationsMenuActivatesOnlyOnEnterAndReleasesCapture(t *testing.T) {
|
||||
{"down", "Codex"},
|
||||
{"up", "Rogue"},
|
||||
} {
|
||||
a.ui.handle(interaction.Key{Name: step.key})
|
||||
a.ui.handle(internalui.Key{Name: step.key})
|
||||
if got := voice.messages[len(voice.messages)-1]; got != step.want {
|
||||
t.Fatalf("%s announcement = %q, want %q", step.key, got, step.want)
|
||||
}
|
||||
@@ -236,14 +236,14 @@ func TestApplicationsMenuActivatesOnlyOnEnterAndReleasesCapture(t *testing.T) {
|
||||
if len(a.overrides) != 0 {
|
||||
t.Fatal("navigation activated override")
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "escape"})
|
||||
a.ui.handle(internalui.Key{Name: "escape"})
|
||||
if len(a.overrides) != 0 || a.ui.active {
|
||||
t.Fatal("cancel activated override")
|
||||
}
|
||||
a.openApplications()
|
||||
a.ui.handle(interaction.Key{Name: "down"})
|
||||
a.ui.handle(interaction.Key{Name: "down"})
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "down"})
|
||||
a.ui.handle(internalui.Key{Name: "down"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
if a.ui.active || a.overrides[1] == nil || a.overrides[1].id != "ninjam" {
|
||||
t.Fatal("activation failed")
|
||||
}
|
||||
@@ -255,17 +255,17 @@ func TestApplicationsMenuActivatesOnlyOnEnterAndReleasesCapture(t *testing.T) {
|
||||
if a.ui.session.Values()["applications.application"].Selected != 2 {
|
||||
t.Fatal("active item not selected")
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "tab"})
|
||||
a.ui.handle(interaction.Key{Name: "tab"}) // Skip Copy alias to reach Cancel.
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "tab"})
|
||||
a.ui.handle(internalui.Key{Name: "tab"}) // Skip Copy alias to reach Cancel.
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
if a.ui.active || a.overrides[1] == nil {
|
||||
t.Fatal("Cancel button changed selection")
|
||||
}
|
||||
a.openApplications()
|
||||
a.ui.handle(interaction.Key{Name: "down"}) // Rogue
|
||||
a.ui.handle(interaction.Key{Name: "down"}) // Codex
|
||||
a.ui.handle(interaction.Key{Name: "down"}) // list wraps to Default
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "down"}) // Rogue
|
||||
a.ui.handle(internalui.Key{Name: "down"}) // Codex
|
||||
a.ui.handle(internalui.Key{Name: "down"}) // list wraps to Default
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
if a.savesUnavailable() || a.engine.TrackingMode() != "cursor" {
|
||||
t.Fatal("default failed")
|
||||
}
|
||||
@@ -276,7 +276,7 @@ func TestApplicationsMenuPrefixSearch(t *testing.T) {
|
||||
overrideRead(t, a, overrideScreen(1, "ninjam"))
|
||||
a.openApplications()
|
||||
for _, step := range []struct{ text, want string }{{"n", "NetworkManager"}, {"i", "Ninjam"}} {
|
||||
a.ui.handle(interaction.Key{Text: step.text})
|
||||
a.ui.handle(internalui.Key{Text: step.text})
|
||||
if got := voice.messages[len(voice.messages)-1]; got != step.want {
|
||||
t.Fatalf("typed %q: got %q, want %q", step.text, got, step.want)
|
||||
}
|
||||
@@ -284,7 +284,7 @@ func TestApplicationsMenuPrefixSearch(t *testing.T) {
|
||||
t.Fatal("search activated an override or closed the menu")
|
||||
}
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
if a.ui.active || a.overrides[1] == nil || a.overrides[1].id != "ninjam" {
|
||||
t.Fatal("Enter did not activate the search result")
|
||||
}
|
||||
@@ -337,9 +337,9 @@ func TestOverrideSavesOwnDraftAndRestoresSession(t *testing.T) {
|
||||
if control, ok := a.ui.session.FocusedControl(); ok && control.Action == "save" {
|
||||
break
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "tab"})
|
||||
a.ui.handle(internalui.Key{Name: "tab"})
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
finishPersistence(t, a, false)
|
||||
a.ui.close()
|
||||
a.selectOverride("default")
|
||||
@@ -589,9 +589,9 @@ func TestApplicationMenuPreservesSessionTogglesAndLaunchChoices(t *testing.T) {
|
||||
if control, ok := a.ui.session.FocusedControl(); ok && control.Action == "save" {
|
||||
break
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "tab"})
|
||||
a.ui.handle(internalui.Key{Name: "tab"})
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
finishPersistence(t, a, false)
|
||||
if !a.muted || a.engine.AutomaticReading() || a.settings.live.Keyboard.Layout != "desktop" || a.settings.live.Presentation.Speech.Driver != "speech-dispatcher" || a.settings.live.Presentation.Speech.Voice != "" {
|
||||
t.Fatal("menu changed session toggles or launch-only choices")
|
||||
|
||||
@@ -15,9 +15,9 @@ import (
|
||||
"git.stormux.org/storm/fenrir/internal/command"
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/input"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/presentation"
|
||||
"git.stormux.org/storm/fenrir/internal/screen"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
func TestQuickAttributesChoicesMenuCancelSaveAndRestart(t *testing.T) {
|
||||
@@ -57,7 +57,7 @@ func TestQuickAttributesChoicesMenuCancelSaveAndRestart(t *testing.T) {
|
||||
if control.Choices[control.Selected].ID != "both" {
|
||||
t.Fatal("menu lost quick choice", control)
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "escape"})
|
||||
ui.handle(internalui.Key{Name: "escape"})
|
||||
saved, _, err := config.Load(path, nil)
|
||||
if err != nil || saved.Reading.Attributes != "none" {
|
||||
t.Fatal("cancel saved choice", saved.Reading, err)
|
||||
@@ -174,7 +174,7 @@ func TestMenuAttributesAppliesOnlyAfterSuccessfulSave(t *testing.T) {
|
||||
step := 0
|
||||
keys.poll = func(_ bool, handle func(input.Decision)) error {
|
||||
step++
|
||||
key := func(name string) { handle(input.Decision{UI: &interaction.Key{Name: name}}) }
|
||||
key := func(name string) { handle(input.Decision{UI: &internalui.Key{Name: name}}) }
|
||||
switch step {
|
||||
case 1:
|
||||
handle(input.Decision{Command: command.FenrirMenu})
|
||||
|
||||
@@ -14,9 +14,9 @@ import (
|
||||
"git.stormux.org/storm/fenrir/internal/command"
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/input"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/screen"
|
||||
"git.stormux.org/storm/screenreader-common/datetime"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
func TestTimeDateMenuAppliesOnlyAfterSave(t *testing.T) {
|
||||
@@ -47,7 +47,7 @@ func TestTimeDateMenuAppliesOnlyAfterSave(t *testing.T) {
|
||||
step := 0
|
||||
keys.poll = func(_ bool, handle func(input.Decision)) error {
|
||||
step++
|
||||
key := func(name string, shift bool) { handle(input.Decision{UI: &interaction.Key{Name: name, Shift: shift}}) }
|
||||
key := func(name string, shift bool) { handle(input.Decision{UI: &internalui.Key{Name: name, Shift: shift}}) }
|
||||
switch step {
|
||||
case 1:
|
||||
handle(input.Decision{Command: command.FenrirMenu})
|
||||
|
||||
@@ -7,8 +7,8 @@ package app
|
||||
import (
|
||||
"git.stormux.org/storm/fenrir/internal/emoji"
|
||||
"git.stormux.org/storm/fenrir/internal/i18n"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/presentation"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
func (ui *internalUI) openEmoji(clipboards *clipboardHost) {
|
||||
@@ -23,7 +23,7 @@ func (ui *internalUI) openEmoji(clipboards *clipboardHost) {
|
||||
}
|
||||
ui.configureSession(session)
|
||||
ui.session = session
|
||||
ui.action = func(action string, session *interaction.Session) {
|
||||
ui.action = func(action string, session *internalui.Session) {
|
||||
if action != "copy_emoji" {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
"git.stormux.org/storm/fenrir/internal/clipboard"
|
||||
"git.stormux.org/storm/fenrir/internal/command"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
func TestEmojiMenuCancellationCopyAndStaleClipboardSync(t *testing.T) {
|
||||
@@ -28,22 +28,22 @@ func TestEmojiMenuCancellationCopyAndStaleClipboardSync(t *testing.T) {
|
||||
if voice.messages[0] != "Emoji Menu. All tab" {
|
||||
t.Fatal(voice.messages)
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(interaction.Key{Text: query})
|
||||
ui.handle(interaction.Key{Name: "escape"})
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Text: query})
|
||||
ui.handle(internalui.Key{Name: "escape"})
|
||||
if got, _ := host.history.Current(); got != "original" || host.revision != stale.Revision {
|
||||
t.Fatal("cancel changed clipboard", got)
|
||||
}
|
||||
ui.openEmoji(host)
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(interaction.Key{Text: query + "zzzz"})
|
||||
ui.handle(interaction.Key{Name: "enter"})
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Text: query + "zzzz"})
|
||||
ui.handle(internalui.Key{Name: "enter"})
|
||||
if !ui.active {
|
||||
t.Fatal("empty results closed menu")
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "backspace", Ctrl: true})
|
||||
ui.handle(interaction.Key{Text: query})
|
||||
ui.handle(interaction.Key{Name: "enter"})
|
||||
ui.handle(internalui.Key{Name: "backspace", Ctrl: true})
|
||||
ui.handle(internalui.Key{Text: query})
|
||||
ui.handle(internalui.Key{Name: "enter"})
|
||||
want := map[string]string{"Jack": "🎃", "Black cat": "🐈⬛", "United States": "🇺🇸", "Coffin": "⚰️"}[query]
|
||||
if got, _ := host.history.Current(); got != want || ui.active || !host.dirty {
|
||||
t.Fatal("selection not copied", got, ui.active, host.dirty)
|
||||
|
||||
@@ -22,8 +22,8 @@ import (
|
||||
"errors"
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/i18n"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/preferences"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -43,7 +43,7 @@ func (ui *internalUI) openSettingsContext(settings config.Settings, path string,
|
||||
}
|
||||
if ui.previewSpelling != nil {
|
||||
ui.onClosed = func() { ui.previewSpelling(settings.Reading) }
|
||||
ui.changed = func(session *interaction.Session) {
|
||||
ui.changed = func(session *internalui.Session) {
|
||||
values := session.Values()
|
||||
draft := settings.Reading
|
||||
draft.Spellcheck = values["reading.spellcheck"].Checked
|
||||
@@ -92,7 +92,7 @@ func (ui *internalUI) openSettingsContext(settings config.Settings, path string,
|
||||
if ui.discoverChoices != nil {
|
||||
discovery = ui.discoverChoices(doc.Settings)
|
||||
}
|
||||
var session *interaction.Session
|
||||
var session *internalui.Session
|
||||
if applicationBase != nil {
|
||||
session, err = preferences.NewApplicationSession(doc.Settings, doc.Order, title, discovery.Choices(doc.Settings))
|
||||
} else {
|
||||
@@ -107,7 +107,7 @@ func (ui *internalUI) openSettingsContext(settings config.Settings, path string,
|
||||
if applicationBase != nil {
|
||||
baseReadSettings = preferences.ApplicationSettings
|
||||
}
|
||||
readSettings := func(s *interaction.Session, base config.Settings) (config.Settings, error) {
|
||||
readSettings := func(s *internalui.Session, base config.Settings) (config.Settings, error) {
|
||||
next, err := baseReadSettings(s, base)
|
||||
next.VoiceProfiles = profileDraft.Clone()
|
||||
return next, err
|
||||
@@ -117,7 +117,7 @@ func (ui *internalUI) openSettingsContext(settings config.Settings, path string,
|
||||
pending := map[string]bool{}
|
||||
var tested config.Speech
|
||||
var testSequence uint64
|
||||
previewSpeech := func(session *interaction.Session) {
|
||||
previewSpeech := func(session *internalui.Session) {
|
||||
if ui.previewSpeech == nil {
|
||||
return
|
||||
}
|
||||
@@ -125,7 +125,7 @@ func (ui *internalUI) openSettingsContext(settings config.Settings, path string,
|
||||
ui.previewSpeech(draft.Presentation.Speech)
|
||||
}
|
||||
}
|
||||
changed := func(session *interaction.Session) {
|
||||
changed := func(session *internalui.Session) {
|
||||
if previewChanged != nil {
|
||||
previewChanged(session)
|
||||
}
|
||||
@@ -174,8 +174,8 @@ func (ui *internalUI) openSettingsContext(settings config.Settings, path string,
|
||||
}})
|
||||
}(previous)
|
||||
}
|
||||
var action func(string, *interaction.Session)
|
||||
action = func(name string, session *interaction.Session) {
|
||||
var action func(string, *internalui.Session)
|
||||
action = func(name string, session *internalui.Session) {
|
||||
if strings.HasSuffix(name, "-profile") && applicationBase == nil {
|
||||
draft, err := readSettings(session, doc.Settings)
|
||||
if err != nil {
|
||||
|
||||
@@ -14,9 +14,9 @@ import (
|
||||
"time"
|
||||
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/preferences"
|
||||
"git.stormux.org/storm/fenrir/internal/speech"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
func focusUiControl(t *testing.T, ui *internalUI, id string) {
|
||||
@@ -25,7 +25,7 @@ func focusUiControl(t *testing.T, ui *internalUI, id string) {
|
||||
if control, ok := ui.session.FocusedControl(); ok && control.ID == id {
|
||||
return
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
}
|
||||
t.Fatal("control not reachable", id)
|
||||
}
|
||||
@@ -42,11 +42,11 @@ func hardwareFormApplication(t *testing.T) (*application, string, *fakeVoice) {
|
||||
receiveUi(t, a.ui)
|
||||
t.Cleanup(func() { a.ui.close(); a.ui.testWorkers.Wait() })
|
||||
focusUiControl(t, a.ui, "speech.driver")
|
||||
a.ui.handle(interaction.Key{Name: "down"})
|
||||
a.ui.handle(internalui.Key{Name: "down"})
|
||||
focusUiControl(t, a.ui, "speech.hardware_device")
|
||||
a.ui.handle(interaction.Key{Text: "/dev/fixture-synth"})
|
||||
a.ui.handle(internalui.Key{Text: "/dev/fixture-synth"})
|
||||
focusUiControl(t, a.ui, "speech.hardware_baud_rate")
|
||||
a.ui.handle(interaction.Key{Name: "end"})
|
||||
a.ui.handle(internalui.Key{Name: "end"})
|
||||
return a, path, voice
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ func TestHardwarePreviewUsesUnsavedDraftAndSaveKeepsActiveDriver(t *testing.T) {
|
||||
return ctx.Err()
|
||||
}
|
||||
focusUiControl(t, a.ui, "speech.test")
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
select {
|
||||
case selected := <-requested:
|
||||
if selected.Driver != "dectalk" || selected.HardwareDevice != "/dev/fixture-synth" || selected.HardwareBaudRate != 115200 {
|
||||
@@ -80,15 +80,15 @@ func TestHardwarePreviewUsesUnsavedDraftAndSaveKeepsActiveDriver(t *testing.T) {
|
||||
t.Fatal("test replaced active driver or closed menu")
|
||||
}
|
||||
focusUiControl(t, a.ui, "speech.hardware_device")
|
||||
a.ui.handle(interaction.Key{Ctrl: true, Text: "a"})
|
||||
a.ui.handle(interaction.Key{Text: "/dev/fixture-updated"})
|
||||
a.ui.handle(internalui.Key{Ctrl: true, Text: "a"})
|
||||
a.ui.handle(internalui.Key{Text: "/dev/fixture-updated"})
|
||||
select {
|
||||
case <-stopped:
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("editing did not cancel preview")
|
||||
}
|
||||
focusUiControl(t, a.ui, "ok")
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
finishPersistence(t, a, false)
|
||||
saved, _, err := config.Load(path, nil)
|
||||
if err != nil || saved.Presentation.Speech.HardwareDevice != "/dev/fixture-updated" || saved.Presentation.Speech.HardwareBaudRate != 115200 {
|
||||
@@ -106,7 +106,7 @@ func TestHardwarePreviewFailureAndCloseDoNotWriteOrDeliverStaleFeedback(t *testi
|
||||
return errors.New("fixture port unavailable")
|
||||
}
|
||||
focusUiControl(t, a.ui, "speech.test")
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
receiveUi(t, a.ui)
|
||||
if got := voice.messages[len(voice.messages)-1]; !strings.Contains(got, "Voice test failed") || !strings.Contains(got, "fixture port unavailable") {
|
||||
t.Fatal(got)
|
||||
@@ -118,7 +118,7 @@ func TestHardwarePreviewFailureAndCloseDoNotWriteOrDeliverStaleFeedback(t *testi
|
||||
<-release
|
||||
return errors.New("stale fixture failure")
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
select {
|
||||
case <-started:
|
||||
case <-time.After(time.Second):
|
||||
@@ -189,7 +189,7 @@ func TestDriverCatalogArrivesWithoutOverwritingAnotherDriverOrMovingFocus(t *tes
|
||||
receiveUi(t, a.ui)
|
||||
<-queries
|
||||
focusUiControl(t, a.ui, "speech.driver")
|
||||
a.ui.handle(interaction.Key{Name: "home"})
|
||||
a.ui.handle(internalui.Key{Name: "home"})
|
||||
select {
|
||||
case id := <-queries:
|
||||
if id != "speech-dispatcher" {
|
||||
@@ -198,13 +198,13 @@ func TestDriverCatalogArrivesWithoutOverwritingAnotherDriverOrMovingFocus(t *tes
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("new driver catalog not requested")
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "down"})
|
||||
a.ui.handle(internalui.Key{Name: "down"})
|
||||
releases <- struct{}{}
|
||||
receiveUi(t, a.ui)
|
||||
if !a.ui.session.Values()["presentation.speech.module"].Hidden {
|
||||
t.Fatal("stale catalog changed driver visibility")
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "home"})
|
||||
a.ui.handle(internalui.Key{Name: "home"})
|
||||
control, _ := a.ui.session.FocusedControl()
|
||||
if control.ID != "speech.driver" || len(a.ui.session.Values()["presentation.speech.module"].Choices) != 2 {
|
||||
t.Fatal("catalog/focus not restored", control)
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
"git.stormux.org/storm/fenrir/internal/command"
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/input"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/screen"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
type unavailableIndentationSounds struct{ fakeSounds }
|
||||
@@ -103,7 +103,7 @@ func TestQuickIndentationChoicesMenuCancelSaveAndRestart(t *testing.T) {
|
||||
if control.Choices[control.Selected].ID != "both" {
|
||||
t.Fatal("menu lost quick choice", control)
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "escape"})
|
||||
ui.handle(internalui.Key{Name: "escape"})
|
||||
saved, _, err := config.Load(path, nil)
|
||||
if err != nil || saved.Reading.Indentation != "none" {
|
||||
t.Fatal("cancel saved choice", saved.Reading, err)
|
||||
@@ -161,7 +161,7 @@ func TestMenuIndentationAppliesOnlyAfterSuccessfulSave(t *testing.T) {
|
||||
step := 0
|
||||
keys.poll = func(_ bool, handle func(input.Decision)) error {
|
||||
step++
|
||||
key := func(name string) { handle(input.Decision{UI: &interaction.Key{Name: name}}) }
|
||||
key := func(name string) { handle(input.Decision{UI: &internalui.Key{Name: name}}) }
|
||||
switch step {
|
||||
case 1:
|
||||
handle(input.Decision{Command: command.FenrirMenu})
|
||||
|
||||
+15
-10
@@ -26,8 +26,8 @@ import (
|
||||
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/i18n"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/preferences"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
// internalUI is the host boundary for every form type and feature. All state
|
||||
@@ -45,12 +45,12 @@ type internalUI struct {
|
||||
tutorial *tutorialMode
|
||||
name string
|
||||
generation uint64
|
||||
session *interaction.Session
|
||||
action func(string, *interaction.Session)
|
||||
session *internalui.Session
|
||||
action func(string, *internalui.Session)
|
||||
updates chan uiUpdate
|
||||
saveSettings func(*config.Document, config.Settings, func(error)) bool
|
||||
discoverChoices func(config.Settings) preferences.Discovery
|
||||
changed func(*interaction.Session)
|
||||
changed func(*internalui.Session)
|
||||
returnToParent func()
|
||||
onClosed func()
|
||||
gridSettings func() config.InternalUI
|
||||
@@ -69,13 +69,18 @@ type uiUpdate struct {
|
||||
apply func() // Event-loop-only completion; guarded by menu generation.
|
||||
discovery *preferences.Discovery
|
||||
generation uint64
|
||||
session *interaction.Session
|
||||
action func(string, *interaction.Session)
|
||||
session *internalui.Session
|
||||
action func(string, *internalui.Session)
|
||||
speech string
|
||||
changed func(*interaction.Session)
|
||||
changed func(*internalui.Session)
|
||||
close bool
|
||||
}
|
||||
|
||||
// newInternalUISession opens a shared toolkit session with Fenrir's catalog.
|
||||
func newInternalUISession(form internalui.Form) (*internalui.Session, error) {
|
||||
return internalui.NewSession(form, internalui.Messages{Translate: i18n.T})
|
||||
}
|
||||
|
||||
func newInternalUi(ctx context.Context, keys Keyboards, voice Speaker) *internalUI {
|
||||
ui := &internalUI{ctx: ctx, keys: keys, voice: voice, updates: make(chan uiUpdate, 8)}
|
||||
ui.testSpeech = ui.testSynthesizer
|
||||
@@ -182,14 +187,14 @@ func (ui *internalUI) update(update uiUpdate) {
|
||||
}
|
||||
}
|
||||
|
||||
func (ui *internalUI) configureSession(session *interaction.Session) {
|
||||
func (ui *internalUI) configureSession(session *internalui.Session) {
|
||||
if ui.gridSettings != nil {
|
||||
settings := ui.gridSettings()
|
||||
session.ConfigureGrid(settings.AnnounceGridCoordinates, settings.AnnounceItemPosition)
|
||||
}
|
||||
}
|
||||
|
||||
func (ui *internalUI) handle(key interaction.Key) {
|
||||
func (ui *internalUI) handle(key internalui.Key) {
|
||||
if key.Name == "escape" {
|
||||
if ui.returnToParent != nil {
|
||||
ui.returnToParent()
|
||||
@@ -221,7 +226,7 @@ func (ui *internalUI) handle(key interaction.Key) {
|
||||
} else {
|
||||
result.Speech = i18n.T("Copied")
|
||||
if strings.EqualFold(key.Text, "x") {
|
||||
result = ui.session.Handle(interaction.Key{Name: "delete"})
|
||||
result = ui.session.Handle(internalui.Key{Name: "delete"})
|
||||
result.Speech = i18n.T("Cut")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,19 +4,19 @@ package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestInternalUIClipboardCutFailurePasteAndSecretClose(t *testing.T) {
|
||||
ui := newInternalUi(context.Background(), &fakeKeys{}, &fakeVoice{})
|
||||
s, err := interaction.NewSession(interaction.Form{Type: interaction.TabForm, Title: "Edit", Tabs: []interaction.Tab{{ID: "p", Label: "Page", Controls: []interaction.Control{{ID: "e", Label: "Text", Kind: interaction.Entry, Text: "one two"}, {ID: "password", Label: "Password", Kind: interaction.Entry, Secret: true, Text: "private"}}}}})
|
||||
s, err := newInternalUISession(internalui.Form{Type: internalui.TabForm, Title: "Edit", Tabs: []internalui.Tab{{ID: "p", Label: "Page", Controls: []internalui.Control{{ID: "e", Label: "Text", Kind: internalui.Entry, Text: "one two"}, {ID: "password", Label: "Password", Kind: internalui.Entry, Secret: true, Text: "private"}}}}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ui.active, ui.session = true, s
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(interaction.Key{Name: "left", Ctrl: true, Shift: true})
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Name: "left", Ctrl: true, Shift: true})
|
||||
copies := 0
|
||||
ui.writeClipboard = func(text string) bool {
|
||||
copies++
|
||||
@@ -25,23 +25,23 @@ func TestInternalUIClipboardCutFailurePasteAndSecretClose(t *testing.T) {
|
||||
}
|
||||
return false
|
||||
}
|
||||
ui.handle(interaction.Key{Ctrl: true, Text: "x"})
|
||||
ui.handle(internalui.Key{Ctrl: true, Text: "x"})
|
||||
if s.Values()["p.e"].Text != "one two" {
|
||||
t.Fatal("failed cut deleted text")
|
||||
}
|
||||
ui.writeClipboard = func(text string) bool { copies++; return text == "two" }
|
||||
ui.handle(interaction.Key{Ctrl: true, Text: "x"})
|
||||
ui.handle(internalui.Key{Ctrl: true, Text: "x"})
|
||||
if s.Values()["p.e"].Text != "one " {
|
||||
t.Fatal("successful cut failed")
|
||||
}
|
||||
ui.readClipboard = func() (string, bool) { return "猫", true }
|
||||
ui.handle(interaction.Key{Ctrl: true, Text: "v"})
|
||||
ui.handle(internalui.Key{Ctrl: true, Text: "v"})
|
||||
if s.Values()["p.e"].Text != "one 猫" {
|
||||
t.Fatal("paste failed")
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(interaction.Key{Ctrl: true, Text: "a"})
|
||||
ui.handle(interaction.Key{Ctrl: true, Text: "c"})
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Ctrl: true, Text: "a"})
|
||||
ui.handle(internalui.Key{Ctrl: true, Text: "c"})
|
||||
if copies != 2 {
|
||||
t.Fatal("secret copied")
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
func TestInternalUIMenuSaveAndCancel(t *testing.T) {
|
||||
@@ -20,17 +20,17 @@ func TestInternalUIMenuSaveAndCancel(t *testing.T) {
|
||||
if count > 20 {
|
||||
t.Fatal("Internal UI tab missing")
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "right"})
|
||||
a.ui.handle(internalui.Key{Name: "right"})
|
||||
}
|
||||
for range 2 {
|
||||
a.ui.handle(interaction.Key{Name: "tab"})
|
||||
a.ui.handle(interaction.Key{Name: "space"})
|
||||
a.ui.handle(internalui.Key{Name: "tab"})
|
||||
a.ui.handle(internalui.Key{Name: "space"})
|
||||
}
|
||||
if save {
|
||||
a.ui.action("save", a.ui.session)
|
||||
a.settingsSaveResult(committedMenuResult(t, a))
|
||||
} else {
|
||||
a.ui.handle(interaction.Key{Name: "escape"})
|
||||
a.ui.handle(internalui.Key{Name: "escape"})
|
||||
}
|
||||
loaded, _, err := config.Load(a.options.ConfigPath, nil)
|
||||
want := config.InternalUI{AnnounceGridCoordinates: !save, AnnounceItemPosition: !save}
|
||||
@@ -38,11 +38,11 @@ func TestInternalUIMenuSaveAndCancel(t *testing.T) {
|
||||
t.Fatal("save/cancel diverged", loaded.InternalUI, a.settings.live.InternalUI, err)
|
||||
}
|
||||
a.ui.openEmoji(a.clipboards)
|
||||
a.ui.handle(interaction.Key{Name: "tab"})
|
||||
a.ui.handle(internalui.Key{Name: "tab"})
|
||||
got := voice.messages[len(voice.messages)-1]
|
||||
if strings.Contains(got, "row 1, column 1") != !save || strings.Contains(got, "1 of ") != !save {
|
||||
t.Fatal("Emoji did not use saved grid preferences", got)
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "escape"})
|
||||
a.ui.handle(internalui.Key{Name: "escape"})
|
||||
}
|
||||
}
|
||||
@@ -30,8 +30,8 @@ import (
|
||||
"git.stormux.org/storm/fenrir/internal/command"
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/input"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/screen"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
func settingsUiApplication(t *testing.T, keys *fakeKeys, voice *fakeVoice, path string) *application {
|
||||
@@ -70,12 +70,12 @@ func TestSettingsMenuCancelSaveAndReopen(t *testing.T) {
|
||||
t.Fatal(ui.active, voice.messages)
|
||||
}
|
||||
tabToControl(t, ui, "speech.rate")
|
||||
ui.handle(interaction.Key{Name: "up"})
|
||||
ui.handle(internalui.Key{Name: "up"})
|
||||
if action == "escape" {
|
||||
ui.handle(interaction.Key{Name: "escape"})
|
||||
ui.handle(internalui.Key{Name: "escape"})
|
||||
} else {
|
||||
tabToControl(t, ui, map[string]string{"save": "ok", "cancel": "cancel"}[action])
|
||||
ui.handle(interaction.Key{Name: "enter"})
|
||||
ui.handle(internalui.Key{Name: "enter"})
|
||||
if action == "save" {
|
||||
finishPersistence(t, a, false)
|
||||
}
|
||||
@@ -130,7 +130,7 @@ func TestMenuSoundVolumeAppliesOnlyAfterSuccessfulSave(t *testing.T) {
|
||||
step := 0
|
||||
keys.poll = func(_ bool, handle func(input.Decision)) error {
|
||||
step++
|
||||
key := func(name string, shift bool) { handle(input.Decision{UI: &interaction.Key{Name: name, Shift: shift}}) }
|
||||
key := func(name string, shift bool) { handle(input.Decision{UI: &internalui.Key{Name: name, Shift: shift}}) }
|
||||
switch step {
|
||||
case 1:
|
||||
handle(input.Decision{Command: command.FenrirMenu})
|
||||
@@ -203,8 +203,8 @@ func TestMenuSaveFailureRetainsEditsAndCapture(t *testing.T) {
|
||||
ui := a.ui
|
||||
ui.openSettings(config.Defaults(), path)
|
||||
receiveUi(t, ui)
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(interaction.Key{Name: "space"}) // Speech enabled false.
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Name: "space"}) // Speech enabled false.
|
||||
other := config.Defaults()
|
||||
other.Presentation.Speech.Rate = 12
|
||||
if err := config.Save(path, other); err != nil {
|
||||
@@ -219,7 +219,7 @@ func TestMenuSaveFailureRetainsEditsAndCapture(t *testing.T) {
|
||||
if !strings.Contains(voice.messages[len(voice.messages)-1], "settings changed") {
|
||||
t.Fatal(voice.messages)
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "escape"})
|
||||
ui.handle(internalui.Key{Name: "escape"})
|
||||
settings, _, err := config.Load(path, nil)
|
||||
if err != nil || settings.Presentation.Speech.Rate != 12 {
|
||||
t.Fatal("external edit overwritten", settings, err)
|
||||
@@ -251,7 +251,7 @@ func TestInternalUICloseUsesTitleWithoutLoadedSessionAndOnlyOnce(t *testing.T) {
|
||||
if _, err := ui.begin(title); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "escape"})
|
||||
ui.handle(internalui.Key{Name: "escape"})
|
||||
ui.close()
|
||||
if ui.active || !reflect.DeepEqual(voice.messages, []string{title + " closed"}) || !reflect.DeepEqual(keys.captures, []bool{true, false}) {
|
||||
t.Fatal(title, ui.active, voice.messages, keys.captures)
|
||||
@@ -285,7 +285,7 @@ func TestMenuSuppressesBackgroundScreenAndRestoresCommands(t *testing.T) {
|
||||
}
|
||||
if step == 2 {
|
||||
handle(input.Decision{Command: command.PassNext}) // Blocked while UI owns input.
|
||||
handle(input.Decision{UI: &interaction.Key{Name: "escape"}, Interrupt: true})
|
||||
handle(input.Decision{UI: &internalui.Key{Name: "escape"}, Interrupt: true})
|
||||
handle(input.Decision{Command: command.CurrentLine, Interrupt: true})
|
||||
handle(input.Decision{Command: command.Quit})
|
||||
}
|
||||
@@ -355,7 +355,7 @@ func tabToControl(t *testing.T, ui *internalUI, id string) {
|
||||
if control, ok := ui.session.FocusedControl(); ok && control.ID == id {
|
||||
return
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
}
|
||||
t.Fatalf("control %s not reached with Tab", id)
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"git.stormux.org/storm/fenrir/internal/command"
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/input"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
func admitMenuSave(t *testing.T, a *application) {
|
||||
@@ -19,7 +19,7 @@ func admitMenuSave(t *testing.T, a *application) {
|
||||
a.openSettings()
|
||||
receiveUi(t, a.ui)
|
||||
tabToControl(t, a.ui, "speech.rate")
|
||||
a.ui.handle(interaction.Key{Name: "right"}) // Rate 24 -> 25.
|
||||
a.ui.handle(internalui.Key{Name: "right"}) // Rate 24 -> 25.
|
||||
a.ui.action("save", a.ui.session)
|
||||
if !a.saver.busy || a.ui.session != nil {
|
||||
t.Fatal("menu save was not admitted")
|
||||
@@ -59,7 +59,7 @@ func TestMenuCommitSurvivesCloseAndHandoff(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
default:
|
||||
a.ui.handle(interaction.Key{Name: "escape"})
|
||||
a.ui.handle(internalui.Key{Name: "escape"})
|
||||
}
|
||||
if a.ui.active || a.keyboards.(*fakeKeys).captures[1] {
|
||||
t.Fatal("close did not release capture immediately")
|
||||
|
||||
@@ -15,10 +15,10 @@ import (
|
||||
|
||||
"git.stormux.org/storm/fenrir/internal/diagnostic"
|
||||
"git.stormux.org/storm/fenrir/internal/i18n"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/notifications"
|
||||
"git.stormux.org/storm/fenrir/internal/presentation"
|
||||
"git.stormux.org/storm/screenreader-common/datetime"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
const notificationLimit = notifications.Limit
|
||||
@@ -182,10 +182,10 @@ func (a *application) openNotifications() {
|
||||
timestamp, _ := datetime.FormatTime(a.settings.live.Presentation.DateTime.TimeFormat, entry.received)
|
||||
items = append(items, entry.text+" "+timestamp)
|
||||
}
|
||||
session, err := interaction.NewSession(interaction.Form{Type: interaction.TabForm, Title: "Notifications", Tabs: []interaction.Tab{
|
||||
{ID: "notifications", Label: "Notifications", Controls: []interaction.Control{
|
||||
{ID: "history", Label: "Notifications", Kind: interaction.List, Items: items, Action: "repeat_notification"},
|
||||
{ID: "close", Label: "Close", Kind: interaction.Button, Action: "cancel"},
|
||||
session, err := newInternalUISession(internalui.Form{Type: internalui.TabForm, Title: "Notifications", Tabs: []internalui.Tab{
|
||||
{ID: "notifications", Label: "Notifications", Controls: []internalui.Control{
|
||||
{ID: "history", Label: "Notifications", Kind: internalui.List, Items: items, Action: "repeat_notification"},
|
||||
{ID: "close", Label: "Close", Kind: internalui.Button, Action: "cancel"},
|
||||
}},
|
||||
}})
|
||||
if err != nil {
|
||||
@@ -196,9 +196,9 @@ func (a *application) openNotifications() {
|
||||
a.ui.failed("Could not open Notifications: {0}", err)
|
||||
return
|
||||
}
|
||||
session.Handle(interaction.Key{Name: "tab"})
|
||||
session.Handle(internalui.Key{Name: "tab"})
|
||||
a.ui.session = session
|
||||
a.ui.action = func(action string, session *interaction.Session) {
|
||||
a.ui.action = func(action string, session *internalui.Session) {
|
||||
if action == "repeat_notification" {
|
||||
control := session.Values()["notifications.history"]
|
||||
a.present(control.Items[control.Selected], "")
|
||||
|
||||
@@ -20,8 +20,8 @@ import (
|
||||
"git.stormux.org/storm/fenrir/internal/command"
|
||||
"git.stormux.org/storm/fenrir/internal/control"
|
||||
"git.stormux.org/storm/fenrir/internal/input"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/presentation"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
func TestNotificationSoundCooldownBoundaryAndConcurrentAdmission(t *testing.T) {
|
||||
@@ -289,28 +289,28 @@ func TestNotificationHistoryTimesNavigationAndNewArrivals(t *testing.T) {
|
||||
if !a.ui.active || a.ui.session == nil || !strings.HasSuffix(voice.messages[len(voice.messages)-1], "You are transmatting "+trial.first) {
|
||||
t.Fatal("history did not open at newest entry", trial, voice.messages)
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "down"})
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "down"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
if got := voice.messages[len(voice.messages)-1]; got != "Hello world "+trial.second {
|
||||
t.Fatal("history order, repeat or received time", trial, got)
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "tab"})
|
||||
a.ui.handle(internalui.Key{Name: "tab"})
|
||||
control, _ := a.ui.session.FocusedControl()
|
||||
if control.ID != "close" {
|
||||
t.Fatal("Tab could not reach Close", control)
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "tab", Shift: true})
|
||||
a.ui.handle(internalui.Key{Name: "tab", Shift: true})
|
||||
control, _ = a.ui.session.FocusedControl()
|
||||
if control.ID != "history" {
|
||||
t.Fatal("Shift+Tab could not return to list", control)
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "escape"})
|
||||
a.ui.handle(internalui.Key{Name: "escape"})
|
||||
if a.ui.active || keys.captures[len(keys.captures)-1] {
|
||||
t.Fatal("history did not release capture")
|
||||
}
|
||||
}
|
||||
a.openNotifications()
|
||||
a.ui.handle(interaction.Key{Name: "down"})
|
||||
a.ui.handle(internalui.Key{Name: "down"})
|
||||
selected := a.ui.session.Values()["notifications.history"]
|
||||
a.notify("New arrival", time.Now())
|
||||
if got := a.ui.session.Values()["notifications.history"]; !reflect.DeepEqual(got, selected) {
|
||||
@@ -321,8 +321,8 @@ func TestNotificationHistoryTimesNavigationAndNewArrivals(t *testing.T) {
|
||||
if !strings.Contains(voice.messages[len(voice.messages)-1], "New arrival") {
|
||||
t.Fatal("reopened history missed arrival")
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "tab"})
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "tab"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
if a.ui.active {
|
||||
t.Fatal("Close button did not close history")
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ import (
|
||||
"git.stormux.org/storm/fenrir/internal/command"
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/input"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/presentation"
|
||||
"git.stormux.org/storm/fenrir/internal/screen"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
func promptSnapshot(lines ...string) screen.Snapshot {
|
||||
@@ -107,7 +107,7 @@ func TestPromptRestorationDiscardsBatchAndPreservesModes(t *testing.T) {
|
||||
t.Fatal("repeated restoration", voice.messages, sounds.cues)
|
||||
}
|
||||
if mode == "menu" {
|
||||
handle(input.Decision{UI: &interaction.Key{Name: "escape"}})
|
||||
handle(input.Decision{UI: &internalui.Key{Name: "escape"}})
|
||||
}
|
||||
handle(input.Decision{Command: command.Quit})
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ import (
|
||||
"git.stormux.org/storm/fenrir/internal/command"
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/input"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/preferences"
|
||||
"git.stormux.org/storm/fenrir/internal/screen"
|
||||
"git.stormux.org/storm/fenrir/internal/speech"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
"git.stormux.org/storm/screenreader-common/quicksettings"
|
||||
)
|
||||
|
||||
@@ -176,7 +176,7 @@ func TestQuickChangesSurviveMenuCancelAndExplicitSaveThenQuit(t *testing.T) {
|
||||
if got := ui.session.Values()["presentation.speech.pitch"].Number; got != 0 {
|
||||
t.Fatal(got)
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "escape"})
|
||||
ui.handle(internalui.Key{Name: "escape"})
|
||||
stillSaved, _, err := config.Load(path, nil)
|
||||
if err != nil || !reflect.DeepEqual(saved, stillSaved) {
|
||||
t.Fatal(stillSaved, err)
|
||||
@@ -426,7 +426,7 @@ func TestQuickEchoCombinationsAndMenuCancelOrSave(t *testing.T) {
|
||||
ui.action("save", ui.session)
|
||||
finishPersistence(t, a, false)
|
||||
} else {
|
||||
ui.handle(interaction.Key{Name: "escape"})
|
||||
ui.handle(internalui.Key{Name: "escape"})
|
||||
}
|
||||
disk, _, err := config.Load(path, nil)
|
||||
if !save {
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"time"
|
||||
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/speech"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
func previewApplication(t *testing.T) (*application, *selectingVoice, string, chan config.Speech) {
|
||||
@@ -136,11 +136,11 @@ func TestMenuRateChangeIsHeardAndEscapeRestoresIt(t *testing.T) {
|
||||
a.openSettings()
|
||||
receiveUi(t, a.ui)
|
||||
tabToControl(t, a.ui, "speech.rate")
|
||||
a.ui.handle(interaction.Key{Name: "right"})
|
||||
a.ui.handle(internalui.Key{Name: "right"})
|
||||
if len(voice.parameters) == 0 || voice.parameters[len(voice.parameters)-1].Rate != live.Rate+1 {
|
||||
t.Fatal("menu rate change was not previewed", voice.parameters, live)
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "escape"})
|
||||
a.ui.handle(internalui.Key{Name: "escape"})
|
||||
if got := voice.parameters[len(voice.parameters)-1]; got != live || a.preview.active {
|
||||
t.Fatal("escape did not restore the live voice", got, live)
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ package app
|
||||
|
||||
import (
|
||||
"git.stormux.org/storm/fenrir/internal/i18n"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/presentation"
|
||||
"git.stormux.org/storm/fenrir/internal/spellcheck"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -24,10 +24,10 @@ type spellcheckMenu struct {
|
||||
busy bool
|
||||
}
|
||||
|
||||
func wordChoices(words []string) []interaction.Choice {
|
||||
choices := make([]interaction.Choice, 0, len(words))
|
||||
func wordChoices(words []string) []internalui.Choice {
|
||||
choices := make([]internalui.Choice, 0, len(words))
|
||||
for _, word := range words {
|
||||
choices = append(choices, interaction.Choice{ID: word, Label: word, Literal: true})
|
||||
choices = append(choices, internalui.Choice{ID: word, Label: word, Literal: true})
|
||||
}
|
||||
return choices
|
||||
}
|
||||
@@ -41,16 +41,16 @@ func (h *spellcheckMenu) open(word string) {
|
||||
}
|
||||
h.generation, h.source, h.deleted, h.busy = generation, spellcheck.Word(word), "", false
|
||||
h.revision++
|
||||
session, err := interaction.NewSession(interaction.Form{Type: interaction.TabForm, Title: spellcheckTitle, Tabs: []interaction.Tab{
|
||||
{ID: "suggestions", Label: "Suggestions", Controls: []interaction.Control{
|
||||
{ID: "word", Label: "Word", Kind: interaction.Entry, Text: h.source, Action: "check_word"},
|
||||
{ID: "suggestions", Label: "Suggestions", Kind: interaction.Grid, Columns: 6, Action: "copy_word"},
|
||||
session, err := newInternalUISession(internalui.Form{Type: internalui.TabForm, Title: spellcheckTitle, Tabs: []internalui.Tab{
|
||||
{ID: "suggestions", Label: "Suggestions", Controls: []internalui.Control{
|
||||
{ID: "word", Label: "Word", Kind: internalui.Entry, Text: h.source, Action: "check_word"},
|
||||
{ID: "suggestions", Label: "Suggestions", Kind: internalui.Grid, Columns: 6, Action: "copy_word"},
|
||||
}},
|
||||
{ID: "exceptions", Label: "Exceptions", Controls: []interaction.Control{
|
||||
{ID: "word", Label: "Word", Kind: interaction.Entry, Text: h.source, Action: "add_word"},
|
||||
{ID: "add", Label: "Add", Kind: interaction.Button, Action: "add_word"},
|
||||
{ID: "exceptions", Label: "Exceptions", Kind: interaction.Grid, Columns: 6, Action: "copy_word", DeleteAction: "remove_word"},
|
||||
{ID: "undo", Label: "Undo", Kind: interaction.Button, Action: "undo_remove"},
|
||||
{ID: "exceptions", Label: "Exceptions", Controls: []internalui.Control{
|
||||
{ID: "word", Label: "Word", Kind: internalui.Entry, Text: h.source, Action: "add_word"},
|
||||
{ID: "add", Label: "Add", Kind: internalui.Button, Action: "add_word"},
|
||||
{ID: "exceptions", Label: "Exceptions", Kind: internalui.Grid, Columns: 6, Action: "copy_word", DeleteAction: "remove_word"},
|
||||
{ID: "undo", Label: "Undo", Kind: internalui.Button, Action: "undo_remove"},
|
||||
}},
|
||||
}})
|
||||
if err != nil {
|
||||
@@ -60,7 +60,7 @@ func (h *spellcheckMenu) open(word string) {
|
||||
}
|
||||
ui.configureSession(session)
|
||||
ui.session, ui.action = session, h.action
|
||||
ui.changed = func(session *interaction.Session) {
|
||||
ui.changed = func(session *internalui.Session) {
|
||||
source := session.Values()["suggestions.word"].Text
|
||||
if source != h.source {
|
||||
h.source = source
|
||||
@@ -88,7 +88,7 @@ func (h *spellcheckMenu) poll() {
|
||||
}
|
||||
}
|
||||
|
||||
func (h *spellcheckMenu) action(action string, session *interaction.Session) {
|
||||
func (h *spellcheckMenu) action(action string, session *internalui.Session) {
|
||||
if action == "check_word" {
|
||||
h.revision++
|
||||
h.due = time.Now()
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/spellcheck"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -44,33 +44,33 @@ func TestSpellcheckMenuSuggestionsFilterCopyCancelAndEditableSource(t *testing.T
|
||||
menu := &spellcheckMenu{ui: ui, service: service, clipboards: clipboard}
|
||||
menu.open("helo")
|
||||
receiveSpelling(t, menu)
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(interaction.Key{Text: "zz"})
|
||||
ui.handle(interaction.Key{Name: "enter"})
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Text: "zz"})
|
||||
ui.handle(internalui.Key{Name: "enter"})
|
||||
if !ui.active {
|
||||
t.Fatal("empty suggestions closed menu")
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "escape"})
|
||||
ui.handle(internalui.Key{Name: "escape"})
|
||||
if text, _ := clipboard.history.Current(); text != "original" {
|
||||
t.Fatal(text)
|
||||
}
|
||||
menu.open("helo")
|
||||
receiveSpelling(t, menu)
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(interaction.Key{Text: "hel"})
|
||||
ui.handle(interaction.Key{Name: "right"})
|
||||
ui.handle(interaction.Key{Name: "enter"})
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Text: "hel"})
|
||||
ui.handle(internalui.Key{Name: "right"})
|
||||
ui.handle(internalui.Key{Name: "enter"})
|
||||
if text, _ := clipboard.history.Current(); text != "help" || ui.active {
|
||||
t.Fatal(text, ui.active)
|
||||
}
|
||||
menu.open("helo")
|
||||
receiveSpelling(t, menu)
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(interaction.Key{Text: "a", Ctrl: true})
|
||||
ui.handle(interaction.Key{Text: "hello"})
|
||||
ui.handle(interaction.Key{Name: "enter"})
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Text: "a", Ctrl: true})
|
||||
ui.handle(internalui.Key{Text: "hello"})
|
||||
ui.handle(internalui.Key{Name: "enter"})
|
||||
if result := receiveSpelling(t, menu); result.Word != "hello" || !result.Correct {
|
||||
t.Fatal(result)
|
||||
}
|
||||
@@ -94,33 +94,33 @@ func TestSpellcheckExceptionAddDeleteUndoAndCopy(t *testing.T) {
|
||||
menu := &spellcheckMenu{ui: ui, service: service, clipboards: clipboard}
|
||||
menu.open("Fenrir")
|
||||
receiveSpelling(t, menu)
|
||||
ui.handle(interaction.Key{Name: "right"})
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(interaction.Key{Name: "enter"})
|
||||
ui.handle(internalui.Key{Name: "right"})
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Name: "enter"})
|
||||
if result := receiveSpelling(t, menu); result.Err != nil {
|
||||
t.Fatal(result)
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(interaction.Key{Text: "fen"})
|
||||
ui.handle(interaction.Key{Name: "delete", Repeat: true})
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Text: "fen"})
|
||||
ui.handle(internalui.Key{Name: "delete", Repeat: true})
|
||||
if menu.busy {
|
||||
t.Fatal("held Delete removed exception")
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "delete"})
|
||||
ui.handle(internalui.Key{Name: "delete"})
|
||||
receiveSpelling(t, menu)
|
||||
if !ui.active || len(ui.session.Values()["exceptions.exceptions"].Choices) != 0 {
|
||||
t.Fatal("remove did not retain empty grid")
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(interaction.Key{Name: "enter"})
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Name: "enter"})
|
||||
receiveSpelling(t, menu)
|
||||
ui.handle(interaction.Key{Name: "tab", Shift: true})
|
||||
ui.handle(internalui.Key{Name: "tab", Shift: true})
|
||||
control, _ := ui.session.FocusedControl()
|
||||
if control.Text != "fen" || len(control.Choices) != 1 {
|
||||
t.Fatal(control)
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "enter"})
|
||||
ui.handle(internalui.Key{Name: "enter"})
|
||||
if text, _ := clipboard.history.Current(); text != "Fenrir" || ui.active {
|
||||
t.Fatal(text, ui.active)
|
||||
}
|
||||
@@ -163,29 +163,29 @@ func TestSpellcheckReadingPreviewCancelAndSave(t *testing.T) {
|
||||
if strings.Contains(ui.session.Describe(), "Reading tab") {
|
||||
break
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "right"})
|
||||
ui.handle(internalui.Key{Name: "right"})
|
||||
}
|
||||
for range 32 {
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
if control, ok := ui.session.FocusedControl(); ok && control.ID == "spellcheck" {
|
||||
break
|
||||
}
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "space"})
|
||||
ui.handle(internalui.Key{Name: "space"})
|
||||
if live.Spellcheck {
|
||||
t.Fatal("checkbox preview did not take effect")
|
||||
}
|
||||
if save {
|
||||
for range 32 {
|
||||
ui.handle(interaction.Key{Name: "tab"})
|
||||
ui.handle(internalui.Key{Name: "tab"})
|
||||
if ui.session.Describe() == "OK button" {
|
||||
break
|
||||
}
|
||||
}
|
||||
ui.handle(interaction.Key{Name: "enter"})
|
||||
ui.handle(internalui.Key{Name: "enter"})
|
||||
finishPersistence(t, a, false)
|
||||
} else {
|
||||
ui.handle(interaction.Key{Name: "escape"})
|
||||
ui.handle(internalui.Key{Name: "escape"})
|
||||
}
|
||||
saved, _, err := config.Load(path, nil)
|
||||
if err != nil || live.Spellcheck != !save || saved.Reading.Spellcheck != !save {
|
||||
|
||||
@@ -13,10 +13,10 @@ import (
|
||||
|
||||
"git.stormux.org/storm/fenrir/internal/command"
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/presentation"
|
||||
"git.stormux.org/storm/fenrir/internal/punctuation"
|
||||
"git.stormux.org/storm/fenrir/internal/screen"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
)
|
||||
|
||||
func TestTextProcessingMenuCommitCancelAndFailedSave(t *testing.T) {
|
||||
@@ -53,7 +53,7 @@ func TestTextProcessingMenuCommitCancelAndFailedSave(t *testing.T) {
|
||||
focus := func(want string) {
|
||||
t.Helper()
|
||||
for range 40 {
|
||||
a.ui.handle(interaction.Key{Name: "tab"})
|
||||
a.ui.handle(internalui.Key{Name: "tab"})
|
||||
if voice.messages[len(voice.messages)-1] == want {
|
||||
return
|
||||
}
|
||||
@@ -61,16 +61,16 @@ func TestTextProcessingMenuCommitCancelAndFailedSave(t *testing.T) {
|
||||
t.Fatal("control not found", want, voice.messages)
|
||||
}
|
||||
focus("Emoticons checked")
|
||||
a.ui.handle(interaction.Key{Name: "space"})
|
||||
a.ui.handle(internalui.Key{Name: "space"})
|
||||
focus("Repeated symbols unchecked")
|
||||
a.ui.handle(interaction.Key{Name: "space"})
|
||||
a.ui.handle(internalui.Key{Name: "space"})
|
||||
focus("Repeated symbols minimum length 4")
|
||||
a.ui.handle(interaction.Key{Name: "up"})
|
||||
a.ui.handle(internalui.Key{Name: "up"})
|
||||
if a.settings.live.Reading != settings.Reading {
|
||||
t.Fatal("draft changed runtime processing")
|
||||
}
|
||||
if action == "cancel" {
|
||||
a.ui.handle(interaction.Key{Name: "escape"})
|
||||
a.ui.handle(internalui.Key{Name: "escape"})
|
||||
} else {
|
||||
if action == "failed save" {
|
||||
if err := os.WriteFile(path, []byte("version=3\n[reading]\nemoticons=false\n"), 0600); err != nil {
|
||||
@@ -78,13 +78,13 @@ func TestTextProcessingMenuCommitCancelAndFailedSave(t *testing.T) {
|
||||
}
|
||||
}
|
||||
focus("OK button")
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
finishPersistence(t, a, action == "failed save")
|
||||
if action == "failed save" {
|
||||
if !a.ui.active || !strings.HasPrefix(voice.messages[len(voice.messages)-1], "Could not save settings:") {
|
||||
t.Fatal("failed save lost the draft", voice.messages)
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "escape"})
|
||||
a.ui.handle(internalui.Key{Name: "escape"})
|
||||
}
|
||||
}
|
||||
voice.messages = nil
|
||||
|
||||
@@ -6,13 +6,13 @@ package app
|
||||
import (
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/i18n"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/preferences"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
sd "git.stormux.org/storm/screenreader-common/speechdispatcher"
|
||||
"git.stormux.org/storm/screenreader-common/voiceprofiles"
|
||||
)
|
||||
|
||||
func (ui *internalUI) manageProfiles(action string, parent *interaction.Session, draft config.Settings, discovery preferences.Discovery, restore func(config.Settings)) {
|
||||
func (ui *internalUI) manageProfiles(action string, parent *internalui.Session, draft config.Settings, discovery preferences.Discovery, restore func(config.Settings)) {
|
||||
ui.profileSequence++
|
||||
sequence := ui.profileSequence
|
||||
index := -1
|
||||
@@ -63,7 +63,7 @@ func (ui *internalUI) manageProfiles(action string, parent *interaction.Session,
|
||||
}
|
||||
open := func(catalog sd.Catalog) {
|
||||
editor := voiceprofiles.NewEditor(p, voiceprofiles.Drivers(), catalog)
|
||||
child, err := interaction.NewSession(editor.Form())
|
||||
child, err := newInternalUISession(editor.Form())
|
||||
if err != nil {
|
||||
ui.failed("Could not edit voice profiles: {0}", err)
|
||||
return
|
||||
@@ -71,7 +71,7 @@ func (ui *internalUI) manageProfiles(action string, parent *interaction.Session,
|
||||
parent.Close()
|
||||
ui.session = child
|
||||
ui.returnToParent = func() { restore(draft) }
|
||||
ui.changed = func(session *interaction.Session) {
|
||||
ui.changed = func(session *internalui.Session) {
|
||||
editor.RefreshSession(session)
|
||||
if ui.previewSpeech == nil {
|
||||
return
|
||||
@@ -84,7 +84,7 @@ func (ui *internalUI) manageProfiles(action string, parent *interaction.Session,
|
||||
ui.previewSpeech(next.Presentation.Speech)
|
||||
}
|
||||
}
|
||||
ui.action = func(name string, session *interaction.Session) {
|
||||
ui.action = func(name string, session *internalui.Session) {
|
||||
if name != "save-profile" {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"errors"
|
||||
"git.stormux.org/storm/fenrir/internal/command"
|
||||
"git.stormux.org/storm/fenrir/internal/config"
|
||||
"git.stormux.org/storm/fenrir/internal/interaction"
|
||||
"git.stormux.org/storm/fenrir/internal/preferences"
|
||||
"git.stormux.org/storm/fenrir/internal/speech"
|
||||
"git.stormux.org/storm/screenreader-common/internalui"
|
||||
"git.stormux.org/storm/screenreader-common/voiceprofiles"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -26,23 +26,23 @@ func TestVoiceProfileMenuAddCancelPersistAndRemove(t *testing.T) {
|
||||
if !a.ui.session.FocusControl("voice-profiles", id) {
|
||||
t.Fatal("missing profile control", id)
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
}
|
||||
activate("add")
|
||||
if c, _ := a.ui.session.FocusedControl(); c.ID != "name" {
|
||||
t.Fatal(c)
|
||||
}
|
||||
a.ui.handle(interaction.Key{Text: "Discarded"})
|
||||
a.ui.handle(interaction.Key{Name: "escape"})
|
||||
a.ui.handle(internalui.Key{Text: "Discarded"})
|
||||
a.ui.handle(internalui.Key{Name: "escape"})
|
||||
if !a.ui.active || a.ui.session.Values()["voice-profiles.profiles"].ID != "" {
|
||||
t.Fatal("child cancel changed catalog or closed menu")
|
||||
}
|
||||
activate("add")
|
||||
a.ui.handle(interaction.Key{Text: "Reading"})
|
||||
a.ui.handle(internalui.Key{Text: "Reading"})
|
||||
a.ui.session.FocusControl(voiceprofiles.PageID, "rate")
|
||||
a.ui.handle(interaction.Key{Name: "right"})
|
||||
a.ui.handle(internalui.Key{Name: "right"})
|
||||
a.ui.session.FocusControl(voiceprofiles.PageID, "save")
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
if _, err := os.Stat(path); !errors.Is(err, os.ErrNotExist) {
|
||||
t.Fatal("child dialog saved before parent confirmation", err)
|
||||
}
|
||||
@@ -50,9 +50,9 @@ func TestVoiceProfileMenuAddCancelPersistAndRemove(t *testing.T) {
|
||||
if a.ui.session.Values()[voiceprofiles.PageID+".rate"].Number != 10 {
|
||||
t.Fatal("rate did not survive add")
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "escape"})
|
||||
a.ui.handle(internalui.Key{Name: "escape"})
|
||||
a.ui.session.FocusControl("presentation", "ok")
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
finishPersistence(t, a, false)
|
||||
loaded, _, err := config.Load(path, nil)
|
||||
if err != nil || len(loaded.VoiceProfiles.Profiles) != 1 || loaded.VoiceProfiles.Profiles[0].Name != "Reading" {
|
||||
@@ -62,7 +62,7 @@ func TestVoiceProfileMenuAddCancelPersistAndRemove(t *testing.T) {
|
||||
receiveUi(t, a.ui)
|
||||
activate("remove")
|
||||
a.ui.session.FocusControl("presentation", "ok")
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
finishPersistence(t, a, false)
|
||||
loaded, _, err = config.Load(path, nil)
|
||||
if err != nil || len(loaded.VoiceProfiles.Profiles) != 0 {
|
||||
@@ -172,7 +172,7 @@ func TestCancelledProfileDiscoveryCannotReplaceNewerEditor(t *testing.T) {
|
||||
}
|
||||
a.ui.manageProfiles("add-profile", a.ui.session, draft, preferences.Discovery{Driver: "dectalk"}, restore)
|
||||
<-requests
|
||||
a.ui.handle(interaction.Key{Name: "escape"})
|
||||
a.ui.handle(internalui.Key{Name: "escape"})
|
||||
draft.Presentation.Speech.Rate = 20
|
||||
a.ui.manageProfiles("add-profile", a.ui.session, draft, preferences.Discovery{Driver: "dectalk"}, restore)
|
||||
<-requests
|
||||
@@ -246,17 +246,17 @@ func TestVoiceProfileEditorPreviewsAndRestoresParentDraft(t *testing.T) {
|
||||
if !a.ui.session.FocusControl("voice-profiles", "add") {
|
||||
t.Fatal("missing Add Voice Profile")
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
a.ui.session.FocusControl(voiceprofiles.PageID, "rate")
|
||||
a.ui.handle(interaction.Key{Name: "right"})
|
||||
a.ui.handle(internalui.Key{Name: "right"})
|
||||
if got := lastParameters(t, voice); got.Rate != 10 {
|
||||
t.Fatal("profile rate was not previewed", got)
|
||||
}
|
||||
// Module changes use the same silent preparation as ordinary settings.
|
||||
control := a.ui.session.Values()[voiceprofiles.PageID+".module"]
|
||||
control.Choices = append(control.Choices, interaction.Choice{ID: "fixture", Label: "fixture", Literal: true})
|
||||
control.Choices = append(control.Choices, internalui.Choice{ID: "fixture", Label: "fixture", Literal: true})
|
||||
a.ui.session.ReplaceChoices(voiceprofiles.PageID, "module", control.Choices, "fixture")
|
||||
a.ui.handle(interaction.Key{Name: "tab"})
|
||||
a.ui.handle(internalui.Key{Name: "tab"})
|
||||
if got := <-prepared; got.Module != "fixture" {
|
||||
t.Fatal("profile module was not previewed", got)
|
||||
}
|
||||
@@ -264,7 +264,7 @@ func TestVoiceProfileEditorPreviewsAndRestoresParentDraft(t *testing.T) {
|
||||
if a.settings.live.Presentation.Speech.Rate != 0 || a.settings.live.Presentation.Speech.Module != "" {
|
||||
t.Fatal("preview committed the profile")
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "escape"})
|
||||
a.ui.handle(internalui.Key{Name: "escape"})
|
||||
if got := lastParameters(t, voice); got.Rate != 0 {
|
||||
t.Fatal("cancel did not restore parent rate", got)
|
||||
}
|
||||
@@ -279,16 +279,16 @@ func TestNewVoiceProfileCanBeConfirmedOnItsTabAndSelectedImmediately(t *testing.
|
||||
a.openSettings()
|
||||
receiveUi(t, a.ui)
|
||||
a.ui.session.FocusControl("voice-profiles", "add")
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(interaction.Key{Text: "Reading"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Text: "Reading"})
|
||||
a.ui.session.FocusControl(voiceprofiles.PageID, "rate")
|
||||
a.ui.handle(interaction.Key{Name: "right"})
|
||||
a.ui.handle(internalui.Key{Name: "right"})
|
||||
a.ui.session.FocusControl(voiceprofiles.PageID, "save")
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
if !a.ui.session.FocusControl("voice-profiles", "ok") {
|
||||
t.Fatal("profile tab has no way to confirm its changes")
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
finishPersistence(t, a, false)
|
||||
loaded, _, err := config.Load(path, nil)
|
||||
if err != nil || len(loaded.VoiceProfiles.Profiles) != 1 || len(a.settings.live.VoiceProfiles.Profiles) != 1 {
|
||||
@@ -314,7 +314,7 @@ func TestUseVoiceProfilePreviewsWithoutCommittingPrimary(t *testing.T) {
|
||||
a.openSettings()
|
||||
receiveUi(t, a.ui)
|
||||
a.ui.session.FocusControl("voice-profiles", "use")
|
||||
a.ui.handle(interaction.Key{Name: "enter"})
|
||||
a.ui.handle(internalui.Key{Name: "enter"})
|
||||
if got := <-prepared; got.Module != "fixture" {
|
||||
t.Fatal("Use Voice Profile did not preview the module", got)
|
||||
}
|
||||
@@ -325,7 +325,7 @@ func TestUseVoiceProfilePreviewsWithoutCommittingPrimary(t *testing.T) {
|
||||
if a.settings.live.Presentation.Speech.Module != "" {
|
||||
t.Fatal("Use Voice Profile committed before parent confirmation")
|
||||
}
|
||||
a.ui.handle(interaction.Key{Name: "escape"})
|
||||
a.ui.handle(internalui.Key{Name: "escape"})
|
||||
if got := <-prepared; got.Module != "" {
|
||||
t.Fatal("menu Cancel did not restore its original module", got)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user