Documentation
¶
Overview ¶
Package fake is an in-memory platform.Backend for testing the public API without a GUI. Its event loop runs on the goroutine that calls Run, which is treated as the main thread.
Index ¶
- Variables
- type Backend
- func (b *Backend) App() platform.AppController
- func (b *Backend) AppMenu() *platform.Menu
- func (b *Backend) Applications() ([]platform.Application, error)
- func (b *Backend) ClickMenuItem(id int)
- func (b *Backend) ClickNotification(id string)
- func (b *Backend) Clipboard() platform.Clipboard
- func (b *Backend) ContentRuleLists() []string
- func (b *Backend) Delivered(n *platform.Notification)
- func (b *Backend) Dialogs() platform.Dialogs
- func (b *Backend) EmitMediaCommand(cmd platform.MediaCommand, position time.Duration)
- func (b *Backend) EmitNetwork(status platform.NetworkStatus)
- func (b *Backend) EmitPower(event string)
- func (b *Backend) Init(h platform.AppHandler, _ platform.AppOptions) error
- func (b *Backend) IsMainThread() bool
- func (b *Backend) LastFileWatch() *FileWatch
- func (b *Backend) MenuUpdates() []*platform.MenuItem
- func (b *Backend) Name() string
- func (b *Backend) Network() platform.Network
- func (b *Backend) NewFileWatch(notify func(platform.FileWatchNotice)) (platform.FileWatch, error)
- func (b *Backend) NewTray(h platform.TrayHandler) (platform.Tray, error)
- func (b *Backend) NewWindow(o *platform.WindowOptions, h platform.WindowHandler) (platform.Window, error)
- func (b *Backend) Notification(id string) *platform.Notification
- func (b *Backend) Notifications() []*platform.Notification
- func (b *Backend) NotificationsSupported() bool
- func (b *Backend) NowPlaying() platform.NowPlaying
- func (b *Backend) PopupMenu(m *platform.Menu, _ platform.Window, pos *platform.Point)
- func (b *Backend) Popups() []Popup
- func (b *Backend) Power() platform.Power
- func (b *Backend) PreferenceReads() int
- func (b *Backend) PressHotkey(acc string)
- func (b *Backend) Quit()
- func (b *Backend) QuitRequested() bool
- func (b *Backend) RegisterHotkey(id int, acc string) error
- func (b *Backend) RemoveAllNotifications()
- func (b *Backend) RemoveNotification(id string)
- func (b *Backend) ReplaceFile(target, replacement string) error
- func (b *Backend) Run() error
- func (b *Backend) Screen() platform.Screen
- func (b *Backend) Secrets() platform.Secrets
- func (b *Backend) SetActive(active bool)
- func (b *Backend) SetApplicationMenu(m *platform.Menu)
- func (b *Backend) SetNoSessionState(v bool)
- func (b *Backend) SetPreferences(p platform.Preferences)
- func (b *Backend) SetSavedLocale(tag string)
- func (b *Backend) SetSecretError(err error)
- func (b *Backend) SetSystemLanguages(tags ...string)
- func (b *Backend) SetSystemRegion(r platform.Region)
- func (b *Backend) SetTrayDark(dark bool)
- func (b *Backend) Shell() platform.Shell
- func (b *Backend) ShowNotification(n *platform.Notification, done func(error))
- func (b *Backend) Signal()
- func (b *Backend) Step()
- func (b *Backend) StoredSecret(service, account string) ([]byte, bool)
- func (b *Backend) Theme() platform.Theme
- func (b *Backend) TrayIDs() []string
- func (b *Backend) UnregisterHotkey(id int)
- func (b *Backend) UpdateMenuItem(it *platform.MenuItem)
- func (b *Backend) Wake()
- func (b *Backend) WebViewAvailable() bool
- func (b *Backend) Windows() []*Window
- type ContentRuleList
- type DataStore
- type FileWatch
- type Popup
- type Surface
- func (s *Surface) Accessibility() (*platform.AccessTree, int)
- func (s *Surface) CancelDataDrag()
- func (s *Surface) Cursor() platform.Cursor
- func (s *Surface) DataDrag() *platform.DragRequest
- func (s *Surface) FinishDataDrag(r transfer.Result)
- func (s *Surface) Frame() bool
- func (s *Surface) FrameRate() float64
- func (s *Surface) Frames() int
- func (s *Surface) Native() platform.SurfaceNative
- func (s *Surface) NewWebView(o *platform.WindowOptions, h platform.WindowHandler) (platform.WebView, error)
- func (s *Surface) Pixel(x, y int) [4]byte
- func (s *Surface) PlaceWebViews(views []platform.WebViewPlacement)
- func (s *Surface) Placements() int
- func (s *Surface) PresentPixels(pix []byte, stride, width, height int)
- func (s *Surface) Press(x, y float64) *WebView
- func (s *Surface) RefreshRate() float64
- func (s *Surface) RequestFrame()
- func (s *Surface) Send(ev platform.SurfaceEvent) bool
- func (s *Surface) SetCursor(c platform.Cursor)
- func (s *Surface) SetDropFormats(f []transfer.Format)
- func (s *Surface) SetFrameRate(fps float64)
- func (s *Surface) SetMaximizeButton(r platform.RectF)
- func (s *Surface) SetRefreshRate(hz float64)
- func (s *Surface) SetTextInput(t platform.TextInputState)
- func (s *Surface) Size() (float64, float64, float64)
- func (s *Surface) StartDataDrag(r platform.DragRequest)
- func (s *Surface) TextInput() (bool, platform.RectF)
- func (s *Surface) TextInputState() platform.TextInputState
- func (s *Surface) UpdateAccessibility(tree *platform.AccessTree)
- func (s *Surface) WebViewAt(x, y float64) *WebView
- func (s *Surface) WebViews() []*WebView
- type WebView
- type Window
- func (w *Window) ActiveAppearance() bool
- func (w *Window) Blur()
- func (w *Window) Bounds() platform.Rect
- func (w *Window) CallAsyncFunction(body string, cb func(string, error))
- func (w *Window) CanGoBack() bool
- func (w *Window) CanGoForward() bool
- func (w *Window) CapturePage(cb func([]byte, error))
- func (w *Window) CaptureState(kind platform.CaptureKind) platform.CaptureState
- func (w *Window) Center()
- func (w *Window) ClearScripts()
- func (w *Window) ClickMenuItem(id int)
- func (w *Window) Close()
- func (w *Window) CloseDevTools()
- func (w *Window) ContentBounds() platform.Rect
- func (w *Window) ContentRules() []*ContentRuleList
- func (w *Window) Document() (path string, edited bool)
- func (w *Window) DroppedFiles() []string
- func (w *Window) Eval(js string)
- func (w *Window) FakeSurface() *Surface
- func (w *Window) FlashFrame(v bool)
- func (w *Window) Focus()
- func (w *Window) GoBack()
- func (w *Window) GoForward()
- func (w *Window) Handle() uintptr
- func (w *Window) HasShadow() bool
- func (w *Window) Hide()
- func (w *Window) IsAlwaysOnTop() bool
- func (w *Window) IsAudible() bool
- func (w *Window) IsAudioMuted() bool
- func (w *Window) IsClosable() bool
- func (w *Window) IsClosed() bool
- func (w *Window) IsDevToolsOpened() bool
- func (w *Window) IsFocused() bool
- func (w *Window) IsFullScreen() bool
- func (w *Window) IsLoading() bool
- func (w *Window) IsMaximizable() bool
- func (w *Window) IsMaximized() bool
- func (w *Window) IsMinimizable() bool
- func (w *Window) IsMinimized() bool
- func (w *Window) IsMovable() bool
- func (w *Window) IsResizable() bool
- func (w *Window) IsVisible() bool
- func (w *Window) LoadFile(path, _ string)
- func (w *Window) LoadHTML(html, _ string)
- func (w *Window) LoadURL(url string)
- func (w *Window) Maximize()
- func (w *Window) Menu() *platform.Menu
- func (w *Window) Minimize()
- func (w *Window) Opacity() float64
- func (w *Window) OpenDevTools()
- func (w *Window) PictureInPictureActive(cb func(bool))
- func (w *Window) PlaceFlyout(f platform.Flyout, size platform.Size)
- func (w *Window) Print()
- func (w *Window) PrintToPDF(o platform.PDFOptions, cb func([]byte, error))
- func (w *Window) ProcessID() int
- func (w *Window) Reload(bool)
- func (w *Window) Restore()
- func (w *Window) RestoreSessionState(state []byte) bool
- func (w *Window) Scripts() []string
- func (w *Window) SessionState() []byte
- func (w *Window) SetActiveAppearance(v bool)
- func (w *Window) SetAlwaysOnTop(bool)
- func (w *Window) SetAudible(v bool)
- func (w *Window) SetAudioMuted(v bool)
- func (w *Window) SetAutoHideMenu(v bool)
- func (w *Window) SetBackgroundColor(c platform.Color)
- func (w *Window) SetBounds(r platform.Rect)
- func (w *Window) SetCapture(kind platform.CaptureKind, state platform.CaptureState)
- func (w *Window) SetCaptureState(kind platform.CaptureKind, state platform.CaptureState)
- func (w *Window) SetClosable(bool)
- func (w *Window) SetContentBounds(r platform.Rect)
- func (w *Window) SetContentProtection(bool)
- func (w *Window) SetContentRules(lists []any)
- func (w *Window) SetDocumentEdited(v bool)
- func (w *Window) SetFullScreen(v bool)
- func (w *Window) SetHasShadow(bool)
- func (w *Window) SetIcon(png []byte) error
- func (w *Window) SetIgnoreMouseEvents(bool)
- func (w *Window) SetMaximizable(bool)
- func (w *Window) SetMaximumSize(platform.Size)
- func (w *Window) SetMenu(m *platform.Menu)
- func (w *Window) SetMinimizable(bool)
- func (w *Window) SetMinimumSize(platform.Size)
- func (w *Window) SetMovable(bool)
- func (w *Window) SetOpacity(float64)
- func (w *Window) SetProcessID(pid int)
- func (w *Window) SetProgressBar(state string, value float64)
- func (w *Window) SetRepresentedFile(p string)
- func (w *Window) SetResizable(bool)
- func (w *Window) SetSkipTaskbar(v bool)
- func (w *Window) SetTitle(t string)
- func (w *Window) SetUserAgent(string)
- func (w *Window) SetUserScripts(scripts []platform.UserScript)
- func (w *Window) SetVibrancy(string)
- func (w *Window) SetVisibleOnAllWorkspaces(v bool)
- func (w *Window) SetWindowButtonsTheme(string)
- func (w *Window) SetZoom(f float64)
- func (w *Window) Show()
- func (w *Window) ShowInactive()
- func (w *Window) StartDrag()
- func (w *Window) StopLoading()
- func (w *Window) Surface() platform.Surface
- func (w *Window) Title() string
- func (w *Window) TitleBar() platform.TitleBar
- func (w *Window) TitleBarDoubleClicked()
- func (w *Window) TogglePictureInPicture()
- func (w *Window) URL() string
- func (w *Window) Unmaximize()
- func (w *Window) UserAgent() string
- func (w *Window) UserClose() bool
- func (w *Window) UserScripts() []platform.UserScript
- func (w *Window) WebViewHandle() uintptr
- func (w *Window) Zoom() float64
Constants ¶
This section is empty.
Variables ¶
var Apps []platform.Application
Apps are the applications Applications lists, which tests set.
var ErrNoReply = errors.New("fake: no reply")
ErrNoReply makes Window.CallAsyncFunction never call back, like a promise that never settles.
var Opened []string
Opened are the paths OpenApplication was given.
var OpenedExternal []string
OpenedExternal are the URLs OpenExternal was given. Main thread only.
var Trashed []string
Trashed are the paths TrashItem was given.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// IgnoresQuit makes Quit leave the event loop running, as AppKit's
// has been seen to; Quits counts the calls.
IgnoresQuit bool
Quits int
// ClipboardError injects a failed write while preserving existing ownership.
ClipboardError error
// ClipboardDuringFlush simulates a toolkit pumping a nested event loop
// after releasing providers but before its storage operation returns.
ClipboardDuringFlush func()
// KeepsLocale makes the backend keep the app's language, as macOS
// does, in SavedLocale; without it the core keeps it in a file.
KeepsLocale bool
// UILanguages are the languages SetLanguages told last, and
// UIRightToLeft its direction.
UILanguages []string
UIRightToLeft bool
// Watching reports whether power events were asked for, Awake counts the
// KeepAwake calls not released yet.
Watching bool
Awake int
// Playing is what NowPlaying.Set showed last, nil once removed, and
// NowPlayingSets counts the calls.
Playing *platform.NowPlayingInfo
NowPlayingSets int
// Online and Metered are what Network.Status answers with, and
// WatchingNetwork whether Network.Watch was called.
Online, Metered bool
WatchingNetwork bool
// FileWatches are the file watches made, FileWatchError what making
// one fails with, FileWatchSubtree whether they take Subtree targets
// and FileWatchNoFiles whether they refuse files.
FileWatches []*FileWatch
FileWatchError error
FileWatchSubtree bool
FileWatchNoFiles bool
// FileWatchAddHook is the AddHook of the file watches made.
FileWatchAddHook func(platform.FileWatchTarget) error
// ReplaceFileHook, when set, replaces files in place of ReplaceFile,
// as a system that fails halfway would.
ReplaceFileHook func(target, replacement string) error
// URLSchemes are the registered URL schemes, by scheme: "id name".
URLSchemes map[string]string
// LoginItem is the command that starts the app at login: "id name arg".
LoginItem string
// DockMenu is the menu of the Dock icon.
DockMenu *platform.Menu
// Active is what App.IsActive answers; SetActive changes it.
Active bool
// ForegroundAllowed counts AllowForeground calls.
ForegroundAllowed int
// ActivationToken is the token of WithActivationToken while its
// function runs.
ActivationToken string
// Cleared counts ClearBrowsingData calls for the default store.
Cleared int
// DataStores are the stores NewDataStore made, in order.
DataStores []*DataStore
ContentRuleCompiles int
// CookiesCleared counts ClearCookies calls.
CookiesCleared int
// RecentDocuments are the paths AddRecentDocument recorded, in order,
// without the ones ClearRecentDocuments removed.
RecentDocuments []string
// RecentCleared counts ClearRecentDocuments calls.
RecentCleared int
// JumpList is the list of the last SetJumpList call, JumpListCommits
// the number of calls.
JumpList platform.JumpList
JumpListCommits int
// Dialog results returned by the next dialog.
OpenResult []string
SaveResult string
MessageResult platform.MessageBoxResult
// OnOpenDialog, OnSaveDialog and OnMessageBox, when set, answer the
// dialogs instead of the results above. They run on the main thread.
OnOpenDialog func(opts *platform.OpenDialogOptions) []string
OnSaveDialog func(opts *platform.SaveDialogOptions) string
OnMessageBox func(opts *platform.MessageBoxOptions) platform.MessageBoxResult
// NotificationError, when set, is what showing a notification fails
// with.
NotificationError error
// OnNotification, when set, handles delivery on the main thread, allowing
// tests to model an authorization answer that arrives asynchronously.
OnNotification func(*platform.Notification, func(error))
// NoWebView makes WebViewAvailable report no system webview, as a
// machine without one does.
NoWebView bool
// contains filtered or unexported fields
}
Backend is a fake platform backend.
func (*Backend) App ¶
func (b *Backend) App() platform.AppController
func (*Backend) Applications ¶
func (b *Backend) Applications() ([]platform.Application, error)
func (*Backend) ClickMenuItem ¶
ClickMenuItem simulates choosing a menu item.
func (*Backend) ClickNotification ¶
ClickNotification reports a click on a notification, as the platform does. It runs on the main thread, like the backends report it.
func (*Backend) ContentRuleLists ¶ added in v0.1.8
ContentRuleLists returns the identifiers of the lists kept.
func (*Backend) Delivered ¶
func (b *Backend) Delivered(n *platform.Notification)
Delivered adds a notification the platform still shows from an earlier run of the app, which the app did not show in this one.
func (*Backend) EmitMediaCommand ¶ added in v0.1.13
func (b *Backend) EmitMediaCommand(cmd platform.MediaCommand, position time.Duration)
EmitMediaCommand simulates a media key or a command of the system's media controls.
func (*Backend) EmitNetwork ¶
func (b *Backend) EmitNetwork(status platform.NetworkStatus)
EmitNetwork reports a network status to the app, as a backend does when it may have changed.
func (*Backend) Init ¶
func (b *Backend) Init(h platform.AppHandler, _ platform.AppOptions) error
func (*Backend) IsMainThread ¶
func (*Backend) LastFileWatch ¶
LastFileWatch returns the FileWatch created last.
func (*Backend) MenuUpdates ¶
MenuUpdates returns the items passed to UpdateMenuItem.
func (*Backend) NewFileWatch ¶
func (*Backend) NewWindow ¶
func (b *Backend) NewWindow(o *platform.WindowOptions, h platform.WindowHandler) (platform.Window, error)
func (*Backend) Notification ¶
func (b *Backend) Notification(id string) *platform.Notification
Notification returns the notification with an id, or nil.
func (*Backend) Notifications ¶
func (b *Backend) Notifications() []*platform.Notification
Notifications returns the notifications shown and not yet removed.
func (*Backend) NotificationsSupported ¶
Notifications are recorded rather than shown, so that a test can see what the app asked for and report a click as a platform does.
func (*Backend) NowPlaying ¶ added in v0.1.13
func (b *Backend) NowPlaying() platform.NowPlaying
func (*Backend) PreferenceReads ¶
PreferenceReads returns how many times Preferences() read the backend, for tests.
func (*Backend) PressHotkey ¶
PressHotkey simulates a global shortcut.
func (*Backend) QuitRequested ¶
QuitRequested simulates Cmd+Q and reports whether the app agreed.
func (*Backend) RemoveAllNotifications ¶
func (b *Backend) RemoveAllNotifications()
func (*Backend) RemoveNotification ¶
func (*Backend) ReplaceFile ¶
ReplaceFile renames replacement over target, with the target's permissions. On Windows it gives a reader holding the target open without sharing deletes a moment to let go, as the Windows backend does: a test reading the file while the app saves it is such a reader.
func (*Backend) SetActive ¶ added in v0.1.13
SetActive makes the app the active one, or not, and reports it as the system does when it changes (main thread).
func (*Backend) SetApplicationMenu ¶
func (*Backend) SetNoSessionState ¶ added in v0.1.13
SetNoSessionState makes the pages keep no session state, as WebView2's: SessionState returns nil and RestoreSessionState fails.
func (*Backend) SetPreferences ¶
func (b *Backend) SetPreferences(p platform.Preferences)
SetPreferences changes the desktop's preferences, as the user does in the system's settings.
func (*Backend) SetSavedLocale ¶
SetSavedLocale sets what the system keeps of the app's language, as the user does choosing it in macOS's System Settings while the app is not running.
func (*Backend) SetSecretError ¶
SetSecretError makes every Secrets call fail with err, or work again when err is nil. It may be called from any goroutine.
func (*Backend) SetSystemLanguages ¶
SetSystemLanguages changes the languages the user prefers, as the user does in the system's settings, and reports it; none goes back to en-US.
func (*Backend) SetSystemRegion ¶
SetSystemRegion changes the user's regional formats, as the user does in the system's settings, and reports it.
func (*Backend) SetTrayDark ¶
SetTrayDark turns the menu bar the icons show on dark or light, as the system's appearance or the wallpaper does, and tells the icons.
func (*Backend) ShowNotification ¶
func (b *Backend) ShowNotification(n *platform.Notification, done func(error))
func (*Backend) StoredSecret ¶
StoredSecret returns the secret stored for service and account, as the system's store would show it.
func (*Backend) UnregisterHotkey ¶
func (*Backend) UpdateMenuItem ¶
func (*Backend) WebViewAvailable ¶
WebViewAvailable reports whether the fake system webview is there: windows showing web pages work, unless NoWebView says otherwise.
type ContentRuleList ¶ added in v0.1.8
type ContentRuleList struct {
ID, Identifier, Rules string
}
ContentRuleList is a list CompileContentRules made: the handle SetContentRules gets.
type DataStore ¶ added in v0.1.13
type DataStore struct {
Opts platform.DataStoreOptions
// Closed tells that Close was called; Cleared lists the types of
// ClearBrowsingData calls.
Closed bool
Cleared []platform.SiteData
// contains filtered or unexported fields
}
DataStore is a website data store NewDataStore made, with cookies of its own.
type FileWatch ¶
type FileWatch struct {
// Subtree makes Add accept Subtree targets, as Windows does.
Subtree bool
// NoFiles makes Add refuse targets that aren't directories, as every
// system backend does.
NoFiles bool
// AddHook, when set, runs in Add before the target is enrolled; an
// error it returns is Add's.
AddHook func(platform.FileWatchTarget) error
// contains filtered or unexported fields
}
FileWatch records the targets the core enrolls; tests report changes with Notify.
func (*FileWatch) Notify ¶
func (w *FileWatch) Notify(n platform.FileWatchNotice)
Notify reports n, as a backend's goroutine would, unless the watch is closed.
func (*FileWatch) Targets ¶
func (w *FileWatch) Targets() []platform.FileWatchTarget
Targets returns the enrolled targets.
type Surface ¶
type Surface struct {
// Scale is the device pixels per DIP.
Scale float64
// contains filtered or unexported fields
}
Surface is a fake window surface: it records what the content asks of it, and tests deliver events through Send.
func (*Surface) Accessibility ¶
func (s *Surface) Accessibility() (*platform.AccessTree, int)
Accessibility returns the last accessibility tree the content gave, and how many it gave.
func (*Surface) CancelDataDrag ¶
func (s *Surface) CancelDataDrag()
func (*Surface) Cursor ¶
Cursor returns the pointer shape the content set; TextInput whether it asked for text input.
func (*Surface) DataDrag ¶
func (s *Surface) DataDrag() *platform.DragRequest
DataDrag returns the active native-source request. Main thread only.
func (*Surface) FinishDataDrag ¶
FinishDataDrag delivers the native source's result once. Main thread only.
func (*Surface) Frame ¶
Frame draws a frame when the content asked for one since the last, as the display would, and reports whether it did.
func (*Surface) FrameRate ¶ added in v0.1.13
FrameRate returns what SetFrameRate last set, 0 for the display's rate.
func (*Surface) Native ¶
func (s *Surface) Native() platform.SurfaceNative
func (*Surface) NewWebView ¶
func (s *Surface) NewWebView(o *platform.WindowOptions, h platform.WindowHandler) (platform.WebView, error)
func (*Surface) PlaceWebViews ¶
func (s *Surface) PlaceWebViews(views []platform.WebViewPlacement)
func (*Surface) Placements ¶
Placements counts the PlaceWebViews calls.
func (*Surface) PresentPixels ¶
func (*Surface) Press ¶
Press presses the pointer at x, y as the platform would: on the web view taking it there, which tells the content (WebViewPress) and returns it, else on the content, and reports nil.
func (*Surface) RefreshRate ¶
RefreshRate returns the display's refresh rate, 60 unless SetRefreshRate set another.
func (*Surface) RequestFrame ¶
func (s *Surface) RequestFrame()
func (*Surface) Send ¶
func (s *Surface) Send(ev platform.SurfaceEvent) bool
Send delivers an event to the window's content, on the main thread, and returns what the content answered.
func (*Surface) SetDropFormats ¶
func (*Surface) SetFrameRate ¶ added in v0.1.13
SetFrameRate records the frames a second the content asks for (platform.FrameRateSurface), which FrameRate returns.
func (*Surface) SetMaximizeButton ¶ added in v0.1.8
SetMaximizeButton records the button in the window's MaximizeButton (platform.MaximizeButtonSurface).
func (*Surface) SetRefreshRate ¶
SetRefreshRate sets the display's refresh rate.
func (*Surface) SetTextInput ¶
func (s *Surface) SetTextInput(t platform.TextInputState)
func (*Surface) StartDataDrag ¶
func (s *Surface) StartDataDrag(r platform.DragRequest)
func (*Surface) TextInputState ¶
func (s *Surface) TextInputState() platform.TextInputState
TextInputState returns the last state of text input the content set.
func (*Surface) UpdateAccessibility ¶
func (s *Surface) UpdateAccessibility(tree *platform.AccessTree)
type WebView ¶
type WebView struct {
*Window
// Placement is where the content last showed the web view, while
// Shown; Focused tells that Focus or TabInto gave it the keyboard
// since, TabbedBack that TabInto did so going back.
Placement platform.WebViewPlacement
Shown bool
Focused bool
TabbedBack bool
// contains filtered or unexported fields
}
WebView is a web view under a fake Surface (Surface.NewWebView): a Window of its own for its page, which its handler hears of, without the window's methods.
type Window ¶
type Window struct {
H platform.WindowHandler
Opts *platform.WindowOptions
// Flyout is how a flyout was placed last.
Flyout platform.Flyout
// Restored is the last state RestoreSessionState put back.
Restored []byte
// Dropped is what DroppedFiles returns, once.
Dropped []string
// PDF holds the options of the last PrintToPDF.
PDF platform.PDFOptions
// HTML holds the documents LoadHTML loaded, in order.
HTML []string
// UserScriptUpdates counts the calls of SetUserScripts.
UserScriptUpdates int
ContentRuleUpdates int
// What the window extras were last set to.
Background platform.Color
Progress string
ProgressValue float64
Flashing bool
SkipsTaskbar bool
OnAllWorkspaces bool
AutoHidesMenu bool
Icon []byte
// RepresentedFile and DocumentEdited are what SetRepresentedFile and
// SetDocumentEdited set.
RepresentedFile string
DocumentEdited bool
// TitleBarRoom is what TitleBar returns: set for windows with a hidden
// title bar, and changed by tests before they call H.TitleBarChanged.
TitleBarRoom platform.TitleBar
// MaximizeButton is where the content last said it shows the maximize
// button.
MaximizeButton platform.RectF
// AsyncFunction answers CallAsyncFunction.
AsyncFunction func(body string) (string, error)
// AsyncCallback, when set, receives CallAsyncFunction calls to answer
// through reply whenever it wants, on the main thread.
AsyncCallback func(body string, reply func(string, error))
// OnEval, when set, receives the scripts passed to Eval instead of
// recording them.
OnEval func(js string)
// contains filtered or unexported fields
}
Window is a fake native window. Scripts evaluated in it are recorded.
func (*Window) ActiveAppearance ¶ added in v0.1.13
ActiveAppearance reports what SetActiveAppearance set last.
func (*Window) CallAsyncFunction ¶
func (*Window) CanGoForward ¶
func (*Window) CapturePage ¶
func (*Window) CaptureState ¶ added in v0.1.13
func (w *Window) CaptureState(kind platform.CaptureKind) platform.CaptureState
func (*Window) ClearScripts ¶
func (w *Window) ClearScripts()
ClearScripts forgets the scripts passed to Eval so far.
func (*Window) ClickMenuItem ¶
ClickMenuItem simulates choosing an item of this window's menu.
func (*Window) CloseDevTools ¶
func (w *Window) CloseDevTools()
func (*Window) ContentBounds ¶
func (*Window) ContentRules ¶ added in v0.1.8
func (w *Window) ContentRules() []*ContentRuleList
ContentRules returns the lists the page's loads go through.
func (*Window) DroppedFiles ¶
func (*Window) FakeSurface ¶
FakeSurface returns the window's surface, for tests.
func (*Window) FlashFrame ¶
func (*Window) IsAlwaysOnTop ¶
func (*Window) IsAudioMuted ¶ added in v0.1.13
func (*Window) IsClosable ¶
func (*Window) IsDevToolsOpened ¶
func (*Window) IsFullScreen ¶
func (*Window) IsMaximizable ¶
func (*Window) IsMaximized ¶
func (*Window) IsMinimizable ¶
func (*Window) IsMinimized ¶
func (*Window) IsResizable ¶
func (*Window) OpenDevTools ¶
func (w *Window) OpenDevTools()
func (*Window) PictureInPictureActive ¶ added in v0.1.13
func (*Window) PlaceFlyout ¶
PlaceFlyout places a flyout as the real backends do, against the parent's content area and the fake display's work area.
func (*Window) PrintToPDF ¶
func (w *Window) PrintToPDF(o platform.PDFOptions, cb func([]byte, error))
func (*Window) RestoreSessionState ¶ added in v0.1.13
RestoreSessionState puts back a state SessionState made, which goes to its URL, and records it in Restored; it can't while the backend keeps no session state, nor read other states.
func (*Window) SessionState ¶ added in v0.1.13
SessionState returns "fake session of " and the page's URL, as an engine returns its back/forward list, or nil while the backend keeps no session state (Backend.SetNoSessionState), as WebView2.
func (*Window) SetActiveAppearance ¶ added in v0.1.13
func (*Window) SetAlwaysOnTop ¶
func (*Window) SetAudible ¶ added in v0.1.13
SetAudible sets whether the page plays sound (IsAudible) and reports it to the handler (AudibleChanged), as a backend does whenever the page starts or stops playing; it reports it even when it did not change. Call it on the main thread, where backends report it.
func (*Window) SetAudioMuted ¶ added in v0.1.13
func (*Window) SetAutoHideMenu ¶
func (*Window) SetBackgroundColor ¶
func (*Window) SetCapture ¶ added in v0.1.13
func (w *Window) SetCapture(kind platform.CaptureKind, state platform.CaptureState)
SetCapture sets the page's capture of kind (CaptureState) and reports it to the handler (CaptureStateChanged), as a backend does whenever the page starts, mutes or stops capturing; it reports it even when it did not change. Call it on the main thread, where backends report it.
func (*Window) SetCaptureState ¶ added in v0.1.13
func (w *Window) SetCaptureState(kind platform.CaptureKind, state platform.CaptureState)
SetCaptureState mutes, unmutes or stops the page's capture of kind, as a page takes it, and reports it to the handler; it does nothing while the page captures no such device.
func (*Window) SetClosable ¶
func (*Window) SetContentBounds ¶
func (*Window) SetContentProtection ¶
func (*Window) SetContentRules ¶ added in v0.1.8
SetContentRules keeps the lists, which ContentRules returns.
func (*Window) SetDocumentEdited ¶
func (*Window) SetFullScreen ¶
func (*Window) SetHasShadow ¶
func (*Window) SetIgnoreMouseEvents ¶
func (*Window) SetMaximizable ¶
func (*Window) SetMaximumSize ¶
func (*Window) SetMinimizable ¶
func (*Window) SetMinimumSize ¶
func (*Window) SetMovable ¶
func (*Window) SetOpacity ¶
func (*Window) SetProcessID ¶ added in v0.1.13
SetProcessID sets the process ID the page reports, as a backend whose web view runs in a process of that ID; 0, the default, is none known.
func (*Window) SetProgressBar ¶
func (*Window) SetRepresentedFile ¶
func (*Window) SetResizable ¶
func (*Window) SetSkipTaskbar ¶
func (*Window) SetUserAgent ¶
func (*Window) SetUserScripts ¶
func (w *Window) SetUserScripts(scripts []platform.UserScript)
SetUserScripts replaces Opts.UserScripts, which tests read and UserScripts returns.
func (*Window) SetVibrancy ¶
func (*Window) SetVisibleOnAllWorkspaces ¶
func (*Window) SetWindowButtonsTheme ¶ added in v0.1.13
func (*Window) ShowInactive ¶
func (w *Window) ShowInactive()
func (*Window) StopLoading ¶
func (w *Window) StopLoading()
func (*Window) Surface ¶
Surface returns the window's surface, nil unless it was created with WindowOptions.Surface.
func (*Window) TitleBarDoubleClicked ¶
func (w *Window) TitleBarDoubleClicked()
func (*Window) TogglePictureInPicture ¶ added in v0.1.13
func (w *Window) TogglePictureInPicture()
TogglePictureInPicture moves the page's video into picture in picture or back, as a page with a video it can move.
func (*Window) Unmaximize ¶
func (w *Window) Unmaximize()
func (*Window) UserScripts ¶
func (w *Window) UserScripts() []platform.UserScript
UserScripts returns the scripts a page loaded now gets: those of the options, or the ones SetUserScripts set since.