Skip to content

API Utils

Tobero edited this page Mar 13, 2023 · 2 revisions

Vector2


The Vector2 class is a container for x and y coordinates. It has some methods to support math operation.

constructor(x: number, y: number)

Creates a new vector2 instance with the x and y value

add(vector: Vector2): Vector2

Adds a vector to this instance. Returns a new instance

sub(vector: Vector2): Vector2

Subtract a vector from this instance. Returns a new instance

div(value: number): Vector2

Divide the current vector by the number value. Returns a new instance with the values.

get x(): number

Get the x of this instance

get y(): number

Get y value of this instance

set x(value: number)

Set the x value for this instance

set y(value: number)

Set the y value for this instance

Bounds


constructor(minX: number, minY: number, maxX: number, maxY: number)

Creates a new bounds instance with the min x and y and max x and y values

center(): Vector2

Get the center in the bounds

get min(): Vector2

Get the min value of the bounds instance

get max(): Vector2

Get the max value of the bounds instance

DeviceTools

ExecResult

This is a interface containing stdout and stderr

exec(command: string): Promise

Runs a command in the command line as a promise and returns a ExecResult

waitForMs(ms: number): Promise

Returns a promise that completes after the given ms.

waitForCondition(condition: () => Promise, timeout: number = 200): Promise

Returns a promise that checks the condition callback in the given interval timeout. When the condition is met, the promise will resolve

waitForXPath(device: Device, expression: string, timeout: number = 1000): Promise

Waits until the device's hierarchy contains the provided xPath

waitForId(device: Device, id: string, timeout: number = 1000): Promise

Waits until the device's hierarchy contains the provided id node

waitForText(device: Device, text: string, timeout: number = 1000): Promise

Waits until the device's hierarchy contains the provided text node

waitForClass(device: Device, className: string, timeout: number = 1000): Promise

Waits until the device's hierarchy contains the provided className node