Documentation ¶
Overview ¶
Package arc supports interacting with the ARC framework, which is used to run Android applications on Chrome OS.
Index ¶
- Constants
- func APKPath(value string) string
- func AndroidDataDir(ctx context.Context, user string) (string, error)
- func AppendToArcvmDevConf(ctx context.Context, text string) error
- func BlockOutbound(ctx context.Context) error
- func Booted() testing.Precondition
- func BootstrapCommand(ctx context.Context, name string, arg ...string) *testexec.Cmd
- func CheckNoDex2Oat(outDir string) error
- func ClickAddAccountInSettings(ctx context.Context, arcDevice *androidui.Device, tconn *chrome.TestConn) error
- func DisableSyncFlags() []string
- func FirstDisplayIDByType(ctx context.Context, a *ARC, displayType DisplayType) (int, error)
- func InitExists() (bool, error)
- func InitPID() (int32, error)
- func Lock()
- func MyFilesVolumeID(ctx context.Context, a *ARC) (string, error)
- func NetworkInterfaceNames(ctx context.Context) ([]string, error)
- func NewArcBootedFixture(fOpts chrome.OptionsCallback) testing.FixtureImpl
- func NewArcBootedWithConfigFixture(fOpts chrome.OptionsCallback, arcvmConfig string) testing.FixtureImpl
- func NewArcBootedWithParentChromeFixture() testing.FixtureImpl
- func NewArcBootedWithPlayStoreFixture(fOpts chrome.OptionsCallback) testing.FixtureImpl
- func NewArcBootedWithoutUIAutomatorFixture(fOpts chrome.OptionsCallback) testing.FixtureImpl
- func NewMtbfArcBootedFixture(fOpts chrome.OptionsCallback) testing.FixtureImpl
- func NewPrecondition(name string, gaia *GaiaVars, gaiaPool *GaiaLoginPoolVars, oDirect bool, ...) testing.Precondition
- func OpenPlayStoreAccountSettings(ctx context.Context, arcDevice *androidui.Device, tconn *chrome.TestConn) error
- func PkgDataDir(ctx context.Context, user, pkg string) (string, error)
- func PkgFileSize(ctx context.Context, user, pkg, filename string) (int64, error)
- func RegexpPred(exp *regexp.Regexp) func(string) bool
- func RestoreArcvmDevConf(ctx context.Context) error
- func SDCardVolumeID(ctx context.Context, a *ARC) (string, error)
- func SDKVersion() (int, error)
- func Supported() bool
- func SwitchPlayStoreAccount(ctx context.Context, arcDevice *androidui.Device, tconn *chrome.TestConn, ...) error
- func UnblockOutbound(ctx context.Context) error
- func Unlock()
- func VMEnabled() (bool, error)
- func WaitAndroidInit(ctx context.Context, reader *syslog.Reader) error
- func WaitForARCMyFilesVolumeMount(ctx context.Context, a *ARC) error
- func WaitForARCMyFilesVolumeMountIfARCVMEnabled(ctx context.Context, a *ARC) error
- func WaitForARCMyFilesVolumeUnmount(ctx context.Context, a *ARC) error
- func WaitForARCRemovableMediaVolumeMount(ctx context.Context, a *ARC) error
- func WaitForARCRemovableMediaVolumeUnmount(ctx context.Context, a *ARC) error
- func WaitForARCSDCardVolumeMount(ctx context.Context, a *ARC) error
- func WaitForARCSDCardVolumeUnmount(ctx context.Context, a *ARC) error
- func WriteArcvmDevConf(ctx context.Context, text string) error
- type ARC
- func (a *ARC) BroadcastIntent(ctx context.Context, action string, params ...string) (*adb.BroadcastResult, error)
- func (a *ARC) BroadcastIntentGetData(ctx context.Context, action string, params ...string) (string, error)
- func (a *ARC) BugReport(ctx context.Context, path string) error
- func (a *ARC) Close(ctx context.Context) error
- func (a *ARC) Command(ctx context.Context, name string, args ...string) *testexec.Cmd
- func (a *ARC) DumpUIHierarchyOnError(ctx context.Context, outDir string, hasError func() bool) error
- func (a *ARC) FileSize(ctx context.Context, filename string) (int64, error)
- func (a *ARC) GetProp(ctx context.Context, key string) (string, error)
- func (a *ARC) Install(ctx context.Context, path string, installOptions ...adb.InstallOption) error
- func (a *ARC) InstallMultiple(ctx context.Context, apks []string, installOptions ...adb.InstallOption) error
- func (a *ARC) InstalledPackages(ctx context.Context) (map[string]struct{}, error)
- func (a *ARC) IsConnected(ctx context.Context) error
- func (a *ARC) NewUIDevice(ctx context.Context) (*ui.Device, error)
- func (a *ARC) PackageInstalled(ctx context.Context, pkg string) (bool, error)
- func (a *ARC) PullFile(ctx context.Context, src, dst string) error
- func (a *ARC) PushFile(ctx context.Context, src, dst string) error
- func (a *ARC) PushFileToTmpDir(ctx context.Context, src string) (string, error)
- func (a *ARC) ReadFile(ctx context.Context, filename string) ([]byte, error)
- func (a *ARC) RemoveAll(ctx context.Context, path string) error
- func (a *ARC) RemoveReverseTCP(ctx context.Context, androidPort int) error
- func (a *ARC) ResetOutDir(ctx context.Context, outDir string) error
- func (a *ARC) ReverseTCP(ctx context.Context, hostPort int) (int, error)
- func (a *ARC) SaveLogFiles(ctx context.Context) error
- func (a *ARC) SendIntentCommand(ctx context.Context, action, data string) *testexec.Cmd
- func (a *ARC) SurfaceFlingerLatencyCommand(ctx context.Context, surfaceViewName string) *testexec.Cmd
- func (a *ARC) TaskInfosFromDumpsys(ctx context.Context) ([]TaskInfo, error)
- func (a *ARC) TempDir(ctx context.Context) (string, error)
- func (a *ARC) Uninstall(ctx context.Context, pkg string) error
- func (a *ARC) WaitForLogcat(ctx context.Context, pred func(string) bool, quitFunc ...func() bool) error
- func (a *ARC) WaitForPackages(ctx context.Context, packages []string) error
- func (a *ARC) WaitIntentHelper(ctx context.Context) error
- func (a *ARC) WriteFile(ctx context.Context, filename string, data []byte) error
- type Activity
- func (ac *Activity) ActivityName() string
- func (ac *Activity) CaptionHeight(ctx context.Context) (int, error)
- func (ac *Activity) Close()
- func (ac *Activity) DisplayDensity(ctx context.Context) (float64, error)
- func (ac *Activity) DisplaySize(ctx context.Context) (s coords.Size, err error)
- func (ac *Activity) Focus(ctx context.Context, tconn *chrome.TestConn) error
- func (ac *Activity) Focused(ctx context.Context) (bool, error)
- func (ac *Activity) GetWindowState(ctx context.Context) (WindowState, error)
- func (ac *Activity) IsRunning(ctx context.Context) (bool, error)
- func (ac *Activity) MoveWindow(ctx context.Context, tconn *chrome.TestConn, t time.Duration, ...) error
- func (ac *Activity) PackageName() string
- func (ac *Activity) PackageResizable(ctx context.Context) (bool, error)
- func (ac *Activity) Resizable(ctx context.Context) (bool, error)
- func (ac *Activity) ResizeWindow(ctx context.Context, tconn *chrome.TestConn, border BorderType, ...) error
- func (ac *Activity) SetWindowState(ctx context.Context, tconn *chrome.TestConn, state WindowState) error
- func (ac *Activity) Start(ctx context.Context, tconn *chrome.TestConn, opts ...ActivityStartOption) error
- func (ac *Activity) StartWithDefaultOptions(ctx context.Context, tconn *chrome.TestConn) error
- func (ac *Activity) Stop(ctx context.Context, tconn *chrome.TestConn) error
- func (ac *Activity) SurfaceBounds(ctx context.Context) (coords.Rect, error)
- func (ac *Activity) WaitForFinished(ctx context.Context, timeout time.Duration) error
- func (ac *Activity) WindowBounds(ctx context.Context) (coords.Rect, error)
- type ActivityInfo
- type ActivityStartOption
- func WithActivityType(activityType ActivityType) ActivityStartOption
- func WithDataURI(dataURI string) ActivityStartOption
- func WithDisplayID(dispID int) ActivityStartOption
- func WithEnableDebugging() ActivityStartOption
- func WithEnableNativeDebugging() ActivityStartOption
- func WithExtraBool(key string, val bool) ActivityStartOption
- func WithExtraInt(key string, val int) ActivityStartOption
- func WithExtraIntUint64(key string, val uint64) ActivityStartOption
- func WithExtraString(key, val string) ActivityStartOption
- func WithExtraStringArray(key string, vals []string) ActivityStartOption
- func WithForceStop() ActivityStartOption
- func WithIntentAction(intentAction string) ActivityStartOption
- func WithUser(user string) ActivityStartOption
- func WithWaitForLaunch() ActivityStartOption
- func WithWindowingMode(windowingMode WindowingMode) ActivityStartOption
- type ActivityType
- type BorderType
- type Display
- func (d *Display) CaptionHeight(ctx context.Context) (h int, err error)
- func (d *Display) Close()
- func (d *Display) OverrideDensityDPI(ctx context.Context) (dpi int, err error)
- func (d *Display) PhysicalDensity(ctx context.Context) (density float64, err error)
- func (d *Display) Size(ctx context.Context) (s coords.Size, err error)
- type DisplayType
- type GaiaLoginPoolVars
- type GaiaVars
- type InstallType
- type PreData
- type Snapshot
- type State
- type TaskInfo
- type WindowState
- type WindowingMode
Constants ¶
const ( // BorderTop is the top border. BorderTop BorderType = 1 << 0 // BorderBottom is the bottom border. BorderBottom = 1 << 1 // BorderLeft is the left border. BorderLeft = 1 << 2 // BorderRight is the right border. BorderRight = 1 << 3 // BorderTopLeft is the top-left corner. BorderTopLeft = (BorderTop | BorderLeft) // BorderTopRight is the top-right corner. BorderTopRight = (BorderTop | BorderRight) // BorderBottomLeft is the bottom-left corner. BorderBottomLeft = (BorderBottom | BorderLeft) // BorderBottomRight is the bottom-right corner. BorderBottomRight = (BorderBottom | BorderRight) )
const ( // BootTimeout is the maximum amount of time that ARC is expected to take to boot. // Tests that call New should declare a timeout that's at least this long. BootTimeout = 120 * time.Second //ARCPath is the path where the container images are installed in the rootfs. ARCPath = "/opt/google/containers/android" //ARCVMPath is the pather where the VM images are installed in the rootfs. ARCVMPath = "/opt/google/vms/android" )
const ( // DefaultDisplayID represents the display ID for the internal display. DefaultDisplayID = 0 // CaptionHeightR represents the caption height in ChromeDP which is defined in ArcSystemUIConstants. // TODO: Replace hard code caption height by getting from ash. CaptionHeightR = 32 // DefaultDensityDPI is equal to DisplayMetrics#DENSITY_DEFAULT, and corresponds to a density of 1.0. // See: https://developer.android.com/reference/android/util/DisplayMetrics#DENSITY_DEFAULT DefaultDensityDPI = 160 )
const ( // VethPrefix is a prefix for host veth interfaces name. VethPrefix = "veth_" // BridgePrefix is a prefix for host bridge interfaces name. BridgePrefix = "arc_" // VmtapPrefix is a prefix for host vmtap interfaces name. VmtapPrefix = "vmtap" // ARCBR0 refers to a host network bridge interface named arcbr0. ARCBR0 = "arcbr0" // ARC0 refers to an ARC network interface named arc0. ARC0 = "arc0" // ARC1 refers to an ARC network interface named arc1 which is created for ARCVM. // On dual-boards, ARC++ might have this interface as a result of switching ARCVM -> ARC++. // ARC++ should not care about this interface. ARC1 = "arc1" // Loopback refers to loopback interface named lo. Loopback = "lo" )
const ( // SDKN is the SDK version of Android N. SDKN = 25 // SDKP is the SDK version of Android P. SDKP = 28 // SDKQ is the SDK version of Android Q. SDKQ = 29 // SDKR is the SDK version of Android R. SDKR = 30 // SDKS is the SDK version of Android S v2, which is the S version of ARC. SDKS = 32 )
const ( // RemovableMediaUUID is the (fake) UUID of the removable media volume for // testing. It is defined in // Chromium's components/arc/volume_mounter/arc_volume_mounter_bridge.cc. RemovableMediaUUID = "00000000000000000000000000000000DEADBEEF" // MyFilesUUID is the UUID of the ARC MyFiles volume. It is defined in // Chromium's components/arc/volume_mounter/arc_volume_mounter_bridge.cc. MyFilesUUID = "0000000000000000000000000000CAFEF00D2019" // VolumeProviderContentURIPrefix is the prefix of the URIs of files served by // ArcVolumeProvider. VolumeProviderContentURIPrefix = "content://org.chromium.arc.volumeprovider/" )
const PostTestTimeout = resetTimeout + 20*time.Second
PostTestTimeout is the timeout duration to save logs after each test. It's intentionally set longer than resetTimeout because dumping 'dumpsys' takes around 20 seconds.
const TestBinaryDirPath = "/usr/local/libexec/arc-binary-tests"
TestBinaryDirPath is the directory to store test binaries which run inside ARC.
Variables ¶
This section is empty.
Functions ¶
func AndroidDataDir ¶
AndroidDataDir returns the ChromeOS path from which /data/ can be accessed (/home/root/${USER_HASH}/android-data).
func AppendToArcvmDevConf ¶
AppendToArcvmDevConf appends the string to the arcvm_dev.conf on ARCVM devices. Useful for modifying crosvm flags. Backs up the original content to arcvm_dev.conf.tast-backup which should later be restored with RestoreArcvmDevConf. Care should be taken to only write or append to the config once during a test run (either from the test itself or from the fixture) to avoid overwriting the backup config file.
func BlockOutbound ¶
BlockOutbound blocks all outbound traffic from ARC.
func Booted ¶
func Booted() testing.Precondition
Booted returns a precondition that ARC Container has already booted when a test is run.
When adding a test, the testing.Test.Pre field may be set to the value returned by this function. Later, in the main test function, the value returned by testing.State.PreValue may be converted to a PreData containing already-initialized chrome.Chrome and ARC objects:
func DoSomething(ctx context.Context, s *testing.State) { d := s.PreValue().(arc.PreData) conn, err := d.Chrome.NewConn(ctx, "http://www.example.org/") ... cmd := d.ARC.Command(ctx, "dumpsys", "window", "displays") ... }
When using this precondition, tests cannot call New or chrome.New. The Chrome and ARC instances are also shared and cannot be closed by tests.
func BootstrapCommand ¶
BootstrapCommand runs a command with android-sh.
It is very rare you want to call this function from your test; call Command instead. A valid use case would to run commands in the Android mini container, to set up adb, etc.
This function should be called only after WaitAndroidInit returns successfully. Please keep in mind that command execution environment of android-sh is not exactly the same as the actual Android container.
func CheckNoDex2Oat ¶
CheckNoDex2Oat verifies whether ARC is pre-optimized and no dex2oat was previously running in the background.
func ClickAddAccountInSettings ¶
func ClickAddAccountInSettings(ctx context.Context, arcDevice *androidui.Device, tconn *chrome.TestConn) error
ClickAddAccountInSettings clicks Add account > Google in ARC Settings. Settings window should be already open.
func DisableSyncFlags ¶
func DisableSyncFlags() []string
DisableSyncFlags is the default flags for disabling ARC content sync and background activities when using GAIA accounts. --arc-disable-app-sync - prevents syncing installed apps from the previous sessions. --arc-disable-play-auto-install - disables PAI flow that downloads and installs apps in the background. --arc-play-store-auto-update=off - prevents Play Store and GMS Core from third party app update and prevents self-updates and downloadable content. --arc-disable-locale-sync - don’t propagate locale sync for the account that might cause reconfiguration updates. --arc-disable-media-store-maintenance - disables GMS scheduling of media store periodic indexing and corpora maintenance tasks.
func FirstDisplayIDByType ¶
FirstDisplayIDByType returns first ARC display id for specific display type.
func InitExists ¶
InitExists returns true in case ARC init process exists.
func InitPID ¶
InitPID returns the PID (outside the guest) of the ARC init process. It returns an error in case process is not found.
func Lock ¶
func Lock()
Lock sets a flag that makes New and Close fail unconditionally. Preconditions and fixtures should call this function on setup to prevent tests from invalidating an ARC object by a mistake.
func MyFilesVolumeID ¶
MyFilesVolumeID returns the volume ID of the MyFiles volume. It waits for the volume to be mounted if it is not mounted yet.
func NetworkInterfaceNames ¶
NetworkInterfaceNames filters Android interfaces and returns ARC related network interfaces.
func NewArcBootedFixture ¶
func NewArcBootedFixture(fOpts chrome.OptionsCallback) testing.FixtureImpl
NewArcBootedFixture returns a FixtureImpl with a OptionsCallback function provided. ARCEnabled() will always be added to the Chrome options returned by OptionsCallback.
func NewArcBootedWithConfigFixture ¶
func NewArcBootedWithConfigFixture(fOpts chrome.OptionsCallback, arcvmConfig string) testing.FixtureImpl
NewArcBootedWithConfigFixture returns a FixtureImpl with a OptionsCallback function provided and the specified config appended to arcvm_dev.conf. ARCEnabled() will always be added to the Chrome options returned by OptionsCallback.
func NewArcBootedWithParentChromeFixture ¶
func NewArcBootedWithParentChromeFixture() testing.FixtureImpl
NewArcBootedWithParentChromeFixture returns a FixtureImpl that gets Chrome from a parent fixture.
func NewArcBootedWithPlayStoreFixture ¶
func NewArcBootedWithPlayStoreFixture(fOpts chrome.OptionsCallback) testing.FixtureImpl
NewArcBootedWithPlayStoreFixture returns a FixtureImpl with a OptionsCallback function provided. ARCSupported() will always be added to the Chrome options returned by OptionsCallback.
func NewArcBootedWithoutUIAutomatorFixture ¶
func NewArcBootedWithoutUIAutomatorFixture(fOpts chrome.OptionsCallback) testing.FixtureImpl
NewArcBootedWithoutUIAutomatorFixture is same as NewArcBootedFixture but does not install UIAutomator by default.
func NewMtbfArcBootedFixture ¶
func NewMtbfArcBootedFixture(fOpts chrome.OptionsCallback) testing.FixtureImpl
NewMtbfArcBootedFixture returns a FixtureImpl with a OptionsCallback function provided for MTBF ARC++ tests.
func NewPrecondition ¶
func NewPrecondition(name string, gaia *GaiaVars, gaiaPool *GaiaLoginPoolVars, oDirect bool, extraArgs ...string) testing.Precondition
NewPrecondition creates a new arc precondition for tests that need different args.
func OpenPlayStoreAccountSettings ¶
func OpenPlayStoreAccountSettings(ctx context.Context, arcDevice *androidui.Device, tconn *chrome.TestConn) error
OpenPlayStoreAccountSettings opens account settings in PlayStore where user can switch between available accounts.
func PkgDataDir ¶
PkgDataDir returns the ChromeOS path of the directory that contains user files of a given Android package (/home/root/${USER_HASH}/android-data/data/media/0/Android/data/${PKG}).
func PkgFileSize ¶
PkgFileSize returns the size of a specified file that belongs to a specified Android package in bytes. Returns an error if the file does not exist.
func RegexpPred ¶
RegexpPred returns a function to be passed to WaitForLogcat that returns true if a given regexp is matched in that line.
func RestoreArcvmDevConf ¶
RestoreArcvmDevConf restores the original arcvm_dev.conf from the backup copy set aside by WriteArcvmDevConf.
func SDCardVolumeID ¶
SDCardVolumeID returns the volume ID of the sdcard volume (/storage/emulated/0). Although the volume ID itself is a constant, the function waits for the volume to be mounted if it is not mounted yet, so that the ID is guaranteed to be valid and usable inside ARC.
func SDKVersion ¶
SDKVersion returns the ARC's Android SDK version for the current ARC image installed into the DUT.
func Supported ¶
func Supported() bool
Supported returns true if ARC is supported on the board.
This function must not be used to skip tests entirely; declare the "android_p" software dependency instead. A valid use case would be to change the test expectation by whether ARC is supported or not (e.g. existence of mount points).
func SwitchPlayStoreAccount ¶
func SwitchPlayStoreAccount(ctx context.Context, arcDevice *androidui.Device, tconn *chrome.TestConn, accountEmail string) error
SwitchPlayStoreAccount switches between the ARC account in PlayStore.
func UnblockOutbound ¶
UnblockOutbound unblocks all outbound traffic from ARC.
func WaitAndroidInit ¶
WaitAndroidInit waits for Android init process to start.
It is very rare you want to call this function from your test; to wait for the Android system to start and become ready, call New instead. A valid use case is when you want to interact with Android mini container.
It is fine to call BootstrapCommand after this function successfully returns.
func WaitForARCMyFilesVolumeMount ¶
WaitForARCMyFilesVolumeMount waits for the MyFiles volume to be mounted inside ARC.
func WaitForARCMyFilesVolumeMountIfARCVMEnabled ¶
WaitForARCMyFilesVolumeMountIfARCVMEnabled waits for the MyFiles volume to be mounted inside ARC only if ARCVM is enabled. Otherwise it just returns nil. This can be used in tests that write to or read from ARC's Download folder, because Downloads integraion in ARCVM depends on MyFiles mount.
func WaitForARCMyFilesVolumeUnmount ¶
WaitForARCMyFilesVolumeUnmount waits for the MyFiles volume to be unmounted inside ARC.
func WaitForARCRemovableMediaVolumeMount ¶
WaitForARCRemovableMediaVolumeMount waits for the removable media volume for testing to be mounted inside ARC.
func WaitForARCRemovableMediaVolumeUnmount ¶
WaitForARCRemovableMediaVolumeUnmount waits for the removable media volume for testing to be unmounted inside ARC.
func WaitForARCSDCardVolumeMount ¶
WaitForARCSDCardVolumeMount waits for the sdcard volume to be mounted inside ARC.
func WaitForARCSDCardVolumeUnmount ¶
WaitForARCSDCardVolumeUnmount waits for the sdcard volume to be unmounted inside ARC.
func WriteArcvmDevConf ¶
WriteArcvmDevConf writes string to arcvm_dev.conf on ARCVM devices. Useful for modifying flags for crosvm start up. Backs up original content to arcvm_dev.conf.tast-backup which should later be restored with RestoreArcvmDevConf. Care should be taken to only write or append to the config once during a test run (either from the test itself or from the fixture) to avoid overwriting the backup config file.
Types ¶
type ARC ¶
type ARC struct {
// contains filtered or unexported fields
}
ARC holds resources related to an active ARC session. Call Close to release those resources.
func New ¶
New waits for Android to finish booting.
ARC must be enabled in advance by passing chrome.ARCEnabled or chrome.ARCSupported with real user gaia login to chrome.New.
After this function returns successfully, you can assume BOOT_COMPLETED intent has been broadcast from Android system, and ADB connection is ready. Note that this does not necessarily mean all ARC mojo services are up; call WaitIntentHelper() to wait for ArcIntentHelper to be ready, for example.
The returned ARC instance must be closed when the test is finished.
func NewWithSyslogReader ¶
NewWithSyslogReader waits for Android to finish booting.
Give a syslog.Reader instantiated before chrome.New to allow diagnosing init failure.
func NewWithTimeout ¶
NewWithTimeout waits for Android to finish booting until timeout expires.
ARC must be enabled in advance by passing chrome.ARCEnabled or chrome.ARCSupported with real user gaia login to chrome.New.
After this function returns successfully, you can assume BOOT_COMPLETED intent has been broadcast from Android system, and ADB connection is ready. Note that this does not necessarily mean all ARC mojo services are up; call WaitIntentHelper() to wait for ArcIntentHelper to be ready, for example.
The returned ARC instance must be closed when the test is finished.
func (*ARC) BroadcastIntent ¶
func (a *ARC) BroadcastIntent(ctx context.Context, action string, params ...string) (*adb.BroadcastResult, error)
BroadcastIntent broadcasts an intent with "am broadcast" and returns the result.
func (*ARC) BroadcastIntentGetData ¶
func (a *ARC) BroadcastIntentGetData(ctx context.Context, action string, params ...string) (string, error)
BroadcastIntentGetData broadcasts an intent with "am broadcast" and returns the result data.
func (*ARC) Close ¶
Close releases testing-related resources associated with ARC. ARC itself is not stopped.
func (*ARC) DumpUIHierarchyOnError ¶
func (a *ARC) DumpUIHierarchyOnError(ctx context.Context, outDir string, hasError func() bool) error
DumpUIHierarchyOnError dumps arc UI hierarchy to 'arc_uidump.xml', when the test fails. Call this function after closing arc UI devices. Otherwise the uiautomator might exist with errors like status 137.
func (*ARC) FileSize ¶
FileSize returns the size of the specified file in bytes. Returns an error if the file does not exist. Note: In contrast to PkgFileSize, FileSize accesses files via adb commands.
func (*ARC) Install ¶
Install installs an APK file to the Android system. By default, it uses InstallOptionReplaceApp and InstallOptionAllowVersionDowngrade.
func (*ARC) InstallMultiple ¶
func (a *ARC) InstallMultiple(ctx context.Context, apks []string, installOptions ...adb.InstallOption) error
InstallMultiple installs a split APK to the Android system. By default, it uses InstallOptionReplaceApp and InstallOptionAllowVersionDowngrade.
func (*ARC) InstalledPackages ¶
InstalledPackages returns a set of currently-installed packages, e.g. "android". This operation is slow (700+ ms), so unnecessary calls should be avoided.
func (*ARC) IsConnected ¶
IsConnected checks if ARC is connected through ADB.
func (*ARC) NewUIDevice ¶
NewUIDevice creates a Device object by starting and connecting to UI Automator server. Close must be called to clean up resources when a test is over.
func (*ARC) PackageInstalled ¶
PackageInstalled returns true if the given package has been installed.
func (*ARC) PushFileToTmpDir ¶
PushFileToTmpDir copies a file in Chrome OS to Android temp directory. The destination path within the ARC container is returned.
func (*ARC) RemoveAll ¶
RemoveAll removes all files and directories under the path in Android. The path must be abspath.
func (*ARC) RemoveReverseTCP ¶
RemoveReverseTCP removes the forwarding from a host port to the specified ADB device local port.
func (*ARC) ResetOutDir ¶
ResetOutDir updates the outDir field of ARC object.
func (*ARC) ReverseTCP ¶
ReverseTCP forwards the host port to an ADB device local port and returns that ADB device port.
func (*ARC) SaveLogFiles ¶
SaveLogFiles writes log files to the a.outDir directory and clears the a.outDir.
func (*ARC) SendIntentCommand ¶
SendIntentCommand returns a Cmd to send an intent with "am start" command.
func (*ARC) SurfaceFlingerLatencyCommand ¶
func (a *ARC) SurfaceFlingerLatencyCommand(ctx context.Context, surfaceViewName string) *testexec.Cmd
SurfaceFlingerLatencyCommand returns a command specifically for calling the SurfaceFlinger command to obtain latencies, via adb. For this particular command, the shutil.EscapeSlice function is inappropriate, because the extra quotation marks added are incompatible with the command.
func (*ARC) TaskInfosFromDumpsys ¶
TaskInfosFromDumpsys returns a list of all available TaskInfo from the "dumpsys activity activities" and "dumpsys Wayland" if needed.
func (*ARC) TempDir ¶
TempDir creates a temporary directory under AndroidTmpDirPath in Android, then returns its absolute path. It is caller's responsibility to remove all the contents in the directory after its use. One of the typical use cases will be as follows:
tmpdir, err := a.MktempDir(ctx) if err != nil { ... // error handling } defer a.RemoveAll(tmpdir) ... // Main code using tmpdir.
func (*ARC) WaitForLogcat ¶
func (a *ARC) WaitForLogcat(ctx context.Context, pred func(string) bool, quitFunc ...func() bool) error
WaitForLogcat keeps scanning logcat. The function pred is called on the logcat contents line by line. This function returns successfully if pred returns true. If pred never returns true, this function returns an error as soon as the context is done. An optional quitFunc will be polled at regular interval, which can be used to break early if for example the activity which is supposed to print the exp has crashed
func (*ARC) WaitForPackages ¶
WaitForPackages waits for Android packages being installed.
func (*ARC) WaitIntentHelper ¶
WaitIntentHelper waits for ArcIntentHelper to get ready.
type Activity ¶
type Activity struct {
// contains filtered or unexported fields
}
Activity holds resources associated with an ARC activity.
func NewActivity ¶
NewActivity returns a new Activity instance. The caller is responsible for closing a. Returned Activity instance must be closed when the test is finished.
func NewActivityOnDisplay ¶
NewActivityOnDisplay returns a new Activity instance on specific display. The caller is responsible for closing a. Returned Activity instance must be closed when the test is finished.
func (*Activity) ActivityName ¶
ActivityName returns the activity name.
func (*Activity) CaptionHeight ¶
CaptionHeight returns the caption height of the activity.
func (*Activity) Close ¶
func (ac *Activity) Close()
Close closes the resources associated with the Activity instance. Calling Close() does not stop the activity.
func (*Activity) DisplayDensity ¶
DisplayDensity returns the density of activity's physical display.
func (*Activity) DisplaySize ¶
DisplaySize returns the size of display associated with the activity.
func (*Activity) Focused ¶
Focused returns whether the app's window has focus or not. Only works on ARC++ R and later.
func (*Activity) GetWindowState ¶
func (ac *Activity) GetWindowState(ctx context.Context) (WindowState, error)
GetWindowState returns the window state.
func (*Activity) MoveWindow ¶
func (ac *Activity) MoveWindow(ctx context.Context, tconn *chrome.TestConn, t time.Duration, toBounds, fromBounds coords.Rect) error
MoveWindow moves the activity's window to a new location. t represents the duration of the movement. toBounds represent the destination bounds (in px). fromBounds represent the source bounds (in px).
func (*Activity) PackageName ¶
PackageName returns the activity package name.
func (*Activity) PackageResizable ¶
PackageResizable returns the window resizability of an app package name.
func (*Activity) ResizeWindow ¶
func (ac *Activity) ResizeWindow(ctx context.Context, tconn *chrome.TestConn, border BorderType, to coords.Point, t time.Duration) error
ResizeWindow resizes the activity's window. border represents from where the resize should start. to represents the coordinates for for the new border's position, in pixels. t represents the duration of the resize. ResizeWindow only works with WindowStateNormal and WindowStatePIP windows. Will fail otherwise. For PiP windows, they must have the PiP Menu Activity displayed. Will fail otherwise.
func (*Activity) SetWindowState ¶
func (ac *Activity) SetWindowState(ctx context.Context, tconn *chrome.TestConn, state WindowState) error
SetWindowState sets the window state. Note this method is async, so ensure to call ash.WaitForArcAppWindowState after this. Supported states: WindowStateNormal, WindowStateMaximized, WindowStateFullscreen, WindowStateMinimized
func (*Activity) Start ¶
func (ac *Activity) Start(ctx context.Context, tconn *chrome.TestConn, opts ...ActivityStartOption) error
Start starts the activity by invoking "am start". Activity start options can be passed in to affect with arguments that are run with the command.
func (*Activity) StartWithDefaultOptions ¶
StartWithDefaultOptions starts the activity by invoking "am start" with default options passed.
func (*Activity) Stop ¶
Stop stops the activity by invoking "am force-stop" with the package name. If there are multiple activities that belong to the same package name, all of them will be stopped.
func (*Activity) SurfaceBounds ¶
SurfaceBounds returns the surface bounds in pixels. A surface represents the buffer used to store the window content. This is the buffer used by SurfaceFlinger and Wayland. The surface bounds might be smaller than the window bounds since the surface does not include the caption. And does not include the shelf size if the activity is fullscreen/maximized and the shelf is in "always show" mode. See: WindowBounds
func (*Activity) WaitForFinished ¶
WaitForFinished waits till all the activities beloninging to this task are inactive. Active means anywhere between activity launched and activity shut down in the activity lifecycle. This function cannot tell if the activity was launched at all.
Activity lifecycle: https://developer.android.com/guide/components/activities/activity-lifecycle#alc
func (*Activity) WindowBounds ¶
WindowBounds returns the window bounding box of the activity in pixels. The caption bounds, in case it is present, is included as part of the window bounds. This is the same size as the one reported by Chrome/Aura. See: SurfaceBounds
type ActivityInfo ¶
type ActivityInfo struct { // PackageName is the package name. PackageName string // ActivityName is the name of the activity. ActivityName string }
ActivityInfo contains the information found in ActivityRecord
type ActivityStartOption ¶
type ActivityStartOption func(*activityStartCmdBuilder)
ActivityStartOption is a function that sets a start command flag on a start command builder passed to it.
func WithActivityType ¶
func WithActivityType(activityType ActivityType) ActivityStartOption
WithActivityType sets the activity type of the activity.
func WithDataURI ¶
func WithDataURI(dataURI string) ActivityStartOption
WithDataURI sets a data URI where data can be written to about the activity.
func WithDisplayID ¶
func WithDisplayID(dispID int) ActivityStartOption
WithDisplayID sets the display ID for the activity.
func WithEnableDebugging ¶
func WithEnableDebugging() ActivityStartOption
WithEnableDebugging enables debugging for an activity.
func WithEnableNativeDebugging ¶
func WithEnableNativeDebugging() ActivityStartOption
WithEnableNativeDebugging enables native debugging for an activity.
func WithExtraBool ¶
func WithExtraBool(key string, val bool) ActivityStartOption
WithExtraBool adds an extra bool to the activity which can provide extra information.
func WithExtraInt ¶
func WithExtraInt(key string, val int) ActivityStartOption
WithExtraInt adds an extra int to the activity which can provide extra information.
func WithExtraIntUint64 ¶
func WithExtraIntUint64(key string, val uint64) ActivityStartOption
WithExtraIntUint64 adds an extra unint64 value converted to an int (since the activity manager can only hand signed 64-bit ints anyway) to the activity.
func WithExtraString ¶
func WithExtraString(key, val string) ActivityStartOption
WithExtraString adds an extra string to the activity which can provide extra information.
func WithExtraStringArray ¶
func WithExtraStringArray(key string, vals []string) ActivityStartOption
WithExtraStringArray adds an extra string array to the activity which can provide extra information.
func WithForceStop ¶
func WithForceStop() ActivityStartOption
WithForceStop forces an activity to stop before a new one of the same name is started.
func WithIntentAction ¶
func WithIntentAction(intentAction string) ActivityStartOption
WithIntentAction sets an intent action for this activity.
func WithUser ¶
func WithUser(user string) ActivityStartOption
WithUser sets the user of the activity.
func WithWaitForLaunch ¶
func WithWaitForLaunch() ActivityStartOption
WithWaitForLaunch waits for the launch of the activity before ending am process.
func WithWindowingMode ¶
func WithWindowingMode(windowingMode WindowingMode) ActivityStartOption
WithWindowingMode sets the windowing mode of the activity.
type ActivityType ¶
type ActivityType int
ActivityType is an enum that changes how the activity is presented upon starting.
const ( ActivityTypeUndefined ActivityType = 0 ActivityTypeStandard ActivityType = 1 ActivityTypeHome ActivityType = 2 ActivityTypeRecents ActivityType = 3 ActivityTypeAssistant ActivityType = 4 ActivityTypeDream ActivityType = 5 )
Constants taken from WindowConfiguration.java. See: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/app/WindowConfiguration.java;l=133;drc=6d5082d3a593d34b413067a3cc30069aa2b78818
type BorderType ¶
type BorderType uint
BorderType represents the 8 different border types that a window can have.
type Display ¶
type Display struct { DisplayID int // contains filtered or unexported fields }
Display holds resources related to an ARC display. For the moment only the default display (internal display) is supported.
func NewDisplay ¶
NewDisplay returns a new Display instance. The caller is responsible for closing a. Returned Display instance must be closed when the test is finished.
func (*Display) CaptionHeight ¶
CaptionHeight returns the caption height in pixels.
func (*Display) Close ¶
func (d *Display) Close()
Close closes resources related to the Display instance.
func (*Display) OverrideDensityDPI ¶
OverrideDensityDPI returns the density DPI used by the Android framework for the display. Only works on Android R and later.
func (*Display) PhysicalDensity ¶
PhysicalDensity returns the density value in PhysicalDisplayInfo.
type DisplayType ¶
type DisplayType string
DisplayType represents corresponding ARC display type string from dumpsys display.
const ( // Internal display. InternalDisplay DisplayType = "INTERNAL" // Virtual display. VirtualDisplay DisplayType = "VIRTUAL" // External display. ExternalDisplay DisplayType = "EXTERNAL" )
DisplayType available on R and above versions.
type GaiaLoginPoolVars ¶
type GaiaLoginPoolVars struct {
PoolVar string // the secret variable for the GAIA pool
}
GaiaLoginPoolVars holds the secret variable for a GAIA POOL.
type GaiaVars ¶
type GaiaVars struct { UserVar string // the secret variable for the GAIA username PassVar string // the secret variable for the GAIA password }
GaiaVars holds the secret variables for username and password for a GAIA login.
type InstallType ¶
type InstallType int
InstallType is the type of ARC (Container or VM) available on the device.
const ( // Container is for the ARC container install. Container InstallType = iota // VM is for the ARCVM install. VM )
func Type ¶
func Type() (t InstallType, ok bool)
Type detects the type (container or VM) of the ARC installation. As for Supported(), it should not be used to skip tests entirely, both fall under the "android_p" software dependency. But it could be used to change the behaviour of a test (e.g. check that ARCVM is running or not).
type PreData ¶
type PreData struct { // Chrome is a connection to an already-started Chrome instance. // It cannot be closed by tests. Chrome *chrome.Chrome // ARC enables interaction with an already-started ARC environment. // It cannot be closed by tests. ARC *ARC // UIDevice is a UI Automator device object. // It cannot be closed by tests. UIDevice *ui.Device }
PreData holds information made available to tests that specify preconditions.
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot represents a Snapshot of ARC state. Fixtures and preconditions can use a Snapshot to revert ARC state to the original one after running a test.
func NewSnapshot ¶
NewSnapshot captures an ARC state snapshot.
type State ¶
type State struct { // Provisioned indicates whether the ARC is provisioned. Provisioned bool `json:"provisioned"` // TOSNeeded indicates whether ARC Terms of Service needs to be shown. TOSNeeded bool `json:"tosNeeded"` // PreStartTime is ARC pre-start time (mini-ARC) or 0 if not pre-started. PreStartTime float64 `json:"preStartTime"` // StartTime is the ARC start time or 0 if not started. StartTime float64 `json:"startTime"` }
State holds the ARC state returned from autotestPrivate.getArcState() call.
Refer to https://chromium.googlesource.com/chromium/src/+/main/chrome/common/extensions/api/autotest_private.idl for the mapping of the fields to JavaScript.
type TaskInfo ¶
type TaskInfo struct { // ID represents the TaskRecord ID. ID int // StackID represents the stack ID. StackID int // StackSize represents how many activities are in the stack. StackSize int // Bounds represents the task bounds in pixels. Caption is not taken into account. Bounds coords.Rect // ActivityInfos is the activities in the task ActivityInfos []ActivityInfo // contains filtered or unexported fields }
TaskInfo contains the information found in TaskRecord. See: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/pie-release/services/core/java/com/android/server/am/TaskRecord.java
type WindowState ¶
type WindowState int
WindowState represents the different states a window can have.
const ( // WindowStateNormal represents the "not maximized" state, but users can maximize it if they want. WindowStateNormal WindowState = 0 // WindowStateMaximized is the maximized window state. WindowStateMaximized WindowState = 1 // WindowStateFullscreen is the fullscreen window state. WindowStateFullscreen WindowState = 2 // WindowStateMinimized is the minimized window state. WindowStateMinimized WindowState = 3 // WindowStatePrimarySnapped is the primary snapped state. WindowStatePrimarySnapped WindowState = 4 // WindowStateSecondarySnapped is the secondary snapped state. WindowStateSecondarySnapped WindowState = 5 // WindowStatePIP is the Picture-in-Picture state. WindowStatePIP WindowState = 6 )
Constants taken from WindowPositioner.java. See: http://cs/pi-arc-dev/frameworks/base/services/core/arc/java/com/android/server/am/WindowPositioner.java
func (WindowState) String ¶
func (s WindowState) String() string
String returns a human-readable string representation for type WindowState.
func (WindowState) ToAshWindowState ¶
func (s WindowState) ToAshWindowState() (ash.WindowStateType, error)
ToAshWindowState returns equivalent ash WindowStateType for the arc WindowState.
type WindowingMode ¶
type WindowingMode int
WindowingMode is an enum that changes how the window of the activity is presented.
const ( WindowingModeUndefined WindowingMode = 0 WindowingModeFullscreen WindowingMode = 1 WindowingModePinned WindowingMode = 2 WindowingModeSplitScreenPrimary WindowingMode = 3 WindowingModeSplitScreenSecondary WindowingMode = 4 WindowingModeFreeform WindowingMode = 5 WindowingModeMultiWindow WindowingMode = 6 )
Constants taken from WindowConfiguration.java. See: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/app/WindowConfiguration.java;l=93;drc=6d5082d3a593d34b413067a3cc30069aa2b78818
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package optin provides set of util functions used to control ARC provisioning.
|
Package optin provides set of util functions used to control ARC provisioning. |
Package playstore provides set of util functions used to install applications through the playstore.
|
Package playstore provides set of util functions used to install applications through the playstore. |