qa

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: EPL-2.0 Imports: 2 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 qa is the QA hook of a gowt app. A build with -tags gowtqa and GOWT_QA_SOCKET in the environment makes gowt.Run listen on that socket; package qa/qatest drives the app from go test. Without the tag the app has no server and no network code: Handle does nothing.

Index

Constants

View Source
const (
	EnvSocket = "GOWT_QA_SOCKET" // unix socket path; a QA build listens only when it is set
	EnvData   = "GOWT_QA_DATA"   // a private data directory for the app to use instead of the user's
)

Environment of a QA run, set by qatest.

View Source
const (
	EnvArtifacts = "GOWT_QA_ARTIFACTS" // directory for the shots, dump and logs of failed tests
	EnvKeep      = "GOWT_QA_KEEP"      // set: keep the app's socket, data and log directory after the run
)

Environment of the test process, read by qatest.

View Source
const ClipboardFile = "clipboard.json"

ClipboardFile is the name, in the app's data directory, of the clipboard of a QA run.

Variables

This section is empty.

Functions

func Handle

func Handle(name string, fn func(args Args) error)

Handle registers fn under name for qatest's State; fn runs on the UI thread. The name "reset" is the one qatest calls before each test. Without -tags gowtqa it does nothing.

func HandleValue

func HandleValue(name string, fn func(args Args) (any, error))

HandleValue is Handle for a handler that returns a value to the test, JSON encoded.

Types

type Args

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

Args are the key-value arguments a test passes to a handler.

func NewArgs

func NewArgs(raw json.RawMessage) (Args, error)

NewArgs wraps the raw JSON object a request carried; an empty or null raw is no arguments.

func (Args) Bool

func (a Args) Bool(key string) bool

func (Args) Decode

func (a Args) Decode(key string, v any) error

Decode reads the value of key into v; an absent key leaves v alone and is no error.

func (Args) Has

func (a Args) Has(key string) bool

Has reports whether the test passed key.

func (Args) Int

func (a Args) Int(key string) int

func (Args) String

func (a Args) String(key string) string

String, Int and Bool give the zero value when key is absent or of another type.

type Clipboard

type Clipboard struct {
	Text   string            `json:"text,omitempty"`
	RTF    string            `json:"rtf,omitempty"`
	HTML   string            `json:"html,omitempty"`
	URL    string            `json:"url,omitempty"`
	Image  []byte            `json:"image,omitempty"`
	Files  []string          `json:"files,omitempty"`
	Custom map[string][]byte `json:"custom,omitempty"`
}

Clipboard is what the clipboard of a QA run holds, as Client.Clipboard returns it and Client.SetClipboard takes it. The app's Clipboard reads and writes it instead of the system clipboard. An empty field means the format is not there. Image is PNG; Custom is by the first type name of a swt Transfer. It mirrors the struct in swt/qa_clipboard_manual.go.

type Dialog

type Dialog struct {
	Kind       string   `json:"kind"`
	Reply      any      `json:"reply,omitempty"`
	Cancel     bool     `json:"cancel,omitempty"`
	Title      string   `json:"title,omitempty"`
	Message    string   `json:"message,omitempty"`
	Buttons    []string `json:"buttons,omitempty"` // message: the buttons it offers
	Dir        string   `json:"dir,omitempty"`     // file, dir: where it opens
	Name       string   `json:"name,omitempty"`    // file: the proposed file name
	Save       bool     `json:"save,omitempty"`
	Multi      bool     `json:"multi,omitempty"`
	Filters    []string `json:"filters,omitempty"` // file: "Name|pattern"
	Unanswered bool     `json:"unanswered,omitempty"`
}

Dialog is a scripted answer for qatest's Answer, or a dialog the app asked for as Dialogs reports it. Kind is "message" (Window.MessageBox), "confirm" (Window.Confirm), "file" (FileDialog), "dir" (DirDialog), "color" (ColorDialog), "font" (FontDialog) or "print" (PrintDialog).

Reply by kind: a button name ("OK", "Cancel", "Yes", "No", "Retry", "Abort", "Ignore") for message; a bool for confirm; a path, or a list of paths for a Multi dialog, for file; a path for dir; "#rrggbb" for color; a Font object ({"Name": "Menlo", "Size": 12, "Bold": true}) for font; the path of the PDF file the job is written to for print. Cancel answers as the user who dismissed the dialog and needs no Reply.

In what Dialogs returns, Reply and Cancel are what the app received, and Unanswered marks a dialog with no scripted answer, which got Cancel.

type Job

type Job struct {
	Name       string `json:"name"`
	Background bool   `json:"background,omitempty"`
	Track      bool   `json:"track,omitempty"`
	ElapsedMS  int64  `json:"elapsed_ms"`
	Done       int    `json:"done,omitempty"`
	Total      int    `json:"total,omitempty"`
	Text       string `json:"text,omitempty"`
}

Job is one running Job or Track of the app, as the "jobs" command reports it; it mirrors gowt.JobInfo.

type Node

type Node struct {
	ID       string `json:"id,omitempty"`
	Class    string `json:"class"`
	Text     string `json:"text,omitempty"`
	Enabled  bool   `json:"enabled"`
	Visible  bool   `json:"visible"`
	Focused  bool   `json:"focused,omitempty"`
	Bounds   [4]int `json:"bounds"` // x, y, width, height in the coordinates of its window
	Checked  *bool  `json:"checked,omitempty"`
	Selected []int  `json:"selected,omitempty"`
	Value    string `json:"value,omitempty"`
	Path     string `json:"path"`
	Children []Node `json:"children,omitempty"`
}

Node is one control or item in a dump; it mirrors internal/qatree.Node.

type PinchEvent

type PinchEvent struct {
	X, Y          float64
	Magnification float64
	Phase         string // "", "began", "changed", "ended" or "cancelled"
	Mods          string
}

PinchEvent is one pinch step for Element.Pinch. Magnification is the change of the zoom: 0.1 makes it 10 percent larger, -0.1 smaller. X and Y are the point the zoom keeps in place.

type PointerEvent

type PointerEvent struct {
	Kind     string
	X, Y     float64
	Button   int
	Count    int
	Mods     string
	ToX, ToY float64 // drag: where the button is released
	Steps    int     // drag: moves before the release, 4 by default
}

PointerEvent is a mouse event for Element.Pointer, ClickAt, DoubleClickAt, RightClickAt and DragTo. X and Y are the point in the control's coordinates. A gfx view gets it through its input router, as the native events arrive; any other control gets the MouseDown, MouseUp, MouseMove (and MouseDoubleClick) events of its listeners, with no operating system event involved.

Kind is "down", "move" or "up" for one event, or "click" (down, up), "doubleclick" (down, up, down with Count 2, up) and "drag" (down, Steps moves on the way to ToX, ToY, up) for a sequence. Button is SWT's numbering, 1 left (the default), 2 middle, 3 right. Count is the click count of a down, 1 by default. Mods is "Shift", "Mod+Alt" and so on, as for Key without the key. A move needs no Button: the view reports the button held.

type ScrollEvent

type ScrollEvent struct {
	X, Y            float64
	DX, DY          float64
	Precise         bool
	Phase, Momentum string
	Mods            string
}

ScrollEvent is one scroll event for Element.ScrollEvent, delivered to a gfx view's input router. X and Y are the point in the control's coordinates. Without Precise the deltas are mouse wheel lines; with it, points as a trackpad reports them. Phase and Momentum are "", "mayBegin", "began", "changed", "ended" or "cancelled"; Momentum is the phase of the coasting after the fingers left. Mods is "Shift", "Mod+Alt" and so on, as for Key without the key; Mod with a wheel zooms.

type Selector

type Selector struct {
	ID     string    `json:"id,omitempty"`
	Class  string    `json:"class,omitempty"`
	Text   string    `json:"text,omitempty"`
	Within *Selector `json:"within,omitempty"`
}

Selector picks controls; it mirrors internal/qatree.Selector, which the client cannot import without linking the toolkit. An empty field matches anything.

func Class

func Class(class string) Selector

Class picks controls of an swt class: "Button", "Table", "TableItem", ...

func ID

func ID(id string) Selector

ID picks the control created with gowt.ID(id).

func Text

func Text(text string) Selector

Text picks controls showing text.

func (Selector) In

func (s Selector) In(parent Selector) Selector

In narrows s to the subtree of the one control parent picks.

Directories

Path Synopsis
Package qatest drives a QA build of a gowt app (go build -tags gowtqa) from go test.
Package qatest drives a QA build of a gowt app (go build -tags gowtqa) from go test.

Jump to

Keyboard shortcuts

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