ash

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 29 Imported by: 0

Documentation

Overview

Package ash implements a library used for communication with Chrome Ash.

Index

Constants

View Source
const (
	// ShelfBehaviorAlwaysAutoHide represents always auto-hide.
	ShelfBehaviorAlwaysAutoHide ShelfBehavior = "always"
	//ShelfBehaviorNeverAutoHide represents never auto-hide, meaning that it is always visible.
	ShelfBehaviorNeverAutoHide = "never"
	// ShelfBehaviorHidden represents always hidden, used for debugging, since this state is not exposed to the user.
	ShelfBehaviorHidden = "hidden"
	// ShelfBehaviorInvalid represents an invalid state.
	ShelfBehaviorInvalid = "invalid"

	// ShelfIconClassName is the class name of the node of the apps on shelf.
	ShelfIconClassName = "ash/ShelfAppButton"
)

As defined in ShelfAutoHideBehavior here: https://cs.chromium.org/chromium/src/ash/public/cpp/shelf_types.h

View Source
const (
	ShelfAlignmentBottom       ShelfAlignment = "Bottom"
	ShelfAlignmentLeft                        = "Left"
	ShelfAlignmentRight                       = "Right"
	ShelfAlignmentBottomLocked                = "BottomLocked"
	ShelfAlignmentInvalid                     = "Invalid"
)

As defined in ShelfAlignment here: https://cs.chromium.org/chromium/src/ash/public/cpp/shelf_types.h

View Source
const AppListBubbleClassName = "AppListBubbleView"

AppListBubbleClassName is the automation API class name of the bubble launcher.

View Source
const DebuggingPortPath = cdputil.DebuggingPortPath

DebuggingPortPath is a file where Chrome writes debugging port.

Variables

View Source
var (
	AccelSearch      = Accelerator{KeyCode: "search", Shift: false, Control: false, Alt: false, Search: false}
	AccelShiftSearch = Accelerator{KeyCode: "search", Shift: true, Control: false, Alt: false, Search: false}
)

Accelerator key used to trigger launcher state change.

View Source
var ErrMultipleWindowsFound = errors.New("found multiple matching windows")

ErrMultipleWindowsFound is returned when multiple windows were returned when only one was requested.

View Source
var ErrWindowNotFound = errors.New("failed to find window")

ErrWindowNotFound is returned when window is failed to be found.

Functions

func ActivateAdjacentDesksToTargetIndex

func ActivateAdjacentDesksToTargetIndex(ctx context.Context, tconn *chrome.TestConn, index int) error

ActivateAdjacentDesksToTargetIndex requests Ash to keep activating the adjacent Virtual Desk until the one at the given index is reached. It waits for the chain of desk-switch animations to complete. This call will fail if index is invalid, or it is the index of the already active desk.

func ActivateDeskAtIndex

func ActivateDeskAtIndex(ctx context.Context, tconn *chrome.TestConn, index int) error

ActivateDeskAtIndex requests Ash to activate the Virtual Desk at the given index. It waits for the desk-switch animation to complete. This call will fail if index is invalid, or its the index of the already active desk.

func AppRunning

func AppRunning(ctx context.Context, tconn *chrome.TestConn, appID string) (bool, error)

AppRunning checks if an app specified by appID is already running.

func AppShown

func AppShown(ctx context.Context, tconn *chrome.TestConn, appID string) (bool, error)

AppShown checks if an app specified by appID is shown in the shelf.

func AutoHide

func AutoHide(ctx context.Context, tconn *chrome.TestConn, displayID string) error

AutoHide sets shelf auto hide behavior from the wallpaper context menu.

func BrowserTitleMatch

func BrowserTitleMatch(bt browser.Type, titlePrefix string) func(w *Window) bool

BrowserTitleMatch returns a func to check whether a window is a browser window of matching type and title.

func BrowserTypeMatch

func BrowserTypeMatch(bt browser.Type) func(w *Window) bool

BrowserTypeMatch returns a func to check whether a window is a browser window of the given type.

func ChromeAppInstalled

func ChromeAppInstalled(ctx context.Context, tconn *chrome.TestConn, appID string) (bool, error)

ChromeAppInstalled checks if an app specified by appID is installed.

func CleanUpDesks

func CleanUpDesks(ctx context.Context, tconn *chrome.TestConn) error

CleanUpDesks removes all but one desk.

func ClipboardTextData

func ClipboardTextData(ctx context.Context, tconn *chrome.TestConn) (string, error)

ClipboardTextData returns clipboard text data.

func CloseAllWindows

func CloseAllWindows(ctx context.Context, tconn *chrome.TestConn) error

CloseAllWindows closes all open windows and waits until gone.

func CloseNotifications

func CloseNotifications(ctx context.Context, tconn *chrome.TestConn) error

CloseNotifications uses autotestPrivate api to close all notifications.

func CountVisibleWindows

func CountVisibleWindows(ctx context.Context, tconn *chrome.TestConn) (int, error)

CountVisibleWindows returns number of visible windows

func CreateNewDesk

func CreateNewDesk(ctx context.Context, tconn *chrome.TestConn) error

CreateNewDesk requests Ash to create a new Virtual Desk which would fail if the maximum number of desks have been reached.

func CreateWindows

func CreateWindows(ctx context.Context, tconn *chrome.TestConn, cs ConnSource, url string, n int) error

CreateWindows create n browser windows with specified URL and wait for them to become visible. It will fail and return an error if at least one request fails to fulfill. Note that this will parallelize the requests to create windows, which may be bad if the caller wants to measure the performance of Chrome. This should be used for a preparation, before the measurement happens.

func DragToShowHomescreen

func DragToShowHomescreen(ctx context.Context, width, height input.TouchCoord, stw *input.SingleTouchEventWriter, tconn *chrome.TestConn) error

DragToShowHomescreen shows the homescreen (app-list) by dragging up from the bottom of the screen quickly. Note that this action only works in tablet mode.

func DragToShowOverview

func DragToShowOverview(ctx context.Context, tsw *input.TouchscreenEventWriter, stw *input.SingleTouchEventWriter, tconn *chrome.TestConn) error

DragToShowOverview shows overview by dragging up, pausing for the gesture to be recognized, then ending the gesture. Note that this action only works in tablet mode.

func EnsureTabletModeEnabled

func EnsureTabletModeEnabled(ctx context.Context, tconn *chrome.TestConn, enabled bool) (func(ctx context.Context) error, error)

EnsureTabletModeEnabled makes sure that the tablet mode state is enabled, and returns a function which reverts back to the original state.

Typically, this will be used like:

cleanup, err := ash.EnsureTabletModeEnabled(ctx, c, true)
if err != nil {
  s.Fatal("Failed to ensure in tablet mode: ", err)
}
defer cleanup(ctx)

func EnterShelfOverflow

func EnterShelfOverflow(ctx context.Context, tconn *chrome.TestConn) error

EnterShelfOverflow pins enough shelf icons to enter overflow mode.

func FindDeskMiniViews

func FindDeskMiniViews(ctx context.Context, ac *uiauto.Context) ([]uiauto.NodeInfo, error)

FindDeskMiniViews returns a list of DeskMiniView nodes. TODO(crbug/1251558): use autotest api to get the number of desks instead.

func FindDeskTemplates

func FindDeskTemplates(ctx context.Context, ac *uiauto.Context) ([]uiauto.NodeInfo, error)

FindDeskTemplates returns a list of desk template nodes.

func ForEachWindow

func ForEachWindow(ctx context.Context, tconn *chrome.TestConn, f func(window *Window) error) error

ForEachWindow runs a specified function on each window. If the given function returns an error, it is returned and f won't be called for following windows.

func GeneratePrepareFakeAppsOptions

func GeneratePrepareFakeAppsOptions(baseDir string, numFakeApps int) ([]chrome.Option, error)

GeneratePrepareFakeAppsOptions is similar with GeneratePrepareFakeAppsWithNamesOptions, with a difference that GeneratePrepareFakeAppsOptions accepts the fake app count as the parameter.

func GeneratePrepareFakeAppsWithIconDataOptions

func GeneratePrepareFakeAppsWithIconDataOptions(baseDir string, names []string, iconData [][]byte) ([]chrome.Option, error)

GeneratePrepareFakeAppsWithIconDataOptions is similar with GeneratePrepareFakeAppsWithNamesOptions, with a difference that GeneratePrepareFakeAppsWithIconDataOptions allows the caller to specify both app names and icon data. The caller has the duty to clean baseDir.

func GeneratePrepareFakeAppsWithNamesOptions

func GeneratePrepareFakeAppsWithNamesOptions(baseDir string, names []string) ([]chrome.Option, error)

GeneratePrepareFakeAppsWithNamesOptions calls PrepareDefaultFakeApps() and returns options to be used by chrome.New() for logging in with the newly created fake apps. baseDir is the path to the directory for keeping app data. The function caller should always clean baseDir regardless of function execution results. names specify app names.

func GetDefaultPinnedAppIDs

func GetDefaultPinnedAppIDs(ctx context.Context, tconn *chrome.TestConn) ([]string, error)

GetDefaultPinnedAppIDs returns the expected default app IDs that are pinned to the shelf.

func GetPinnedAppIds

func GetPinnedAppIds(ctx context.Context, tconn *chrome.TestConn) ([]string, error)

GetPinnedAppIds returns the ids of the pinned apps. Note that the browser shortcut is not among the return value because it is always pinned to shelf.

func LaunchAppFromShelf

func LaunchAppFromShelf(ctx context.Context, tconn *chrome.TestConn, appName, appID string) error

LaunchAppFromShelf opens an app by name which is currently pinned to the shelf. The parameter appName should be the name of the app which is same as the value stored in apps.App.Name.

func PinAndUnpinApps

func PinAndUnpinApps(ctx context.Context, tconn *chrome.TestConn, appIDsToPin, appIDsToUnpin []string) error

PinAndUnpinApps pins and unpins the apps specified by appIDs to shelf.

func PinApp

func PinApp(ctx context.Context, tconn *chrome.TestConn, appID string) error

PinApp pins the shelf icon for the app specified by appID. Deprecated. Use PinApps() instead.

func PinApps

func PinApps(ctx context.Context, tconn *chrome.TestConn, appIDs []string) error

PinApps pins the apps specified by appIDs to shelf.

func PrepareDefaultFakeApps

func PrepareDefaultFakeApps(baseDir string, appNames []string, hasIcon bool) ([]string, error)

PrepareDefaultFakeApps creates directories for fake apps (hosted apps) under the directory of baseDir and returns their path names. Fake app names are specified by the parameter. hasIcon specifies whether a default icon should be used. The intermediate data may remain even when an error is returned. It is the caller's responsibility to clean up the contents under the baseDir. This also may update the ownership of baseDir.

func PrimaryDisplayMode

func PrimaryDisplayMode(ctx context.Context, tconn *chrome.TestConn) (*display.DisplayMode, error)

PrimaryDisplayMode returns the display mode that is currently selected in the primary display.

func RemoveActiveDesk

func RemoveActiveDesk(ctx context.Context, tconn *chrome.TestConn) error

RemoveActiveDesk requests Ash to remove the currently active desk and waits for the desk-removal animation to complete. This call will fail if the currently active desk is the last available desk which cannot be removed.

func ResetShelfPinState

func ResetShelfPinState(ctx context.Context, tconn *chrome.TestConn) (func(ctx context.Context) error, error)

ResetShelfPinState returns a callback to reset shelf app pin states to default. The callback should be run before the test ends. This function should be called before any change in shelf pin states.

func RightClickApp

func RightClickApp(tconn *chrome.TestConn, appName string) uiauto.Action

RightClickApp returns a function that right clicks the given app's icon on the shelf.

func ScrollShelfAndWaitUntilFinish

func ScrollShelfAndWaitUntilFinish(ctx context.Context, tconn *chrome.TestConn, buttonBounds coords.Rect, targetOffset float32) error

ScrollShelfAndWaitUntilFinish triggers the scroll animation by mouse click then waits the animation to finish.

func SetClipboard

func SetClipboard(ctx context.Context, tconn *chrome.TestConn, data string) error

SetClipboard forcibly sets the clipboard to the given data.

func SetOverviewModeAndWait

func SetOverviewModeAndWait(ctx context.Context, tconn *chrome.TestConn, inOverview bool) error

SetOverviewModeAndWait requests Ash to set the overview mode state and waits for its animation to complete.

func SetShelfAlignment

func SetShelfAlignment(ctx context.Context, tconn *chrome.TestConn, displayID string, a ShelfAlignment) error

SetShelfAlignment sets the shelf alignment. displayID is the display that contains the shelf.

func SetShelfBehavior

func SetShelfBehavior(ctx context.Context, tconn *chrome.TestConn, displayID string, b ShelfBehavior) error

SetShelfBehavior sets the shelf visibility behavior. displayID is the display that contains the shelf.

func SetTabletModeEnabled

func SetTabletModeEnabled(ctx context.Context, tconn *chrome.TestConn, enabled bool) error

SetTabletModeEnabled enables / disables tablet mode. After calling this function, it won't be possible to physically switch to/from tablet mode since that functionality will be disabled.

func SetWindowBounds

func SetWindowBounds(ctx context.Context, tconn *chrome.TestConn, id int, b coords.Rect, displayID string) (coords.Rect, string, error)

SetWindowBounds requests changing the bounds of the window and which display it is on to the given values. It returns the actual bounds and display set, which may be different to the requested bounds and display. (e.g. setting bounds on an Android app may not have Android framework honour the request).

func SetWindowStateAndWait

func SetWindowStateAndWait(ctx context.Context, tconn *chrome.TestConn, id int, targetState WindowStateType) error

SetWindowStateAndWait requests a WMEvent to make the window for the id to be in the targetState, and wait for the window animations when it happens. It returns an error when it can't be in the target state. It will return nil when the window is already in the target state.

func ShowHotseat

func ShowHotseat(ctx context.Context, tconn *chrome.TestConn) error

ShowHotseat make sure hotseat is shown in tablet mode.

func ShowHotseatAction

func ShowHotseatAction(tconn *chrome.TestConn) uiauto.Action

ShowHotseatAction returns a function that makes sure hotseat is shown in tablet mode.

func SwapWindowsInSplitView

func SwapWindowsInSplitView(ctx context.Context, tconn *chrome.TestConn) error

SwapWindowsInSplitView swaps the positions of snapped windows in split view.

func SwipeDownHotseatAndWaitForCompletion

func SwipeDownHotseatAndWaitForCompletion(ctx context.Context, tconn *chrome.TestConn, stw *input.SingleTouchEventWriter, tcc *input.TouchCoordConverter) error

SwipeDownHotseatAndWaitForCompletion swipes the hotseat down, changing the hotseat state from extended to hidden. The function does not end until the hotseat animation completes.

func SwipeUpHotseatAndWaitForCompletion

func SwipeUpHotseatAndWaitForCompletion(ctx context.Context, tconn *chrome.TestConn, stw *input.SingleTouchEventWriter, tcc *input.TouchCoordConverter) error

SwipeUpHotseatAndWaitForCompletion swipes the hotseat up, changing the hotseat state from hidden to extended. The function does not end until the hotseat animation completes.

func TabletModeEnabled

func TabletModeEnabled(ctx context.Context, tconn *chrome.TestConn) (bool, error)

TabletModeEnabled gets the tablet mode enabled status.

func TriggerLauncherStateChange

func TriggerLauncherStateChange(ctx context.Context, tconn *chrome.TestConn, accel Accelerator) error

TriggerLauncherStateChange will cause the launcher state change via accelerator.

func UnpinApps

func UnpinApps(ctx context.Context, tconn *chrome.TestConn, appIDs []string) error

UnpinApps unpins the apps specified by appIDs to shelf.

func UpdateAppPinFromHotseat

func UpdateAppPinFromHotseat(ctx context.Context, tconn *chrome.TestConn, appName string, pin bool) error

UpdateAppPinFromHotseat pins or unpins an app shown in the hotseat using the context menu. The parameter appName should be the name of the app which is same as the value stored in apps.App.Name.

func UpdateAppPinFromShelf

func UpdateAppPinFromShelf(ctx context.Context, tconn *chrome.TestConn, appName string, pin bool) error

UpdateAppPinFromShelf pins or unpins an app shown in the shelf using the context menu. The parameter appName should be the name of the app which is same as the value stored in apps.App.Name.

func VerifyShelfIconIndices

func VerifyShelfIconIndices(ctx context.Context, tconn *chrome.TestConn, expectedApps []string) error

VerifyShelfIconIndices checks whether the apps are ordered as expected.

func WaitForARCAppWindowState

func WaitForARCAppWindowState(ctx context.Context, tconn *chrome.TestConn, pkgName string, state WindowStateType) error

WaitForARCAppWindowState waits for a window state to appear on the Chrome side. If you expect an Activity's window state to change, this method will guarantee that the state change has fully occurred and propagated to the Chrome side.

func WaitForARCAppWindowStateWithPollOptions

func WaitForARCAppWindowStateWithPollOptions(ctx context.Context, tconn *chrome.TestConn, pkgName string, state WindowStateType, pollOptions *testing.PollOptions) error

WaitForARCAppWindowStateWithPollOptions waits for a window state to appear on the Chrome side. If you expect an Activity's window state to change, this method will guarantee that the state change has fully occurred and propagated to the Chrome side.

func WaitForApp

func WaitForApp(ctx context.Context, tconn *chrome.TestConn, appID string, timeout time.Duration) error

WaitForApp waits for the app specified by appID to appear in the shelf.

func WaitForAppClosed

func WaitForAppClosed(ctx context.Context, tconn *chrome.TestConn, appID string) error

WaitForAppClosed waits for the app specified by appID to be closed.

func WaitForAppCondition

func WaitForAppCondition(ctx context.Context, tconn *chrome.TestConn, appID string, timeout, interval time.Duration, cond func() (bool, error), msg string) error

WaitForAppCondition waits for the app specified by appID to meet the given condition within the given timeout.

func WaitForChromeAppInstalled

func WaitForChromeAppInstalled(ctx context.Context, tconn *chrome.TestConn, appID string, timeout time.Duration) error

WaitForChromeAppInstalled waits for the app specified by appID to appear in installed apps.

func WaitForCondition

func WaitForCondition(ctx context.Context, tconn *chrome.TestConn, predicate func(window *Window) bool, pollOptions *testing.PollOptions) error

WaitForCondition waits for a window to satisfy the given predicate.

func WaitForFullScreen

func WaitForFullScreen(ctx context.Context, tconn *chrome.TestConn) error

WaitForFullScreen waits until any window that exists is in the full screen state.

func WaitForHidden

func WaitForHidden(ctx context.Context, tconn *chrome.TestConn, pkgName string) error

WaitForHidden waits for a window to be dismissed on the Chrome side. Visibility is defined to be the corresponding Aura window's visibility.

func WaitForHotseatAnimatingToIdealState

func WaitForHotseatAnimatingToIdealState(ctx context.Context, tconn *chrome.TestConn, state HotseatStateType) error

WaitForHotseatAnimatingToIdealState waits for the hotseat to reach the expected state after animation.

func WaitForHotseatAnimationToFinish

func WaitForHotseatAnimationToFinish(ctx context.Context, tconn *chrome.TestConn) error

WaitForHotseatAnimationToFinish waits for the hotseat animation is done.

func WaitForHotseatToUpdateAutoHideState

func WaitForHotseatToUpdateAutoHideState(ctx context.Context, tconn *chrome.TestConn, autoHideState bool) error

WaitForHotseatToUpdateAutoHideState waits for the hotseat to reach the expected autohide state.

func WaitForLauncherState

func WaitForLauncherState(ctx context.Context, tconn *chrome.TestConn, state LauncherState) error

WaitForLauncherState waits until the launcher state becomes state. It waits up to 10 seconds and fail if the launcher doesn't have the desired state. Expected to fail with "Not supported for bubble launcher" error when waiting for state different from "Closed" if called for clamshell productivity (bubble) launcher. Note that the autotest API is expected to return immediately, but still asynchronously, in this case. NOTE: Waiting for "Closed" state will always wait for the fullscreen launcher to hide, even if one would otherwise expect bubble launcher to be used for the current session state - this supports waiting for launcher UI hide animation to complete after transitioning from tablet mode to clamshell.

func WaitForOverviewState

func WaitForOverviewState(ctx context.Context, tconn *chrome.TestConn, state OverviewState, timeout time.Duration) error

WaitForOverviewState waits until overview is shown or hidden completely. Returns immediately if overview mode state matches |overview_state|.

func WaitForShelf

func WaitForShelf(ctx context.Context, tconn *chrome.TestConn, timeout time.Duration) error

WaitForShelf waits for the shelf to exist in the UI tree.

func WaitForStableShelfBounds

func WaitForStableShelfBounds(ctx context.Context, tconn *chrome.TestConn) error

WaitForStableShelfBounds waits for the shelf location to be the same for a single iteration of polling.

func WaitForVisible

func WaitForVisible(ctx context.Context, tconn *chrome.TestConn, pkgName string) error

WaitForVisible waits for a window to be visible on the Chrome side. Visibility is defined to be the corresponding Aura window's visibility.

func WaitIDContains

func WaitIDContains(idContains string) waitPredicate

WaitIDContains creates a predicate that checks whether notification ID contains idContains.

func WaitMessageContains

func WaitMessageContains(messageContains string) waitPredicate

WaitMessageContains creates a predicate that checks whether the notification's message contains the given text.

func WaitTitle

func WaitTitle(title string) waitPredicate

WaitTitle creates a predicate that checks whether notification has specific title.

func WaitTitleContains

func WaitTitleContains(titleContains string) waitPredicate

WaitTitleContains creates a predicate that checks whether the notification's title contains the given text.

func WaitUntilNotificationGone

func WaitUntilNotificationGone(ctx context.Context, tconn *chrome.TestConn, timeout time.Duration, predicates ...waitPredicate) error

WaitUntilNotificationGone waits for the notifications that satisfies all predicates to disappear.

func WaitUntilShelfIconAnimationFinish

func WaitUntilShelfIconAnimationFinish(ctx context.Context, tconn *chrome.TestConn) error

WaitUntilShelfIconAnimationFinish waits for the shelf icon animation to finish.

func WaitWindowFinishAnimating

func WaitWindowFinishAnimating(ctx context.Context, tconn *chrome.TestConn, windowID int) error

WaitWindowFinishAnimating waits for a window with a given ID to finish animating on the Chrome side.

Types

type Accelerator

type Accelerator struct {
	KeyCode string `json:"keyCode"`
	Shift   bool   `json:"shift"`
	Control bool   `json:"control"`
	Alt     bool   `json:"alt"`
	Search  bool   `json:"search"`
}

Accelerator represents the accelerator key to trigger certain actions.

type AppInstallSource

type AppInstallSource string

AppInstallSource maps apps::mojom::InstallSource.

const (
	Unknown AppInstallSource = "Unknown"
	System  AppInstallSource = "System"
	Policy  AppInstallSource = "Policy"
	Oem     AppInstallSource = "Oem"
	Default AppInstallSource = "Default"
	Sync    AppInstallSource = "Sync"
	User    AppInstallSource = "User"
)

Corresponds to the definition in autotest_private.idl

type AppReadiness

type AppReadiness string

AppReadiness maps apps::mojom::Readiness.

const (
	Ready               AppReadiness = "Ready"
	DisabledByBlacklist AppReadiness = "DisabledByBlacklist"
	DisabledByPolicy    AppReadiness = "DisabledByPolicy"
	DisabledByUser      AppReadiness = "DisabledByUser"
	Terminated          AppReadiness = "Terminated"
	UninstalledByUser   AppReadiness = "UninstalledByUser"
)

Corresponds to the definition in autotest_private.idl

type AppType

type AppType string

AppType defines the types of available apps.

const (
	Arc               AppType = "Arc"
	BuiltIn           AppType = "BuiltIn"
	Crostini          AppType = "Crostini"
	Extension         AppType = "Extension"
	StandaloneBrowser AppType = "StandaloneBrowser"
	Web               AppType = "Web"
	MacNative         AppType = "MacNative"
)

Corresponds to the definition in autotest_private.idl.

type CaptionButtonStatus

type CaptionButtonStatus uint

CaptionButtonStatus represents the bit mask flag in ArcAppWindowInfo

const (
	CaptionButtonMinimize CaptionButtonStatus = 1 << iota
	CaptionButtonMaximizeAndRestore
	CaptionButtonClose
	CaptionButtonLeftSnapped
	CaptionButtonRightSnapped
	CaptionButtonBack
	CaptionButtonLocation
	CaptionButtonMenu
	CaptionButtonZoom
	CaptionButtonCount
)

As defined in views::CaptionButtonIcon here: https://cs.chromium.org/chromium/src/ui/views/window/caption_button_types.h

func (*CaptionButtonStatus) String

func (c *CaptionButtonStatus) String() string

String returns the CaptionButtonStatus string representation.

type ChromeApp

type ChromeApp struct {
	AppID                 string           `json:"appId"`
	Name                  string           `json:"name"`
	ShortName             string           `json:"shortName"`
	PublisherID           string           `json:"publisherId"`
	Type                  AppType          `json:"type"`
	InstallSource         AppInstallSource `json:"installSource"`
	Readiness             AppReadiness     `json:"readiness"`
	AdditionalSearchTerms []string         `json:"additionalSearchTerms"`
	ShowInLauncher        bool             `json:"showInLauncher"`
	ShowInSearch          bool             `json:"showInSearch"`
}

ChromeApp corresponds to the "App" defined in autotest_private.idl.

func ChromeApps

func ChromeApps(ctx context.Context, tconn *chrome.TestConn) ([]*ChromeApp, error)

ChromeApps returns all of the installed apps.

type ConnSource

type ConnSource interface {
	NewConn(ctx context.Context, url string, opts ...cdputil.CreateTargetOption) (*chrome.Conn, error)
}

ConnSource is an interface which allows new chrome.Conn connections to be created.

type DevtoolsConn

type DevtoolsConn = cdputil.Conn

DevtoolsConn is the connection to a web content view, e.g. a tab.

type FrameMode

type FrameMode string

FrameMode represents the frame mode of the window.

const (
	FrameModeNormal    FrameMode = "Normal"
	FrameModeImmersive FrameMode = "Immersive"
)

As defined in autotest_private.idl: https://cs.chromium.org/chromium/src/chrome/common/extensions/api/autotest_private.idl?q=FrameMode

type HotseatInfoClass

type HotseatInfoClass struct {
	SwipeUp      HotseatSwipeDescriptor `json:"swipeUp"`
	HotseatState HotseatStateType       `json:"state"`
	IsAnimating  bool                   `json:"isAnimating"`
	IsAutoHidden bool                   `json:"IsAutoHidden"`
}

HotseatInfoClass corresponds to the "HotseatInfo" defined in autotest_private.idl.

func FetchHotseatInfo

func FetchHotseatInfo(ctx context.Context, c *chrome.TestConn) (*HotseatInfoClass, error)

FetchHotseatInfo returns the hotseat's ui related information.

type HotseatStateType

type HotseatStateType string

HotseatStateType corresponds to the "HotseatState" defined in autotest_private.idl.

const (
	// ShelfHidden means that hotseat is shown off screen.
	ShelfHidden HotseatStateType = "Hidden"
	// ShelfShownClamShell means that hotseat is shown within the shelf in clamshell mode.
	ShelfShownClamShell HotseatStateType = "ShownClamShell"
	// ShelfShownHomeLauncher means that hotseat is shown in the tablet mode home launcher's shelf.
	ShelfShownHomeLauncher HotseatStateType = "ShownHomeLauncher"
	// ShelfExtended means that hotseat is shown above the shelf.
	ShelfExtended HotseatStateType = "Extended"
)

type HotseatSwipeDescriptor

type HotseatSwipeDescriptor struct {
	SwipeStartLocation coords.Point `json:"swipeStartLocation"`
	SwipeEndLocation   coords.Point `json:"swipeEndLocation"`
}

HotseatSwipeDescriptor corresponds to the "HotseatSwipeDescriptor" defined in autotest_private.idl.

type LauncherState

type LauncherState string

LauncherState represents the launcher (a.k.a AppList) state.

const (
	Peeking           LauncherState = "Peeking"
	FullscreenAllApps LauncherState = "FullscreenAllApps"
	FullscreenSearch  LauncherState = "FullscreenSearch"
	Half              LauncherState = "Half"
	Closed            LauncherState = "Closed"
)

LauncherState as defined in https://cs.chromium.org/chromium/src/ash/public/cpp/app_list/app_list_types.h

type Notification

type Notification struct {
	ID       string `json:"id"`
	Type     string `json:"type"`
	Title    string `json:"title"`
	Message  string `json:"message"`
	Priority int    `json:"priority"`
	Progress int    `json:"progress"`
}

Notification corresponds to the "Notification" defined in autotest_private.idl.

func Notifications

func Notifications(ctx context.Context, tconn *chrome.TestConn) ([]*Notification, error)

Notifications returns an array of notifications in Chrome. tconn must be the connection returned by chrome.TestAPIConn().

Note: it uses an autotestPrivate API with the misleading name getVisibleNotifications under the hood.

func WaitForNotification

func WaitForNotification(ctx context.Context, tconn *chrome.TestConn, timeout time.Duration, predicates ...waitPredicate) (*Notification, error)

WaitForNotification waits for the first notification that satisfies all wait predicates.

type OverviewInfo

type OverviewInfo struct {
	Bounds    coords.Rect `json:"bounds"`
	IsDragged bool        `json:"isDragged"`
}

OverviewInfo holds overview info of a window. https://cs.chromium.org/chromium/src/chrome/common/extensions/api/autotest_private.idl

type OverviewState

type OverviewState string

OverviewState represents the animation state of overview mode.

const (
	Shown  OverviewState = "Shown"
	Hidden OverviewState = "Hidden"
)

OverviewState represents two final states for overview mode, when animations complete.

type PortWaitOption

type PortWaitOption = cdputil.PortWaitOption

PortWaitOption controls whether the NewSession should wait for the port file to be created.

const (
	NoWaitPort PortWaitOption = cdputil.NoWaitPort
	WaitPort   PortWaitOption = cdputil.WaitPort
)

PortWaitOption values.

type ScrollableShelfInfoClass

type ScrollableShelfInfoClass struct {
	MainAxisOffset         float32        `json:"mainAxisOffset"`
	PageOffset             float32        `json:"pageOffset"`
	TargetMainAxisOffset   float32        `json:"targetMainAxisOffset"`
	LeftArrowBounds        coords.Rect    `json:"leftArrowBounds"`
	RightArrowBounds       coords.Rect    `json:"rightArrowBounds"`
	IsAnimating            bool           `json:"isAnimating"`
	IconsUnderAnimation    bool           `json:"iconsUnderAnimation"`
	IsOverflow             bool           `json:"isOverflow"`
	IsShelfWidgetAnimating bool           `json:"isShelfWidgetAnimating"`
	IconsBoundsInScreen    []*coords.Rect `json:"iconsBoundsInScreen"`
}

ScrollableShelfInfoClass corresponds to the "ScrollableShelfInfo" defined in autotest_private.idl

func FetchScrollableShelfInfoForState

func FetchScrollableShelfInfoForState(ctx context.Context, c *chrome.TestConn, state *ShelfState) (*ScrollableShelfInfoClass, error)

FetchScrollableShelfInfoForState returns the scrollable shelf's ui related information for the given state.

type Session

type Session = cdputil.Session

Session maintains the connection to talk to the browser in Chrome DevTools Protocol over WebSocket.

func NewDevtoolsSession

func NewDevtoolsSession(ctx context.Context, debuggingPortPath string, portWait PortWaitOption) (sess *Session, retErr error)

NewDevtoolsSession establishes a Chrome DevTools Protocol WebSocket connection to the browser.

type ShelfAlignment

type ShelfAlignment string

ShelfAlignment represents the different Chrome OS shelf alignments.

func GetShelfAlignment

func GetShelfAlignment(ctx context.Context, tconn *chrome.TestConn, displayID string) (ShelfAlignment, error)

GetShelfAlignment returns the shelf alignment. displayID is the display that contains the shelf.

type ShelfBehavior

type ShelfBehavior string

ShelfBehavior represents the different Chrome OS shelf behaviors.

func GetShelfBehavior

func GetShelfBehavior(ctx context.Context, tconn *chrome.TestConn, displayID string) (ShelfBehavior, error)

GetShelfBehavior returns the shelf visibility behavior. displayID is the display that contains the shelf.

type ShelfIconPinUpdateParam

type ShelfIconPinUpdateParam struct {
	AppID     string `json:"appId"`
	ShouldPin bool   `json:"pinned"`
}

ShelfIconPinUpdateParam is defined in autotest_private.idl.

type ShelfInfo

type ShelfInfo struct {
	HotseatInfo         HotseatInfoClass         `json:"hotseatInfo"`
	ScrollableShelfInfo ScrollableShelfInfoClass `json:"scrollableShelfInfo"`
}

ShelfInfo corresponds to the "ShelfInfo" defined in autotest_private.idl.

type ShelfItem

type ShelfItem struct {
	AppID           string          `json:"appId"`
	LaunchID        string          `json:"launchId"`
	Title           string          `json:"title"`
	Type            ShelfItemType   `json:"type"`
	Status          ShelfItemStatus `json:"status"`
	ShowsToolTip    bool            `json:"showsTooltip"`
	PinnedByPolicy  bool            `json:"pinnedByPolicy"`
	HasNotification bool            `json:"hasNotification"`
}

ShelfItem corresponds to the "ShelfItem" defined in autotest_private.idl.

func ShelfItems

func ShelfItems(ctx context.Context, tconn *chrome.TestConn) ([]*ShelfItem, error)

ShelfItems returns the list of apps in the shelf.

type ShelfItemStatus

type ShelfItemStatus string

ShelfItemStatus repsents the type of the current status of a shelf item.

const (
	ShelfItemClosed    ShelfItemStatus = "Closed"
	ShelfItemRunning   ShelfItemStatus = "Running"
	ShelfItemAttention ShelfItemStatus = "Attention"
)

As defined in ShelfItemStatus in autotest_private.idl.

type ShelfItemType

type ShelfItemType string

ShelfItemType represents the type of a shelf item.

const (
	ShelfItemTypeApp       ShelfItemType = "App"
	ShelfItemTypePinnedApp ShelfItemType = "PinnedApp"
	ShelfItemTypeShortcut  ShelfItemType = "BrowserShortcut"
	ShelfItemTypeDialog    ShelfItemType = "Dialog"
)

As defined in ShelfItemType in autotest_private.idl.

type ShelfState

type ShelfState struct {
	ScrollDistance float32 `json:"scrollDistance"`
}

ShelfState corresponds to the "ShelfState" defined in autotest_private.idl

type SnapPosition

type SnapPosition string

SnapPosition represents the different snap position in split view.

const (
	SnapPositionLeft  SnapPosition = "Left"
	SnapPositionRight SnapPosition = "Right"
)

As defined in ash::SplitViewController here: https://cs.chromium.org/chromium/src/ash/wm/splitview/split_view_controller.h

type WMEventType

type WMEventType string

WMEventType represents the different WM Event type in Ash.

const (
	WMEventNormal     WMEventType = "WMEventNormal"
	WMEventMaximize   WMEventType = "WMEventMaximize"
	WMEventMinimize   WMEventType = "WMEventMinimize"
	WMEventFullscreen WMEventType = "WMEventFullscreen"
	WMEventSnapLeft   WMEventType = "WMEventSnapLeft"
	WMEventSnapRight  WMEventType = "WMEventSnapRight"
)

As defined in ash::wm::WMEventType here: https://cs.chromium.org/chromium/src/ash/wm/wm_event.h

func WMEventTypeForState

func WMEventTypeForState(state WindowStateType) WMEventType

WMEventTypeForState returns the WMEventType to turn a window into the given state.

type Window

type Window struct {
	ID           int             `json:"id"`
	Name         string          `json:"name"`
	WindowType   WindowType      `json:"windowType"`
	State        WindowStateType `json:"stateType"`
	BoundsInRoot coords.Rect     `json:"boundsInRoot"`
	TargetBounds coords.Rect     `json:"targetBounds"`
	DisplayID    string          `json:"displayId"`

	Title            string `json:"title"`
	IsAnimating      bool   `json:"isAnimating"`
	IsVisible        bool   `json:"isVisible"`
	TargetVisibility bool   `json:"target_visibility"`
	CanFocus         bool   `json:"canFocus"`
	CanResize        bool   `json:"canResize"`

	IsActive                   bool                `json:"isActive"`
	HasFocus                   bool                `json:"hasFocus"`
	OnActiveDesk               bool                `json:"onActiveDesk"`
	HasCapture                 bool                `json:"hasCapture"`
	CaptionHeight              int                 `json:"captionHeight"`
	CaptionButtonEnabledStatus CaptionButtonStatus `json:"captionButtonEnabledStatus"`
	CaptionButtonVisibleStatus CaptionButtonStatus `json:"captionButtonVisibleStatus"`
	ARCPackageName             string              `json:"arcPackageName"`
	OverviewInfo               *OverviewInfo       `json:"overviewInfo,omitempty"`
	IsFrameVisible             bool                `json:"isFrameVisible"`
	FrameMode                  FrameMode           `json:"FrameMode"`
	FullRestoreWindowAppID     string              `json:"fullRestoreWindowAppId"`
}

Window represents a normal window (i.e. browser windows or ARC app windows). As defined in AppWindowInfo in https://cs.chromium.org/chromium/src/chrome/common/extensions/api/autotest_private.idl

func BringWindowToForeground

func BringWindowToForeground(ctx context.Context, tconn *chrome.TestConn, windowTitle string) (*Window, error)

BringWindowToForeground takes windowTitle, finds the window and activates it.

func DraggedWindowInOverview

func DraggedWindowInOverview(ctx context.Context, tconn *chrome.TestConn) (*Window, error)

DraggedWindowInOverview returns the window that is currently being dragged under overview mode. It is an error if no window is being dragged.

func FindAllWindows

func FindAllWindows(ctx context.Context, tconn *chrome.TestConn, predicate func(*Window) bool) (matchingWindows []*Window, err error)

FindAllWindows returns the Chrome windows with which the given predicate returns true.

func FindFirstWindowInOverview

func FindFirstWindowInOverview(ctx context.Context, tconn *chrome.TestConn) (*Window, error)

FindFirstWindowInOverview returns the window which positioned the first item of the overview (i.e. appears at the top-left in the overview mode).

func FindOnlyWindow

func FindOnlyWindow(ctx context.Context, tconn *chrome.TestConn, predicate func(*Window) bool) (*Window, error)

FindOnlyWindow returns the Chrome window with which the given predicate returns true. If there are multiple, this returns an error.

func FindWindow

func FindWindow(ctx context.Context, tconn *chrome.TestConn, predicate func(*Window) bool) (*Window, error)

FindWindow returns the Chrome window with which the given predicate returns true. If there are multiple, this returns the first found window.

func GetARCAppWindowInfo

func GetARCAppWindowInfo(ctx context.Context, tconn *chrome.TestConn, pkgName string) (*Window, error)

GetARCAppWindowInfo queries into Ash and returns the ARC window info. Currently, this returns information on the top window of a specified app.

func GetARCGhostWindowInfo

func GetARCGhostWindowInfo(ctx context.Context, tconn *chrome.TestConn, appID string) (*Window, error)

GetARCGhostWindowInfo queries into Ash and returns the ARC ghost window info by session id.

func GetActiveWindow

func GetActiveWindow(ctx context.Context, tconn *chrome.TestConn) (*Window, error)

GetActiveWindow returns the active window.

func GetAllARCAppWindowsInfo

func GetAllARCAppWindowsInfo(ctx context.Context, tconn *chrome.TestConn, pkgName string) ([]*Window, error)

GetAllARCAppWindowsInfo queries into Ash and returns all of the ARC windows info.

func GetAllWindows

func GetAllWindows(ctx context.Context, tconn *chrome.TestConn) ([]*Window, error)

GetAllWindows queries Chrome to list all of the app windows currently in the system.

func GetWindow

func GetWindow(ctx context.Context, tconn *chrome.TestConn, windowID int) (*Window, error)

GetWindow is a utility function to return the info of the window for the given ID.

func SnappedWindows

func SnappedWindows(ctx context.Context, tconn *chrome.TestConn) ([]*Window, error)

SnappedWindows returns the snapped windows if any.

func WaitForAnyWindow

func WaitForAnyWindow(ctx context.Context, tconn *chrome.TestConn, p func(*Window) bool) (*Window, error)

WaitForAnyWindow waits for a window to satisfy the given predicate and returns it.

func WaitForAnyWindowWithTitle

func WaitForAnyWindowWithTitle(ctx context.Context, tconn *chrome.TestConn, title string) (*Window, error)

WaitForAnyWindowWithTitle finds the first window whose title is title.

func WaitForAnyWindowWithoutTitle

func WaitForAnyWindowWithoutTitle(ctx context.Context, tconn *chrome.TestConn, title string) (*Window, error)

WaitForAnyWindowWithoutTitle finds the first window whose title is not title.

func (*Window) ActivateWindow

func (w *Window) ActivateWindow(ctx context.Context, tconn *chrome.TestConn) error

ActivateWindow requests to activate this window.

func (*Window) CloseWindow

func (w *Window) CloseWindow(ctx context.Context, tconn *chrome.TestConn) error

CloseWindow requests to close this window and waits for it to be closed.

type WindowStateType

type WindowStateType string

WindowStateType represents the different window state type in Ash.

const (
	// Normal is actually used to represent both "Normal" and "Default".
	WindowStateNormal       WindowStateType = "Normal"
	WindowStateMinimized    WindowStateType = "Minimized"
	WindowStateMaximized    WindowStateType = "Maximized"
	WindowStateFullscreen   WindowStateType = "Fullscreen"
	WindowStateLeftSnapped  WindowStateType = "LeftSnapped"
	WindowStateRightSnapped WindowStateType = "RightSnapped"
	WindowStatePIP          WindowStateType = "PIP"
)

As defined in ash::WindowStateType here: https://cs.chromium.org/chromium/src/ash/public/cpp/window_state_type.h

func GetARCAppWindowState

func GetARCAppWindowState(ctx context.Context, tconn *chrome.TestConn, pkgName string) (WindowStateType, error)

GetARCAppWindowState gets the Chrome side window state of the ARC app window with pkgName.

func GetAllARCAppWindowStates

func GetAllARCAppWindowStates(ctx context.Context, tconn *chrome.TestConn, pkgName string) (windowStates []WindowStateType, err error)

GetAllARCAppWindowStates gets all the Chrome side window states of the ARC app windows with pkgName.

func SetARCAppWindowState

func SetARCAppWindowState(ctx context.Context, tconn *chrome.TestConn, pkgName string, et WMEventType) (WindowStateType, error)

SetARCAppWindowState sends WM event to ARC app window to change its window state, and returns the expected new state type.

func SetARCAppWindowStateAndWait

func SetARCAppWindowStateAndWait(ctx context.Context, tconn *chrome.TestConn, pkgName string, expectedState WindowStateType) (WindowStateType, error)

SetARCAppWindowStateAndWait sends WM event to ARC app window to change its window state, waits for it to stop animating, and returns the expected new state type.

func SetWindowState

func SetWindowState(ctx context.Context, tconn *chrome.TestConn, id int, et WMEventType, waitForStateChange bool) (WindowStateType, error)

SetWindowState requests changing the state of the window to the requested event type and returns the updated state if waitForStateChange is true. Otherwise, SetWindowState just sends a WMEvent and returns the expected state.

type WindowType

type WindowType string

WindowType represents the type of a window.

const (
	WindowTypeBrowser   WindowType = "Browser"
	WindowTypeChromeApp WindowType = "ChromeApp"
	WindowTypeArc       WindowType = "ArcApp"
	WindowTypeCrostini  WindowType = "CrostiniApp"
	WindowTypeSystem    WindowType = "SystemApp"
	WindowTypeExtension WindowType = "ExtensionApp"
	WindowTypeLacros    WindowType = "Lacros"
)

As defined in ash::AppType here: https://cs.chromium.org/chromium/src/ash/constants/app_types.h

Directories

Path Synopsis
Package ashproc provides utilities to find ash Chrome (a.k.a.
Package ashproc provides utilities to find ash Chrome (a.k.a.

Jump to

Keyboard shortcuts

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