|
@@ -101,8 +101,10 @@ func TestDoorInputConnection(t *testing.T) {
|
|
|
"\x1b[A\x1b[B\x1b[C\x1b[D": []int{XKEY_UP_ARROW, XKEY_DOWN_ARROW, XKEY_RIGHT_ARROW, XKEY_LEFT_ARROW},
|
|
|
"\x1b[H\x1b[F\x1b[K\x1b[V\x1b[U": []int{XKEY_HOME, XKEY_END, XKEY_END, XKEY_PGUP, XKEY_PGDN},
|
|
|
"\x1b[5~\x1b[6~": []int{XKEY_PGUP, XKEY_PGDN},
|
|
|
+ "\x1b[@\x1b[2~\x1b[3~": []int{XKEY_INSERT, XKEY_INSERT, XKEY_DELETE},
|
|
|
"\x1bOP\x1bOQ\x1bOR\x1bOS": []int{XKEY_F1, XKEY_F2, XKEY_F3, XKEY_F4},
|
|
|
"\x1b[15~\x1b[17~\x1b[18~\x1b[19~": []int{XKEY_F5, XKEY_F6, XKEY_F7, XKEY_F8},
|
|
|
+ "\x1b[20~\x1b[21~\x1b[23~\x1b[24~": []int{XKEY_F9, XKEY_F10, XKEY_F11, XKEY_F12},
|
|
|
}
|
|
|
|
|
|
for send, get := range keytest {
|
|
@@ -135,13 +137,38 @@ func TestDoorInputConnection(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- input := d.WaitKey(0, 50)
|
|
|
- if input != -1 {
|
|
|
- t.Errorf("Expected timeout, got %d / %X", input, input)
|
|
|
+ timeout := d.WaitKey(0, 50)
|
|
|
+ if timeout != -1 {
|
|
|
+ t.Errorf("Expected timeout, got %d / %X", timeout, timeout)
|
|
|
} else {
|
|
|
t.Logf("Ok! Buffer should be empty! -1 (timeout)")
|
|
|
}
|
|
|
|
|
|
+ // Input test
|
|
|
+ buffer = []byte("1234567890\r")
|
|
|
+ server.Write(buffer)
|
|
|
+ input := d.Input(5)
|
|
|
+
|
|
|
+ if input != "12345" {
|
|
|
+ t.Errorf("Expected Input(5) = 12345, but got %#v", input)
|
|
|
+ }
|
|
|
+
|
|
|
+ buffer = []byte("12345678\x08\x089\r")
|
|
|
+ server.Write(buffer)
|
|
|
+ input = d.Input(5)
|
|
|
+
|
|
|
+ if input != "1239" {
|
|
|
+ t.Errorf("Expected Input(5) = 1239, but got %#v", input)
|
|
|
+ }
|
|
|
+
|
|
|
+ buffer = []byte("12\x08\x08\x08987\x00\x48654321\r")
|
|
|
+ server.Write(buffer)
|
|
|
+ input = d.Input(5)
|
|
|
+
|
|
|
+ if input != "98765" {
|
|
|
+ t.Errorf("Expected Input(5) = 98765, but got %#v", input)
|
|
|
+ }
|
|
|
+
|
|
|
server.Close()
|
|
|
|
|
|
hungup := d.WaitKey(1, 0)
|
|
@@ -156,3 +183,17 @@ func TestDoorInputConnection(t *testing.T) {
|
|
|
client.Close()
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+func TestDisplayInput(t *testing.T) {
|
|
|
+ verify := map[int]string{1: " \x08",
|
|
|
+ 2: " \x08\x08",
|
|
|
+ 5: " \x08\x08\x08\x08\x08",
|
|
|
+ }
|
|
|
+
|
|
|
+ for count, expect := range verify {
|
|
|
+ got := DisplayInput(count)
|
|
|
+ if expect != got {
|
|
|
+ t.Errorf("DisplayInput %d, expected %#v, got %#v", count, expect, got)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|