46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
// Copyright (c) 2026 Storm Dragon
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package input
|
|
|
|
import (
|
|
"git.stormux.org/storm/fenrir/internal/command"
|
|
"testing"
|
|
)
|
|
|
|
func TestSpellcheckChordCaptureReleaseAndHeldDelete(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 _, releases := range [][]uint16{{KeyInsert, 31}, {31, KeyInsert}} {
|
|
router, err := New_router(bindings)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
router.Key(0, KeyInsert, 1, false, false)
|
|
if got := router.Key(0, 31, 1, false, false); got.Command != command.SpellcheckMenu || got.Forward {
|
|
t.Fatal(layout, got)
|
|
}
|
|
if got := router.Key(0, 31, 2, false, false); got.Command != "" {
|
|
t.Fatal("held opener repeated", got)
|
|
}
|
|
router.Capture(true)
|
|
for _, code := range releases {
|
|
if got := router.Key(0, code, 0, false, false); got.Forward || got.UI != nil {
|
|
t.Fatal(got)
|
|
}
|
|
}
|
|
router.Key(0, KeyDelete, 1, false, false)
|
|
if got := router.Key(0, KeyDelete, 2, false, false); got.UI == nil || !got.UI.Repeat {
|
|
t.Fatal("repeat metadata lost", got)
|
|
}
|
|
router.Capture(false)
|
|
if got := router.Key(0, KeyDelete, 2, false, false); got.Forward || got.UI != nil {
|
|
t.Fatal("held Delete escaped capture", got)
|
|
}
|
|
}
|
|
}
|
|
}
|