2014-07-08 09:00:16 -05:00
|
|
|
// 8 july 2014
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
// This file is called zz_test.go to keep it separate from the other files in this package (and because go test won't accept just test.go)
|
|
|
|
|
|
|
|
import (
|
2014-07-21 20:07:14 -05:00
|
|
|
"fmt"
|
2014-07-18 21:30:07 -05:00
|
|
|
"flag"
|
2014-07-08 09:00:16 -05:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2014-07-18 21:30:07 -05:00
|
|
|
var closeOnClick = flag.Bool("close", false, "close on click")
|
|
|
|
|
2014-07-08 15:47:28 -05:00
|
|
|
// because Cocoa hates being run off the main thread, even if it's run exclusively off the main thread
|
|
|
|
func init() {
|
2014-07-18 21:30:07 -05:00
|
|
|
flag.Parse()
|
2014-07-19 09:16:00 -05:00
|
|
|
go func() {
|
2014-07-08 09:00:16 -05:00
|
|
|
done := make(chan struct{})
|
2014-07-19 09:16:00 -05:00
|
|
|
Do(func() {
|
|
|
|
w := NewWindow("Hello", 320, 240)
|
|
|
|
b := NewButton("There")
|
|
|
|
w.SetControl(b)
|
2014-07-18 21:30:07 -05:00
|
|
|
if *closeOnClick {
|
2014-07-19 09:16:00 -05:00
|
|
|
b.SetText("Click to Close")
|
2014-07-18 21:30:07 -05:00
|
|
|
}
|
2014-07-19 09:16:00 -05:00
|
|
|
w.OnClosing(func() bool {
|
|
|
|
if *closeOnClick {
|
|
|
|
panic("window closed normally in close on click mode (should not happen)")
|
|
|
|
}
|
|
|
|
println("window close event received")
|
2014-07-18 21:30:07 -05:00
|
|
|
Stop()
|
|
|
|
done <- struct{}{}
|
2014-07-19 09:16:00 -05:00
|
|
|
return true
|
|
|
|
})
|
|
|
|
// GTK+ TODO: this is causing a resize event to happen afterward?!
|
|
|
|
b.OnClicked(func() {
|
|
|
|
println("in OnClicked()")
|
|
|
|
if *closeOnClick {
|
|
|
|
w.Close()
|
|
|
|
Stop()
|
|
|
|
done <- struct{}{}
|
2014-07-21 20:07:14 -05:00
|
|
|
} else {
|
|
|
|
c := NewCheckbox("You Should Now See Me Instead")
|
|
|
|
w.SetControl(c)
|
|
|
|
c.OnClicked(func() {
|
|
|
|
w.SetTitle(fmt.Sprint(c.Checked()))
|
|
|
|
})
|
2014-07-19 09:16:00 -05:00
|
|
|
}
|
|
|
|
})
|
|
|
|
w.Show()
|
2014-07-19 08:58:57 -05:00
|
|
|
})
|
2014-07-08 09:00:16 -05:00
|
|
|
<-done
|
2014-07-19 09:16:00 -05:00
|
|
|
}()
|
2014-07-08 09:00:16 -05:00
|
|
|
err := Go()
|
|
|
|
if err != nil {
|
2014-07-08 15:47:28 -05:00
|
|
|
panic(err)
|
2014-07-08 09:00:16 -05:00
|
|
|
}
|
|
|
|
}
|
2014-07-08 15:47:28 -05:00
|
|
|
|
|
|
|
func TestDummy(t *testing.T) {
|
|
|
|
// do nothing
|
|
|
|
}
|