Documentation
¶
Overview ¶
Package fake is a scripted platform for tests: it replays queued events and records what the engine asks of it.
Flutter: no counterpart (the role of the test binding's fake platform).
Index ¶
- Constants
- type Accessibility
- func (a *Accessibility) Close()
- func (a *Accessibility) Closed() bool
- func (a *Accessibility) Perform(event ui.SemanticsActionEvent)
- func (a *Accessibility) RemoveView(view ui.ViewID)
- func (a *Accessibility) Removed() []ui.ViewID
- func (a *Accessibility) ScreenReader(on bool)
- func (a *Accessibility) SetWindow(view ui.ViewID, title string, active bool)
- func (a *Accessibility) Start(_ context.Context, host platform.AccessibilityHost)
- func (a *Accessibility) Started() bool
- func (a *Accessibility) UpdateSemantics(view ui.ViewID, update *ui.SemanticsUpdate)
- func (a *Accessibility) Updates() []ViewUpdate
- func (a *Accessibility) Windows() []WindowRecord
- type CloseRequestEvent
- type ContentLostEvent
- type DisplaysEvent
- type DragEndEvent
- type DropEvent
- type Entry
- type EntryKind
- type Event
- type FrameEvent
- type KeyEvent
- type LifecycleEvent
- type MetricsEvent
- type Platform
- func (p *Platform) Accessibility() *Accessibility
- func (p *Platform) Clipboard() platform.Clipboard
- func (p *Platform) ClipboardContent(kind ui.ClipboardKind) ui.ClipboardContent
- func (p *Platform) ClipboardText() (string, bool)
- func (p *Platform) Displays() []platform.Display
- func (p *Platform) DropAnswers() []ui.DropActions
- func (p *Platform) Inject(event Event)
- func (p *Platform) Log() []Entry
- func (p *Platform) NewWindow(cfg platform.WindowConfig) (platform.Window, error)
- func (p *Platform) Post(fn func())
- func (p *Platform) RequestActivationToken(view ui.ViewID, done func(token string))
- func (p *Platform) Run(ctx context.Context, h platform.Handler) error
- func (p *Platform) Services() platform.Services
- func (p *Platform) SetClipboardContent(kind ui.ClipboardKind, content ui.ClipboardContent)
- func (p *Platform) SetClipboardText(text string)
- func (p *Platform) SetDisplays(displays []platform.Display)
- func (p *Platform) SetSettings(settings platform.Settings)
- func (p *Platform) Settings() platform.Settings
- func (p *Platform) Windows() []*Window
- type PointerEvent
- type SettingsEvent
- type SizeConstraints
- type TextInputEvent
- type ViewFocusEvent
- type ViewUpdate
- type Window
- func (w *Window) Close()
- func (w *Window) Closed() bool
- func (w *Window) Config() platform.WindowConfig
- func (w *Window) ContentType() ui.ContentType
- func (w *Window) Cursor() platform.MouseCursor
- func (w *Window) Hidden() bool
- func (w *Window) ID() ui.ViewID
- func (w *Window) Icon() ui.WindowIcon
- func (w *Window) KeepScreenOn(on bool) error
- func (w *Window) NativeSurface() gpu.SurfaceHandle
- func (w *Window) PerformWindowAction(action ui.WindowAction)
- func (w *Window) PortalHandle(done func(handle string))
- func (w *Window) RequestFrame()
- func (w *Window) ScreenKeptOn() bool
- func (w *Window) SetContentType(contentType ui.ContentType)
- func (w *Window) SetCursor(cursor platform.MouseCursor)
- func (w *Window) SetHidden(hidden bool) bool
- func (w *Window) SetIcon(icon ui.WindowIcon) error
- func (w *Window) SetSize(size ui.Size)
- func (w *Window) SetSizeConstraints(min, max ui.Size)
- func (w *Window) SetState(state platform.WindowState)
- func (w *Window) SetTextInput(state ui.TextInputState)
- func (w *Window) SetTitle(title string)
- func (w *Window) Size() ui.Size
- func (w *Window) SizeConstraints() SizeConstraints
- func (w *Window) StartDrag(data ui.DragRequest) error
- func (w *Window) State() platform.WindowState
- func (w *Window) TextInput() ui.TextInputState
- func (w *Window) Title() string
- type WindowRecord
Constants ¶
const FakeActivationToken = "fake-activation-token"
FakeActivationToken is the token that RequestActivationToken gives.
Flutter: no counterpart
const FakePortalHandlePrefix = "fake:"
FakePortalHandlePrefix is what the handle of a fake window starts with; the view ID follows.
Flutter: no counterpart
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Accessibility ¶
type Accessibility struct {
// contains filtered or unexported fields
}
Accessibility is the accessibility bridge of the fake platform: it keeps what the engine gave it, and the test plays the screen reader with ScreenReader and Perform.
Flutter: no counterpart
func (*Accessibility) Close ¶
func (a *Accessibility) Close()
Close records that the engine closed the bridge.
func (*Accessibility) Closed ¶
func (a *Accessibility) Closed() bool
Closed says whether the engine closed the bridge.
func (*Accessibility) Perform ¶
func (a *Accessibility) Perform(event ui.SemanticsActionEvent)
Perform plays an assistive technology that asks for an action on a node.
func (*Accessibility) RemoveView ¶
func (a *Accessibility) RemoveView(view ui.ViewID)
RemoveView records the view that was removed.
func (*Accessibility) Removed ¶
func (a *Accessibility) Removed() []ui.ViewID
Removed are the views that the bridge was told to forget.
func (*Accessibility) ScreenReader ¶
func (a *Accessibility) ScreenReader(on bool)
ScreenReader plays a screen reader that starts or stops: the host is told on the UI thread. It does nothing before Start.
func (*Accessibility) SetWindow ¶
func (a *Accessibility) SetWindow(view ui.ViewID, title string, active bool)
SetWindow records the window.
func (*Accessibility) Start ¶
func (a *Accessibility) Start(_ context.Context, host platform.AccessibilityHost)
Start keeps the host.
func (*Accessibility) Started ¶
func (a *Accessibility) Started() bool
Started says whether the engine started the bridge.
func (*Accessibility) UpdateSemantics ¶
func (a *Accessibility) UpdateSemantics(view ui.ViewID, update *ui.SemanticsUpdate)
UpdateSemantics records the update.
func (*Accessibility) Updates ¶
func (a *Accessibility) Updates() []ViewUpdate
Updates are the semantics updates the bridge got, oldest first.
func (*Accessibility) Windows ¶
func (a *Accessibility) Windows() []WindowRecord
Windows are the windows that the bridge was told about, oldest first.
type CloseRequestEvent ¶
CloseRequestEvent delivers a close request to Handler.OnCloseRequest. When the handler returns true, the fake closes the view's window.
Flutter: no counterpart
type ContentLostEvent ¶
ContentLostEvent delivers a window whose content was lost to Handler.OnContentLost.
Flutter: no counterpart
type DisplaysEvent ¶
DisplaysEvent changes the displays that Platform.Displays reports and then tells Handler.OnDisplaysChanged.
Flutter: no counterpart
type DragEndEvent ¶
type DragEndEvent struct {
// Result is how the drag ended.
Result ui.DragResult
}
DragEndEvent delivers the end of a drag the app started to Handler.OnDragEnd.
Flutter: no counterpart
type DropEvent ¶
type DropEvent struct {
// Event is the event; its ViewID says which view it is over.
Event ui.DropEvent
}
DropEvent delivers a drag-and-drop event to Handler.OnDrop. The answer of the handler is kept in the platform: see Platform.DropAnswers.
Flutter: no counterpart
type Entry ¶
type Entry struct {
// Kind says what happened.
Kind EntryKind
// View is the view the entry is about, or ui.ImplicitViewID when it is
// about no particular view.
View ui.ViewID
// Value carries the details; its type depends on Kind.
Value any
}
Entry is one line of the log of a fake Platform.
Flutter: no counterpart
type EntryKind ¶
type EntryKind string
EntryKind names what an Entry in the log records.
Flutter: no counterpart
const ( // EntryNewWindow records NewWindow; Value is the platform.WindowConfig. // // Flutter: no counterpart EntryNewWindow EntryKind = "NewWindow" // EntryEvent records an injected event delivered to the handler; Value is // the Event. // // Flutter: no counterpart EntryEvent EntryKind = "Event" // EntryCloseDecision records the handler's answer to a close request; // Value is a bool, true when the window was closed. // // Flutter: no counterpart EntryCloseDecision EntryKind = "CloseDecision" // EntrySetTitle records Window.SetTitle; Value is the string. // // Flutter: no counterpart EntrySetTitle EntryKind = "SetTitle" // EntrySetSize records Window.SetSize; Value is the ui.Size. // // Flutter: no counterpart EntrySetSize EntryKind = "SetSize" // EntrySetState records Window.SetState; Value is the platform.WindowState. // // Flutter: no counterpart EntrySetState EntryKind = "SetState" // EntrySetHidden records Window.SetHidden; Value is the bool. // // Flutter: no counterpart EntrySetHidden EntryKind = "SetHidden" // EntrySetCursor records Window.SetCursor; Value is the // platform.MouseCursor. // // Flutter: no counterpart EntrySetCursor EntryKind = "SetCursor" // EntrySetTextInput records Window.SetTextInput; Value is the // ui.TextInputState. // // Flutter: no counterpart EntrySetTextInput EntryKind = "SetTextInput" // EntryRequestFrame records Window.RequestFrame; Value is nil. // // Flutter: no counterpart EntryRequestFrame EntryKind = "RequestFrame" // EntryStartDrag records Window.StartDrag; Value is the ui.DragRequest. // // Flutter: no counterpart EntryStartDrag EntryKind = "StartDrag" // EntrySetSizeConstraints records Window.SetSizeConstraints; Value is a // SizeConstraints. // // Flutter: no counterpart EntrySetSizeConstraints EntryKind = "SetSizeConstraints" // EntryWindowAction records Window.PerformWindowAction; Value is the // ui.WindowAction. // // Flutter: no counterpart EntryWindowAction EntryKind = "WindowAction" // EntrySetIcon records Window.SetIcon; Value is the ui.WindowIcon. // // Flutter: no counterpart EntrySetIcon EntryKind = "SetIcon" // EntrySetContentType records Window.SetContentType; Value is the // ui.ContentType. // // Flutter: no counterpart EntrySetContentType EntryKind = "SetContentType" // EntryKeepScreenOn records Window.KeepScreenOn; Value is the bool. // // Flutter: no counterpart EntryKeepScreenOn EntryKind = "KeepScreenOn" // EntryPortalHandle records Window.PortalHandle; Value is nil. // // Flutter: no counterpart EntryPortalHandle EntryKind = "PortalHandle" // EntryActivationToken records Platform.RequestActivationToken; Value is the // ui.ViewID. // // Flutter: no counterpart EntryActivationToken EntryKind = "ActivationToken" // EntryClose records Window.Close; Value is nil. // // Flutter: no counterpart EntryClose EntryKind = "Close" )
The kinds of log entries.
type Event ¶
type Event interface {
// contains filtered or unexported methods
}
Event is an input or system event that Platform.Inject can queue. The set of events is closed: it is the methods of platform.Handler.
Flutter: no counterpart
type FrameEvent ¶
type FrameEvent struct {
// View is the view to draw a frame of.
View ui.ViewID
// FrameTime is the frame time since an arbitrary fixed point.
FrameTime time.Duration
}
FrameEvent delivers a frame request to Handler.OnFrame.
Flutter: no counterpart
type LifecycleEvent ¶
type LifecycleEvent struct {
// State is the new lifecycle state.
State ui.AppLifecycleState
}
LifecycleEvent delivers a lifecycle change to Handler.OnLifecycle.
Flutter: no counterpart
type MetricsEvent ¶
type MetricsEvent struct {
// View is the view whose metrics changed.
View ui.ViewID
// Metrics is the new metrics.
Metrics platform.ViewMetrics
}
MetricsEvent delivers new view metrics to Handler.OnMetrics.
Flutter: no counterpart
type Platform ¶
type Platform struct {
// contains filtered or unexported fields
}
Platform is a scripted platform.Platform for tests. Run replays a queue of events and posted functions on the goroutine that called it (the fake UI thread), and everything the engine asks of the platform is recorded in a log. It needs no display.
Flutter: no counterpart
func New ¶
func New() *Platform
New returns a fake platform that has no windows and is not running.
Flutter: no counterpart
func (*Platform) Accessibility ¶
func (p *Platform) Accessibility() *Accessibility
Accessibility is the fake accessibility bridge, which Services gives the engine.
Flutter: no counterpart
func (*Platform) Clipboard ¶
Clipboard returns the in-memory clipboard. Its results come back through Post, like the real ones.
Flutter: no counterpart
func (*Platform) ClipboardContent ¶
func (p *Platform) ClipboardContent(kind ui.ClipboardKind) ui.ClipboardContent
ClipboardContent is what the in-memory clipboard (kind system) or primary selection (kind primary) holds.
Flutter: no counterpart
func (*Platform) ClipboardText ¶
ClipboardText is the text that the in-memory clipboard holds, and whether it holds any.
Flutter: no counterpart
func (*Platform) Displays ¶
Displays returns the displays set by SetDisplays; none by default.
Flutter: no counterpart
func (*Platform) DropAnswers ¶
func (p *Platform) DropAnswers() []ui.DropActions
DropAnswers are the actions that Handler.OnDrop returned for the DropEvents the platform delivered, in order.
Flutter: no counterpart
func (*Platform) Inject ¶
Inject queues an input event for delivery to the handler inside Run. It is safe to call from any goroutine.
Flutter: no counterpart
func (*Platform) Log ¶
Log returns a copy of the log: window creation, calls on windows, and the events delivered to the handler, in the order they happened.
Flutter: no counterpart
func (*Platform) NewWindow ¶
NewWindow creates a fake window and records its config. The first window gets the implicit view ID; later windows get the next IDs.
Flutter: no counterpart
func (*Platform) Post ¶
func (p *Platform) Post(fn func())
Post queues fn to run inside Run. It is safe to call from any goroutine. Functions posted by one goroutine run in the order it posted them, and in order with events added by Inject. A function posted after Run has returned waits for the next Run.
Flutter: no counterpart
func (*Platform) RequestActivationToken ¶
RequestActivationToken records the request and answers with FakeActivationToken on the platform's thread.
Flutter: no counterpart
func (*Platform) Run ¶
Run delivers queued events and posted functions to h, in the order they were queued, until ctx is cancelled. It returns nil on cancellation. Events queued before Run starts are delivered once it does. A second call while Run is active fails with PlatformAlreadyRunning.
Flutter: no counterpart
func (*Platform) Services ¶
Services returns the fake services: the fake accessibility bridge.
Flutter: no counterpart
func (*Platform) SetClipboardContent ¶
func (p *Platform) SetClipboardContent(kind ui.ClipboardKind, content ui.ClipboardContent)
SetClipboardContent sets the in-memory clipboard (kind system) or primary selection (kind primary), as another application would.
Flutter: no counterpart
func (*Platform) SetClipboardText ¶
SetClipboardText sets the text of the in-memory clipboard, as another application would.
Flutter: no counterpart
func (*Platform) SetDisplays ¶
SetDisplays sets the displays that Displays reports.
Flutter: no counterpart
func (*Platform) SetSettings ¶
SetSettings sets the settings that Settings reports, without notifying the handler. Use a SettingsEvent to notify it.
Flutter: no counterpart
type PointerEvent ¶
type PointerEvent struct {
// Data is the batch.
Data []ui.PointerData
}
PointerEvent delivers a batch of pointer reports to Handler.OnPointer.
Flutter: no counterpart
type SettingsEvent ¶
SettingsEvent changes the settings that Platform.Settings reports and then delivers them to Handler.OnSettings.
Flutter: no counterpart
type SizeConstraints ¶
type SizeConstraints struct {
// Min is the smallest size in logical pixels; zero means no limit.
Min ui.Size
// Max is the largest size in logical pixels; zero means no limit.
Max ui.Size
}
SizeConstraints is the value of an EntrySetSizeConstraints entry.
Flutter: no counterpart
type TextInputEvent ¶
type TextInputEvent struct {
// Event is the IME event.
Event ui.TextInputEvent
}
TextInputEvent delivers an IME event to Handler.OnTextInput.
Flutter: no counterpart
type ViewFocusEvent ¶
type ViewFocusEvent struct {
// View is the view whose focus changed.
View ui.ViewID
// Focused is whether the view has the focus now.
Focused bool
}
ViewFocusEvent delivers a keyboard focus change to Handler.OnViewFocus.
Flutter: no counterpart
type ViewUpdate ¶
type ViewUpdate struct {
View ui.ViewID
Update *ui.SemanticsUpdate
}
ViewUpdate is a semantics update that the engine gave the bridge.
Flutter: no counterpart
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window is a fake platform.Window. It records the calls made on it and keeps the last values set, so tests can inspect them.
Flutter: no counterpart
func (*Window) Close ¶
func (w *Window) Close()
Close marks the window closed and records it. Closing a closed window records nothing.
Flutter: no counterpart
func (*Window) Config ¶
func (w *Window) Config() platform.WindowConfig
Config returns the config the window was created with.
Flutter: no counterpart
func (*Window) ContentType ¶
func (w *Window) ContentType() ui.ContentType
ContentType returns the last content type set; the config's until then.
Flutter: no counterpart
func (*Window) Cursor ¶
func (w *Window) Cursor() platform.MouseCursor
Cursor returns the last cursor set.
Flutter: no counterpart
func (*Window) Hidden ¶
Hidden returns whether the last SetHidden was with true.
Flutter: no counterpart
func (*Window) Icon ¶
func (w *Window) Icon() ui.WindowIcon
Icon returns the last icon set; the config's icon until then.
Flutter: no counterpart
func (*Window) KeepScreenOn ¶
KeepScreenOn records the request and always succeeds.
Flutter: no counterpart
func (*Window) NativeSurface ¶
func (w *Window) NativeSurface() gpu.SurfaceHandle
NativeSurface returns a handle of kind gpu.SurfaceKindFake whose Window is the view ID.
Flutter: no counterpart
func (*Window) PerformWindowAction ¶
func (w *Window) PerformWindowAction(action ui.WindowAction)
PerformWindowAction records the action.
Flutter: no counterpart
func (*Window) PortalHandle ¶
PortalHandle records the request and answers with "fake:" and the view ID, on the platform's thread.
Flutter: no counterpart
func (*Window) RequestFrame ¶
func (w *Window) RequestFrame()
RequestFrame records the request.
Flutter: no counterpart
func (*Window) ScreenKeptOn ¶
ScreenKeptOn returns whether the last KeepScreenOn was with true.
Flutter: no counterpart
func (*Window) SetContentType ¶
func (w *Window) SetContentType(contentType ui.ContentType)
SetContentType records the hint.
Flutter: no counterpart
func (*Window) SetCursor ¶
func (w *Window) SetCursor(cursor platform.MouseCursor)
SetCursor records the new cursor.
Flutter: no counterpart
func (*Window) SetHidden ¶
SetHidden records whether the window is hidden; the fake platform can hide windows.
Flutter: no counterpart
func (*Window) SetIcon ¶
func (w *Window) SetIcon(icon ui.WindowIcon) error
SetIcon records the icon.
Flutter: no counterpart
func (*Window) SetSizeConstraints ¶
SetSizeConstraints records the new limits.
Flutter: no counterpart
func (*Window) SetState ¶
func (w *Window) SetState(state platform.WindowState)
SetState records the new state.
Flutter: no counterpart
func (*Window) SetTextInput ¶
func (w *Window) SetTextInput(state ui.TextInputState)
SetTextInput records the new text input state.
Flutter: no counterpart
func (*Window) Size ¶
Size returns the last size set; the config's size until then.
Flutter: no counterpart
func (*Window) SizeConstraints ¶
func (w *Window) SizeConstraints() SizeConstraints
SizeConstraints returns the last limits set; the config's until then.
Flutter: no counterpart
func (*Window) StartDrag ¶
func (w *Window) StartDrag(data ui.DragRequest) error
StartDrag records the drag and always succeeds.
Flutter: no counterpart
func (*Window) State ¶
func (w *Window) State() platform.WindowState
State returns the last state set; the config's state until then.
Flutter: no counterpart
func (*Window) TextInput ¶
func (w *Window) TextInput() ui.TextInputState
TextInput returns the last text input state set.
Flutter: no counterpart