Speech settings updated, no large decimals for settings. Also changing with quick settings keys now applies across window changes.
This commit is contained in:
1 parent
7ae2801e53
commit
6ee0454fbe
17 files changed
+406
-15
No files matched your search
@@ -5,11 +5,76 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSpeechNumbersPersistWithOneDecimal(t *testing.T) {
|
||||
settings := DefaultSettings()
|
||||
rate, pitch, gain := 61.29999999999999, 4.499999999999998, 4.999999999999999
|
||||
settings.DefaultVoice = Voice{Rate: &rate, AveragePitch: &pitch, Gain: &gain}
|
||||
settings.UppercaseVoice.AveragePitch = &pitch
|
||||
settings.HyperlinkVoice.Rate = &rate
|
||||
settings.SystemVoice.Gain = &gain
|
||||
settings.EchoVoice = settings.DefaultVoice
|
||||
path := filepath.Join(t.TempDir(), "settings.toml")
|
||||
store, err := NewStore(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := store.Save(settings); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, err := store.Load()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for index, voice := range []Voice{loaded.DefaultVoice, loaded.UppercaseVoice, loaded.HyperlinkVoice, loaded.SystemVoice, loaded.EchoVoice} {
|
||||
for field, value := range []*float64{voice.Rate, voice.AveragePitch, voice.Gain} {
|
||||
if value != nil && *value != []float64{61.3, 4.5, 5}[field] {
|
||||
t.Fatalf("voice %d field %d = %g", index, field, *value)
|
||||
}
|
||||
}
|
||||
}
|
||||
if loaded.UppercaseVoice.Rate != nil || loaded.HyperlinkVoice.Gain != nil || loaded.SystemVoice.AveragePitch != nil {
|
||||
t.Fatal("rounding turned inheritance into explicit settings")
|
||||
}
|
||||
if *settings.DefaultVoice.AveragePitch != 4.499999999999998 {
|
||||
t.Fatal("saving mutated caller's voice")
|
||||
}
|
||||
contents, err := os.ReadFile(path)
|
||||
if err != nil || strings.Contains(string(contents), "999999") || !strings.Contains(string(contents), "average-pitch = 4.5") {
|
||||
t.Fatalf("TOML does not contain rounded decimal values: %v", err)
|
||||
}
|
||||
if err := store.SaveForApplication("Example Editor", settings); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
contents, err = os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
document, _, err := decodeDocument(contents)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
profile := document.Profiles[document.Applications["Example Editor"]]
|
||||
if profile.Speech.DefaultVoice != nil || profile.KeyEcho.EchoVoice != nil {
|
||||
t.Fatal("floating-point noise created application voice overrides")
|
||||
}
|
||||
appGain := 3.299999999999999
|
||||
settings.DefaultVoice.Gain = &appGain
|
||||
if err := store.SaveForApplication("Example Editor", settings); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
application, found, err := store.LoadForApplication("Example Editor")
|
||||
if err != nil || !found || *application.DefaultVoice.Gain != 3.3 {
|
||||
t.Fatalf("application speech was not rounded: %+v, %v", application.DefaultVoice, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVoiceTypesPersistAndInheritAcrossApplications(t *testing.T) {
|
||||
settings := DefaultSettings()
|
||||
rate, pitch, gain := 62.0, 8.0, 4.0
|
||||
|
||||
Reference in new issue
Block a user