Package org.testfx.service.adapter
Interface RobotAdapter<T>
- All Known Implementing Classes:
AwtRobotAdapter
,GlassRobotAdapter
,JavafxRobotAdapter
,PrivateGlassRobotAdapter
,PublicGlassRobotAdapter
public interface RobotAdapter<T>
The common interface for all RobotAdapters.
These are the minimum set of functions required from a robot to provide the full functionality use in the higher level api.
These are the minimum set of functions required from a robot to provide the full functionality use in the higher level api.
Threading
The caller of the Adapter usually doesn't run on the FX-Application Thread. If required, the implementation of this class will schedule the actions on the FX-Application Thread.-
Method Summary
Modifier and TypeMethodDescriptionjavafx.scene.paint.Color
getCapturePixelColor
(javafx.geometry.Point2D location) Gets the color of a pixel at the given JavaFx coordinates.javafx.scene.image.Image
getCaptureRegion
(javafx.geometry.Rectangle2D region) Captures a region of the screen.javafx.geometry.Point2D
Returns the current position of the cursor in JavaFx coordinatesvoid
keyPress
(javafx.scene.input.KeyCode key) Function used to make the robot press a key.void
keyRelease
(javafx.scene.input.KeyCode key) Function used to make the robot release a key.void
mouseMove
(javafx.geometry.Point2D location) Moves the mouse cursor to the given position in JavaFx coordinatesvoid
mousePress
(javafx.scene.input.MouseButton button) Makes the robot press a mouse button.void
mouseRelease
(javafx.scene.input.MouseButton button) Makes the robot release a mouse button.void
mouseWheel
(int wheelAmount) Makes the robot to simulate a action of the mouse wheel.
Negative values indicate movement up/away from the user, positive values indicate movement down/towards the user.void
Creates a robot.void
Destroys the robot
-
Method Details
-
robotCreate
void robotCreate()Creates a robot. -
robotDestroy
void robotDestroy()Destroys the robot -
keyPress
void keyPress(javafx.scene.input.KeyCode key) Function used to make the robot press a key. The key must be a physical existing key on the keyboard.- Parameters:
key
- the key to press (must exist on a keyboard)
-
keyRelease
void keyRelease(javafx.scene.input.KeyCode key) Function used to make the robot release a key. The key must be a physical existing key on the keyboard.- Parameters:
key
- the key to press (must exist on a keyboard)
-
getMouseLocation
javafx.geometry.Point2D getMouseLocation()Returns the current position of the cursor in JavaFx coordinates- Returns:
- the current position of the mouse cursor
-
mouseMove
void mouseMove(javafx.geometry.Point2D location) Moves the mouse cursor to the given position in JavaFx coordinates- Parameters:
location
- the location in JavaFx coordinates to move the cursor to
-
mousePress
void mousePress(javafx.scene.input.MouseButton button) Makes the robot press a mouse button.- Parameters:
button
- the button to press
-
mouseRelease
void mouseRelease(javafx.scene.input.MouseButton button) Makes the robot release a mouse button.- Parameters:
button
- the button to release
-
mouseWheel
void mouseWheel(int wheelAmount) Makes the robot to simulate a action of the mouse wheel.
Negative values indicate movement up/away from the user, positive values indicate movement down/towards the user.- Parameters:
wheelAmount
- the amount to scroll
-
getCapturePixelColor
javafx.scene.paint.Color getCapturePixelColor(javafx.geometry.Point2D location) Gets the color of a pixel at the given JavaFx coordinates. The returned Color is in the JavaFx color space. //TODO Due to technical reasons, there might be a deviation in color.- Parameters:
location
- of the pixel in JavaFx coordinates, to retrieve the color for- Returns:
- the Color of the given Pixel in the JavaFx color space
-
getCaptureRegion
javafx.scene.image.Image getCaptureRegion(javafx.geometry.Rectangle2D region) Captures a region of the screen. The returned Image is in the JavaFx color space. //TODO Due to technical reasons, there might be a deviation.- Parameters:
region
- the region to capture in JavaFx coordinates- Returns:
- a image of the region
-