benjamin84 / fest

Automatically exported from code.google.com/p/fest
0 stars 0 forks source link

NullPointerException on JButtonFixture.click #169

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When form disappears on button click - sometimes getting:

java.lang.NullPointerException
    at org.fest.swing.util.AWT.locationOnScreenOf(AWT.java:147)
    at org.fest.swing.util.AWT.locationOnScreenOf(AWT.java:146)
    at org.fest.swing.util.AWT.locationOnScreenOf(AWT.java:146)
    at org.fest.swing.util.AWT.locationOnScreenOf(AWT.java:146)
    at org.fest.swing.input.InputState.updateState(InputState.java:94)
    at org.fest.swing.input.InputState.update(InputState.java:75)
    at org.fest.swing.core.AWTEventPoster.postEvent(AWTEventPoster.java:64)
    at
org.fest.swing.core.AWTEventPoster.verifyPostedEvent(AWTEventPoster.java:92)
    at org.fest.swing.core.AWTEventPoster.postEvent(AWTEventPoster.java:67)
    at
org.fest.swing.core.AWTEventGenerator.postMouseRelease(AWTEventGenerator.java:12
2)
    at
org.fest.swing.core.AWTEventGenerator.releaseMouse(AWTEventGenerator.java:109)
    at org.fest.swing.core.RobotFixture.click(RobotFixture.java:349)
    at org.fest.swing.core.RobotFixture.click(RobotFixture.java:324)
    at org.fest.swing.core.RobotFixture.click(RobotFixture.java:314)
    at org.fest.swing.core.RobotFixture.click(RobotFixture.java:304)
    at org.fest.swing.driver.ComponentDriver.click(ComponentDriver.java:73)
    at org.fest.swing.fixture.JButtonFixture.click(JButtonFixture.java:73)

Original issue reported on code.google.com by filim...@gmail.com on 4 Jul 2008 at 12:06

GoogleCodeExporter commented 9 years ago
How to reproduce

AWTEventPoster.postEvent
... 
 pause(settings.delayBetweenEvents());
replace with 
pause(2000)
or just set breakpoint here.

Original comment by filim...@gmail.com on 4 Jul 2008 at 12:19

GoogleCodeExporter commented 9 years ago
No, unfortunatelly pause(2000) or breakpoiint in not enough...
we have to somehow be inside this condition

if (isAWTMode() && event.getID() == MOUSE_RELEASED && previous.getID() == 
MOUSE_PRESSED)

AWTEventPoster.verifyPostedEvent

Original comment by filim...@gmail.com on 4 Jul 2008 at 12:30

GoogleCodeExporter commented 9 years ago
finally:

AWT.locationOnScreenOf
...
Point parentLocation = locationOnScreenOf(parent);
...
have to be fixed e.g. as:
if(parentLocation)
throw new IllegalComponentStateException();

Original comment by filim...@gmail.com on 4 Jul 2008 at 12:58

GoogleCodeExporter commented 9 years ago
if(parentLocation == null)
throw new IllegalComponentStateException();

Original comment by filim...@gmail.com on 4 Jul 2008 at 1:05

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Set the module as a label, instead of being part of the title.

Original comment by Alex.Rui...@gmail.com on 1 Dec 2008 at 2:06

GoogleCodeExporter commented 9 years ago
Hi Filimono,

IMHO this bug is no longer applicable. 'locationOnScreenOf' returns null, if the
parent of the given component is null. 'updateState' (in InputState) ultimately 
will
not do anything if the location is null.

Please let me know if it makes sense.

-Alex

Original comment by Alex.Rui...@gmail.com on 1 Dec 2008 at 7:49