Documentation
¶
Overview ¶
Package wltest helps tests run Wayland clients: a private runtime dir and a loopback display for wire-level tests with no compositor, and, against the headless compositor the test recipes boot, a client that puts solid-colored surfaces on screen for capture tests to find.
Index ¶
- Constants
- func Eventually(t *testing.T, what string, fn func() error)
- func LoopbackDisplay(t *testing.T, display string) (*net.UnixListener, string)
- func Require(t *testing.T)
- func RuntimeDir(t *testing.T) string
- func WantColor(img *image.RGBA, x, y int, want color.RGBA) error
- type Painter
- func (p *Painter) HandleRegistryGlobal(ev wl.RegistryGlobalEvent)
- func (p *Painter) HandleRegistryGlobalRemove(wl.RegistryGlobalRemoveEvent)
- func (p *Painter) HandleWmBasePing(ev xdg.WmBasePingEvent)
- func (p *Painter) Layer(anchor uint32, w, h int32, c color.RGBA)
- func (p *Painter) Run()
- func (p *Painter) Window(appID, title string, w, h int32, c color.RGBA) *Window
- type Window
Constants ¶
const ( AnchorTop = wlr.ZwlrLayerSurfaceV1AnchorTop AnchorBottom = wlr.ZwlrLayerSurfaceV1AnchorBottom AnchorLeft = wlr.ZwlrLayerSurfaceV1AnchorLeft AnchorRight = wlr.ZwlrLayerSurfaceV1AnchorRight )
Layer anchors, wlr-layer-shell's: a layer anchored to two opposite edges stretches between them.
const HeadlessEnv = "LYS_TEST_HEADLESS"
HeadlessEnv is set by the recipes that boot a headless compositor for a test run; Require skips without it.
Variables ¶
This section is empty.
Functions ¶
func Eventually ¶
Eventually retries fn until it succeeds or eight seconds pass.
func LoopbackDisplay ¶
LoopbackDisplay binds a real unix socket as a wayland display the test process owns: the far end for wire-level and dead-peer tests, no compositor involved. The socket lives in a fresh RuntimeDir and the process env is pointed at the display, so wl.Connect("") reaches the listener. The caller closes the listener.
func RuntimeDir ¶
RuntimeDir creates a private XDG_RUNTIME_DIR at the temp root and points the process env at it. It sits outside t.TempDir because the kernel caps a socket path at 107 bytes and CI's nested temp dirs push a t.TempDir path past that, so bind fails with EINVAL. The dir goes away at cleanup.
Types ¶
type Painter ¶
type Painter struct {
// contains filtered or unexported fields
}
Painter is a Wayland client that shows solid-colored surfaces: layer surfaces on the first output and toplevel windows, each repainted at whatever size the compositor configures it to. Its events run on a goroutine of their own until the test ends.
func NewPainter ¶
NewPainter connects to the compositor WAYLAND_DISPLAY names and binds what painting needs; the connection closes at cleanup.
func (*Painter) HandleRegistryGlobal ¶
func (p *Painter) HandleRegistryGlobal(ev wl.RegistryGlobalEvent)
HandleRegistryGlobal binds the globals painting needs.
func (*Painter) HandleRegistryGlobalRemove ¶
func (p *Painter) HandleRegistryGlobalRemove(wl.RegistryGlobalRemoveEvent)
HandleRegistryGlobalRemove implements the registry listener.
func (*Painter) HandleWmBasePing ¶
func (p *Painter) HandleWmBasePing(ev xdg.WmBasePingEvent)
HandleWmBasePing answers the compositor's ping.
func (*Painter) Layer ¶
Layer shows an overlay layer surface of c on the first output, anchored to anchor, w x h where it is not stretched between two anchored edges (0 there).
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window is a toplevel a Painter shows, painted at the size the compositor configures, as a tiling compositor holds it to whatever the client asks.
func (*Window) Fullscreen ¶
func (w *Window) Fullscreen()
Fullscreen asks the compositor to make the window fullscreen; it repaints at the size that configures.