wltest

package
v0.3.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 19 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package wltest helps tests run Wayland clients: a private runtime dir, a loopback display for wire-level tests with no compositor, a fake compositor serving linux-dmabuf feedback over one, 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

Layer anchors, wlr-layer-shell's: a layer anchored to two opposite edges stretches between them.

View Source
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

func Eventually(t *testing.T, what string, fn func() error)

Eventually retries fn until it succeeds or eight seconds pass.

func LoopbackDisplay

func LoopbackDisplay(t *testing.T, display string) (*net.UnixListener, string)

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 Require

func Require(t *testing.T)

Require skips a test that needs the headless compositor when the run has none.

func RuntimeDir

func RuntimeDir(t *testing.T) string

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.

func WantColor

func WantColor(img *image.RGBA, x, y int, want color.RGBA) error

WantColor checks one pixel of a captured frame.

Types

type DmabufFeedback

type DmabufFeedback struct {
	// contains filtered or unexported fields
}

DmabufFeedback is a fake compositor for one client, at the far end of a LoopbackDisplay: wl_compositor and zwp_linux_dmabuf_v1 at version 4, whose default and surface feedback objects it sends a feedback when they are made and again at each SetFeedback, as a compositor does when a surface gains or loses a scanout plane.

func NewDmabufFeedback

func NewDmabufFeedback(t *testing.T, device uint64, tranches ...FeedbackTranche) *DmabufFeedback

NewDmabufFeedback serves one client on a loopback display the process's WAYLAND_DISPLAY then names, sending feedback of main device and tranches until SetFeedback changes them.

func (*DmabufFeedback) Sent

func (f *DmabufFeedback) Sent() int

Sent counts the feedbacks sent, each ending in a done.

func (*DmabufFeedback) SetFeedback

func (f *DmabufFeedback) SetFeedback(device uint64, tranches ...FeedbackTranche)

SetFeedback replaces the feedback and sends it whole to every feedback object the client holds.

type FeedbackTranche

type FeedbackTranche struct {
	Device  uint64
	Flags   uint32
	Formats []FormatModifier
}

FeedbackTranche is one tranche a DmabufFeedback sends: its target device, its tranche_flags and its formats in preference order.

type FormatModifier

type FormatModifier struct {
	Format   fourcc.Format
	Modifier fourcc.Modifier
}

FormatModifier is one entry of a linux-dmabuf format table.

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

func NewPainter(t *testing.T) *Painter

NewPainter connects to the compositor WAYLAND_DISPLAY names and binds what painting needs; the connection closes at cleanup.

func (*Painter) Cursor

func (p *Painter) Cursor(side int32, c color.RGBA)

Cursor sets the pointer's image over the painter's surfaces to a side x side square of c with its hotspot in the middle, once the pointer has entered one of them. A new call is a new image.

func (*Painter) HandlePointerEnter

func (p *Painter) HandlePointerEnter(ev wl.PointerEnterEvent)

HandlePointerEnter keeps the enter's serial, which setting the pointer's image needs.

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) HandleSeatCapabilities

func (p *Painter) HandleSeatCapabilities(ev wl.SeatCapabilitiesEvent)

HandleSeatCapabilities follows the seat's pointer, once it has one.

func (*Painter) HandleWmBasePing

func (p *Painter) HandleWmBasePing(ev xdg.WmBasePingEvent)

HandleWmBasePing answers the compositor's ping.

func (*Painter) Layer

func (p *Painter) Layer(anchor uint32, w, h int32, c color.RGBA)

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).

func (*Painter) Run

func (p *Painter) Run()

Run hands the connection's events to a goroutine of their own, so surfaces are repainted when the compositor reconfigures them (an output turned or resized): call it once every surface is shown.

func (*Painter) Window

func (p *Painter) Window(appID, title string, w, h int32, c color.RGBA) *Window

Window shows a toplevel of c titled title with app id appID, w x h on an axis the compositor leaves to the client (Size is what it took).

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) Close

func (w *Window) Close()

Close unmaps and destroys the window.

func (*Window) Fullscreen

func (w *Window) Fullscreen()

Fullscreen asks the compositor to make the window fullscreen; it repaints at the size that configures.

func (*Window) Repaint

func (w *Window) Repaint()

Repaint paints the window again at its size: a change of content the compositor sees, with no change of size.

func (*Window) Size

func (w *Window) Size() (width, height int32)

Size is the size the window is painted at.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL