mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 09:25:38 +00:00
io/input: test deferred behaviour of Router
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -14,6 +14,25 @@ import (
|
|||||||
"gioui.org/op/clip"
|
"gioui.org/op/clip"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestDeferred(t *testing.T) {
|
||||||
|
r := new(Router)
|
||||||
|
h := new(int)
|
||||||
|
f := []event.Filter{
|
||||||
|
key.FocusFilter{Target: h},
|
||||||
|
key.Filter{Name: "A"},
|
||||||
|
}
|
||||||
|
// Provoke deferring by exhausting events for h.
|
||||||
|
events(r, -1, f...)
|
||||||
|
r.Source().Execute(key.FocusCmd{Tag: h})
|
||||||
|
ke := key.Event{Name: "A"}
|
||||||
|
r.Queue(ke)
|
||||||
|
// All events are deferred at this point.
|
||||||
|
assertEventSequence(t, events(r, -1, f...))
|
||||||
|
r.Frame(new(op.Ops))
|
||||||
|
// But delivered after a frame.
|
||||||
|
assertEventSequence(t, events(r, -1, f...), key.FocusEvent{Focus: true}, ke)
|
||||||
|
}
|
||||||
|
|
||||||
func TestInputWakeup(t *testing.T) {
|
func TestInputWakeup(t *testing.T) {
|
||||||
handler := new(int)
|
handler := new(int)
|
||||||
var ops op.Ops
|
var ops op.Ops
|
||||||
|
|||||||
Reference in New Issue
Block a user