Documentation
¶
Overview ¶
Package nsgotest runs NSGo apps in Go tests, as net/http/httptest runs handlers: headless by default, with approximate text, a manual clock and every batch applied to a model of the native views that tests query; `nsgo test -target` runs the same tests on a platform, with its native input.
func TestAdd(t *testing.T) {
app := nsgotest.Start(t, Root)
app.Type("id:draft", "Milk")
app.Press("role:button Add")
app.Find("text:Milk")
}
Selectors name the views a user sees, in Playwright's manner:
id:<TestID> the view with that test ID
label:<Label> the view with that accessibility label
text:<text> a text, or a field holding it (its placeholder while empty), containing text
role:<role> a view with that role ("button", "checkbox", "textbox", ...)
role:<role> <name> one whose label is name, or whose texts contain it
view:<node> the view of that node ID, as traces print it
anything else a test ID, else a label, else a whole text
label:, text: and a role's name take /regexp/flags, with JavaScript's i, m and s flags. " >> " chains selectors, each part looking inside the views the last matched, and " >> nth=<i>" keeps one match. Matches come in the order a user finds them: the topmost modal's first, then the rest in tree order.
Steps act as a user does and send what a platform's input sends: Press is a finger down and up, Type a key at a time, Scroll a drag 10 points a frame. A step whose selector matches no view, or more than one it would act on, or a disabled one, fails the test. Each step then waits, moving the clock a frame at a time for at most 2 seconds, until no animation that ends runs.
Index ¶
- Constants
- func Main(m *testing.M)
- func Target() string
- type AnimatedProp
- type AnimatedValues
- type App
- func (a *App) AccessibilityAction(selector, name string)
- func (a *App) Advance(d time.Duration)
- func (a *App) Alerts() []driver.AlertConfig
- func (a *App) Animated(selector string) driver.ViewStyle
- func (a *App) AnimatedValue(node uint32) float64
- func (a *App) Answer(index int)
- func (a *App) AnswerScript(selector, result, errText string)
- func (a *App) Back()
- func (a *App) Bound(selector string) Bindings
- func (a *App) Capture() image.Image
- func (a *App) CapturePNG() []byte
- func (a *App) ChooseMenu(path ...string)
- func (a *App) ChoosePopup(path ...string)
- func (a *App) Clear(selector string)
- func (a *App) CloseGuide()
- func (a *App) ClosePopup()
- func (a *App) Commit(selector, text string)
- func (a *App) Compose(selector, text string)
- func (a *App) Drag(selector string, path ...driver.Point)
- func (a *App) DragAt(selector string, at driver.Point, path ...driver.Point)
- func (a *App) DragScroll(selector string, offset driver.Point, velocity float32)
- func (a *App) DropFiles(selector string, uris ...string)
- func (a *App) Dump() string
- func (a *App) Emit(selector, name string, data any)
- func (a *App) Enabled(selector string) bool
- func (a *App) EndSpeech(err string)
- func (a *App) Exists(selector string) bool
- func (a *App) FastForward(d time.Duration)
- func (a *App) Find(selector string) *View
- func (a *App) FindMounted(selector string) *View
- func (a *App) Focus(selector string)
- func (a *App) GrantPermission(p core.Permission)
- func (a *App) HeaderBack(selector string)
- func (a *App) HearSpeech(text string, final bool)
- func (a *App) Hover(selector string)
- func (a *App) HoverAt(selector string, at driver.Point)
- func (a *App) HoverOut()
- func (a *App) Key(key string)
- func (a *App) KeyPress(selector, key string)
- func (a *App) Load(selector string, pixels driver.Size)
- func (a *App) LongPress(selector string)
- func (a *App) Mark(name string)
- func (a *App) Navigate(selector string, nav driver.WebNavigation)
- func (a *App) Pan(selector string, translations ...driver.Point)
- func (a *App) Paste(selector string, p driver.PasteEvent)
- func (a *App) Pinch(selector string, scales ...float32)
- func (a *App) PinchZoom(selector string, scale float32)
- func (a *App) Play(selector string, info core.VideoInfo)
- func (a *App) Post(fn func())
- func (a *App) PostMessage(selector, data string)
- func (a *App) PostMessageFrom(selector, url string, mainFrame bool, data string)
- func (a *App) PresentModal(selector string, size driver.Size, insets driver.Edges)
- func (a *App) Press(selector string)
- func (a *App) PressAt(selector string, at driver.Point)
- func (a *App) PressDown(selector string)
- func (a *App) PressNotification(id string)
- func (a *App) PressUp(selector string)
- func (a *App) Progress(selector string, position, duration time.Duration)
- func (a *App) PullToRefresh(selector string)
- func (a *App) Query(selector string) []*View
- func (a *App) QueryMounted(selector string) []*View
- func (a *App) Report(ev driver.Event)
- func (a *App) Resize(width, height driver.Points)
- func (a *App) RevokeOverlayPermission()
- func (a *App) RightClick(selector string)
- func (a *App) Rotate(selector string, angles ...float32)
- func (a *App) Screenshot(name string)
- func (a *App) Scroll(selector string, distance driver.Points)
- func (a *App) ScrollTo(selector string, offset driver.Point)
- func (a *App) Select(selector string, start, end int)
- func (a *App) SelectText(selector string, box driver.Bounds)
- func (a *App) SetEnvironment(env driver.Environment)
- func (a *App) Settle()
- func (a *App) Span(selector string) driver.TextSpan
- func (a *App) SpanStyle(selector string) driver.TextStyle
- func (a *App) Storage() core.Storage
- func (a *App) Submit(selector string)
- func (a *App) SwipeClose(selector string)
- func (a *App) Texts() []string
- func (a *App) Touch(selector string, at driver.Point) *Finger
- func (a *App) TouchpadScroll(selector string, velocity driver.Point, deltas ...driver.Point)
- func (a *App) Type(selector, text string)
- func (a *App) WaitFor(selector string, timeout time.Duration) *View
- func (a *App) WaitForGone(selector string, timeout time.Duration)
- func (a *App) WaitUntil(timeout time.Duration, cond func() bool)
- func (a *App) Wheel(selector string, delta driver.Point, mods driver.Modifiers)
- type AudioPlayer
- type AwakeHold
- type Bindings
- type Channel
- type Event
- type EventKind
- type EventMask
- type Finger
- type ImageConfig
- type InputConfig
- type Microphone
- type ModalConfig
- type NativeCommand
- type Option
- func Environment(env driver.Environment) Option
- func Errors(report func(error)) Option
- func Host(h *core.Host) Option
- func HotKeyTaken(keys ...string) Option
- func HotKeyUnsupported(keys ...string) Option
- func ManualFrames() Option
- func Measure() Option
- func MicrophoneInput(m *Microphone) Option
- func NoCaretMoves() Option
- func Offscreen() Option
- func PendingAlerts() Option
- func Size(width, height driver.Points) Option
- func Storage(entries map[string]string) Option
- func TextEngine(e driver.TextEngine) Option
- type Overlay
- type Pictures
- type Recorded
- type ScreenConfig
- type ScrollConfig
- type ScrollEdge
- type Shader
- type ShaderNode
- type ShaderRole
- type Sound
- type StatusBarConfig
- type TextBackground
- type TextSpan
- type TextStyle
- type VideoConfig
- type View
- type ViewKind
- type ViewProps
- type ViewStyle
- type WebCommand
- type WebCommandKind
- type WebConfig
Constants ¶
const ( PropOpacity = driver.PropOpacity PropTranslateX = driver.PropTranslateX PropTranslateY = driver.PropTranslateY PropScale = driver.PropScale PropScaleX = driver.PropScaleX PropScaleY = driver.PropScaleY PropRotate = driver.PropRotate PropBackground = driver.PropBackground PropBorderColor = driver.PropBorderColor PropShadowColor = driver.PropShadowColor PropShadowRadius = driver.PropShadowRadius PropShadowOpacity = driver.PropShadowOpacity PropTextColor = driver.PropTextColor PropRotateX = driver.PropRotateX PropRotateY = driver.PropRotateY PropCount = driver.PropCount )
const ( EventPress = driver.EventPress EventPressDown = driver.EventPressDown EventPressUp = driver.EventPressUp EventLongPress = driver.EventLongPress EventMouseEnter = driver.EventMouseEnter EventMouseLeave = driver.EventMouseLeave EventFocus = driver.EventFocus EventBlur = driver.EventBlur EventChangeText = driver.EventChangeText EventSubmitEditing = driver.EventSubmitEditing EventScroll = driver.EventScroll EventLoadStart = driver.EventLoadStart EventProgress = driver.EventProgress EventLoad = driver.EventLoad EventError = driver.EventError EventLoadEnd = driver.EventLoadEnd EventPressOutside = driver.EventPressOutside EventBack = driver.EventBack EventAlert = driver.EventAlert EventClipboard = driver.EventClipboard EventContextMenu = driver.EventContextMenu EventKey = driver.EventKey EventPan = driver.EventPan EventPinch = driver.EventPinch EventWheel = driver.EventWheel EventRotation = driver.EventRotation EventMenu = driver.EventMenu EventMessage = driver.EventMessage EventEnd = driver.EventEnd EventBuffer = driver.EventBuffer EventFileDragEnter = driver.EventFileDragEnter EventFileDragLeave = driver.EventFileDragLeave EventFileDrop = driver.EventFileDrop EventNative = driver.EventNative EventNativeSize = driver.EventNativeSize EventAnimation = driver.EventAnimation EventScrollDragStart = driver.EventScrollDragStart EventScrollDragEnd = driver.EventScrollDragEnd EventMomentumStart = driver.EventMomentumStart EventMomentumEnd = driver.EventMomentumEnd EventRefresh = driver.EventRefresh EventImageInfo = driver.EventImageInfo EventSelectionChange = driver.EventSelectionChange EventKeyPress = driver.EventKeyPress EventCompositionChange = driver.EventCompositionChange EventAccessibilityAction = driver.EventAccessibilityAction EventRequestClose = driver.EventRequestClose EventModalSize = driver.EventModalSize EventMouseMove = driver.EventMouseMove EventTouch = driver.EventTouch EventCaretMove = driver.EventCaretMove EventPaste = driver.EventPaste )
const ( ShaderFill = driver.ShaderFill ShaderEffect = driver.ShaderEffect ShaderTransition = driver.ShaderTransition ShaderScreen = driver.ShaderScreen ShaderScreenTransition = driver.ShaderScreenTransition PictureContent = driver.PictureContent PictureBackdrop = driver.PictureBackdrop PictureFrom = driver.PictureFrom PictureTo = driver.PictureTo )
const ( KindView = driver.KindView KindText = driver.KindText KindInput = driver.KindInput KindScroll = driver.KindScroll KindImage = driver.KindImage KindModal = driver.KindModal KindCanvas = driver.KindCanvas KindWeb = driver.KindWeb KindVideo = driver.KindVideo KindNative = driver.KindNative KindShader = driver.KindShader )
const ( WebReload = driver.WebReload WebGoBack = driver.WebGoBack WebGoForward = driver.WebGoForward WebStopLoading = driver.WebStopLoading WebPostMessage = driver.WebPostMessage WebInjectJavaScript = driver.WebInjectJavaScript )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AnimatedProp ¶
type AnimatedProp = driver.AnimatedProp
AnimatedProp is a view property an animated node drives.
type AnimatedValues ¶
type AnimatedValues = driver.AnimatedValues
AnimatedValues are the bound properties of a view, as the animator last evaluated them.
type App ¶
type App struct {
// Clipboard is the clipboard's text, ClipboardImage its image as the
// app last set it or reads it (a read of what is no PNG fails), and ClipboardFiles the file: URLs it
// holds; Announced what screen readers were asked to say.
Clipboard string
ClipboardImage []byte
ClipboardFiles []string
Announced []string
// InputSource is the keyboard input source the app selected, as a
// test sees it; inputSourceWas the one that selection replaced.
InputSource string
// Speech is the speech session running, nil without one, which
// HearSpeech and EndSpeech report to; sessions end unavailable unless
// the environment says Speech.
Speech *driver.SpeechRequest
// OpenedURLs are the URLs the app opened, oldest first. OpenURL
// answers whether each opens; every one does when it is nil.
OpenedURLs []string
OpenURL func(url string) bool
// UpdateChecks are the checks for a newer version the app asked the
// platform's updater for (updater.Check), oldest first, true for one
// in the background. Update answers each with what the updater found;
// with none the app is the newest.
UpdateChecks []bool
Update func(background bool) core.UpdateCheck
// Picks are the photo picks the app asked for, oldest first.
// PickImages answers each with the files the user picks; with none
// the user cancels.
Picks []driver.PickRequest
PickImages func(r driver.PickRequest) []driver.PickedFile
// Photos are the photos the app asked to take, oldest first, where
// the environment says Camera. TakePhoto answers each with the photo
// the user takes, or with why it failed; with none the user cancels.
Photos []driver.PickRequest
TakePhoto func(r driver.PickRequest) (*driver.PickedFile, error)
// PickScreenColor answers Scope.PickScreenColor with the color the user
// samples; without it, or with false, the user cancels.
PickScreenColor func() (driver.Color, bool)
// FilePicks are the file picks the app asked for, oldest first.
// PickFiles answers each with the files the user picks; with none
// the user cancels.
FilePicks []driver.FilesRequest
PickFiles func(r driver.FilesRequest) []driver.File
// DirectoryPicks are the folder picks the app asked for, oldest
// first. PickDirectories answers each with the folders the user
// picks; with none the user cancels.
DirectoryPicks []driver.DirectoriesRequest
PickDirectories func(r driver.DirectoriesRequest) []driver.Directory
// Saves are the saves the app asked for, oldest first. SaveFile
// answers each with the path the user saves to, where the file is
// written; with none, or "", the user cancels.
Saves []driver.SaveRequest
SaveFile func(r driver.SaveRequest) string
// OpenedFiles are the files the app opened in other apps, oldest
// first. OpenFile answers whether an app opens each; every one does
// when it is nil.
OpenedFiles []driver.SharedFile
OpenFile func(f driver.SharedFile) bool
// RevealedFiles records paths shown in the system file manager. RevealFile
// answers whether the manager accepted each request; nil accepts all.
RevealedFiles []string
RevealFile func(path string) bool
// TrashedFiles records paths moved to the system trash. TrashFile returns the path in the trash, or "" as Linux does, and an error, which may be core.ErrNoTrash; nil trashes each with no path.
TrashedFiles []string
TrashFile func(path string) (string, error)
// shows.
Shares []driver.ShareRequest
// Installs are the packages the app handed Android's installer,
// oldest first; each installer starts. InstallAllowed is what
// CanInstallPackages answers, and InstallSettings counts the times the
// app opened the setting, which opens.
Installs []driver.SharedFile
InstallAllowed bool
InstallSettings int
// Notifications are the notifications showing, oldest first, one of
// an ID replacing the one before; Badge is the count on the app's
// icon. NotificationPermission is what the platform answers whether
// the app may show them with, the user not asked at first; a request
// while not asked makes it NotificationAnswer, the user granting it
// when that is zero. Only a granted app shows them.
Notifications []core.Notification
Badge int
// TaskProgress is the last task progress sent by the app. A zero value
// means the indicator is cleared.
TaskProgress core.TaskProgress
NotificationPermission core.NotificationPermission
NotificationAnswer core.NotificationPermission
// BiometricAvailability is the enrolled biometric the test platform
// reports. BiometricAnswer is the result of each authentication request;
// zero makes it unavailable. AuthenticationReasons records prompts.
BiometricAvailability core.BiometricKind
BiometricAnswer core.BiometricResult
AuthenticationReasons []string
// Permissions is each permission's status as the platform answers it, PermissionNotAsked for one it does not hold; a request while not asked makes it PermissionAnswers' for it, the user granting it when that has none. Start makes both maps. PermissionSettings are the permissions whose settings the app opened, oldest first, and Guide the permission a guide shows, "" for none: GrantPermission and CloseGuide end it.
Permissions map[core.Permission]core.PermissionStatus
PermissionAnswers map[core.Permission]core.PermissionStatus
PermissionSettings []core.Permission
Guide core.Permission
// Awake is the keep-awake holds the app keeps, oldest first, each gone once released. AwakeHolds records every hold the app took and AwakeReleases the IDs of the holds it released, oldest first. None changes the test machine's power state.
Awake []AwakeHold
AwakeHolds []AwakeHold
AwakeReleases []uint32
// OverlayPermission is what the platform answers whether the app may show overlays over other apps with (mobile.OverlayPermission), denied at first, as Android's special access is. A request while denied opens the setting, which OverlaySettings counts, and makes it OverlayAnswer, which the test sets to OverlayGranted for a user who grants it. Overlay is the overlay the app opened last, kept once it closed; RevokeOverlayPermission takes the grant away.
OverlayPermission core.OverlayPermission
OverlayAnswer core.OverlayPermission
OverlaySettings int
Overlay *Overlay
// AudioDurations are the lengths of the audio the platform decodes, by a source's URI or, for bytes, their string; a source missing from it fails with audio.Decode, and a sound is cut at 5 seconds, as a platform cuts it. RefusePlayback has every player's play fail with audio.NotAllowed, as a browser's before a user gesture. Sounds are the sounds the platform decoded and Players the players the app opened, oldest first, where the environment says Audio; a player plays only as Advance moves the clock.
AudioDurations map[string]time.Duration
RefusePlayback bool
Sounds []*Sound
Players []*AudioPlayer
// OnAlert answers each alert the app shows with the index of the
// button the user presses, or -1 to dismiss it, once the step that
// showed it ends. Without it Alerts lists them and Answer answers
// them; one still unanswered when the next step starts gets its
// default answer: its cancel button, else dismissed when cancelable,
// else the step fails.
OnAlert func(driver.AlertConfig) int
// Appearance is the appearance the app last forced; Quits how often
// it asked to quit, Restarts how many of those restart it;
// BackUnhandled how many backs nothing took, which leave an Android
// app.
Appearance driver.Appearance
Quits int
Restarts int
BackUnhandled int
// PopupMenu is the context menu the app shows with PopupMenu, at
// PopupAt; nil once it closed.
PopupMenu []driver.MenuEntry
PopupAt driver.Point
// AccessibilityFocus is the view the app last moved the screen
// reader's focus to.
AccessibilityFocus *View
// Keymap is the keyboard shortcuts the app binds; Title its title.
Keymap []string
Title string
// Language is the language the platform labels its menus in, and
// LanguageForced whether the app forces it (core.Scope.SetLocale),
// which Apple platforms keep for the system's words in later launches.
Language string
LanguageForced bool
// Menu is the application menu the app set; Window the window
// commands it sent, oldest first.
Menu []driver.MenuEntry
Window []driver.WindowCommand
// ImageSizes are the pixel sizes of the images the model's platform
// loads, by URI, which answer Scope.ImageSize; others fail to load.
ImageSizes map[string]driver.Size
Clock *core.ManualClock
// StatusBar is the status bar the app last set.
StatusBar driver.StatusBarConfig
// LayoutAnimation is the layout animation the last batch to carry
// one asked the platform for.
LayoutAnimation *driver.LayoutAnimation
// contains filtered or unexported fields
}
App is an app running in a test. Its methods run on the test's goroutine; the app's goroutines reach it through Scope.Post, which App runs when it settles.
func Start ¶
Start runs app and settles it; the test's cleanup disposes it. Under `nsgo test -target` it opens the app on that platform instead.
func (*App) AccessibilityAction ¶
selector matches, as a screen reader would: an action the view offers, or ActionActivate on a pressable view without it, which presses it.
func (*App) Advance ¶
Advance moves the clock by d, runs the timers and display frames that come due and settles. A frame runs every FrameInterval while the app waits for one, as a display's frames do. Measuring on a target, it waits d.
func (*App) Alerts ¶
func (a *App) Alerts() []driver.AlertConfig
Alerts returns the alerts shown and not answered yet, oldest first.
func (*App) Animated ¶
Animated returns the style the view selector matches shows: its own, with the animated values bound to it drawn over it as the platform's animator has them.
func (*App) AnimatedValue ¶
AnimatedValue returns animated value node's value as the platform's animator has it.
func (*App) AnswerScript ¶
AnswerScript answers the oldest Ref.Evaluate the web view selector matches still waits for, as its page would: with result, JSON, or when errText is set the error the script threw.
func (*App) Back ¶
func (a *App) Back()
Back goes back as Escape, the back button or the back gesture does.
func (*App) Bound ¶
Bound returns the animated values the gestures or the scrolling of the view selector matches set (AnimBindPan, ...), which AnimatedValue reads.
func (*App) Capture ¶
Capture captures the app as the platform shows it and decodes its PNG. Its pixels are in the colour space of the display the app is on, Display P3 on a Mac with a P3 display: the PNG names it in its colour profile, which image/png ignores, so a colour read from the image is that space's and not sRGB's, and Capture does not convert it. Headless runs skip the test because they have no native pixels.
func (*App) CapturePNG ¶
CapturePNG captures the app as the platform shows it and returns its PNG, whose colour profile is the display's, as Capture's pixels are. Headless runs skip the test because they have no native pixels.
func (*App) ChooseMenu ¶
ChooseMenu chooses the application menu item at path, its labels from the menu bar down, such as "File", "New". the menu bar down, such as "File", "New".
func (*App) ChoosePopup ¶
ChoosePopup chooses the item at path in the context menu the app shows with PopupMenu, its labels from the menu down, which closes the menu.
func (*App) Clear ¶
Clear empties the field selector names, as selecting all and deleting does: one KeyPress of Backspace and an edit to nothing.
func (*App) CloseGuide ¶
func (a *App) CloseGuide()
CloseGuide has the user close the guide's panel or the system's settings, which ends the guide, and settles.
func (*App) ClosePopup ¶
func (a *App) ClosePopup()
ClosePopup closes the context menu the app shows without choosing an item, as Escape or a click elsewhere does.
func (*App) Commit ¶
Commit has the input method composing in the field selector names commit text, ending its composition: the Type of text, then the composition's end, or the platform's commit under nsgo test -target.
func (*App) Compose ¶
Compose has an input method compose text in the field selector names; "" ends the composition, after the Type of what it commits, or Commit commits it. While it lasts the field holds the values the app sets, as platforms do. Under nsgo test -target it goes through the platform's text input client, as an input method's does.
func (*App) Drag ¶
Drag puts a finger on the middle of what selector names, rests it there for 100 ms, moves it through each point of path in turn (offsets from where it landed) 10 points a display frame, and lifts it, as the platforms decide what takes it: the views listening to touches hear them, past the slop a pan or the scroll view the drag runs along takes it unless the touch responder holds it, and the press under the finger is cancelled once it moves away. The clock moves with the frames.
func (*App) DragAt ¶
DragAt drags as Drag does from a point of the view selector matches, in its coordinates, rather than its middle: for what a finger takes by a part of its own, such as a selection's handle.
func (*App) DragScroll ¶
DragScroll drags the scroll view selector matches to offset at once and lets go at velocity (points per second along its axis, positive as the offset grows), as a platform does: the drag's events, then the glide or the snap its ScrollBehavior decides, clamped to its content and insets.
func (*App) DropFiles ¶
DropFiles drops files on the view selector matches, as a desktop or the web does: the drag enters, then the files drop. the web does: the drag enters, then the files drop.
func (*App) Dump ¶
Dump returns the visible views as an indented outline, for failure messages and golden files.
func (*App) Emit ¶
Emit reports that the component of the native view selector matches emitted name with data. The view need only be mounted: headless, a component that sizes itself, such as the system's tab bar, has no size.
func (*App) Enabled ¶
Enabled reports whether the one view selector matches takes input: neither it nor a view around it is disabled, and an input is editable.
func (*App) EndSpeech ¶
EndSpeech ends the session running with what it heard, and err, one of driver's Speech errors or "" for none, and settles.
func (*App) FastForward ¶
FastForward jumps the clock ahead by d, as a laptop closed for a while and opened: each timer that comes due on the way runs once, at the end, and so does one display frame.
func (*App) FindMounted ¶
FindMounted returns the one view selector matches among every view mounted, shown or not: hidden, empty, scrolled away or clipped, as a test reading what the platform received of a view finds it.
func (*App) Focus ¶
Focus puts the keyboard focus on the selector's focus stop: the text field the match is or holds, focused as a tap would, else the pressable or Focusable view the match is or is in, else the first one inside it, reached by pressing Tab from where the focus is, so a following Return or Space presses it. Only macOS and the web give views other than fields the keyboard focus, so elsewhere, headless outside a macOS or web environment included, such a view fails the step, as a disabled or read-only match and a NoFocus view do.
func (*App) GrantPermission ¶
func (a *App) GrantPermission(p core.Permission)
GrantPermission has the user turn p on in the system's settings, which ends a guide of p, and settles.
func (*App) HeaderBack ¶
HeaderBack presses the back button in the system header of the screen selector matches, as iOS and Android draw it.
func (*App) HearSpeech ¶
HearSpeech has the recognizer of the session running hear text, the whole transcript so far, final once it will not change it, and settles.
func (*App) Hover ¶
Hover moves the mouse over the middle of what selector names, as a desktop's pointer does: the views from it out that hover matters to (hover styles or hover events) replace those hovered before, which hear MouseLeave, the new ones MouseEnter, and each hovered view MouseMove.
func (*App) HoverAt ¶
HoverAt moves the mouse over what selector names as Hover does, to at in its coordinates: a chart's row under the pointer.
func (*App) HoverOut ¶
func (a *App) HoverOut()
HoverOut moves the mouse out of the surface: every view hovered hears MouseLeave.
func (*App) Key ¶
Key presses a key on a hardware keyboard, as the app's keymap reads it ("mod+s", "Escape", "a"): a binding of the keymap fires, unless the focused view uses the key itself as on a device (core.KeyAuto), a field its editing keys, a pressable view Return and Space, a slider or a tab bar its arrows; else, in a macOS or web environment, Tab and Shift+Tab move the keyboard focus between fields and pressable views, and Return or Space press the pressable view it is on; else the focused field takes a character, Backspace or Enter; else Escape goes back. A key nothing takes does nothing, as on a device.
func (*App) KeyPress ¶
KeyPress types key in the field selector names, as a key the user presses: its text, "Backspace" or "Enter". It reports the key, then edits the end of the text as the key would; Enter is the return key.
func (*App) Load ¶
Load reports that the image selector matches loaded at pixels. An image that takes its size from what it loads matches before, at no size.
func (*App) LongPress ¶
LongPress holds a finger on what selector names, or the nearest view around it that hears long presses, presses or touches or selects text (a selection area, or a selectable text), for its DelayLongPress (500 ms by default) of the clock's time, as a long press does: PressDown, LongPress, then PressUp, and no Press.
func (*App) Mark ¶
Mark names what the performance monitor's readings measure from here on, a line of nsgo test -fps's output among them ("perf mark name"); "-" ends it. It logs as the monitor does, so the two keep their order.
func (*App) Navigate ¶
func (a *App) Navigate(selector string, nav driver.WebNavigation)
Navigate reports that the web view selector matches loaded the page nav describes, as a platform does: it starts loading, then loads.
func (*App) Pan ¶
Pan drags the view selector matches, or the one around it or under its middle with a pan, through each translation in turn, then lets go.
func (*App) Paste ¶
func (a *App) Paste(selector string, p driver.PasteEvent)
Paste pastes into the field selector names as the user would: the field hears it with OnPaste, then, unless its PasteBehavior is PasteReport, the text goes in at its end.
func (*App) Pinch ¶
Drag puts a finger down at the middle of the view selector matches, moves it there plus each offset in turn, 16 ms apart, and lifts it, as the platform reports touches: OnTouch and the touch responder hear it. Pinch pinches the view selector matches, or the one around it with a pinch, through each scale in turn.
func (*App) PinchZoom ¶
PinchZoom zooms the zoomable scroll view selector matches to scale, as a user's pinch does, within its limits.
func (*App) Play ¶
Play reports that the video selector matches opened and loaded info, as a platform does: it starts loading, then loads.
func (*App) Post ¶
func (a *App) Post(fn func())
Post runs fn on the test's goroutine as the next step or wait settles: what another goroutine hands the test, as a stubbed request does.
func (*App) PostMessage ¶
PostMessage reports that the page the web view selector matches loaded posted data, from its top frame: at its Src, its HTML's BaseURL, or about:blank for HTML without one.
func (*App) PostMessageFrom ¶
PostMessageFrom reports that a frame at url, the page's top one when mainFrame is set, posted data in the web view selector matches, as a page the view navigated to or a frame within it would, from url's origin.
func (*App) PresentModal ¶
PresentModal reports that the platform presents the modal around what selector matches at size, with insets covered, as an iOS sheet does.
func (*App) Press ¶
Press presses what selector names, or the pressable view around it, as a tap does: a finger goes down and lifts on its middle, which the views listening to touches hear and presses outside the overlays it is not in report, while the view hears PressDown, PressUp and Press. On a platform, a native component's view, such as the system's switch, takes the press itself.
func (*App) PressAt ¶
PressAt presses the view selector matches at a point in it, or what is pressable there, as Press does its middle: for what finds its own targets under the pointer, such as a canvas.
func (*App) PressDown ¶
PressDown starts a press on the view selector matches, or the pressable view around it, and holds it until PressUp.
func (*App) PressNotification ¶
PressNotification has the user press the notification called id, which goes as the system takes it away, and settles.
func (*App) Progress ¶
Progress reports that the video selector matches played to position: its progress, then its end when position reaches duration.
func (*App) PullToRefresh ¶
PullToRefresh pulls the refreshable scroll view selector matches down past its top, as a user does to refresh it.
func (*App) Query ¶
Query returns the visible views selector matches, the topmost modal's first, then the rest in tree order.
func (*App) QueryMounted ¶
QueryMounted returns the views selector matches among every view mounted, shown or not, in tree order.
func (*App) Report ¶
Report sends ev as the platform reports it and settles: an event the steps here do not make. Platforms report most kinds only to views whose Events ask for them, which the test checks.
func (*App) RevokeOverlayPermission ¶
func (a *App) RevokeOverlayPermission()
RevokeOverlayPermission takes the app's permission to show overlays away, as the user does in the system's settings: an overlay open ends, OverlayEndRevoked, and settles.
func (*App) RightClick ¶
RightClick sends a secondary click to the view selector matches, or the one around it that listens, as a desktop's mouse does.
func (*App) Rotate ¶
Rotate rotates the view selector matches, or the one around it with a rotation, through each angle in radians in turn.
func (*App) Screenshot ¶
Screenshot captures the app as the platform shows it. name is a relative path under the directory `nsgo test -target` saves screenshots to; its extension is optional and .png is added when absent. Headless runs have no pixels and keep the historical log-only behavior.
func (*App) Scroll ¶
Scroll drags the scroll view selector names (the match, the nearest scroll view around it, else the first in it) by distance points along its axis, 10 points a display frame within its content, as a finger does: ScrollDragStart, the offsets as platforms report them, then ScrollDragEnd. It fails when the view cannot move that way at all or the user cannot scroll it.
func (*App) ScrollTo ¶
ScrollTo reports that the scroll view selector matches is at offset, as a platform reports where it is; it moves no finger.
func (*App) Select ¶
Select moves the selection of the field selector names, as the user would, in UTF-16 units.
func (*App) SelectText ¶
SelectText has the selection of the Selectable view selector names touch box of its texts, no Size clearing it, as the platforms report it.
func (*App) SetEnvironment ¶
func (a *App) SetEnvironment(env driver.Environment)
SetEnvironment reports env as a platform would and settles.
func (*App) Settle ¶
func (a *App) Settle()
Settle runs what the app's goroutines posted and applies the commits that follow, until nothing is left.
func (*App) Span ¶
Span returns the span of the characters selector names in a text, as SpanStyle finds them: its style and what it draws behind them; the text's own style where no span sets one.
func (*App) SpanStyle ¶
SpanStyle returns the resolved style of the characters selector names in a text: "text:<chars>" (or a chain ending in it) finds the text that shows them, and the style is that of their first character, as a span sets it over the text's.
func (*App) Storage ¶
Storage returns the app's storage, to read what it kept or change it as another of the app's windows would.
func (*App) Submit ¶
Submit presses Return in the field selector names, as its SubmitBehavior says: SubmitEditing, after which the focus leaves a single-line field by default, or a line break in a multiline field.
func (*App) SwipeClose ¶
SwipeClose swipes away the modal around what selector matches, as an iOS sheet is: the platform closes it and asks the app to remove it ("swipe").
func (*App) Touch ¶
Touch puts a finger down at at, in the coordinates of the view selector names, and reports it there.
func (*App) TouchpadScroll ¶
TouchpadScroll scrolls two fingers on a touchpad over the middle of the view selector matches, or the one around it that takes the wheel, moving the content by each delta in turn, and lifts them at velocity, which the platform's momentum follows when zero. On a target it is the platform's trackpad gesture by the deltas' sum, without momentum.
func (*App) Type ¶
Type types text at the end of the field selector names (the match or the first field in it), as a keyboard does: the field takes the focus, then each character is a key (KeyPress) and an edit (ChangeText); a line break in a single-line field is the return key, as Submit. A character past MaxLength is dropped.
func (*App) WaitFor ¶
WaitFor settles until selector matches a view, failing the test after timeout of real time. Use it for work on other goroutines.
func (*App) WaitForGone ¶
WaitForGone settles until no view matches selector, failing the test after timeout of real time.
type AudioPlayer ¶
type AudioPlayer struct {
Source core.AudioSource
Session core.AudioSession
// Commands are what the app asked of it, by name: open, preload, resume, pause, seek, set and close.
Commands []string
// Position is where it is, and Duration how long it plays once Loaded; Volume, Rate and Loop are how it plays, Playing whether it does and Closed whether the app closed it.
Position, Duration time.Duration
Volume, Rate float32
Loop bool
Loaded bool
Playing bool
Closed bool
// contains filtered or unexported fields
}
AudioPlayer is a player the app opened.
type AwakeHold ¶
AwakeHold is a keep-awake hold the app took: the ID its release names in AwakeReleases, and what it asked for.
type Bindings ¶
type Bindings struct {
PanX, PanY, ScrollX, ScrollY, Pinch, Rotation, Pull uint32
}
Bindings are the animated values, by node, a view's gestures and scrolling set; 0 is none.
type Finger ¶
type Finger struct {
// contains filtered or unexported fields
}
Finger is a finger a test puts down with Touch and moves a step at a time, as Drag does in one: the views listening to touches hear it, presses and the touch responder follow it, and past the slop a pan or a scroll view may take it.
func (*Finger) Cancel ¶
func (g *Finger) Cancel()
Cancel ends the finger as the system does when it takes the touches: no press.
func (*Finger) Lift ¶
func (g *Finger) Lift()
Lift lifts the finger, where it is: a tap where it went down presses.
type ImageConfig ¶
type ImageConfig = driver.ImageConfig
ImageConfig is an image view's source and look.
type InputConfig ¶
type InputConfig = driver.InputConfig
InputConfig is a text field's look and behavior.
type Microphone ¶
type Microphone struct {
// Denied refuses the app the microphone: Authorize and RecordWAV answer microphone.ErrDenied.
Denied bool
// Rate is the rate the fake records at whatever the app asks, as a device with only its own does; 0 records at the rate asked, or 48 kHz.
Rate int
// contains filtered or unexported fields
}
Microphone is a fake recorder for package microphone's RecordWAV, Authorize and Allowed, which MicrophoneInput gives an app: it writes the samples a test emits into real WAV files under the test's temporary directory, as Android's runtime writes them, so a test checks what the app recorded and how long.
func (*Microphone) Emit ¶
func (m *Microphone) Emit(samples []int16)
Emit records samples, interleaved when the recording is stereo, into the running recording, reporting their level to an app that asked for levels and the duration written to one that did not; nothing records while none runs or while Interrupt silences it.
func (*Microphone) Interrupt ¶
func (m *Microphone) Interrupt(silenced bool)
Interrupt silences the running recording, as a call does, or ends its silence: one that pauses on interruption writes nothing meanwhile, and another ends with microphone.ErrInterrupted.
func (*Microphone) Recording ¶
func (m *Microphone) Recording() bool
Recording says a recording runs.
func (*Microphone) Recordings ¶
func (m *Microphone) Recordings() []Recorded
Recordings are the files the app finished recording, oldest first.
type ModalConfig ¶
type ModalConfig = driver.ModalConfig
ModalConfig is how a modal appears and goes.
type NativeCommand ¶
NativeCommand is a command a native view received.
type Option ¶
type Option func(*App)
Option configures Start.
func Environment ¶
func Environment(env driver.Environment) Option
Environment starts the app in env from its first frame, as a platform reports it before the app mounts: screens have the system header where env has HeaderHeight.
func Errors ¶
Errors hands what the app reports failing to report instead of failing the test, as a host's overlay shows it while the app runs on. It applies headless only.
func Host ¶
Host runs the app with h as its channel to an embedding host, so a test sends it events and answers its calls as the host would.
func HotKeyTaken ¶
HotKeyTaken has the headless platform answer the global shortcuts of keys, in core.Scope.OnKey's form, as desktop.HotKeyTaken, so a test runs an app's path for a combination another app holds; other keys register.
func HotKeyUnsupported ¶
HotKeyUnsupported has the headless platform answer the global shortcuts of keys as desktop.HotKeyUnsupported.
func ManualFrames ¶
func ManualFrames() Option
ManualFrames keeps steps from taking display frames: the animations a step starts move only as Advance moves the clock, so a test can look at them on the way.
func Measure ¶
func Measure() Option
Measure runs the app as it runs for its users, for a measurement on a target: on the system's clock, so Advance waits as long as it moves, with its commits unchecked (driver.CheckCommits), whose check lays every node out again, and with steps that wait only for what animates to rest, not for the app to stop committing. Headless, it does nothing.
func MicrophoneInput ¶
func MicrophoneInput(m *Microphone) Option
MicrophoneInput records the app's RecordWAV with m. The recorder is one per process, as the runtime's is, so Start fails a test whose app would take the one another running test's app has. On a target the device records instead.
func NoCaretMoves ¶
func NoCaretMoves() Option
NoCaretMoves keeps typing from reporting where the caret moves, as NSH's headless model types: a test reports caret moves itself.
func Offscreen ¶
func Offscreen() Option
Offscreen has selectors match every view mounted and not hidden, also one outside the window or clipped away, as NSH's headless runs act.
func PendingAlerts ¶
func PendingAlerts() Option
PendingAlerts leaves the alerts the app shows unanswered unless the test answers them, as NSH's headless runs present none.
func Storage ¶
Storage starts the app with entries in its storage, as if kept from an earlier run; it starts empty otherwise.
func TextEngine ¶
func TextEngine(e driver.TextEngine) Option
TextEngine measures and lays out the app's text with e instead of core.ApproxTextEngine, as a test that checks frames another headless runner computed needs its measurements.
type Overlay ¶
type Overlay struct {
// Frame is where it shows and how large, in the surface's points, kept within the surface as Android keeps an overlay on the screen.
Frame driver.WindowFrame
// Visible is whether it shows; Focusable, Passive and Accessible are its input modes.
Visible bool
Focusable, Passive, Accessible bool
// Closed is whether it closed, and Ended why the platform closed it itself, 0 when the app did.
Closed bool
Ended core.OverlayEnd
// contains filtered or unexported fields
}
Overlay is an overlay over other apps the app opened (mobile.OpenOverlay), as the test's platform shows it: over the surface, which stands for the screen. Its content is a tree of its own that steps do not reach.
type ScreenConfig ¶
type ScreenConfig = driver.ScreenConfig
ScreenConfig is a screen's system header, which the platform draws over the top of the screen's view, HeaderHeight tall.
type ScrollEdge ¶
type ScrollEdge = driver.ScrollEdge
ScrollEdge is a scroll view's edge effect at one of its sides: the effect, how far its bars reach and the bars.
type Shader ¶
type Shader struct {
Role ShaderRole
WGSL bool
Lanes []float64
Nodes []ShaderNode
Pictures Pictures
Overflow float64
Running, Backwards bool
}
Shader is what a view's shader draws: its role, the program's lanes and the nodes that drive them, the pictures it reads and a transition's state.
type ShaderNode ¶
type ShaderNode = driver.ShaderNode
ShaderNode binds a lane of a shader's uniforms to an animated node.
type ShaderRole ¶
type ShaderRole = driver.ShaderRole
ShaderRole is what a shader draws: a fill, an effect, a transition, the screen or a change of pages.
type Sound ¶
type Sound struct {
// Source is what it decoded and Duration how long it plays.
Source core.AudioSource
Duration time.Duration
// Plays are its playbacks, oldest first, Stops how often the app stopped them, and Unloaded whether the app let it go.
Plays []core.SoundVoice
Stops int
Unloaded bool
// contains filtered or unexported fields
}
Sound is a sound the platform decoded.
type StatusBarConfig ¶
type StatusBarConfig = driver.StatusBarConfig
StatusBarConfig is the status bar the platform shows (ItemStatusBar).
type TextBackground ¶
type TextBackground = driver.TextBackground
TextBackground is what a span draws behind its characters.
type VideoConfig ¶
type VideoConfig = driver.VideoConfig
VideoConfig is everything a video plays with (ItemVideo), with the defaults applied: Volume in 0 to 1, Rate above 0, a ResizeMode and ProgressInterval at least 16 milliseconds.
type View ¶
type View struct {
ID driver.NodeID
Kind driver.ViewKind
Parent *View
Children []*View
Frame driver.Bounds
Style driver.ViewStyle
Props driver.ViewProps
Events driver.EventMask
Text string // a text view's text or a field's value
// TextStyle and Spans are a text view's resolved style and its
// spans', which SpanStyle reads.
TextStyle driver.TextStyle
Spans []driver.TextSpan
// TextShadow is drawn behind a text's glyphs; MaxLines and Ellipsize
// cut its lines.
TextShadow driver.TextShadow
MaxLines int
Ellipsize driver.EllipsizeMode
// Hovered says the mouse is over the view, as Hover left it.
Hovered bool
Input driver.InputConfig
Content driver.Size // a scroll view's content
Offset driver.Point // and its offset
// Applied counts the ItemScrollTo and ItemScrollBy items the scroll
// view applied, which its reports carry; Sticky are its sticky
// cells.
Applied uint32
Sticky []driver.StickyCell
// Scroll is a scroll view's configuration, and ZoomScale its zoom
// (0 until it zooms).
Scroll driver.ScrollConfig
ZoomScale float32
Image driver.ImageConfig
Web driver.WebConfig
// WebCommands are what the app asked a web view to do, oldest first;
// answered counts those AnswerScript went past.
WebCommands []WebCommand
Video driver.VideoConfig
// Seeks are the positions the app asked a video to jump to, oldest
// first.
Seeks []time.Duration
// Component and NativeProps are a native view's component and props,
// an animated one at the value the frame clock last handed over;
// NativeCommands what Ref.Command sent it, oldest first.
Component string
NativeProps map[string]any
NativeCommands []NativeCommand
// Animated are the values of the animated properties bound to the
// view, which the model's animator steps with the clock.
Animated driver.AnimatedValues
Focused bool
// Selection is a field's selection, as the app last set it or Select
// moved it, in UTF-16 units.
Selection driver.TextRange
// Composing is the text an input method composes in a field (Compose);
// held is a value the app set meanwhile, applied when it ends.
Composing string
// Screen is a screen's system header, sent where the environment
// has HeaderHeight; Modal a modal's config.
Screen driver.ScreenConfig
Modal driver.ModalConfig
// Drawing is a canvas's last drawing, and Ops its operations as the
// platform plays them now, with the values of the animated nodes its
// arguments are bound to.
Drawing *driver.Drawing
Ops []driver.DrawOp
// Shader is what the view's shader draws, a shader view's fill or a
// view's effect, transition or navigation shader, nil for none.
// ShaderStarts counts the transitions it started
// (ItemShaderTransition), ShaderInputs the batches that said its
// pictures changed (ItemShaderInput).
Shader *Shader
ShaderStarts int
ShaderInputs int
// Node is the part of a drawing a view of a canvas's names: a canvas
// shows each of its drawing's nodes as a child, which selectors find
// by its label (label: and text:), test ID and role, and which presses
// at its center.
Node *driver.CanvasNode
// contains filtered or unexported fields
}
View is the model of one native view, as the last batch left it.
type WebCommand ¶
type WebCommand struct {
Command driver.WebCommand
Value string
}
WebCommand is a command a web view received, with its message or script.
type WebCommandKind ¶
type WebCommandKind = driver.WebCommand
WebCommandKind is what ItemWebCommand asks a web view to do.