-
Notifications
You must be signed in to change notification settings - Fork 4
/
navigation_test.go
112 lines (79 loc) · 2.79 KB
/
navigation_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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCursorHomeEnd(t *testing.T) {
g := initGui()
defer g.Close()
err := openAndDisplayFile(g, "LICENSE")
assert.Nil(t, err, "No error should be found")
wView := g.Workingview()
xPos, yPos := wView.Cursor()
assert.Equal(t, xPos, 0, "Cursor should be at first column")
assert.Equal(t, yPos, 0, "Cursor should be at first line")
err = cursorEnd(g, wView)
assert.Nil(t, err, "cursorEnd shouldn't return any error")
xPos, _ = wView.Cursor()
line, _ := wView.Line(yPos)
assert.Equal(t, xPos, len(line), "Cursor at wrong position")
assert.Equal(t, yPos, 0, "Cursor at wrong position")
err = cursorHome(g, wView)
assert.Nil(t, err, "cursorEnd shouldn't return any error")
xPos, _ = wView.Cursor()
assert.Equal(t, xPos, 0, "Cursor at wrong position")
assert.Equal(t, yPos, 0, "Cursor at wrong position")
}
func TestPageUpDown(t *testing.T) {
g := initGui()
defer g.Close()
err := openAndDisplayFile(g, "LICENSE")
assert.Nil(t, err, "No error should be found")
wView := g.Workingview()
_, ySize := wView.Size()
xPos, yPos := wView.Cursor()
err = goPgUp(g, wView)
assert.Nil(t, err, "No error should happen")
assert.Equal(t, xPos, 0, "Cursor at wrong position")
assert.Equal(t, yPos, 0, "Cursor at wrong position")
err = goPgDown(g, wView)
assert.Nil(t, err, "No error should happen")
xPos, yPos = wView.Origin()
xT, yT := wView.Cursor()
assert.Equal(t, xPos+xT, 0, "Cursor at wrong position")
assert.Equal(t, yPos+yT, ySize, "Cursor at wrong position")
}
func TestMoveLeftRight(t *testing.T) {
g := initGui()
defer g.Close()
err := openAndDisplayFile(g, "LICENSE")
assert.Nil(t, err, "No error should be found")
wView := g.Workingview()
xPos, yPos := wView.Cursor()
assert.Equal(t, xPos, 0, "Cursor at wrong position")
assert.Equal(t, yPos, 0, "Cursor at wrong position")
moveRight(g, wView)
xPos, yPos = wView.Cursor()
assert.Equal(t, xPos, 1, "Cursor at wrong position")
assert.Equal(t, yPos, 0, "Cursor at wrong position")
//wView.MoveCursor(-1, 0, false)
moveLeft(g, wView)
xPos, yPos = wView.Cursor()
assert.Equal(t, xPos, 0, "Cursor at wrong position")
assert.Equal(t, yPos, 0, "Cursor at wrong position")
wView.MoveCursor(4, 0, false)
xPos, yPos = wView.Cursor()
assert.Equal(t, xPos, 4, "Cursor at wrong position")
assert.Equal(t, yPos, 0, "Cursor at wrong position")
wView.MoveCursor(0, 4, false)
//xPos, yPos = wView.Cursor()
xPos, _ = wView.Cursor()
assert.Equal(t, xPos, 4, "Cursor at wrong position")
// viewlines == nil
//assert.Equal(t, yPos, 4, "Cursor at wrong position")
wView.MoveCursor(0, -2, false)
//xPos, yPos = wView.Cursor()
xPos, _ = wView.Cursor()
assert.Equal(t, xPos, 4, "Cursor at wrong position")
//assert.Equal(t, yPos, 2, "Cursor at wrong position")
}