Documentation ¶
Overview ¶
Package settings provides support for the Linux settings on the Settings app.
Index ¶
- Constants
- Variables
- func ChangeDiskSize(ctx context.Context, tconn *chrome.TestConn, kb *input.KeyboardEventWriter, ...) (uint64, error)
- func GetDiskSize(ctx context.Context, tconn *chrome.TestConn, slider *nodewith.Finder) (uint64, error)
- func OpenInstaller(ctx context.Context, tconn *chrome.TestConn, cr *chrome.Chrome) (retErr error)
- func ParseDiskSize(sizeString string) (uint64, error)
- type Settings
- func FindSettingsPage(ctx context.Context, tconn *chrome.TestConn, windowName string) (s *Settings, err error)
- func OpenLinuxManagedSharedFoldersSetting(ctx context.Context, tconn *chrome.TestConn, cr *chrome.Chrome) (*Settings, error)
- func OpenLinuxSettings(ctx context.Context, tconn *chrome.TestConn, cr *chrome.Chrome, ...) (*Settings, error)
- func OpenLinuxSubpage(ctx context.Context, tconn *chrome.TestConn, cr *chrome.Chrome) (*Settings, error)
- func (s *Settings) ClickChange() uiauto.Action
- func (s *Settings) ClickRemove() uiauto.Action
- func (s *Settings) Close(ctx context.Context) error
- func (s *Settings) GetCurAndTargetDiskSize(ctx context.Context, keyboard *input.KeyboardEventWriter) (curSize, targetSize uint64, err error)
- func (s *Settings) GetDiskSize(ctx context.Context) (string, error)
- func (s *Settings) GetSharedFolders(ctx context.Context) ([]string, error)
- func (s *Settings) LeftClickUI(findParams *nodewith.Finder) uiauto.Action
- func (s *Settings) Remove() uiauto.Action
- func (s *Settings) Resize(ctx context.Context, keyboard *input.KeyboardEventWriter, ...) (string, uint64, error)
- func (s *Settings) ResizeDisk(ctx context.Context, kb *input.KeyboardEventWriter, targetSize uint64, ...) error
- func (s *Settings) UnshareFolder(ctx context.Context, folder string) error
- func (s *Settings) VerifyResizeResults(ctx context.Context, cont *vm.Container, sizeOnSlider string, size uint64) error
- func (s *Settings) WaitForUI(findParams *nodewith.Finder) uiauto.Action
Constants ¶
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 )
const ( PageNameLinux = "Settings - Linux development environment" PageNameMSF = "Settings - " + ManageSharedFolders )
Window names for different settings page.
const (
)Sub settings name.
Variables ¶
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.
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.
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 ¶
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 ¶
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 ¶
ClickChange clicks Change to launch the resize dialog.
func (*Settings) ClickRemove ¶
ClickRemove clicks Remove to launch the delete.
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 ¶
GetDiskSize returns the disk size on the Settings app.
func (*Settings) GetSharedFolders ¶
GetSharedFolders returns a list of shared folders. Settings must be open at the Linux Manage Shared Folders page.
func (*Settings) LeftClickUI ¶
LeftClickUI performs a left click action on the given Finder
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 ¶
UnshareFolder deletes a shared folder from Settings app. Settings must be open at the Linux Manage Shared Folders page.