e2e

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: MIT Imports: 34 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 e2e drives the built icebath program in a real terminal window on a fresh computer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Seated

func Seated()

Seated runs as the first process on a fresh computer when the seat variable is set: it opens the program's terminal and the listening socket for the computer's model server, passes both out to the seat, and becomes the program. It returns when the variable is unset.

func TestMain

func TestMain(m *testing.M)

func TestTour

func TestTour(t *testing.T)

TestTour starts icebath for the first time on a fresh computer, sets it up, talks to a model, and then opens every command, row and button it can find, with a picture of each view under shots.

func Tools

func Tools() []string

Tools lists the programs a seat needs that this computer lacks.

Types

type Box

type Box struct{ X, Y, W, H int }

Box is a rectangle of cells drawn with a border.

func (Box) Inside

func (b Box) Inside(other Box) bool

Inside reports whether the box lies within the other box.

type Button

type Button struct {
	Label string
	Key   string
	X, Y  int
}

Button is an action the bottom edge of a box offers, with the key the screen shows for it.

type Command

type Command struct {
	Group  string
	Title  string
	Detail string
	Key    string
}

Command is one entry in the program's command list.

type Controller

type Controller struct {
	Seat *Seat
	// contains filtered or unexported fields
}

Controller uses the program in a seat the way a user does: it reads the screen to find things by their names, presses the keys the screen shows for its buttons, and takes every other key from the program's own key map.

func NewController

func NewController(seat *Seat) *Controller

NewController makes a controller for the seat, reading the screen in the glyphs and keys the program starts with.

func (*Controller) Act

func (c *Controller) Act(action string)

Act presses the key the program binds to the action.

func (*Controller) After

func (c *Controller) After(before *Screen) *View

After returns the view that has the keys once an action has shown on the screen. The program may answer an action a moment after it stops drawing, so After waits for the screen to differ from the screen before the action, and then for a longer quiet time.

func (*Controller) Back

func (c *Controller) Back()

Back leaves the front view: by its last button when that button backs out, by its close mark when it has no such button and is a window, and by the key that backs out of every dialog otherwise.

func (*Controller) Choice

func (c *Controller) Choice(row Row) (choice, chosen bool)

Choice reports whether the row is one value in a set of choices, which the screen marks with a filled or hollow circle, and whether it is the value chosen now.

func (*Controller) Choose

func (c *Controller) Choose(name string) bool

Choose highlights the row with the name in the front view and uses the view's first button on it.

func (*Controller) Click

func (c *Controller) Click(x, y int)

Click presses and releases the left mouse button on a cell.

func (*Controller) Close

func (c *Controller) Close() bool

Close clicks the close mark in the front view's title, and reports whether the title has a close mark.

func (*Controller) Command

func (c *Controller) Command(title, detail string) bool

Command runs the command list entry with the title and detail, and reports whether the list had it.

func (*Controller) Commands

func (c *Controller) Commands() []Command

Commands lists every entry in the program's command list, in list order.

func (*Controller) Describe

func (c *Controller) Describe() string

Describe returns the front view's title, buttons and highlighted row in one line, for a failure message.

func (*Controller) Do

func (c *Controller) Do(label string) bool

Do uses the front view's button with the label, and reports whether the view has it.

func (*Controller) Front

func (c *Controller) Front() *View

Front returns the view that has the keys after the program has stopped drawing. While the program runs some view always has them, so a screen without one is between two views, and Front waits for the next view.

func (*Controller) Leaves

func (c *Controller) Leaves(key string) bool

Leaves reports whether the key is bound to an action that backs out of a view without doing anything.

func (*Controller) Look

func (c *Controller) Look() *Screen

Look returns the screen after the program has stopped drawing.

func (*Controller) OpenCommands

func (c *Controller) OpenCommands() bool

OpenCommands opens the program's command list and reports whether it showed.

func (*Controller) Press

func (c *Controller) Press(chords ...string)

Press sends the keys, each in key map spelling, such as ctrl+g.

func (*Controller) Push

func (c *Controller) Push(button Button)

Push uses a button: by its key when the screen shows a key for it, and by a click otherwise.

func (*Controller) Rows

func (c *Controller) Rows(page func(), stop func(Row) bool) []Row

Rows walks the highlight from the first row to the last and returns every row it passed. It calls page each time the list has scrolled a full page past the rows last shown, and stops early when stop accepts a row.

func (*Controller) Screen

func (c *Controller) Screen() *Screen

Screen copies the program's current screen.

func (*Controller) Select

func (c *Controller) Select(rows []Row, i int) bool

Select moves the highlight to row i from a walk's rows, and reports whether it got there.

func (*Controller) Settle

func (c *Controller) Settle(limit time.Duration)

Settle waits until the program has stopped drawing, or the limit passes.

func (*Controller) Shot

func (c *Controller) Shot(path string) error

Shot writes the terminal window's picture to path.png and the screen's text to path.txt. It waits for the window to finish drawing.

func (*Controller) Type

func (c *Controller) Type(text string)

Type sends the text as typed characters.

func (*Controller) Until

func (c *Controller) Until(limit time.Duration, test func(*Screen) bool) bool

Until waits for the screen to pass the test, and reports whether it did within the limit.

type Machine

type Machine struct {
	User string
	Host string
	// contains filtered or unexported fields
}

Machine is a fresh computer: an empty home folder, the program installed, one user, and no network but its own.

func NewMachine

func NewMachine(dir, kept, binary string) *Machine

NewMachine describes a computer kept in dir, which saves its states under kept and runs the program built at binary.

func (*Machine) Fresh

func (m *Machine) Fresh() error

Fresh makes the computer new: the home folder a new account starts with, and the program installed.

func (*Machine) Home

func (m *Machine) Home() string

Home is the user's home folder as programs on the computer see it.

func (*Machine) Keep

func (m *Machine) Keep(name string) error

Keep saves the computer's files under a name.

func (*Machine) Restore

func (m *Machine) Restore(name string) error

Restore replaces the computer's files with the files kept under the name. The installed program is copied only when it changed.

type Row

type Row struct {
	X, Y int
	Text string
	Name string
	Mark string
	// Offers lists the labels of the buttons the view showed for the row, without the button that backs out.
	Offers []string
}

Row is the selected line of a list, form or menu.

type Screen

type Screen struct {
	W, H  int
	Cells [][]uv.Cell
	Alt   bool
	// contains filtered or unexported fields
}

Screen is the program's screen at one moment, as rows of cells.

func (*Screen) Boxes

func (s *Screen) Boxes() []Box

Boxes finds every bordered rectangle on the screen by its left and bottom edges, because a notice may cover its top right corner.

func (*Screen) Find

func (s *Screen) Find(text string) (int, int, bool)

Find returns the cell where the text starts, searching from the top.

func (*Screen) Front

func (s *Screen) Front() *View

Front returns the window or dialog that has the keys: the marked box with the brightest title, because a dialog dims what is behind it.

func (*Screen) Has

func (s *Screen) Has(text string) bool

Has reports whether the text shows anywhere on the screen.

func (*Screen) Selected

func (s *Screen) Selected(b Box) (Row, bool)

Selected returns the highlighted line inside the box: the row mark on a background that differs from the box's background. A row that spans several lines is returned as a single row.

func (*Screen) Steady

func (s *Screen) Steady() string

Steady returns the screen's text with digits and working marks replaced, so a running clock does not count as a change.

func (*Screen) String

func (s *Screen) String() string

String returns the whole screen as lines of text.

func (*Screen) Text

func (s *Screen) Text(y, x0, x1 int) string

Text returns the cells of row y from column x0 up to x1 as text.

type Seat

type Seat struct {
	Cols int
	Rows int
	// contains filtered or unexported fields
}

Seat is one terminal window on its own display, with the program running in it.

func OpenSeat

func OpenSeat(dir string, width, height int) (*Seat, error)

OpenSeat starts a display and a terminal window that fills it, and measures the window's grid.

func (*Seat) Close

func (s *Seat) Close()

Close ends the program, the terminal window and the display.

func (*Seat) Emulator

func (s *Seat) Emulator() *term.Emulator

Emulator returns the program's screen model.

func (*Seat) Grab

func (s *Seat) Grab() *image.RGBA

Grab copies the terminal grid's picture.

func (*Seat) Ignored

func (s *Seat) Ignored(since time.Duration) bool

Ignored reports whether the program has written nothing since its last input, for at least the given time.

func (*Seat) Quiet

func (s *Seat) Quiet(quiet, answer time.Duration) bool

Quiet reports whether the program has been silent for the quiet time, and has had the answer time since its last input.

func (*Seat) Run

func (s *Seat) Run(m *Machine, program ...string) (net.Listener, error)

Run starts the program on the computer in this seat's terminal, and returns the listener for the computer's model server.

func (*Seat) Running

func (s *Seat) Running() bool

Running reports whether the program has not ended.

func (*Seat) Send

func (s *Seat) Send(data []byte)

Send writes bytes to the program's terminal input.

func (*Seat) Stop

func (s *Seat) Stop()

Stop ends the program: it hangs up the terminal, then kills what is left.

type View

type View struct {
	Box
	Trail   []string
	Buttons []Button
	// contains filtered or unexported fields
}

View is the box the program gives the keys to: a window or a dialog.

func (*View) Button

func (v *View) Button(label string) (Button, bool)

Button returns the view's button with the label, ignoring letter case.

func (*View) ID

func (v *View) ID() string

ID identifies the view by its title's trail.

func (*View) Out

func (v *View) Out() (Button, bool)

Out returns the button that backs out of the view, which a dialog shows last and a window does not have.

func (*View) Selected

func (v *View) Selected() (Row, bool)

Selected returns the view's highlighted row.

func (*View) Text

func (v *View) Text() string

Text returns the view's text inside its border, with numbers and working marks replaced, so two readings from an unchanged view are equal while clocks and counters run.

Jump to

Keyboard shortcuts

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