On Tue, 27 Feb 2024 21:05:47 GMT, Alisen Chung <[email protected]> wrote:

>> test/jdk/java/awt/TrayIcon/DisposeInActionEventTest/DisposeInActionEventTest.java
>>  line 77:
>> 
>>> 75:                 .testUI(DisposeInActionEventTest::showFrameAndIcon)
>>> 76:                 .build()
>>> 77:                 .awaitAndCheck();
>> 
>> I propose removing the icon from the system tray in a `finally` block. 
>> Otherwise, the test doesn't exit if you run it without jtreg.
>
> i'm not sure i understand this, the test is trying to remove right after the 
> click action is delivered and not before the test is closing, so wouldn't 
> putting the removal of the icon in a finally block defeat the purpose of the 
> test?

@alisenchung  Since the trayicon is added back after removal and PassFailJFrame 
handles disposal of test windows only, Aleksei is suggesting we handle the 
removal of trayicon explicitly (when test is run outside of jtreg) something 
like below. You probably want to move `systemTray` and `trayIcon` vars 
accordingly.


try {
    PassFailJFrame.builder()
                  .title("Event Message Display")
                  .instructions(instructions)
                  .testTimeOut(5)
                  .rows(15)
                  .columns(45)
                  .testUI(DisposeInActionEventTest::showFrameAndIcon)
                  .build()
                  .awaitAndCheck();
} finally {
     systemTray.remove(trayIcon);
}

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/17838#discussion_r1505220550

Reply via email to