For speech rate in settings up/down move by 10, left/right move by 1. Easier to get settings right without having to hold doown the arrow keys lol.
This commit is contained in:
1 parent
ea5d26f56d
commit
088f706cb4
13 files changed
+81
-10
No files matched your search
@@ -28,7 +28,7 @@ func TestApplicationSettingsOnlyExposeRestorableControls(t *testing.T) {
|
||||
session.Handle(interaction.Key{Name: "tab"})
|
||||
session.Handle(interaction.Key{Name: "up"})
|
||||
saved, err := Application_settings(session, base)
|
||||
if err != nil || saved.Presentation.Speech.Rate != base.Presentation.Speech.Rate+1 || saved.Keyboard.Layout != base.Keyboard.Layout {
|
||||
if err != nil || saved.Presentation.Speech.Rate != base.Presentation.Speech.Rate+10 || saved.Keyboard.Layout != base.Keyboard.Layout {
|
||||
t.Fatal(saved, err)
|
||||
}
|
||||
}
|
||||
@@ -132,6 +132,9 @@ func make_control(definition config.Definition, settings config.Settings, discov
|
||||
control.Number = value.(float64)
|
||||
}
|
||||
control.Min, control.Max, control.Step = definition.Min, definition.Max, definition.Step
|
||||
if definition.Path == "presentation.speech.rate" {
|
||||
control.UpDownStep = 10
|
||||
}
|
||||
case reflect.String:
|
||||
control.Kind, control.Text = interaction.Entry, value.(string)
|
||||
case reflect.Slice:
|
||||
|
||||
@@ -19,6 +19,7 @@ package preferences
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -52,11 +53,51 @@ func TestSettingsFormCoversSchemaAndReturnsIsolatedDraft(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if draft.Presentation.Speech.Enabled || draft.Presentation.Speech.Rate != 1 || !base.Presentation.Speech.Enabled || base.Presentation.Speech.Rate != 0 {
|
||||
if draft.Presentation.Speech.Enabled || draft.Presentation.Speech.Rate != 10 || !base.Presentation.Speech.Enabled || base.Presentation.Speech.Rate != 0 {
|
||||
t.Fatal("draft isolation", draft, base)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSpeechRateArrowSteps(t *testing.T) {
|
||||
for _, application := range []bool{false, true} {
|
||||
for _, trial := range []struct {
|
||||
start int
|
||||
key string
|
||||
want int
|
||||
}{
|
||||
{-3, "up", 7}, {-3, "down", -13},
|
||||
{-3, "right", -2}, {-3, "left", -4},
|
||||
{96, "up", 100}, {-96, "down", -100},
|
||||
{100, "up", 100}, {-100, "down", -100},
|
||||
{100, "right", 100}, {-100, "left", -100},
|
||||
{100, "down", 90}, {-100, "up", -90},
|
||||
{100, "left", 99}, {-100, "right", -99},
|
||||
} {
|
||||
base := config.Defaults()
|
||||
base.Presentation.Speech.Rate = trial.start
|
||||
session, err := new_session(base, []string{"presentation"}, MenuTitle, application)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
session.Handle(interaction.Key{Name: "tab"}) // Speech enabled.
|
||||
session.Handle(interaction.Key{Name: "tab"}) // Rate.
|
||||
result := session.Handle(interaction.Key{Name: trial.key})
|
||||
if want := "Rate " + strconv.Itoa(trial.want); result.Speech != want {
|
||||
t.Fatalf("application=%v, rate=%d, key=%s: speech=%q, want %q", application, trial.start, trial.key, result.Speech, want)
|
||||
}
|
||||
var draft config.Settings
|
||||
if application {
|
||||
draft, err = Application_settings(session, base)
|
||||
} else {
|
||||
draft, err = Settings(session, base)
|
||||
}
|
||||
if err != nil || draft.Presentation.Speech.Rate != trial.want || base.Presentation.Speech.Rate != trial.start {
|
||||
t.Fatalf("application=%v, trial=%+v: draft rate=%d, base rate=%d, err=%v", application, trial, draft.Presentation.Speech.Rate, base.Presentation.Speech.Rate, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadingModeIsConstrainedAndSavedInDraft(t *testing.T) {
|
||||
base := config.Defaults()
|
||||
session, err := New_session(base, []string{"reading"})
|
||||
|
||||
Reference in new issue
Block a user