Documentation
¶
Overview ¶
Package testutil holds widget-test helpers: test fonts, isolated paths and proof images (SPEC §15).
Index ¶
- Constants
- Variables
- func Fonts() []gluttertest.Font
- func Isolate(t testing.TB) storage.Paths
- func MatchesGolden(ts *gluttertest.Tester, name string)
- func New(t testing.TB, size ui.Size) *gluttertest.Tester
- func Proof(t testing.TB, ts *gluttertest.Tester, name string)
- func ProofEnabled() bool
- func RepoRoot(t testing.TB) string
- func Settings(t testing.TB, paths storage.Paths, extra map[string]any) *settings.Store
- func SettleTokens(ts *gluttertest.Tester)
Constants ¶
const MonoFamily = "Go Mono"
MonoFamily is the family name of the test font for the editor (SPEC D14).
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 ¶
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 ¶
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 ¶
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 (the race run, -tags debug_mode); the release run of the tests (SPEC §15.1) runs as the host, which on the Linux machines that run it is the same.
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 ¶
RepoRoot finds the folder of the repository: the nearest parent of the working directory that holds the go.mod of Emetos.
func Settings ¶
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.