-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathwindow_test.go
75 lines (58 loc) · 1.83 KB
/
window_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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright 2013 The lime Authors.
// Use of this source code is governed by a 2-clause
// BSD-style license that can be found in the LICENSE file.
package commands
import (
"testing"
"github.com/limetext/backend"
)
func TestNewWindow(t *testing.T) {
ed := backend.GetEditor()
l := len(ed.Windows())
ed.CommandHandler().RunWindowCommand(ed.ActiveWindow(), "new_window", nil)
if len(ed.Windows()) != l+1 {
t.Errorf("Expected %d window, but got %d", l+1, len(ed.Windows()))
}
}
func TestCloseAll(t *testing.T) {
ed := backend.GetEditor()
w := ed.NewWindow()
defer w.Close()
ed.CommandHandler().RunWindowCommand(w, "new_file", nil)
ed.CommandHandler().RunWindowCommand(w, "new_file", nil)
ed.CommandHandler().RunWindowCommand(w, "new_file", nil)
ed.CommandHandler().RunWindowCommand(w, "close_all", nil)
if len(w.Views()) != 0 {
t.Errorf("Expected no views, but got %d", len(w.Views()))
}
}
func TestCloseWindow(t *testing.T) {
ed := backend.GetEditor()
w1 := ed.NewWindow()
_ = ed.NewWindow()
l := len(ed.Windows())
ed.CommandHandler().RunWindowCommand(w1, "close_window", nil)
if len(ed.Windows()) != l-1 {
t.Errorf("Expected %d window, but got %d", l-1, len(ed.Windows()))
}
}
func TestNewAppWindow(t *testing.T) {
ed := backend.GetEditor()
l := len(ed.Windows())
ed.CommandHandler().RunApplicationCommand("new_window", nil)
if len(ed.Windows()) != l+1 {
t.Errorf("Expected %d window, but got %d", l+1, len(ed.Windows()))
}
}
func TestCloseAppWindow(t *testing.T) {
ed := backend.GetEditor()
tmp := ed.NewWindow().Id()
l := len(ed.Windows())
ed.CommandHandler().RunApplicationCommand("close_window", nil)
if len(ed.Windows()) != l-1 {
t.Errorf("Expected %d window, but got %d", l-1, len(ed.Windows()))
}
if ed.ActiveWindow().Id() == tmp {
t.Error(`The active window should not be the same but it is`)
}
}