ergerodr / fest

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

BasicRobot#close(Window) #289

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
BasicRobot#close(Window) should give focus to the window to be closed
before posting the WINDOW_CLOSING event.
This would mimic the user actually closing the window more closely.

Here is a hack for BasicRobot#close(Window):

  /** {@inheritDoc} */
  @RunsInEDT
  public void close(Window w) {
    WindowEvent event = new WindowEvent(w, WINDOW_CLOSING);
    // If the window contains an applet, send the event on the applet's
queue instead to ensure a shutdown from the
    // applet's context (assists AppletViewer cleanup).
    Component applet = findAppletDescendent(w);
    Component c = applet != null ? applet : w;
    focus(c, true);
    EventQueue eventQueue = windowMonitor.eventQueueFor(c);
    eventQueue.postEvent(event);
    waitForIdle();
  }

I think that this fix is essential, because in some cases the focus
subsystem gets confused. For instance, given the scenario:

1. application starts up
2. FEST pops up dialog A
3. FEST pops up dialog B

(dialog B completely covers dialog A)

4. FEST to closes dialog A
5. FEST to closes dialog B

after step 5, the entire application loses focus.

I believe that this has to do with the previous focus owner of dialog B.
When FEST sends the WINDOW_CLOSING event to dialog A, it doesn't get
removed as the previous focus owner, so after closing dialog B, Swing tries
to give focus to dialog A (I think), which has already been closed.

In my test case I can reproduce the buggy behavior every single time. After
applying the hack, the buggy behavior disappears. I will create and upload
a test case as soon as possible.

Thanks,
Csabi

Original issue reported on code.google.com by csaba.ju...@gmail.com on 28 Jan 2009 at 1:07

GoogleCodeExporter commented 8 years ago

Original comment by Alex.Rui...@gmail.com on 5 Feb 2009 at 4:56

GoogleCodeExporter commented 8 years ago

Original comment by Alex.Rui...@gmail.com on 9 Feb 2009 at 6:30

GoogleCodeExporter commented 8 years ago
Hi Csabi,

I could not reproduce this bug. Please review the test case at
http://code.google.com/p/fest/source/detail?r=2267 (r2267). 

Please let me know if I'm missing something.

Thanks,
-Alex

Original comment by Alex.Rui...@gmail.com on 9 Feb 2009 at 6:46

GoogleCodeExporter commented 8 years ago
Hi Alex,

Sorry I haven't managed to create the test case myself.
In shouldGiveFocusToWindowBeforeClosingIt you should close window1, before 
window2.

Thanks,
Csabi

Original comment by csaba.ju...@gmail.com on 9 Feb 2009 at 1:46

GoogleCodeExporter commented 8 years ago
Hi,

I agree, the issue is invalid.
Fortunately moveToFront ( http://jira.codehaus.org/browse/FEST-20 ) solves my 
problem.

Thank you,
Csabi

Original comment by csaba.ju...@gmail.com on 6 May 2009 at 9:57