Headless and tests
Drive the real UI pipeline in tests and CI, with no window or GPU.
Build with -tags nogpu to swap the GPU and GLFW files for stubs. The UI pipeline is the same: layout, input dispatch, focus and painting into a draw list.
go run -tags nogpu ./example/todo
go test -tags nogpu ./...Ship a GPU main (//go:build !nogpu) and a headless main (//go:build nogpu) in the same package, as the demos do.
Driving frames#
text, _ := shape.NewEngine(1, false)
clip := &input.MemClipboard{}
sheet := render.NewSpriteSheet(text.Atlas)
yoga.SetResources(text, sheet, clip)
c := ui.New(text, ui.NewFocusScope(), nil)
c.SetIcons(sheet)
c.SetClipboard(clip)
root := ui.BuildFrame(c, app.Body, w, h, mouse, keyboard)
layout.Dispatch(root, mouse)
c.Focus().Route(keyboard)
mouse.EndFrame()
keyboard.EndFrame()
root = ui.BuildFrame(c, app.Body, w, h, mouse, keyboard)
layout.Paint(root, drawList, text)Use input.MemClipboard in tests so they never touch the system clipboard.