fake

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 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 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

View Source
const FakeActivationToken = "fake-activation-token"

FakeActivationToken is the token that RequestActivationToken gives.

Flutter: no counterpart

View Source
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

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

type CloseRequestEvent struct {
	// View is the view the user asked to close.
	View ui.ViewID
}

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

type ContentLostEvent struct {
	// View is the view that lost its content.
	View ui.ViewID
}

ContentLostEvent delivers a window whose content was lost to Handler.OnContentLost.

Flutter: no counterpart

type DisplaysEvent

type DisplaysEvent struct {
	// Displays is the new list of displays.
	Displays []platform.Display
}

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

func (Entry) String

func (e Entry) String() string

String describes the entry, for test failure messages.

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"
	// 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 KeyEvent

type KeyEvent struct {
	// Data is the key event.
	Data ui.KeyData
}

KeyEvent delivers a key event to Handler.OnKey.

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

func (p *Platform) Clipboard() 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

func (p *Platform) ClipboardText() (string, bool)

ClipboardText is the text that the in-memory clipboard holds, and whether it holds any.

Flutter: no counterpart

func (*Platform) Displays

func (p *Platform) Displays() []platform.Display

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

func (p *Platform) Inject(event Event)

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

func (p *Platform) Log() []Entry

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

func (p *Platform) NewWindow(cfg platform.WindowConfig) (platform.Window, error)

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

func (p *Platform) RequestActivationToken(view ui.ViewID, done func(token string))

RequestActivationToken records the request and answers with FakeActivationToken on the platform's thread.

Flutter: no counterpart

func (*Platform) Run

func (p *Platform) Run(ctx context.Context, h platform.Handler) error

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

func (p *Platform) Services() 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

func (p *Platform) SetClipboardText(text string)

SetClipboardText sets the text of the in-memory clipboard, as another application would.

Flutter: no counterpart

func (*Platform) SetDisplays

func (p *Platform) SetDisplays(displays []platform.Display)

SetDisplays sets the displays that Displays reports.

Flutter: no counterpart

func (*Platform) SetSettings

func (p *Platform) SetSettings(settings platform.Settings)

SetSettings sets the settings that Settings reports, without notifying the handler. Use a SettingsEvent to notify it.

Flutter: no counterpart

func (*Platform) Settings

func (p *Platform) Settings() platform.Settings

Settings returns the current settings: the zero value, or what the last SettingsEvent or SetSettings set.

Flutter: no counterpart

func (*Platform) Windows

func (p *Platform) Windows() []*Window

Windows returns every window created so far, closed ones included, in creation order.

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

type SettingsEvent struct {
	// Settings is the new settings.
	Settings platform.Settings
}

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

func (w *Window) Closed() bool

Closed returns whether Close was called.

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

func (w *Window) ID() ui.ViewID

ID returns the window's view ID.

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

func (w *Window) KeepScreenOn(on bool) error

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

func (w *Window) PortalHandle(done func(handle string))

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

func (w *Window) ScreenKeptOn() bool

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

func (w *Window) SetIcon(icon ui.WindowIcon) error

SetIcon records the icon.

Flutter: no counterpart

func (*Window) SetSize

func (w *Window) SetSize(size ui.Size)

SetSize records the new size.

Flutter: no counterpart

func (*Window) SetSizeConstraints

func (w *Window) SetSizeConstraints(min, max ui.Size)

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

func (w *Window) SetTitle(title string)

SetTitle records the new title.

Flutter: no counterpart

func (*Window) Size

func (w *Window) Size() ui.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

func (*Window) Title

func (w *Window) Title() string

Title returns the last title set; the config's title until then.

Flutter: no counterpart

type WindowRecord

type WindowRecord struct {
	View   ui.ViewID
	Title  string
	Active bool
}

WindowRecord is what the engine told the accessibility bridge about a window.

Flutter: no counterpart

Jump to

Keyboard shortcuts

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