Documentation
¶
Overview ¶
Package setup contains helpers to set up a DUT for a power test.
Index ¶
- Constants
- func New(name string) (*Setup, CleanupCallback)
- type AudioMode
- type BacklightMode
- type BatteryDischargeMode
- type BluetoothMode
- type CleanupCallback
- func AdbMkdir(ctx context.Context, a *arc.ARC, path string) (CleanupCallback, error)
- func DisableBluetooth(ctx context.Context) (CleanupCallback, error)
- func DisableNetworkInterface(ctx context.Context, iface string) (CleanupCallback, error)
- func DisableNetworkInterfaces(ctx context.Context, pattern *regexp.Regexp) (CleanupCallback, error)
- func DisableService(ctx context.Context, name string) (CleanupCallback, error)
- func DisableServiceIfExists(ctx context.Context, name string) (CleanupCallback, error)
- func DisableWiFiAdaptors(ctx context.Context) (CleanupCallback, error)
- func GrantAndroidPermission(ctx context.Context, a *arc.ARC, pkg, permission string) (CleanupCallback, error)
- func InstallApp(ctx context.Context, a *arc.ARC, apkDataPath, pkg string) (CleanupCallback, error)
- func MuteAudio(ctx context.Context) (CleanupCallback, error)
- func Nested(ctx context.Context, name string, nestedSetup func(s *Setup) error) (CleanupCallback, error)
- func PowerTest(ctx context.Context, c *chrome.TestConn, options PowerTestOptions) (CleanupCallback, error)
- func SetBacklightLux(ctx context.Context, lux uint) (CleanupCallback, error)
- func SetBatteryDischarge(ctx context.Context, expectedMaxCapacityDischarge float64) (CleanupCallback, error)
- func SetKeyboardBrightness(ctx context.Context, brightness uint) (CleanupCallback, error)
- func SetNightLightEnabled(ctx context.Context, c *chrome.TestConn, enabled bool) (CleanupCallback, error)
- func SetNightLightSchedule(ctx context.Context, c *chrome.TestConn, ...) (CleanupCallback, error)
- func StartActivity(ctx context.Context, tconn *chrome.TestConn, a *arc.ARC, ...) (CleanupCallback, error)
- func TurnOffNightLight(ctx context.Context, c *chrome.TestConn) (CleanupCallback, error)
- type DPTFMode
- type KbBrightnessMode
- type NightLightMode
- type PowerTestOptions
- type PowerdMode
- type Setup
- type UpdateEngineMode
- type VNCMode
- type WifiInterfacesMode
Constants ¶
const ( // NoBatteryDischarge option requests setup not to try // forcing discharge of battery NoBatteryDischarge basicBatteryDischargeMode = iota // ForceBatteryDischarge option requests setup to force // discharging battery during a test ForceBatteryDischarge )
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(name string) (*Setup, CleanupCallback)
New creates a Setup object to collect the results of setup items, and a cleanup function that should be immediately deferred to make sure cleanup callbacks are called.
Types ¶
type BacklightMode ¶
type BacklightMode int
BacklightMode indicates what backlight setup is needed for a test.
const ( // SetBacklight indicates that back light should be disabled. SetBacklight BacklightMode = iota // DoNotChangeBacklight indicates that back light should be left in the same state. DoNotChangeBacklight )
type BatteryDischargeMode ¶
type BatteryDischargeMode interface {
// contains filtered or unexported methods
}
BatteryDischargeMode what setup is needed for a test
func TryBatteryDischarge ¶
func TryBatteryDischarge(errp *error) BatteryDischargeMode
TryBatteryDischarge option requests setup to try battery discharge. If the given pointer is nil, TryBatteryDischarge returns ForceBatteryDischarge. Otherwise, the battery discharge error is omitted from the power test setup and reported through the given pointer instead.
type BluetoothMode ¶
type BluetoothMode int
BluetoothMode indicates what Bluetooth setup is needed for a test.
const ( // DisableBluetoothInterfaces indicates that bluetooth should be disabled. DisableBluetoothInterfaces BluetoothMode = iota // DoNotChangeBluetooth indicates that bluetooth should be left in the same state. DoNotChangeBluetooth )
type CleanupCallback ¶
CleanupCallback cleans up a single setup item.
func DisableBluetooth ¶
func DisableBluetooth(ctx context.Context) (CleanupCallback, error)
DisableBluetooth disables all bluetooth adapters on the DUT.
func DisableNetworkInterface ¶
func DisableNetworkInterface(ctx context.Context, iface string) (CleanupCallback, error)
DisableNetworkInterface disables a single network interface.
func DisableNetworkInterfaces ¶
DisableNetworkInterfaces disables all network interfaces whose names match a regexp.
func DisableService ¶
func DisableService(ctx context.Context, name string) (CleanupCallback, error)
DisableService stops a service if it is running.
func DisableServiceIfExists ¶
func DisableServiceIfExists(ctx context.Context, name string) (CleanupCallback, error)
DisableServiceIfExists stops a service if it is running. Unlike DisableService above, it does not return an error if the service does not exist.
func DisableWiFiAdaptors ¶
func DisableWiFiAdaptors(ctx context.Context) (CleanupCallback, error)
DisableWiFiAdaptors disables all WiFi adapters and returns a callback to re-enable them.
func GrantAndroidPermission ¶
func GrantAndroidPermission(ctx context.Context, a *arc.ARC, pkg, permission string) (CleanupCallback, error)
GrantAndroidPermission grants an Android permission to an app.
func InstallApp ¶
InstallApp installs an Android APK.
func MuteAudio ¶
func MuteAudio(ctx context.Context) (CleanupCallback, error)
MuteAudio sets volume to zero, recording, gain to zero, and mutes audio.
func Nested ¶
func Nested(ctx context.Context, name string, nestedSetup func(s *Setup) error) (CleanupCallback, error)
Nested is used by setup items that have multiple stages that need separate cleanup callbacks.
func PowerTest ¶
func PowerTest(ctx context.Context, c *chrome.TestConn, options PowerTestOptions) (CleanupCallback, error)
PowerTest configures a DUT to run a power test by disabling features that add noise, and consistently configuring components that change power draw.
func SetBacklightLux ¶
func SetBacklightLux(ctx context.Context, lux uint) (CleanupCallback, error)
SetBacklightLux sets the screen backlight to a brightness in lux.
func SetBatteryDischarge ¶
func SetBatteryDischarge(ctx context.Context, expectedMaxCapacityDischarge float64) (CleanupCallback, error)
SetBatteryDischarge forces the battery to discharge. This will fail if the remaining battery charge is lower than lowBatteryCutoff.
func SetKeyboardBrightness ¶
func SetKeyboardBrightness(ctx context.Context, brightness uint) (CleanupCallback, error)
SetKeyboardBrightness sets the keyboard brightness if there is a backlight.
func SetNightLightEnabled ¶
func SetNightLightEnabled(ctx context.Context, c *chrome.TestConn, enabled bool) (CleanupCallback, error)
SetNightLightEnabled enables or disables Night Light.
func SetNightLightSchedule ¶
func SetNightLightSchedule(ctx context.Context, c *chrome.TestConn, schedule settings.NightLightScheduleValue) (CleanupCallback, error)
SetNightLightSchedule sets the Night Light schedule. See settings.NightLightSchedule* for possible values.
func StartActivity ¶
func StartActivity(ctx context.Context, tconn *chrome.TestConn, a *arc.ARC, pkg, activityName string, opts ...arc.ActivityStartOption) (CleanupCallback, error)
StartActivity starts an Android activity.
func TurnOffNightLight ¶
TurnOffNightLight disables Night Light, and sets the schedule to 'Never' so it won't turn on half way through a test.
type KbBrightnessMode ¶
type KbBrightnessMode int
KbBrightnessMode indicates what keyboard brightness setup is needed for a test.
const ( // SetKbBrightness indicates that back light should be disabled. SetKbBrightness KbBrightnessMode = iota // DoNotChangeKbBrightness indicates that back light should be left in the same state. DoNotChangeKbBrightness )
type NightLightMode ¶
type NightLightMode int
NightLightMode what setup is needed for a test.
const ( // DoNotDisableNightLight indicates that Night Light should be left in the same state. DoNotDisableNightLight NightLightMode = iota // DisableNightLight indicates that Night Light should be disabled. DisableNightLight )
type PowerTestOptions ¶
type PowerTestOptions struct { // The default value of the following options is not to perform any changes. Battery BatteryDischargeMode Wifi WifiInterfacesMode NightLight NightLightMode // The default value of the following options is to perform the actions. Powerd PowerdMode UpdateEngine UpdateEngineMode VNC VNCMode DPTF DPTFMode Backlight BacklightMode KeyboardBrightness KbBrightnessMode Audio AudioMode Bluetooth BluetoothMode }
PowerTestOptions describes how to set up a power test.
type PowerdMode ¶
type PowerdMode int
PowerdMode indicates what powerd setup is needed for a test.
const ( // DisablePowerd indicates that powerd should be disabled. DisablePowerd PowerdMode = iota // DoNotChangePowerd indicates that powerd should be left in the same state. DoNotChangePowerd )
type Setup ¶
type Setup struct {
// contains filtered or unexported fields
}
Setup accumulates the results of setup items so that their results can be checked, errors logged, and cleaned up.
func (*Setup) Add ¶
func (s *Setup) Add(callback CleanupCallback, err error)
Add adds a result to be checked or cleaned up later.
type UpdateEngineMode ¶
type UpdateEngineMode int
UpdateEngineMode indicates what update engine setup is needed for a test.
const ( // DisableUpdateEngine indicates that update engine should be disabled. DisableUpdateEngine UpdateEngineMode = iota // DoNotChangeUpdateEngine indicates that update engine should be left in the same state. DoNotChangeUpdateEngine )
type WifiInterfacesMode ¶
type WifiInterfacesMode int
WifiInterfacesMode describes how to setup WiFi interfaces for a test.
const ( // DoNotChangeWifiInterfaces indicates that WiFi interfaces should be left in the same state. DoNotChangeWifiInterfaces WifiInterfacesMode = iota // DisableWifiInterfaces indicates that WiFi interfaces should be disabled. DisableWifiInterfaces )