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
- Variables
- func Main(m *testing.M)
- func MainFunc(run func() int)
- func PlatformTextEngine() core.TextEngine
- func RegisterFont([]byte) error
- func Render(*core.Drawing, core.Size, float64) (*image.RGBA, error)
- func Target() string
- type ActiveCursor
- type ActivityChange
- type ActivityEnd
- type ActivityRecord
- type AnimatedProp
- type AnimatedValues
- type App
- func (a *App) AccessibilityAction(selector, name string)
- func (a *App) ActiveCursor() ActiveCursor
- func (a *App) ActiveSensorStreams() int
- func (a *App) Advance(d time.Duration)
- func (a *App) Alerts() []driver.AlertConfig
- func (a *App) Animated(selector string) 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) BlurWindow()
- func (a *App) Bound(selector string) Bindings
- func (a *App) CanvasImageCacheBytes() int64
- func (a *App) CanvasImageCached(src core.ImageSource) bool
- func (a *App) Capture() image.Image
- func (a *App) CapturePNG() []byte
- func (a *App) ChooseDockMenu(path ...string)
- func (a *App) ChooseEditAction(action core.EditAction)
- func (a *App) ChooseMenu(path ...string)
- func (a *App) ChoosePopup(path ...string)
- func (a *App) Clear(selector string)
- func (a *App) ClickTray(selector string, button core.MouseButton, bounds ...core.Bounds)
- func (a *App) ClickTrayIndex(index int, button core.MouseButton, bounds ...core.Bounds)
- func (a *App) ClickTrayTitle(title string, button core.MouseButton, bounds ...core.Bounds)
- func (a *App) CloseEditMenu()
- 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) ConnectGamepad(id int, name string)
- func (a *App) CursorAt(selector string) ActiveCursor
- func (a *App) DisconnectGamepad(id int)
- func (a *App) DoublePress(selector 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) DragTo(source, target string)
- func (a *App) DropFiles(selector string, uris ...string)
- func (a *App) Dump() string
- func (a *App) EditMenuItems() []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) FeedActivity(sample core.ActivitySample)
- func (a *App) FeedGeofence(sample core.GeofenceSample)
- func (a *App) FeedLocation(f core.LocationFix)
- func (a *App) FeedMotion(m core.MotionSample)
- func (a *App) FeedPressure(sample core.PressureSample)
- func (a *App) FeedSteps(sample core.StepSample)
- 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) FrameAt(at time.Time)
- func (a *App) GPUFrames() []GPUFrameRecord
- func (a *App) GPUReadPixels(selector string) (*image.RGBA, error)
- func (a *App) GameServicesAchievements() []core.GameAchievement
- func (a *App) GameServicesScoreQueries() []GameServicesScoreQuery
- func (a *App) GameServicesScores(leaderboardID string) []core.GameScoreEntry
- func (a *App) GameServicesShownAchievements() int
- func (a *App) GameServicesShownLeaderboards() []string
- func (a *App) GameServicesSubmittedScores() []core.GameScoreEntry
- func (a *App) GamepadRumbles() []gamepad.RumbleEvent
- 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) ImageCacheBytes() int64
- func (a *App) ImageCached(src core.ImageSource) bool
- func (a *App) KeptImage(src core.ImageSource) bool
- func (a *App) Key(key string)
- func (a *App) KeyCode(code string)
- func (a *App) KeyCodeDown(code string)
- func (a *App) KeyCodeUp(code string)
- func (a *App) KeyCommands() []KeyCommand
- func (a *App) KeyDown(key string)
- func (a *App) KeyPress(selector, key string)
- func (a *App) KeyUp(key string)
- func (a *App) LastGamepadRumble(id int) (gamepad.RumbleEvent, bool)
- func (a *App) LiveActivities() []ActivityRecord
- func (a *App) Load(selector string, pixels driver.Size)
- func (a *App) LongPress(selector string)
- func (a *App) LongPressAt(selector string, at driver.Point)
- func (a *App) Mark(name string)
- func (a *App) MediaCommand(command core.MediaCommand)
- func (a *App) MouseDown(selector string, button driver.MouseButton)
- func (a *App) MouseDownAt(selector string, at driver.Point, button driver.MouseButton)
- func (a *App) MouseDownAtWith(selector string, at driver.Point, button driver.MouseButton, ...)
- func (a *App) MouseDownWith(selector string, button driver.MouseButton, mods driver.Modifiers)
- func (a *App) MouseUp(selector string, button driver.MouseButton)
- func (a *App) MouseUpAt(selector string, at driver.Point, button driver.MouseButton)
- func (a *App) MouseUpAtWith(selector string, at driver.Point, button driver.MouseButton, ...)
- func (a *App) MouseUpWith(selector string, button driver.MouseButton, mods driver.Modifiers)
- func (a *App) Navigate(selector string, nav driver.WebNavigation)
- func (a *App) NowPlaying() *core.NowPlaying
- func (a *App) Offscreen(off *core.OffscreenImage) *OffscreenSurface
- func (a *App) OpenLinks(links ...string)
- 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) PictureInPictureControl(selector, action string, interval time.Duration)
- 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) PointerDelta(dx, dy float64)
- 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) ReceiveShare(items ...core.SharedItem)
- func (a *App) Report(ev Event)
- func (a *App) ReportPictureInPicture(selector string, state core.PictureInPictureState)
- func (a *App) RequestQuit(forced bool)
- func (a *App) Resize(width, height driver.Points)
- func (a *App) RestoreGPUDevice(selector string)
- 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) ScrollHandle(selector string) (core.Bounds, bool)
- func (a *App) ScrollTo(selector string, offset driver.Point)
- func (a *App) SeedLeaderboardScores(leaderboardID string, entries ...core.GameScoreEntry)
- func (a *App) Select(selector string, start, end int)
- func (a *App) SelectTab(selector string, index int)
- func (a *App) SelectText(selector string, box driver.Bounds)
- func (a *App) SelectTextRange(selector, from string, start int, to string, end int)
- func (a *App) SetCloudAvailable(available bool)
- func (a *App) SetEnvironment(env driver.Environment)
- func (a *App) SetGameServicesAuthError(err error)
- func (a *App) SetGameServicesError(err error)
- func (a *App) SetGameServicesFriends(playerIDs ...string)
- func (a *App) SetGameServicesPlayer(p core.GamePlayer)
- func (a *App) SetGamepadAxis(id int, axis gamepad.Axis, value float32)
- func (a *App) SetGamepadButton(id int, btn gamepad.Button, value float32)
- func (a *App) SetGamepadInfo(id int, family gamepad.Family, vendorID, productID uint16, canRumble bool)
- func (a *App) SetVerticalBarEdge(edge driver.VerticalBarEdge)
- func (a *App) SetWindowEnvironment(title string, change func(*driver.Environment))
- func (a *App) Settle()
- func (a *App) SimulateCloudChange(kv map[string][]byte, files map[string][]byte, reason core.CloudChangeReason)
- func (a *App) SimulateCloudConflict(name string, remote []byte)
- 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) Surface(selector string) *Surface
- func (a *App) Surfaces() []*Surface
- 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) TriggerGPUDeviceLost(selector string, reason GPUDeviceLostReason, message string)
- func (a *App) TriggerGPUDeviceLostWithReason(selector string, reason GPUDeviceLostReason, message string)
- func (a *App) TriggerGPUSurfaceRotation(selector string, width, height int)
- func (a *App) Type(selector, text string)
- func (a *App) UnkeptImageCacheBytes() int64
- func (a *App) UpdatePurchase(tr core.Transaction)
- func (a *App) VerticalBarEdge() driver.VerticalBarEdge
- 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)
- func (a *App) Widgets() map[string][]widget.Entry
- type AppleSignInRequest
- type AudioPlayback
- type AudioPlayer
- type AuthSession
- type AwakeHold
- type Bindings
- type Channel
- type CodeScan
- type CustomCursor
- type DirectoryPick
- type EditMenu
- type Event
- type EventKind
- type EventMask
- type FilePick
- type FileSave
- type Finger
- type GPUDeviceLostReason
- type GPUFrameRecord
- type GameServicesScoreQuery
- type ImageConfig
- type ImagePick
- type InputConfig
- type KeyCommand
- type LookUp
- type MenuItem
- type Microphone
- type ModalConfig
- type NativeCommand
- type OffscreenSurface
- type Option
- func Clock(c *core.ManualClock) Option
- func CloudAvailable(available bool) Option
- func DiskSpace(space core.DiskSpace, err error) 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 LiveActivities(enabled bool) Option
- func LocalServices(services ...core.LocalService) Option
- func ManualFrames() Option
- func Measure() Option
- func MicrophoneInput(m *Microphone) Option
- func NoCaretMoves() Option
- func NoGPU() Option
- func NoGPUCompute() Option
- func Offscreen() Option
- func PendingAlerts() Option
- func PictureInPictureSupport(supported, possible bool) 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 UpdaterState(state core.UpdaterState) Option
- func UserDirs(dirs map[core.StandardDir]string) Option
- func VerticalBarEdge(edge driver.VerticalBarEdge) Option
- func WallTime(t time.Time) Option
- func Widgets(available bool) Option
- type Overlay
- type PictureInPictureConfig
- type Pictures
- type PurchaseAction
- type PurchaseRequest
- type Recorded
- type ScreenConfig
- type ScrollConfig
- type ScrollEdge
- type SelectedRange
- type Shader
- type ShaderNode
- type ShaderRole
- type Share
- type Sound
- type SpeechSession
- type StatusBarConfig
- type StickyCell
- type Surface
- func (s *Surface) AccessibilityAction(selector, name string)
- func (s *Surface) ActiveCursor() ActiveCursor
- func (s *Surface) Animated(selector string) ViewStyle
- func (s *Surface) AnimatedValue(node uint32) float64
- func (s *Surface) AnswerScript(selector, result, errText string)
- func (s *Surface) Back()
- func (s *Surface) BlurWindow()
- func (s *Surface) Bound(selector string) Bindings
- func (s *Surface) Capture() image.Image
- func (s *Surface) CapturePNG() []byte
- func (s *Surface) Clear(selector string)
- func (s *Surface) Close() bool
- func (s *Surface) Commit(selector, text string)
- func (s *Surface) Compose(selector, text string)
- func (s *Surface) Config() SurfaceConfig
- func (s *Surface) CursorAt(selector string) ActiveCursor
- func (s *Surface) Drag(selector string, path ...core.Point)
- func (s *Surface) DragAt(selector string, at core.Point, path ...core.Point)
- func (s *Surface) DragScroll(selector string, offset core.Point, velocity float32)
- func (s *Surface) DragTo(source, target string)
- func (s *Surface) DropFiles(selector string, uris ...string)
- func (s *Surface) Dump() string
- func (s *Surface) Emit(selector, name string, data any)
- func (s *Surface) Enabled(selector string) bool
- func (s *Surface) Exists(selector string) bool
- func (s *Surface) Find(selector string) *View
- func (s *Surface) FindMounted(selector string) *View
- func (s *Surface) Focus(selector string)
- func (s *Surface) GPUReadPixels(selector string) (*image.RGBA, error)
- func (s *Surface) HeaderBack(selector string)
- func (s *Surface) Hover(selector string)
- func (s *Surface) HoverAt(selector string, at core.Point)
- func (s *Surface) HoverOut()
- func (s *Surface) Key(key string)
- func (s *Surface) KeyCommands() []KeyCommand
- func (s *Surface) KeyDown(key string)
- func (s *Surface) KeyPress(selector, key string)
- func (s *Surface) KeyUp(key string)
- func (s *Surface) Load(selector string, pixels core.Size)
- func (s *Surface) LongPress(selector string)
- func (s *Surface) MouseDown(selector string, button core.MouseButton)
- func (s *Surface) MouseDownAt(selector string, at core.Point, button core.MouseButton)
- func (s *Surface) MouseDownAtWith(selector string, at core.Point, button core.MouseButton, mods core.Modifiers)
- func (s *Surface) MouseDownWith(selector string, button core.MouseButton, mods core.Modifiers)
- func (s *Surface) MouseUp(selector string, button core.MouseButton)
- func (s *Surface) MouseUpAt(selector string, at core.Point, button core.MouseButton)
- func (s *Surface) MouseUpAtWith(selector string, at core.Point, button core.MouseButton, mods core.Modifiers)
- func (s *Surface) MouseUpWith(selector string, button core.MouseButton, mods core.Modifiers)
- func (s *Surface) Navigate(selector string, nav core.WebNavigation)
- func (s *Surface) Pan(selector string, translations ...core.Point)
- func (s *Surface) Paste(selector string, p core.PasteEvent)
- func (s *Surface) PauseVideo(selector string, reason core.VideoPauseReason)
- func (s *Surface) PictureInPictureControl(selector, action string, interval time.Duration)
- func (s *Surface) Pinch(selector string, scales ...float32)
- func (s *Surface) PinchZoom(selector string, scale float32)
- func (s *Surface) Play(selector string, info core.VideoInfo)
- func (s *Surface) PlayVideo(selector string)
- func (s *Surface) Post(fn func())
- func (s *Surface) PostMessage(selector, data string)
- func (s *Surface) PostMessageFrom(selector, url string, mainFrame bool, data string)
- func (s *Surface) PresentModal(selector string, size core.Size, insets core.Edges)
- func (s *Surface) Press(selector string)
- func (s *Surface) PressAt(selector string, at core.Point)
- func (s *Surface) PressAtWith(selector string, at core.Point, mods core.Modifiers)
- func (s *Surface) PressDown(selector string)
- func (s *Surface) PressUp(selector string)
- func (s *Surface) PressWith(selector string, mods core.Modifiers)
- func (s *Surface) Progress(selector string, position, duration time.Duration)
- func (s *Surface) PullToRefresh(selector string)
- func (s *Surface) Query(selector string) []*View
- func (s *Surface) QueryMounted(selector string) []*View
- func (s *Surface) Report(ev Event)
- func (s *Surface) ReportPictureInPicture(selector string, state core.PictureInPictureState)
- func (s *Surface) Resize(width, height core.Points)
- func (s *Surface) RestoreGPUDevice(selector string)
- func (s *Surface) RightClick(selector string)
- func (s *Surface) Rotate(selector string, angles ...float32)
- func (s *Surface) Screenshot(name string)
- func (s *Surface) Scroll(selector string, distance core.Points)
- func (s *Surface) ScrollTo(selector string, offset core.Point)
- func (s *Surface) Select(selector string, start, end int)
- func (s *Surface) SelectTab(selector string, index int)
- func (s *Surface) SelectText(selector string, box core.Bounds)
- func (s *Surface) SelectTextRange(selector, from string, start int, to string, end int)
- func (s *Surface) Settle()
- func (s *Surface) Span(selector string) TextSpan
- func (s *Surface) SpanStyle(selector string) TextStyle
- func (s *Surface) Submit(selector string)
- func (s *Surface) SwipeClose(selector string)
- func (s *Surface) SystemGestures() core.SystemGestureOptions
- func (s *Surface) Texts() []string
- func (s *Surface) Touch(selector string, at core.Point) *Finger
- func (s *Surface) TouchpadScroll(selector string, velocity core.Point, deltas ...core.Point)
- func (s *Surface) TriggerGPUDeviceLost(selector string, reason GPUDeviceLostReason, message string)
- func (s *Surface) Type(selector, text string)
- func (s *Surface) WaitFor(selector string, timeout time.Duration) *View
- func (s *Surface) WaitForGone(selector string, timeout time.Duration)
- func (s *Surface) WaitUntil(timeout time.Duration, cond func() bool)
- func (s *Surface) Wheel(selector string, delta core.Point, mods core.Modifiers)
- func (s *Surface) WindowState() WindowState
- type SurfaceConfig
- type SurfaceKind
- type TextBackground
- type TextSpan
- type TextStyle
- type TouchGeometry
- type Utterance
- type VideoConfig
- type VideoHeaders
- type View
- type ViewKind
- type ViewProps
- type ViewStyle
- type WebCommand
- type WebCommandKind
- type WebConfig
- type WebSource
- type WindowAction
- type WindowRequest
- type WindowState
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 EventMouseDown = driver.EventMouseDown EventMouseUp = driver.EventMouseUp 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 EventKeyUp = driver.EventKeyUp 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 EventModalShown = driver.EventModalShown EventModalDismissed = driver.EventModalDismissed EventScreenInsets = driver.EventScreenInsets EventMouseMove = driver.EventMouseMove EventTouch = driver.EventTouch EventCaretMove = driver.EventCaretMove EventPaste = driver.EventPaste EventEditAction = driver.EventEditAction )
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 ( GPULostUnknown = driver.GPULostUnknown GPULostReset = driver.GPULostReset GPULostDestroyed = driver.GPULostDestroyed GPULostOutOfMemory = driver.GPULostOutOfMemory GPULostDeviceRemoved = driver.GPULostDeviceRemoved GPULostContextLost = driver.GPULostContextLost GPULostSurfaceDestroyed = driver.GPULostSurfaceDestroyed )
const AuthLoopback = "http://127.0.0.1:49152"
AuthLoopback is where the model serves a loopback redirect, before the session's path.
Variables ¶
var ErrNoPlayer = errors.New("nsgotest: no windowless canvas player on this target")
ErrNoPlayer means this target has no windowless canvas player.
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.
func PlatformTextEngine ¶
func PlatformTextEngine() core.TextEngine
PlatformTextEngine returns nil where no windowless native engine is available.
func RegisterFont ¶
RegisterFont reports ErrNoPlayer where native font registration is unavailable.
Types ¶
type ActiveCursor ¶
type ActiveCursor struct {
// Cursor is the active named cursor (or the effective fallback when Custom
// has empty images).
Cursor driver.Cursor
// Custom is the active CustomCursor specification, or nil when a named
// cursor is shown.
Custom *driver.CustomCursor
// Source is the ImageSource selected for the surface's pixel ratio
// (Image2x when PixelRatio >= 1.5 and Image2x is set, else Image).
Source driver.ImageSource
// Is2x reports whether Source is Custom.Image2x.
Is2x bool
// Hotspot is Custom.Hotspot clamped to the image's logical bounds (or
// clamped to >= 0 when the image dimensions are unknown).
Hotspot driver.Point
// Fallback is the effective fallback named cursor.
Fallback driver.Cursor
}
ActiveCursor describes the resolved pointer cursor over a view or at the current mouse position (ActiveCursor, CursorAt).
type ActivityChange ¶
type ActivityChange struct {
At time.Time
Content widget.ActivityContent
Alert bool
AlertTitle, AlertBody string
}
ActivityChange is the content the app showed at start or in an update.
type ActivityEnd ¶
ActivityEnd records the end of an activity and its optional final content.
type ActivityRecord ¶
type ActivityRecord struct {
Activity *widget.Activity
Options widget.ActivityOptions
Changes []ActivityChange
End *ActivityEnd
}
ActivityRecord is a Live Activity the app started. Changes are in order from the initial content. End is nil while the activity is running.
type AnimatedProp ¶
type AnimatedProp = driver.AnimatedProp
AnimatedProp is a view property an animated node drives.
type AnimatedValues ¶
type AnimatedValues struct {
// Set holds a bit for each bound AnimatedProp.
Set uint16
Opacity float32
TranslateX, TranslateY core.Points
Scale, ScaleX, ScaleY float32
Rotate float32
Background core.Color
BorderColor core.Color
ShadowColor core.Color
ShadowRadius core.Points
ShadowOpacity float32
// TextColor colors a text's whole content.
TextColor core.Color
RotateX, RotateY float32
}
AnimatedValues records the bound properties last evaluated by the animator.
func (AnimatedValues) Apply ¶
func (v AnimatedValues) Apply(style ViewStyle) ViewStyle
Apply returns style with its bound properties replaced by the recorded values.
func (AnimatedValues) Has ¶
func (v AnimatedValues) Has(prop AnimatedProp) bool
Has reports whether prop is bound.
type App ¶
type App struct {
// PreciseLocationAnswer is the authorization returned by an explicit accuracy upgrade.
PreciseLocationAnswer bool
// 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
// ClipboardItems and ClipboardChangeCount track representation writes and the changes made to the test's clipboard.
ClipboardItems []core.ClipboardItem
ClipboardChangeCount int64
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 *SpeechSession
// 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 []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. It answers headless and under `nsgo test -target` macos, windows and linux, in place of the system's picker; on the other targets the system's picker shows and PickImages is not asked.
Picks []ImagePick
PickImages func(r ImagePick) []core.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. It answers headless and under `nsgo test -target` through the test host, without opening a system camera.
Photos []ImagePick
TakePhoto func(r ImagePick) (*core.PickedFile, error)
// Scans are the codes the app asked to scan, oldest first, where the environment says ScanCode. ScanCode answers each with the code the camera reads, or with why it failed; with none the user closes the scanner. It answers headless and on every target, in place of the camera.
Scans []CodeScan
ScanCode func(r CodeScan) (*core.ScannedCode, 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 []FilePick
PickFiles func(r FilePick) []core.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 []DirectoryPick
PickDirectories func(r DirectoryPick) []core.Directory
// written after any preflight check. An absent answer or "" cancels.
Saves []FileSave
SaveFile func(r FileSave) 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, which core.Scope.WebCookies lists), 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
// WebsiteDataClears counts the app's core.Scope.ClearWebsiteData, each of which empties WebCookies.
WebsiteDataClears int
// shows.
Shares []Share
// LookUps are the dictionary panels the app showed (desktop.LookUp), oldest first, where the environment sets CanLookUp.
LookUps []LookUp
// ReviewRequests counts the in-app store rating prompts the app asked for (core.Scope.RequestReview), where the environment sets CanRequestReview.
ReviewRequests int
// Installs are the packages handed to Linux's or Android's installer,
// oldest first. InstallPackage can return the installation error. With
// no function, Linux installs the package and Android opens the
// installer. InstallAllowed is what Android's CanInstallPackages
// answers. InstallSettings counts the requests to open its setting.
Installs []driver.SharedFile
InstallPackage func(path string) error
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
// MiniProgramSignIns records requests; MiniProgramSignIn supplies a code or error. Without it the platform answers unavailable.
MiniProgramSignIns []core.MiniProgramSignInOptions
MiniProgramSignIn func(core.MiniProgramSignInOptions) (core.MiniProgramCredential, error)
// 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 []AppleSignInRequest
AppleSignIn func(r 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 []PurchaseRequest
PurchaseAnswer func(r PurchaseRequest) (core.Transaction, error)
Unfinished []core.Transaction
Entitlements []core.Transaction
Finished []string
SyncAnswer error
ManageSubscriptionsError error
RefundStatus core.RefundStatus
// 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
// Orientation is the app's current interface orientation request. Zero means the app uses the system policy.
Orientation core.Orientation
// 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
// SystemGestures is the main surface's current system gesture request.
SystemGestures core.SystemGestureOptions
// HapticPatterns lists the timed haptics the app played. A nil entry is a cancellation.
HapticPatterns []core.HapticPattern
// 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
// AudioOutputLatency is the test output's latency, zero when unknown.
AudioOutputLatency 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, or a tray icon's menu, with a zero PopupAt; nil once it closed.
PopupMenu []MenuItem
PopupAt core.Point
// EditMenu is the touch edit menu an input opened with Ref.OpenEditMenu; nil when none shows.
EditMenu *EditMenu
// 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: on macOS the one the main window or the app's own surface sent last, none once that surface closed, and on other desktops 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 []MenuItem
DockMenu []MenuItem
Window []WindowRequest
// 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
// ImageBytes are the encoded byte sizes of URI images the model's platform loads, by URI or ImageSource.Key, used when modeling SetImageCacheLimit. Inline ImageSource.Data sources automatically count len(Data) bytes.
ImageBytes map[string]int64
// ImageCacheLimit is the encoded image cache memory budget last set with core.Scope.SetImageCacheLimit, defaulting to core.DefaultImageCacheLimit.
ImageCacheLimit int64
// KeptImages maps each ImageSource.Key currently pinned with Scope.KeepImage
// to its active pin count.
KeptImages map[string]int
// 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 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, in the main window on macOS, as there nsgo.Run shows a root view. 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, which on macOS opens its windows as there nsgo.Run(app) does, steps acting on the main window.
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) ActiveCursor ¶
func (a *App) ActiveCursor() ActiveCursor
ActiveCursor returns the resolved cursor at the current mouse position (after Hover or HoverAt), walking up from the view under the pointer to the nearest ancestor that names a cursor or custom cursor image. Returns CursorAuto when the pointer is outside the surface or no view under it names a cursor.
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) Answer ¶
Answer chooses the button at index (-1: dismiss) of the oldest alert shown. It is a step as Press is: it returns once what the answer starts, as a sheet's exit, has run its frames.
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) BlurWindow ¶
func (a *App) BlurWindow()
BlurWindow simulates the window losing focus (resign key / blur), releasing every held key and held mouse button just as desktop and web platforms do on focus loss.
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) CanvasImageCacheBytes ¶
CanvasImageCacheBytes returns the total encoded bytes currently held in the model's canvas image cache, including kept entries.
func (*App) CanvasImageCached ¶
func (a *App) CanvasImageCached(src core.ImageSource) bool
CanvasImageCached reports whether src is currently held in the model's canvas image cache (kept or within the 64-source and byte LRU bounds).
func (*App) Capture ¶
Capture captures the app as the platform shows it and decodes its PNG. On macOS, iOS and tvOS its pixels are sRGB, regardless of the display's color space. 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. On macOS, iOS and tvOS its pixels are sRGB. 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) ChooseEditAction ¶
func (a *App) ChooseEditAction(action core.EditAction)
ChooseEditAction chooses action from the touch edit menu an input opened with Ref.OpenEditMenu and closes the menu: EditPaste pastes the model's clipboard into the input (EventPaste), while EditCut, EditCopy and EditSelectAll report EventEditAction to it.
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 on macOS is the one the main window or the app's function sent last, and on other desktops the main window's or 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) ClickTray ¶
ClickTray reports a primary or secondary click on a tray icon. selector is index:N in the order icons were opened, or title:Title for a tray's title. Headless clicks have no icon bounds unless bounds supplies one rectangle. The click's menu, when any, can be chosen with ChoosePopup.
func (*App) ClickTrayIndex ¶
ClickTrayIndex clicks the live tray icon at index in opening order.
func (*App) ClickTrayTitle ¶
ClickTrayTitle clicks the live tray icon with title.
func (*App) CloseEditMenu ¶
func (a *App) CloseEditMenu()
CloseEditMenu dismisses any touch edit menu shown without choosing an action.
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 Windows and Linux also ask OnQuitRequest if the close would end the app. 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) ConnectGamepad ¶
ConnectGamepad connects a fake game controller with the given ID and name (or updates its name if already connected) and settles the app so scopes reading gamepad.Pads rerender. The controller's initial Family is inferred from name with gamepad.DetectFamily; call SetGamepadInfo to override family, vendor/product IDs, or rumble support.
func (*App) CursorAt ¶
func (a *App) CursorAt(selector string) ActiveCursor
CursorAt returns the resolved cursor over the view selector matches, walking up to its nearest ancestor that names a cursor or custom cursor image.
func (*App) DisconnectGamepad ¶
DisconnectGamepad disconnects the fake game controller with the given ID and settles the app so scopes reading gamepad.Pads rerender.
func (*App) DoublePress ¶
DoublePress presses what selector names twice without waiting for animations between the two presses. The platform counts the clicks as it does for a user's double click or tap.
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) DragTo ¶
DragTo drags the middle of source onto the middle of target, using the same touch sequence as Drag. Both views must fit in the visible window; the step does not synthesize a drop callback or scroll while the drag is held.
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) EditMenuItems ¶
EditMenuItems returns the visible labels of the touch edit menu an input opened with Ref.OpenEditMenu, in platform order, omitting Paste while the clipboard is empty (matching iOS and Android), or nil when none shows.
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) FeedActivity ¶
func (a *App) FeedActivity(sample core.ActivitySample)
FeedActivity delivers a copied native classification to active activity streams.
func (*App) FeedGeofence ¶
func (a *App) FeedGeofence(sample core.GeofenceSample)
FeedGeofence delivers the latest observed state only to streams monitoring that region. Back-pressure is separate for each region identifier.
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) FeedPressure ¶
func (a *App) FeedPressure(sample core.PressureSample)
FeedPressure delivers a copied pressure observation in pascals.
func (*App) FeedSteps ¶
func (a *App) FeedSteps(sample core.StepSample)
FeedSteps delivers a copied counter observation to active step streams.
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) FrameAt ¶
FrameAt runs the display frame the app waits for, stamped at, and settles; the clock does not move. A zero at stamps the frame with the clock's now, as today's frame is. A frame stamped a frame ahead of the clock, or before it, is what a display that stamps a frame's show time hands the app. It skips a target run, which drives its own frames.
func (*App) GPUFrames ¶
func (a *App) GPUFrames() []GPUFrameRecord
GPUFrames returns all off-commit GPU frames submitted so far across the app, oldest first.
func (*App) GPUReadPixels ¶
GPUReadPixels returns an independent RGBA snapshot of the rendered pixels in the KindGPU view matching selector.
func (*App) GameServicesAchievements ¶
func (a *App) GameServicesAchievements() []core.GameAchievement
GameServicesAchievements returns the achievements recorded for this app, sorted by ID.
func (*App) GameServicesScoreQueries ¶
func (a *App) GameServicesScoreQueries() []GameServicesScoreQuery
GameServicesScoreQueries returns the LoadScores queries this app made, oldest first, including those that ended in an error. The fake does not filter by time scope.
func (*App) GameServicesScores ¶
func (a *App) GameServicesScores(leaderboardID string) []core.GameScoreEntry
GameServicesScores returns the current ranked entries for leaderboardID (combining seeded and submitted scores), sorted descending by score.
func (*App) GameServicesShownAchievements ¶
GameServicesShownAchievements returns how many times this app called gameservices.ShowAchievements.
func (*App) GameServicesShownLeaderboards ¶
GameServicesShownLeaderboards returns the leaderboard IDs passed to gameservices.ShowLeaderboard by this app, oldest first.
func (*App) GameServicesSubmittedScores ¶
func (a *App) GameServicesSubmittedScores() []core.GameScoreEntry
GameServicesSubmittedScores returns every score submitted by this app via gameservices.SubmitScore, oldest first.
func (*App) GamepadRumbles ¶
func (a *App) GamepadRumbles() []gamepad.RumbleEvent
GamepadRumbles returns all rumble start and stop events recorded on fake controllers in order.
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) ImageCacheBytes ¶
ImageCacheBytes returns the total encoded bytes currently held in the model's encoded image cache, including kept entries.
func (*App) ImageCached ¶
func (a *App) ImageCached(src core.ImageSource) bool
ImageCached reports whether src is currently held in the model's encoded image cache (kept or within the byte budget set by SetImageCacheLimit).
func (*App) KeptImage ¶
func (a *App) KeptImage(src core.ImageSource) bool
KeptImage reports whether src is currently pinned via core.Scope.KeepImage.
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"), and lets it come up: 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 when no 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. Then the key comes up, which OnKeyUp of the view that heard it go down hears, with the key's modifiers still held. The modifiers KeyDown holds join the key, so KeyDown("shift") then Key("a") presses shift+a.
func (*App) KeyCode ¶
KeyCode presses and releases a physical position, such as KeyW. A headless test names the key with the test environment's KeyCodeNames or the US layout. On a target the platform's own event carries the position; on macOS, Windows, Linux and the web the platform's current keyboard layout names the key, so KeyW is "z" on AZERTY, and elsewhere the US layout does. A target that cannot press a position skips the test.
func (*App) KeyCodeDown ¶
KeyCodeDown presses a physical position and holds it until KeyCodeUp.
func (*App) KeyCommands ¶
func (a *App) KeyCommands() []KeyCommand
KeyCommands returns the titled bindings that would fire with the current focus and visible views, in binding order.
func (*App) KeyDown ¶
KeyDown presses one key and holds it, as the keymap names it ("a", "left", "space", "shift", "mod"), never a chord, which fails the step: what Key does as a key goes down, OnKeyDown, the keymap, Tab, the focused field and the menu, without its coming up. A modifier it holds joins every later KeyDown, KeyUp and Key until KeyUp releases it, so KeyDown("shift") then Key("a") presses shift+a. A key already held goes down again as its auto-repeat, except on the iOS and tvOS simulators, where UIKit reports a held key's down once. A key still held as the test ends is released then, under nsgo test -target through the platform, whose OnKeyUp the view that heard it go down hears, so none stays held into the next test. Under nsgo test -target, a platform that cannot hold a key skips the test: Android, HarmonyOS and watchOS.
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) KeyUp ¶
KeyUp releases one key KeyDown holds, which OnKeyUp of the view that heard it go down hears, wherever the focus has gone since, with the modifiers still held; a key not held fails the step. Under nsgo test -target, a platform that cannot hold a key skips the test, as for KeyDown.
func (*App) LastGamepadRumble ¶
func (a *App) LastGamepadRumble(id int) (gamepad.RumbleEvent, bool)
LastGamepadRumble returns the most recent rumble start or stop event recorded for controller id, or (gamepad.RumbleEvent{}, false) if none was recorded.
func (*App) LiveActivities ¶
func (a *App) LiveActivities() []ActivityRecord
LiveActivities returns snapshots of the activities the app started, in start order, including those that ended.
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) LongPressAt ¶
LongPressAt holds a finger at a point in the view selector matches, in its coordinates, as LongPress does its middle.
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) MediaCommand ¶
func (a *App) MediaCommand(command core.MediaCommand)
MediaCommand sends a system media command to the app's publication. It works headless and on targets that support Now Playing.
func (*App) MouseDown ¶
func (a *App) MouseDown(selector string, button driver.MouseButton)
MouseDown presses button on the middle of what selector names and holds it until MouseUp or BlurWindow.
func (*App) MouseDownAt ¶
MouseDownAt presses button at local point at in what selector names and holds it until MouseUp or BlurWindow.
func (*App) MouseDownAtWith ¶
func (a *App) MouseDownAtWith(selector string, at driver.Point, button driver.MouseButton, mods driver.Modifiers)
MouseDownAtWith presses button as MouseDownAt does, with mods held.
func (*App) MouseDownWith ¶
MouseDownWith presses button as MouseDown does, with mods held.
func (*App) MouseUp ¶
func (a *App) MouseUp(selector string, button driver.MouseButton)
MouseUp releases button held by MouseDown at the middle of what selector names. Releasing a button not held fails the step.
func (*App) MouseUpAt ¶
MouseUpAt releases button held by MouseDown at local point at in what selector names.
func (*App) MouseUpAtWith ¶
func (a *App) MouseUpAtWith(selector string, at driver.Point, button driver.MouseButton, mods driver.Modifiers)
MouseUpAtWith releases button as MouseUpAt does, with mods held.
func (*App) MouseUpWith ¶
MouseUpWith releases button as MouseUp does, with mods held.
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) NowPlaying ¶
func (a *App) NowPlaying() *core.NowPlaying
NowPlaying returns a copy of the last system media publication, or nil when the app has none.
func (*App) Offscreen ¶
func (a *App) Offscreen(off *core.OffscreenImage) *OffscreenSurface
Offscreen returns the headless model's record of off, or nil if it has never been drawn or released on this app.
func (*App) OpenLinks ¶
OpenLinks asks the app to open links, as the system does with a link of one of its URL schemes (url_schemes), or one a second launch on Windows and Linux names. The first registered desktop.OnOpenLinks or mobile.OnOpenLinks handler takes any waiting links. Runs headless and on iOS and Android targets.
func (*App) Pan ¶
Pan drags the view selector matches, or the one around it or under its middle with a pan, through each translation from the starting point.
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) PictureInPictureControl ¶
PictureInPictureControl sends what the PiP window asks of a mobile.PictureInPicture: play, pause, skip, or, for a video too, restore. interval is skip's signed duration. A video's PiP window plays and pauses its player, which PauseVideo and PlayVideo report.
func (*App) Pinch ¶
Pinch pinches the view selector matches, or the one around it with a pinch, through each scale in turn. Under -target it needs a test host with native pinch input, and skips the test's remaining steps without one.
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, including its rate capability, 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) PointerDelta ¶
PointerDelta sends relative motion to the view holding the pointer lock. A surface with no lock ignores it.
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 the field, pressable or touch-listening view selector names or is inside, 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. The step settles the keyboard focus the press moves.
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) ReceiveShare ¶
func (a *App) ReceiveShare(items ...core.SharedItem)
ReceiveShare delivers mobile.SharedItem values as another app sharing text or files would. It runs headless and on iOS and Android targets.
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) ReportPictureInPicture ¶
func (a *App) ReportPictureInPicture(selector string, state core.PictureInPictureState)
ReportPictureInPicture reports a system session state. It also finds detached custom content, whose tree never joins the app's inline UI.
func (*App) RequestQuit ¶
RequestQuit sends a user quit request, or a forced request as at logout, to the app's OnQuitRequest handlers. An approved request counts in Quits. The step runs headless and on macOS, Windows and Linux.
func (*App) RestoreGPUDevice ¶
RestoreGPUDevice simulates GPU device recreation after a device loss on the KindGPU view matching selector, bumping its generation and invoking OnReady and OnDeviceRestored.
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) ScrollHandle ¶
ScrollHandle returns the phone scroll handle's resting rectangle in the local viewport coordinates of the scroll view selector matches, and whether the scroll view currently shows a touch-draggable scroll handle (iOS or Android touch idiom, indicator shown, scrolling enabled, non-zooming, and content overflowing along its active axis).
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) SeedLeaderboardScores ¶
func (a *App) SeedLeaderboardScores(leaderboardID string, entries ...core.GameScoreEntry)
SeedLeaderboardScores seeds entries into leaderboardID for this app's fake game services backend, replacing any prior entries for that leaderboard.
func (*App) Select ¶
Select moves the selection of the field selector names, as the user would, in UTF-16 units.
func (*App) SelectTab ¶
SelectTab chooses the zero-based index in the mounted mobile.TabBar selector names. It uses the native tab bar on iOS and Android targets and delivers the same change event headless.
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. Ranges is each such text's whole content, with the text's Ref.
func (*App) SelectTextRange ¶
SelectTextRange has the selection of the Selectable view selector names run from UTF-16 offset start of the text from names to offset end of the text to names, both inside it, as a drag on the platforms does, the ends swapped when to comes before from. OnTextSelection receives the text, the extent of the texts the selection touches and the per-text ranges, each with its text's Ref: where SelectText selects the whole texts a box overlaps, this selects a part, so an app can tell texts of the same content apart.
func (*App) SetCloudAvailable ¶
SetCloudAvailable toggles the per-app in-memory cloud store's availability and updates core.Env.CanUseCloudStorage on every surface, then settles. When false, every package cloud operation returns cloud.ErrUnavailable and never silently drops writes.
func (*App) SetEnvironment ¶
func (a *App) SetEnvironment(env driver.Environment)
SetEnvironment reports env as a platform would and settles.
func (*App) SetGameServicesAuthError ¶
SetGameServicesAuthError configures an error returned by subsequent gameservices.Authenticate calls on this app (such as gameservices.ErrCancelled). Pass nil to clear the error.
func (*App) SetGameServicesError ¶
SetGameServicesError configures an error returned by subsequent game services operations on this app (such as gameservices.ErrUnavailable). Pass nil to clear the error.
func (*App) SetGameServicesFriends ¶
SetGameServicesFriends sets the player IDs treated as friends of the local player when gameservices.LoadScores is called with Friends scope.
func (*App) SetGameServicesPlayer ¶
func (a *App) SetGameServicesPlayer(p core.GamePlayer)
SetGameServicesPlayer sets the local player for this app's fake game services backend. When p.Authenticated is true the player is immediately signed in; when p.ID is non-empty and p.Authenticated is false, calling gameservices.Authenticate signs the player in; passing a zero GamePlayer signs the player out.
func (*App) SetGamepadAxis ¶
SetGamepadAxis sets axis on connected fake controller id to value (clamped to [-1, 1]). Axis updates do not trigger connect/disconnect rerenders of gamepad.Pads; read them from gamepad.State inside RequestAnimationFrame.
func (*App) SetGamepadButton ¶
SetGamepadButton sets button btn on connected fake controller id to value (clamped to [0, 1]). Button updates do not trigger connect/disconnect rerenders of gamepad.Pads; read them from gamepad.State inside RequestAnimationFrame.
func (*App) SetGamepadInfo ¶
func (a *App) SetGamepadInfo(id int, family gamepad.Family, vendorID, productID uint16, canRumble bool)
SetGamepadInfo sets the controller family, USB vendor/product IDs, and rumble capability of connected fake controller id, then settles so scopes reading gamepad.Pads rerender.
func (*App) SetVerticalBarEdge ¶
func (a *App) SetVerticalBarEdge(edge driver.VerticalBarEdge)
SetVerticalBarEdge updates only the system's preferred vertical bar edge on the current environment and settles.
func (*App) SetWindowEnvironment ¶
func (a *App) SetWindowEnvironment(title string, change func(*driver.Environment))
SetWindowEnvironment reports one window's environment changed by change, as a platform reports a window minimized, zoomed, full screen or out of sight while the app's other windows stay as they are, and settles: the window the app opened titled title, or the main window for "". The app's own surface, whose Lifecycle is every window's together, and the other windows keep the app's environment. Changes add up until SetEnvironment sets every window's again; each is applied again whenever the window's environment is reported, so change should only set fields of env. It needs a desktop environment, where the app opens windows, and runs headless only.
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) SimulateCloudChange ¶
func (a *App) SimulateCloudChange(kv map[string][]byte, files map[string][]byte, reason core.CloudChangeReason)
SimulateCloudChange applies external multi-device changes to the app's in-memory cloud store, delivers a ChangeEvent to all active cloud.WatchChanges subscribers on the engine goroutine, and settles. A nil slice in kv or files deletes that key or file; a non-nil slice writes or replaces it.
func (*App) SimulateCloudConflict ¶
SimulateCloudConflict injects a conflicting remote version for the file named name in the app's in-memory cloud store, delivers a Conflict (with a working Resolve callback) to all active cloud.OnConflict subscribers on the engine goroutine, and settles. Until resolved (or overwritten/deleted), cloud.ReadFile on name returns a *cloud.ConflictError unwrapping to cloud.ErrConflict.
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) Surface ¶
Surface finds one open surface by title:Title, id:root-test-id or index:0 (zero-based in Surfaces). It fails for no or several matches.
func (*App) Surfaces ¶
Surfaces lists the open surfaces in opening order, with the main window first. A platform with one surface has just its main surface.
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) TriggerGPUDeviceLost ¶
func (a *App) TriggerGPUDeviceLost(selector string, reason GPUDeviceLostReason, message string)
TriggerGPUDeviceLost simulates a GPU device/context loss on the KindGPU view matching selector and settles the app.
func (*App) TriggerGPUDeviceLostWithReason ¶
func (a *App) TriggerGPUDeviceLostWithReason(selector string, reason GPUDeviceLostReason, message string)
TriggerGPUDeviceLostWithReason simulates a GPU device, WebGL/WebGPU context, or Android surface loss with an explicit reason on the KindGPU view matching selector and settles the app.
func (*App) TriggerGPUSurfaceRotation ¶
TriggerGPUSurfaceRotation simulates an Android surface destruction and recreation across orientation change on the KindGPU view matching selector. If width or height is <= 0, the current surface width and height are swapped.
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) UnkeptImageCacheBytes ¶
UnkeptImageCacheBytes returns the unkept encoded bytes currently held in the model's encoded image cache.
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) VerticalBarEdge ¶
func (a *App) VerticalBarEdge() driver.VerticalBarEdge
VerticalBarEdge returns the system's preferred vertical bar edge reported to the app's environment.
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.
func (*App) WaitUntil ¶
WaitUntil settles until cond holds, failing the test after timeout of real time. Headless it advances one frame between checks unless ManualFrames was set; on a target it takes a step's frames between checks, moving the clock only while a style transition waits for its OnTransitionEnd.
type AppleSignInRequest ¶
AppleSignInRequest records the requested credential fields and the SHA-256 hex of the nonce, empty when the app supplies none.
type AudioPlayback ¶
type AudioPlayback struct {
// Volume and Rate are its current settings and Loop whether it repeats until stopped. Ended reports all ways it stopped. Restricted says a restricted scope's sound played it, which the platform holds to the restricted playbacks' share of the output's voices.
Volume, Rate float32
Loop bool
Ended bool
Restricted bool
// contains filtered or unexported fields
}
AudioPlayback is one play of a Sound in the headless audio model.
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
// LoopStart is where playback returns after its first pass.
LoopStart time.Duration
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 CodeScan ¶
CodeScan records the kinds of codes the app asked to scan. An empty list asks for QR codes.
type CustomCursor ¶
type CustomCursor = driver.CustomCursor
CustomCursor describes an image-based pointer cursor on desktops and the web.
type DirectoryPick ¶
DirectoryPick records the app's options for picking directories.
type EditMenu ¶
type EditMenu struct {
Input *View
Bounds core.Bounds
Actions core.EditAction
}
EditMenu records the system touch edit menu an input opened with Ref.OpenEditMenu, clear of Bounds in surface points, offering Actions.
type Event ¶
type Event struct {
Kind EventKind
ID core.NodeID
Text string
Count uint32
Point core.Point
// Page is a pointer's position in the root view, the surface or the
// modal, and Modifiers the keys held.
Page core.Point
Modifiers core.Modifiers
// Button is the mouse button a mouse event holds down.
Button core.MouseButton
Size core.Size
// Loaded and Total are an image's bytes loaded and expected.
Loaded, Total int64
Index int
// Phase, Velocity and Value are a gesture's.
Phase core.GesturePhase
Velocity core.Point
Value float32
// Position and PagePosition are the current point of a pan in its view
// and page coordinates. Point remains the pan's translation.
Position, PagePosition core.Point
Navigation *core.WebNavigation
// Origin and URL identify the frame that posted a web view's message;
// MainFrame says whether it is the page's top frame.
Origin string
URL string
MainFrame bool
// Time, Duration, Buffering and RateChangeable are a video's.
Time, Duration time.Duration
Buffering bool
RateChangeable bool
// URIs are the file: URLs of dropped files.
URIs []string
// Data is what a native component emitted.
Data any
// Ranges are what each text of a selection area has selected, in
// document order (EventSelectionChange), nil on a platform that
// does not report them.
Ranges []SelectedRange
// Repeat is whether EventKeyDown's key is a held key's auto-repeat.
Repeat bool
// Forced is whether EventQuitRequest was issued by the system to end its session.
Forced bool
// Finished is whether an animation ran to its end, or the platform
// closed a modal.
Finished bool
// Insets are what system UI covers of a modal (EventModalSize).
Insets core.Edges
// Touches are EventTouch's fingers.
Touches []core.Touch
// TouchGeometry is the platform's presentation snapshot for these
// touches. Without one, the committed layout and static transforms apply.
TouchGeometry *TouchGeometry
// Values are the values a pan moves as it begins and ends.
Values core.Point
// Delta and Precise are a wheel's (EventWheel).
Delta core.Point
Precise bool
}
Event is a platform report a test sends with App.Report. The report copies its slices, navigation state and touch geometry; Data keeps the test's payload.
type FilePick ¶
type FilePick struct {
Limit int
Title string
Button string
TypesName string
Start string
Types []string
}
FilePick records the app's options for picking files.
type FileSave ¶
type FileSave struct {
Name string
MIME string
Path string
Data []byte
// Preflight asks the platform to confirm the destination before writing.
Preflight bool
}
FileSave records the app's suggested file name and what it wants to save, from the file at Path when given or from Data.
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) Hold ¶
Hold holds the finger still for d; if held past the view's DelayLongPress (500 ms by default) without moving, it fires LongPress while the finger remains down, so a subsequent Move can sweep after a long press.
func (*Finger) Lift ¶
func (g *Finger) Lift()
Lift lifts the finger, where it is: a tap where it went down presses.
type GPUDeviceLostReason ¶
type GPUDeviceLostReason = driver.GPUDeviceLostReason
GPUDeviceLostReason describes why a simulated GPU device was lost.
type GPUFrameRecord ¶
type GPUFrameRecord struct {
SurfaceID uint32
ViewID driver.NodeID
Generation uint32
FrameIndex uint64
FrameSlot int
OpsCount int
CopiesCount int
PassesCount int
DrawsCount int
InstancesCount uint64
DispatchesCount int
Present bool
}
GPUFrameRecord summarizes one off-commit GPUFrame submitted by a gpu.View.
type GameServicesScoreQuery ¶
type GameServicesScoreQuery struct {
LeaderboardID string
PlayerScope core.GamePlayerScope
TimeScope core.GameTimeScope
Limit int
}
fakeGameServices is a per-app isolated in-memory implementation of driver.GameServices used by nsgotest.App so parallel tests never interfere. GameServicesScoreQuery is one gameservices.LoadScores call, as this app's fake game services saw it.
type ImageConfig ¶
type ImageConfig struct {
Source core.ImageSource
Placeholder core.ImageSource
ResizeMode core.ResizeMode
Sampling core.ImageSampling
BlurRadius core.Points
FadeDuration time.Duration
HitTestAlpha float32
// Position locates the fitted image within its view.
Position core.ObjectPosition
}
ImageConfig records the source and appearance of a mounted image.
func (ImageConfig) Same ¶
func (c ImageConfig) Same(other ImageConfig) bool
Same reports whether c and other show the same image with the same appearance.
type ImagePick ¶
type ImagePick struct {
Limit int
MaxDimension int
Quality float32
Format core.PickFormat
}
ImagePick records the app's photo picker or camera options.
type InputConfig ¶
type InputConfig struct {
Style core.TextStyle
Placeholder string
Masked bool
Readonly bool
Disabled bool
KeyboardType core.KeyboardType
// Content is where the text goes in the view: inside padding and border.
Content core.Bounds
// Padding surrounds Content inside the border. A multi-line editor
// scrolls in the padding box, its text inset by Padding.
Padding core.Edges
// Accessory identifies the view above the keyboard while the field
// has focus. AccessoryID is its application identifier.
Accessory core.NodeID
AccessoryID string
// Multiline takes several lines in a multi-line control.
Multiline bool
// MaxLength caps input in UTF-16 units. Zero leaves it unlimited.
MaxLength int
// SubmitBehavior records the requested Return action. Submit resolves its default.
SubmitBehavior core.SubmitBehavior
ReturnKey core.ReturnKeyType
AutoCapitalize core.AutoCapitalize
NoAutoCorrect bool
AutoComplete core.AutoComplete
// KeyboardAppearance is iOS's.
KeyboardAppearance core.KeyboardAppearance
// PlaceholderColor selects the placeholder text color. Zero uses the platform default.
PlaceholderColor core.Color
// SelectionColor colors selected text. Caret resolves CaretColor
// against SelectionColor.
SelectionColor core.Color
CaretColor core.Color
// AccentColor is the accent of the input's theme, for what the
// platform draws around it, such as an input method's candidates.
AccentColor core.Color
HideCaret bool
// PasteBehavior says whether a paste inserts its text.
PasteBehavior core.PasteBehavior
// HideIndicator hides a multiline input's native scroll bar.
HideIndicator bool
}
InputConfig records the appearance and editing behavior of a mounted text field.
func (*InputConfig) Caret ¶
func (c *InputConfig) Caret() core.Color
Caret returns the effective caret color.
func (*InputConfig) Highlight ¶
func (c *InputConfig) Highlight() core.Color
Highlight returns the background color of selected text.
func (*InputConfig) Submit ¶
func (c *InputConfig) Submit() core.SubmitBehavior
Submit reports the effective action of the Return key.
type KeyCommand ¶
type KeyCommand struct {
Key, Title, Group string
}
KeyCommand describes a titled keyboard binding.
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 MenuItem ¶
type MenuItem struct {
Label string
Icon core.MenuIcon
Shortcut string
Role core.MenuRole
Disabled bool
Checkable bool
Checked bool
Radio bool
Separator bool
NotInText bool
// HasHandler reports whether the app supplied an OnSelect handler.
HasHandler bool
Items []MenuItem
}
MenuItem records an application, Dock or context menu item as the test sees it, including the resolved label, icon and shortcut.
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 struct {
Animation core.ModalAnimation
// Presentation, NoCloseOnSwipe and Orientations configure iOS presentation.
Presentation core.ModalPresentation
NoCloseOnSwipe bool
Orientations core.Orientation
// NoCloseOnEscape and NoCloseOnBackdropPress describe the app's close policy.
// StatusBarTranslucent configures the Android status bar.
NoCloseOnEscape, NoCloseOnBackdropPress bool
StatusBarTranslucent bool
}
ModalConfig records how a mounted modal appears and closes.
type NativeCommand ¶
NativeCommand is a command a native view received.
type OffscreenSurface ¶
type OffscreenSurface struct {
ID uint64
Version uint64
RenderCount int
Size core.Size
Scale float32
Ops []driver.DrawOp
Released bool
}
OffscreenSurface is the headless model's record of a retained core.OffscreenImage rendered for canvases or image views. RenderCount increments only when the offscreen surface renders a new Version (on first use and after Invalidate or Resize), never when reused across subsequent frames.
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 CloudAvailable ¶
CloudAvailable starts a headless app with its per-app in-memory cloud store enabled or disabled, setting core.Env.CanUseCloudStorage accordingly from the first render.
func DiskSpace ¶
DiskSpace sets what Scope.DiskSpace answers in headless and native tests. Without it the service reports core.ErrDiskSpaceUnavailable.
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, camera and code scanner availability, and, when set, the locale, text size, device name, device model and vertical bar edge; 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 LiveActivities ¶
LiveActivities records activity starts, updates and ends in App.LiveActivities. When enabled is false, widget.ActivitiesEnabled reports false and widget.StartActivity returns widget.ErrActivitiesDisabled. Like Widgets, this option takes the process-wide service for the test.
func LocalServices ¶
func LocalServices(services ...core.LocalService) Option
LocalServices supplies the DNS-SD instances a headless app can browse.
func ManualFrames ¶
func ManualFrames() Option
ManualFrames keeps steps and waits from taking display frames so a test can inspect animations and style transitions as it advances the clock.
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 NoGPU ¶
func NoGPU() Option
NoGPU disables GPU surface support (Env.SupportsGPU() == false) for headless tests verifying fallback UI and ErrUnsupported handling.
func NoGPUCompute ¶
func NoGPUCompute() Option
NoGPUCompute disables compute shader, storage buffer and storage texture capabilities (Device.SupportsCompute() == false) to simulate WebGL 2 / OpenGL ES 3.0 targets in headless tests.
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 PictureInPictureSupport ¶
PictureInPictureSupport configures the headless system's PiP support and current readiness. Native tests always use their platform's state.
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 Size ¶
Size sets the surface size; 390 by 844 points by default, and under `nsgo test -target macos` the main window's default size, 480 by 640.
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 UpdaterState ¶
func UpdaterState(state core.UpdaterState) Option
UpdaterState supplies the updater snapshot before the first render.
func UserDirs ¶
func UserDirs(dirs map[core.StandardDir]string) Option
UserDirs pins what Scope.UserDir answers in headless and native tests: a folder left out reports core.ErrUserDirUnavailable. Without it each folder is a directory of the test's temporary one, never the user's.
func VerticalBarEdge ¶
func VerticalBarEdge(edge driver.VerticalBarEdge) Option
VerticalBarEdge starts the app with the system's preferred vertical bar edge (core.Env.VerticalBarEdge) set to edge, combining with Environment in any order. On a native target, a non-unspecified edge pins it over the platform's.
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 PictureInPictureConfig ¶
type PictureInPictureConfig struct {
Size core.Size
Paused bool
Duration time.Duration // zero is a live stream
Position time.Duration
Automatically bool
}
PictureInPictureConfig records a custom Picture in Picture session.
type PurchaseAction ¶
type PurchaseAction string
PurchaseAction identifies a store operation in App.PurchaseRequests.
const ( PurchaseProducts PurchaseAction = "products" PurchaseBuy PurchaseAction = "buy" PurchaseFinish PurchaseAction = "finish" PurchaseEntitlements PurchaseAction = "entitlements" PurchaseSync PurchaseAction = "sync" PurchaseManageSubscriptions PurchaseAction = "manageSubscriptions" PurchaseRefund PurchaseAction = "refund" )
type PurchaseRequest ¶
type PurchaseRequest struct {
Action PurchaseAction
IDs []string
Product string
AccountToken string
Quantity int
Offer *core.PromotionalOffer
Transaction string
}
PurchaseRequest records a store operation and its options. IDs are the products to look up. Transaction is the ID of a purchase to finish.
type ScreenConfig ¶
type ScreenConfig struct {
Title string
// HeaderHidden hides the header and sets HeaderHeight to zero.
HeaderHidden bool
HeaderTransparent bool
LargeTitle bool
// CanGoBack reports a preceding screen. BackHidden and BackTitle
// configure its back button.
CanGoBack bool
BackHidden bool
BackTitle string
// OwnBackTitle is the screen's own HeaderBackTitle: the label of the
// back button to it on the screen above, which that screen's
// BackTitle shows.
OwnBackTitle string
// NoPopOnSwipe disables swipe navigation. NoPopOnBack lets the app
// handle a back press through its callback.
NoPopOnSwipe bool
NoPopOnBack bool
// Background, TitleColor and TintColor select the header colors.
// Zero uses the platform defaults.
Background, TitleColor, TintColor core.Color
// Left, Right and TitleView are the header views, each a layout root
// at its content's size that no view holds, or 0.
Left, Right, TitleView core.NodeID
// Header identifies the screen's custom header view.
Header core.NodeID
// RightSystemItem, with a Right view, is the UIKit button iOS shows
// in Right's place. A press on it presses Right's first view that
// takes presses.
RightSystemItem core.HeaderSystemItem
// RightSymbols, with a Right view, are the UIKit buttons iOS shows in
// its place, a line each of an SF Symbol's name, a tab and its label. A
// press on one presses that of Right's views that take presses.
RightSymbols string
// HeaderHeight is the area the header covers from the screen's top:
// the bar and the part of the status bar the screen reaches under.
HeaderHeight core.Points
// Animation is how the screen enters and leaves.
Animation core.ScreenAnimation
// TitleFont and LargeTitleFont override the native title fonts; zero fields keep their platform defaults.
TitleFont, LargeTitleFont core.Font
// RightWithLargeTitle moves Android's trailing view beside its large title, returning to the toolbar as the header collapses.
RightWithLargeTitle bool
// TitleFills lets TitleView expand to fill the room between the bar's ends.
TitleFills bool
}
ScreenConfig records the header and navigation settings of a mounted screen.
type ScrollConfig ¶
type ScrollConfig struct {
Horizontal bool
HideIndicator bool
Behavior core.ScrollBehavior
// HeaderInset is the part of Behavior.ContentInset's top that a
// transparent or large system header covers, which a large title
// collapses into as the content scrolls under it.
HeaderInset core.Points
// Refreshable enables pull-to-refresh. Refreshing records whether
// the app keeps the spinner visible.
Refreshable bool
Refreshing bool
// MinZoomScale and MaxZoomScale bound zooming. ZoomScale is the
// scale the app requests.
MinZoomScale, MaxZoomScale float32
ZoomScale float32
// NoBouncesZoom stops pinches at the limits. NoPinchZoom disables
// pinch gestures. CenterContent centers smaller content.
NoBouncesZoom bool
NoPinchZoom bool
CenterContent bool
// Edges records top, right, bottom and left effects in that order.
Edges [4]ScrollEdge
}
ScrollConfig records the behavior and edge effects of a mounted scroll view.
func (*ScrollConfig) ClampZoom ¶
func (c *ScrollConfig) ClampZoom(scale float32) float32
ClampZoom returns scale within the configured zoom range.
func (*ScrollConfig) Equal ¶
func (c *ScrollConfig) Equal(other *ScrollConfig) bool
Equal reports whether c and other configure scrolling identically.
func (*ScrollConfig) Zooms ¶
func (c *ScrollConfig) Zooms() bool
Zooms reports whether the configured zoom range allows zooming.
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 SelectedRange ¶
type SelectedRange = driver.SelectedRange
SelectedRange is what one text of a selection area has selected, by its node and UTF-16 offsets, as Event.Ranges reports it.
type Shader ¶
type Shader struct {
Role ShaderRole
WGSL bool
Lanes []float64
// Images are what the program's image0At to image3At read, in order,
// as the view was sent them: an image of Pixels carries the copy's
// Version and Rect.
Images []driver.ImageSource
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 records effective initial volume and rate, Playbacks the individual plays oldest first, Stops how often the app stopped all plays, and Unloaded whether the app let it go.
Plays []core.SoundVoice
Playbacks []*AudioPlayback
Stops int
Unloaded bool
// contains filtered or unexported fields
}
Sound is a sound the platform decoded.
type SpeechSession ¶
SpeechSession records the active speech recognizer's language and whether it reports interim results.
type StatusBarConfig ¶
type StatusBarConfig struct {
Style core.StatusBarStyle
Hidden bool
Animated bool
Immersive bool
}
StatusBarConfig records the resolved status bar settings the app sent.
type StickyCell ¶
type StickyCell struct {
Cell core.NodeID
Start, End core.Points
// Node optionally animates the cell's inset from the viewport start.
// Start includes the static Inset.
Node uint32
Inset core.Points
}
StickyCell records a sticky cell and its travel in a scroll view.
func (StickyCell) StickyShift ¶
func (c StickyCell) StickyShift(offset core.Points) core.Points
StickyShift returns the cell's static shift at the given scroll offset.
type Surface ¶
type Surface struct {
// contains filtered or unexported fields
}
Surface is an open window, panel or tray view, as nsgotest's steps see it. A surface's handle stays tied to it after it closes. View queries and input steps use this surface; app-wide service fixtures and clocks stay on App.
func (*Surface) AccessibilityAction ¶
AccessibilityAction delegates to App.AccessibilityAction in this surface.
func (*Surface) ActiveCursor ¶
func (s *Surface) ActiveCursor() ActiveCursor
ActiveCursor delegates to App.ActiveCursor in this surface.
func (*Surface) AnimatedValue ¶
AnimatedValue delegates to App.AnimatedValue in this surface.
func (*Surface) AnswerScript ¶
AnswerScript delegates to App.AnswerScript in this surface.
func (*Surface) BlurWindow ¶
func (s *Surface) BlurWindow()
BlurWindow delegates to App.BlurWindow in this surface.
func (*Surface) CapturePNG ¶
CapturePNG delegates to App.CapturePNG in this surface.
func (*Surface) Close ¶
Close asks the surface to close as its close button does, and reports whether it closed. Its OnClosing handlers can cancel the request.
func (*Surface) Config ¶
func (s *Surface) Config() SurfaceConfig
Config returns the surface's opening configuration.
func (*Surface) CursorAt ¶
func (s *Surface) CursorAt(selector string) ActiveCursor
CursorAt delegates to App.CursorAt in this surface.
func (*Surface) DragScroll ¶
DragScroll delegates to App.DragScroll in this surface.
func (*Surface) FindMounted ¶
FindMounted delegates to App.FindMounted in this surface.
func (*Surface) GPUReadPixels ¶
GPUReadPixels returns this window's independent software GPU snapshot, as App.GPUReadPixels does for the main window.
func (*Surface) HeaderBack ¶
HeaderBack delegates to App.HeaderBack in this surface.
func (*Surface) HoverOut ¶
func (s *Surface) HoverOut()
HoverOut delegates to App.HoverOut in this surface.
func (*Surface) KeyCommands ¶
func (s *Surface) KeyCommands() []KeyCommand
KeyCommands delegates to App.KeyCommands in this surface.
func (*Surface) MouseDown ¶
func (s *Surface) MouseDown(selector string, button core.MouseButton)
MouseDown delegates to App.MouseDown in this surface.
func (*Surface) MouseDownAt ¶
MouseDownAt delegates to App.MouseDownAt in this surface.
func (*Surface) MouseDownAtWith ¶
func (s *Surface) MouseDownAtWith(selector string, at core.Point, button core.MouseButton, mods core.Modifiers)
MouseDownAtWith delegates to App.MouseDownAtWith in this surface.
func (*Surface) MouseDownWith ¶
MouseDownWith delegates to App.MouseDownWith in this surface.
func (*Surface) MouseUp ¶
func (s *Surface) MouseUp(selector string, button core.MouseButton)
MouseUp delegates to App.MouseUp in this surface.
func (*Surface) MouseUpAtWith ¶
func (s *Surface) MouseUpAtWith(selector string, at core.Point, button core.MouseButton, mods core.Modifiers)
MouseUpAtWith delegates to App.MouseUpAtWith in this surface.
func (*Surface) MouseUpWith ¶
MouseUpWith delegates to App.MouseUpWith in this surface.
func (*Surface) Navigate ¶
func (s *Surface) Navigate(selector string, nav core.WebNavigation)
Navigate delegates to App.Navigate in this surface.
func (*Surface) Paste ¶
func (s *Surface) Paste(selector string, p core.PasteEvent)
Paste delegates to App.Paste in this surface.
func (*Surface) PauseVideo ¶
func (s *Surface) PauseVideo(selector string, reason core.VideoPauseReason)
PauseVideo delegates to App.PauseVideo in this surface.
func (*Surface) PictureInPictureControl ¶
PictureInPictureControl delegates to App.PictureInPictureControl in this surface.
func (*Surface) Post ¶
func (s *Surface) Post(fn func())
Post queues fn with App.Post's scheduling. The surface is checked on the test goroutine before fn is handed to the app's graph. Like App.Post, it is safe to call from any goroutine; fn takes no test steps.
func (*Surface) PostMessage ¶
PostMessage delegates to App.PostMessage in this surface.
func (*Surface) PostMessageFrom ¶
PostMessageFrom delegates to App.PostMessageFrom in this surface.
func (*Surface) PresentModal ¶
PresentModal delegates to App.PresentModal in this surface.
func (*Surface) PressAtWith ¶
PressAtWith delegates to App.PressAtWith in this surface.
func (*Surface) PullToRefresh ¶
PullToRefresh delegates to App.PullToRefresh in this surface.
func (*Surface) QueryMounted ¶
QueryMounted delegates to App.QueryMounted in this surface.
func (*Surface) ReportPictureInPicture ¶
func (s *Surface) ReportPictureInPicture(selector string, state core.PictureInPictureState)
ReportPictureInPicture delegates to App.ReportPictureInPicture in this surface.
func (*Surface) RestoreGPUDevice ¶
RestoreGPUDevice recreates this window's software GPU device, as App.RestoreGPUDevice does for the main window.
func (*Surface) RightClick ¶
RightClick delegates to App.RightClick in this surface.
func (*Surface) Screenshot ¶
Screenshot delegates to App.Screenshot in this surface.
func (*Surface) SelectText ¶
SelectText delegates to App.SelectText in this surface.
func (*Surface) SelectTextRange ¶
SelectTextRange delegates to App.SelectTextRange in this surface.
func (*Surface) SwipeClose ¶
SwipeClose delegates to App.SwipeClose in this surface.
func (*Surface) SystemGestures ¶
func (s *Surface) SystemGestures() core.SystemGestureOptions
SystemGestures returns this surface's combined system gesture request.
func (*Surface) TouchpadScroll ¶
TouchpadScroll delegates to App.TouchpadScroll in this surface.
func (*Surface) TriggerGPUDeviceLost ¶
func (s *Surface) TriggerGPUDeviceLost(selector string, reason GPUDeviceLostReason, message string)
TriggerGPUDeviceLost simulates device loss in this window's GPU view, as App.TriggerGPUDeviceLost does for the main window.
func (*Surface) WaitForGone ¶
WaitForGone delegates to App.WaitForGone in this surface.
func (*Surface) WindowState ¶
func (s *Surface) WindowState() WindowState
WindowState reads the native window after settling. It skips headless tests and targets without native window observation, rather than inferring a window's position or focus from the commands the app sent.
type SurfaceConfig ¶ added in v0.2.0
type SurfaceConfig struct {
ID uint32
Kind SurfaceKind
Title string
Width, Height core.Points
Frame core.WindowFrame
Hidden bool
Focusable, Passive, Accessible bool
Material core.WindowMaterial
Constraints core.WindowConstraints
HideOnBlur, NoActivate bool
Dock core.PanelDock
PointerEvents core.WindowPointerEvents
Transparent, NoShadow bool
SkipTaskbar bool
// Tray and Scene identify an existing tray icon or system scene,
// when the surface was opened for one.
Tray, Scene uint32
Workspaces core.WindowWorkspaces
Main bool
}
SurfaceConfig records a surface's opening options. ID identifies the surface, and Main reports whether it is the app's main window.
type SurfaceKind ¶ added in v0.2.0
type SurfaceKind uint8
SurfaceKind identifies what the app opened.
const ( SurfaceWindow SurfaceKind = iota SurfacePanel SurfaceTrayIcon SurfaceOverlay SurfaceScene )
type TextBackground ¶
type TextBackground = driver.TextBackground
TextBackground is what a span draws behind its characters.
type TouchGeometry ¶ added in v0.2.0
TouchGeometry captures native hit targets and local positions for Event.Touches. Positions use the same order as the event's 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 struct {
Source string
Headers *VideoHeaders
Paused bool
Muted bool
Volume float32
Rate float32
Repeat bool
ResizeMode core.ResizeMode
Controls bool
PictureInPicture bool
AutoPictureInPicture bool
ProgressInterval time.Duration
AudioSource string
AudioSession core.AudioSession
// HitTestAlpha passes the pointer through video pixels below it in painted windows; 0 disables it.
HitTestAlpha float32
}
VideoConfig records the source and playback settings of a mounted video.
type VideoHeaders ¶
type VideoHeaders = driver.VideoHeaders
VideoHeaders is the snapshot of a video's HTTP request headers.
type View ¶
type View struct {
ID driver.NodeID
Kind ViewKind
Parent *View
Children []*View
Frame driver.Bounds
// ShownFrame is the frame the view shows now: mid layout transition or layout animation, or Frame when none is running.
ShownFrame driver.Bounds
Style ViewStyle
Props 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 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 []StickyCell
// Scroll is a scroll view's configuration, and ZoomScale its zoom
// (0 until it zooms).
Scroll ScrollConfig
ZoomScale float32
Image ImageConfig
Web WebConfig
// WebCommands are what the app asked a web view to do, oldest first;
// answered counts those AnswerScript went past.
WebCommands []WebCommand
Video VideoConfig
PictureInPicture PictureInPictureConfig
PiPState core.PictureInPictureState
PiPStarts, PiPStops, PiPRestores int
// 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 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 ScreenConfig
Modal 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.
func (*View) Bounds ¶ added in v0.2.0
Bounds is v's layout frame in surface points, as its ancestors and their scroll offsets place it, before transforms: what Ref.Bounds reports.
func (*View) StickyShift ¶
StickyShift is how far the sticky cell id of scroll view v moves from its frame at v's offset, as a platform moves it.
type ViewKind ¶
type ViewKind uint8
ViewKind identifies the native view a mounted model represents. Its zero value describes no known view kind.
const ( // KindView identifies a container. KindView ViewKind = iota + 1 // KindText identifies prepared text. KindText // KindInput identifies a native text editor. KindInput // KindScroll identifies a scroll view. KindScroll // KindImage identifies an image. KindImage // KindModal identifies a presented layer. KindModal // KindCanvas identifies a recorded drawing. KindCanvas // KindWeb identifies a web view. KindWeb // KindVideo identifies a video player. KindVideo // KindNative identifies an app-registered native component. KindNative // KindShader identifies a fragment shader. KindShader // KindGPU identifies a 3D GPU surface. KindGPU )
type ViewProps ¶
type ViewProps struct {
Role core.Role
// Href is the browser address of a link; other backends ignore it.
Href string
// Level is a heading's or a tree item's level, from 1; 0 for none.
Level int
Label string
// LabelledBy lists the visible elements naming this view. The model
// owns a copy; a pointer keeps ViewProps comparable. Label holds the
// resolved name too.
LabelledBy *[]core.NodeID
// LabelFor is the control this visible label activates. LabelPress
// marks a press handler that forwards activation to that control.
LabelFor core.NodeID
LabelPress bool
// Description says more about the element, read after its name, as
// ARIA's aria-description; Hint says what activating it does.
Description string
Hint string
Disabled bool
// Selected, Checked and Indeterminate (mixed) are reported to
// assistive technology, and Expanded when Expandable.
Selected bool
// MultiSelectable says a RoleGrid, RoleListbox or RoleTree permits selecting more than one of its items.
MultiSelectable bool
// SelectionItem says the view is one item in a selectable collection; it stays true when the item is not currently selected.
SelectionItem bool
Checked bool
Indeterminate bool
// Pressed is a toggle that is on and Busy an element still loading;
// Invalid a field whose content the app rejected (aria-invalid).
Pressed bool
Busy bool
Invalid bool
Expandable bool
Expanded bool
// Value is a range's or a textual element's value.
Value core.AccessibilityValue
// Accessible makes the view one element, or none.
Accessible core.Accessible
// ElementsHidden hides the view and its subtree from assistive
// technology.
ElementsHidden bool
LiveRegion core.LiveRegion
// Actions are the actions offered to assistive technology, reported
// with EventAccessibilityAction. The model owns a copy; a pointer
// keeps ViewProps comparable. Read it with ActionList.
Actions *[]core.AccessibilityAction
TestID string
// WindowDrag, PanActivation and selections are decided on the main
// thread.
WindowDrag core.WindowDrag
PanActivation core.PanActivation
// PanScrollHandoff: the view's pan shares a drag with the scroll view
// inside it where the drag starts, on iOS (core.View.PanScrollHandoff).
PanScrollHandoff bool
// SelectionArea is a view's, Selectable and SelectionColor a text's.
SelectionArea bool
Selectable core.Selectable
SelectionColor core.Color
// NoFocus keeps a pressable view out of the Tab stops, and Focusable
// makes a Tab stop of a view that takes no presses.
NoFocus, Focusable bool
// TabAfter is a shown dialog overlay's place in the Tab order, the
// view it follows, before that view's children: the native view
// right before it where the app put it, as WAI-ARIA's non-modal
// popups follow their trigger. Backends that order Tab themselves
// take it; the toolkits ordering it by their own trees (AppKit's key
// view loop, the browser's DOM) leave the overlay where it is.
TabAfter core.NodeID
// Topmost marks a Topmost overlay hoisted above modals on its host.
Topmost bool
// Appearance is the one its subtree forces (core.Scope.SetSubtreeAppearance),
// for the platform's views in it; AppearanceSystem follows the window.
Appearance core.Appearance
// PointerEvents, HitSlop and DelayLongPress are the view's; a zero
// DelayLongPress is the platform's 500 ms.
PointerEvents core.PointerEvents
HitSlop core.Edges
DelayLongPress time.Duration
// Ripple is Android's press ripple, nil for none. The model owns a copy.
Ripple *core.Ripple
}
ViewProps records a mounted view's identity, accessibility and interaction settings.
func (*ViewProps) ActionList ¶
func (p *ViewProps) ActionList() []core.AccessibilityAction
ActionList returns the recorded accessibility actions.
func (*ViewProps) FocusStop ¶
FocusStop reports whether a visible, mounted non-input view takes keyboard focus.
type ViewStyle ¶
type ViewStyle struct {
Background core.Color
// CornerRadius rounds every corner, unless Corners is set: then each
// corner has its own radius. Platforms fit radii that do not fit
// with Corners.Fit.
CornerRadius core.Points
Corners core.Corners
// ContinuousCorners eases the corners into the edges (RoundedRect)
// instead of drawing quarter circles.
ContinuousCorners bool
// BorderWidth and BorderColor are the border on every side, unless
// Borders is set: then each side has its width there and its color
// in BorderColors.
BorderWidth core.Points
BorderColor core.Color
Borders core.Edges
BorderColors core.EdgeColors
// BorderStyle dashes or dots the border; 0 is solid.
BorderStyle core.BorderStyle
Outline core.Outline
Opacity float32
// Clip clips children to the padding box, inside the border, with its corners.
Clip bool
ShadowColor core.Color
ShadowOffset core.Point
ShadowRadius core.Points
// TintColor recolors an image's opaque pixels; 0 keeps its colors.
TintColor core.Color
// Cursor is the pointer's look over the view; Auto inherits the
// nearest ancestor's. Pressables keep the platform's arrow.
Cursor core.Cursor
// CursorImage is an optional custom cursor image over the view; it
// travels behind a pointer so ViewStyle stays comparable, and the core
// keeps the same pointer while Equal.
CursorImage *core.CustomCursor
// Transform moves, scales and rotates the view around its transform
// origin without moving its children's frames; hit testing follows
// it. The core has resolved its percentages.
Transform core.Transform
// Origin is where the transform acts, from the view's center, and
// OriginZ how far toward the viewer.
Origin core.Point
OriginZ core.Points
// BackfaceHidden hides the view while its rotations turn its back to
// the viewer.
BackfaceHidden bool
// ChildPerspective, when set, is the depth children's rotations out
// of the plane are seen from, at the view's center (ChildPerspective
// the function).
ChildPerspective core.Points
BlendMode core.BlendMode
// Material and Glass record the view's backdrop presentation.
Material core.BackdropMaterial
// Elevation is Android's: how high the view floats, which casts the
// system's shadow under it where the style casts none.
Elevation core.Points
Glass core.GlassEffect
// GlassInteractive lets Liquid Glass answer presses on platforms that support it (macOS 27 and iOS 26).
GlassInteractive bool
// Effects are shadows, gradients, filters and masks, nil without any.
Effects *core.Effects
// Transition, when it has a duration, animates the change from the
// previous ViewStyle to this one.
Transition core.Transition
// Animation runs keyframes over the view while it is set; a change
// starts it again.
Animation core.KeyframeAnimation
// Hidden hides the view and its children (display none, visibility
// hidden).
Hidden bool
}
ViewStyle records the resolved look of one mounted view. Effects, custom cursors keep their immutable app-value identities.
type WebCommand ¶
type WebCommand struct {
Command WebCommandKind
Value string
Data any
}
WebCommand records what the app asked a web view to do. Value is a message or script. WebLoad's Data is a *core.WebSource and WebSendInput's is a *core.WebInput.
type WebCommandKind ¶
type WebCommandKind uint8
WebCommandKind identifies an action recorded in View.WebCommands.
const ( WebReload WebCommandKind = iota + 1 WebGoBack WebGoForward WebStopLoading WebPostMessage WebInjectJavaScript WebSendInput WebLoad )
type WebConfig ¶
type WebConfig struct {
Source WebSource
InjectedJavaScript string
InjectedJavaScriptBeforeContent string
UserAgent string
UserAgentSuffix string
// Headers accompany the initial URL request where custom headers are supported.
Headers map[string]string
// Incognito keeps website data in memory for this view.
Incognito bool
// SchemeHandlers are the app's responders for its URL schemes.
SchemeHandlers map[string]core.WebSchemeHandler
NoScroll bool
NoJavaScript bool
Muted bool
PinchZoom bool
BackForwardGestures bool
Mobile bool
// DownloadDir is where downloads go. An empty path disables saving them.
DownloadDir string
// Restricted applies the navigation rules below.
Restricted bool
// Hosts and Schemes are the space-separated host patterns and page schemes
// allowed by a restricted view.
Hosts, Schemes string
Media core.WebMedia
}
WebConfig records the source, settings and permissions of a mounted web view.
func (*WebConfig) Navigable ¶
Navigable reports whether the page may navigate to rawURL in its top frame.
func (*WebConfig) OpenWindowEvent ¶
func (c *WebConfig) OpenWindowEvent(r core.WebWindowRequest) Event
OpenWindowEvent returns the platform report for the page's request to open another window, using the recorded navigation policy.
func (*WebConfig) SourceNavigable ¶
SourceNavigable reports whether the app may load rawURL in the web view.
type WindowAction ¶
type WindowAction string
WindowAction identifies a window request recorded by App.Window.
const ( WindowSetTitleBar WindowAction = "setTitleBar" WindowMinimize WindowAction = "minimize" WindowToggleMaximize WindowAction = "toggleMaximize" WindowToggleFullScreen WindowAction = "toggleFullScreen" WindowSetFullScreen WindowAction = "setFullScreen" WindowClose WindowAction = "close" WindowSetFrame WindowAction = "setFrame" WindowSetLevel WindowAction = "setLevel" WindowOrderFront WindowAction = "orderFront" WindowSetMenuBar WindowAction = "setMenuBar" WindowSetControls WindowAction = "setControls" WindowSetMaterial WindowAction = "setMaterial" WindowSetConstraints WindowAction = "setConstraints" WindowShow WindowAction = "show" WindowHide WindowAction = "hide" WindowDestroy WindowAction = "destroy" WindowSetAnchor WindowAction = "setAnchor" WindowSetWorkspaces WindowAction = "setWorkspaces" WindowSetPointerEvents WindowAction = "setPointerEvents" WindowSetTransparent WindowAction = "setTransparent" WindowSetShadow WindowAction = "setShadow" WindowSetSkipTaskbar WindowAction = "setSkipTaskbar" WindowFitSize WindowAction = "fitSize" )
type WindowRequest ¶
type WindowRequest struct {
Action WindowAction
TitleBar core.TitleBarStyle
// Height is the custom title bar's height, zero for the platform's own.
Height core.Points
Frame core.WindowFrame
Level core.WindowLevel
MenuBar core.MenuBarMode
Controls core.WindowControls
Material core.WindowMaterial
Constraints core.WindowConstraints
// Anchor is the tray icon below which the panel opens, if set.
Anchor uint32
// AnchorBounds and Placement locate the panel beside a rectangle in screen points.
AnchorBounds core.Bounds
Placement core.WindowPlacement
Workspaces core.WindowWorkspaces
PointerEvents core.WindowPointerEvents
// On enables transparency, the window shadow, skipping the taskbar, or
// entering full screen, according to Action.
On bool
// DisplayID is the display WindowSetFullScreen enters on, empty for the
// window's current display.
DisplayID string
}
WindowRequest records a window action and the options it was given.
type WindowState ¶
type WindowState struct {
Frame core.WindowFrame
Visible, Focused bool
}
WindowState is the native window containing a surface, sampled on its UI thread. Frame uses the desktop screen points Window.ShowAt takes; Move is false when the platform cannot report its position, as on Wayland.
Source Files
¶
- animated_values.go
- assets.go
- audio.go
- automation.go
- automation_apptool.go
- automation_off.go
- cloud.go
- discovery.go
- event.go
- file_requests.go
- files.go
- gamepad.go
- gameservices.go
- gpu.go
- image.go
- input.go
- menu_records.go
- microphone.go
- miniprogramsignin.go
- modal.go
- model.go
- nowplaying.go
- nsgotest.go
- overlay.go
- pictureinpicture.go
- pointer.go
- pointerlock.go
- purchases.go
- render.go
- render_other.go
- reports.go
- requests.go
- screen.go
- scroll.go
- scrollhandle.go
- selector.go
- sensorext.go
- sensors.go
- service_records.go
- speak.go
- steps.go
- sticky.go
- surface.go
- surface_gpu.go
- surface_records.go
- surface_steps.go
- target.go
- trace.go
- video.go
- view_kind.go
- view_props.go
- view_style.go
- views.go
- web.go
- widgets.go
- windowstate.go