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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
package tui
import "testing"
func TestInputReporting(t *testing.T) {
type tc struct {
mouseEnabled bool
inlineHeight int
wantMouse bool
wantAltScroll bool
}
tests := map[string]tc{
"full-screen with mouse": {
mouseEnabled: true,
inlineHeight: 0,
wantMouse: true,
wantAltScroll: false,
},
"full-screen without mouse": {
mouseEnabled: false,
inlineHeight: 0,
wantMouse: false,
wantAltScroll: true,
},
"inline without mouse": {
mouseEnabled: false,
inlineHeight: 5,
wantMouse: false,
wantAltScroll: false,
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
term := NewMockTerminal(80, 24)
app := &App{
terminal: term,
mouseEnabled: tt.mouseEnabled,
inlineHeight: tt.inlineHeight,
}
app.enableInputReporting()
if term.IsMouseEnabled() != tt.wantMouse {
t.Errorf("after enable: mouse = %v, want %v", term.IsMouseEnabled(), tt.wantMouse)
}
if term.IsAltScrollEnabled() != tt.wantAltScroll {
t.Errorf("after enable: altScroll = %v, want %v", term.IsAltScrollEnabled(), tt.wantAltScroll)
}
app.disableInputReporting()
if term.IsMouseEnabled() {
t.Error("after disable: mouse still enabled")
}
if term.IsAltScrollEnabled() {
t.Error("after disable: altScroll still enabled")
}
})
}
}
|