-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathcanvas_test.go
More file actions
37 lines (34 loc) · 1015 Bytes
/
Copy pathcanvas_test.go
File metadata and controls
37 lines (34 loc) · 1015 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
34
35
36
37
package vtui
import "testing"
func TestCanvasPlacesAndRemovesSurface(t *testing.T) {
scr := &ScreenBuf{}
canvas := NewCanvas()
canvas.SetPosition(2, 3, 5, 6)
canvas.SetSurface(NewImageSurface(12, 8))
canvas.Show(scr)
placements, _ := scr.Graphics().Snapshot(nil)
if len(placements) != 1 {
t.Fatalf("placements = %d, want 1", len(placements))
}
p := placements[0]
if p.Col != 2 || p.Row != 3 || p.Cols != 4 || p.Rows != 4 || p.Surface != canvas.Surface {
t.Fatalf("placement = %+v", p)
}
canvas.SetSurface(nil)
if got := scr.Graphics().Len(); got != 0 {
t.Fatalf("placements after clearing surface = %d, want 0", got)
}
canvas.Hide(scr)
if got := scr.Graphics().Len(); got != 0 {
t.Fatalf("placements after Hide = %d, want 0", got)
}
}
func TestCanvasFactoryImplementsPropertyAccess(t *testing.T) {
element, err := NewByType("Canvas")
if err != nil {
t.Fatal(err)
}
if _, ok := element.(PropertyAccess); !ok {
t.Fatalf("Canvas %T does not implement PropertyAccess", element)
}
}