Documentation
¶
Index ¶
- Constants
- Variables
- func Apply(fx *Fixture, ss ...Setting) error
- func MockedBackend(ui *view.UI) *mock.UI
- func SendSize(ui *view.UI, columns, rows uint) error
- func Settings(fx *Fixture) *settings
- type ContentMock
- func (cm *ContentMock) Done(err error)
- func (cm *ContentMock) DoneCount() int
- func (cm *ContentMock) Init(columns, rows int) lyt.Settings
- func (cm *ContentMock) Next() (rune, lyt.Settings)
- func (cm *ContentMock) NextCount() int
- func (cm *ContentMock) ReceivedErr() error
- func (cm *ContentMock) ReceivedSize() image.Point
- func (cm *ContentMock) With(mock any) *ContentMock
- type Fixture
- func (fx *Fixture) HasQuit() bool
- func (fx *Fixture) IsZero() bool
- func (fx *Fixture) SendMRune(mm backends.KeyModifier, r rune)
- func (fx *Fixture) SendMSpecial(mm backends.KeyModifier, s backends.SpecialKey)
- func (fx *Fixture) SendQuit()
- func (fx *Fixture) SendRune(r rune, rr ...rune)
- func (fx *Fixture) SendSize(columns, rows uint)
- func (fx *Fixture) SendSpecial(s backends.SpecialKey)
- type FrameEvent
- type KeyEvent
- type LayoutEvaluation
- func (le LayoutEvaluation) BG() lyt.Color
- func (le LayoutEvaluation) Equals(other LayoutEvaluation) bool
- func (le LayoutEvaluation) FG() lyt.Color
- func (le LayoutEvaluation) Goto() (column, row int, have bool)
- func (le LayoutEvaluation) HasCursor() bool
- func (le LayoutEvaluation) HasGoto(column, row int) bool
- func (le LayoutEvaluation) HasInvert() bool
- func (le LayoutEvaluation) HasLineInversion() bool
- type Next
- type PanicEvent
- type QuitEvent
- type Runes
- type RunesFunc
- type Setting
Constants ¶
const ( DefaultColumns = 80 DefaultRows = 24 )
Variables ¶
var ( // MkRuneKey constructs a Key instance which has given rune r and // given modifier mm set. In case the control modifier is set and r // corresponds to one of the first 31 special keys Special is set to // that key otherwise Special is set to IsRune. MkRuneKey = backends.MkRuneKey // MkSpecialKey constructs a Key instance which has given special // key s and given modifier mm set. In case s is one of the first // 31 special keys the corresponding rune and the control modifier // is set as well. MkSpecialKey = backends.MkSpecialKey )
var PanicEventPolling = mock.PanicEventPolling
PanicEventPolling triggers a panic at the next event poll. Don't forget to actually inject an event so the conditions for the panic are met.
Functions ¶
func SendSize ¶
SendSize injects an initial resize event to a view.UI instance with mocked backend. Its sole purpose is to trigger content initialization by providing size information to the UI. SendSize blocks until the resize event has been processed and the UI reports the new dimensions. An optional timeout can be provided to control how long to wait.
Types ¶
type ContentMock ¶
type ContentMock struct {
// contains filtered or unexported fields
}
ContentMock is an implementation of vw.Content interface which allows to set up a content provider for testing with less typing:
cm := new(vwtest.ContentMock).
With(vwtest.Runes{
vwtest.Next{ Rune: 'r', Lyt: *new(lyt.Settings).
Add(lyt.Background(lyt.Blue)).
Add(lyt.Foreground(lyt.Yellow)) }
})
which of course may be shortened additionally by short aliases of used vwtest-types.
func (*ContentMock) Done ¶
func (cm *ContentMock) Done(err error)
Err implements vw.Content.Err and stores a reported error
func (*ContentMock) DoneCount ¶
func (cm *ContentMock) DoneCount() int
func (*ContentMock) Init ¶
func (cm *ContentMock) Init(columns, rows int) lyt.Settings
Init implements vw.Content.Init and stores received columns and rows to make them queryable by contentMock.init.
func (*ContentMock) Next ¶
func (cm *ContentMock) Next() (rune, lyt.Settings)
Next implements vw.view.Content.Next reporting runes along with their settings from given content mock cm's _runes filed. (see type next)
func (*ContentMock) NextCount ¶
func (cm *ContentMock) NextCount() int
func (*ContentMock) ReceivedErr ¶
func (cm *ContentMock) ReceivedErr() error
ReceivedErr reports an that was received through ContentMock.Err from the layout engine.
func (*ContentMock) ReceivedSize ¶
func (cm *ContentMock) ReceivedSize() image.Point
ReceivedSize reports columns and rows counts received by an contentMock.Init call.
func (*ContentMock) With ¶
func (cm *ContentMock) With(mock any) *ContentMock
With allows to setup the mockup. With panics on an unsupported type. Supported types are at least
- vwtest.Runes
- vwtest.RunesFunc
type Fixture ¶
type Fixture struct {
// contains filtered or unexported fields
}
Fixture implements the backends.UIer for its production vw.UI instance. It also can simulate user input.
func Register ¶
Register at given settings contexts scc given view-fixture fx and given ui for given test t. Register panics if t is nil or if an fx or ui is already registered at scc. fx, ui and scc may be nil. Note returned ui has zero columns and rows whereas vwtest.View initializes an ui's size with vwview.DefaultColumns and vwview.DefaultRows.
func View ¶
func View(t *T, ss ...settingspkg.Setting) (*Fixture, *view.UI)
View provides a view fixture whose event loop is polling for event on this fixture and which is terminated automatically on t.Cleanup.
func (*Fixture) HasQuit ¶
HasQuit reports if the quit event has been reported to given fixture fx's default quit-dummy.
func (*Fixture) SendMRune ¶
func (fx *Fixture) SendMRune(mm backends.KeyModifier, r rune)
SendMRune injects a key event with given modifiers mm and rune r into associated ui's event loop.
func (*Fixture) SendMSpecial ¶
func (fx *Fixture) SendMSpecial( mm backends.KeyModifier, s backends.SpecialKey, )
SendMSpecial injects a key event with given modifier mask mm and given special key s into associated ui's event loop.
func (*Fixture) SendQuit ¶
func (fx *Fixture) SendQuit()
SendQuit sends a backend.QuitEvent to associated vw.UI's event loop.
func (*Fixture) SendRune ¶
SendRune injects a key event with given rune r into associated ui's event loop.
func (*Fixture) SendSize ¶
SendSize issues a backend.ResizeEvent to associated vw.UI's event loop. Note SendSize does not return before given columns and rows count have been applied.
func (*Fixture) SendSpecial ¶
func (fx *Fixture) SendSpecial(s backends.SpecialKey)
SendSpecial injects a key event with given special key s into associated ui's event loop.
type FrameEvent ¶ added in v0.9.3
type FrameEvent = backends.FrameEvent
type LayoutEvaluation ¶
type LayoutEvaluation struct {
// contains filtered or unexported fields
}
LayoutEvaluation provides a systematic api to evaluate the internal state internal/lyt.Settings of lyt.Settings. Use vwtest.Eval to crate an evaluation of the internal settings associated to a given sequence of lyt.Settings.
func Eval ¶
func Eval(ss lyt.Settings) LayoutEvaluation
Eval maps given sequence of layout settings (function calls) to an LayoutEvaluation that allows to evaluate the corresponding internal/lyt.Settings.
func (LayoutEvaluation) BG ¶
func (le LayoutEvaluation) BG() lyt.Color
func (LayoutEvaluation) Equals ¶
func (le LayoutEvaluation) Equals(other LayoutEvaluation) bool
func (LayoutEvaluation) FG ¶
func (le LayoutEvaluation) FG() lyt.Color
func (LayoutEvaluation) Goto ¶
func (le LayoutEvaluation) Goto() (column, row int, have bool)
func (LayoutEvaluation) HasCursor ¶
func (le LayoutEvaluation) HasCursor() bool
HasCursor returns true iff given evaluation of layout settings le has the cursor flag set.
func (LayoutEvaluation) HasGoto ¶
func (le LayoutEvaluation) HasGoto(column, row int) bool
HasGoto reports true if given evaluation has the goto consumer flag along with given column and row set.
func (LayoutEvaluation) HasInvert ¶
func (le LayoutEvaluation) HasInvert() bool
HasInvert return true iff given evaluation of layout settings has the invert flag set.
func (LayoutEvaluation) HasLineInversion ¶
func (le LayoutEvaluation) HasLineInversion() bool
HasLineInversion returns true iff given evaluation of layout settings le has the invert line flag set.
type Next ¶
Next represents a "next-rune" in a ContentMock having been set using vwtest.ContentMock.With(Runes{Next1 ... NextN})
type PanicEvent ¶ added in v0.9.3
type PanicEvent = backends.PanicEvent