mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 15:45:38 +00:00
d9a007586c
Until now, every event has had a particular target. We're about to simplify key event delivery to match the first matching filter, so there is no longer a global meaning to the tag argument to Source.Event. Add fields to filters to specify their target tags. Signed-off-by: Elias Naur <mail@eliasnaur.com>
35 lines
664 B
Go
35 lines
664 B
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
package input
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gioui.org/io/pointer"
|
|
"gioui.org/op"
|
|
)
|
|
|
|
func TestNoFilterAllocs(t *testing.T) {
|
|
b := testing.Benchmark(func(b *testing.B) {
|
|
var r Router
|
|
s := r.Source()
|
|
b.ReportAllocs()
|
|
b.ResetTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
s.Event(pointer.Filter{})
|
|
}
|
|
})
|
|
if allocs := b.AllocsPerOp(); allocs != 0 {
|
|
t.Fatalf("expected 0 AllocsPerOp, got %d", allocs)
|
|
}
|
|
}
|
|
|
|
func TestRouterWakeup(t *testing.T) {
|
|
r := new(Router)
|
|
r.Source().Execute(op.InvalidateCmd{})
|
|
r.Frame(new(op.Ops))
|
|
if _, wake := r.WakeupTime(); !wake {
|
|
t.Errorf("InvalidateCmd did not trigger a redraw")
|
|
}
|
|
}
|