36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package input
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestCurrentLineBindingAndPresses(t *testing.T) {
|
|
for _, layout := range []KeyboardLayout{DesktopKeyboardLayout, LaptopKeyboardLayout} {
|
|
for _, bindings := range []CommandBindings{DefaultCommandBindings(layout), BrowseCommandBindings(layout)} {
|
|
router := NewCommandRouter([]uint32{0xff63}, bindings)
|
|
now := time.Unix(100, 0)
|
|
router.now = func() time.Time { return now }
|
|
router.Handle(0xff63, 118, 0, true)
|
|
press := func(modifiers uint16, want Command) {
|
|
t.Helper()
|
|
if consumed, got := router.Handle(upKeySymbol, 111, modifiers, true); !consumed || got != want {
|
|
t.Fatalf("layout %d: consumed=%v command=%s want=%s", layout, consumed, got, want)
|
|
}
|
|
if consumed, got := router.Handle(upKeySymbol, 111, modifiers, true); !consumed || got != "" {
|
|
t.Fatal("held arrow repeated command")
|
|
}
|
|
router.Handle(upKeySymbol, 111, modifiers, false)
|
|
}
|
|
press(1, PresentCurrentLine)
|
|
press(1, SpellCurrentLine)
|
|
press(1, PhoneticCurrentLine)
|
|
press(1, PresentCurrentLine)
|
|
now = now.Add(501 * time.Millisecond)
|
|
press(1, PresentCurrentLine)
|
|
press(0, IncreaseSpeechSetting)
|
|
press(1, PresentCurrentLine)
|
|
}
|
|
}
|
|
}
|