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
- Variables
- func All[T widget.Widget](root widget.Widget) []T
- func Button(t *testing.T, root widget.Widget, name string) *widget.Button
- func ButtonTextPx(a, b *widget.Button, face render.Font) float64
- func Code(sym xkb.Keysym) uint32
- func Contains(root, w widget.Widget) bool
- func ExpectGreen(t *testing.T, scale string, px []byte)
- func First[T widget.Widget](t *testing.T, root widget.Widget) T
- func Font(t *testing.T) render.Font
- func FractionalFirstPaint(t *testing.T, num int, makeIcon func(post func(func())) *widget.Icon) []byte
- func GreenSVG(t *testing.T) string
- func HeapBytes(f func()) uint64
- func IconTheme(t *testing.T, names ...string)
- func Ink(w widget.Widget) int
- func KeySym(code uint32) xkb.Keysym
- func LabelReading(t *testing.T, root widget.Widget, text string) *widget.Label
- func Labels(root widget.Widget) []string
- func OffScale(root widget.Widget, face render.Font, sizes []float64) []string
- func Pointer(root widget.Widget, target widget.Boundser, w, h int) (*widget.Router, widget.Point)
- func RenderedTextPx(l *widget.Label, face render.Font) float64
- func Walk(w widget.Widget, visit func(widget.Widget))
- func WithClass(root widget.Widget, class string) []widget.Widget
Constants ¶
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 ¶
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.
var Loop sync.Mutex
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 ButtonTextPx ¶
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 ExpectGreen ¶
ExpectGreen fails unless the pixel is the exact green GreenSVG draws.
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 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 ¶
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 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 ¶
LabelReading is the first label Walk reaches under root whose text is text.
func OffScale ¶
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 ¶
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 ¶
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.
Types ¶
This section is empty.