After commit c018f5fd29 Fenrir is being switched over to go. If you do not want to be part of the testing process, please switch to master.
This commit is contained in:
1 parent
c018f5fd29
commit
0e50de4c76
1047 files changed
+58364
-63747
No files matched your search
@@ -0,0 +1,98 @@
|
||||
// Copyright (c) 2026 Storm Dragon
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package input
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.stormux.org/storm/fenrir/internal/command"
|
||||
)
|
||||
|
||||
func TestRegionChordsInBothLayoutsConsumeRepeatsAndEitherReleaseOrder(t *testing.T) {
|
||||
for _, layout := range []string{"desktop", "laptop"} {
|
||||
bindings, _, err := Load_bindings([]string{"../../config/keyboard/" + layout + ".toml"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, binding := range bindings {
|
||||
if binding.Command != command.SetWindow && binding.Command != command.SetLiveRegion && binding.Command != command.ListReadingRegions && binding.Command != command.ClearLiveRegions && binding.Command != command.ClearReadingRegions &&
|
||||
!strings.HasPrefix(string(binding.Command), "read_live_region_") && !strings.HasPrefix(string(binding.Command), "clear_live_region_") {
|
||||
continue
|
||||
}
|
||||
for _, modifierFirst := range []bool{false, true} {
|
||||
for _, numLock := range []bool{false, true} {
|
||||
router, err := New_router(bindings)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
modifiers := []uint16{KeyInsert}
|
||||
for _, name := range binding.Keys[1 : len(binding.Keys)-1] {
|
||||
if name == "CTRL" {
|
||||
modifiers = append(modifiers, KeyCtrl)
|
||||
} else if name == "SHIFT" {
|
||||
modifiers = append(modifiers, KeyShift)
|
||||
}
|
||||
}
|
||||
for _, key := range modifiers {
|
||||
router.Key(0, key, 1, numLock, false)
|
||||
}
|
||||
key := keyCodes[binding.Keys[len(binding.Keys)-1]]
|
||||
if got := router.Key(0, key, 1, numLock, false); got.Command != binding.Command || got.Forward {
|
||||
t.Fatal(layout, binding.Name, got)
|
||||
}
|
||||
if got := router.Key(0, key, 2, numLock, false); got.Command != "" || got.Forward {
|
||||
t.Fatal("repeat escaped", layout, binding.Name, got)
|
||||
}
|
||||
if modifierFirst {
|
||||
for _, modifier := range modifiers {
|
||||
router.Key(0, modifier, 0, numLock, false)
|
||||
}
|
||||
}
|
||||
if got := router.Key(0, key, 0, numLock, false); got.Forward || got.Command != "" {
|
||||
t.Fatal("release escaped", layout, binding.Name, got)
|
||||
}
|
||||
if !modifierFirst {
|
||||
for _, modifier := range modifiers {
|
||||
router.Key(0, modifier, 0, numLock, false)
|
||||
}
|
||||
}
|
||||
if got := router.Key(0, 48, 1, numLock, false); !got.Forward {
|
||||
t.Fatal("plain typing trapped after chord", layout, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWindowDoublePressSurvivesX11AggregateControlSamples(t *testing.T) {
|
||||
for _, modifier := range []uint16{KeyCtrl, KeyRightCtrl} {
|
||||
bindings, _, err := Load_bindings([]string{"../../config/keyboard/laptop.toml"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
router, err := New_router(bindings)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
now := time.Unix(1000, 0)
|
||||
router.now = func() time.Time { return now }
|
||||
for _, want := range []command.ID{command.SetWindow, command.ClearWindow} {
|
||||
router.Observe_modifier(1, KeyCtrl, 0, false)
|
||||
router.Key(0, KeyInsert, 1, false, false)
|
||||
router.Key(0, modifier, 1, false, false)
|
||||
router.Observe_modifier(1, KeyCtrl, 1, false)
|
||||
if got := router.Key(0, 9, 1, false, false); got.Command != want || got.Forward {
|
||||
t.Fatal("control modifier shadow broke double press", modifier, got, want)
|
||||
}
|
||||
router.Key(0, 9, 0, false, false)
|
||||
router.Key(0, modifier, 0, false, false)
|
||||
router.Observe_modifier(1, KeyCtrl, 0, false)
|
||||
router.Key(0, KeyInsert, 0, false, false)
|
||||
now = now.Add(100 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user