setup

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

Documentation

Overview

Package setup contains helpers to set up a DUT for a power test.

Index

Constants

View Source
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 AudioMode

type AudioMode int

AudioMode indicates what audio setup is needed for a test.

const (
	// Mute indicates that audio should be muted.
	Mute AudioMode = iota
	// DoNotChangeAudio indicates that audio should be left in the same state.
	DoNotChangeAudio
)

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

type CleanupCallback func(context.Context) error

CleanupCallback cleans up a single setup item.

func AdbMkdir

func AdbMkdir(ctx context.Context, a *arc.ARC, path string) (CleanupCallback, error)

AdbMkdir runs 'adb shell mkdir <path>'.

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

func DisableNetworkInterfaces(ctx context.Context, pattern *regexp.Regexp) (CleanupCallback, error)

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

func InstallApp(ctx context.Context, a *arc.ARC, apkDataPath, pkg string) (CleanupCallback, error)

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

func TurnOffNightLight(ctx context.Context, c *chrome.TestConn) (CleanupCallback, error)

TurnOffNightLight disables Night Light, and sets the schedule to 'Never' so it won't turn on half way through a test.

type DPTFMode

type DPTFMode int

DPTFMode indicates what DPTF setup is needed for a test.

const (
	// DisableDPTF indicates that dptf should be disabled.
	DisableDPTF DPTFMode = iota
	// DoNotChangeDPTF indicates that dptf should be left in the same state.
	DoNotChangeDPTF
)

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.

func (*Setup) Check

func (s *Setup) Check(ctx context.Context) error

Check checks if any Result shows a failure happened. All failures are logged, and a summary of failures is returned.

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 VNCMode

type VNCMode int

VNCMode indicates what VNC setup is needed for a test.

const (
	// DisableVNC indicates that vnc should be disabled.
	DisableVNC VNCMode = iota
	// DoNotChangeVNC indicates that vnc should be left in the same state.
	DoNotChangeVNC
)

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
)

Jump to

Keyboard shortcuts

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