testutil

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 22 Imported by: 0 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 testutil holds widget-test helpers: test fonts, isolated paths and proof images (SPEC §15).

Index

Constants

View Source
const MonoFamily = "Go Mono"

MonoFamily is the family name of the test font for the editor (SPEC D14).

View Source
const ScanTimeout = 30 * time.Second

ScanTimeout is the time limit of one pattern search of a grammar in the tests that tokenize. The default (100 ms in production, SPEC §8.2) is exceeded by the first search of a grammar on a loaded machine under the race detector, and a search that times out leaves its line without colors, which a golden image shows.

Variables

View Source
var WindowInfo = ui.WindowInfo{
	Decoration: ui.DecorationApp, Capabilities: ui.AllWindowCapabilities, Activated: true, Maximized: true,
}

WindowInfo is the window the tester shows: the one Emetos asks for (SPEC §10.14), whose title bar the application draws (DecorationApp), with every capability, focused and maximized (so that the window has no border and no resize edges, which would show in every image).

Functions

func Fonts

func Fonts() []gluttertest.Font

Fonts are the fonts every UI test loads: Go Mono in its four styles under the family MonoFamily, then Codicons and Seti. The look of a test never depends on the fonts of the machine that runs it.

func Isolate

func Isolate(t testing.TB) storage.Paths

Isolate points every user folder at temporary ones (see storagetest.Isolate) and returns their paths.

func MatchesGolden

func MatchesGolden(ts *gluttertest.Tester, name string)

MatchesGolden is the MatchesGolden of the tester after SettleTokens: a golden image never depends on how far the background tokenizer got. Every golden test calls it.

func New

func New(t testing.TB, size ui.Size) *gluttertest.Tester

New makes a tester of the given size in logical pixels with the test fonts loaded. The tester unmounts the widget tree when the test ends, so the states are disposed and the goroutines they started (State.Go, the tokenizers of the app) end with the test. Its window is WindowInfo, so that the title bar row shows as it does in the application.

It also pins the target platform to Linux, which the key bindings, the golden pictures and the behavior of the text fields were made for (Flutter's text field fades its caret on macOS and does not blink it, for one thing): without it a test on a Mac runs as a Mac and differs by a caret. The pin needs a debug build, which `go test` is.

func Proof

func Proof(t testing.TB, ts *gluttertest.Tester, name string)

Proof writes the screenshot of the tester as a PNG to docs/implemented-proof-images/<name> (proof method A) when the run has the -proof flag, and does nothing otherwise. The name ends in .png.

func ProofEnabled

func ProofEnabled() bool

ProofEnabled tells whether the test run has the -proof flag.

func RepoRoot

func RepoRoot(t testing.TB) string

RepoRoot finds the folder of the repository: the nearest parent of the working directory that holds the go.mod of Emetos.

func Settings

func Settings(t testing.TB, paths storage.Paths, extra map[string]any) *settings.Store

Settings makes a settings store over the registry of Emetos whose user settings.json sits in the isolated configuration folder and says editor.fontFamily is MonoFamily. extra adds or replaces other settings. The files are read before it returns.

func SettleTokens

func SettleTokens(ts *gluttertest.Tester)

SettleTokens tokenizes, on the caller, every line of every editor the tester shows (also the ones that are offstage), then pumps a frame so that the text is painted with the colors. The editor tokenizes the lines it draws only as far as a wall-clock budget allows and leaves the rest to a background goroutine, so a picture taken without this depends on the speed of the machine.

Types

This section is empty.

Jump to

Keyboard shortcuts

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