37 lines
1.3 KiB
Go
37 lines
1.3 KiB
Go
// Copyright (c) 2026 Storm Dragon
|
|
// Authors: Storm Dragon, Angus Kola
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package input
|
|
|
|
import "testing"
|
|
|
|
func TestSpeechModeBindings(t *testing.T) {
|
|
for _, layout := range []KeyboardLayout{DesktopKeyboardLayout, LaptopKeyboardLayout} {
|
|
for _, browse := range []bool{false, true} {
|
|
bindings, err := ResolveCommandBindings(layout, browse, nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if got := bindings[CommandChord{Symbol: 's', CthulhuModifier: true}]; got != CycleSpeechMode {
|
|
t.Fatalf("layout %d browse %v: %q", layout, browse, got)
|
|
}
|
|
if got := bindings[CommandChord{Symbol: 's', Modifiers: 1 | controlModifier, CthulhuModifier: true}]; got != SaveSpeechSettings {
|
|
t.Fatalf("speech settings save changed: %q", got)
|
|
}
|
|
if browse && bindings[CommandChord{Symbol: 's'}] != DocumentNextSeparator {
|
|
t.Fatal("unmodified separator navigation changed")
|
|
}
|
|
custom, err := ResolveCommandBindings(layout, browse, []BindingOverride{{
|
|
Layout: layout, Scope: "global", Command: CycleSpeechMode, Keys: []string{"Cthulhu+F8"},
|
|
}})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, exists := custom[CommandChord{Symbol: 's', CthulhuModifier: true}]; exists {
|
|
t.Fatal("custom binding retained the old shortcut")
|
|
}
|
|
}
|
|
}
|
|
}
|