Documentation
¶
Overview ¶
Package engine runs flows on a device, around device events.
An element lookup reads the screen once; if the element is not there it sleeps until the agent pushes "the UI changed and settled" (or keeps changing for longer than a frame budget), then reads again. A screen read is reused for as long as the device reports no change since.
Index ¶
- func Describe(c *flow.Command) string
- type CSSQuerier
- type DarkModer
- type Event
- type FlowError
- type FlowResult
- type NotFound
- type Options
- type Reporter
- type ReporterFunc
- type Runner
- func (r *Runner) Begin(f *flow.Flow, extraEnv []flow.KV) error
- func (r *Runner) End()
- func (r *Runner) LastScreen() *ui.Screen
- func (r *Runner) Locate(ctx context.Context, s *ui.Screen, selector *flow.Selector) (*ui.Node, []*ui.Node, error)
- func (r *Runner) RunCommands(ctx context.Context, cmds []*flow.Command, appID string, ...) error
- func (r *Runner) RunFlow(ctx context.Context, f *flow.Flow) (res FlowResult)
- func (r *Runner) RunList(ctx context.Context, cmds []*flow.Command, f *flow.Flow) error
- func (r *Runner) SetAppID(id string)
- func (r *Runner) SetEnv(kvs []flow.KV) error
- func (r *Runner) Videos() []Video
- type Signals
- type Status
- type StepResult
- type Trace
- type Video
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CSSQuerier ¶
CSSQuerier is a driver that can evaluate CSS selectors (web).
type DarkModer ¶
type DarkModer interface {
SetDarkMode(ctx context.Context, on bool) error
DarkMode(ctx context.Context) (bool, error)
}
DarkModer is implemented by drivers that can read and set the system appearance.
type Event ¶
type Event struct {
Device string // role or device name (multi-device runs)
Cmd *flow.Command
Desc string
Depth int
Start bool
Status Status
Err error
Elapsed time.Duration
Log string // console.log or diagnostic line
Hint string // a step that did nothing as written (iOS back): once per flow (Runner.hint)
}
Event tells a Reporter about progress.
type FlowError ¶
type FlowError struct {
Msg string
// contains filtered or unexported fields
}
FlowError is a test failure an optional command downgrades to a warning (element not found, assertion false, ...).
type FlowResult ¶
type FlowResult struct {
Name string
File string
Status Status
Err error
Duration time.Duration
Steps []StepResult
Videos []Video // the screen recordings of the run (Options.Record)
}
FlowResult is the outcome of one flow.
type NotFound ¶
type NotFound struct {
FlowError
Screen *ui.Screen
Query string
// contains filtered or unexported fields
}
NotFound is an element lookup that timed out; it carries what was on screen.
type Options ¶
type Options struct {
Env []flow.KV // -e values and injected TB_ variables, in order
LookupTimeout time.Duration // default 17 s
OptionalTimeout time.Duration // default 7 s
ArtifactsDir string // where takeScreenshot/startRecording write ("" = cwd)
Reporter Reporter
Role string // device role in a multi-device flow
Signals *Signals
JS *js.Engine // shared engine (multi-device); nil = a new one per flow
Trace *Trace // the run's step-by-step log (trace.go); nil = none
// Timeline records the run for its HTML timeline (timeline.go): each command, the
// screen after it and its gestures. nil = none (no screenshots are taken).
Timeline *timeline.Recorder
// Record records the screen from the flow's start to its end into ArtifactsDir
// (recording.mp4; recording.go).
Record bool
// StallFloor is the shortest device stall a failed step names (stall.go); 0 = 10 s.
StallFloor time.Duration
// AwayGrace is how long a lookup waits on SpringBoard alone in front of the flow's app
// before it fails (away.go); 0 = 5 s, 10 s in CI.
AwayGrace time.Duration
}
Options configure a Runner.
type Reporter ¶
type Reporter interface{ Event(Event) }
Reporter receives events. Implementations must be safe for concurrent use.
type ReporterFunc ¶
type ReporterFunc func(Event)
func (ReporterFunc) Event ¶
func (f ReporterFunc) Event(e Event)
type Runner ¶
Runner runs commands on one device.
func (*Runner) Begin ¶
Begin prepares a flow run without running commands (multi-device flows drive each device's command lists themselves). extraEnv (a role's env) comes after the CLI env and the flow's, so it wins.
func (*Runner) End ¶
func (r *Runner) End()
End stops recordings left running (the flow's, then the run's: Videos) and drops the flow's network mocks and dialog answer.
func (*Runner) LastScreen ¶
LastScreen is the most recent read (for failure reports).
func (*Runner) Locate ¶ added in v0.5.0
func (r *Runner) Locate(ctx context.Context, s *ui.Screen, selector *flow.Selector) (*ui.Node, []*ui.Node, error)
Locate reports the runner's pick and candidates on one snapshot without waiting for UI changes, handling dialogs, or performing a device action.
func (*Runner) RunCommands ¶
func (r *Runner) RunCommands(ctx context.Context, cmds []*flow.Command, appID string, onStep func(StepResult)) error
RunCommands runs loose commands (an agent's `tb do`) with the flow context of appID.
func (*Runner) RunFlow ¶
RunFlow runs a flow file from the start: env, onFlowStart, commands, onFlowComplete.
func (*Runner) RunList ¶
RunList runs commands in the current flow context, stopping at the first failure.
func (*Runner) SetAppID ¶
SetAppID sets the default appId (a device role's appId in a multi-device flow).
type Signals ¶
type Signals struct {
// contains filtered or unexported fields
}
Signals lets devices in a multi-device flow wait for each other: one device runs `signal: sent`, another `waitForSignal: sent`. Waiting is a channel close, not a poll.
func NewSignals ¶
func NewSignals() *Signals
type StepResult ¶
type StepResult struct {
Desc string
Status Status
Err string
Duration time.Duration
Hints []string // what the step (or a step inside it) did not do as written (Runner.hint)
}
StepResult is one top-level command's outcome.
type Trace ¶
type Trace struct {
// contains filtered or unexported fields
}
Trace is safe for concurrent use: a multi-device flow's devices share one, each line tagged with its device's role.
Source Files
¶
- animation.go
- assert_dialog.go
- away.go
- composite.go
- cover.go
- describe.go
- dialogs.go
- exec.go
- find.go
- history.go
- input.go
- input_target.go
- js_dialogs.go
- location.go
- network.go
- recording.go
- runner.go
- screenshots.go
- scroll.go
- scroll_geometry.go
- signals.go
- stall.go
- swipe.go
- swipe_slider.go
- tap.go
- tap_outcome.go
- tap_recovery.go
- tap_switch.go
- tap_target.go
- timeline.go
- trace.go