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
- 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 DmabufFeedback
- type FeedbackTranche
- type FormatModifier
- type Painter
- func (p *Painter) Cursor(side int32, c color.RGBA)
- func (p *Painter) HandlePointerEnter(ev wl.PointerEnterEvent)
- func (p *Painter) HandleRegistryGlobal(ev wl.RegistryGlobalEvent)
- func (p *Painter) HandleRegistryGlobalRemove(wl.RegistryGlobalRemoveEvent)
- func (p *Painter) HandleSeatCapabilities(ev wl.SeatCapabilitiesEvent)
- 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, failing the test with fn's last error when it still does not after waittest's limit.
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 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 ¶
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 ¶
NewPainter connects to the compositor WAYLAND_DISPLAY names and binds what painting needs; the connection closes at cleanup.
func (*Painter) Cursor ¶
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 ¶
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.