gioui.org@v0.6.1-0.20240506124620-7a9ce51988ce/io/input/router_test.go (about) 1 // SPDX-License-Identifier: Unlicense OR MIT 2 3 package input 4 5 import ( 6 "testing" 7 8 "gioui.org/io/pointer" 9 "gioui.org/op" 10 ) 11 12 func TestNoFilterAllocs(t *testing.T) { 13 b := testing.Benchmark(func(b *testing.B) { 14 var r Router 15 s := r.Source() 16 b.ReportAllocs() 17 b.ResetTimer() 18 for i := 0; i < b.N; i++ { 19 s.Event(pointer.Filter{}) 20 } 21 }) 22 if allocs := b.AllocsPerOp(); allocs != 0 { 23 t.Fatalf("expected 0 AllocsPerOp, got %d", allocs) 24 } 25 } 26 27 func TestRouterWakeup(t *testing.T) { 28 r := new(Router) 29 r.Source().Execute(op.InvalidateCmd{}) 30 r.Frame(new(op.Ops)) 31 if _, wake := r.WakeupTime(); !wake { 32 t.Errorf("InvalidateCmd did not trigger a redraw") 33 } 34 }