RFR: 8348299: Update List/ItemEventTest/ItemEventTest.java

Alexander Zvegintsev azvegint at openjdk.org
Thu Jan 23 09:43:48 UTC 2025


On Wed, 22 Jan 2025 16:45:17 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

> With this changeset, I update the `java/awt/List/ItemEventTest/ItemEventTest.java` test to improve its stability and analysis of failures of the test.
> 
> 1. Use thread-safe `StringBuffer` for `actualSelectionOrder` to track selecting/deselecting items in the list.
> 2. Enable `robot.setAutoWaitForIdle(true)` and remove `robot.waitForIdle()` from the test code.
> 3. Log `handleEvent` and `ItemListener` which helps to identify test failures.  
>     (In case of [JDK-8204221](https://bugs.openjdk.org/browse/JDK-8204221), `handleEvent` is never logged.)
> 5. Take screenshot of the list on failure;  
>     Optionally take screenshot after each mouse press+release if `-save` is passed as a parameter to the test.
> 
> The updated test passes.

test/jdk/java/awt/List/ItemEventTest/ItemEventTest.java line 82:

> 80:         pack();
> 81:         setLocationRelativeTo(null);
> 82:         setVisible(true);

Didn't we decide that we should also now handle AWT calls on EDT?

test/jdk/java/awt/List/ItemEventTest/ItemEventTest.java line 93:

> 91:                 || e.id == Event.LIST_SELECT)) {
> 92:             logEvent("handleEvent: ", e.arg);
> 93:         }

Suggestion:

        if (e.target instanceof List) {
            switch (e.id) {
                case Event.LIST_SELECT
                        -> logEvent("handleEvent: LIST_SELECT ", e.arg);
                case Event.LIST_DESELECT
                        -> logEvent("handleEvent: LIST_DESELECT ", e.arg);
            }
        }

Not sure if this is really useful or not, but logging can be slightly improved.

test/jdk/java/awt/List/ItemEventTest/ItemEventTest.java line 117:

> 115:         synchronized (actualSelectionOrder) {
> 116:             actualSelectionOrder.delete(0, actualSelectionOrder.length());
> 117:         }

Suggestion:

        actualSelectionOrder.setLength(0);


we can make it shorter

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23238#discussion_r1926666866
PR Review Comment: https://git.openjdk.org/jdk/pull/23238#discussion_r1926656462
PR Review Comment: https://git.openjdk.org/jdk/pull/23238#discussion_r1926649258


More information about the client-libs-dev mailing list