On Sat, 16 Jan 2021 01:33:00 GMT, Alexander Zuev <[email protected]> wrote:
>> Create implementation for NSAccessibilityImage protocol peer
>
>> @pankaj-bansal please provide some steps to test that a11y for the image
>> works.
>
> I use the simple code snippet like this:
>
> <pre>
> import java.awt.*;
> import java.net.MalformedURLException;
> import java.net.URL;
> import javax.swing.*;
>
> public class AccessibleImageTest {
> public static void main(String[] args) throws MalformedURLException {
> new AccessibleImageTest().test();
> }
>
> public void test() throws MalformedURLException {
> JFrame frame = new JFrame("Test frame");
> frame.setLayout(new BorderLayout());
> ImageIcon imageIcon = new ImageIcon(new
> URL("https://www.oracle.com/a/ocom/img/i-code-java-300x352-3854596.png"));
> JLabel label = new JLabel(imageIcon);
> label.getAccessibleContext().setAccessibleDescription("I code Java");
> frame.add(label, BorderLayout.CENTER);
> frame.add(new JButton("Top button"), BorderLayout.NORTH);
> frame.add(new JButton("Bottom button"), BorderLayout.SOUTH);
> frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
> frame.pack();
> frame.setVisible(true);
> }
> }
> </pre>
>
> After compiling and running the code you should see frame with two buttons on
> top and bottom and image in the middle. Now if you turn on VoiceOver with
> `<Command><F5>` the accessibility cursor should be on one of the buttons. By
> using `<Control><Option><UpArrow>` and `<Control><Option><DownArrow>`
> combinations you should be able to move accessibility cursor between buttons
> and the image. If image accessibility implemented correctly the accessibility
> cursor should be drawn around the image borders and the VoiceOver should
> understand the selected element type and take accessible text of the image
> into account, so the narration should sound like "I code Java, image". Of
> course that also should work with the local images and icon images.
I also used something similar. I used this program
https://docs.oracle.com/javase/tutorial/uiswing/examples/components/LabelDemoProject/src/components/LabelDemo.java.
I verified that the VO output is same before and after this change.
To verify that the VO is actually using the ImageAccessibility and not JLabel
accessibility support, I returned some dummy text from (nullable NSString
*)accessibilityLabel function in ImageAccessibility class. VO does return the
dummy text as expected.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2096