// Copyright (c) 2026 Storm Dragon // Authors: Storm Dragon, Angus Kola // SPDX-License-Identifier: GPL-3.0-or-later package input import "testing" func TestDocumentListShortcutsAndCustomization(t *testing.T) { for _, layout := range []KeyboardLayout{DesktopKeyboardLayout, LaptopKeyboardLayout} { bindings := BrowseCommandBindings(layout) bound := 0 for _, binding := range DocumentListBindings() { if binding.Symbol == 0 { continue } bound++ chord := CommandChord{Symbol: binding.Symbol, Modifiers: 9} if bindings[chord] != binding.Command || DefaultCommandBindings(layout)[chord] != "" { t.Fatalf("%s has incorrect scope or shortcut", binding.Command) } outside := NewCommandRouter([]uint32{0xff63}, DefaultCommandBindings(layout)) if consumed, command := outside.Handle(binding.Symbol, 100, 9, true); consumed || command != "" { t.Fatalf("%s intercepted outside browse mode", binding.Command) } router := NewCommandRouter([]uint32{0xff63}, bindings) if consumed, command := router.Handle(binding.Symbol, 100, 9, true); !consumed || command != binding.Command { t.Fatalf("%s was not dispatched: %v %s", binding.Command, consumed, command) } if consumed, _ := router.Handle(binding.Symbol, 100, 9, false); !consumed { t.Fatal("lost list key release") } } if bound != 25 { t.Fatalf("got %d shortcuts, want 19 types and 6 heading levels", bound) } overrides := []BindingOverride{{Layout: layout, Scope: "browse", Command: DocumentListMath, Keys: []string{"Alt+Shift+y"}}} if err := ValidateBindingOverrides(overrides); err != nil { t.Fatal(err) } custom, err := ResolveCommandBindings(layout, true, overrides) if err != nil || custom[CommandChord{Symbol: 'y', Modifiers: 9}] != DocumentListMath { t.Fatalf("unbound list customization: %v", err) } } }