|
@@ -5,6 +5,7 @@ import (
|
|
|
"fmt"
|
|
|
"io/ioutil"
|
|
|
"os"
|
|
|
+ "runtime"
|
|
|
"strings"
|
|
|
"testing"
|
|
|
"time"
|
|
@@ -64,6 +65,7 @@ func TestMenuConnection(t *testing.T) {
|
|
|
// unicode 90x40 response
|
|
|
buffer := []byte("\x1b[1;1R\x1b[2;3R\x1b[40;90R")
|
|
|
server.Write(buffer)
|
|
|
+ runtime.Gosched()
|
|
|
|
|
|
// Access Fd (File descriptor) of client for dropfile
|
|
|
var fd int = socket_to_fd(client)
|
|
@@ -135,8 +137,13 @@ func TestMenuConnection(t *testing.T) {
|
|
|
// BUG: I can't use \x1b[A because of the way extended codes work there.
|
|
|
keys := "\x00\x50\x00\x50\r" // down, down, ENTER
|
|
|
server.Write([]byte(keys))
|
|
|
+ runtime.Gosched()
|
|
|
|
|
|
choice = m.Choose(&d)
|
|
|
+ if choice < 0 {
|
|
|
+ t.Errorf("Error <0 from Choose: %d", choice)
|
|
|
+ }
|
|
|
+
|
|
|
option := m.GetOption(choice)
|
|
|
|
|
|
if choice != 3 {
|
|
@@ -164,8 +171,14 @@ func TestMenuConnection(t *testing.T) {
|
|
|
|
|
|
keys = "\x00\x48\r" // up, ENTER
|
|
|
server.Write([]byte(keys))
|
|
|
+ runtime.Gosched()
|
|
|
+
|
|
|
m.Chosen = 1
|
|
|
choice = m.Choose(&d)
|
|
|
+ if choice < 0 {
|
|
|
+ t.Errorf("Error <0 from Choose: %d", choice)
|
|
|
+ }
|
|
|
+
|
|
|
option = m.GetOption(choice)
|
|
|
|
|
|
if choice != 1 {
|
|
@@ -190,6 +203,8 @@ func TestMenuConnection(t *testing.T) {
|
|
|
|
|
|
keys = "\x00\x4f\r" // END, ENTER
|
|
|
server.Write([]byte(keys))
|
|
|
+ runtime.Gosched()
|
|
|
+
|
|
|
m.Chosen = 1
|
|
|
choice = m.Choose(&d)
|
|
|
option = m.GetOption(choice)
|
|
@@ -209,6 +224,8 @@ func TestMenuConnection(t *testing.T) {
|
|
|
|
|
|
keys = "\x00\x47\r" // HOME, ENTER
|
|
|
server.Write([]byte(keys))
|
|
|
+ runtime.Gosched()
|
|
|
+
|
|
|
m.Chosen = 2
|
|
|
choice = m.Choose(&d)
|
|
|
option = m.GetOption(choice)
|
|
@@ -227,6 +244,8 @@ func TestMenuConnection(t *testing.T) {
|
|
|
// output = string(buffer[:r])
|
|
|
|
|
|
server.Write([]byte("B"))
|
|
|
+ runtime.Gosched()
|
|
|
+
|
|
|
m.Chosen = 0
|
|
|
choice = m.Choose(&d)
|
|
|
option = m.GetOption(choice)
|
|
@@ -236,7 +255,9 @@ func TestMenuConnection(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
// Read the display output
|
|
|
- server.SetReadDeadline(time.Now().Add(time.Millisecond * 50))
|
|
|
+
|
|
|
+ // i/o timeout
|
|
|
+ server.SetReadDeadline(time.Now().Add(time.Millisecond * 100))
|
|
|
r, err = server.Read(buffer)
|
|
|
if err != nil {
|
|
|
t.Errorf("server.Read: %s", err)
|
|
@@ -246,6 +267,8 @@ func TestMenuConnection(t *testing.T) {
|
|
|
|
|
|
keys = "2\r" // "Down", ENTER
|
|
|
server.Write([]byte(keys))
|
|
|
+ runtime.Gosched()
|
|
|
+
|
|
|
m.Chosen = 1
|
|
|
choice = m.Choose(&d)
|
|
|
option = m.GetOption(choice)
|