treetest

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 15 Imported by: ? modules, 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 treetest walks lys-ui widget trees for the shell's surface tests: find the button a user would click, read what the labels say.

Index

Constants

View Source
const Liveness = 2 * time.Minute

Liveness is how long a surface harness waits for a surface to open or a request to be answered before failing: a guard against a hang, not a speed bound. The first surface of a test binary compiles the whole stylesheet bundle, which the race detector under a parallel test run stretches past a couple of seconds.

Variables

View Source
var FractionalScales = []struct {
	Name string
	Num  int
}{{"1.25", 150}, {"1.5", 180}}

FractionalScales are the device scales, in 120ths, the fractional icon gates paint at.

Loop stands in for the process's one UI goroutine in the surface harnesses: lys-ui keeps its style and layout scratch per process, so every harness in a test binary runs its widget work under this one lock, never a lock of its own (a finished test's harness can still be draining while the next one builds).

Functions

func All

func All[T widget.Widget](root widget.Widget) []T

All is every widget of type T under root, in walk order.

func Button

func Button(t *testing.T, root widget.Widget, name string) *widget.Button

Button is the first button whose accessible name is name.

func ButtonTextPx

func ButtonTextPx(a, b *widget.Button, face render.Font) float64

ButtonTextPx is the font size two buttons of one build render their labels at in face, read off how much wider the one with the longer accessible name measures: their padding, borders and icons cancel out, so it needs no reach into a button's content.

func Code

func Code(sym xkb.Keysym) uint32

Code is the code KeySym reads as sym.

func Contains

func Contains(root, w widget.Widget) bool

Contains reports whether w is root or one of its descendants.

func ExpectGreen

func ExpectGreen(t *testing.T, scale string, px []byte)

ExpectGreen fails unless the pixel is the exact green GreenSVG draws.

func First

func First[T widget.Widget](t *testing.T, root widget.Widget) T

First is the first widget of type T under root.

func Font

func Font(t *testing.T) render.Font

Font is the Go Regular face the widget tests measure and paint text with.

func FractionalFirstPaint

func FractionalFirstPaint(t *testing.T, num int, makeIcon func(post func(func())) *widget.Icon) []byte

FractionalFirstPaint puts the 16px icon makeIcon builds into a tree that presents at num/120, as a window does before its first frame, runs what it posts to the loop until it shows an .svg file, and returns the center pixel of its first paint. It fails when that paint would have to decode.

func GreenSVG

func GreenSVG(t *testing.T) string

GreenSVG writes a 16px green square to a file of its own.

func HeapBytes

func HeapBytes(f func()) uint64

HeapBytes is how many bytes f allocates on the Go heap, read from the runtime's stopped-world statistics so allocations still cached per thread are counted where they happened.

func IconTheme

func IconTheme(t *testing.T, names ...string)

IconTheme points theme icon lookups at a temp hicolor theme holding one solid square SVG app icon per name, for the duration of the test.

func Ink

func Ink(w widget.Widget) int

Ink counts the pixels w paints when laid out at its natural size.

func KeySym

func KeySym(code uint32) xkb.Keysym

KeySym reads each code as the keysym of the same number, so a surface harness presses a key by its symbol: OnKey(r, Code(xkb.KeyEscape), 0).

func LabelReading

func LabelReading(t *testing.T, root widget.Widget, text string) *widget.Label

LabelReading is the first label Walk reaches under root whose text is text.

func Labels

func Labels(root widget.Widget) []string

Labels is the text of every label under root, in walk order.

func OffScale

func OffScale(root widget.Widget, face render.Font, sizes []float64) []string

OffScale names every laid-out, shown label Walk reaches under root whose rendered size is none of sizes, within the rounding of its measured width. A button's content is out of its reach: lys-ui's Button lists no Children.

func Pointer

func Pointer(root widget.Widget, target widget.Boundser, w, h int) (*widget.Router, widget.Point)

Pointer lays root out in a w x h rect and returns a Router over it with the pointer resting on target's centre, and that point: the real input path, hit testing and the pointer and scroll hooks included.

func RenderedTextPx

func RenderedTextPx(l *widget.Label, face render.Font) float64

RenderedTextPx is the font size l's text renders at in face: the cascade's font-size, else the constructor's, read off how much its measured width grows by eight more probe glyphs, unclipped, so padding and borders cancel out.

func Walk

func Walk(w widget.Widget, visit func(widget.Widget))

Walk visits w and every descendant, depth first: a hidden revealer's content too, which its Children leave out.

func WithClass

func WithClass(root widget.Widget, class string) []widget.Widget

WithClass is every widget under root carrying class.

Types

This section is empty.

Jump to

Keyboard shortcuts

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