renderhost

package
v1.9.8 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0 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 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

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 {
	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
	// 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

func (h *Host) ActivateSystemCursor(device int, kind string)

ActivateSystemCursor keeps the activation.

func (*Host) ActivationToken

func (h *Host) ActivationToken(_ ui.ViewID, done func(token string))

ActivationToken answers with the token, posted.

func (*Host) AppID

func (h *Host) AppID() string

AppID is the application ID that the test set.

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

func (h *Host) DestroyWindow(view ui.ViewID)

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

func (h *Host) GetClipboardText(ctx context.Context, done func(string, bool, error))

GetClipboardText posts the text that was kept.

func (*Host) KeepScreenOn

func (h *Host) KeepScreenOn(view ui.ViewID, on bool) error

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) PerformWindowAction

func (h *Host) PerformWindowAction(view ui.ViewID, action ui.WindowAction)

PerformWindowAction keeps the action.

func (*Host) PortalParentHandle

func (h *Host) PortalParentHandle(view ui.ViewID, done func(handle string))

PortalParentHandle answers with the handle of the view, posted.

func (*Host) Post

func (h *Host) Post(fn func())

Post keeps the function.

func (*Host) RenderView

func (h *Host) RenderView(view ui.ViewID, scene *ui.Scene) error

RenderView keeps the scene.

func (*Host) RequestAppExit

func (h *Host) RequestAppExit()

RequestAppExit counts the requests.

func (*Host) RequestViewFocus

func (h *Host) RequestViewFocus(view ui.ViewID, state ui.ViewFocusState, direction ui.ViewFocusDirection)

RequestViewFocus keeps the request.

func (*Host) RunPosted

func (h *Host) RunPosted() int

RunPosted runs what was posted, including what that posts.

func (*Host) Scenes

func (h *Host) Scenes() []*ui.Scene

Scenes are the scenes that the views rendered so far.

func (*Host) ScenesOf

func (h *Host) ScenesOf(view ui.ViewID) []*ui.Scene

ScenesOf are the scenes that the view rendered so far.

func (*Host) ScheduleFrame

func (h *Host) ScheduleFrame()

ScheduleFrame counts the frames asked for.

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

func (h *Host) SetClipboardText(_ context.Context, text string, done func(error))

SetClipboardText keeps the text. done is posted, like the engine's results.

func (*Host) SetSemanticsTreeEnabled

func (h *Host) SetSemanticsTreeEnabled(enabled bool)

SetSemanticsTreeEnabled keeps the flag.

func (*Host) SetTextInput

func (h *Host) SetTextInput(state ui.TextInputState)

SetTextInput keeps the state.

func (*Host) SetWindowConstraints

func (h *Host) SetWindowConstraints(view ui.ViewID, min, max ui.Size)

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

func (h *Host) SetWindowHidden(view ui.ViewID, hidden bool)

SetWindowHidden keeps whether the window of the view is hidden, for the windows the framework made and for the implicit one.

func (*Host) SetWindowIcon

func (h *Host) SetWindowIcon(view ui.ViewID, icon ui.WindowIcon) error

SetWindowIcon keeps the icon of the view.

func (*Host) SetWindowSize

func (h *Host) SetWindowSize(view ui.ViewID, size ui.Size)

SetWindowSize keeps the size.

func (*Host) SetWindowTitle

func (h *Host) SetWindowTitle(view ui.ViewID, title string)

SetWindowTitle keeps the title.

func (*Host) StartDrag

func (h *Host) StartDrag(_ ui.ViewID, request ui.DragRequest) error

StartDrag records the drag; it fails with DragErr when that is set.

func (*Host) Unlock

func (h *Host) Unlock()

Unlock ends what Lock began.

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

func New(opts ...Opts) *Stack

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) LastScene

func (s *Stack) LastScene() *ui.Scene

LastScene is the scene of the last composited frame, or nil.

func (*Stack) Pump

func (s *Stack) Pump()

Pump runs one frame: layout, compositing bits, paint and composite.

func (*Stack) Scenes

func (s *Stack) Scenes() []*ui.Scene

Scenes are the scenes that the view rendered so far.

func (*Stack) SetRoot

func (s *Stack) SetRoot(box rendering.Box)

SetRoot makes the box the child of the render view.

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.

Jump to

Keyboard shortcuts

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