forked from asticode/go-astilectron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
display_pool_test.go
46 lines (40 loc) · 1.06 KB
/
display_pool_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
package astilectron
import (
"testing"
"github.com/asticode/go-astikit"
"github.com/stretchr/testify/assert"
)
func TestDisplayPool(t *testing.T) {
// Init
var dp = newDisplayPool()
// Test update
dp.update(&EventDisplays{
All: []*DisplayOptions{
{ID: astikit.Int64Ptr(1), Rotation: astikit.IntPtr(1)},
{ID: astikit.Int64Ptr(2)},
},
Primary: &DisplayOptions{ID: astikit.Int64Ptr(2)},
})
assert.Len(t, dp.all(), 2)
assert.Equal(t, int64(2), *dp.primary().o.ID)
// Test removing one display
dp.update(&EventDisplays{
All: []*DisplayOptions{
{ID: astikit.Int64Ptr(1), Rotation: astikit.IntPtr(2)},
},
Primary: &DisplayOptions{ID: astikit.Int64Ptr(1)},
})
assert.Len(t, dp.all(), 1)
assert.Equal(t, 2, dp.all()[0].Rotation())
assert.Equal(t, int64(1), *dp.primary().o.ID)
// Test adding a new one
dp.update(&EventDisplays{
All: []*DisplayOptions{
{ID: astikit.Int64Ptr(1)},
{ID: astikit.Int64Ptr(3)},
},
Primary: &DisplayOptions{ID: astikit.Int64Ptr(1)},
})
assert.Len(t, dp.all(), 2)
assert.Equal(t, int64(1), *dp.primary().o.ID)
}