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,67 @@
|
||||
// Copyright (c) 2026 Storm Dragon
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package input
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.stormux.org/storm/fenrir/internal/command"
|
||||
)
|
||||
|
||||
func TestVerticalCharacterChordsRepeatAndRelease(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 _, trial := range []struct {
|
||||
desktop, laptop uint16
|
||||
want command.ID
|
||||
}{
|
||||
{KeyKP8, 23, command.ReviewUp}, {KeyKP2, 51, command.ReviewDown},
|
||||
} {
|
||||
for _, controlKey := range []uint16{KeyCtrl, KeyRightCtrl} {
|
||||
for _, modifierFirst := range []bool{false, true} {
|
||||
for _, numLock := range []bool{false, true} {
|
||||
router, err := New_router(bindings)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
keyCode := trial.desktop
|
||||
if layout == "laptop" {
|
||||
keyCode = trial.laptop
|
||||
}
|
||||
router.Key(0, KeyInsert, 1, numLock, false)
|
||||
controlPress := router.Key(1, controlKey, 1, numLock, false)
|
||||
for _, value := range []int32{1, 2, 2} {
|
||||
if got := router.Key(0, keyCode, value, numLock, false); got.Command != trial.want || got.Forward || !got.Interrupt {
|
||||
t.Fatal(layout, trial.want, value, got)
|
||||
}
|
||||
}
|
||||
releases := []uint16{keyCode, KeyInsert, controlKey}
|
||||
if modifierFirst {
|
||||
releases = []uint16{KeyInsert, controlKey, keyCode}
|
||||
}
|
||||
for _, code := range releases {
|
||||
device := 0
|
||||
if code == controlKey {
|
||||
device = 1
|
||||
}
|
||||
got := router.Key(device, code, 0, numLock, false)
|
||||
if got.Forward != (code == controlKey && controlPress.Forward) || got.Command != "" {
|
||||
t.Fatal("unbalanced release", layout, code, got)
|
||||
}
|
||||
}
|
||||
if router.Held(0) || router.Held(1) {
|
||||
t.Fatal("stuck vertical chord")
|
||||
}
|
||||
if got := router.Key(0, 30, 1, numLock, false); !got.Forward || got.Command != "" {
|
||||
t.Fatal("typing after vertical chord", got)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user