Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: FEST-Swing 1.1
-
Fix Version/s: FEST-Swing 1.3a1
-
Component/s: Swing
-
Labels:None
-
Number of attachments :
Description
E-mail form Epaga:
Unfortunately, on my dual monitor system with my main monitor on the right and the second monitor on the left, FEST seems to be trying to click at the wrong position when it tries to click on a component.
My code looks something like this:
fixture = WindowFinder.findDialog( JDialog.class ).withTimeout( 10000 ).using( RobotFixture.robotWithCurrentAwtHierarchy() ); fixture.textBox( "Dtf_PromptName" ).click().deleteText().enterText( "text" );
When it runs the click method, the cursor vibrates on the right screen, apparently looking for the text box, but the dialog is on the left side of the screen. Is there some way to avoid this problem? I've tried setting the location of the dialog to move to the right side, but then FEST just moves the cursor to the right as well.
Original report: Issue 51 (Google Code)
A possible fix to this is in the AWT class with code similar to (I needed to do this for multiple monitor setup);
/** * Indicates whether the given point, relative to the given <code>JComponent</code>, is inside the screen boundaries. * @param c the given <code>JComponent</code>. * @param p the point to verify. * @return <code>true</code> if the point is inside the screen boundaries; <code>false</code> otherwise. * @since 1.2 */ public static boolean isPointInScreenBoundaries(JComponent c, Point p) { Point where = translate(c, p.x, p.y); return isPointInScreenBoundaries(where); } /** * Indicates whether the given point is inside the screen boundaries. * @param p the point to verify. * @return <code>true</code> if the point is inside the screen boundaries; <code>false</code> otherwise. * @since 1.2 */ public static boolean isPointInScreenBoundaries(Point p) { GraphicsDevice[] screens = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); if (screens.length == 1) { Rectangle screen = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); return screen.contains(p); } else { for (GraphicsDevice device : screens) { for (GraphicsConfiguration config : device.getConfigurations()) { if (config.getBounds().contains(p)) { return true; } } } } return false; }I think that caching would be necessary as there appears to be an overhead with the above code, but screens tend not to change during the tests, or if they did it would be rather unusual.