settings

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

Documentation

Overview

Package settings provides support for the Linux settings on the Settings app.

Index

Constants

View Source
const (
	// SizeB is a multiplier to convert bytes to bytes.
	SizeB = 1
	// SizeKB is a multiplier to convert bytes to kilobytes.
	SizeKB = 1024
	// SizeMB is a multiplier to convert bytes to megabytes.
	SizeMB = 1024 * 1024
	// SizeGB is a multiplier to convert bytes to gigabytes.
	SizeGB = 1024 * 1024 * 1024
	// SizeTB is a multiplier to convert bytes to terabytes.
	SizeTB = 1024 * 1024 * 1024 * 1024
)
View Source
const (
	PageNameLinux = "Settings - Linux development environment"
	PageNameMSF   = "Settings - " + ManageSharedFolders
)

Window names for different settings page.

View Source
const (
	ManageSharedFolders = "Manage shared folders"
)

Sub settings name.

Variables

View Source
var (
	DebianUpgradeText = nodewith.NameStartingWith("An upgrade to Debian").First()
	PageLinux         = nodewith.NameStartingWith(PageNameLinux).First()
	// We may need to update this if more 'Turn on' buttons are added to Settings, but there isn't a good way to make this more specific yet.
	TurnOnButton     = nodewith.NameRegex(regexp.MustCompile("Turn on")).Role(role.Button).Ancestor(ossettings.WindowFinder)
	DevelopersButton = nodewith.NameRegex(regexp.MustCompile("Developers")).Role(role.Button).Ancestor(ossettings.WindowFinder)
	LinuxText        = nodewith.Name("Linux development environment").Role(role.StaticText).Ancestor(ossettings.WindowFinder)

	RemoveLinuxAlert     = nodewith.Name("Remove Linux development environment").Role(role.AlertDialog).ClassName("Widget")
	BackupButton         = nodewith.NameStartingWith("Backup Linux").Role(role.Button).Ancestor(ossettings.WindowFinder)
	RestoreButton        = nodewith.NameStartingWith("Replace").Role(role.Button).Ancestor(ossettings.WindowFinder)
	BackupFileWindow     = nodewith.Name("Backup").Role(role.Window).ClassName("ExtensionViewViews")
	BackupSave           = nodewith.Name("Save").Role(role.Button).Ancestor(BackupFileWindow)
	BackupNotification   = nodewith.NameStartingWith("Backup complete").Role(role.AlertDialog).ClassName("MessagePopupView")
	RestoreNotification  = nodewith.NameStartingWith("Restore complete").Role(role.AlertDialog).ClassName("MessagePopupView")
	RestoreConfirmButton = nodewith.Name("Restore").Role(role.Button).ClassName("action-button")
	RestoreFileWindow    = nodewith.Name("Restore").Role(role.Window).ClassName("ExtensionViewViews")
	RestoreTiniFile      = nodewith.NameContaining(".tini").Role(role.StaticText).Ancestor(RestoreFileWindow)
	RestoreOpen          = nodewith.Name("Open").Role(role.Button).Ancestor(RestoreFileWindow)
)

find params for fixed items.

View Source
var RemoveConfirmDialog = removeConfirmDialogStruct{
	Self:   removeLinuxDialog,
	Delete: nodewith.Name("Delete").Role(role.Button).Ancestor(removeLinuxDialog),
	Cancel: nodewith.Name("Cancel").Role(role.Button).Ancestor(removeLinuxDialog),
}

RemoveConfirmDialog represents an instance of the confirm dialog of removing Crostini.

View Source
var ResizeDiskDialog = resizeDiskDialogStruct{
	Self:   nodewith.Name("Resize Linux disk").Role(role.GenericContainer),
	Slider: nodewith.Role(role.Slider),
	Resize: nodewith.Name("Resize").Role(role.Button),
	Cancel: nodewith.Name("Cancel").Role(role.Button).ClassName("cancel-button"),
}

ResizeDiskDialog represents an instance of the Resize Linux disk dialog.

Functions

func ChangeDiskSize

func ChangeDiskSize(ctx context.Context, tconn *chrome.TestConn, kb *input.KeyboardEventWriter, slider *nodewith.Finder, increase bool, targetDiskSize uint64) (uint64, error)

ChangeDiskSize changes the disk size to targetDiskSize through moving the slider. If the target disk size is bigger, set increase to true, otherwise set it to false. The method will return if it reaches the target or the end of the slider. The real size might not be exactly equal to the target because the increment changes depending on the range. FocusAndWait(slider) should be called before calling this method.

func GetDiskSize

func GetDiskSize(ctx context.Context, tconn *chrome.TestConn, slider *nodewith.Finder) (uint64, error)

GetDiskSize returns the current size based on the disk size slider text.

func OpenInstaller

func OpenInstaller(ctx context.Context, tconn *chrome.TestConn, cr *chrome.Chrome) (retErr error)

OpenInstaller clicks the "Turn on" Linux button to open the Crostini installer.

It also clicks next to skip the information screen. An ui.Installer page object can be constructed after calling OpenInstaller to adjust the settings and to complete the installation.

func ParseDiskSize

func ParseDiskSize(sizeString string) (uint64, error)

ParseDiskSize parses disk size from a string like "xx.x GB" to a uint64 value in bytes.

Types

type Settings

type Settings struct {
	// contains filtered or unexported fields
}

Settings represents an instance of the Linux settings in Settings App.

func FindSettingsPage

func FindSettingsPage(ctx context.Context, tconn *chrome.TestConn, windowName string) (s *Settings, err error)

FindSettingsPage finds a pre-opened Settings page with a window name.

func OpenLinuxManagedSharedFoldersSetting

func OpenLinuxManagedSharedFoldersSetting(ctx context.Context, tconn *chrome.TestConn, cr *chrome.Chrome) (*Settings, error)

OpenLinuxManagedSharedFoldersSetting opens the Manage Shared Folders sub-settings page. This is implemented a two-stage process as a single invocation off OpenLinuxSettings with the ManageSharedFolders subsettings param fails on a few boards.

func OpenLinuxSettings

func OpenLinuxSettings(ctx context.Context, tconn *chrome.TestConn, cr *chrome.Chrome, subSettings ...string) (*Settings, error)

OpenLinuxSettings opens Settings app and navigate to Linux Settings and its sub settings if any. Returns a Settings instance.

func OpenLinuxSubpage

func OpenLinuxSubpage(ctx context.Context, tconn *chrome.TestConn, cr *chrome.Chrome) (*Settings, error)

OpenLinuxSubpage opens Linux subpage on Settings page. If Linux is not installed, it opens the installer.

func (*Settings) ClickChange

func (s *Settings) ClickChange() uiauto.Action

ClickChange clicks Change to launch the resize dialog.

func (*Settings) ClickRemove

func (s *Settings) ClickRemove() uiauto.Action

ClickRemove clicks Remove to launch the delete.

func (*Settings) Close

func (s *Settings) Close(ctx context.Context) error

Close closes the Settings App.

func (*Settings) GetCurAndTargetDiskSize

func (s *Settings) GetCurAndTargetDiskSize(ctx context.Context, keyboard *input.KeyboardEventWriter) (curSize, targetSize uint64, err error)

GetCurAndTargetDiskSize gets the current disk size and calculates a target disk size to resize.

func (*Settings) GetDiskSize

func (s *Settings) GetDiskSize(ctx context.Context) (string, error)

GetDiskSize returns the disk size on the Settings app.

func (*Settings) GetSharedFolders

func (s *Settings) GetSharedFolders(ctx context.Context) ([]string, error)

GetSharedFolders returns a list of shared folders. Settings must be open at the Linux Manage Shared Folders page.

func (*Settings) LeftClickUI

func (s *Settings) LeftClickUI(findParams *nodewith.Finder) uiauto.Action

LeftClickUI performs a left click action on the given Finder

func (*Settings) Remove

func (s *Settings) Remove() uiauto.Action

Remove removes Crostini.

func (*Settings) Resize

func (s *Settings) Resize(ctx context.Context, keyboard *input.KeyboardEventWriter, curSize, targetSize uint64) (string, uint64, error)

Resize changes the disk size to the target size. It returns the size on the slider as string and the result size as uint64.

func (*Settings) ResizeDisk

func (s *Settings) ResizeDisk(ctx context.Context, kb *input.KeyboardEventWriter, targetSize uint64, increase bool) error

ResizeDisk resizes the VM disk to approximately targetSize via the settings app. If growing the VM disk, set increase to true, otherwise set it to false.

func (*Settings) UnshareFolder

func (s *Settings) UnshareFolder(ctx context.Context, folder string) error

UnshareFolder deletes a shared folder from Settings app. Settings must be open at the Linux Manage Shared Folders page.

func (*Settings) VerifyResizeResults

func (s *Settings) VerifyResizeResults(ctx context.Context, cont *vm.Container, sizeOnSlider string, size uint64) error

VerifyResizeResults verifies the disk after resizing, both on the Settings page and container.

func (*Settings) WaitForUI

func (s *Settings) WaitForUI(findParams *nodewith.Finder) uiauto.Action

WaitForUI waits until findParams exists

Jump to

Keyboard shortcuts

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