summaryrefslogtreecommitdiff
path: root/zz_test.go
blob: 657f5dc856757d428ab5bba985cc65d1996571d2 (plain)
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
// 11 december 2015

package ui

import "time"
import "testing"

func TestIt(t *testing.T) {
	err := Main(func() {
		w := NewWindow("Hello", 320, 240, false)
		stop := make(chan struct{})
		w.OnClosing(func(w *Window) bool {
			stop <- struct{}{}
			Quit()
			return true
		})
		p := NewProgressBar()
		w.SetChild(p)
		go func() {
			value := 0
			ticker := time.NewTicker(time.Second / 2)
			for {
				select {
				case <-ticker.C:
					QueueMain(func() {
						value++
						if value > 100 {
							value = 0
						}
						p.SetValue(value)
					})
				case <-stop:
					return
				}
			}
		}()
		w.Show()
	})
	if err != nil {
		t.Fatal(err)
	}
}