unittest confirms multiple keyboards just werk

master
Bel LaPointe 2023-03-02 14:32:12 -07:00
parent 1a80e70fc4
commit c4e1c525d1
1 changed files with 26 additions and 10 deletions

View File

@ -9,18 +9,34 @@ import (
"time"
)
func TestTwoKeyboards(t *testing.T) {
kb1 := output.NewKeyboard()
t.Cleanup(kb1.Close)
kb2 := output.NewKeyboard()
t.Cleanup(kb2.Close)
kb1.Press(key.D)
kb2.Press(key.W)
t.Log("pressing 'w' and 'd' over 2 keyboards for 5 seconds")
for i := 0; i < 5; i++ {
t.Logf("\t%d...", 5-i)
time.Sleep(time.Second)
}
t.Logf("releasing")
kb1.Press()
kb2.Press()
}
func TestKeyboardIntegration(t *testing.T) {
kb := output.NewKeyboard()
t.Cleanup(kb.Close)
t.Run("hold d", func(t *testing.T) {
t.Log("pressing 'd' for 5 seconds")
kb.Press(key.D)
for i := 0; i < 5; i++ {
t.Logf("\t%d...", 5-i)
time.Sleep(time.Second)
}
t.Logf("releasing")
kb.Press()
})
t.Log("pressing 'd' for 5 seconds")
kb.Press(key.D)
for i := 0; i < 5; i++ {
t.Logf("\t%d...", 5-i)
time.Sleep(time.Second)
}
t.Logf("releasing")
kb.Press()
}