tuitest

package module
v0.0.0-...-ee61efd Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: MIT Imports: 13 Imported by: 1

README

license CI godoc goreport codecov

tui-tester

A black box testing library for interactive terminal applications written in Go

Documentation

Index

Constants

View Source
const (
	KeyNull      = keyNUL
	KeyBreak     = keyETX
	KeyEnter     = keyCR
	KeyBackspace = keyDEL
	KeyTab       = keyHT
	KeyEsc       = keyESC
	KeyEscape    = keyESC

	KeyCtrlAt           = keyNUL // ctrl+@
	KeyCtrlA            = keySOH
	KeyCtrlB            = keySTX
	KeyCtrlC            = keyETX
	KeyCtrlD            = keyEOT
	KeyCtrlE            = keyENQ
	KeyCtrlF            = keyACK
	KeyCtrlG            = keyBEL
	KeyCtrlH            = keyBS
	KeyCtrlI            = keyHT
	KeyCtrlJ            = keyLF
	KeyCtrlK            = keyVT
	KeyCtrlL            = keyFF
	KeyCtrlM            = keyCR
	KeyCtrlN            = keySO
	KeyCtrlO            = keySI
	KeyCtrlP            = keyDLE
	KeyCtrlQ            = keyDC1
	KeyCtrlR            = keyDC2
	KeyCtrlS            = keyDC3
	KeyCtrlT            = keyDC4
	KeyCtrlU            = keyNAK
	KeyCtrlV            = keySYN
	KeyCtrlW            = keyETB
	KeyCtrlX            = keyCAN
	KeyCtrlY            = keyEM
	KeyCtrlZ            = keySUB
	KeyCtrlOpenBracket  = keyESC // ctrl+[
	KeyCtrlBackslash    = keyFS  // ctrl+\
	KeyCtrlCloseBracket = keyGS  // ctrl+]
	KeyCtrlCaret        = keyRS  // ctrl+^
	KeyCtrlUnderscore   = keyUS  // ctrl+_
	KeyCtrlQuestionMark = keyDEL // ctrl+?
)

Control key aliases.

View Source
const (
	// Arrow keys
	KeyUp                = "\x1b[A"
	KeyDown              = "\x1b[B"
	KeyRight             = "\x1b[C"
	KeyLeft              = "\x1b[D"
	KeyShiftUp           = "\x1b[1;2A"
	KeyShiftDown         = "\x1b[1;2B"
	KeyShiftRight        = "\x1b[1;2C"
	KeyShiftLeft         = "\x1b[1;2D"
	KeyAltUp             = "\x1b[1;3A"
	KeyAltDown           = "\x1b[1;3B"
	KeyAltRight          = "\x1b[1;3C"
	KeyAltLeft           = "\x1b[1;3D"
	KeyAltShiftUp        = "\x1b[1;4A"
	KeyAltShiftDown      = "\x1b[1;4B"
	KeyAltShiftRight     = "\x1b[1;4C"
	KeyAltShiftLeft      = "\x1b[1;4D"
	KeyCtrlUp            = "\x1b[1;5A"
	KeyCtrlDown          = "\x1b[1;5B"
	KeyCtrlRight         = "\x1b[1;5C"
	KeyCtrlLeft          = "\x1b[1;5D"
	KeyCtrlShiftUp       = "\x1b[1;6A"
	KeyCtrlShiftDown     = "\x1b[1;6B"
	KeyCtrlShiftRight    = "\x1b[1;6C"
	KeyCtrlShiftLeft     = "\x1b[1;6D"
	KeyCtrlAltUp         = "\x1b[1;7A"
	KeyCtrlAltDown       = "\x1b[1;7B"
	KeyCtrlAltRight      = "\x1b[1;7C"
	KeyCtrlAltLeft       = "\x1b[1;7D"
	KeyCtrlAltShiftUp    = "\x1b[1;8A"
	KeyCtrlAltShiftDown  = "\x1b[1;8B"
	KeyCtrlAltShiftRight = "\x1b[1;8C"
	KeyCtrlAltShiftLeft  = "\x1b[1;8D"

	// Miscellaneous keys
	KeyShiftTab = "\x1b[Z"

	KeyInsert    = "\x1b[2~"
	KeyAltInsert = "\x1b[3;2~"

	KeyDelete    = "\x1b[3~"
	KeyAltDelete = "\x1b[3;3~"

	KeyPgUp    = "\x1b[5~"
	KeyAltPgUp = "\x1b[5;3~"

	KeyCtrlPgUp    = "\x1b[5;5~"
	KeyCtrlAltPgUp = "\x1b[5;7~"

	KeyPgDown        = "\x1b[6~"
	KeyAltPgDown     = "\x1b[6;3~"
	KeyCtrlPgDown    = "\x1b[6;5~"
	KeyCtrlAltPgDown = "\x1b[6;7~"

	KeyHome             = "\x1b[1~"
	KeyAltHome          = "\x1b[1;3H"
	KeyCtrlHome         = "\x1b[1;5H"
	KeyCtrlAltHome      = "\x1b[1;7H"
	KeyShiftHome        = "\x1b[1;2H"
	KeyShiftAltHome     = "\x1b[1;4H"
	KeyCtrlShiftHome    = "\x1b[1;6H"
	KeyCtrlAltShiftHome = "\x1b[1;8H"

	KeyEnd             = "\x1b[4~"
	KeyAltEnd          = "\x1b[1;3F"
	KeyCtrlEnd         = "\x1b[1;5F"
	KeyCtrlAltEnd      = "\x1b[1;7F"
	KeyShiftEnd        = "\x1b[1;2F"
	KeyAltShiftEnd     = "\x1b[1;4F"
	KeyCtrlShiftEnd    = "\x1b[1;6F"
	KeyCtrlAltShiftEnd = "\x1b[1;8F"

	KeyF1  = "\x1bOP"
	KeyF2  = "\x1bOQ"
	KeyF3  = "\x1bOR"
	KeyF4  = "\x1bOS"
	KeyF5  = "\x1b[15~"
	KeyF6  = "\x1b[17~"
	KeyF7  = "\x1b[18~"
	KeyF8  = "\x1b[19~"
	KeyF9  = "\x1b[20~"
	KeyF10 = "\x1b[21~"
	KeyF11 = "\x1b[23~"
	KeyF12 = "\x1b[24~"
	KeyF13 = "\x1b[25~"
	KeyF14 = "\x1b[26~"
	KeyF15 = "\x1b[28~"
	KeyF16 = "\x1b[29~"
	KeyF17 = "\x1b[31~"
	KeyF18 = "\x1b[32~"
	KeyF19 = "\x1b[33~"
	KeyF20 = "\x1b[34~"

	KeyAltF1  = "\x1b[1;3P"
	KeyAltF2  = "\x1b[1;3Q"
	KeyAltF3  = "\x1b[1;3R"
	KeyAltF4  = "\x1b[1;3S"
	KeyAltF5  = "\x1b[15;3~"
	KeyAltF6  = "\x1b[17;3~"
	KeyAltF7  = "\x1b[18;3~"
	KeyAltF8  = "\x1b[19;3~"
	KeyAltF9  = "\x1b[20;3~"
	KeyAltF10 = "\x1b[21;3~"
	KeyAltF11 = "\x1b[23;3~"
	KeyAltF12 = "\x1b[24;3~"
	KeyAltF13 = "\x1b[25;3~"
	KeyAltF14 = "\x1b[26;3~"
	KeyAltF15 = "\x1b[28;3~"
	KeyAltF16 = "\x1b[29;3~"
	KeyAltF17 = "\x1b\x1b[31~"
	KeyAltF18 = "\x1b\x1b[32~"
	KeyAltF19 = "\x1b\x1b[33~"
	KeyAltF20 = "\x1b\x1b[34~"
)
View Source
const DefaultBG = uint16(vt10x.DefaultBG)
View Source
const DefaultFG = uint16(vt10x.DefaultFG)

Variables

This section is empty.

Functions

func Matcher

func Matcher(condition func(state TermState) bool, trimOutput bool, outCh chan TermState, duration *time.Duration) expect.ExpectOpt

Types

type Color

type Color uint16

func (Color) Int

func (c Color) Int() uint16

func (Color) String

func (c Color) String() string

type Console

type Console struct {
	TrimOutput bool
	// contains filtered or unexported fields
}

func (*Console) SendString

func (c *Console) SendString(input string)

func (*Console) WaitFor

func (c *Console) WaitFor(condition func(state TermState) bool) (TermState, error)

func (*Console) WaitForDuration

func (c *Console) WaitForDuration(condition func(state TermState) bool, duration time.Duration) (TermState, error)

func (*Console) WaitForTermination

func (c *Console) WaitForTermination() error

type Option

type Option func(t *Tester) error

func WithDefaultWaitTimeout

func WithDefaultWaitTimeout(timeout time.Duration) Option

func WithErrorHandler

func WithErrorHandler(onError func(err error) error) Option

func WithMinInputInterval

func WithMinInputInterval(minInterval time.Duration) Option

func WithTerminationTimeout

func WithTerminationTimeout(terminationTimeout time.Duration) Option

type Suite

type Suite struct {
	// contains filtered or unexported fields
}

func NewSuite

func NewSuite() *Suite

func (*Suite) NewTester

func (s *Suite) NewTester(binDir string, opts ...Option) (*Tester, error)

func (*Suite) TearDown

func (s *Suite) TearDown() error

type TermState

type TermState struct {
	// contains filtered or unexported fields
}

func (TermState) BackgroundColor

func (t TermState) BackgroundColor(row int, col int) Color

func (TermState) ForegroundColor

func (t TermState) ForegroundColor(row int, col int) Color

func (TermState) NthOutputLine

func (t TermState) NthOutputLine(index int) string

func (TermState) NumLines

func (t TermState) NumLines() int

func (TermState) Output

func (t TermState) Output() string

func (TermState) OutputLines

func (t TermState) OutputLines() []string

type Tester

type Tester struct {
	// contains filtered or unexported fields
}

func (*Tester) CreateConsole

func (t *Tester) CreateConsole(args ...string) (*Console, error)

Jump to

Keyboard shortcuts

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