Assistive-Webdriver

Home > vm-providers

vm-providers package

This package contains functions to clone and start a virtual machine with one of the available providers (virtualbox or qemu), to send it keyboard and mouse events and finally to destroy it. It also contains some utilities commonly used with applications that need to control a virtual machine.

Remarks

The main entry point to clone and start a virtual machine is the createVM function

Enumerations

Enumeration Description
Key Keyboard keys that can be sent to a virtual machine through VM.sendKeyDownEvent() and VM.sendKeyUpEvent().
MouseButton Mouse buttons that can be sent to a virtual machine through VM.sendMouseDownEvent() and VM.sendMouseUpEvent().

Functions

Function Description
bufferToDataURI(buffer, mediaType) Takes a buffer and returns the corresponding data URI with base64 encoding.
calibrationQRCodesGenerate(width, height, config) Creates a calibration image containing QR codes. Each QR code encodes its position inside the image, allowing to easily detect the position of the whole image by reading any of its QR codes, which can be done with calibrationQRCodesScan().
calibrationQRCodesScan(image, config) Scans an image containing a calibration image (which can be generated by calibrationQRCodesGenerate()) and returns its position and the position of the QR code that was successfully scanned.
getFreePort({ host }) Returns a free TCP port on the local IP address specified by the host parameter.
pngToBuffer(png) Takes a png image and returns a buffer.
pngToDataURI(png) Takes a png image and returns a data URI.
wait(delay) Waits for the specified delay.

Interfaces

Interface Description
CalibrationQRCodesConfig Configuration used when generating or scanning a calibration image.
CalibrationQRCodesScanResult Calibration image scan result, as returned by calibrationQRCodesScan().
PortRedirection A port redirection from a port on the host to a port in the virtual machine.
QEMUSettings Settings specifying how to create a virtual machine with the QEMU provider.
Rectangle Contains the position and size of a rectangle on the screen.
ScreenPosition A position in the screen, that extends SimplePosition with the size of the screen in pixels, because it is needed by some providers (i.e. qemu) to compute the mouse position to send to the virtual machine.
SimplePosition A position specified by the horizontal (x) and vertical (y) coordinates.
VirtualBoxSettings Settings specifying how to create a virtual machine with the VirtualBox provider.
VM This interface is implemented by each virtual machine provider. It specifies the set of operations that can be done on a virtual machine, including sending keyboard and mouse events and destroying the virtual machine.
VMConfig Configuration that can be passed to createVM when cloning and starting a virtual machine.

Variables

Variable Description
createSubLogFunction Creates a log function that, whenever it is called, calls the log function passed as the first paremeter with the predefined properties passed as the second parameter, (in addition to the properties it received it is called with).
createVM Clone and start a virtual machine, using the provider specified in the type property of VMSettings.
isShiftedKey Returns whether it is necessary to have the Shift key pressed to type the given character (with the US keyboard layout).
keysMap Map of keyboard keys. The key in the map is a character produced by the key (either with or without pressing Shift). The value in the map is the key from the Key enum.
logMessages Map of all messages that can be logged from this package. The key in the map is in the format: category.message, with category and message the properties from the log entry object passed to the LogFunction. The value in the map is the log message in English.
vmFactories Map of available virtual machine providers. The key in the map corresponds to the type property in VMSettings. The value is the VMFactory implemented by the provider.

Type Aliases

Type Alias Description
LogFunction A log function, as expected by this package.
VMFactory The virtual machine factory provided by each virtual machine provider. It is a function that takes the configuration and asynchronously returns an object that implements the VM interface.
VMSettings Settings specifying how to create a virtual machine. Depending on the chosen provider (determined by the type property), the required settings are different.