Cthulhu is no longer a fork. Now it is a screen reader written in Golang.
This commit is contained in:
1 parent
a998fe67de
commit
069fc674dc
708 files changed
+112482
-532
No files matched your search
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) 2026 Storm Dragon
|
||||
// Authors: Storm Dragon, Angus Kola
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
package config
|
||||
|
||||
import (
|
||||
"git.stormux.org/storm/cthulhu/internal/input"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestKeyBindingsSaveLoadAndIsolation(t *testing.T) {
|
||||
store, err := NewStore(filepath.Join(t.TempDir(), "settings.toml"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
settings := DefaultSettings()
|
||||
settings.KeyBindings = []input.BindingOverride{
|
||||
{Layout: input.DesktopKeyboardLayout, Scope: "global", Command: input.Preferences, Keys: []string{"Cthulhu+Ctrl+F8"}},
|
||||
{Layout: input.LaptopKeyboardLayout, Scope: "browse", Command: input.DocumentNextHeading, Keys: []string{}},
|
||||
}
|
||||
if err := store.Save(settings); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, err := store.Load()
|
||||
if err != nil || !reflect.DeepEqual(settings.KeyBindings, loaded.KeyBindings) {
|
||||
t.Fatalf("round trip: %+v %v", loaded.KeyBindings, err)
|
||||
}
|
||||
loaded.KeyBindings[0].Keys[0] = "F1"
|
||||
if store.Current().KeyBindings[0].Keys[0] == "F1" {
|
||||
t.Fatal("caller changed store bindings")
|
||||
}
|
||||
settings.KeyBindings = nil
|
||||
if err := store.Save(settings); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, err = store.Load()
|
||||
if err != nil || len(loaded.KeyBindings) != 0 {
|
||||
t.Fatalf("reset failed: %+v %v", loaded.KeyBindings, err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user