andlabs-ui/redo/zz_test.go

69 lines
1.5 KiB
Go
Raw Normal View History

// 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 (
"fmt"
2014-07-18 21:30:07 -05:00
"flag"
"testing"
)
2014-07-18 21:30:07 -05:00
var closeOnClick = flag.Bool("close", false, "close on click")
// because Cocoa hates being run off the main thread, even if it's run exclusively off the main thread
func init() {
flag.BoolVar(&spaced, "spaced", false, "enable spacing")
2014-07-18 21:30:07 -05:00
flag.Parse()
go func() {
done := make(chan struct{})
Do(func() {
2014-07-25 14:58:24 -05:00
t := NewTab()
w := NewWindow("Hello", 320, 240, t)
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{}{}
return true
})
b := NewButton("There")
if *closeOnClick {
b.SetText("Click to Close")
}
// 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-25 14:58:24 -05:00
t.Append("Button", b)
c := NewCheckbox("You Should Now See Me Instead")
c.OnClicked(func() {
w.SetTitle(fmt.Sprint(c.Checked()))
})
t.Append("Checkbox", c)
2014-07-26 05:57:11 -05:00
e := NewTextField()
t.Append("Text Field", e)
e = NewPasswordField()
t.Append("Password Field", e)
w.Show()
})
<-done
}()
err := Go()
if err != nil {
panic(err)
}
}
func TestDummy(t *testing.T) {
// do nothing
}