gluttertest

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: BSD-3-Clause Imports: 28 Imported by: 1 module, 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 gluttertest is the widget-testing package: WidgetTester, finders and golden comparison, driven by a fake clock and a fake platform. A test makes a Tester with New, pumps a widget into it, finds widgets, sends them pointer and key events, and checks what it finds. No display, no GPU and no real time are involved (SPEC §17).

func TestCounter(t *testing.T) {
	tester := gluttertest.New(t)
	tester.PumpWidget(NewCounter())
	tester.Tap(gluttertest.ByType[*Button]())
	tester.Pump()
	if err := gluttertest.FindsOneWidget(tester, gluttertest.ByText("1")); err != nil {
		t.Error(err)
	}
}

The text of a test is laid out with the fonts bundled with Glutter (Roboto and Material Icons) and no system fonts, so that it is the same on every machine. Opts.Fonts adds more, for example a monospace font for the golden of a code view.

An error that the framework reports (a panic in Build, layout or a callback, SPEC §14.2) does not stop the test where it happens; it is kept, and the test fails at its end unless it took the error with TakeError.

Flutter: package:flutter_test/flutter_test.dart.

Index

Constants

View Source
const DragSlopDefault = 20.0

DragSlopDefault is how far a drag moves first so that it passes the touch slop of the recognizers, in logical pixels.

Flutter: flutter_test/lib/src/controller.dart kDragSlopDefault

Variables

This section is empty.

Functions

func FindsAtLeastNWidgets

func FindsAtLeastNWidgets(t *Tester, f Finder, n int) error

FindsAtLeastNWidgets checks that the finder finds n widgets or more.

Flutter: flutter_test/lib/src/matchers.dart findsAtLeastNWidgets

func FindsNWidgets

func FindsNWidgets(t *Tester, f Finder, n int) error

FindsNWidgets checks that the finder finds exactly n widgets.

Flutter: flutter_test/lib/src/matchers.dart findsNWidgets

func FindsNothing

func FindsNothing(t *Tester, f Finder) error

FindsNothing checks that the finder finds nothing.

Flutter: flutter_test/lib/src/matchers.dart findsNothing

func FindsOneWidget

func FindsOneWidget(t *Tester, f Finder) error

FindsOneWidget checks that the finder finds exactly one widget.

Flutter: flutter_test/lib/src/matchers.dart findsOneWidget

func FindsWidgets

func FindsWidgets(t *Tester, f Finder) error

FindsWidgets checks that the finder finds at least one widget.

Flutter: flutter_test/lib/src/matchers.dart findsWidgets

func StateOf

func StateOf[T widgets.State](t *Tester, f Finder) T

StateOf is the state of the one StatefulWidget the finder finds, as the type T. The test fails with the tag FinderNotStateful when the element has no state, and FinderWrongType when the state has another type.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetController.state

func WidgetAs

func WidgetAs[T widgets.Widget](t *Tester, f Finder) T

WidgetAs is the one widget the finder finds, as the type T. The test fails with the tag FinderWrongType if it has another type.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetController.widget

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 a system mouse cursor that the framework asked the platform to show.

Flutter: no counterpart (a call of the flutter/mousecursor channel)

type DescendantOpts

type DescendantOpts struct {
	// MatchRoot also counts the element of the first finder itself.
	MatchRoot bool
}

DescendantOpts are the optional parameters of Descendant and Ancestor.

Flutter: flutter_test/lib/src/finders.dart CommonFinders.descendant

type FakeDesktop

type FakeDesktop struct {
	// contains filtered or unexported fields
}

FakeDesktop is a desktop for the tests of an app that uses package desktop: a notification service, a StatusNotifierWatcher for the system tray, and a file chooser portal, on an in-process bus. The code of the app runs as it does for real; the test looks at what it sent and answers the way the user would.

Flutter: no counterpart

func (*FakeDesktop) ActivateTray

func (f *FakeDesktop) ActivateTray()

ActivateTray does what the user does when they click the tray icon.

Flutter: no counterpart

func (*FakeDesktop) AnswerFileChooser

func (f *FakeDesktop) AnswerFileChooser(paths ...string)

AnswerFileChooser chooses the paths in the oldest file dialog that is open, the way the user does.

Flutter: no counterpart

func (*FakeDesktop) CancelFileChooser

func (f *FakeDesktop) CancelFileChooser()

CancelFileChooser closes the oldest file dialog that is open without a choice.

Flutter: no counterpart

func (*FakeDesktop) ClickTrayMenuItem

func (f *FakeDesktop) ClickTrayMenuItem(label string)

ClickTrayMenuItem does what the user does when they choose the item with the label in the menu of the tray, and runs the app's callback. It fails the test when there is no such item.

Flutter: no counterpart

func (*FakeDesktop) CloseNotification

func (f *FakeDesktop) CloseNotification(id, reason uint32)

CloseNotification closes a notification the way the desktop does, with a reason of the specification (1 expired, 2 dismissed by the user, 3 closed by the app), and runs the app's callback.

Flutter: no counterpart

func (*FakeDesktop) InvokeNotificationAction

func (f *FakeDesktop) InvokeNotificationAction(id uint32, action string)

InvokeNotificationAction does what the user does when they choose an action of a notification, and runs the app's callback.

Flutter: no counterpart

func (*FakeDesktop) Notifications

func (f *FakeDesktop) Notifications() []FakeNotification

Notifications are the notifications that the app showed, oldest first; a notification that replaced another takes its place.

Flutter: no counterpart

func (*FakeDesktop) PendingFileChoosers

func (f *FakeDesktop) PendingFileChoosers() int

PendingFileChoosers is how many file dialogs the app has opened that the test has not answered.

Flutter: no counterpart

func (*FakeDesktop) TrayMenu

func (f *FakeDesktop) TrayMenu() []string

TrayMenu are the labels of the first level of the menu of the tray, in order, with "-" for a separator.

Flutter: no counterpart

func (*FakeDesktop) TrayProperty

func (f *FakeDesktop) TrayProperty(name string) any

TrayProperty is a property of the tray icon (StatusNotifierItem), such as "Title", "Status" or "IconName"; it is nil when there is none.

Flutter: no counterpart

func (*FakeDesktop) TrayRegistered

func (f *FakeDesktop) TrayRegistered() bool

TrayRegistered says whether a tray icon registered with the watcher.

Flutter: no counterpart

func (*FakeDesktop) WaitFor

func (f *FakeDesktop) WaitFor(what string, cond func() bool)

WaitFor pumps the posted functions until cond is true, for what the app does on other goroutines (the calls of package desktop). It fails the test after five seconds.

Flutter: no counterpart

type FakeNotification

type FakeNotification struct {
	// ID is the number that the fake desktop gave the notification.
	ID uint32
	// AppName, Icon, Summary and Body are what the app sent.
	AppName, Icon, Summary, Body string
	// Actions are the buttons.
	Actions []FakeNotificationAction
	// Urgency is the urgency hint: 0 low, 1 normal, 2 critical.
	Urgency byte
	// Closed says that the app or the test closed it.
	Closed bool
}

FakeNotification is a notification that the app showed to the fake desktop.

Flutter: no counterpart

type FakeNotificationAction

type FakeNotificationAction struct {
	// ID is the key that the app gave the action.
	ID string
	// Label is the text of the button.
	Label string
}

FakeNotificationAction is a button of a FakeNotification.

Flutter: no counterpart

type FindOpts

type FindOpts struct {
	// IncludeOffstage also looks inside the widgets that are offstage; Flutter's
	// skipOffstage: false.
	IncludeOffstage bool
	// FindRichText makes ByText and ByTextContaining also match RichText widgets,
	// not only Text; Flutter's findRichText: true.
	FindRichText bool
}

FindOpts are the optional parameters of the finders that look at every element.

Flutter: flutter_test/lib/src/finders.dart CommonFinders

type Finder

type Finder interface {
	// Describe says what the finder looks for, for the messages of a failure.
	//
	// Flutter: flutter_test/lib/src/finders.dart Finder.description
	Describe() string
	// Find returns the matching elements of the tree under test, in depth first
	// order (a parent before its children, siblings in order).
	//
	// Flutter: flutter_test/lib/src/finders.dart Finder.evaluate
	Find(t *Tester) []widgets.Element
}

Finder finds the elements of the tree under test that match some criterion. Make one with ByText, ByKey, ByType and the others of this file, combine them with Descendant and Ancestor, and give it to the methods of the Tester (Tap, Widget, Center) or to the matchers (FindsOneWidget). A finder looks at the tree each time it is used, so it can be made before the widget exists.

Flutter: flutter_test/lib/src/finders.dart Finder

func Ancestor

func Ancestor(of, matching Finder, opts ...DescendantOpts) Finder

Ancestor finds the elements of the second finder that are above an element of the first (or are one, with MatchRoot), the closest first.

Flutter: flutter_test/lib/src/finders.dart CommonFinders.ancestor

func At

func At(f Finder, index int) Finder

At is the match of the finder at the index, or nothing when there are not so many.

Flutter: flutter_test/lib/src/finders.dart FinderBase.at

func ByElementPredicate

func ByElementPredicate(description string, fn func(e widgets.Element) bool, opts ...FindOpts) Finder

ByElementPredicate finds the elements for which the function is true.

Flutter: flutter_test/lib/src/finders.dart CommonFinders.byElementPredicate

func ByIcon

func ByIcon(icon any, opts ...FindOpts) Finder

ByIcon finds the widgets that implement IconWidget and show this icon.

Flutter: flutter_test/lib/src/finders.dart CommonFinders.byIcon

func ByKey

func ByKey(key foundation.Key, opts ...FindOpts) Finder

ByKey finds the widgets that have the key.

Flutter: flutter_test/lib/src/finders.dart CommonFinders.byKey

func ByPredicate

func ByPredicate(description string, fn func(w widgets.Widget) bool, opts ...FindOpts) Finder

ByPredicate finds the widgets for which the function is true. The description is used in the messages of a failure.

Flutter: flutter_test/lib/src/finders.dart CommonFinders.byWidgetPredicate

func BySemanticsLabel

func BySemanticsLabel(label string, opts ...FindOpts) Finder

BySemanticsLabel finds the elements whose render object has a semantics node with exactly this label. Ask for semantics with Tester.EnsureSemantics and pump a frame first. It reads RenderObject.DebugSemantics, so it finds nothing in a release or profile build (Flutter's tests run in debug mode).

Flutter: flutter_test/lib/src/finders.dart CommonFinders.bySemanticsLabel

func BySemanticsLabelMatching

func BySemanticsLabelMatching(pattern *regexp.Regexp, opts ...FindOpts) Finder

BySemanticsLabelMatching is BySemanticsLabel with a regular expression.

Flutter: flutter_test/lib/src/finders.dart CommonFinders.bySemanticsLabel

func ByText

func ByText(text string, opts ...FindOpts) Finder

ByText finds the widgets that show exactly this text: those that implement TextWidget (Text, and RichText with FindRichText).

Flutter: flutter_test/lib/src/finders.dart CommonFinders.text

func ByTextContaining

func ByTextContaining(substring string, opts ...FindOpts) Finder

ByTextContaining finds the widgets that show a text with this substring.

Flutter: flutter_test/lib/src/finders.dart CommonFinders.textContaining

func ByTooltip

func ByTooltip(message string, opts ...FindOpts) Finder

ByTooltip finds the widgets that implement TooltipWidget and have this message.

Flutter: flutter_test/lib/src/finders.dart CommonFinders.byTooltip

func ByType

func ByType[T widgets.Widget](opts ...FindOpts) Finder

ByType finds the widgets of the type T, such as ByType[*Button]().

Flutter: flutter_test/lib/src/finders.dart CommonFinders.byType

func ByWidget

func ByWidget(w widgets.Widget, opts ...FindOpts) Finder

ByWidget finds the elements of this very widget (the same pointer).

Flutter: flutter_test/lib/src/finders.dart CommonFinders.byWidget

func Descendant

func Descendant(of, matching Finder, opts ...DescendantOpts) Finder

Descendant finds the elements of the second finder that are below an element of the first (or are one, with MatchRoot).

Flutter: flutter_test/lib/src/finders.dart CommonFinders.descendant

func Everything

func Everything(opts ...FindOpts) Finder

Everything finds every element of the tree.

Flutter: flutter_test/lib/src/finders.dart CommonFinders.everything

func First

func First(f Finder) Finder

First is the first match of the finder, in depth first order.

Flutter: flutter_test/lib/src/finders.dart FinderBase.first

func Last

func Last(f Finder) Finder

Last is the last match of the finder.

Flutter: flutter_test/lib/src/finders.dart FinderBase.last

type Font

type Font struct {
	// Family is the family name that TextStyle.FontFamily uses. When empty, the
	// family name inside the font is used.
	Family string
	// Data is the content of a TrueType or OpenType file.
	Data []byte
}

Font is a font file for Opts.Fonts.

Flutter: services/font_loader.dart FontLoader

type GestureOpts

type GestureOpts struct {
	// Kind is the kind of device; the default is touch.
	Kind ui.PointerDeviceKind
	// Buttons are the buttons pressed; the default is the primary button.
	Buttons foundation.Opt[int]
	// Pointer is the ID of the pointer; the default is a new one each time.
	Pointer int
	// TouchSlopX and TouchSlopY are how far Drag and DragFrom move first, along
	// each axis, so that the recognizers of drags win; the default is
	// DragSlopDefault.
	//
	// Flutter: flutter_test/lib/src/controller.dart WidgetController.drag touchSlopX
	TouchSlopX, TouchSlopY foundation.Opt[float64]
	// View is the view the pointer is in; the default is the implicit view. The
	// gestures that take a Finder use the view of the element it finds.
	//
	// Flutter: flutter_test/lib/src/controller.dart WidgetController.startGesture
	View ui.ViewID
}

GestureOpts are the optional parameters of the gestures of the tester.

Flutter: flutter_test/lib/src/controller.dart WidgetController.startGesture

type IconWidget

type IconWidget interface {
	widgets.Widget
	// IconValue is the icon the widget shows (an IconData).
	IconValue() any
}

IconWidget is implemented by the Icon widget (step 7.7): ByIcon matches its IconValue with the icon it is given.

Flutter: flutter_test/lib/src/finders.dart CommonFinders.byIcon

type KeyOpts

type KeyOpts struct {
	// Physical is the physical key; the default is the key of the same name as the
	// logical key (services.PhysicalKeyOf), or none.
	Physical services.PhysicalKeyboardKey
	// Character is the text the key produces, for a key down or a repeat.
	Character string
}

KeyOpts are the optional parameters of the key events of the tester.

Flutter: flutter_test/lib/src/event_simulation.dart simulateKeyDownEvent

type OffstageWidget

type OffstageWidget interface {
	widgets.Widget
	// IsOffstage is whether the subtree is hidden.
	IsOffstage() bool
}

OffstageWidget is implemented by a widget that hides its subtree from the finders, such as Offstage (step 7.6): the finders skip the subtree unless they are made with IncludeOffstage.

Flutter: flutter_test/lib/src/finders.dart CommonFinders.skipOffstage

type Opts

type Opts struct {
	// Size is the size of the view in logical pixels; the default is 800x600,
	// the size of flutter_test's view.
	Size ui.Size
	// DevicePixelRatio is the number of physical pixels per logical pixel; the
	// default is 1.
	DevicePixelRatio float64
	// TextEngine lays out the text. The default has only the fonts bundled with
	// Glutter, so that the text is the same on every machine.
	TextEngine ui.ParagraphFactory
	// Fonts are added to the text engine of the test, besides the bundled Roboto
	// and Material Icons: a golden test can then show monospace text, or any text,
	// the same on every machine. Like the fonts of RunAppOpts.Fonts, several fonts
	// of one family make a family of weights and slants. The engine has no system
	// fonts. A font that fails to load fails the test, and Fonts together with
	// TextEngine fails it too.
	//
	// Flutter: flutter_test/lib/src/binding.dart (FontLoader in a test)
	Fonts []Font
	// Debug are the debug flags; the default is a fresh set, all off.
	Debug *widgets.DebugOptions
	// DiscardScenes drops the scenes that the view renders instead of keeping them
	// for Scenes and Screenshot: for benchmarks that run many frames.
	//
	// Flutter: no counterpart
	DiscardScenes bool
	// ErrorWidgetBuilder replaces the widget that is built for a widget that
	// panicked in Build.
	ErrorWidgetBuilder func(err error) widgets.Widget
}

Opts are the optional parameters of New.

Flutter: flutter_test/lib/src/binding.dart TestWidgetsFlutterBinding

type PumpAndSettleOpts

type PumpAndSettleOpts struct {
	// Duration is the time between the frames; the default is 100 ms.
	Duration time.Duration
	// Timeout is how much fake time to wait for the frames to stop; the default
	// is 10 minutes.
	Timeout time.Duration
}

PumpAndSettleOpts are the optional parameters of PumpAndSettle.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetTester.pumpAndSettle

type PumpFramesOpts

type PumpFramesOpts struct {
	// Interval is the time between the frames; the default is 16.683 ms, a frame
	// at 60 Hz.
	Interval time.Duration
}

PumpFramesOpts are the optional parameters of PumpFrames.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetTester.pumpFrames

type PumpWidgetOpts

type PumpWidgetOpts struct {
	// Duration is how far to advance the clock before the frame; see Pump.
	Duration time.Duration
	// NoView says not to wrap the widget in a View for the view of the tester
	// (Flutter's wrapWithView: false); the widget must be or contain one.
	NoView bool
}

PumpWidgetOpts are the optional parameters of PumpWidget.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetTester.pumpWidget

type TB

type TB interface {
	Helper()
	Errorf(format string, args ...any)
	Fatalf(format string, args ...any)
	Fatal(args ...any)
	Logf(format string, args ...any)
	Cleanup(func())
}

TB is the part of testing.TB that gluttertest needs. *testing.T and *testing.B implement it; gluttertest's own tests give a fake one to see how a test fails.

Flutter: no counterpart

type TestGesture

type TestGesture struct {
	// contains filtered or unexported fields
}

TestGesture is a pointer that the test moves: it sent a down event when it was created and sends the moves, the up or the cancel when the test calls them. The events carry the time of the fake clock.

Flutter: flutter_test/lib/src/test_pointer.dart TestGesture

func (*TestGesture) Cancel

func (g *TestGesture) Cancel()

Cancel cancels the pointer, as the system does when it takes the touch away.

Flutter: flutter_test/lib/src/test_pointer.dart TestGesture.cancel

func (*TestGesture) Down

func (g *TestGesture) Down(at ui.Offset)

Down presses the pointer again at the position, after Up or Cancel. A mouse that Up removed is added again first.

Flutter: flutter_test/lib/src/test_pointer.dart TestGesture.down

func (*TestGesture) MoveBy

func (g *TestGesture) MoveBy(by ui.Offset)

MoveBy moves the pressed pointer by the offset.

Flutter: flutter_test/lib/src/test_pointer.dart TestGesture.moveBy

func (*TestGesture) MoveByAt

func (g *TestGesture) MoveByAt(by ui.Offset, timeStamp time.Duration)

MoveByAt moves the pressed pointer by the offset with the event time stamp set to timeStamp (since the start of the test), instead of the time of the fake clock. The next events keep the time stamp until another call sets it.

Flutter: flutter_test/lib/src/test_pointer.dart TestGesture.moveBy timeStamp

func (*TestGesture) MoveTo

func (g *TestGesture) MoveTo(to ui.Offset)

MoveTo moves the pressed pointer to the position.

Flutter: flutter_test/lib/src/test_pointer.dart TestGesture.moveTo

func (*TestGesture) Position

func (g *TestGesture) Position() ui.Offset

Position is where the pointer is.

Flutter: flutter_test/lib/src/test_pointer.dart TestPointer.location

func (*TestGesture) Up

func (g *TestGesture) Up()

Up releases the pointer.

Flutter: flutter_test/lib/src/test_pointer.dart TestGesture.up

type TestTrackpadGesture

type TestTrackpadGesture struct {
	// contains filtered or unexported fields
}

TestTrackpadGesture is a pan/zoom gesture of a trackpad that the test updates: it sent a pan/zoom start event when it was created and sends the updates or the end when the test calls them.

Flutter: flutter_test/lib/src/test_pointer.dart TestPointer.panZoomStart

func (*TestTrackpadGesture) End

func (g *TestTrackpadGesture) End()

End ends the gesture.

Flutter: flutter_test/lib/src/test_pointer.dart TestPointer.panZoomEnd

func (*TestTrackpadGesture) PanBy

func (g *TestTrackpadGesture) PanBy(by ui.Offset)

PanBy pans the gesture by the offset from where it is.

Flutter: flutter_test/lib/src/test_pointer.dart TestPointer.panZoomUpdate

func (*TestTrackpadGesture) Update

func (g *TestTrackpadGesture) Update(pan ui.Offset, scale, rotation float64)

Update reports the totals of the gesture since it started: the pan, the scale and the rotation (radians).

Flutter: flutter_test/lib/src/test_pointer.dart TestPointer.panZoomUpdate

type TestWindow

type TestWindow struct {
	// View is the view of the window.
	View ui.ViewID
	// Spec is what the app asked for.
	Spec ui.WindowSpec
	// Title is the last title the app set; the one it asked for until then.
	Title string
	// Size is the last content size the app asked for, in logical pixels.
	Size ui.Size
	// Min and Max are the last limits the app set on the content size; zero is no
	// limit.
	Min, Max ui.Size
	// Destroyed is whether the app destroyed the window.
	Destroyed bool
	// Hidden is whether the app hid the window.
	Hidden bool
}

TestWindow is a window that the app asked the fake platform for.

Flutter: no counterpart

type Tester

type Tester struct {

	// Binding is the widgets binding of the app under test.
	Binding *widgets.WidgetsBinding
	// Clock is the fake clock. Pump moves it; the timers of the recognizers and
	// of the image cache run when it passes them.
	Clock *fakeclock.Fake
	// View is the implicit view of the platform.
	View *ui.View
	// contains filtered or unexported fields
}

Tester is a widgets binding on a fake platform with one view, a fake clock and the software renderer. It stands for flutter_test's WidgetTester and the binding under it.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetTester

func New

func New(tb TB, opts ...Opts) *Tester

New creates a tester. It fails the test, when the test ends, if the framework reported an error that the test did not take (TakeError).

Flutter: flutter_test/lib/src/binding.dart TestWidgetsFlutterBinding.ensureInitialized

func (*Tester) ActivatedCursors

func (t *Tester) ActivatedCursors() []CursorActivation

ActivatedCursors are the system mouse cursors that the framework asked the platform to show, in order.

Flutter: no counterpart (the log of a mock handler of SystemChannels.mouseCursor)

func (*Tester) BottomRight

func (t *Tester) BottomRight(f Finder) ui.Offset

BottomRight is the position of the bottom right corner of the one widget the finder finds.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetController.getBottomRight

func (*Tester) Center

func (t *Tester) Center(f Finder) ui.Offset

Center is the position of the center of the one widget the finder finds, in logical pixels of the view.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetController.getCenter

func (*Tester) ClearClipboard

func (t *Tester) ClearClipboard()

ClearClipboard empties the fake system clipboard.

Flutter: no counterpart (MockClipboard.clipboardData = null)

func (*Tester) ClipboardPNG

func (t *Tester) ClipboardPNG() []byte

ClipboardPNG is the image on the fake system clipboard, or nil.

Flutter: no counterpart

func (*Tester) ClipboardText

func (t *Tester) ClipboardText() (string, bool)

ClipboardText is the text on the fake system clipboard, and whether there is any. The framework's Clipboard calls use it.

Flutter: no counterpart (the state of flutter_test's MockClipboard)

func (*Tester) ClipboardURIs

func (t *Tester) ClipboardURIs() []string

ClipboardURIs are the URIs on the fake system clipboard, or nil.

Flutter: no counterpart

func (*Tester) Count

func (t *Tester) Count(f Finder) int

Count is how many elements the finder finds.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetController.any

func (*Tester) Dispatcher

func (t *Tester) Dispatcher() *ui.PlatformDispatcher

Dispatcher is the platform dispatcher of the app: the test calls it as the platform would (for the lifecycle state, the close request, the keys).

Flutter: flutter_test/lib/src/binding.dart TestWidgetsFlutterBinding.platformDispatcher

func (*Tester) Drag

func (t *Tester) Drag(f Finder, by ui.Offset, opts ...GestureOpts)

Drag drags from the center of the one element the finder finds by the offset.

Flutter: flutter_test/lib/src/controller.dart WidgetController.drag

func (*Tester) DragFrom

func (t *Tester) DragFrom(at, by ui.Offset, opts ...GestureOpts)

DragFrom presses a pointer at the position and moves it by the offset, first by the slop (so that the recognizers of drags win), then by the rest, and releases it.

Flutter: flutter_test/lib/src/controller.dart WidgetController.dragFrom

func (*Tester) Drags

func (t *Tester) Drags() []ui.DragRequest

Drags are the drag and drop operations the app started, in order.

Flutter: no counterpart

func (*Tester) Drop

func (t *Tester) Drop(view ui.ViewID, phase ui.DropPhase, at ui.Offset, event ui.DropEvent) ui.DropActions

Drop plays a drag and drop operation of another application (or of the platform) over a view, and returns the action the framework accepts: the way the platform delivers the enter, move, leave and drop events. The position is in logical pixels of the view; the event has it in physical pixels.

Flutter: no counterpart

func (*Tester) Elapsed

func (t *Tester) Elapsed() time.Duration

Elapsed is how much fake time has passed since the tester was made.

Flutter: flutter_test/lib/src/binding.dart AutomatedTestWidgetsFlutterBinding.clock

func (*Tester) Element

func (t *Tester) Element(f Finder) widgets.Element

Element is the one element the finder finds. The test fails with the tag FinderNoMatch when there is none, and FinderManyMatches when there are more than one.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetController.element

func (*Tester) Elements

func (t *Tester) Elements(f Finder) []widgets.Element

Elements are the elements the finder finds in the tree under test.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetController.elementList

func (*Tester) EnsureSemantics

func (t *Tester) EnsureSemantics() *semantics.SemanticsHandle

EnsureSemantics asks for semantics until the handle is disposed; pump a frame before looking for a semantics label. Test cleanup disposes the handle if the test did not.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetTester.ensureSemantics

func (*Tester) EnterText

func (t *Tester) EnterText(f Finder, text string)

EnterText types the text into the text field the finder finds: the field gets the focus, and its text becomes the text, with the caret at the end, as if the input method had sent the new value.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetTester.enterText

func (*Tester) Errors

func (t *Tester) Errors() []error

Errors are the errors that were reported and not taken, oldest first.

Flutter: no counterpart

func (*Tester) Exists

func (t *Tester) Exists(f Finder) bool

Exists is whether the finder finds anything.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetController.any

func (*Tester) ExitRequests

func (t *Tester) ExitRequests() int

ExitRequests is how many times the app asked the platform to exit the application (WidgetsBinding.ExitApplication with the fake platform).

Flutter: no counterpart

func (*Tester) FailDrags

func (t *Tester) FailDrags(err error)

FailDrags makes the fake platform refuse to start drags with err, as a platform that cannot.

Flutter: no counterpart

func (*Tester) FailKeepScreenOn

func (t *Tester) FailKeepScreenOn(err error)

FailKeepScreenOn makes the fake platform refuse to keep the screen on with err, as a platform that cannot.

Flutter: no counterpart

func (*Tester) FakeDesktop

func (t *Tester) FakeDesktop() *FakeDesktop

FakeDesktop installs a fake desktop in the app and returns it. Call it before the app first uses package desktop (before the SystemTray is pumped).

Flutter: no counterpart

func (*Tester) Fling

func (t *Tester) Fling(f Finder, by ui.Offset, speed float64, opts ...GestureOpts)

Fling flings from the center of the one element the finder finds.

Flutter: flutter_test/lib/src/controller.dart WidgetController.fling

func (*Tester) FlingFrom

func (t *Tester) FlingFrom(at, by ui.Offset, speed float64, opts ...GestureOpts)

FlingFrom presses a pointer at the position and moves it by the offset in 50 steps at the speed (logical pixels per second), pumping between the steps so that the velocity the recognizers measure is the speed, then releases it.

Flutter: flutter_test/lib/src/controller.dart WidgetController.flingFrom

func (*Tester) FlushPosted

func (t *Tester) FlushPosted()

FlushPosted runs the functions that were posted to the UI thread (by State.Go, for one) without running a frame.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetTester.idle

func (*Tester) FocusEvents

func (t *Tester) FocusEvents() []ui.ViewFocusEvent

FocusEvents are the focus changes that the app asked the platform for, in order, with the direction: what Flutter's TestPlatformDispatcher.testFocusEvents has.

Flutter: flutter_test/lib/src/platform.dart TestPlatformDispatcher.testFocusEvents

func (*Tester) FocusRequests

func (t *Tester) FocusRequests() []ui.ViewID

FocusRequests are the views that the app asked the platform to focus, in order.

Flutter: no counterpart

func (*Tester) Hover

func (t *Tester) Hover(at ui.Offset)

Hover moves a mouse to the position without pressing it; the first hover adds the mouse.

Flutter: flutter_test/lib/src/test_pointer.dart TestPointer.hover

func (*Tester) LongPress

func (t *Tester) LongPress(f Finder, opts ...GestureOpts)

LongPress long-presses the center of the one element the finder finds.

Flutter: flutter_test/lib/src/controller.dart WidgetController.longPress

func (*Tester) LongPressAt

func (t *Tester) LongPressAt(at ui.Offset, opts ...GestureOpts)

LongPressAt presses a pointer at the position, lets enough fake time pass for a long press to be recognized, and releases it. It pumps while it waits.

Flutter: flutter_test/lib/src/controller.dart WidgetController.longPressAt

func (*Tester) MatchesGolden

func (t *Tester) MatchesGolden(name string)

MatchesGolden compares the view, as the last frame drew it, with the golden image testdata/goldens/<name>.png of the package under test. Run the tests with -update-goldens to write the image, and look at every golden that changed (CLAUDE.md).

Flutter: flutter_test/lib/src/matchers.dart matchesGoldenFile

func (*Tester) PrimaryText

func (t *Tester) PrimaryText() (string, bool)

PrimaryText is the text on the fake primary selection, and whether there is any. Selecting text in a text field puts it there.

Flutter: no counterpart

func (*Tester) Pump

func (t *Tester) Pump(duration ...time.Duration)

Pump advances the fake clock by the duration (if there is one), then runs one frame at the new time if a frame is scheduled, and the work that was posted to the UI thread (also between the begin and the draw phase of the frame, like the microtasks of flutter_test). The timers that come due while the clock advances run first.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetTester.pump

func (*Tester) PumpAndSettle

func (t *Tester) PumpAndSettle(opts ...PumpAndSettleOpts) int

PumpAndSettle pumps frames, Duration apart, until no frame is scheduled anymore, and returns how many times it pumped. If frames are still scheduled after Timeout of fake time the test fails with the tag PumpAndSettleTimeout.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetTester.pumpAndSettle

func (*Tester) PumpFrame

func (t *Tester) PumpFrame(duration time.Duration)

PumpFrame is Pump for a caller that is the UI thread already (the goroutine that made the tester, or the last one that called Pump): it does not look for the calling goroutine, which costs an allocation, so that a benchmark measures the frame and not the harness.

Flutter: no counterpart

func (*Tester) PumpFrames

func (t *Tester) PumpFrames(w widgets.Widget, maxDuration time.Duration, opts ...PumpFramesOpts)

PumpFrames pumps the widget, then frames Interval apart until maxDuration of fake time has passed. It is for animations that are watched frame by frame.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetTester.pumpFrames

func (*Tester) PumpWidget

func (t *Tester) PumpWidget(w widgets.Widget, opts ...PumpWidgetOpts)

PumpWidget makes the widget the root of the app, in a View for the view of the tester, and pumps a frame. Calling it again replaces the widget.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetTester.pumpWidget

func (*Tester) RenderObject

func (t *Tester) RenderObject(f Finder) rendering.RenderObject

RenderObject is the render object of the one element the finder finds.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetController.renderObject

func (*Tester) RequestWindowClose

func (t *Tester) RequestWindowClose(view ui.ViewID) bool

RequestWindowClose tells the framework, as the platform would, that the user asked to close the window of the view. It reports whether the platform would close the window: false when the delegate of the controller took the request, or the app answered the request to exit with a cancel.

Flutter: no counterpart

func (*Tester) ResetFocusEvents

func (t *Tester) ResetFocusEvents()

ResetFocusEvents forgets the focus changes that FocusEvents has.

Flutter: flutter_test/lib/src/platform.dart TestPlatformDispatcher.resetFocusedViewTestValues

func (*Tester) Scenes

func (t *Tester) Scenes() []*ui.Scene

Scenes are the scenes that the view rendered, one for each frame that was composited.

Flutter: no counterpart

func (*Tester) ScreenKeptOn

func (t *Tester) ScreenKeptOn(view ui.ViewID) bool

ScreenKeptOn is whether the app asked to keep the screen on for the view.

Flutter: no counterpart

func (*Tester) Screenshot

func (t *Tester) Screenshot() *image.RGBA

Screenshot renders the last scene with the software renderer, in physical pixels. It fails the test when no frame was composited yet.

Flutter: flutter_test/lib/src/matchers.dart matchesGoldenFile

func (*Tester) Scroll

func (t *Tester) Scroll(f Finder, delta ui.Offset)

Scroll scrolls the wheel over the center of the one element the finder finds.

Flutter: flutter_test/lib/src/controller.dart WidgetController.scroll

func (*Tester) ScrollAt

func (t *Tester) ScrollAt(at, delta ui.Offset)

ScrollAt sends a scroll event of a mouse wheel at the position, as the system does for one notch or a trackpad scroll, and pumps nothing.

Flutter: flutter_test/lib/src/controller.dart WidgetController.sendEventToBinding / TestPointer.scroll

func (*Tester) ScrollKindAt

func (t *Tester) ScrollKindAt(kind ui.PointerDeviceKind, at, delta ui.Offset)

ScrollKindAt is ScrollAt for a device of another kind, such as a trackpad. Each kind has one pointer of its own, which stays for the life of the tester.

Flutter: flutter_test/lib/src/test_pointer.dart TestPointer.scroll

func (*Tester) SemanticsUpdates

func (t *Tester) SemanticsUpdates() []*ui.SemanticsUpdate

SemanticsUpdates are the semantics updates that the views sent to the engine, oldest first, as an accessibility bridge gets them. Ask for semantics first (EnsureSemantics) and pump a frame.

Flutter: no counterpart (the embedder's side of the semantics update)

func (*Tester) SendKeyDownEvent

func (t *Tester) SendKeyDownEvent(logical services.LogicalKeyboardKey, opts ...KeyOpts) bool

SendKeyDownEvent sends a key down for the logical key and returns whether something handled it.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetTester.sendKeyDownEvent

func (*Tester) SendKeyEvent

func (t *Tester) SendKeyEvent(logical services.LogicalKeyboardKey, opts ...KeyOpts) bool

SendKeyEvent sends a key down and a key up for the logical key and returns whether the down was handled.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetTester.sendKeyEvent

func (*Tester) SendKeyRepeatEvent

func (t *Tester) SendKeyRepeatEvent(logical services.LogicalKeyboardKey, opts ...KeyOpts) bool

SendKeyRepeatEvent sends a key repeat for the logical key and returns whether something handled it.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetTester.sendKeyRepeatEvent

func (*Tester) SendKeyUpEvent

func (t *Tester) SendKeyUpEvent(logical services.LogicalKeyboardKey, opts ...KeyOpts) bool

SendKeyUpEvent sends a key up for the logical key and returns whether something handled it.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetTester.sendKeyUpEvent

func (*Tester) SendTextInputEvent

func (t *Tester) SendTextInputEvent(event ui.TextInputEvent)

SendTextInputEvent plays the input method: it asks the focused text field for a change (a commit, a preedit, a deletion), and runs what that posted.

Flutter: flutter_test/lib/src/test_text_input.dart TestTextInput.updateEditingValue

func (*Tester) SetClipboardPNG

func (t *Tester) SetClipboardPNG(png []byte)

SetClipboardPNG puts an image on the fake system clipboard, as another application would.

Flutter: no counterpart

func (*Tester) SetClipboardText

func (t *Tester) SetClipboardText(text string)

SetClipboardText puts text on the fake system clipboard, as another application would.

Flutter: no counterpart (MockClipboard.clipboardData)

func (*Tester) SetClipboardURIs

func (t *Tester) SetClipboardURIs(uris []string)

SetClipboardURIs puts URIs (such as copied files) on the fake system clipboard, as another application would.

Flutter: no counterpart

func (*Tester) SetDevicePixelRatio

func (t *Tester) SetDevicePixelRatio(ratio float64)

SetDevicePixelRatio changes the pixel ratio of the view, keeping its logical size.

Flutter: flutter_test/lib/src/window.dart TestFlutterView.devicePixelRatio

func (*Tester) SetLifecycleState

func (t *Tester) SetLifecycleState(state ui.AppLifecycleState)

SetLifecycleState tells the framework that the app lifecycle state changed, as the platform would.

Flutter: flutter_test/lib/src/binding.dart TestWidgetsFlutterBinding.handleAppLifecycleStateChanged

func (*Tester) SetPlatformConfiguration

func (t *Tester) SetPlatformConfiguration(change func(c *ui.PlatformConfiguration))

SetPlatformConfiguration changes the system settings (locales, text scale, brightness, accessibility features) with the function and tells the framework.

Flutter: flutter_test/lib/src/window.dart TestPlatformDispatcher

func (*Tester) SetPrimaryText

func (t *Tester) SetPrimaryText(text string)

SetPrimaryText puts text on the fake primary selection, as another application would.

Flutter: no counterpart

func (*Tester) SetViewConfiguration

func (t *Tester) SetViewConfiguration(change func(c *ui.ViewConfiguration))

SetViewConfiguration changes the configuration of the view with the function, from the current one (sizes in physical pixels), and tells the framework.

Flutter: flutter_test/lib/src/window.dart TestFlutterView

func (*Tester) SetViewFocus

func (t *Tester) SetViewFocus(view ui.ViewID, focused bool, direction ...ui.ViewFocusDirection)

SetViewFocus tells the framework, as the platform would, that the keyboard focus moved into the view (true), or out of it, from the direction (undefined by default).

Flutter: no counterpart

func (*Tester) SetViewSize

func (t *Tester) SetViewSize(size ui.Size)

SetViewSize changes the size of the view, in logical pixels, and tells the framework as the platform would; the next Pump lays out again.

Flutter: flutter_test/lib/src/window.dart TestFlutterView.physicalSize

func (*Tester) SetWindowCreateError

func (t *Tester) SetWindowCreateError(err error)

SetWindowCreateError makes the platform fail to create windows with the error, or, with nil, create them again.

Flutter: no counterpart

func (*Tester) SetWindowInfo

func (t *Tester) SetWindowInfo(view ui.ViewID, info ui.WindowInfo)

SetWindowInfo tells the framework, as the platform would, what it now knows of the window of the view: who draws the title bar, and whether the window is maximized, fullscreen or activated.

Flutter: no counterpart

func (*Tester) SetWindowSize

func (t *Tester) SetWindowSize(view ui.ViewID, size ui.Size)

SetWindowSize tells the framework, as the platform would, that the content of the window of the view now has the size, in logical pixels.

Flutter: no counterpart

func (*Tester) ShowKeyboard

func (t *Tester) ShowKeyboard(f Finder) *widgets.EditableTextState

ShowKeyboard gives the focus to the text field the finder finds (or whose descendant it finds) and opens its input connection, as the tap on a field does. The test fails with the tag EnterTextNoField when the finder finds no EditableText.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetTester.showKeyboard

func (*Tester) Size

func (t *Tester) Size(f Finder) ui.Size

Size is the size of the render box of the one widget the finder finds.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetController.getSize

func (*Tester) StartGesture

func (t *Tester) StartGesture(at ui.Offset, opts ...GestureOpts) *TestGesture

StartGesture presses a pointer at the position (logical pixels) and returns the gesture to move and release it. A mouse is added first, as a real one would be. The tester runs the posted functions after the press (and after every move, up and cancel), as the await in Flutter's test gestures runs the microtasks: a recognizer alone in the arena wins at once.

Flutter: flutter_test/lib/src/controller.dart WidgetController.startGesture

func (*Tester) StartTrackpadGesture

func (t *Tester) StartTrackpadGesture(at ui.Offset) *TestTrackpadGesture

StartTrackpadGesture starts a pan/zoom gesture of a trackpad at the position (logical pixels). The tester runs the posted functions after every event, as StartGesture does.

Flutter: flutter_test/lib/src/test_pointer.dart TestPointer.panZoomStart

func (*Tester) TakeError

func (t *Tester) TakeError() error

TakeError returns the oldest error that the framework reported and that the test did not take yet, and forgets it; nil when there is none. A test that expects an error takes it and checks its tag.

Flutter: flutter_test/lib/src/binding.dart TestWidgetsFlutterBinding.takeException

func (*Tester) TakeErrors

func (t *Tester) TakeErrors() []error

TakeErrors returns all the errors that the framework reported and the test did not take yet, oldest first, and forgets them.

Flutter: flutter_test/lib/src/binding.dart TestWidgetsFlutterBinding.takeException

func (*Tester) Tap

func (t *Tester) Tap(f Finder, opts ...GestureOpts)

Tap taps the center of the one element the finder finds.

Flutter: flutter_test/lib/src/controller.dart WidgetController.tap

func (*Tester) TapAt

func (t *Tester) TapAt(at ui.Offset, opts ...GestureOpts)

TapAt presses and releases a pointer at the position, without time passing in between.

Flutter: flutter_test/lib/src/controller.dart WidgetController.tapAt

func (*Tester) TextInputStates

func (t *Tester) TextInputStates() []ui.TextInputState

TextInputStates are the states of the text field that the framework gave to the input method of the fake platform, in order: the last one is what the input method knows now.

Flutter: flutter_test/lib/src/test_text_input.dart TestTextInput

func (*Tester) TopLeft

func (t *Tester) TopLeft(f Finder) ui.Offset

TopLeft is the position of the top left corner of the one widget the finder finds, in logical pixels of the view.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetController.getTopLeft

func (*Tester) TrackpadFling

func (t *Tester) TrackpadFling(f Finder, by ui.Offset, speed float64)

TrackpadFling flings a trackpad from the center of the one element the finder finds.

Flutter: flutter_test/lib/src/controller.dart WidgetController.trackpadFling

func (*Tester) TrackpadFlingFrom

func (t *Tester) TrackpadFlingFrom(at, by ui.Offset, speed float64)

TrackpadFlingFrom starts a trackpad pan at the position and pans it by the offset in 50 steps at the speed (logical pixels per second), pumping between the steps, then ends it.

Flutter: flutter_test/lib/src/controller.dart WidgetController.trackpadFlingFrom

func (*Tester) ViewActions

func (t *Tester) ViewActions(view ui.ViewID) []ui.WindowAction

ViewActions are the actions that were asked of the window of a view (minimize, maximize, ...), in order.

Flutter: no counterpart

func (*Tester) ViewScenes

func (t *Tester) ViewScenes(view ui.ViewID) []*ui.Scene

ViewScenes are the scenes that the view rendered so far.

Flutter: no counterpart

func (*Tester) Widget

func (t *Tester) Widget(f Finder) widgets.Widget

Widget is the one widget the finder finds (see Element).

Flutter: flutter_test/lib/src/widget_tester.dart WidgetController.widget

func (*Tester) Widgets

func (t *Tester) Widgets(f Finder) []widgets.Widget

Widgets are the widgets the finder finds.

Flutter: flutter_test/lib/src/widget_tester.dart WidgetController.widgetList

func (*Tester) WindowActions

func (t *Tester) WindowActions() []ui.WindowAction

WindowActions are the actions that a title bar of the app asked of the window (move, resize, minimize, ...), in order.

Flutter: no counterpart

func (*Tester) WindowContentType

func (t *Tester) WindowContentType(view ui.ViewID) ui.ContentType

WindowContentType is the last content type hint the app set for the view.

Flutter: no counterpart

func (*Tester) WindowHidden

func (t *Tester) WindowHidden(view ui.ViewID) bool

WindowHidden is whether the app hid the window of the view (RegularWindowController.SetHidden): the implicit view's too.

Flutter: no counterpart

func (*Tester) WindowIcon

func (t *Tester) WindowIcon(view ui.ViewID) ui.WindowIcon

WindowIcon is the last icon the app set for the view; the zero icon if none.

Flutter: no counterpart

func (*Tester) Windows

func (t *Tester) Windows() []TestWindow

Windows are the windows that the app asked the platform for with the window controllers, in order, destroyed ones included. The implicit view is not one of them.

Flutter: no counterpart

type TextWidget

type TextWidget interface {
	widgets.Widget
	// PlainText is the text the widget shows, without styles.
	PlainText() string
}

TextWidget is implemented by a widget that shows text: Text, RichText and EditableText (steps 7.7 and 11.4). ByText and ByTextContaining match their PlainText.

Flutter: flutter_test/lib/src/finders.dart CommonFinders.text

type TooltipWidget

type TooltipWidget interface {
	widgets.Widget
	// TooltipMessage is the message the widget shows.
	TooltipMessage() string
}

TooltipWidget is implemented by the Tooltip widget (step 9.x): ByTooltip matches its message.

Flutter: flutter_test/lib/src/finders.dart CommonFinders.byTooltip

Jump to

Keyboard shortcuts

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