mirror of
https://github.com/openjdk/jdk.git
synced 2026-06-10 12:37:09 +00:00
8385302: Open source accessibility AWT tests
Reviewed-by: prr, kizune
This commit is contained in:
parent
241d649d9e
commit
27f27dac96
145
test/jdk/javax/accessibility/awt/CheckboxTest.java
Normal file
145
test/jdk/javax/accessibility/awt/CheckboxTest.java
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Checkbox Accessibility test.
|
||||
* @library ../../swing/regtesthelpers/accessibility/
|
||||
* @build AccessibleTestUtils AccessibleComponentTester AccessibleStateSetTester
|
||||
* @run main CheckboxTest
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.Checkbox;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Robot;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import javax.accessibility.AccessibleState;
|
||||
import javax.accessibility.AccessibleStateSet;
|
||||
|
||||
public class CheckboxTest {
|
||||
|
||||
private static Checkbox checkbox;
|
||||
private static Frame frame;
|
||||
|
||||
private static final String ACCESSIBLE_NAME = "Checkbox Test";
|
||||
private static final String ACCESSIBLE_DESCRIPTION =
|
||||
"Regression Test: javax.accessibility, Checkbox";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException, AWTException {
|
||||
CheckboxTest checkboxTest = new CheckboxTest();
|
||||
EventQueue.invokeAndWait(checkboxTest::createGUI);
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
robot.delay(5000);
|
||||
|
||||
try {
|
||||
EventQueue.invokeAndWait(checkboxTest::test);
|
||||
} finally {
|
||||
checkboxTest.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void createGUI() {
|
||||
frame = new Frame("Checkbox Test");
|
||||
checkbox = new Checkbox("This is a checkbox", true);
|
||||
|
||||
checkbox.getAccessibleContext().setAccessibleName(ACCESSIBLE_NAME);
|
||||
checkbox.getAccessibleContext().setAccessibleDescription(
|
||||
ACCESSIBLE_DESCRIPTION);
|
||||
|
||||
frame.add(checkbox);
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private void dispose() throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void test() {
|
||||
AccessibleTestUtils.verifyCheckboxAccessibility(
|
||||
checkbox,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
|
||||
new CheckboxStateTester(
|
||||
checkbox,
|
||||
checkbox.getAccessibleContext().getAccessibleStateSet()
|
||||
).testAll();
|
||||
|
||||
checkbox.setState(!checkbox.getState());
|
||||
|
||||
AccessibleTestUtils.verifyCheckboxAccessibility(
|
||||
checkbox,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
|
||||
new CheckboxStateTester(
|
||||
checkbox,
|
||||
checkbox.getAccessibleContext().getAccessibleStateSet()
|
||||
).testAll();
|
||||
}
|
||||
|
||||
private static final class CheckboxStateTester
|
||||
extends AccessibleStateSetTester {
|
||||
private final Checkbox checkbox;
|
||||
private final AccessibleStateSet set;
|
||||
|
||||
private CheckboxStateTester(Checkbox checkbox, AccessibleStateSet set) {
|
||||
super(checkbox, set);
|
||||
this.checkbox = checkbox;
|
||||
this.set = set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testChecked() {
|
||||
if (set.contains(AccessibleState.CHECKED)) {
|
||||
if (!checkbox.getState()) {
|
||||
throw new RuntimeException(
|
||||
"AccessibleStateSet contains CHECKED but " +
|
||||
"this component is not checked");
|
||||
}
|
||||
} else {
|
||||
if (checkbox.getState()) {
|
||||
throw new RuntimeException(
|
||||
"AccessibleStateSet does not contain CHECKED " +
|
||||
"but this component is checked");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
158
test/jdk/javax/accessibility/awt/FrameTest.java
Normal file
158
test/jdk/javax/accessibility/awt/FrameTest.java
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Frame Accessibility test.
|
||||
* @library ../../swing/regtesthelpers/accessibility/
|
||||
* @build AccessibleTestUtils AccessibleComponentTester AccessibleStateSetTester
|
||||
* @run main FrameTest
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Robot;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import javax.accessibility.AccessibleState;
|
||||
import javax.accessibility.AccessibleStateSet;
|
||||
|
||||
public class FrameTest {
|
||||
|
||||
private static Frame frame;
|
||||
|
||||
private static final String ACCESSIBLE_NAME = "Frame Test";
|
||||
private static final String ACCESSIBLE_DESCRIPTION =
|
||||
"Regression Test: javax.accessibility, Frame";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException, AWTException {
|
||||
FrameTest frameTest = new FrameTest();
|
||||
EventQueue.invokeAndWait(frameTest::createGUI);
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
robot.delay(5000);
|
||||
|
||||
try {
|
||||
EventQueue.invokeAndWait(frameTest::test);
|
||||
} finally {
|
||||
frameTest.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void createGUI() {
|
||||
frame = new Frame("Frame Test");
|
||||
|
||||
frame.getAccessibleContext().setAccessibleName(ACCESSIBLE_NAME);
|
||||
frame.getAccessibleContext().setAccessibleDescription(
|
||||
ACCESSIBLE_DESCRIPTION);
|
||||
|
||||
frame.setSize(300, 300);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private void dispose() throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void test() {
|
||||
AccessibleTestUtils.verifyFrameAccessibility(
|
||||
frame,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
|
||||
new FrameStateTester(
|
||||
frame,
|
||||
frame.getAccessibleContext().getAccessibleStateSet()
|
||||
).testAll();
|
||||
|
||||
frame.setResizable(false);
|
||||
|
||||
AccessibleTestUtils.verifyFrameAccessibility(
|
||||
frame,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
|
||||
new FrameStateTester(
|
||||
frame,
|
||||
frame.getAccessibleContext().getAccessibleStateSet()
|
||||
).testAll();
|
||||
}
|
||||
|
||||
private static final class FrameStateTester
|
||||
extends AccessibleStateSetTester {
|
||||
private final Frame component;
|
||||
private final AccessibleStateSet set;
|
||||
|
||||
private FrameStateTester(Frame frame, AccessibleStateSet set) {
|
||||
super(frame, set);
|
||||
this.component = frame;
|
||||
this.set = set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testResizable() {
|
||||
if (set.contains(AccessibleState.RESIZABLE)) {
|
||||
if (!component.isResizable()) {
|
||||
throw new RuntimeException(
|
||||
"AccessibleStateSet contains RESIZABLE but " +
|
||||
"this component is not resizable");
|
||||
}
|
||||
} else {
|
||||
if (component.isResizable()) {
|
||||
throw new RuntimeException(
|
||||
"AccessibleStateSet does not contain RESIZABLE " +
|
||||
"but this component is resizable");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testActive() {
|
||||
if (set.contains(AccessibleState.ACTIVE)) {
|
||||
if (component.getFocusOwner() == null) {
|
||||
throw new RuntimeException(
|
||||
"AccessibleStateSet contains ACTIVE but " +
|
||||
"this component is not active");
|
||||
}
|
||||
} else {
|
||||
if (component.getFocusOwner() != null) {
|
||||
throw new RuntimeException(
|
||||
"AccessibleStateSet does not contain ACTIVE but " +
|
||||
"this component is active");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
100
test/jdk/javax/accessibility/awt/LabelTest.java
Normal file
100
test/jdk/javax/accessibility/awt/LabelTest.java
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Label Accessibility test.
|
||||
* @library ../../swing/regtesthelpers/accessibility/
|
||||
* @build AccessibleTestUtils AccessibleComponentTester AccessibleStateSetTester
|
||||
* @run main LabelTest
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Label;
|
||||
import java.awt.Robot;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class LabelTest {
|
||||
|
||||
private static Label label;
|
||||
private static Frame frame;
|
||||
|
||||
private static final String ACCESSIBLE_NAME = "Label Test";
|
||||
private static final String ACCESSIBLE_DESCRIPTION =
|
||||
"Regression Test: javax.accessibility, Label";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException, AWTException {
|
||||
LabelTest labelTest = new LabelTest();
|
||||
EventQueue.invokeAndWait(labelTest::createGUI);
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
robot.delay(5000);
|
||||
|
||||
try {
|
||||
EventQueue.invokeAndWait(labelTest::test);
|
||||
} finally {
|
||||
labelTest.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void createGUI() {
|
||||
frame = new Frame("Label Test");
|
||||
label = new Label("This is a label");
|
||||
|
||||
label.getAccessibleContext().setAccessibleName(ACCESSIBLE_NAME);
|
||||
label.getAccessibleContext().setAccessibleDescription(
|
||||
ACCESSIBLE_DESCRIPTION);
|
||||
|
||||
frame.add(label);
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private void dispose() throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void test() {
|
||||
AccessibleTestUtils.verifyLabelAccessibility(
|
||||
label,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
|
||||
new AccessibleStateSetTester(
|
||||
label,
|
||||
label.getAccessibleContext().getAccessibleStateSet()
|
||||
).testAll();
|
||||
}
|
||||
}
|
||||
157
test/jdk/javax/accessibility/awt/ListTest.java
Normal file
157
test/jdk/javax/accessibility/awt/ListTest.java
Normal file
@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary List Accessibility test.
|
||||
* @library ../../swing/regtesthelpers/accessibility/
|
||||
* @build AccessibleTestUtils AccessibleComponentTester AccessibleStateSetTester
|
||||
* @run main ListTest
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.List;
|
||||
import java.awt.Robot;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import javax.accessibility.AccessibleState;
|
||||
import javax.accessibility.AccessibleStateSet;
|
||||
|
||||
public class ListTest {
|
||||
|
||||
private static List list;
|
||||
private static Frame frame;
|
||||
|
||||
private static final String ACCESSIBLE_NAME = "List Test";
|
||||
private static final String ACCESSIBLE_DESCRIPTION =
|
||||
"Regression Test: javax.accessibility, List";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException, AWTException {
|
||||
ListTest listTest = new ListTest();
|
||||
EventQueue.invokeAndWait(listTest::createGUI);
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
robot.delay(5000);
|
||||
|
||||
try {
|
||||
EventQueue.invokeAndWait(listTest::test);
|
||||
} finally {
|
||||
listTest.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void createGUI() {
|
||||
frame = new Frame("List Test");
|
||||
list = new List();
|
||||
|
||||
list.add("Mercury");
|
||||
list.add("Venus");
|
||||
list.add("Earth");
|
||||
list.add("JavaSoft");
|
||||
list.add("Mars");
|
||||
list.add("Jupiter");
|
||||
list.add("Saturn");
|
||||
list.add("Uranus");
|
||||
list.add("Neptune");
|
||||
list.add("Pluto");
|
||||
|
||||
list.getAccessibleContext().setAccessibleName(ACCESSIBLE_NAME);
|
||||
list.getAccessibleContext().setAccessibleDescription(
|
||||
ACCESSIBLE_DESCRIPTION);
|
||||
|
||||
frame.add(list);
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private void dispose() throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void test() {
|
||||
AccessibleTestUtils.verifyListAccessibility(
|
||||
list,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
|
||||
new ListStateTester(
|
||||
list,
|
||||
list.getAccessibleContext().getAccessibleStateSet()
|
||||
).testAll();
|
||||
|
||||
list.setMultipleMode(!list.isMultipleMode());
|
||||
|
||||
AccessibleTestUtils.verifyListAccessibility(
|
||||
list,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
|
||||
new ListStateTester(
|
||||
list,
|
||||
list.getAccessibleContext().getAccessibleStateSet()
|
||||
).testAll();
|
||||
}
|
||||
|
||||
private static final class ListStateTester
|
||||
extends AccessibleStateSetTester {
|
||||
private final List list;
|
||||
private final AccessibleStateSet set;
|
||||
|
||||
private ListStateTester(List list, AccessibleStateSet set) {
|
||||
super(list, set);
|
||||
this.list = list;
|
||||
this.set = set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testMultiSelectable() {
|
||||
if (set.contains(AccessibleState.MULTISELECTABLE)) {
|
||||
if (!list.isMultipleMode()) {
|
||||
throw new RuntimeException(
|
||||
"AccessibleStateSet contains MULTISELECTABLE " +
|
||||
"but this component is not multiselectable");
|
||||
}
|
||||
} else {
|
||||
if (list.isMultipleMode()) {
|
||||
throw new RuntimeException(
|
||||
"AccessibleStateSet does not contain " +
|
||||
"MULTISELECTABLE but this component is " +
|
||||
"multiselectable");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
102
test/jdk/javax/accessibility/awt/MenuBarTest.java
Normal file
102
test/jdk/javax/accessibility/awt/MenuBarTest.java
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary MenuBar Accessibility test.
|
||||
* @library ../../swing/regtesthelpers/accessibility/
|
||||
* @build AccessibleTestUtils AccessibleMenuComponentTester
|
||||
* @run main MenuBarTest
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Menu;
|
||||
import java.awt.MenuBar;
|
||||
import java.awt.MenuItem;
|
||||
import java.awt.Robot;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class MenuBarTest {
|
||||
|
||||
private static MenuBar menuBar;
|
||||
private static Frame frame;
|
||||
|
||||
private static final String ACCESSIBLE_NAME = "Menu Test";
|
||||
private static final String ACCESSIBLE_DESCRIPTION =
|
||||
"Regression Test: javax.accessibility, MenuBar";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException, AWTException {
|
||||
MenuBarTest menuBarTest = new MenuBarTest();
|
||||
EventQueue.invokeAndWait(menuBarTest::createGUI);
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
robot.delay(5000);
|
||||
|
||||
try {
|
||||
EventQueue.invokeAndWait(menuBarTest::test);
|
||||
} finally {
|
||||
menuBarTest.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void createGUI() {
|
||||
frame = new Frame("MenuBar Test");
|
||||
menuBar = new MenuBar();
|
||||
|
||||
Menu menu = new Menu("Menu 1");
|
||||
menu.add(new MenuItem("One"));
|
||||
menu.add(new MenuItem("Two"));
|
||||
menuBar.add(menu);
|
||||
|
||||
menuBar.getAccessibleContext().setAccessibleName(ACCESSIBLE_NAME);
|
||||
menuBar.getAccessibleContext().setAccessibleDescription(
|
||||
ACCESSIBLE_DESCRIPTION);
|
||||
|
||||
frame.setMenuBar(menuBar);
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private void dispose() throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void test() {
|
||||
AccessibleTestUtils.verifyMenuBarAccessibility(
|
||||
menuBar,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
}
|
||||
}
|
||||
103
test/jdk/javax/accessibility/awt/MenuItemTest.java
Normal file
103
test/jdk/javax/accessibility/awt/MenuItemTest.java
Normal file
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary MenuItem Accessibility test.
|
||||
* @library ../../swing/regtesthelpers/accessibility/
|
||||
* @build AccessibleTestUtils AccessibleMenuComponentTester
|
||||
* @run main MenuItemTest
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Menu;
|
||||
import java.awt.MenuBar;
|
||||
import java.awt.MenuItem;
|
||||
import java.awt.Robot;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class MenuItemTest {
|
||||
|
||||
private static MenuItem menuItem;
|
||||
private static Frame frame;
|
||||
|
||||
private static final String ACCESSIBLE_NAME = "MenuItem Test";
|
||||
private static final String ACCESSIBLE_DESCRIPTION =
|
||||
"Regression Test: javax.accessibility, MenuItem";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException, AWTException {
|
||||
MenuItemTest menuItemTest = new MenuItemTest();
|
||||
EventQueue.invokeAndWait(menuItemTest::createGUI);
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
robot.delay(5000);
|
||||
|
||||
try {
|
||||
EventQueue.invokeAndWait(menuItemTest::test);
|
||||
} finally {
|
||||
menuItemTest.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void createGUI() {
|
||||
frame = new Frame("MenuItem Test");
|
||||
|
||||
MenuBar menuBar = new MenuBar();
|
||||
Menu menu = new Menu("Menu");
|
||||
menuItem = new MenuItem("This here's a MenuItem");
|
||||
|
||||
menu.add(menuItem);
|
||||
menuBar.add(menu);
|
||||
|
||||
menuItem.getAccessibleContext().setAccessibleName(ACCESSIBLE_NAME);
|
||||
menuItem.getAccessibleContext().setAccessibleDescription(
|
||||
ACCESSIBLE_DESCRIPTION);
|
||||
|
||||
frame.setMenuBar(menuBar);
|
||||
frame.setSize(300, 300);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private void dispose() throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void test() {
|
||||
AccessibleTestUtils.verifyMenuItemAccessibility(
|
||||
menuItem,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
}
|
||||
}
|
||||
99
test/jdk/javax/accessibility/awt/MenuTest.java
Normal file
99
test/jdk/javax/accessibility/awt/MenuTest.java
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Menu Accessibility test.
|
||||
* @library ../../swing/regtesthelpers/accessibility/
|
||||
* @build AccessibleTestUtils AccessibleMenuComponentTester
|
||||
* @run main MenuTest
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Menu;
|
||||
import java.awt.MenuBar;
|
||||
import java.awt.Robot;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class MenuTest {
|
||||
|
||||
private static Menu menu;
|
||||
private static Frame frame;
|
||||
|
||||
private static final String ACCESSIBLE_NAME = "Menu Test";
|
||||
private static final String ACCESSIBLE_DESCRIPTION =
|
||||
"Regression Test: javax.accessibility, Menu";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException, AWTException {
|
||||
MenuTest menuTest = new MenuTest();
|
||||
EventQueue.invokeAndWait(menuTest::createGUI);
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
robot.delay(5000);
|
||||
|
||||
try {
|
||||
EventQueue.invokeAndWait(menuTest::test);
|
||||
} finally {
|
||||
menuTest.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void createGUI() {
|
||||
frame = new Frame("Menu Test");
|
||||
|
||||
MenuBar menuBar = new MenuBar();
|
||||
menu = new Menu("File");
|
||||
menuBar.add(menu);
|
||||
|
||||
menu.getAccessibleContext().setAccessibleName(ACCESSIBLE_NAME);
|
||||
menu.getAccessibleContext().setAccessibleDescription(
|
||||
ACCESSIBLE_DESCRIPTION);
|
||||
|
||||
frame.setMenuBar(menuBar);
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private void dispose() throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void test() {
|
||||
AccessibleTestUtils.verifyMenuAccessibility(
|
||||
menu,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
}
|
||||
}
|
||||
105
test/jdk/javax/accessibility/awt/PanelTest.java
Normal file
105
test/jdk/javax/accessibility/awt/PanelTest.java
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Panel Accessibility test.
|
||||
* @library ../../swing/regtesthelpers/accessibility/
|
||||
* @build AccessibleTestUtils AccessibleComponentTester AccessibleStateSetTester
|
||||
* @run main PanelTest
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.Button;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Panel;
|
||||
import java.awt.Robot;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class PanelTest {
|
||||
|
||||
private static Panel panel;
|
||||
private static Frame frame;
|
||||
|
||||
private static final String ACCESSIBLE_NAME = "Panel Test";
|
||||
private static final String ACCESSIBLE_DESCRIPTION =
|
||||
"Regression Test: javax.accessibility, Panel";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException, AWTException {
|
||||
PanelTest panelTest = new PanelTest();
|
||||
EventQueue.invokeAndWait(panelTest::createGUI);
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
robot.delay(5000);
|
||||
|
||||
try {
|
||||
EventQueue.invokeAndWait(panelTest::test);
|
||||
} finally {
|
||||
panelTest.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void createGUI() {
|
||||
frame = new Frame("Panel Test");
|
||||
panel = new Panel();
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
panel.add(new Button("Button #" + i));
|
||||
}
|
||||
|
||||
panel.getAccessibleContext().setAccessibleName(ACCESSIBLE_NAME);
|
||||
panel.getAccessibleContext().setAccessibleDescription(
|
||||
ACCESSIBLE_DESCRIPTION);
|
||||
|
||||
frame.add(panel);
|
||||
frame.pack();
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private void dispose() throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void test() {
|
||||
AccessibleTestUtils.verifyPanelAccessibility(
|
||||
panel,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
|
||||
new AccessibleStateSetTester(
|
||||
panel,
|
||||
panel.getAccessibleContext().getAccessibleStateSet()
|
||||
).testAll();
|
||||
}
|
||||
}
|
||||
100
test/jdk/javax/accessibility/awt/PopupMenuTest.java
Normal file
100
test/jdk/javax/accessibility/awt/PopupMenuTest.java
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary PopupMenu Accessibility test.
|
||||
* @library ../../swing/regtesthelpers/accessibility/
|
||||
* @build AccessibleTestUtils AccessibleMenuComponentTester
|
||||
* @run main PopupMenuTest
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.PopupMenu;
|
||||
import java.awt.Robot;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class PopupMenuTest {
|
||||
|
||||
private static PopupMenu popupMenu;
|
||||
private static Frame frame;
|
||||
|
||||
private static final String ACCESSIBLE_NAME = "PopupMenu Test";
|
||||
private static final String ACCESSIBLE_DESCRIPTION =
|
||||
"Regression Test: javax.accessibility, PopupMenu";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException, AWTException {
|
||||
PopupMenuTest popupMenuTest = new PopupMenuTest();
|
||||
EventQueue.invokeAndWait(popupMenuTest::createGUI);
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
robot.delay(5000);
|
||||
|
||||
try {
|
||||
EventQueue.invokeAndWait(popupMenuTest::test);
|
||||
} finally {
|
||||
popupMenuTest.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void createGUI() {
|
||||
frame = new Frame("PopupMenu Test");
|
||||
popupMenu = new PopupMenu("PopupMenu");
|
||||
|
||||
popupMenu.add("Sleepy");
|
||||
popupMenu.add("Happy");
|
||||
popupMenu.add("Grumpy");
|
||||
popupMenu.add("Dopey");
|
||||
|
||||
popupMenu.getAccessibleContext().setAccessibleName(ACCESSIBLE_NAME);
|
||||
popupMenu.getAccessibleContext().setAccessibleDescription(
|
||||
ACCESSIBLE_DESCRIPTION);
|
||||
|
||||
frame.add(popupMenu);
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private void dispose() throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void test() {
|
||||
AccessibleTestUtils.verifyPopupMenuAccessibility(
|
||||
popupMenu,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
}
|
||||
}
|
||||
104
test/jdk/javax/accessibility/awt/ScrollPaneTest.java
Normal file
104
test/jdk/javax/accessibility/awt/ScrollPaneTest.java
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary ScrollPane Accessibility test.
|
||||
* @library ../../swing/regtesthelpers/accessibility/
|
||||
* @build AccessibleTestUtils AccessibleComponentTester AccessibleStateSetTester
|
||||
* @run main ScrollPaneTest
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Label;
|
||||
import java.awt.Robot;
|
||||
import java.awt.ScrollPane;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class ScrollPaneTest {
|
||||
|
||||
private static ScrollPane scrollPane;
|
||||
private static Frame frame;
|
||||
|
||||
private static final String ACCESSIBLE_NAME = "ScrollPane Test";
|
||||
private static final String ACCESSIBLE_DESCRIPTION =
|
||||
"Regression Test: javax.accessibility, ScrollPane";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException, AWTException {
|
||||
ScrollPaneTest scrollPaneTest = new ScrollPaneTest();
|
||||
EventQueue.invokeAndWait(scrollPaneTest::createGUI);
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
robot.delay(5000);
|
||||
|
||||
try {
|
||||
EventQueue.invokeAndWait(scrollPaneTest::test);
|
||||
} finally {
|
||||
scrollPaneTest.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void createGUI() {
|
||||
frame = new Frame("ScrollPane Test");
|
||||
frame.setSize(300, 300);
|
||||
frame.setLocationRelativeTo(null);
|
||||
|
||||
scrollPane = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
|
||||
scrollPane.setSize(frame.getSize().width, frame.getSize().height);
|
||||
scrollPane.add(new Label("This is a label with quite a bit of text."));
|
||||
|
||||
scrollPane.getAccessibleContext().setAccessibleName(ACCESSIBLE_NAME);
|
||||
scrollPane.getAccessibleContext().setAccessibleDescription(
|
||||
ACCESSIBLE_DESCRIPTION);
|
||||
|
||||
frame.add(scrollPane);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private void dispose() throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void test() {
|
||||
AccessibleTestUtils.verifyScrollPaneAccessibility(
|
||||
scrollPane,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
|
||||
new AccessibleStateSetTester(
|
||||
scrollPane,
|
||||
scrollPane.getAccessibleContext().getAccessibleStateSet()
|
||||
).testAll();
|
||||
}
|
||||
}
|
||||
155
test/jdk/javax/accessibility/awt/TextAreaTest.java
Normal file
155
test/jdk/javax/accessibility/awt/TextAreaTest.java
Normal file
@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary TextArea Accessibility test.
|
||||
* @library ../../swing/regtesthelpers/accessibility/
|
||||
* @build AccessibleTestUtils AccessibleComponentTester AccessibleStateSetTester
|
||||
* @run main TextAreaTest
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Robot;
|
||||
import java.awt.TextArea;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import javax.accessibility.AccessibleState;
|
||||
import javax.accessibility.AccessibleStateSet;
|
||||
|
||||
public class TextAreaTest {
|
||||
|
||||
private static TextArea textArea;
|
||||
private static Frame frame;
|
||||
|
||||
private static final String ACCESSIBLE_NAME = "TextArea Test";
|
||||
private static final String ACCESSIBLE_DESCRIPTION =
|
||||
"Regression Test: javax.accessibility, TextArea";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException, AWTException {
|
||||
TextAreaTest textAreaTest = new TextAreaTest();
|
||||
EventQueue.invokeAndWait(textAreaTest::createGUI);
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
robot.delay(5000);
|
||||
|
||||
try {
|
||||
EventQueue.invokeAndWait(textAreaTest::test);
|
||||
} finally {
|
||||
textAreaTest.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void createGUI() {
|
||||
frame = new Frame("TextAreaTest");
|
||||
String TEXT_CONTENT = """
|
||||
1. Test TextArea javax.accessibility methods
|
||||
2. Test TextArea javax.accessibility setAccessibleName
|
||||
3. Test TextArea javax.accessibility setAccessibleDescription
|
||||
4. Test TextArea javax.accessibility setAccessibleStateSet
|
||||
""";
|
||||
textArea = new TextArea(TEXT_CONTENT, 24, 80);
|
||||
|
||||
textArea.getAccessibleContext().setAccessibleName(ACCESSIBLE_NAME);
|
||||
textArea.getAccessibleContext().setAccessibleDescription(
|
||||
ACCESSIBLE_DESCRIPTION);
|
||||
|
||||
frame.add(textArea);
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private void dispose() throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void test() {
|
||||
AccessibleTestUtils.verifyTextAreaAccessibility(
|
||||
textArea,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
|
||||
new TextStateTester(
|
||||
textArea,
|
||||
textArea.getAccessibleContext().getAccessibleStateSet()
|
||||
).testAll();
|
||||
|
||||
textArea.setEditable(false);
|
||||
|
||||
AccessibleTestUtils.verifyTextAreaAccessibility(
|
||||
textArea,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
|
||||
new TextStateTester(
|
||||
textArea,
|
||||
textArea.getAccessibleContext().getAccessibleStateSet()
|
||||
).testAll();
|
||||
}
|
||||
|
||||
private static final class TextStateTester
|
||||
extends AccessibleStateSetTester {
|
||||
private final TextArea textArea;
|
||||
private final AccessibleStateSet stateSet;
|
||||
|
||||
private TextStateTester(TextArea textArea,
|
||||
AccessibleStateSet stateSet) {
|
||||
super(textArea, stateSet);
|
||||
this.textArea = textArea;
|
||||
this.stateSet = stateSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testEditable() {
|
||||
if (stateSet.contains(AccessibleState.EDITABLE)) {
|
||||
if (!textArea.isEditable()) {
|
||||
throw new RuntimeException(
|
||||
"AccessibleStateSet contains EDITABLE but " +
|
||||
"this component is not editable");
|
||||
}
|
||||
} else {
|
||||
if (textArea.isEditable()) {
|
||||
throw new RuntimeException(
|
||||
"AccessibleStateSet does not contain EDITABLE " +
|
||||
"but this component is editable");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
148
test/jdk/javax/accessibility/awt/TextFieldTest.java
Normal file
148
test/jdk/javax/accessibility/awt/TextFieldTest.java
Normal file
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary TextField Accessibility test.
|
||||
* @library ../../swing/regtesthelpers/accessibility/
|
||||
* @build AccessibleTestUtils AccessibleComponentTester AccessibleStateSetTester
|
||||
* @run main TextFieldTest
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Robot;
|
||||
import java.awt.TextField;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import javax.accessibility.AccessibleState;
|
||||
import javax.accessibility.AccessibleStateSet;
|
||||
|
||||
public class TextFieldTest {
|
||||
|
||||
private static TextField textField;
|
||||
private static Frame frame;
|
||||
|
||||
private static final String ACCESSIBLE_NAME = "TextField Test";
|
||||
private static final String ACCESSIBLE_DESCRIPTION =
|
||||
"Regression Test: javax.accessibility, TextField";
|
||||
private static final String TEXT =
|
||||
"I love Cheesy Poofs you love Cheesy Poofs if we didn't " +
|
||||
"eat Cheesy Poofs we'd be lame!";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException, AWTException {
|
||||
TextFieldTest textFieldTest = new TextFieldTest();
|
||||
EventQueue.invokeAndWait(textFieldTest::createGUI);
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
robot.delay(5000);
|
||||
|
||||
try {
|
||||
EventQueue.invokeAndWait(textFieldTest::test);
|
||||
} finally {
|
||||
textFieldTest.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void createGUI() {
|
||||
frame = new Frame("TextField Test");
|
||||
textField = new TextField(TEXT, 80);
|
||||
|
||||
textField.getAccessibleContext().setAccessibleName(ACCESSIBLE_NAME);
|
||||
textField.getAccessibleContext().setAccessibleDescription(
|
||||
ACCESSIBLE_DESCRIPTION);
|
||||
|
||||
frame.add(textField);
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private void dispose() throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void test() {
|
||||
AccessibleTestUtils.verifyTextFieldAccessibility(
|
||||
textField,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
|
||||
new TextStateTester(
|
||||
textField,
|
||||
textField.getAccessibleContext().getAccessibleStateSet()
|
||||
).testAll();
|
||||
|
||||
textField.setEditable(false);
|
||||
|
||||
AccessibleTestUtils.verifyTextFieldAccessibility(
|
||||
textField,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
|
||||
new TextStateTester(
|
||||
textField,
|
||||
textField.getAccessibleContext().getAccessibleStateSet()
|
||||
).testAll();
|
||||
}
|
||||
|
||||
private static final class TextStateTester
|
||||
extends AccessibleStateSetTester {
|
||||
private final TextField textField;
|
||||
private final AccessibleStateSet set;
|
||||
|
||||
private TextStateTester(TextField textField, AccessibleStateSet set) {
|
||||
super(textField, set);
|
||||
this.textField = textField;
|
||||
this.set = set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testEditable() {
|
||||
if (set.contains(AccessibleState.EDITABLE)) {
|
||||
if (!textField.isEditable()) {
|
||||
throw new RuntimeException(
|
||||
"AccessibleStateSet contains EDITABLE but " +
|
||||
"this component is not editable");
|
||||
}
|
||||
} else {
|
||||
if (textField.isEditable()) {
|
||||
throw new RuntimeException(
|
||||
"AccessibleStateSet does not contain EDITABLE " +
|
||||
"but this component is editable");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
129
test/jdk/javax/accessibility/awt/WindowTest.java
Normal file
129
test/jdk/javax/accessibility/awt/WindowTest.java
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @summary Window Accessibility test.
|
||||
* @library ../../swing/regtesthelpers/accessibility/
|
||||
* @build AccessibleTestUtils AccessibleComponentTester AccessibleStateSetTester
|
||||
* @run main WindowTest
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Window;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import javax.accessibility.AccessibleState;
|
||||
import javax.accessibility.AccessibleStateSet;
|
||||
|
||||
public class WindowTest {
|
||||
|
||||
private static Window window;
|
||||
|
||||
private static final String ACCESSIBLE_NAME = "Window Test";
|
||||
private static final String ACCESSIBLE_DESCRIPTION =
|
||||
"Regression Test: javax.accessibility, Window";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException, AWTException {
|
||||
WindowTest windowTest = new WindowTest();
|
||||
EventQueue.invokeAndWait(windowTest::createGUI);
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
robot.delay(5000);
|
||||
|
||||
try {
|
||||
EventQueue.invokeAndWait(windowTest::test);
|
||||
} finally {
|
||||
windowTest.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void createGUI() {
|
||||
window = new Window(new Frame("Frame"));
|
||||
window.setSize(300, 300);
|
||||
window.setLocationRelativeTo(null);
|
||||
|
||||
window.getAccessibleContext().setAccessibleName(ACCESSIBLE_NAME);
|
||||
window.getAccessibleContext().setAccessibleDescription(
|
||||
ACCESSIBLE_DESCRIPTION);
|
||||
|
||||
window.setVisible(true);
|
||||
}
|
||||
|
||||
private void dispose() throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
if (window != null) {
|
||||
window.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void test() {
|
||||
AccessibleTestUtils.verifyWindowAccessibility(
|
||||
window,
|
||||
ACCESSIBLE_NAME,
|
||||
ACCESSIBLE_DESCRIPTION
|
||||
);
|
||||
|
||||
new WindowStateTester(
|
||||
window,
|
||||
window.getAccessibleContext().getAccessibleStateSet()
|
||||
).testAll();
|
||||
}
|
||||
|
||||
private static final class WindowStateTester
|
||||
extends AccessibleStateSetTester {
|
||||
private final Window window;
|
||||
private final AccessibleStateSet set;
|
||||
|
||||
private WindowStateTester(Window window, AccessibleStateSet set) {
|
||||
super(window, set);
|
||||
this.window = window;
|
||||
this.set = set;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testActive() {
|
||||
if (set.contains(AccessibleState.ACTIVE)) {
|
||||
if (window.getFocusOwner() == null) {
|
||||
throw new RuntimeException(
|
||||
"AccessibleStateSet contains ACTIVE but " +
|
||||
"this component is not active");
|
||||
}
|
||||
} else {
|
||||
if (window.getFocusOwner() != null) {
|
||||
throw new RuntimeException(
|
||||
"AccessibleStateSet does not contain ACTIVE " +
|
||||
"but this component is active");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.MenuComponent;
|
||||
|
||||
import javax.accessibility.AccessibleComponent;
|
||||
|
||||
public class AccessibleMenuComponentTester {
|
||||
|
||||
private final AccessibleComponent acomp;
|
||||
private final MenuComponent comp;
|
||||
|
||||
public AccessibleMenuComponentTester(MenuComponent menuComponent,
|
||||
AccessibleComponent ac) {
|
||||
if (menuComponent == null) {
|
||||
throw new RuntimeException("MenuComponent should not be null");
|
||||
}
|
||||
|
||||
if (ac == null) {
|
||||
throw new RuntimeException("AccessibleComponent should not be null");
|
||||
}
|
||||
|
||||
this.comp = menuComponent;
|
||||
this.acomp = ac;
|
||||
}
|
||||
|
||||
// The only method supported by MenuComponents is getFont(). Everything
|
||||
// else should return null.
|
||||
public void test() {
|
||||
testGetBackground();
|
||||
testGetBounds();
|
||||
testGetCursor();
|
||||
testGetFont();
|
||||
testGetForeground();
|
||||
testGetLocation();
|
||||
testGetLocationOnScreen();
|
||||
testGetSize();
|
||||
testIsEnabled();
|
||||
testIsFocusTraversable();
|
||||
testIsShowing();
|
||||
testIsVisible();
|
||||
}
|
||||
|
||||
public void testGetBackground() {
|
||||
}
|
||||
|
||||
public void testGetBounds() {
|
||||
}
|
||||
|
||||
public void testGetCursor() {
|
||||
}
|
||||
|
||||
public void testGetFont() {
|
||||
Font accessibleFont = acomp.getFont();
|
||||
Font componentFont = comp.getFont();
|
||||
|
||||
if (componentFont == null) {
|
||||
if (accessibleFont != null) {
|
||||
throw new RuntimeException(
|
||||
"MenuComponent.getFont returned null but " +
|
||||
"AccessibleComponent.getFont did not");
|
||||
}
|
||||
} else if (!componentFont.equals(accessibleFont)) {
|
||||
throw new RuntimeException(
|
||||
"AccessibleComponent.getFont does not match " +
|
||||
"MenuComponent.getFont");
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetForeground() {
|
||||
}
|
||||
|
||||
public void testGetLocation() {
|
||||
}
|
||||
|
||||
public void testGetLocationOnScreen() {
|
||||
}
|
||||
|
||||
public void testGetSize() {
|
||||
}
|
||||
|
||||
public void testIsEnabled() {
|
||||
}
|
||||
|
||||
public void testIsFocusTraversable() {
|
||||
}
|
||||
|
||||
public void testIsShowing() {
|
||||
}
|
||||
|
||||
public void testIsVisible() {
|
||||
}
|
||||
}
|
||||
@ -22,17 +22,33 @@
|
||||
*/
|
||||
|
||||
import java.awt.Button;
|
||||
import java.awt.Checkbox;
|
||||
import java.awt.Choice;
|
||||
import java.awt.Component;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Label;
|
||||
import java.awt.List;
|
||||
import java.awt.Menu;
|
||||
import java.awt.MenuBar;
|
||||
import java.awt.MenuComponent;
|
||||
import java.awt.MenuItem;
|
||||
import java.awt.Panel;
|
||||
import java.awt.PopupMenu;
|
||||
import java.awt.Scrollbar;
|
||||
import java.awt.ScrollPane;
|
||||
import java.awt.TextArea;
|
||||
import java.awt.TextField;
|
||||
import java.awt.Window;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.accessibility.Accessible;
|
||||
import javax.accessibility.AccessibleAction;
|
||||
import javax.accessibility.AccessibleComponent;
|
||||
import javax.accessibility.AccessibleContext;
|
||||
import javax.accessibility.AccessibleRole;
|
||||
import javax.accessibility.AccessibleSelection;
|
||||
import javax.accessibility.AccessibleState;
|
||||
import javax.accessibility.AccessibleStateSet;
|
||||
import javax.accessibility.AccessibleText;
|
||||
import javax.accessibility.AccessibleValue;
|
||||
@ -51,32 +67,22 @@ public final class AccessibleTestUtils {
|
||||
boolean expectSelection,
|
||||
boolean expectText,
|
||||
boolean expectValue) {
|
||||
|
||||
Objects.requireNonNull(context, "AccessibleContext must not be null");
|
||||
|
||||
assertExpectedString(
|
||||
"getAccessibleName",
|
||||
expectedName,
|
||||
context.getAccessibleName()
|
||||
);
|
||||
assertExpectedString("getAccessibleName",
|
||||
expectedName, context.getAccessibleName());
|
||||
assertExpectedString("getAccessibleDescription",
|
||||
expectedDescription, context.getAccessibleDescription());
|
||||
|
||||
assertExpectedString(
|
||||
"getAccessibleDescription",
|
||||
expectedDescription,
|
||||
context.getAccessibleDescription()
|
||||
);
|
||||
AccessibleRole actualRole = context.getAccessibleRole();
|
||||
if (actualRole == null) {
|
||||
throw new RuntimeException("getAccessibleRole returned null");
|
||||
}
|
||||
|
||||
if (expectedRole != null) {
|
||||
AccessibleRole actualRole = context.getAccessibleRole();
|
||||
if (actualRole == null) {
|
||||
throw new RuntimeException("getAccessibleRole returned null");
|
||||
}
|
||||
if (!expectedRole.equals(actualRole)) {
|
||||
throw new RuntimeException(String.format(
|
||||
"getAccessibleRole returned [%s]; expected [%s]",
|
||||
actualRole, expectedRole
|
||||
));
|
||||
}
|
||||
if (!expectedRole.equals(actualRole)) {
|
||||
throw new RuntimeException(
|
||||
"getAccessibleRole returned [" + actualRole +
|
||||
"]; expected [" + expectedRole + "]");
|
||||
}
|
||||
|
||||
AccessibleStateSet stateSet = context.getAccessibleStateSet();
|
||||
@ -84,10 +90,14 @@ public final class AccessibleTestUtils {
|
||||
throw new RuntimeException("getAccessibleStateSet returned null");
|
||||
}
|
||||
|
||||
assertPresence("getAccessibleAction", expectAction, context.getAccessibleAction());
|
||||
assertPresence("getAccessibleSelection", expectSelection, context.getAccessibleSelection());
|
||||
assertPresence("getAccessibleText", expectText, context.getAccessibleText());
|
||||
assertPresence("getAccessibleValue", expectValue, context.getAccessibleValue());
|
||||
assertPresence("getAccessibleAction",
|
||||
expectAction, context.getAccessibleAction());
|
||||
assertPresence("getAccessibleSelection",
|
||||
expectSelection, context.getAccessibleSelection());
|
||||
assertPresence("getAccessibleText",
|
||||
expectText, context.getAccessibleText());
|
||||
assertPresence("getAccessibleValue",
|
||||
expectValue, context.getAccessibleValue());
|
||||
}
|
||||
|
||||
public static void verifyAWTComponentAccessibility(
|
||||
@ -99,10 +109,13 @@ public final class AccessibleTestUtils {
|
||||
boolean expectSelection,
|
||||
boolean expectText,
|
||||
boolean expectValue) {
|
||||
|
||||
Objects.requireNonNull(component, "Component under test must not be null");
|
||||
Objects.requireNonNull(component, "Component must not be null");
|
||||
|
||||
AccessibleContext context = component.getAccessibleContext();
|
||||
if (context == null) {
|
||||
throw new RuntimeException("getAccessibleContext returned null");
|
||||
}
|
||||
|
||||
verifyAccessibleContextCommon(
|
||||
context,
|
||||
expectedName,
|
||||
@ -111,12 +124,12 @@ public final class AccessibleTestUtils {
|
||||
expectAction,
|
||||
expectSelection,
|
||||
expectText,
|
||||
expectValue
|
||||
);
|
||||
expectValue);
|
||||
|
||||
assertLocaleMatches(component, context);
|
||||
|
||||
AccessibleComponent accessibleComponent = context.getAccessibleComponent();
|
||||
AccessibleComponent accessibleComponent =
|
||||
context.getAccessibleComponent();
|
||||
if (accessibleComponent == null) {
|
||||
throw new RuntimeException("getAccessibleComponent returned null");
|
||||
}
|
||||
@ -124,101 +137,10 @@ public final class AccessibleTestUtils {
|
||||
new AccessibleComponentTester(component, accessibleComponent).test();
|
||||
}
|
||||
|
||||
public static void verifyChoiceAccessibility(
|
||||
Choice choice,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
|
||||
Objects.requireNonNull(choice, "Choice must not be null");
|
||||
|
||||
verifyAWTComponentAccessibility(
|
||||
choice,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
AccessibleRole.COMBO_BOX,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
AccessibleContext context = choice.getAccessibleContext();
|
||||
|
||||
AccessibleAction action = context.getAccessibleAction();
|
||||
if (action == null) {
|
||||
throw new RuntimeException("getAccessibleAction should not return null for Choice");
|
||||
}
|
||||
|
||||
AccessibleValue value = context.getAccessibleValue();
|
||||
if (value != null) {
|
||||
throw new RuntimeException("getAccessibleValue should return null for Choice");
|
||||
}
|
||||
}
|
||||
|
||||
public static void verifyScrollbarAccessibility(
|
||||
Scrollbar scrollbar,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
|
||||
Objects.requireNonNull(scrollbar, "Scrollbar must not be null");
|
||||
|
||||
verifyAWTComponentAccessibility(
|
||||
scrollbar,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
AccessibleRole.SCROLL_BAR,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
AccessibleValue value = scrollbar.getAccessibleContext().getAccessibleValue();
|
||||
if (value == null) {
|
||||
throw new RuntimeException("getAccessibleValue should not return null for Scrollbar");
|
||||
}
|
||||
|
||||
assertIntValueEquals(
|
||||
"getCurrentAccessibleValue",
|
||||
scrollbar.getValue(),
|
||||
value.getCurrentAccessibleValue()
|
||||
);
|
||||
|
||||
assertIntValueEquals(
|
||||
"getMinimumAccessibleValue",
|
||||
scrollbar.getMinimum(),
|
||||
value.getMinimumAccessibleValue()
|
||||
);
|
||||
|
||||
assertIntValueEquals(
|
||||
"getMaximumAccessibleValue",
|
||||
scrollbar.getMaximum(),
|
||||
value.getMaximumAccessibleValue()
|
||||
);
|
||||
|
||||
if (!value.setCurrentAccessibleValue(Integer.valueOf(5))) {
|
||||
throw new RuntimeException("setCurrentAccessibleValue(5) returned false for Scrollbar");
|
||||
}
|
||||
|
||||
assertIntValueEquals(
|
||||
"getCurrentAccessibleValue after setCurrentAccessibleValue(5)",
|
||||
5,
|
||||
value.getCurrentAccessibleValue()
|
||||
);
|
||||
|
||||
if (scrollbar.getValue() != 5) {
|
||||
throw new RuntimeException(
|
||||
"setCurrentAccessibleValue(5) did not update Scrollbar.getValue(); actual value: "
|
||||
+ scrollbar.getValue()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static void verifyButtonAccessibility(
|
||||
Button button,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
|
||||
Objects.requireNonNull(button, "Button must not be null");
|
||||
|
||||
verifyAWTComponentAccessibility(
|
||||
@ -229,106 +151,576 @@ public final class AccessibleTestUtils {
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
true
|
||||
);
|
||||
true);
|
||||
|
||||
AccessibleContext context = button.getAccessibleContext();
|
||||
verifyClickAction(context, "Button");
|
||||
verifyZeroAccessibleValue(context, "Button");
|
||||
}
|
||||
|
||||
public static void verifyCheckboxAccessibility(
|
||||
Checkbox checkbox,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
Objects.requireNonNull(checkbox, "Checkbox must not be null");
|
||||
|
||||
verifyAWTComponentAccessibility(
|
||||
checkbox,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
AccessibleRole.CHECK_BOX,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
true);
|
||||
}
|
||||
|
||||
public static void verifyChoiceAccessibility(
|
||||
Choice choice,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
Objects.requireNonNull(choice, "Choice must not be null");
|
||||
|
||||
verifyAWTComponentAccessibility(
|
||||
choice,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
AccessibleRole.COMBO_BOX,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
}
|
||||
|
||||
public static void verifyFrameAccessibility(
|
||||
Frame frame,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
Objects.requireNonNull(frame, "Frame must not be null");
|
||||
|
||||
verifyAWTComponentAccessibility(
|
||||
frame,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
AccessibleRole.FRAME,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
}
|
||||
|
||||
public static void verifyLabelAccessibility(
|
||||
Label label,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
Objects.requireNonNull(label, "Label must not be null");
|
||||
|
||||
verifyAWTComponentAccessibility(
|
||||
label,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
AccessibleRole.LABEL,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
}
|
||||
|
||||
public static void verifyListAccessibility(
|
||||
List list,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
Objects.requireNonNull(list, "List must not be null");
|
||||
|
||||
verifyAWTComponentAccessibility(
|
||||
list,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
AccessibleRole.LIST,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false);
|
||||
|
||||
verifyListChildren(list);
|
||||
}
|
||||
|
||||
public static void verifyPanelAccessibility(
|
||||
Panel panel,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
Objects.requireNonNull(panel, "Panel must not be null");
|
||||
|
||||
verifyAWTComponentAccessibility(
|
||||
panel,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
AccessibleRole.PANEL,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
|
||||
verifyContainerChildren(panel, "Panel");
|
||||
}
|
||||
|
||||
public static void verifyScrollbarAccessibility(
|
||||
Scrollbar scrollbar,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
Objects.requireNonNull(scrollbar, "Scrollbar must not be null");
|
||||
|
||||
verifyAWTComponentAccessibility(
|
||||
scrollbar,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
AccessibleRole.SCROLL_BAR,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true);
|
||||
|
||||
AccessibleValue value =
|
||||
scrollbar.getAccessibleContext().getAccessibleValue();
|
||||
|
||||
assertIntValueEquals(
|
||||
"getCurrentAccessibleValue",
|
||||
scrollbar.getValue(),
|
||||
value.getCurrentAccessibleValue());
|
||||
|
||||
assertIntValueEquals(
|
||||
"getMinimumAccessibleValue",
|
||||
scrollbar.getMinimum(),
|
||||
value.getMinimumAccessibleValue());
|
||||
|
||||
assertIntValueEquals(
|
||||
"getMaximumAccessibleValue",
|
||||
scrollbar.getMaximum(),
|
||||
value.getMaximumAccessibleValue());
|
||||
|
||||
if (!value.setCurrentAccessibleValue(Integer.valueOf(5))) {
|
||||
throw new RuntimeException(
|
||||
"setCurrentAccessibleValue should not return false " +
|
||||
"for Scrollbar");
|
||||
}
|
||||
|
||||
assertIntValueEquals(
|
||||
"getCurrentAccessibleValue after setCurrentAccessibleValue(5)",
|
||||
5,
|
||||
value.getCurrentAccessibleValue());
|
||||
|
||||
if (scrollbar.getValue() != 5) {
|
||||
throw new RuntimeException(
|
||||
"setCurrentAccessibleValue should change the Scrollbar " +
|
||||
"value");
|
||||
}
|
||||
}
|
||||
|
||||
public static void verifyScrollPaneAccessibility(
|
||||
ScrollPane scrollPane,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
Objects.requireNonNull(scrollPane, "ScrollPane must not be null");
|
||||
|
||||
verifyAWTComponentAccessibility(
|
||||
scrollPane,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
AccessibleRole.SCROLL_PANE,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
}
|
||||
|
||||
public static void verifyTextAreaAccessibility(
|
||||
TextArea textArea,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
Objects.requireNonNull(textArea, "TextArea must not be null");
|
||||
|
||||
verifyAWTComponentAccessibility(
|
||||
textArea,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
AccessibleRole.TEXT,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
false);
|
||||
}
|
||||
|
||||
public static void verifyTextFieldAccessibility(
|
||||
TextField textField,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
Objects.requireNonNull(textField, "TextField must not be null");
|
||||
|
||||
verifyAWTComponentAccessibility(
|
||||
textField,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
AccessibleRole.TEXT,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
false);
|
||||
}
|
||||
|
||||
public static void verifyWindowAccessibility(
|
||||
Window window,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
Objects.requireNonNull(window, "Window must not be null");
|
||||
|
||||
verifyAWTComponentAccessibility(
|
||||
window,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
AccessibleRole.WINDOW,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
}
|
||||
|
||||
public static void verifyMenuAccessibility(
|
||||
Menu menu,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
Objects.requireNonNull(menu, "Menu must not be null");
|
||||
|
||||
verifyMenuComponentAccessibility(
|
||||
menu,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
AccessibleRole.MENU,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
"Menu");
|
||||
|
||||
AccessibleContext context = menu.getAccessibleContext();
|
||||
verifyClickAction(context, "Menu");
|
||||
verifyZeroAccessibleValue(context, "Menu");
|
||||
}
|
||||
|
||||
public static void verifyMenuBarAccessibility(
|
||||
MenuBar menuBar,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
Objects.requireNonNull(menuBar, "MenuBar must not be null");
|
||||
|
||||
verifyMenuComponentAccessibility(
|
||||
menuBar,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
AccessibleRole.MENU_BAR,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
"MenuBar");
|
||||
}
|
||||
|
||||
public static void verifyMenuItemAccessibility(
|
||||
MenuItem menuItem,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
Objects.requireNonNull(menuItem, "MenuItem must not be null");
|
||||
|
||||
verifyMenuComponentAccessibility(
|
||||
menuItem,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
AccessibleRole.MENU_ITEM,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
"MenuItem");
|
||||
|
||||
AccessibleContext context = menuItem.getAccessibleContext();
|
||||
verifyClickAction(context, "MenuItem");
|
||||
verifyZeroAccessibleValue(context, "MenuItem");
|
||||
}
|
||||
|
||||
public static void verifyPopupMenuAccessibility(
|
||||
PopupMenu popupMenu,
|
||||
String expectedName,
|
||||
String expectedDescription) {
|
||||
Objects.requireNonNull(popupMenu, "PopupMenu must not be null");
|
||||
|
||||
verifyMenuComponentAccessibility(
|
||||
popupMenu,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
AccessibleRole.POPUP_MENU,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
"PopupMenu");
|
||||
|
||||
AccessibleContext context = popupMenu.getAccessibleContext();
|
||||
verifyClickAction(context, "PopupMenu");
|
||||
verifyZeroAccessibleValue(context, "PopupMenu");
|
||||
}
|
||||
|
||||
private static void verifyMenuComponentAccessibility(
|
||||
MenuComponent menuComponent,
|
||||
String expectedName,
|
||||
String expectedDescription,
|
||||
AccessibleRole expectedRole,
|
||||
boolean expectAction,
|
||||
boolean expectSelection,
|
||||
boolean expectText,
|
||||
boolean expectValue,
|
||||
String componentName) {
|
||||
Objects.requireNonNull(menuComponent,
|
||||
componentName + " must not be null");
|
||||
|
||||
AccessibleContext context = menuComponent.getAccessibleContext();
|
||||
if (context == null) {
|
||||
throw new RuntimeException("getAccessibleContext returned null");
|
||||
}
|
||||
|
||||
verifyAccessibleContextCommon(
|
||||
context,
|
||||
expectedName,
|
||||
expectedDescription,
|
||||
expectedRole,
|
||||
expectAction,
|
||||
expectSelection,
|
||||
expectText,
|
||||
expectValue);
|
||||
|
||||
AccessibleComponent accessibleComponent =
|
||||
context.getAccessibleComponent();
|
||||
if (accessibleComponent == null) {
|
||||
throw new RuntimeException("getAccessibleComponent returned null");
|
||||
}
|
||||
|
||||
new AccessibleMenuComponentTester(
|
||||
menuComponent, accessibleComponent).test();
|
||||
}
|
||||
|
||||
private static void verifyClickAction(AccessibleContext context,
|
||||
String componentName) {
|
||||
AccessibleAction action = context.getAccessibleAction();
|
||||
if (action == null) {
|
||||
throw new RuntimeException("getAccessibleAction should not return null for Button");
|
||||
throw new RuntimeException(
|
||||
"getAccessibleAction should not return null for " +
|
||||
componentName);
|
||||
}
|
||||
|
||||
int actionCount = action.getAccessibleActionCount();
|
||||
if (actionCount != 1) {
|
||||
throw new RuntimeException(
|
||||
"getAccessibleActionCount should return 1 for Button; got " + actionCount
|
||||
);
|
||||
"getAccessibleActionCount returned the wrong number for " +
|
||||
componentName);
|
||||
}
|
||||
|
||||
String actionDescription = action.getAccessibleActionDescription(0);
|
||||
if (!"click".equals(actionDescription)) {
|
||||
throw new RuntimeException(
|
||||
"getAccessibleActionDescription(0) should return \"click\" for Button; got ["
|
||||
+ actionDescription + "]"
|
||||
);
|
||||
"getAccessibleActionDescription returned the wrong " +
|
||||
"description for " + componentName);
|
||||
}
|
||||
}
|
||||
|
||||
private static void verifyZeroAccessibleValue(AccessibleContext context,
|
||||
String componentName) {
|
||||
AccessibleValue value = context.getAccessibleValue();
|
||||
if (value == null) {
|
||||
throw new RuntimeException("getAccessibleValue should not return null for Button");
|
||||
throw new RuntimeException(
|
||||
"getAccessibleValue should not return null for " +
|
||||
componentName);
|
||||
}
|
||||
|
||||
assertIntValueEquals("getCurrentAccessibleValue", 0, value.getCurrentAccessibleValue());
|
||||
assertIntValueEquals("getMinimumAccessibleValue", 0, value.getMinimumAccessibleValue());
|
||||
assertIntValueEquals("getMaximumAccessibleValue", 0, value.getMaximumAccessibleValue());
|
||||
assertIntValueEquals(
|
||||
"getCurrentAccessibleValue",
|
||||
0,
|
||||
value.getCurrentAccessibleValue());
|
||||
|
||||
assertIntValueEquals(
|
||||
"getMinimumAccessibleValue",
|
||||
0,
|
||||
value.getMinimumAccessibleValue());
|
||||
|
||||
assertIntValueEquals(
|
||||
"getMaximumAccessibleValue",
|
||||
0,
|
||||
value.getMaximumAccessibleValue());
|
||||
|
||||
if (value.setCurrentAccessibleValue(Integer.valueOf(5))) {
|
||||
throw new RuntimeException(
|
||||
"setCurrentAccessibleValue(5) should return false for Button"
|
||||
);
|
||||
"setCurrentAccessibleValue should return false for " +
|
||||
componentName);
|
||||
}
|
||||
|
||||
assertIntValueEquals(
|
||||
"getCurrentAccessibleValue after setCurrentAccessibleValue(5)",
|
||||
0,
|
||||
value.getCurrentAccessibleValue()
|
||||
);
|
||||
value.getCurrentAccessibleValue());
|
||||
}
|
||||
|
||||
private static void assertExpectedString(String methodName, String expected, String actual) {
|
||||
private static void verifyListChildren(List list) {
|
||||
AccessibleContext context = list.getAccessibleContext();
|
||||
|
||||
int childCount = context.getAccessibleChildrenCount();
|
||||
if (childCount != list.getItemCount()) {
|
||||
throw new RuntimeException(
|
||||
"getAccessibleChildrenCount returned an incorrect value " +
|
||||
"for List");
|
||||
}
|
||||
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
Accessible child = context.getAccessibleChild(i);
|
||||
if (child == null) {
|
||||
throw new RuntimeException(
|
||||
"getAccessibleChild returned null for child " + i);
|
||||
}
|
||||
|
||||
AccessibleContext childContext = child.getAccessibleContext();
|
||||
if (childContext == null) {
|
||||
throw new RuntimeException(
|
||||
"getAccessibleContext returned null for List child " +
|
||||
i);
|
||||
}
|
||||
|
||||
if (childContext.getAccessibleRole() != AccessibleRole.LIST_ITEM) {
|
||||
throw new RuntimeException(
|
||||
"The AccessibleRole of AccessibleAWTListChild is " +
|
||||
"incorrect for child " + i);
|
||||
}
|
||||
|
||||
if (childContext.getAccessibleIndexInParent() != i) {
|
||||
throw new RuntimeException(
|
||||
"getAccessibleIndexInParent returned an incorrect " +
|
||||
"value for AccessibleAWTListChild " + i);
|
||||
}
|
||||
|
||||
AccessibleStateSet childStateSet =
|
||||
childContext.getAccessibleStateSet();
|
||||
if (childStateSet == null) {
|
||||
throw new RuntimeException(
|
||||
"getAccessibleStateSet returned null for List child " +
|
||||
i);
|
||||
}
|
||||
|
||||
boolean accessibleSelected =
|
||||
childStateSet.contains(AccessibleState.SELECTED);
|
||||
boolean listSelected = list.isIndexSelected(i);
|
||||
|
||||
if (accessibleSelected != listSelected) {
|
||||
throw new RuntimeException(
|
||||
"getAccessibleStateSet reports that list item " + i +
|
||||
(accessibleSelected ? " is " : " is not ") +
|
||||
"selected but List reports that it " +
|
||||
(listSelected ? "is" : "is not") + " selected");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void verifyContainerChildren(Component component,
|
||||
String componentName) {
|
||||
AccessibleContext context = component.getAccessibleContext();
|
||||
|
||||
int childCount = context.getAccessibleChildrenCount();
|
||||
if (childCount != component.getAccessibleContext()
|
||||
.getAccessibleChildrenCount()) {
|
||||
throw new RuntimeException(
|
||||
"getAccessibleChildrenCount returned an incorrect value " +
|
||||
"for " + componentName);
|
||||
}
|
||||
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
Accessible child = context.getAccessibleChild(i);
|
||||
if (child == null) {
|
||||
throw new RuntimeException(
|
||||
"getAccessibleChild returned null for " +
|
||||
componentName + " child " + i);
|
||||
}
|
||||
|
||||
AccessibleContext childContext = child.getAccessibleContext();
|
||||
if (childContext == null) {
|
||||
throw new RuntimeException(
|
||||
"getAccessibleContext returned null for " +
|
||||
componentName + " child " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void assertExpectedString(String methodName,
|
||||
String expected,
|
||||
String actual) {
|
||||
if (expected == null) {
|
||||
throw new RuntimeException("Excepted value is null. Provide " +
|
||||
"excepted value");
|
||||
throw new RuntimeException(
|
||||
"Expected value for " + methodName + " should not be null");
|
||||
}
|
||||
|
||||
if (actual == null) {
|
||||
throw new RuntimeException(methodName + " returned null; expected" +
|
||||
" [" + expected + "]");
|
||||
throw new RuntimeException(
|
||||
methodName + " returned null; expected [" + expected + "]");
|
||||
}
|
||||
|
||||
if (!expected.equals(actual)) {
|
||||
throw new RuntimeException(methodName + " returned [" + actual +
|
||||
"]; expected [" + expected + "]");
|
||||
throw new RuntimeException(
|
||||
methodName + " returned [" + actual +
|
||||
"]; expected [" + expected + "]");
|
||||
}
|
||||
}
|
||||
|
||||
private static void assertPresence(String methodName, boolean expectedPresent, Object value) {
|
||||
private static void assertPresence(String methodName,
|
||||
boolean expectedPresent,
|
||||
Object value) {
|
||||
if (expectedPresent && value == null) {
|
||||
throw new RuntimeException(methodName + " returned null but was expected");
|
||||
throw new RuntimeException(
|
||||
methodName + " returned null but should not");
|
||||
}
|
||||
|
||||
if (!expectedPresent && value != null) {
|
||||
throw new RuntimeException(methodName + " returned non-null but " +
|
||||
"was expected to be null");
|
||||
throw new RuntimeException(
|
||||
methodName + " returned non-null but should return null");
|
||||
}
|
||||
}
|
||||
|
||||
private static void assertLocaleMatches(Component component, AccessibleContext context) {
|
||||
private static void assertLocaleMatches(Component component,
|
||||
AccessibleContext context) {
|
||||
Locale componentLocale = component.getLocale();
|
||||
Locale accessibleLocale = context.getLocale();
|
||||
|
||||
if (componentLocale == null) {
|
||||
throw new RuntimeException("Component.getLocale returned null");
|
||||
}
|
||||
|
||||
if (accessibleLocale == null) {
|
||||
throw new RuntimeException("AccessibleContext.getLocale returned null");
|
||||
throw new RuntimeException(
|
||||
"AccessibleContext.getLocale returned null");
|
||||
}
|
||||
|
||||
if (!componentLocale.equals(accessibleLocale)) {
|
||||
throw new RuntimeException(String.format(
|
||||
"AccessibleContext.getLocale returned [%s], but Component" +
|
||||
".getLocale returned [%s]",
|
||||
accessibleLocale, componentLocale
|
||||
));
|
||||
throw new RuntimeException(
|
||||
"AccessibleContext.getLocale returned [" +
|
||||
accessibleLocale + "], but Component.getLocale returned [" +
|
||||
componentLocale + "]");
|
||||
}
|
||||
}
|
||||
|
||||
private static void assertIntValueEquals(String methodName, int expected, Number actual) {
|
||||
private static void assertIntValueEquals(String methodName,
|
||||
int expected,
|
||||
Number actual) {
|
||||
if (actual == null) {
|
||||
throw new RuntimeException(methodName + " returned null; expected [" + expected + "]");
|
||||
throw new RuntimeException(
|
||||
methodName + " returned null; expected [" + expected + "]");
|
||||
}
|
||||
|
||||
if (actual.intValue() != expected) {
|
||||
throw new RuntimeException(
|
||||
methodName + " returned [" + actual + "]; expected [" + expected + "]"
|
||||
);
|
||||
methodName + " returned [" + actual +
|
||||
"]; expected [" + expected + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user