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 and every style transition has reached its OnTransitionEnd; ManualFrames leaves them to the test's Advance.
Index ¶
- Constants
- func Main(m *testing.M)
- func MainFunc(run func() int)
- func Target() string
- type AnimatedProp
- type AnimatedValues
- type App
- func (a *App) AccessibilityAction(selector, name string)
- func (a *App) ActiveSensorStreams() int
- 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) ChooseDockMenu(path ...string)
- 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) CloseWindow() bool
- 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) FeedLocation(f core.LocationFix)
- func (a *App) FeedMotion(m core.MotionSample)
- func (a *App) Find(selector string) *View
- func (a *App) FindMounted(selector string) *View
- func (a *App) FinishSpeaking(err core.SpeakError)
- 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) PauseVideo(selector string, reason core.VideoPauseReason)
- 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) PlayVideo(selector string)
- 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) PressAtWith(selector string, at driver.Point, mods driver.Modifiers)
- func (a *App) PressDown(selector string)
- func (a *App) PressNotification(id string)
- func (a *App) PressUp(selector string)
- func (a *App) PressWith(selector string, mods driver.Modifiers)
- 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) Speaking() *Utterance
- 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) UpdatePurchase(tr core.Transaction)
- 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 AuthSession
- type AwakeHold
- type Bindings
- type Channel
- type Event
- type EventKind
- type EventMask
- type Finger
- type ImageConfig
- type InputConfig
- type LookUp
- type Microphone
- type ModalConfig
- type NativeCommand
- type Option
- func Clock(c *core.ManualClock) 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 Idiom(idiom driver.Idiom) Option
- func ManualFrames() Option
- func Measure() Option
- func MicrophoneInput(m *Microphone) Option
- func NoCaretMoves() Option
- func Offscreen() Option
- func PendingAlerts() Option
- func Secrets(values map[string]string) Option
- func Size(width, height driver.Points) Option
- func Storage(entries map[string]string) Option
- func TextEngine(e driver.TextEngine) Option
- func UnfinishedTransactions(txs ...core.Transaction) Option
- func WallTime(t time.Time) Option
- type Overlay
- type Pictures
- type Recorded
- type ScreenConfig
- type ScrollConfig
- type ScrollEdge
- type Shader
- type ShaderNode
- type ShaderRole
- type Sound
- type StatusBarConfig
- type SurfaceConfig
- type SurfaceKind
- type TextBackground
- type TextSpan
- type TextStyle
- type TouchGeometry
- type Utterance
- type VideoConfig
- type View
- type ViewKind
- type ViewProps
- type ViewStyle
- type WebCommand
- type WebCommandKind
- type WebConfig
- type WebSource
Constants ¶
const ( SurfaceWindow = driver.SurfaceWindow SurfacePanel = driver.SurfacePanel SurfaceTrayIcon = driver.SurfaceTrayIcon SurfaceOverlay = driver.SurfaceOverlay )
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 EventKeyDown = driver.EventKeyDown EventPan = driver.EventPan EventPinch = driver.EventPinch EventWheel = driver.EventWheel EventRotation = driver.EventRotation EventMenu = driver.EventMenu EventDockMenu = driver.EventDockMenu 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 WebLoad = driver.WebLoad )
const AuthLoopback = "http://127.0.0.1:49152"
AuthLoopback is where the model serves a loopback redirect, before the session's path.
Variables ¶
This section is empty.
Functions ¶
func Main ¶
Main runs the package's tests, from TestMain:
func TestMain(m *testing.M) { nsgotest.Main(m) }
It is MainFunc(m.Run), and like it never returns.
func MainFunc ¶ added in v0.2.0
func MainFunc(run func() int)
MainFunc runs the package's tests through run, from TestMain, and ends the process with the code run returns. run calls m.Run, with whatever setup and teardown the package needs around it, deferred calls included:
func TestMain(m *testing.M) {
nsgotest.MainFunc(func() int {
setup()
defer teardown()
return m.Run()
})
}
Headless it is os.Exit(run()). Under `nsgo test -target` it gives the main thread to the platform, as macOS, iOS and Windows need their windows' loop there, and runs run beside it; the process ends only once run has returned, so its teardown completes first. A target runs each test in a process of its own, so there run, and its setup and teardown, run once per test.
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 {
// LocationCache is the last fix the platform keeps, which Locate takes when its MaxAge allows; the location and motion permissions are in Permissions, and the fixes and samples come from FeedLocation and FeedMotion.
LocationCache *core.LocationFix
// 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
// Spoken are the utterances the app spoke, oldest first, where the environment says Speak; the last speaks until FinishSpeaking ends it or the app stops it (Speaking). Voices are the voices the platform has, which Scope.Voices answers with.
Spoken []*Utterance
Voices []core.VoiceInfo
// 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
// AuthSessions are the auth sessions the app opened, oldest first. The model catches the app's scheme as macOS's and iOS's session does, and serves a redirect without one on AuthLoopback, as desktops do. AuthAnswer answers each as it opens with the URL the provider redirects to, or an error: core.AuthCancelled for a user who closes it, another for a failure. Without AuthAnswer, or with neither, the session stays open until the app cancels it or its timeout passes.
AuthSessions []*AuthSession
AuthAnswer func(s AuthSession) (callback string, err error)
// 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)
// WebCookies are the cookies of the store the app's web views share (core.Scope.SetWebCookies), oldest first, one the app sets again replacing the one of its name, domain and path. A test puts the cookies a run left there, as the store outlives the app. SetWebCookies answers each call before the store takes its cookies, nil to take them and an error to refuse them all; every call succeeds when it is nil.
WebCookies []core.WebCookie
SetWebCookies func(cookies []core.WebCookie) error
// shows.
Shares []driver.ShareRequest
// LookUps are the dictionary panels the app showed (desktop.LookUp), oldest first, where the environment sets CanLookUp.
LookUps []LookUp
// 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. PendingNotifications are those scheduled for a later time, where the environment says ScheduledNotifications, each At the next time it shows: Advance and FastForward show them as the clock's wall time reaches it, and a repeated one stays for its next time.
Notifications []core.Notification
PendingNotifications []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
// AppleSignIns are the Sign in with Apple requests the app made where the environment says SignInWithApple, oldest first, their nonces hashed as the system receives them. AppleSignIn answers each with the credential the user signs in with, or an error, core.AppleSignInCancelled for a user who closes the sheet; without it the user cancels. AppleCredentialStates is what the platform answers a credential's state with, by user ID, AppleCredentialNotFound for one it does not hold.
AppleSignIns []core.AppleSignInRequest
AppleSignIn func(r core.AppleSignInRequest) (core.AppleCredential, error)
AppleCredentialStates map[string]core.AppleCredentialState
// Products are what the store sells where the environment says Purchases. PurchaseRequests are the in-app purchase requests the app made, oldest first. PurchaseAnswer answers each purchase with the transaction the user buys, or an error, core.PurchaseCancelled for a user who closes the sheet and core.PurchasePending for one waiting for approval; without it a product among Products is bought and any other fails. A transaction bought joins Unfinished, and Entitlements unless consumable; FinishTransaction takes it out of Unfinished into Finished, by ID, and CurrentEntitlements answers Entitlements. SyncAnswer is what SyncPurchases answers, nil by default. UpdatePurchase delivers a transaction as the store does one made outside the app, and UnfinishedTransactions those the store hands the app as it starts.
Products []core.Product
PurchaseRequests []core.PurchaseRequest
PurchaseAnswer func(r core.PurchaseRequest) (core.Transaction, error)
Unfinished []core.Transaction
Entitlements []core.Transaction
Finished []string
SyncAnswer error
// 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, or quit as the user asked: by a Quit menu role on Windows and Linux, or with a quit request it let proceed; 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, with a desktop environment in the main window; 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, with a desktop environment the main window's or else the app's own surface's; DockMenu the app icon's menu, the one any surface set last; Window the window commands it sent, oldest first.
Menu []driver.MenuEntry
DockMenu []driver.MenuEntry
Window []driver.WindowCommand
// Opened are the surfaces the app opened, oldest first, as it opened them: with a desktop environment its windows, panels and tray views, a window's transparency, shadow and taskbar button among what it asked for, and on Android its overlays.
Opened []SurfaceConfig
// 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 is the app's clock, which Advance and FastForward move: a ManualClock starting at 2026-01-01 00:00 UTC, its wall time with it, unless the Clock or WallTime option sets it. Options apply before the first render, so what they set is what it reads. Under Measure the app runs on the system's clock instead.
Clock *core.ManualClock
// Secrets is the app's secure store, in memory: what Scope.Secrets keeps, by item, for a test to read or change, so no test touches the machine's keychain, also on a target. seedSecrets are what the Secrets option starts it with.
Secrets *core.MemorySecrets
// 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, a root view, and settles it; the test's cleanup disposes it. Under `nsgo test -target` it opens the app on that platform instead. With a macOS Environment app shows in the main window, as nsgo.Run shows a root view there, which steps act on; with any other, Windows and Linux included, it fills the app's one surface, as nsgo.Run's does. An app run with its function is tested with StartApp.
func StartApp ¶ added in v0.2.0
StartApp runs the app's function app, as nsgo.Run(app) does, and settles it; the test's cleanup disposes it. app runs once in the app's own scope, where what it registers, such as its application menu, quit handlers and global shortcuts, lives. With a desktop Environment (macOS, Windows or Linux) it opens windows as on a desktop, and the view SetMainView sets shows in the main window, which steps act on; with any other that view fills the app's one surface. Under `nsgo test -target` it opens core.AppRoot(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) ActiveSensorStreams ¶ added in v0.2.0
ActiveSensorStreams is the number of native providers the model holds.
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) ChooseDockMenu ¶ added in v0.2.0
ChooseDockMenu chooses the item at path in the app icon's menu (desktop.SetDockMenu), its labels from the menu down, as the Dock menu on macOS and a Jump List task on Windows do.
func (*App) ChooseMenu ¶
ChooseMenu chooses the application menu item at path, its labels from the menu bar down, such as "File", "New": of Menu, which with a desktop environment is the main window's, else the one the app's function set. Headless, as the desktop platforms do, an editing role goes to the focused field first, its OnSelect running when no field takes it, and an item without OnSelect carries out its standard role: Close, Quit, Minimize, Zoom, Toggle Full Screen and the editing roles; a role the model does not carry out fails the step. Under nsgo test -target an item without OnSelect skips the test.
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) CloseWindow ¶ added in v0.2.0
CloseWindow asks the main window to close, as its close button does, and reports whether it closed: its OnClosing handlers run newest first, and it closes unless one cancels. It needs a main window open, which a macOS environment, or StartApp with a Windows or Linux one, opens, and runs headless only.
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, on the match or the nearest view around it with OnFileDrop, within the modal it is in. It fails when that view is disabled or there is none.
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) FeedLocation ¶ added in v0.2.0
func (a *App) FeedLocation(f core.LocationFix)
FeedLocation delivers a copied fix to active location requests. Call several times before Settle to test latest-value back-pressure.
func (*App) FeedMotion ¶ added in v0.2.0
func (a *App) FeedMotion(m core.MotionSample)
FeedMotion delivers a copied reading to streams requesting that sensor.
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) FinishSpeaking ¶ added in v0.2.0
func (a *App) FinishSpeaking(err core.SpeakError)
FinishSpeaking ends the utterance being spoken, as it finished when err is "", or failed with err, and settles.
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. Desktops and the web give views other than fields the keyboard focus; elsewhere 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", or a modifier alone, "shift"): the focused view's OnKeyDown hears it first, and a key it consumes goes no further; else 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 desktop 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 with the modifiers held, except with Alt on Windows, where they go to the window menu; else the focused field takes a character, Backspace or Enter, mod+a selects all its text, and mod+c, mod+x and mod+v copy, cut and paste with Clipboard unless an application-menu item has the key as its shortcut; else, in a macOS, Windows or Linux environment, the enabled application-menu item with the key as its shortcut is chosen, unless it is NotInText and a field or web view has the focus; 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. The web view need only be mounted, as a hidden one goes on loading.
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) PauseVideo ¶ added in v0.2.0
func (a *App) PauseVideo(selector string, reason core.VideoPauseReason)
PauseVideo reports that the platform paused the video selector matches for reason, as its controls or the system do (Video.OnPause).
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) PlayVideo ¶ added in v0.2.0
PlayVideo reports that the platform played the video selector matches, as its controls or the system do (Video.OnPlay).
func (*App) Post ¶
func (a *App) Post(fn func())
Post runs fn on the app's graph goroutine as the next step or wait settles: the test goroutine headless, the engine goroutine on a target. It is safe to call from any goroutine, fn may read or set the app's signals and post more, and the step settles what they post too. As fn may run off the test goroutine, it takes no steps and does not call t.Fatal or t.FailNow: check what it did after the step.
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. The web view need only be mounted, as Navigate's.
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 or touch-listening 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) PressAtWith ¶ added in v0.2.0
PressAtWith presses as PressAt does, with the modifier keys held for this press only.
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) PressWith ¶ added in v0.2.0
PressWith presses as Press does, with the modifier keys held for this press only. A target sends them through its native input.
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, in the view, no Size clearing it, as the platforms report it. The text OnTextSelection receives is that of the texts box overlaps, whole, as a copy gives it: texts on one row joined by a tab and the others by a line break, hidden spans left out.
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. On a target it first waits for the engine to hand its pending commits to the platform, then until no batch came and nothing finite animated for 100 ms, checking the engine again before it returns, five seconds at most in all.
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) UpdatePurchase ¶ added in v0.2.0
func (a *App) UpdatePurchase(tr core.Transaction)
UpdatePurchase has the store deliver tr to OnPurchaseUpdate, as it does a transaction made or changed outside a Purchase call: a renewal, a purchase approved after Ask to Buy, one made on another device or a refund, and settles. tr joins Unfinished, and Entitlements as a purchase does, or leaves them once its RevocationDate is set.
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 AuthSession ¶ added in v0.2.0
type AuthSession struct {
Redirect string
URL string
Ephemeral bool
Cancelled bool
// contains filtered or unexported fields
}
AuthSession is an auth session the app opened (core.Scope.AuthSession): the redirect the model catches, the authorization URL the app built for it, whether it asked for an ephemeral session, and whether the app cancelled it or its timeout passed.
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 LookUp ¶ added in v0.2.0
LookUp is a dictionary panel the app showed: its text and the box the text is drawn over, in the surface.
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 Clock ¶ added in v0.2.0
func Clock(c *core.ManualClock) Option
Clock runs the app on c instead of a new ManualClock, for a test that shares one clock with code of its own: App.Clock is c, and the app's timers and frames run as c moves. c must not be nil. Under Measure the app runs on the system's clock instead.
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. Under `nsgo test -target` it pins only the appearance, reduced motion, increased contrast, the login launch reason, the application in front and whether the platform follows it, and, when set, the locale, text size, device name and device model; the OS, the idiom, the safe area and the header heights stay the platform's, so a test of another OS's layout runs headless or on that OS's target.
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 Idiom ¶ added in v0.2.0
Idiom starts a headless app with idiom, core.IdiomPhone by default, and the rest of its environment as it would be otherwise: Environment's when the test passes one, before or after Idiom, the defaults when not. IdiomDesktop has what reads Env.Desktop take its desktop path, such as hover tooltips; keyboard focus follows the environment's OS instead. App.SetEnvironment later reports its environment whole, idiom included. Under `nsgo test -target` the platform's idiom stays, as Environment's does.
func ManualFrames ¶
func ManualFrames() Option
ManualFrames keeps steps from taking display frames: the animations and style transitions a step starts move, and their OnTransitionEnd runs, 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 own commits unchecked, whose check otherwise 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. A headless test in a browser skips, since the fake writes real WAV files.
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 Secrets ¶ added in v0.2.0
Secrets starts the app with values kept in its secure store, by account under the app's own service (core.Secrets.Service), as if kept from an earlier run; it starts empty otherwise.
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.
func UnfinishedTransactions ¶ added in v0.2.0
func UnfinishedTransactions(txs ...core.Transaction) Option
UnfinishedTransactions starts the app with transactions it has not finished, as if bought in an earlier run: where the environment says Purchases, the store hands each to OnPurchaseUpdate as the app starts, as StoreKit does, and they stay in Unfinished until the app finishes them.
func WallTime ¶ added in v0.2.0
WallTime starts the app with its wall time (Scope.WallTime, a TSX app's Date) at t, in t's location, as ManualClock.SetWallTime sets it, so the first render reads t. The clock's own time, which timers and frames run on, starts where it would, and no timer moves. It applies after every option, Clock's included, in any order. Under Measure the app reads the system's time instead.
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 SurfaceConfig ¶ added in v0.2.0
type SurfaceConfig = driver.SurfaceConfig
SurfaceConfig is a window, panel, tray view or overlay as the app opened it (App.Opened), and SurfaceKind which of them it is.
type SurfaceKind ¶ added in v0.2.0
type SurfaceKind = driver.SurfaceKind
type TextBackground ¶
type TextBackground = driver.TextBackground
TextBackground is what a span draws behind its characters.
type TouchGeometry ¶ added in v0.2.0
type TouchGeometry = driver.TouchGeometry
TouchGeometry is an event's snapshot of native hit targets and local positions, indexed in the same order as Event.Touches.
type Utterance ¶ added in v0.2.0
type Utterance struct {
// Text is what it said, Lang its language, Voice the voice's ID, "" for the default one, and Rate and Pitch how it spoke, from 0.5 to 2.
Text, Lang, Voice string
Rate, Pitch float32
// Stopped says the app stopped it, or spoke another, before it finished, and Error why FinishSpeaking failed it.
Stopped bool
Error core.SpeakError
// Finished says it ended, however it did.
Finished bool
// contains filtered or unexported fields
}
Utterance is text the app spoke with Scope.Speak.
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
Data any
}
WebCommand is a command a web view received, with its message or script in Value and any structured argument in Data (such as WebLoad's WebSource).
type WebCommandKind ¶
type WebCommandKind = driver.WebCommand
WebCommandKind is what ItemWebCommand asks a web view to do.