/
view_test.go
52 lines (43 loc) · 1.13 KB
/
view_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
package ui
import (
"fmt"
"image"
//"image/draw"
//"image/color"
"github.com/usedbytes/fonts"
"github.com/usedbytes/s4548"
"testing"
"time"
"math/rand"
)
func TestView(t* testing.T) {
screen := s4548.NewS4548(s4548.GetS4548EnvPath())
font := fonts.NewFontFromFile("/home/kernelcode/tiny_font.fnt")
fmt.Println("Font Loaded")
r := rand.New(rand.NewSource(99))
view := NewView(nil, "Test View");
view.SetWidth(101)
view.SetHeight(40)
lbl1 := NewLabel(nil, font)
lbl1.AutoWidth = false
lbl1.AutoHeight = true
lbl1.SetWidth(101)
lbl1.SetHeight(40)
lbl1.VAlign = Middle
lbl1.HAlign = Centre
lbl1.Text = "This is a big long label test which should be scrolling with any luck"
lbl1.Scroll = true
view.AddChild(lbl1)
bar := NewProgressBar(nil)
bar.SetWidth(101)
bar.SetHeight(8)
bar.SetPos(image.Point{0, 32})
bar.Progress = 33
view.AddChild(bar)
for i := 0; i < 20; i++ {
time.Sleep(500 * time.Millisecond)
bar.Progress = r.Intn(101)
view.Draw(screen)
screen.Scanout()
}
}