Documentation
¶
Overview ¶
Package renderhost builds a RendererBinding on a fake engine with one view, lays out and paints a render tree through the pipeline, and keeps the scenes that the view rendered. The rendering tests (internal/renderingtest) and the proof scenes that run a render tree (internal/proof) share it. It has no renderer: the caller turns a scene into pixels.
Flutter: no counterpart (test/rendering/rendering_tester.dart)
Index ¶
- type CursorActivation
- type FakeWindow
- type Host
- func (h *Host) ActivateSystemCursor(device int, kind string)
- func (h *Host) ActivationToken(_ ui.ViewID, done func(token string))
- func (h *Host) AddReleaseHook(fn func())
- func (h *Host) AppID() string
- func (h *Host) Audio() platform.Audio
- func (h *Host) CreateWindow(spec ui.WindowSpec) (ui.ViewID, ui.ViewConfiguration, error)
- func (h *Host) DestroyWindow(view ui.ViewID)
- func (h *Host) GetClipboard(ctx context.Context, kind ui.ClipboardKind, format string, ...)
- func (h *Host) GetClipboardText(ctx context.Context, done func(string, bool, error))
- func (h *Host) KeepScreenOn(view ui.ViewID, on bool) error
- func (h *Host) Lock()
- func (h *Host) LockPointer(view ui.ViewID) error
- func (h *Host) PadManager() *pads.Manager
- func (h *Host) PerformWindowAction(view ui.ViewID, action ui.WindowAction)
- func (h *Host) PortalParentHandle(view ui.ViewID, done func(handle string))
- func (h *Host) Post(fn func())
- func (h *Host) RenderView(view ui.ViewID, scene *ui.Scene) error
- func (h *Host) RequestAppExit()
- func (h *Host) RequestViewFocus(view ui.ViewID, state ui.ViewFocusState, direction ui.ViewFocusDirection)
- func (h *Host) RunPosted() int
- func (h *Host) RunReleaseHooks()
- func (h *Host) Scenes() []*ui.Scene
- func (h *Host) ScenesOf(view ui.ViewID) []*ui.Scene
- func (h *Host) ScheduleFrame()
- func (h *Host) Sensors() platform.Sensors
- func (h *Host) SetClipboard(_ context.Context, kind ui.ClipboardKind, content ui.ClipboardContent, ...)
- func (h *Host) SetClipboardText(_ context.Context, text string, done func(error))
- func (h *Host) SetSemanticsTreeEnabled(enabled bool)
- func (h *Host) SetTextInput(state ui.TextInputState)
- func (h *Host) SetWindowConstraints(view ui.ViewID, min, max ui.Size)
- func (h *Host) SetWindowContentType(view ui.ViewID, contentType ui.ContentType)
- func (h *Host) SetWindowHidden(view ui.ViewID, hidden bool)
- func (h *Host) SetWindowIcon(view ui.ViewID, icon ui.WindowIcon) error
- func (h *Host) SetWindowSize(view ui.ViewID, size ui.Size)
- func (h *Host) SetWindowTitle(view ui.ViewID, title string)
- func (h *Host) StartDrag(_ ui.ViewID, request ui.DragRequest) error
- func (h *Host) Unlock()
- func (h *Host) UnlockPointer(view ui.ViewID)
- func (h *Host) UpdateSemantics(_ ui.ViewID, update *ui.SemanticsUpdate)
- type Opts
- type Stack
- type ViewAction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CursorActivation ¶
type CursorActivation struct {
// Device is the pointer device the cursor is for.
Device int
// Kind is the kind of the system cursor, such as "click".
Kind string
}
CursorActivation is one call of ActivateSystemCursor.
type FakeWindow ¶
type FakeWindow struct {
// View is the view of the window.
View ui.ViewID
// Spec is what the framework asked for.
Spec ui.WindowSpec
// Title is the last title set; the spec's until then.
Title string
// Size is the last size asked for; the spec's until then.
Size ui.Size
// Min and Max are the last limits set; the spec's until then.
Min, Max ui.Size
// Destroyed is whether the framework destroyed the window.
Destroyed bool
// Hidden is whether the framework hid the window.
Hidden bool
}
FakeWindow is a window the framework asked the fake engine for.
type Host ¶
type Host struct {
// Pads is the manager of the gamepads of the fake app, or nil: the host implements pads.Host with it.
Pads *pads.Manager
// AudioService is the audio service of the fake app, or nil: the host implements platform.AudioHost with it.
AudioService platform.Audio
// SensorService is the motion sensors service of the fake app, or nil: the host implements platform.SensorsHost with it.
SensorService platform.Sensors
Scheduled int
// ExitRequests counts the calls of RequestAppExit.
ExitRequests int
// DiscardScenes makes RenderView drop the scenes instead of keeping them, for
// benchmarks that run many frames.
//
// Flutter: no counterpart
DiscardScenes bool
// RenderErr is returned by RenderView, to test a failing renderer.
RenderErr error
// SemanticsUpdates are the semantics updates that the view sent.
SemanticsUpdates []*ui.SemanticsUpdate
// SemanticsTreeEnabled is what the framework last said about producing a
// semantics tree.
SemanticsTreeEnabled bool
// ActivatedCursors are the system cursors that the framework activated, in
// order.
ActivatedCursors []CursorActivation
// Clipboard is the in-memory clipboard; HasClipboard says whether it holds
// text. A test can set them to play another application.
Clipboard string
HasClipboard bool
// ClipboardPNG, ClipboardURIs and ClipboardHTML are the other formats of the
// in-memory system clipboard; Primary is the in-memory primary selection.
ClipboardPNG []byte
ClipboardURIs []string
ClipboardHTML string
Primary ui.ClipboardContent
// WindowActions are the actions that a title bar asked of the window, in order.
WindowActions []ui.WindowAction
// ViewActions are the same actions with the view they were for.
ViewActions []ViewAction
// TextInputStates are the states of the text field that the framework gave
// to the input method, in order.
TextInputStates []ui.TextInputState
// Windows are the windows the framework asked for, in order, destroyed ones
// included.
Windows []*FakeWindow
// CreateErr is returned by CreateWindow, to test a platform that cannot make
// windows.
CreateErr error
// Drags are the drag and drop operations the framework started, in order.
Drags []ui.DragRequest
// DragErr is returned by StartDrag, to test a platform that cannot drag.
DragErr error
// Icons, ContentTypes and ScreenOn are what the framework set for each view: the
// window icon, the content type hint, and whether the screen is kept on.
Icons map[ui.ViewID]ui.WindowIcon
ContentTypes map[ui.ViewID]ui.ContentType
ScreenOn map[ui.ViewID]bool
// HiddenViews says which views the framework hid, the implicit one included;
// a view that was shown again is false.
HiddenViews map[ui.ViewID]bool
// ViewTitles are the last titles the framework set, for every view: the implicit
// one too, which Windows does not list.
ViewTitles map[ui.ViewID]string
// OnHiddenChanged, when set, is called after the framework hid or showed a
// window, without the lock: the tester gives the app its lifecycle from it.
OnHiddenChanged func()
// ParentHandle is the handle of a view for the portals; the default is
// "test:" and the view ID. ActivationTokenValue is the activation token; the
// default is "test-token". Both are called on the thread that runs the posted
// functions.
ParentHandle func(view ui.ViewID) string
ActivationTokenValue string
// AppIDValue is the application ID of the app; the default is empty.
AppIDValue string
// KeepScreenOnErr is returned by KeepScreenOn, to test a platform that cannot
// keep the screen on.
KeepScreenOnErr error
// FocusEvents are the focus changes the framework asked the platform for, in
// order.
FocusEvents []ui.ViewFocusEvent
// LockPointerErr is returned by LockPointer, to test a platform that cannot lock the
// pointer or refuses.
LockPointerErr error
// LockedViews says which views the framework locked the pointer to; a view that was
// unlocked is false.
LockedViews map[ui.ViewID]bool
// PointerLocks counts the calls of LockPointer that succeeded, and PointerUnlocks the
// calls of UnlockPointer.
PointerLocks, PointerUnlocks int
// contains filtered or unexported fields
}
Host is the fake engine: it remembers the scenes a view rendered and keeps the functions posted to the "UI thread" until the caller runs them.
func (*Host) ActivateSystemCursor ¶
ActivateSystemCursor keeps the activation.
func (*Host) ActivationToken ¶
ActivationToken answers with the token, posted.
func (*Host) AddReleaseHook ¶
func (h *Host) AddReleaseHook(fn func())
AddReleaseHook implements platform.AudioHost and platform.SensorsHost: fn runs when RunReleaseHooks does, as the engine's runs when the app ends.
func (*Host) Audio ¶
Audio implements platform.AudioHost: the audio service of the fake app, nil when the test has none.
func (*Host) CreateWindow ¶
func (h *Host) CreateWindow(spec ui.WindowSpec) (ui.ViewID, ui.ViewConfiguration, error)
CreateWindow records the window and gives it the next view ID, after the implicit one. The view starts at the size asked for, or 800x600.
func (*Host) DestroyWindow ¶
DestroyWindow marks the window destroyed.
func (*Host) GetClipboard ¶
func (h *Host) GetClipboard(ctx context.Context, kind ui.ClipboardKind, format string, done func(ui.ClipboardContent, error))
GetClipboard posts the content that was kept, in the format.
func (*Host) GetClipboardText ¶
GetClipboardText posts the text that was kept.
func (*Host) KeepScreenOn ¶
KeepScreenOn keeps the request of the view; it fails with KeepScreenOnErr when that is set.
func (*Host) Lock ¶
func (h *Host) Lock()
Lock and Unlock guard the fields of the host that tests set.
func (*Host) LockPointer ¶
LockPointer keeps the lock of the view; it fails with LockPointerErr when that is set (ui.PointerLockHost).
func (*Host) PadManager ¶
PadManager implements pads.Host: the manager of the gamepads of the fake app, nil when the test has none.
func (*Host) PerformWindowAction ¶
func (h *Host) PerformWindowAction(view ui.ViewID, action ui.WindowAction)
PerformWindowAction keeps the action.
func (*Host) PortalParentHandle ¶
PortalParentHandle answers with the handle of the view, posted.
func (*Host) RenderView ¶
RenderView keeps the scene.
func (*Host) RequestViewFocus ¶
func (h *Host) RequestViewFocus(view ui.ViewID, state ui.ViewFocusState, direction ui.ViewFocusDirection)
RequestViewFocus keeps the request.
func (*Host) RunReleaseHooks ¶
func (h *Host) RunReleaseHooks()
RunReleaseHooks runs the functions of AddReleaseHook once, the way the engine does when the app ends.
func (*Host) ScheduleFrame ¶
func (h *Host) ScheduleFrame()
ScheduleFrame counts the frames asked for.
func (*Host) Sensors ¶
Sensors implements platform.SensorsHost: the motion sensors service of the fake app, nil when the test has none.
func (*Host) SetClipboard ¶
func (h *Host) SetClipboard(_ context.Context, kind ui.ClipboardKind, content ui.ClipboardContent, done func(error))
SetClipboard keeps the content on the selection of the kind. done is posted.
func (*Host) SetClipboardText ¶
SetClipboardText keeps the text. done is posted, like the engine's results.
func (*Host) SetSemanticsTreeEnabled ¶
SetSemanticsTreeEnabled keeps the flag.
func (*Host) SetTextInput ¶
func (h *Host) SetTextInput(state ui.TextInputState)
SetTextInput keeps the state.
func (*Host) SetWindowConstraints ¶
SetWindowConstraints keeps the limits.
func (*Host) SetWindowContentType ¶
func (h *Host) SetWindowContentType(view ui.ViewID, contentType ui.ContentType)
SetWindowContentType keeps the content type of the view.
func (*Host) SetWindowHidden ¶
SetWindowHidden keeps whether the window of the view is hidden, for the windows the framework made and for the implicit one.
func (*Host) SetWindowIcon ¶
SetWindowIcon keeps the icon of the view.
func (*Host) SetWindowSize ¶
SetWindowSize keeps the size.
func (*Host) SetWindowTitle ¶
SetWindowTitle keeps the title.
func (*Host) UnlockPointer ¶
UnlockPointer ends the lock of the view (ui.PointerLockHost).
func (*Host) UpdateSemantics ¶
func (h *Host) UpdateSemantics(_ ui.ViewID, update *ui.SemanticsUpdate)
UpdateSemantics keeps the update.
type Opts ¶
type Opts struct {
// Size is the size of the view in physical pixels; the default is 800x600.
Size ui.Size
// DevicePixelRatio defaults to 1.
DevicePixelRatio float64
// Debug are the debug flags; the default is a fresh set.
Debug *rendering.DebugOptions
// TextEngine lays out the text; the default is none.
TextEngine ui.ParagraphFactory
// ReportError gets the errors that the binding reports.
ReportError func(error)
}
Opts are the optional parameters of New.
type Stack ¶
type Stack struct {
Host *Host
Dispatcher *ui.PlatformDispatcher
Scheduler *scheduler.SchedulerBinding
Gestures *gestures.GestureBinding
Binding *rendering.RendererBinding
View *ui.View
RenderView *rendering.RenderView
Owner *rendering.PipelineOwner
// contains filtered or unexported fields
}
Stack is a rendering binding on a fake engine, with one view.
func New ¶
New creates the stack with the render view attached to the binding's root pipeline owner, ready for SetRoot.
func (*Stack) FlushPipeline ¶
func (s *Stack) FlushPipeline()
FlushPipeline runs layout, compositing bits and paint on the owner only, not the composite step.
func (*Stack) Pump ¶
func (s *Stack) Pump()
Pump runs one frame: layout, compositing bits, paint and composite.
type ViewAction ¶
type ViewAction struct {
// View is the view of the window.
View ui.ViewID
// Action is what was asked.
Action ui.WindowAction
}
ViewAction is an action of a title bar and the view it was for.