mock

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2021 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package mock provides a mock widget to be used for testing the layout algorithms of container widgets.

Unlike most other widgets, the type for the element is also made public. Container widgets can therefore directly created instances, as if they were mounted, to test layout algorithms.

If used in a real GUI, the mock object will not create any controls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewIfNotZero

func NewIfNotZero(size base.Size) base.Element

NewIfNotZero returns a new mock element if the size is not zero, otherwise it returns the nil element.

func NewList

func NewList(sizes ...base.Size) []base.Element

NewList returns a slice of new mock elements.

Types

type Element

type Element struct {
	Size base.Size
	// contains filtered or unexported fields
}

Element is a mock element. Although this is a leaf element (i.e. it does not have any children), there is no control associated with this element.

func New

func New(size base.Size) *Element

New returns a new mock element.

func (*Element) Bounds

func (w *Element) Bounds() base.Rectangle

Bounds returns the position of the widget.

func (*Element) Close

func (w *Element) Close()

Close removes the widget from the GUI, and frees any associated resources. This is a no-op for a mock element.

func (*Element) Kind

func (*Element) Kind() *base.Kind

Kind returns the concrete type for the Element.

func (*Element) Layout

func (w *Element) Layout(bc base.Constraints) base.Size

Layout determines the best size for an element that satisfies the constraints. For a mock element, it will try to match the specific size in the field Size.

func (*Element) MinIntrinsicHeight

func (w *Element) MinIntrinsicHeight(base.Length) base.Length

MinIntrinsicHeight returns the minimum height that this element requires to be correctly displayed.

func (*Element) MinIntrinsicWidth

func (w *Element) MinIntrinsicWidth(base.Length) base.Length

MinIntrinsicWidth returns the minimum width that this element requires to be correctly displayed.

func (*Element) Props

func (w *Element) Props() base.Widget

Props recreates the widget description for this element.

func (*Element) SetBounds

func (w *Element) SetBounds(bounds base.Rectangle)

SetBounds updates the position of the widget.

func (*Element) UpdateProps

func (w *Element) UpdateProps(data base.Widget) error

UpdateProps will update the properties of the widget.

type Widget

type Widget struct {
	Size base.Size
	Err  error
}

Widget is a mock widget. When mounted, it will create a mock element.

func (*Widget) Kind

func (*Widget) Kind() *base.Kind

Kind returns the concrete type for use in the Widget interface. Users should not need to use this method directly.

func (*Widget) Mount

func (w *Widget) Mount(parent base.Control) (base.Element, error)

Mount creates an mock control.

Jump to

Keyboard shortcuts

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