2015-12-11 21:58:21 -06:00
|
|
|
// 11 december 2015
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
2015-12-12 17:44:35 -06:00
|
|
|
import "time"
|
2015-12-11 21:58:21 -06:00
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestIt(t *testing.T) {
|
|
|
|
err := Main(func() {
|
2015-12-12 12:37:36 -06:00
|
|
|
w := NewWindow("Hello", 320, 240, false)
|
2015-12-12 17:44:35 -06:00
|
|
|
stop := make(chan struct{})
|
2015-12-12 12:37:36 -06:00
|
|
|
w.OnClosing(func(w *Window) bool {
|
2015-12-12 17:44:35 -06:00
|
|
|
stop <- struct{}{}
|
2015-12-12 12:37:36 -06:00
|
|
|
Quit()
|
|
|
|
return true
|
|
|
|
})
|
2015-12-12 17:44:35 -06:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
2015-12-12 12:37:36 -06:00
|
|
|
w.Show()
|
2015-12-11 21:58:21 -06:00
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|