Skip to main content

Transition Guide

About

This Transition Guide describes the steps one should perform with tests in order to make them conform to the Jemmy3. Primary goal of Jemmy3 is to support JavaFX application that use prism testing. As the prism doesn't use AWTEventQueue and also doesn't work if java.awt.Robot class is loaded, Jemmy3 had to get rid of all the AWT related things. That leaded to creation of separate JemmyAWTInput library which can use java.awt.Robot class running on another JVM and performing all the necessary input manipulations.

Where to get

is available via this link: http://baracuda.russia.sun.com:9090/hudson/job/Jemmy3.dev/. This page also contains JavaDoc.

Incompatibilities

Due to incompatibility of Prism and AWT stack, all AWT classes were removed from JemmyCore. They were either replaced by similar classes which were created in Jemmy or abstracted and moved to different libraries. The list of incompatibilities:

Incompatibility What to do Comments
java.awt.Rectangle, java.awt.Point and java.awt.Dimension Replace "java.awt" to "org.jemmy" in import section of the code Analogous classes were created in Jemmy to replace the ones from AWT. Classes have the same API, so there is a good chance that by replacing the import it all get fixed. To convert instances of these classes from awt to jemmy and vice versa org.jemmy.image.Utils class static methods can be used.
InputEvent, KeyEvent and MouseEvent Replace key constants with the ones from Keyboard.KeyboardButtons and Mouse.MouseButtons and modifier constants combination with an array of elements from Keyboard.KeyboardModifiers, Mouse.MouseModifiers. Methods accept them via varargs. See Input section for more details
Direct java.awt.Robot calls Replace any invocations of Robot.waitForIdle with ActionExecutor.waitQuiet(Timeout) method See Event queue section for more info.
Image functionality Use new API. See Images section for more details.
Jemmy setup. If you are using JemmyCore directly (i.e. not through JemmyFX), you need to set up the environment by calling methods from the table below See Event queue and Images

Jemmy properties

Jemmy behaviour defaults are now set in JemmyAWT or JemmyFX libraries. You could also override these settings through properties file. It is possible to change them programmatically too, but to diminish amount of test code and to allow the same code be executed in different configuration, the properties could be placed in the Jemmy properties file.

The file location is defined through jemmy.properties Java system property. If the property is not specified, .jemmy.properties file from user home directory is read.

The following table summarizes .jemmy.properties file properties with their default values for different libraries:

Property name
API analog
Meaning
Default values
JemmyAWT
JemmyFX
awt.robot.othervm AWTRobotInputFactory.runInOtherJVM whether to run awt.Robot in another JVM false false
awt.robot.othervm.host Set AWTRobotInputFactory.OTHER_VM_HOST_PROPERTY property in Environment prior to first Input action Hostname of the robot VM localhost localhost
awt.robot.othervm.port Set AWTRobotInputFactory.OTHER_VM_PORT_PROPERTY property in Environment prior to first Input action Port of the robot VM 53669 53669
awt.robot.othervm.connection.timeout Set AWTRobotInputFactory.OTHER_VM_CONNECTION_TIMEOUT_PROPERTY property in Environment prior to first Input action Wait time for connection 15 * 60000 15 * 60000
awt.robot.mouse.smoothness AWTRobotInputFactory.setMouseSmoothness and AWTRobotInputFactory.getMouseSmoothness Mouse move smoothness which is the maximum distance in pixels between mouse positions during movement false false
action.executor.property Environment.setExecutor Event queue synchronization implementation. AWTExecutor FXExecutor
input.factory.property Wrap.setInputFactory Implementation of a user input simulation. AWTRobotInputFactory AWTRobotInputFactory
image.factory.property Wrap.setImageFactory Implementation of obtaining images AWTImageFactory
AWTImageFactory

Input

As awt InputEvent and similar classes had to go away, replacement enums for the constants were introduced. Button interface represents particular keyboard or mouse button and Modifier interface does the same thing for modifiers. Default set of buttons and modifiers can be found in Keyboard.KeyboardModifiers, Mouse.MouseModifiers, Keyboard.KeyboardButtons and Mouse.MouseButtons enums. There is also AWTMap helper class in JemmyAWTInput library which can do conversion between awt constants and jemmy enum values.

New ControlInterfaceFactory interface was introduced to support different input libraries. Existing implementation were extended with another JVM mode (see below) and moved to JemmyAWTInput library.

Another JVM mode was introduced to support JavaFX prism stack where usage of awt.Robot is prohibited. Thus separate JVM starts and all Robot invocations occur in the separate JVM when in another JVM mode.

AWTRobotInputFactory is the ControlInterfaceFactory implemenataion of JemmyAWTInput library.

Event Queue

ActionExecutor.waitQuiet(Timeout) method added which should be used to wait for the event queue to be fully processed. This method is implemented in each particular library differently. Among them AWTExecutor and FXExecutor.

Image

As AWT BufferedImage had to go away, Image interface was introduced. Each library is supposed to provide its own implementation or use AWTImage implementation from JemmyAWTInput library. Image has method to compare image to another and a way to save image. Particular libraries can provide more features. AWTImage can be compared using one of image comparators and can be saved to filesystem.

To obtain images one of ImageFactory interface implementations should be used. It has methods to capture image of the particular control represented by Wrap object instance and load image from the filesystem or other source. JemmyAWTInput library provides two implementations: FilesystemImageFactory and ClasspathImageFactory that load images from filesystem or from the specified resource bundle respectively.

Mostly all other image related classes and interfaces such as ImageComparator and ImageFinder were moved to JemmyAWTInput library.

API changes

Old
New
org.jemmy.control.Control
org.jemmy.control.Wrap
org.jemmy.control.ControlException
org.jemmy.control.WrapperException
java.awt.Image
org.jemmy.image.Image
java.awt.image.BufferedImage
org.jemmy.image.AWTImage
java.awt.Point
org.jemmy.Point
java.awt.Dimension
org.jemmy.Dimension
java.awt.Rectangle
org.jemmy.Rectangle
Control.waitImage(BufferedImage)
Wrap.waitImage(Image, String, String)
java.awt.input.InputEvent.VK_*
org.jemmy.interfaces.Keyboard.KeyboardButtons.*
java.awt.input.InputEvent.*_DOWN_MASK org.jemmy.interfaces.Keyboard.KeyboardModifiers.*
org.jemmy.interfaces.Mouse.MouseModifiers.*
java.awt.input.MouseEvent.BUTTON*
org.jemmy.interfaces.Mouse.MouseButtons.*
javax.imageio.ImageIO.read
org.jemmy.image.ImageFactory.load(String)
javax.imageio.ImageIO.write org.jemmy.image.Image.save(String)
java.awt.Robot.waitForIdle()
org.jemmy.action.ActionExecutor.waitQuiet(Timeout)

 
 
Close
loading
Please Confirm
Close