/
zz_test.go
60 lines (53 loc) · 952 Bytes
/
zz_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
// 10 june 2014
package screentext
import (
"fmt"
"image"
"testing"
"github.com/andlabs/ui"
)
type areaHandler struct {
img *image.RGBA
}
func (a *areaHandler) Paint(r image.Rectangle) *image.RGBA {
return a.img.SubImage(r).(*image.RGBA)
}
func (a *areaHandler) Key(ke ui.KeyEvent) bool {
return false
}
func (a *areaHandler) Mouse(me ui.MouseEvent) {}
var w ui.Window
func myMain() {
fonts := ListFonts()
for _, font := range fonts {
fmt.Printf("%#v\n", font)
}
f := NewFont(FontSpec{
Family: "Helvetica",
Size: 12,
Bold: true,
})
i := Line("hello, world", f, 0, 128, 0)
f.Close()
ui.Do(func() {
w = ui.NewWindow("Test", 200, 200, ui.NewArea(i.Rect.Dx(), i.Rect.Dy(), &areaHandler{
img: i,
}))
w.OnClosing(func() bool {
ui.Stop()
return true
})
w.Show()
})
}
func init() {
testInit()
go myMain()
err := ui.Go()
if err != nil {
panic(err)
}
}
func TestDummy(t *testing.T) {
// do nothing
}