44 lines
1.7 KiB
Go
44 lines
1.7 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 TestClipboardChordConsumesBothReleaseOrders(t *testing.T) {
|
|
for _, layout := range []KeyboardLayout{DesktopKeyboardLayout, LaptopKeyboardLayout} {
|
|
for _, modifierFirst := range []bool{false, true} {
|
|
router := NewCommandRouter([]uint32{0xff63}, DefaultCommandBindings(layout))
|
|
router.Handle(0xff63, 118, 0, true)
|
|
if consumed, command := router.Handle('c', 54, 1, true); !consumed || command != PresentClipboard {
|
|
t.Fatalf("layout %d: Cthulhu+Shift+C = %v %q", layout, consumed, command)
|
|
}
|
|
if consumed, command := router.Handle('c', 54, 1, true); !consumed || command != "" {
|
|
t.Fatalf("layout %d: repeated C = %v %q", layout, consumed, command)
|
|
}
|
|
if modifierFirst {
|
|
if consumed, command := router.Handle(0xff63, 118, 1, false); !consumed || command != "" {
|
|
t.Fatalf("layout %d: modifier release = %v %q", layout, consumed, command)
|
|
}
|
|
}
|
|
if consumed, command := router.Handle('c', 54, 1, false); !consumed || command != "" {
|
|
t.Fatalf("layout %d: C release = %v %q", layout, consumed, command)
|
|
}
|
|
if !modifierFirst {
|
|
if consumed, command := router.Handle(0xff63, 118, 0, false); !consumed || command != "" {
|
|
t.Fatalf("layout %d: modifier release = %v %q", layout, consumed, command)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestClipboardChordRequiresShift(t *testing.T) {
|
|
router := NewCommandRouter([]uint32{0xff63}, DefaultCommandBindings(DesktopKeyboardLayout))
|
|
router.Handle(0xff63, 118, 0, true)
|
|
if consumed, command := router.Handle('c', 54, 0, true); consumed || command != "" {
|
|
t.Fatalf("unshifted C = %v %q", consumed, command)
|
|
}
|
|
}
|