Previously:
The action description would be localized text. So in German's case 
`getAccessibleActionDescription(0)` would return `Klicken`. As that String is 
passed upwards towards VoiceOver, we're counting on VoiceOver's code 
interpreting it correctly.

With this PR:
We always return "click" (using the AccessibleAction.CLICK constant). VoiceOver 
knows how to interpret an unlocalized "click".

## Context

I looked up references to other AccessibleAction constants:

- AccessibleAction.TOGGLE_EXPAND is referenced in JTree.java's 
`getAccessibleActionDescription` method.
- AccessibleAction.INCREMENT and AccessibleAction.DECREMENT are referenced in 
JSlider's and JSpinner's `getAccessibleActionDescription` method.
- AccessibleAction.CLICK and AccessibleAction.TOGGLE_POPUP are NOT currently 
referenced (prior to this PR)

The javadoc for `getAccessibleActionDescription` simply describes the return 
value as "a String description of the action". It makes no comment on whether 
it should be localized or not.

JList.java is similar to AbstractButton:

public String getAccessibleActionDescription(int i) {
    if (i == 0) {
        return UIManager.getString("AbstractButton.clickText");
    } else {
        return null;
    }
}


JComboBox.java includes:

public String getAccessibleActionDescription(int i) {
    if (i == 0) {
        return UIManager.getString("ComboBox.togglePopupText");
    }
    else {
        return null;
    }
}


I'd argue that we need to be consistent: either JTree/JSlider/JSpinner should 
be modified to return a localized action description, OR 
AbstractButton/JList/JComboBox should be modified to return the unlocalized 
constant.

My preference is to modify AbstractButton and JList (as shown in this PR). (And 
I'd recommend addressing JComboBox in a separate PR.)

(Also, I really like JTextComponent.java's implementation that combined Swing's 
ActionMap with AccessibleActions:

public String getAccessibleActionDescription(int i) {
    Action [] actions = JTextComponent.this.getActions();
    if (i < 0 || i >= actions.length) {
        return null;
    }
    return (String)actions[i].getValue(Action.NAME);
}

... but that's straying pretty far from the original ticket.)

## Non-Swing Context

I also searched for `getAccessibleActionDescription` in general.

In Button.java and MenuItem.java we have:

public String getAccessibleActionDescription(int i) {
    if (i == 0) {
        // [[[PENDING:  WDW -- need to provide a localized string]]]
        return "click";
    } else {
        return null;
    }
}


These comments date back to the beginning of the git history. This commenter 
(WDW maybe William D. Walker?) appears to take the opposite view.

## Regarding the Test

Since we prefer automated tests over manual tests: I'm proposing in this PR an 
automated test that only identifies the description String. (This way we don't 
have to toggle VoiceOver on/off, so we don't need a manual test.)

I have separately confirmed the original bug test case from the ticket does not 
reproduce in this branch, but as of this writing I am NOT including that as a 
new manual test.

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

Commit messages:
 - 8377938: Fixing test to fail
 - 8377938: AbstractAction should describe actions using AccessibleAction.CLICK

Changes: https://git.openjdk.org/jdk/pull/29727/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29727&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8377938
  Stats: 57 lines in 2 files changed: 56 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/29727.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29727/head:pull/29727

PR: https://git.openjdk.org/jdk/pull/29727

Reply via email to