wm

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: 25 Imported by: 0

Documentation

Overview

Package wm provides Window Manager Helper functions.

Package wm provides Window Manager Helper functions.

Package wm provides Window Manager Helper functions.

Index

Constants

View Source
const (
	// ResizeLockTestPkgName is the package name of the resize lock app.
	ResizeLockTestPkgName = "org.chromium.arc.testapp.resizelock"
	// ResizeLockApkName is the apk name of the resize lock app.
	ResizeLockApkName = "ArcResizeLockTest.apk"
	// ResizeLockMainActivityName is the main activity name of the resize lock app.
	ResizeLockMainActivityName = "org.chromium.arc.testapp.resizelock.MainActivity"
	// ResizeLockUnresizableUnspecifiedActivityName is the name of the unresizable, unspecified activity of the resize lock app.
	ResizeLockUnresizableUnspecifiedActivityName = "org.chromium.arc.testapp.resizelock.UnresizableUnspecifiedActivity"
	// ResizeLockUnresizablePortraitActivityName is the name of the unresizable, portrait-only activity of the resize lock app.
	ResizeLockUnresizablePortraitActivityName = "org.chromium.arc.testapp.resizelock.UnresizablePortraitActivity"
	// ResizeLockResizableUnspecifiedMaximizedActivityName is the name of the resizable, maximized activity of the resize lock app.
	ResizeLockResizableUnspecifiedMaximizedActivityName = "org.chromium.arc.testapp.resizelock.ResizableUnspecifiedMaximizedActivity"
	// ResizeLockPipActivityName is the name of the PIP-able activity of the resize lock app.
	ResizeLockPipActivityName = "org.chromium.arc.testapp.resizelock.PipActivity"

	// ResizeLock2PkgName is the package name of the second resize lock app.
	ResizeLock2PkgName = "org.chromium.arc.testapp.resizelock2"
	// ResizeLock3PkgName is the package name of the third resize lock app.
	ResizeLock3PkgName = "org.chromium.arc.testapp.resizelock3"
	// ResizeLock2ApkName is the apk name of the second resize lock app.
	ResizeLock2ApkName = "ArcResizeLockTest2.apk"
	// ResizeLock3ApkName is the apk name of the third resize lock app.
	ResizeLock3ApkName = "ArcResizeLockTest3.apk"

	// CenterButtonClassName is the class name of the caption center button.
	CenterButtonClassName = "FrameCenterButton"
	// BubbleDialogClassName is the class name of the bubble dialog.
	BubbleDialogClassName = "BubbleDialogDelegateView"

	// AppManagementSettingToggleName is the a11y name of the app-management setting toggle.
	AppManagementSettingToggleName = "Preset window sizes"

	// ResizeLockAppName is the name of the resize lock app. Used to identify the shelf icon of interest.
	ResizeLockAppName = "ArcResizeLockTest"
)
View Source
const (
	// Pkg23 Apk compiled against target SDK 23 (Pre-N)
	Pkg23 = "org.chromium.arc.testapp.windowmanager23"
	// Pkg24 Apk compiled against target SDK 24 (N)
	Pkg24 = "org.chromium.arc.testapp.windowmanager24"
	// Pkg24InPhoneSizeList is an app whose package name is allowlisted so it will be launched in phone size by default.
	Pkg24InPhoneSizeList = "org.chromium.arc.testapp.windowmanager24.inphonesizelist"
	// Pkg24InTabletSizeList is an app whose package name is allowlisted so it will be launched in tablet size by default.
	Pkg24InTabletSizeList = "org.chromium.arc.testapp.windowmanager24.intabletsizelist"
	// Pkg24InMaximizedList is an app whose package name is allowlisted so it will be launched in maximized by default.
	Pkg24InMaximizedList = "org.chromium.arc.testapp.windowmanager24.inmaximizedlist"

	// APKNameArcWMTestApp23 APK name for ArcWMTestApp_23.apk
	APKNameArcWMTestApp23 = "ArcWMTestApp_23.apk"

	// APKNameArcWMTestApp24 APK name for ArcWMTestApp_24.apk
	APKNameArcWMTestApp24 = "ArcWMTestApp_24.apk"

	// APKNameArcPipSimpleTastTest APK name for ArcPipSimpleTastTest.apk
	APKNameArcPipSimpleTastTest = "ArcPipSimpleTastTest.apk"

	// APKNameArcWMTestApp24PhoneSize APK name for ArcWMTestApp_24_InPhoneSizeList.apk.
	APKNameArcWMTestApp24PhoneSize = "ArcWMTestApp_24_InPhoneSizeList.apk"
	// APKNameArcWMTestApp24TabletSize APK name for ArcWMTestApp_24_InTabletSizeList.apk.
	APKNameArcWMTestApp24TabletSize = "ArcWMTestApp_24_InTabletSizeList.apk"
	// APKNameArcWMTestApp24Maximized APK name for ArcWMTestApp_24_InMaximizedList.apk.
	APKNameArcWMTestApp24Maximized = "ArcWMTestApp_24_InMaximizedList.apk"

	// ResizableLandscapeActivity used by the subtests.
	ResizableLandscapeActivity = "org.chromium.arc.testapp.windowmanager.ResizeableLandscapeActivity"
	// NonResizableLandscapeActivity used by the subtests.
	NonResizableLandscapeActivity = "org.chromium.arc.testapp.windowmanager.NonResizeableLandscapeActivity"
	// ResizableUnspecifiedActivity used by the subtests.
	ResizableUnspecifiedActivity = "org.chromium.arc.testapp.windowmanager.ResizeableUnspecifiedActivity"
	// NonResizableUnspecifiedActivity used by the subtests.
	NonResizableUnspecifiedActivity = "org.chromium.arc.testapp.windowmanager.NonResizeableUnspecifiedActivity"
	// ResizablePortraitActivity used by the subtests.
	ResizablePortraitActivity = "org.chromium.arc.testapp.windowmanager.ResizeablePortraitActivity"
	// NonResizablePortraitActivity used by the subtests.
	NonResizablePortraitActivity = "org.chromium.arc.testapp.windowmanager.NonResizeablePortraitActivity"
	// LandscapeActivity used by the subtests.
	LandscapeActivity = "org.chromium.arc.testapp.windowmanager.LandscapeActivity"
	// UnspecifiedActivity used by the subtests.
	UnspecifiedActivity = "org.chromium.arc.testapp.windowmanager.UnspecifiedActivity"
	// PortraitActivity used by the subtests.
	PortraitActivity = "org.chromium.arc.testapp.windowmanager.PortraitActivity"

	// Landscape and Portrait constraints come from:
	// http://cs/android/vendor/google_arc/packages/development/ArcWMTestApp/src/org/chromium/arc/testapp/windowmanager/BaseActivity.java?l=411
	// Landscape used by the subtests.
	Landscape = "landscape"
	// Portrait used by the subtests.
	Portrait = "portrait"

	// TimeReservedForStop is the time that is reserved to stop an activity after the execution is complete.
	TimeReservedForStop = 500 * time.Millisecond
	// RotationAnimationDuration is the time to wait for an animation to complete.
	RotationAnimationDuration = 750 * time.Millisecond

	// SplitScreenDividerThickness is the width of the divider when in tablet mode. This comes from:
	// http://cs/eureka_internal/chromium/src/ash/wm/splitview/split_view_constants.h;l=32;rcl=62c9f9769fdd621050662f3cde82d5672e75271f
	// Window widths may be adjusted by up to this amount when in split screen mode.
	SplitScreenDividerThickness = 8
)

Variables

This section is empty.

Functions

func ChangeDisplayZoomFactor

func ChangeDisplayZoomFactor(ctx context.Context, tconn *chrome.TestConn, dispID string, zoomFactor float64) error

ChangeDisplayZoomFactor changes the ChromeOS display zoom factor.

func CheckCompatModeButton

func CheckCompatModeButton(ctx context.Context, tconn *chrome.TestConn, a *arc.ARC, d *ui.Device, cr *chrome.Chrome, activity *arc.Activity, mode ResizeLockMode) error

CheckCompatModeButton verifies the state of the compat-mode button of the given app.

func CheckHorizontalTabletSplit

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

CheckHorizontalTabletSplit helps to assert window bounds in horizontal split mode.

func CheckMaximizeNonResizable

func CheckMaximizeNonResizable(ctx context.Context, tconn *chrome.TestConn, act *arc.Activity, d *ui.Device) error

CheckMaximizeNonResizable checks that the window is both maximized and not resizable.

func CheckMaximizeResizable

func CheckMaximizeResizable(ctx context.Context, tconn *chrome.TestConn, act *arc.Activity, d *ui.Device) error

CheckMaximizeResizable checks that the window is both maximized and resizable.

func CheckMaximizeToFullscreenToggle

func CheckMaximizeToFullscreenToggle(ctx context.Context, tconn *chrome.TestConn, maxWindowCoords coords.Rect, pkgName string) error

CheckMaximizeToFullscreenToggle checks window's bounds transitioning from max to fullscreen.

func CheckMaximizeWindowInTabletMode

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

CheckMaximizeWindowInTabletMode checks the activtiy covers display's work area in maximize mode.

func CheckPillarbox

func CheckPillarbox(ctx context.Context, tconn *chrome.TestConn, act *arc.Activity, d *ui.Device) error

CheckPillarbox checks that the window is in pillar-box mode.

func CheckPillarboxNonResizable

func CheckPillarboxNonResizable(ctx context.Context, tconn *chrome.TestConn, act *arc.Activity, d *ui.Device) error

CheckPillarboxNonResizable checks that the window is both in pillar-box mode and is not resizable.

func CheckPillarboxResizable

func CheckPillarboxResizable(ctx context.Context, tconn *chrome.TestConn, act *arc.Activity, d *ui.Device) error

CheckPillarboxResizable checks that the window is both in pillar-box mode and is resizable.

func CheckResizability

func CheckResizability(ctx context.Context, tconn *chrome.TestConn, a *arc.ARC, d *ui.Device, pkgName string, expected bool) error

CheckResizability verifies the given app's resizability.

func CheckResizeLockState

func CheckResizeLockState(ctx context.Context, tconn *chrome.TestConn, a *arc.ARC, d *ui.Device, cr *chrome.Chrome, activity *arc.Activity, mode ResizeLockMode, isSplashVisible bool) error

CheckResizeLockState verifies the various properties that depend on resize lock state.

func CheckRestoreNonResizable

func CheckRestoreNonResizable(ctx context.Context, tconn *chrome.TestConn, act *arc.Activity, d *ui.Device) error

CheckRestoreNonResizable checks that the window is both in restore mode and is not resizable.

func CheckRestoreResizable

func CheckRestoreResizable(ctx context.Context, tconn *chrome.TestConn, act *arc.Activity, d *ui.Device) error

CheckRestoreResizable checks that the window is both in restore mode and is resizable.

func CheckVerticalTabletSplit

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

CheckVerticalTabletSplit helps to assert window bounds in vertical split mode.

func CheckVisibility

func CheckVisibility(ctx context.Context, tconn *chrome.TestConn, className string, visible bool) error

CheckVisibility checks whether the node specified by the given class name exists or not.

func CloseAppManagementSetting

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

CloseAppManagementSetting closes any open app management page.

func CloseSplash

func CloseSplash(ctx context.Context, tconn *chrome.TestConn, method InputMethodType, keyboard *input.KeyboardEventWriter) error

CloseSplash closes the splash screen via the given method.

func CompareCaption

func CompareCaption(ctx context.Context, tconn *chrome.TestConn, pkgName string, wantedCaption ash.CaptionButtonStatus) error

CompareCaption compares the activity caption buttons with the wanted one. Returns nil only if they are equal.

func EnsureARCFontScaleChanged

func EnsureARCFontScaleChanged(ctx context.Context, a *arc.ARC, fontScale float64) error

EnsureARCFontScaleChanged changes the android font scale via settings and waits until the font scale changes completely.

func GetARCFontScale

func GetARCFontScale(ctx context.Context, a *arc.ARC) (float64, error)

GetARCFontScale gets the font scale from the android settings.

func GetButtonBounds

func GetButtonBounds(ctx context.Context, d *ui.Device, actPkgName string) (coords.Rect, error)

GetButtonBounds is used to get button bounds in a given package name.

func OpenAppManagementSetting

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

OpenAppManagementSetting opens the app management page if the given app.

func OrientationFromBounds

func OrientationFromBounds(bounds coords.Rect) string

OrientationFromBounds returns orientation from the given bounds.

func RotateDisplay

func RotateDisplay(ctx context.Context, tconn *chrome.TestConn, angle display.RotationAngle) (func() error, error)

RotateDisplay rotates the screen by the given rotation angle. It returns a cleanup function that should be called to restore the device rotation to the original state.

func RotateToLandscape

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

RotateToLandscape ensures to set the primary display orientation to landscape.

func SetupAndRunTestCases

func SetupAndRunTestCases(ctx context.Context, s *testing.State, isTabletMode bool, testCases []TestCase)

SetupAndRunTestCases sets up the environment for tests and runs testcases.

func TabletDefaultLaunchHelper

func TabletDefaultLaunchHelper(ctx context.Context, tconn *chrome.TestConn, a *arc.ARC, d *ui.Device, activityInfo []TabletLaunchActivityInfo, isResizable bool) error

TabletDefaultLaunchHelper runs tablet default lunch test-cases by given activity names.

func TabletDisplaySizeChangeHelper

func TabletDisplaySizeChangeHelper(ctx context.Context, tconn *chrome.TestConn, a *arc.ARC, d *ui.Device, activityInfo []TabletLaunchActivityInfo) (err error)

TabletDisplaySizeChangeHelper runs test-cases for tablet display size change.

func TabletFontSizeChangeHelper

func TabletFontSizeChangeHelper(ctx context.Context, tconn *chrome.TestConn, a *arc.ARC, d *ui.Device, activityInfo []TabletLaunchActivityInfo) (err error)

TabletFontSizeChangeHelper runs test-cases for tablet font size change.

func TabletImmerseViaAPI

func TabletImmerseViaAPI(ctx context.Context, tconn *chrome.TestConn, a *arc.ARC, d *ui.Device, activityInfo []TabletLaunchActivityInfo) error

TabletImmerseViaAPI runs test-cases for immerse via API.

func TabletShelfHideShowHelper

func TabletShelfHideShowHelper(ctx context.Context, tconn *chrome.TestConn, a *arc.ARC, d *ui.Device, activityInfo []TabletLaunchActivityInfo, checkFunc CheckFunc) error

TabletShelfHideShowHelper runs tablet test-cases that hide and show the shelf.

func ToggleAppManagementSettingToggle

func ToggleAppManagementSettingToggle(ctx context.Context, tconn *chrome.TestConn, a *arc.ARC, d *ui.Device, cr *chrome.Chrome, activity *arc.Activity, appName string, currentMode, nextMode ResizeLockMode, method InputMethodType, keyboard *input.KeyboardEventWriter) error

ToggleAppManagementSettingToggle opens the app-management page for the given app via the shelf icon, toggles the resize lock setting, and verifies the states of the app and the setting toggle.

func ToggleCompatModeMenu

func ToggleCompatModeMenu(ctx context.Context, tconn *chrome.TestConn, method InputMethodType, keyboard *input.KeyboardEventWriter, isMenuVisible bool) error

ToggleCompatModeMenu toggles the compat-mode menu via the given method and verifies the expected visibility of the compat-mode menu.

func ToggleFullscreen

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

ToggleFullscreen toggles fullscreen by injecting the Zoom Toggle keycode.

func ToggleResizeLockMode

func ToggleResizeLockMode(ctx context.Context, tconn *chrome.TestConn, a *arc.ARC, d *ui.Device, cr *chrome.Chrome, activity *arc.Activity, currentMode, nextMode ResizeLockMode, action ConfirmationDialogAction, method InputMethodType, keyboard *input.KeyboardEventWriter) error

ToggleResizeLockMode shows the compat-mode menu, selects one of the resize lock mode buttons on the compat-mode menu via the given method, and verifies the post state.

func UIClick

func UIClick(ctx context.Context, d *ui.Device, opts ...ui.SelectorOption) error

UIClick sends a "Click" message to an UI Object. The UI Object is selected from opts, which are the selectors.

func UIClickImmersive

func UIClickImmersive(ctx context.Context, act *arc.Activity, d *ui.Device) error

UIClickImmersive clicks on the "Immersive" button that is present on the ArcWMTest activity.

func UIClickLandscape

func UIClickLandscape(ctx context.Context, act *arc.Activity, d *ui.Device) error

UIClickLandscape clicks on the "Landscape" radio button that is present in the ArcWMTest activity.

func UIClickLaunchActivity

func UIClickLaunchActivity(ctx context.Context, act *arc.Activity, d *ui.Device) error

UIClickLaunchActivity clicks on the "Launch Activity" button that is present in the ArcWMTest activity.

func UIClickNormal

func UIClickNormal(ctx context.Context, act *arc.Activity, d *ui.Device) error

UIClickNormal clicks on the "Normal" button that is present on the ArcWMTest activity.

func UIClickPortrait

func UIClickPortrait(ctx context.Context, act *arc.Activity, d *ui.Device) error

UIClickPortrait clicks on the "Portrait" radio button that is present in the ArcWMTest activity.

func UIClickRootActivity

func UIClickRootActivity(ctx context.Context, act *arc.Activity, d *ui.Device) error

UIClickRootActivity clicks on the "Root Activity" checkbox that is present on the ArcWMTest activity.

func UIClickUnspecified

func UIClickUnspecified(ctx context.Context, act *arc.Activity, d *ui.Device) error

UIClickUnspecified clicks on the "Unspecified" radio button that is present in the ArcWMTest activity.

func UINumberActivities

func UINumberActivities(ctx context.Context, act *arc.Activity, d *ui.Device) (int, error)

UINumberActivities returns the number of activities present in the ArcWMTestApp stack.

func UIOrientation

func UIOrientation(ctx context.Context, act *arc.Activity, d *ui.Device) (string, error)

UIOrientation returns the current orientation of the ArcWMTestApp window.

func UIWaitForRestartDialogAndRestart

func UIWaitForRestartDialogAndRestart(ctx context.Context, act *arc.Activity, d *ui.Device) error

UIWaitForRestartDialogAndRestart waits for the "Application needs to restart to resize" dialog. This dialog appears when a Pre-N application tries to switch between maximized / restored window states. See: http://cs/pi-arc-dev/frameworks/base/core/java/com/android/internal/policy/DecorView.java

func WaitForARCAppWindowState

func WaitForARCAppWindowState(ctx context.Context, tconn *chrome.TestConn, windowState ash.WindowStateType, windowID int, isFrameVisible bool) error

WaitForARCAppWindowState waits for conditions to make sure ARC App window is in correct state and animation finished.

func WaitForDisplayOrientation

func WaitForDisplayOrientation(ctx context.Context, tconn *chrome.TestConn, desiredOrientation display.OrientationType) error

WaitForDisplayOrientation waits for the display to rotate to the desired orientation.

func WaitForShelfAnimationComplete

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

WaitForShelfAnimationComplete waits for 5 seconds to shelf animation complete.

func WaitUntilActivityIsReady

func WaitUntilActivityIsReady(ctx context.Context, tconn *chrome.TestConn, act *arc.Activity, d *ui.Device) error

WaitUntilActivityIsReady waits until the given activity is ready. The "wait" is performed both at the Ash and Android sides. Additionally, it waits until the "Refresh" button exists. act must be a "org.chromium.arc.testapp.windowmanager" activity, otherwise the "Refresh" button check will fail.

func WaitUntilFrameMatchesCondition

func WaitUntilFrameMatchesCondition(ctx context.Context, tconn *chrome.TestConn, pkgName string, visible bool, mode ash.FrameMode) error

WaitUntilFrameMatchesCondition waits until the package's window has a frame that matches the given condition.

Types

type CheckCase

type CheckCase struct {
	Name string
	Func CheckFunc
}

CheckCase represents a struct for activtiy names and their assert func.

type CheckFunc

type CheckFunc func(ctx context.Context, tconn *chrome.TestConn, act *arc.Activity, d *ui.Device) error

CheckFunc represents a function that checks certain criteria for tests.

type ConfirmationDialogAction

type ConfirmationDialogAction int

ConfirmationDialogAction represents the expected behavior and action to take for the resizability confirmation dialog.

const (
	// DialogActionNoDialog represents the behavior where resize confirmation dialog isn't shown when a window is resized.
	DialogActionNoDialog ConfirmationDialogAction = iota
	// DialogActionCancel represents the behavior where resize confirmation dialog is shown, and the cancel button should be selected.
	DialogActionCancel
	// DialogActionConfirm represents the behavior where resize confirmation dialog is shown, and the confirm button should be selected.
	DialogActionConfirm
	// DialogActionConfirmWithDoNotAskMeAgainChecked represents the behavior where resize confirmation dialog is shown, and the confirm button should be selected with the "Don't ask me again" option on.
	DialogActionConfirmWithDoNotAskMeAgainChecked
)

type InputMethodType

type InputMethodType int

InputMethodType represents how to interact with UI.

const (
	// InputMethodClick represents the state where UI should be interacted with mouse click.
	InputMethodClick InputMethodType = iota
	// InputMethodKeyEvent represents the state where UI should be interacted with keyboard.
	InputMethodKeyEvent
)

func (InputMethodType) String

func (mode InputMethodType) String() string

type ResizeLockMode

type ResizeLockMode int

ResizeLockMode represents the high-level state of the app from the resize-lock feature's perspective.

const (
	// PhoneResizeLockMode represents the state where an app is locked in a portrait size.
	PhoneResizeLockMode ResizeLockMode = iota
	// TabletResizeLockMode represents the state where an app is locked in a landscape size.
	TabletResizeLockMode
	// ResizableTogglableResizeLockMode represents the state where an app is not resize lock, and the resize lock state is togglable.
	ResizableTogglableResizeLockMode
	// NoneResizeLockMode represents the state where an app is not eligible for resize lock.
	NoneResizeLockMode
)

func (ResizeLockMode) String

func (mode ResizeLockMode) String() string

type TabletLaunchActivityInfo

type TabletLaunchActivityInfo struct {
	// Test-case activity name.
	ActivityName string
	// Activity's desired orientation.
	DesiredDO display.OrientationType
}

TabletLaunchActivityInfo holds activity info.

type TestCase

type TestCase struct {
	Name string
	Func TestFunc
}

TestCase represents a struct for test names and their func.

type TestFunc

type TestFunc func(context.Context, *chrome.TestConn, *arc.ARC, *ui.Device) error

TestFunc represents a function that tests if the window is in a certain state.

Jump to

Keyboard shortcuts

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