standardizedtestutil

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

Documentation

Overview

Package standardizedtestutil provides helper functions to assist with running standardized arc tests for against android applications.

Index

Constants

View Source
const (
	TrackpadMajorSize                              = 240
	TrackpadMinorSize                              = 180
	TrackpadClickPressureAsProportionOfMaxPressure = .2
	TrackpadClickDefaultPressure                   = 50
	TrackpadGesturePressure                        = 10
	TrackpadVerticalScrollAmountAsProportionOfPad  = .2
	TrackpadScrollDuration                         = 250 * time.Millisecond
	TrackpadFingerSeparation                       = 350
)

Trackpad related constants. These values were derived experimentally and should work on both physical, and virtual trackpads.

View Source
const RunTestCasesCleanupTime = 20 * time.Second

RunTestCasesCleanupTime stores the amount of time a test has to clean up between runs.

View Source
const ShortUITimeout = 30 * time.Second

ShortUITimeout stores the time a UI action has before a timeout should occur.

Variables

View Source
var ClamshellHardwareDep = hwdep.SkipOnModel(TabletOnlyModels...)

ClamshellHardwareDep returns the hardware dependencies all clamshell tests share.

View Source
var ClamshellOnlyModels = []string{
	"sarien",
	"elemi",
	"berknip",
	"dratini",

	"careena",
	"kasumi",
	"treeya",
	"grunt",
	"barla",
	"aleena",
	"liara",
	"nuwani",

	"bluebird",
	"apel",
	"blooglet",
	"blorb",
	"bobba",
	"casta",
	"dorp",
	"droid",
	"fleex",
	"foob",
	"garfour",
	"garg",
	"laser14",
	"lick",
	"mimrock",
	"nospike",
	"orbatrix",
	"phaser",
	"sparky",
}

ClamshellOnlyModels is a list of clamshell only models to be skipped from tablet mode runs.

View Source
var TabletHardwareDep = hwdep.SkipOnModel(ClamshellOnlyModels...)

TabletHardwareDep returns the hardware dependencies all tablet tests share.

View Source
var TabletOnlyModels = []string{
	"dru",
	"krane",
}

TabletOnlyModels is a list of tablet only models to be skipped from clamshell mode runs.

Functions

func ClickInputAndGuaranteeFocus

func ClickInputAndGuaranteeFocus(ctx context.Context, selector *ui.Object) error

ClickInputAndGuaranteeFocus makes sure an input exists, clicks it, and ensures it is focused.

func MouseClickObject

func MouseClickObject(ctx context.Context, testParameters TestFuncParams, selector *ui.Object, mew *input.MouseEventWriter, mouseButton PointerButton) error

MouseClickObject implements a standard way to click the mouse button on an object.

func MouseMoveOntoObject

func MouseMoveOntoObject(ctx context.Context, testParameters TestFuncParams, selector *ui.Object, mew *input.MouseEventWriter) error

MouseMoveOntoObject moves the mouse onto the center of an object.

func MouseScroll

func MouseScroll(ctx context.Context, testParameters TestFuncParams, scrollDirection ScrollDirection, mew *input.MouseEventWriter) error

MouseScroll performs a scroll on the mouse. Due to different device settings, the actual scroll amount in pixels will be imprecise. Therefore, multiple iterations should be run, with a check for the desired output between each call.

func RunResizeLockTest

func RunResizeLockTest(ctx context.Context, s *testing.State, apkName, appPkgName, appActivity string, t Test)

RunResizeLockTest runs the provided test cases with ResizeLock enabled, and handles cleanup between tests.

func RunTest

func RunTest(ctx context.Context, s *testing.State, apkName, appPkgName, appActivity string, t Test)

RunTest runs the provided test cases and handles cleanup between tests.

func StandardizedTestLayoutID

func StandardizedTestLayoutID(appPkgName string) string

StandardizedTestLayoutID returns the fully qualified path to the layout each standardized application is built with.

func TouchscreenScroll

func TouchscreenScroll(ctx context.Context, touchScreen *StandardizedTouchscreen, testParameters TestFuncParams, selector *ui.Object, scrollDirection ScrollDirection) error

TouchscreenScroll performs a scroll on the touchscreen. Due to different device settings, the actual scroll amount in pixels will be imprecise. Therefore, multiple iterations should be run, with a check for the desired output between each call.

func TouchscreenSwipe

func TouchscreenSwipe(ctx context.Context, testParameters TestFuncParams, selector *ui.Object, numTouches int, swipeDirection TouchscreenSwipeDirection) error

TouchscreenSwipe performs a swipe in a given direction, starting from the provided selector. Due to different device settings, the actual swipe distance will be imprecise but aims to be near 50 pixels.

func TouchscreenTap

func TouchscreenTap(ctx context.Context, testParameters TestFuncParams, selector *ui.Object, tapType TouchscreenTapType) error

TouchscreenTap performs a tap on the touchscreen.

func TouchscreenZoom

func TouchscreenZoom(ctx context.Context, testParameters TestFuncParams, selector *ui.Object, zoomType ZoomType) error

TouchscreenZoom performs a zoom on the touchscreen. Zoom in distance varies per device but the function aims to zoom by 2x (i.e. a scale factor of 2.0 when zooming in, or .5 when zooming out).

func TrackpadClickObject

func TrackpadClickObject(ctx context.Context, testParameters TestFuncParams, selector *ui.Object, tew *input.TrackpadEventWriter, pointerButton PointerButton) error

TrackpadClickObject implements a click on the trackpad.

func TrackpadScroll

func TrackpadScroll(ctx context.Context, trackpad *input.TrackpadEventWriter, testParameters TestFuncParams, selector *ui.Object, scrollDirection ScrollDirection) error

TrackpadScroll performs a two-finger scroll gesture on the trackpad.

func TrackpadZoom

func TrackpadZoom(ctx context.Context, trackpad *input.TrackpadEventWriter, testParameters TestFuncParams, selector *ui.Object, zoomType ZoomType) error

TrackpadZoom performs a two-finger zoom gesture on the trackpad.

Types

type PointerButton

type PointerButton int

PointerButton abstracts the underlying pointer button implementation into a standard type that can be used by callers.

const (
	LeftPointerButton PointerButton = iota
	RightPointerButton
)

Pointer buttons that can be used by tests.

type ScrollDirection

type ScrollDirection int

ScrollDirection represents the scroll direction.

const (
	DownScroll ScrollDirection = iota
	UpScroll
)

Variables used to determine the scroll direction.

type StandardizedTouchscreen

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

StandardizedTouchscreen is a wrapper around the touchscreen that hides configuration which allows the touchscreen to work on all DUTs.

func NewStandardizedTouchscreen

func NewStandardizedTouchscreen(ctx context.Context, tconn *chrome.TestConn) (*StandardizedTouchscreen, error)

NewStandardizedTouchscreen returns a touchscreen that has been configured to work on all DUTs.

func (*StandardizedTouchscreen) Close

func (ts *StandardizedTouchscreen) Close() error

Close closes the touchscreen device.

type Test

type Test struct {
	Fn           TestFunc
	InTabletMode bool
	WindowStates []WindowState
}

Test holds information about a test that should run in a given mode, over multiple window states.

func GetClamshellTest

func GetClamshellTest(fn TestFunc) Test

GetClamshellTest returns the test cases required for clamshell devices.

func GetTabletTest

func GetTabletTest(fn TestFunc) Test

GetTabletTest returns the test cases required for tablet devices.

type TestFunc

type TestFunc func(ctx context.Context, testParameters TestFuncParams) error

TestFunc represents the test function.

type TestFuncParams

type TestFuncParams struct {
	TestConn        *chrome.TestConn
	Arc             *arc.ARC
	Device          *ui.Device
	AppPkgName      string
	AppActivityName string
	Activity        *arc.Activity
}

TestFuncParams contains parameters that can be used by the tests.

type TouchscreenSwipeDirection

type TouchscreenSwipeDirection int

TouchscreenSwipeDirection represents the touchscreen swipe direction.

const (
	DownTouchscreenSwipe TouchscreenSwipeDirection = iota
	UpTouchscreenSwipe
	LeftTouchscreenSwipe
	RightTouchscreenSwipe
)

Holds all the swipe directions that can be performed on the touchscreen.

type TouchscreenTapType

type TouchscreenTapType int

TouchscreenTapType represents the touch screen tap type to perform.

const (
	ShortTouchscreenTap TouchscreenTapType = iota
	LongTouchscreenTap
)

Holds all the tap types that can be performed on the touchscreen.

type WindowState

type WindowState struct {
	Name            string
	WindowStateType ash.WindowStateType
}

WindowState holds information about a window state that should be run as part of a test.

type ZoomType

type ZoomType int

ZoomType represents the zoom type to perform.

const (
	ZoomIn ZoomType = iota
	ZoomOut
)

Holds all of the zoom types that can be performed.

Jump to

Keyboard shortcuts

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