mirror of https://github.com/subgraph/fw-daemon
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.4 KiB
59 lines
1.4 KiB
package glib_test
|
|
|
|
import (
|
|
"runtime"
|
|
"testing"
|
|
|
|
"github.com/gotk3/gotk3/glib"
|
|
"github.com/gotk3/gotk3/gtk"
|
|
)
|
|
|
|
func init() {
|
|
gtk.Init(nil)
|
|
}
|
|
|
|
// TestConnectNotifySignal ensures that property notification signals (those
|
|
// whose name begins with "notify::") are queried by the name "notify" (with the
|
|
// "::" and the property name omitted). This is because the signal is "notify"
|
|
// and the characters after the "::" are not recognized by the signal system.
|
|
//
|
|
// See
|
|
// https://developer.gnome.org/gobject/stable/gobject-The-Base-Object-Type.html#GObject-notify
|
|
// for background, and
|
|
// https://developer.gnome.org/gobject/stable/gobject-Signals.html#g-signal-new
|
|
// for the specification of valid signal names.
|
|
func TestConnectNotifySignal(t *testing.T) {
|
|
runtime.LockOSThread()
|
|
|
|
// Create any GObject that has defined properties.
|
|
spacing := 0
|
|
box, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, spacing)
|
|
|
|
// Connect to a "notify::" signal to listen on property changes.
|
|
box.Connect("notify::spacing", func() {
|
|
gtk.MainQuit()
|
|
})
|
|
|
|
glib.IdleAdd(func(s string) bool {
|
|
t.Log(s)
|
|
spacing++
|
|
box.SetSpacing(spacing)
|
|
return true
|
|
}, "IdleAdd executed")
|
|
|
|
gtk.Main()
|
|
}
|
|
|
|
/*At this moment Visionect specific*/
|
|
func TestTimeoutAdd(t *testing.T) {
|
|
runtime.LockOSThread()
|
|
|
|
glib.TimeoutAdd(2500, func(s string) bool {
|
|
t.Log(s)
|
|
gtk.MainQuit()
|
|
return false
|
|
}, "TimeoutAdd executed")
|
|
|
|
gtk.Main()
|
|
}
|