-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdesktop_test.go
More file actions
33 lines (26 loc) · 900 Bytes
/
desktop_test.go
File metadata and controls
33 lines (26 loc) · 900 Bytes
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
package vtui
import (
"testing"
"github.com/unxed/vtinput"
)
func TestDesktop_ExitKeys(t *testing.T) {
// Desktop uses global FrameManager.
oldScreens := FrameManager.Screens
defer func() { FrameManager.Screens = oldScreens }()
// 1. Test F10
FrameManager.Init(NewSilentScreenBuf())
d1 := NewDesktop()
FrameManager.Push(d1)
d1.ProcessKey(&vtinput.InputEvent{Type: vtinput.KeyEventType, KeyDown: true, VirtualKeyCode: vtinput.VK_F10})
if !FrameManager.IsShutdown() {
t.Error("Desktop should trigger Shutdown on F10 via CmQuit")
}
// 2. Test ESC (Re-init manager for fresh state)
FrameManager.Init(NewSilentScreenBuf())
d2 := NewDesktop()
FrameManager.Push(d2)
d2.ProcessKey(&vtinput.InputEvent{Type: vtinput.KeyEventType, KeyDown: true, VirtualKeyCode: vtinput.VK_ESCAPE})
if !FrameManager.IsShutdown() {
t.Error("Desktop should trigger Shutdown on ESC via CmQuit")
}
}