Documentation ¶
Overview ¶
Package test provides utility drivers for running UI tests without rendering
Index ¶
- func ApplyTheme(t *testing.T, theme fyne.Theme)
- func AssertCanvasTappableAt(t *testing.T, c fyne.Canvas, pos fyne.Position) bool
- func AssertImageMatches(t *testing.T, masterFilename string, img image.Image, ...) bool
- func AssertNotificationSent(t *testing.T, n *fyne.Notification, f func())
- func Canvas() fyne.Canvas
- func DoubleTap(obj fyne.DoubleTappable)
- func Drag(c fyne.Canvas, pos fyne.Position, deltaX, deltaY int)
- func FocusNext(c fyne.Canvas)
- func FocusPrevious(c fyne.Canvas)
- func LaidOutObjects(o fyne.CanvasObject) (objects []fyne.CanvasObject)
- func MoveMouse(c fyne.Canvas, pos fyne.Position)
- func NewApp() fyne.App
- func NewClipboard() fyne.Clipboard
- func NewDriver() fyne.Driver
- func NewDriverWithPainter(painter SoftwarePainter) fyne.Driver
- func NewTheme() fyne.Theme
- func NewWindow(content fyne.CanvasObject) fyne.Window
- func Scroll(c fyne.Canvas, pos fyne.Position, deltaX, deltaY int)
- func Tap(obj fyne.Tappable)
- func TapAt(obj fyne.Tappable, pos fyne.Position)
- func TapCanvas(c fyne.Canvas, pos fyne.Position)
- func TapSecondary(obj fyne.SecondaryTappable)
- func TapSecondaryAt(obj fyne.SecondaryTappable, pos fyne.Position)
- func Type(obj fyne.Focusable, chars string)
- func TypeOnCanvas(c fyne.Canvas, chars string)
- func WidgetRenderer(wid fyne.Widget) fyne.WidgetRenderer
- func WithTestTheme(t *testing.T, f func())
- type SoftwarePainter
- type WindowlessCanvas
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyTheme ¶ added in v1.3.0
ApplyTheme sets the given theme and waits for it to be applied to the current app.
func AssertCanvasTappableAt ¶ added in v1.3.0
AssertCanvasTappableAt asserts that the canvas is tappable at the given position.
func AssertImageMatches ¶ added in v1.3.0
func AssertImageMatches(t *testing.T, masterFilename string, img image.Image, msgAndArgs ...interface{}) bool
AssertImageMatches asserts that the given image is the same as the one stored in the master file. The master filename is relative to the `testdata` directory which is relative to the test. The test `t` fails if the given image is not equal to the loaded master image. In this case the given image is written into a file in `testdata/failed/<masterFilename>` (relative to the test). This path is also reported, thus the file can be used as new master.
func AssertNotificationSent ¶ added in v1.3.0
func AssertNotificationSent(t *testing.T, n *fyne.Notification, f func())
AssertNotificationSent allows an app developer to assert that a notification was sent. After the content of f has executed this utility will check that the specified notification was sent.
func DoubleTap ¶ added in v1.4.0
func DoubleTap(obj fyne.DoubleTappable)
DoubleTap simulates a double left mouse click on the specified object.
func Drag ¶ added in v1.3.0
Drag drags at an absolute position on the canvas. deltaX/Y is the dragging distance: <0 for dragging up/left, >0 for dragging down/right.
func FocusPrevious ¶ added in v1.4.0
FocusPrevious focuses the previous focusable on the canvas.
func LaidOutObjects ¶ added in v1.3.0
func LaidOutObjects(o fyne.CanvasObject) (objects []fyne.CanvasObject)
LaidOutObjects returns all fyne.CanvasObject starting at the given fyne.CanvasObject which is laid out previously.
func NewApp ¶
NewApp returns a new dummy app used for testing. It loads a test driver which creates a virtual window in memory for testing.
func NewClipboard ¶
NewClipboard returns a single use in-memory clipboard used for testing
func NewDriverWithPainter ¶ added in v1.2.0
func NewDriverWithPainter(painter SoftwarePainter) fyne.Driver
NewDriverWithPainter creates a new dummy driver that will pass the given painter to all canvases created
func NewWindow ¶
func NewWindow(content fyne.CanvasObject) fyne.Window
NewWindow creates and registers a new window for test purposes
func Scroll ¶ added in v1.3.0
Scroll scrolls at an absolute position on the canvas. deltaX/Y is the scrolling distance: <0 for scrolling up/left, >0 for scrolling down/right.
func TapAt ¶ added in v1.2.0
TapAt simulates a left mouse click on the passed object at a specified place within it.
func TapSecondary ¶ added in v1.1.1
func TapSecondary(obj fyne.SecondaryTappable)
TapSecondary simulates a right mouse click on the specified object.
func TapSecondaryAt ¶ added in v1.2.0
func TapSecondaryAt(obj fyne.SecondaryTappable, pos fyne.Position)
TapSecondaryAt simulates a right mouse click on the passed object at a specified place within it.
func Type ¶
Type performs a series of key events to simulate typing of a value into the specified object. The focusable object will be focused before typing begins. The chars parameter will be input one rune at a time to the focused object.
func TypeOnCanvas ¶
TypeOnCanvas is like the Type function but it passes the key events to the canvas object rather than a focusable widget.
func WidgetRenderer ¶ added in v1.3.0
func WidgetRenderer(wid fyne.Widget) fyne.WidgetRenderer
WidgetRenderer allows test scripts to gain access to the current renderer for a widget. This can be used for verifying correctness of rendered components for a widget in unit tests.
func WithTestTheme ¶ added in v1.3.0
WithTestTheme runs a function with the testTheme temporarily set.
Types ¶
type SoftwarePainter ¶ added in v1.2.0
SoftwarePainter describes a simple type that can render canvases
type WindowlessCanvas ¶ added in v1.2.0
type WindowlessCanvas interface { fyne.Canvas FocusNext() FocusPrevious() Padded() bool Resize(fyne.Size) SetPadded(bool) }
WindowlessCanvas provides functionality for a canvas to operate without a window
func NewCanvas ¶
func NewCanvas() WindowlessCanvas
NewCanvas returns a single use in-memory canvas used for testing
func NewCanvasWithPainter ¶ added in v1.2.0
func NewCanvasWithPainter(painter SoftwarePainter) WindowlessCanvas
NewCanvasWithPainter allows creation of an in-memory canvas with a specific painter. The painter will be used to render in the Capture() call.