Skip to content

Commit

Permalink
Test out of range errors for all keyboard functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bendahl committed May 1, 2018
1 parent 3107d76 commit 7004d3d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions keyboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,43 @@ func TestKeyOutsideOfRangeKeyPressFails(t *testing.T) {
t.Fatalf("Expected key press to fail due to invalid key code, but got no error.")
}

}
func TestKeyOutsideOfRangeKeyUpFails(t *testing.T) {
vk, err := CreateKeyboard("/dev/uinput", []byte("Test Basic Keyboard"))
if err != nil {
t.Fatalf("Failed to create the virtual keyboard. Last error was: %s\n", err)
}
defer vk.Close()

err = vk.KeyUp(249)
if err == nil {
t.Fatalf("Expected key press to fail due to invalid key code, but got no error.")
}

err = vk.KeyUp(-1)
if err == nil {
t.Fatalf("Expected key press to fail due to invalid key code, but got no error.")
}

}

func TestKeyOutsideOfRangeKeyDownFails(t *testing.T) {
vk, err := CreateKeyboard("/dev/uinput", []byte("Test Basic Keyboard"))
if err != nil {
t.Fatalf("Failed to create the virtual keyboard. Last error was: %s\n", err)
}
defer vk.Close()

err = vk.KeyDown(249)
if err == nil {
t.Fatalf("Expected key press to fail due to invalid key code, but got no error.")
}

err = vk.KeyDown(-1)
if err == nil {
t.Fatalf("Expected key press to fail due to invalid key code, but got no error.")
}

}

func TestKeyPressFailsIfDeviceIsClosed(t *testing.T) {
Expand Down

0 comments on commit 7004d3d

Please sign in to comment.