forked from fyne-io/terminal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
term_test.go
41 lines (33 loc) · 839 Bytes
/
term_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package terminal
import (
"testing"
"time"
"fyne.io/fyne"
_ "fyne.io/fyne/test"
"github.com/stretchr/testify/assert"
)
func TestNewTerminal(t *testing.T) {
term := NewTerminal()
assert.NotNil(t, term)
assert.NotNil(t, term.content)
}
func TestTerminal_Resize(t *testing.T) {
term := NewTerminal()
term.Resize(fyne.NewSize(45, 45))
assert.Equal(t, uint(4), term.config.Columns)
assert.Equal(t, uint(2), term.config.Rows)
}
func TestTerminal_AddListener(t *testing.T) {
term := NewTerminal()
listen := make(chan Config, 1)
term.AddListener(listen)
assert.Equal(t, 1, len(term.listeners))
go term.onConfigure()
select {
case <-listen: // passed
case <-time.After(time.Millisecond * 100):
t.Error("Failed waiting for configure callback")
}
term.RemoveListener(listen)
assert.Equal(t, 0, len(term.listeners))
}