undefect. CWE-407 — 63 sites patched across 27 ecosystems
Authors: russell@unturf.com · brackishbert@gmail.com · foxhop.net · TimeHexOn.com Patches, unit tests, benchmarks, whitepaper, and outreach briefs. Public domain — no copyright claimed. Use freely.
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2022, 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
|
||||
* @bug 4170173
|
||||
* @summary AccessibleJTextComponent.getAfterIndex works incorrectly
|
||||
* @run main AccessibleJTextAfterIndexTest
|
||||
*/
|
||||
|
||||
import javax.accessibility.AccessibleText;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public class AccessibleJTextAfterIndexTest {
|
||||
|
||||
public static void doTest() {
|
||||
JTextField jTextField =
|
||||
new JTextField("Test1 Test2 Test3. Test4 Test5. Test6");
|
||||
JTextArea jTextArea = new JTextArea("Test1 Test2 Test3.\nTest4 Test5");
|
||||
JEditorPane jEditorPane =
|
||||
new JEditorPane("text/plain", "Test1 Test2 Test3.\nTest4 Test5");
|
||||
|
||||
String actualAccessibleText = jTextField.getAccessibleContext()
|
||||
.getAccessibleText().getAfterIndex(AccessibleText.CHARACTER, 5);
|
||||
if (!(actualAccessibleText.equals("T"))) {
|
||||
throw new RuntimeException(
|
||||
"JTextField -" + "getAfterIndex() CHARACTER parameter"
|
||||
+ " expected:--T--, actual:--" + actualAccessibleText + "--");
|
||||
}
|
||||
|
||||
actualAccessibleText = jTextField.getAccessibleContext()
|
||||
.getAccessibleText().getAfterIndex(AccessibleText.WORD, 5);
|
||||
if (!(actualAccessibleText.equals("Test2"))) {
|
||||
throw new RuntimeException(
|
||||
"JTextField - " + "getAfterIndex() WORD parameter"
|
||||
+ " expected:--Test2--, actual:--" + actualAccessibleText + "--");
|
||||
}
|
||||
|
||||
actualAccessibleText = jTextField.getAccessibleContext()
|
||||
.getAccessibleText().getAfterIndex(AccessibleText.SENTENCE, 5);
|
||||
if (!(actualAccessibleText.equals("Test4 Test5. "))) {
|
||||
throw new RuntimeException("JTextField - "
|
||||
+ "getAfterIndex() SENTENCE parameter"
|
||||
+ " expected:--Test4 Test5. --, actual:--" + actualAccessibleText + "--");
|
||||
}
|
||||
|
||||
actualAccessibleText = jTextArea.getAccessibleContext()
|
||||
.getAccessibleText().getAfterIndex(AccessibleText.CHARACTER, 5);
|
||||
if (!(actualAccessibleText.equals("T"))) {
|
||||
throw new RuntimeException(
|
||||
"JTextArea - " + "getAfterIndex() CHARACTER parameter"
|
||||
+ " expected:--T--, actual:--" + actualAccessibleText + "--");
|
||||
}
|
||||
|
||||
actualAccessibleText = jTextArea.getAccessibleContext()
|
||||
.getAccessibleText().getAfterIndex(AccessibleText.WORD, 5);
|
||||
if (!(actualAccessibleText.equals("Test2"))) {
|
||||
throw new RuntimeException(
|
||||
"JTextArea - " + "getAfterIndex() WORD parameter"
|
||||
+ " expected:--Test2--, actual:--" + actualAccessibleText + "--");
|
||||
}
|
||||
|
||||
actualAccessibleText = jTextArea.getAccessibleContext()
|
||||
.getAccessibleText().getAfterIndex(AccessibleText.SENTENCE, 5);
|
||||
if (!(actualAccessibleText.equals("Test4 Test5\n"))) {
|
||||
throw new RuntimeException("JTextArea - "
|
||||
+ "getAfterIndex() SENTENCE parameter"
|
||||
+ " expected:--Test4 Test5\n--, actual:--" + actualAccessibleText + "--");
|
||||
}
|
||||
|
||||
actualAccessibleText = jEditorPane.getAccessibleContext()
|
||||
.getAccessibleText().getAfterIndex(AccessibleText.CHARACTER, 5);
|
||||
if (!(actualAccessibleText.equals("T"))) {
|
||||
throw new RuntimeException(
|
||||
"JEditorPane - " + "getAfterIndex() CHARACTER parameter"
|
||||
+ " expected:--T--, actual:--" + actualAccessibleText +"--");
|
||||
}
|
||||
|
||||
actualAccessibleText = jEditorPane.getAccessibleContext()
|
||||
.getAccessibleText().getAfterIndex(AccessibleText.WORD, 5);
|
||||
if (!(actualAccessibleText.equals("Test2"))) {
|
||||
throw new RuntimeException(
|
||||
"JEditorPane - " + "getAfterIndex() WORD parameter"
|
||||
+ " expected:--Test2--, actual:--" + actualAccessibleText + "--");
|
||||
}
|
||||
|
||||
actualAccessibleText = jEditorPane.getAccessibleContext()
|
||||
.getAccessibleText().getAfterIndex(AccessibleText.SENTENCE, 5);
|
||||
if (!(actualAccessibleText.equals("Test4 Test5\n"))) {
|
||||
throw new RuntimeException("JEditorPane - "
|
||||
+ "getAfterIndex() Sentence parameter"
|
||||
+ " expected:--Test4 Test5\n--, actual:--" + actualAccessibleText +"--");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeAndWait(() -> doTest());
|
||||
System.out.println("Test Passed");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2022, 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
|
||||
* @bug 4170173
|
||||
* @summary AccessibleJTextComponent.getBeforeIndex works incorrectly
|
||||
* @run main AccessibleJTextBeforeIndexTest
|
||||
*/
|
||||
|
||||
import javax.accessibility.AccessibleText;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public class AccessibleJTextBeforeIndexTest {
|
||||
|
||||
public static void doTest() {
|
||||
JTextField jTextField =
|
||||
new JTextField("Test1 Test2 Test3. Test4 Test5. Test6");
|
||||
JTextArea jTextArea = new JTextArea("Test1 Test2 Test3.\nTest4 Test5");
|
||||
JEditorPane jEditorPane =
|
||||
new JEditorPane("text/plain", "Test1 Test2 Test3.\nTest4 Test5");
|
||||
|
||||
String actualAccessibleText = jTextField.getAccessibleContext()
|
||||
.getAccessibleText().getBeforeIndex(AccessibleText.CHARACTER, 5);
|
||||
if (!(actualAccessibleText.equals("1"))) {
|
||||
throw new RuntimeException(
|
||||
"JTextField -" + "getBeforeIndex() CHARACTER parameter"
|
||||
+ " expected:--1--, actual:--" + actualAccessibleText + "--");
|
||||
}
|
||||
|
||||
actualAccessibleText = jTextField.getAccessibleContext()
|
||||
.getAccessibleText().getBeforeIndex(AccessibleText.WORD, 5);
|
||||
if (!(actualAccessibleText.equals("Test1"))) {
|
||||
throw new RuntimeException(
|
||||
"JTextField -" + "getBeforeIndex() WORD parameter"
|
||||
+ " expected:--Test1--, actual:--" + actualAccessibleText + "--");
|
||||
}
|
||||
|
||||
actualAccessibleText = jTextField.getAccessibleContext()
|
||||
.getAccessibleText().getBeforeIndex(AccessibleText.SENTENCE, 20);
|
||||
if (!(actualAccessibleText.equals("Test1 Test2 Test3. "))) {
|
||||
throw new RuntimeException(
|
||||
"JTextField -" + "getBeforeIndex() SENTENCE parameter"
|
||||
+ " expected:--Test1 Test2 Test3. --, actual:--"
|
||||
+ actualAccessibleText + "--");
|
||||
}
|
||||
|
||||
actualAccessibleText = jTextArea.getAccessibleContext()
|
||||
.getAccessibleText().getBeforeIndex(AccessibleText.CHARACTER, 5);
|
||||
if (!(actualAccessibleText.equals("1"))) {
|
||||
throw new RuntimeException(
|
||||
"JTextArea -" + "getBeforeIndex() CHARACTER parameter"
|
||||
+ " expected:--1--, actual:--" + actualAccessibleText + "--");
|
||||
}
|
||||
|
||||
actualAccessibleText = jTextArea.getAccessibleContext()
|
||||
.getAccessibleText().getBeforeIndex(AccessibleText.WORD, 5);
|
||||
if (!(actualAccessibleText.equals("Test1"))) {
|
||||
throw new RuntimeException("JTextArea -"
|
||||
+ "getBeforeIndex() WORD parameter"
|
||||
+ " expected:--Test1--, actual:--" + actualAccessibleText + "--");
|
||||
}
|
||||
|
||||
actualAccessibleText = jTextArea.getAccessibleContext()
|
||||
.getAccessibleText().getBeforeIndex(AccessibleText.SENTENCE, 20);
|
||||
if (!(actualAccessibleText.equals("Test1 Test2 Test3.\n"))) {
|
||||
throw new RuntimeException(
|
||||
"JTextArea -" + "getBeforeIndex() SENTENCE parameter"
|
||||
+ " expected: Test1 Test2 Test3.\n--, actual:--"
|
||||
+ actualAccessibleText + "--");
|
||||
}
|
||||
|
||||
actualAccessibleText = jEditorPane.getAccessibleContext()
|
||||
.getAccessibleText().getBeforeIndex(AccessibleText.CHARACTER, 5);
|
||||
if (!(actualAccessibleText.equals("1"))) {
|
||||
throw new RuntimeException(
|
||||
"JEditorPane -" + "getBeforeIndex() CHARACTER parameter"
|
||||
+ " expected:--1--, actual:--" + actualAccessibleText + "--");
|
||||
}
|
||||
|
||||
actualAccessibleText = jEditorPane.getAccessibleContext()
|
||||
.getAccessibleText().getBeforeIndex(AccessibleText.WORD, 5);
|
||||
if (!(actualAccessibleText.equals("Test1"))) {
|
||||
throw new RuntimeException(
|
||||
"JEditorPane -" + "getBeforeIndex() WORD parameter"
|
||||
+ " expected:--Test1--, actual:--" + actualAccessibleText + "--");
|
||||
}
|
||||
|
||||
actualAccessibleText = jEditorPane.getAccessibleContext()
|
||||
.getAccessibleText().getBeforeIndex(AccessibleText.SENTENCE, 20);
|
||||
if (!(actualAccessibleText.equals("Test1 Test2 Test3.\n"))) {
|
||||
throw new RuntimeException(
|
||||
"JEditorPane -" + "getBeforeIndex() SENTENCE parameter"
|
||||
+ " expected:--Test1 Test2 Test3.\n--, actual:--"
|
||||
+ actualAccessibleText + "--");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeAndWait(() -> doTest());
|
||||
System.out.println("Test Passed");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2022, 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
|
||||
* @bug 4529616
|
||||
* @summary AccessibleJTableCell.isShowing() returns false
|
||||
* when the cell is actually on the screen.
|
||||
* @run main AccessibleJTableCellTest
|
||||
*/
|
||||
|
||||
import java.awt.Robot;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public class AccessibleJTableCellTest {
|
||||
private static JTable jTable;
|
||||
private static JFrame jFrame;
|
||||
|
||||
private static Object[][] rowData = { { "01", "02", "03", "04", "05" },
|
||||
{ "11", "12", "13", "14", "15" }, { "21", "22", "23", "24", "25" },
|
||||
{ "31", "32", "33", "34", "35" }, { "41", "42", "43", "44", "45" } };
|
||||
|
||||
private static Object[] colNames = { "1", "2", "3", "4", "5" };
|
||||
|
||||
private static void doTest() throws Exception {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> createGUI());
|
||||
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(500);
|
||||
robot.waitForIdle();
|
||||
|
||||
for (int i = 0; i <= colNames.length - 1; i++) {
|
||||
if (!isJTableCellShowing(i)) {
|
||||
throw new RuntimeException(
|
||||
"Assertion Failed: JTable accessible child " + i
|
||||
+ " isShowing returns false");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(() -> jFrame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isJTableCellShowing(int i) throws Exception {
|
||||
AtomicBoolean isShowing = new AtomicBoolean();
|
||||
SwingUtilities.invokeAndWait(() -> isShowing
|
||||
.set(jTable.getAccessibleContext().getAccessibleChild(i)
|
||||
.getAccessibleContext().getAccessibleComponent().isShowing()));
|
||||
|
||||
return isShowing.get();
|
||||
}
|
||||
|
||||
private static void createGUI() {
|
||||
jTable = new JTable(rowData, colNames);
|
||||
jFrame = new JFrame();
|
||||
jFrame.setBounds(100, 100, 300, 300);
|
||||
jFrame.getContentPane().add(jTable);
|
||||
jFrame.setLocationRelativeTo(null);
|
||||
jFrame.setVisible(true);
|
||||
}
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
doTest();
|
||||
System.out.println("Test Passed");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* Copyright (c) 2008, 2022, 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
|
||||
* @bug 4670319
|
||||
* @summary AccessibleJTree should fire a PropertyChangeEvent
|
||||
* using a AccessibleJTreeNode as source.
|
||||
* @run main AccessibleJTreePCESourceTest
|
||||
*/
|
||||
|
||||
import java.awt.Robot;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public class AccessibleJTreePCESourceTest {
|
||||
private static JTree jTree;
|
||||
private static JFrame jFrame;
|
||||
|
||||
private static ArrayList<PropertyChangeEvent> eventsList =
|
||||
new ArrayList<PropertyChangeEvent>();
|
||||
|
||||
private static void doTest() throws Exception {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> createGUI());
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
|
||||
expand(1);
|
||||
robot.waitForIdle();
|
||||
collapse(1);
|
||||
robot.waitForIdle();
|
||||
expand(2);
|
||||
robot.waitForIdle();
|
||||
collapse(2);
|
||||
robot.waitForIdle();
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(() -> jFrame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
public static void expand(int row) throws Exception {
|
||||
SwingUtilities.invokeAndWait(() -> jTree.expandRow(row));
|
||||
}
|
||||
|
||||
public static void collapse(int row) throws Exception {
|
||||
SwingUtilities.invokeAndWait(() -> jTree.collapseRow(row));
|
||||
}
|
||||
|
||||
private static void createGUI() {
|
||||
jTree = new JTree();
|
||||
jFrame = new JFrame();
|
||||
|
||||
jFrame.add(jTree);
|
||||
|
||||
jTree.getAccessibleContext().addPropertyChangeListener(event -> {
|
||||
if (event.getNewValue() != null) {
|
||||
eventsList.add(event);
|
||||
}
|
||||
});
|
||||
|
||||
jFrame.setSize(200, 200);
|
||||
jFrame.getContentPane().add(jTree);
|
||||
jFrame.setVisible(true);
|
||||
}
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
doTest();
|
||||
|
||||
for (int i = 0; i < eventsList.size(); i++) {
|
||||
PropertyChangeEvent obj = eventsList.get(i);
|
||||
String state = obj.getNewValue().toString();
|
||||
|
||||
if ((state.equals("expanded") || state.equals("collapsed"))
|
||||
&& (obj.getPropertyName().toString())
|
||||
.equals("AccessibleState")) {
|
||||
if (!(obj.getSource().getClass().getName()).equals(
|
||||
"javax.swing.JTree$AccessibleJTree$AccessibleJTreeNode")) {
|
||||
throw new RuntimeException("Test Failed: When tree node is "
|
||||
+ state + ", PropertyChangeEventSource is "
|
||||
+ obj.getSource().getClass().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println(
|
||||
"Test Passed: When tree node is expanded/collapsed, "
|
||||
+ "PropertyChangeEventSource is the Node");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2022, 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
|
||||
* @bug 4702199
|
||||
* @summary AccessibleExtendedText and related classes for
|
||||
* missing accessibility support
|
||||
* @run main AccessibleExtendedTextTest
|
||||
*/
|
||||
|
||||
public class AccessibleExtendedTextTest {
|
||||
|
||||
public static void doTest() throws Exception {
|
||||
try {
|
||||
Class[] param = { int.class, int.class };
|
||||
Class accessibleExtendedText =
|
||||
Class.forName("javax.accessibility.AccessibleExtendedText");
|
||||
accessibleExtendedText.getDeclaredField("LINE");
|
||||
accessibleExtendedText.getDeclaredField("ATTRIBUTE_RUN");
|
||||
accessibleExtendedText.getDeclaredMethod("getTextRange", param);
|
||||
accessibleExtendedText.getDeclaredMethod("getTextSequenceAt",
|
||||
param);
|
||||
accessibleExtendedText.getDeclaredMethod("getTextSequenceAfter",
|
||||
param);
|
||||
accessibleExtendedText.getDeclaredMethod("getTextSequenceBefore",
|
||||
param);
|
||||
accessibleExtendedText.getDeclaredMethod("getTextBounds", param);
|
||||
} catch (Exception e) {
|
||||
throw new Exception(
|
||||
"Failures in Interface AccessibleExtendedText");
|
||||
}
|
||||
|
||||
try {
|
||||
Class accessibleTextSequence =
|
||||
Class.forName("javax.accessibility.AccessibleTextSequence");
|
||||
accessibleTextSequence.getDeclaredField("startIndex");
|
||||
accessibleTextSequence.getDeclaredField("endIndex");
|
||||
accessibleTextSequence.getDeclaredField("text");
|
||||
} catch (Exception e) {
|
||||
throw new Exception(
|
||||
"Failures in Interface AccessibleTextSequence");
|
||||
}
|
||||
|
||||
try {
|
||||
Class accessibleTextAttributeSequence = Class
|
||||
.forName("javax.accessibility.AccessibleAttributeSequence");
|
||||
accessibleTextAttributeSequence.getDeclaredField("startIndex");
|
||||
accessibleTextAttributeSequence.getDeclaredField("endIndex");
|
||||
accessibleTextAttributeSequence.getDeclaredField("attributes");
|
||||
} catch (Exception e) {
|
||||
throw new Exception(
|
||||
"Failures in Interface AccessibleAttributeSequence");
|
||||
}
|
||||
|
||||
try {
|
||||
Class accessibleContext =
|
||||
Class.forName("javax.accessibility.AccessibleContext");
|
||||
accessibleContext
|
||||
.getDeclaredField("ACCESSIBLE_INVALIDATE_CHILDREN");
|
||||
accessibleContext
|
||||
.getDeclaredField("ACCESSIBLE_TEXT_ATTRIBUTES_CHANGED");
|
||||
accessibleContext
|
||||
.getDeclaredField("ACCESSIBLE_COMPONENT_BOUNDS_CHANGED");
|
||||
} catch (Exception e) {
|
||||
throw new Exception(
|
||||
"Failures in Interface AccessibleContext");
|
||||
}
|
||||
System.out.println("Test Passed");
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2022, 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @summary Constant for testing public fields in AccessibleAction.
|
||||
*/
|
||||
|
||||
public interface AccessibleActionConstants {
|
||||
|
||||
String CLASS_NAME = "javax.accessibility.AccessibleAction";
|
||||
|
||||
/**
|
||||
* Public fields values in AccessibleAction class.
|
||||
*/
|
||||
String[][] FIELDS =
|
||||
new String[][] { { "CLICK", "click" }, { "DECREMENT", "decrement" },
|
||||
{ "INCREMENT", "increment" }, { "TOGGLE_EXPAND", "toggleexpand" },
|
||||
{ "TOGGLE_POPUP", "toggle popup" } };
|
||||
/**
|
||||
* Old(removed) fields in AccessibleAction class.
|
||||
*/
|
||||
String[] OLD_FIELDS = new String[] {};
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2022, 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @summary Constant for testing public fields in AccessibleContext.
|
||||
*/
|
||||
|
||||
public interface AccessibleContextConstants {
|
||||
|
||||
String CLASS_NAME = "javax.accessibility.AccessibleContext";
|
||||
|
||||
/**
|
||||
* Public fields values in AccessibleContext class.
|
||||
*/
|
||||
String[][] FIELDS = new String[][] {
|
||||
{ "ACCESSIBLE_NAME_PROPERTY", "AccessibleName" },
|
||||
{ "ACCESSIBLE_DESCRIPTION_PROPERTY", "AccessibleDescription" },
|
||||
{ "ACCESSIBLE_STATE_PROPERTY", "AccessibleState" },
|
||||
{ "ACCESSIBLE_VALUE_PROPERTY", "AccessibleValue" },
|
||||
{ "ACCESSIBLE_SELECTION_PROPERTY", "AccessibleSelection" },
|
||||
{ "ACCESSIBLE_CARET_PROPERTY", "AccessibleCaret" },
|
||||
{ "ACCESSIBLE_VISIBLE_DATA_PROPERTY", "AccessibleVisibleData" },
|
||||
{ "ACCESSIBLE_CHILD_PROPERTY", "AccessibleChild" },
|
||||
{ "ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY",
|
||||
"AccessibleActiveDescendant" },
|
||||
{ "ACCESSIBLE_TABLE_CAPTION_CHANGED", "accessibleTableCaptionChanged" },
|
||||
{ "ACCESSIBLE_TABLE_SUMMARY_CHANGED", "accessibleTableSummaryChanged" },
|
||||
{ "ACCESSIBLE_TABLE_MODEL_CHANGED", "accessibleTableModelChanged" },
|
||||
{ "ACCESSIBLE_TABLE_ROW_HEADER_CHANGED",
|
||||
"accessibleTableRowHeaderChanged" },
|
||||
{ "ACCESSIBLE_TABLE_ROW_DESCRIPTION_CHANGED",
|
||||
"accessibleTableRowDescriptionChanged" },
|
||||
{ "ACCESSIBLE_TABLE_COLUMN_HEADER_CHANGED",
|
||||
"accessibleTableColumnHeaderChanged" },
|
||||
{ "ACCESSIBLE_TABLE_COLUMN_DESCRIPTION_CHANGED",
|
||||
"accessibleTableColumnDescriptionChanged" },
|
||||
{ "ACCESSIBLE_ACTION_PROPERTY", "accessibleActionProperty" },
|
||||
{ "ACCESSIBLE_HYPERTEXT_OFFSET", "AccessibleHypertextOffset" },
|
||||
{ "ACCESSIBLE_TEXT_PROPERTY", "AccessibleText" },
|
||||
{ "ACCESSIBLE_INVALIDATE_CHILDREN", "accessibleInvalidateChildren" },
|
||||
{ "ACCESSIBLE_TEXT_ATTRIBUTES_CHANGED",
|
||||
"accessibleTextAttributesChanged" },
|
||||
{ "ACCESSIBLE_COMPONENT_BOUNDS_CHANGED",
|
||||
"accessibleComponentBoundsChanged" } };
|
||||
|
||||
/**
|
||||
* Old(removed) fields in AccessibleContext class.
|
||||
*/
|
||||
String[] OLD_FIELDS = new String[] {};
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2022, 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
|
||||
* @bug 4702233
|
||||
* @summary Testing current and old(removed) public fields in AccessibleAction,
|
||||
* AccessibleContext, AccessibleRelation, AccessibleRole and AccessibleState.
|
||||
* @run main AccessiblePropertiesTest
|
||||
*/
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class AccessiblePropertiesTest {
|
||||
|
||||
private static void checkFields(String className, String[][] fields,
|
||||
String[] oldFields) {
|
||||
try {
|
||||
Class<?> klass = Class.forName(className);
|
||||
|
||||
if (klass.getFields().length != fields.length) {
|
||||
throw new RuntimeException("Fields in " + className
|
||||
+ " were changed. Test should be updated!");
|
||||
}
|
||||
|
||||
for (int i = 0; i < fields.length; ++i) {
|
||||
String key = fields[i][0];
|
||||
String value = fields[i][1];
|
||||
Field field = klass.getDeclaredField(key);
|
||||
String current = field.get(String.class).toString();
|
||||
|
||||
if (!current.equals(value)) {
|
||||
throw new RuntimeException(
|
||||
"Field " + field.getName() + " current value=" + current
|
||||
+ " , expected value=" + value);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < oldFields.length; ++i) {
|
||||
String key = oldFields[i];
|
||||
|
||||
try {
|
||||
klass.getDeclaredField(key);
|
||||
|
||||
throw new RuntimeException(key + " exists in " + klass);
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
checkFields(AccessibleActionConstants.CLASS_NAME,
|
||||
AccessibleActionConstants.FIELDS,
|
||||
AccessibleActionConstants.OLD_FIELDS);
|
||||
|
||||
checkFields(AccessibleRelationConstants.CLASS_NAME,
|
||||
AccessibleRelationConstants.FIELDS,
|
||||
AccessibleRelationConstants.OLD_FIELDS);
|
||||
|
||||
checkFields(AccessibleRoleConstants.CLASS_NAME,
|
||||
AccessibleRoleConstants.FIELDS, AccessibleRoleConstants.OLD_FIELDS);
|
||||
|
||||
checkFields(AccessibleStateConstants.CLASS_NAME,
|
||||
AccessibleStateConstants.FIELDS,
|
||||
AccessibleStateConstants.OLD_FIELDS);
|
||||
|
||||
checkFields(AccessibleContextConstants.CLASS_NAME,
|
||||
AccessibleContextConstants.FIELDS,
|
||||
AccessibleContextConstants.OLD_FIELDS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2022, 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @summary Constant for testing public fields in AccessibleRelation.
|
||||
*/
|
||||
public interface AccessibleRelationConstants {
|
||||
|
||||
/**
|
||||
* Fully-qualified name of the class.
|
||||
*/
|
||||
String CLASS_NAME = "javax.accessibility.AccessibleRelation";
|
||||
|
||||
/**
|
||||
* Public fields values in AccessibleRelation class.
|
||||
*/
|
||||
String[][] FIELDS = new String[][] { { "CHILD_NODE_OF", "childNodeOf" },
|
||||
{ "CHILD_NODE_OF_PROPERTY", "childNodeOfProperty" },
|
||||
{ "CONTROLLED_BY", "controlledBy" },
|
||||
{ "CONTROLLED_BY_PROPERTY", "controlledByProperty" },
|
||||
{ "CONTROLLER_FOR", "controllerFor" },
|
||||
{ "CONTROLLER_FOR_PROPERTY", "controllerForProperty" },
|
||||
{ "EMBEDDED_BY", "embeddedBy" },
|
||||
{ "EMBEDDED_BY_PROPERTY", "embeddedByProperty" },
|
||||
{ "EMBEDS", "embeds" }, { "EMBEDS_PROPERTY", "embedsProperty" },
|
||||
{ "FLOWS_FROM", "flowsFrom" },
|
||||
{ "FLOWS_FROM_PROPERTY", "flowsFromProperty" },
|
||||
{ "FLOWS_TO", "flowsTo" }, { "FLOWS_TO_PROPERTY", "flowsToProperty" },
|
||||
{ "LABELED_BY", "labeledBy" },
|
||||
{ "LABELED_BY_PROPERTY", "labeledByProperty" },
|
||||
{ "LABEL_FOR", "labelFor" },
|
||||
{ "LABEL_FOR_PROPERTY", "labelForProperty" },
|
||||
{ "MEMBER_OF", "memberOf" },
|
||||
{ "MEMBER_OF_PROPERTY", "memberOfProperty" },
|
||||
{ "PARENT_WINDOW_OF", "parentWindowOf" },
|
||||
{ "PARENT_WINDOW_OF_PROPERTY", "parentWindowOfProperty" },
|
||||
{ "SUBWINDOW_OF", "subwindowOf" },
|
||||
{ "SUBWINDOW_OF_PROPERTY", "subwindowOfProperty" }, };
|
||||
|
||||
/**
|
||||
* Old(removed) fields in AccessibleRelation class.
|
||||
*/
|
||||
String[] OLD_FIELDS = new String[] {};
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2022, 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @summary Constant for testing public fields in AccessibleRole.
|
||||
*/
|
||||
|
||||
public interface AccessibleRoleConstants {
|
||||
|
||||
/**
|
||||
* Fully-qualified name of the class.
|
||||
*/
|
||||
String CLASS_NAME = "javax.accessibility.AccessibleRole";
|
||||
|
||||
/**
|
||||
* Public fields values in AccessibleRole class.
|
||||
*/
|
||||
String[][] FIELDS = new String[][] { { "ALERT", "alert" },
|
||||
{ "AWT_COMPONENT", "AWT component" }, { "CANVAS", "canvas" },
|
||||
{ "CHECK_BOX", "check box" }, { "COLOR_CHOOSER", "color chooser" },
|
||||
{ "COLUMN_HEADER", "column header" }, { "COMBO_BOX", "combo box" },
|
||||
{ "DATE_EDITOR", "dateeditor" }, { "DESKTOP_ICON", "desktop icon" },
|
||||
{ "DESKTOP_PANE", "desktop pane" }, { "DIALOG", "dialog" },
|
||||
{ "DIRECTORY_PANE", "directory pane" }, { "EDITBAR", "editbar" },
|
||||
{ "FILE_CHOOSER", "file chooser" }, { "FILLER", "filler" },
|
||||
{ "FONT_CHOOSER", "fontchooser" }, { "FOOTER", "footer" },
|
||||
{ "FRAME", "frame" }, { "GLASS_PANE", "glass pane" },
|
||||
{ "GROUP_BOX", "groupbox" }, { "HEADER", "header" },
|
||||
{ "HTML_CONTAINER", "HTML container" }, { "HYPERLINK", "hyperlink" },
|
||||
{ "ICON", "icon" }, { "INTERNAL_FRAME", "internal frame" },
|
||||
{ "LABEL", "label" }, { "LAYERED_PANE", "layered pane" },
|
||||
{ "LIST", "list" }, { "LIST_ITEM", "list item" }, { "MENU", "menu" },
|
||||
{ "MENU_BAR", "menu bar" }, { "MENU_ITEM", "menu item" },
|
||||
{ "OPTION_PANE", "option pane" }, { "PAGE_TAB", "page tab" },
|
||||
{ "PAGE_TAB_LIST", "page tab list" }, { "PANEL", "panel" },
|
||||
{ "PARAGRAPH", "paragraph" }, { "PASSWORD_TEXT", "password text" },
|
||||
{ "POPUP_MENU", "popup menu" }, { "PROGRESS_BAR", "progress bar" },
|
||||
{ "PROGRESS_MONITOR", "progress monitor" },
|
||||
{ "PUSH_BUTTON", "push JButton" }, { "RADIO_BUTTON", "radio JButton" },
|
||||
{ "ROOT_PANE", "root pane" }, { "ROW_HEADER", "row header" },
|
||||
{ "RULER", "ruler" }, { "SCROLL_BAR", "scroll bar" },
|
||||
{ "SCROLL_PANE", "scroll pane" }, { "SEPARATOR", "separator" },
|
||||
{ "SLIDER", "slider" }, { "SPIN_BOX", "spinbox" },
|
||||
{ "SPLIT_PANE", "split pane" }, { "STATUS_BAR", "statusbar" },
|
||||
{ "SWING_COMPONENT", "swing component" }, { "TABLE", "table" },
|
||||
{ "TEXT", "text" }, { "TOGGLE_BUTTON", "toggle JButton" },
|
||||
{ "TOOL_BAR", "tool bar" }, { "TOOL_TIP", "tool tip" },
|
||||
{ "TREE", "tree" }, { "UNKNOWN", "unknown" },
|
||||
{ "VIEWPORT", "viewport" }, { "WINDOW", "window" } };
|
||||
|
||||
/**
|
||||
* Old(removed) fields in AccessibleRole class.
|
||||
*/
|
||||
String[] OLD_FIELDS = new String[] {};
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2022, 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @summary Constant for testing public fields in AccessibleState.
|
||||
*/
|
||||
|
||||
public interface AccessibleStateConstants {
|
||||
|
||||
/**
|
||||
* Fully-qualified name of the class.
|
||||
*/
|
||||
String CLASS_NAME = "javax.accessibility.AccessibleState";
|
||||
|
||||
/**
|
||||
* Public fields values in AccessibleState class.
|
||||
*/
|
||||
String[][] FIELDS = new String[][] { { "ACTIVE", "active" },
|
||||
{ "ARMED", "armed" }, { "BUSY", "busy" }, { "CHECKED", "checked" },
|
||||
{ "COLLAPSED", "collapsed" }, { "EDITABLE", "editable" },
|
||||
{ "ENABLED", "enabled" }, { "EXPANDABLE", "expandable" },
|
||||
{ "EXPANDED", "expanded" }, { "FOCUSABLE", "focusable" },
|
||||
{ "FOCUSED", "focused" }, { "HORIZONTAL", "horizontal" },
|
||||
{ "ICONIFIED", "iconified" }, { "INDETERMINATE", "indeterminate" },
|
||||
{ "MANAGES_DESCENDANTS", "manages descendants" }, { "MODAL", "modal" },
|
||||
{ "MULTISELECTABLE", "multiselectable" },
|
||||
{ "MULTI_LINE", "multiple line" }, { "OPAQUE", "opaque" },
|
||||
{ "PRESSED", "pressed" }, { "RESIZABLE", "resizable" },
|
||||
{ "SELECTABLE", "selectable" }, { "SELECTED", "selected" },
|
||||
{ "SHOWING", "showing" }, { "SINGLE_LINE", "single line" },
|
||||
{ "TRANSIENT", "transient" }, { "TRUNCATED", "truncated" },
|
||||
{ "VERTICAL", "vertical" }, { "VISIBLE", "visible" } };
|
||||
|
||||
/**
|
||||
* Old(removed) fields in AccessibleState class.
|
||||
*/
|
||||
String[] OLD_FIELDS = new String[] {
|
||||
|
||||
// CR 4981070 INCONSISTENT was replaced by INDETERMINATE.
|
||||
"INCONSISTENT" };
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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
|
||||
* @bug 4715503
|
||||
* @summary AccessibleTable cannot get the Bounding Rectangle of Table Header Cells.
|
||||
* @run main AccessibleJTableCellBoundingRectangleTest
|
||||
*/
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public class AccessibleJTableCellBoundingRectangleTest {
|
||||
private static JTable jTable;
|
||||
private static JFrame jFrame;
|
||||
|
||||
private static Object[][] rowData = { { "01", "02", "03", "04", "05" },
|
||||
{ "11", "12", "13", "14", "15" }, { "21", "22", "23", "24", "25" },
|
||||
{ "31", "32", "33", "34", "35" }, { "41", "42", "43", "44", "45" } };
|
||||
|
||||
private static Object[] colNames = { "1", "2", "3", "4", "5" };
|
||||
|
||||
private static void doTest() throws Exception {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> createGUI());
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(500);
|
||||
robot.waitForIdle();
|
||||
|
||||
for (int i = 0; i <= colNames.length - 1; i++) {
|
||||
try {
|
||||
Rectangle bounds =
|
||||
jTable.getTableHeader().getAccessibleContext().getAccessibleChild(i)
|
||||
.getAccessibleContext().getAccessibleComponent().getBounds();
|
||||
|
||||
if (bounds != null) {
|
||||
System.out.println("Column " + i + " Bounds: " + bounds);
|
||||
} else {
|
||||
throw new RuntimeException(
|
||||
"Bounding Rectangles getting bounding rectangle for table header cells is null");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Bounding Rectangles getting bounding rectangle for "
|
||||
+ "table header cells threw an exception:\n" + e);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(() -> jFrame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
private static void createGUI() {
|
||||
jTable = new JTable(rowData, colNames);
|
||||
jFrame = new JFrame();
|
||||
jFrame.setBounds(100, 100, 300, 300);
|
||||
jFrame.getContentPane().add(jTable);
|
||||
jFrame.setVisible(true);
|
||||
}
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
doTest();
|
||||
System.out.println("Test Passed");
|
||||
}
|
||||
}
|
||||
|
||||
99
test/jdk/javax/accessibility/6192422/bug6192422.java
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* Copyright (c) 2005, 2019, 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 javax.accessibility.Accessible;
|
||||
import javax.accessibility.AccessibleContext;
|
||||
import javax.accessibility.AccessibleRole;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 6192422 7106851
|
||||
* @key headful
|
||||
* @summary Verifies fix for JMenuBar not being in the accessibility hierarchy
|
||||
*/
|
||||
public class bug6192422 {
|
||||
|
||||
private static boolean foundJMenuBar = false;
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
if (!testIt()) {
|
||||
throw new RuntimeException("JMenuBar was not found");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Test whether JMenuBar is in accessibility hierarchy
|
||||
*/
|
||||
private static boolean testIt() {
|
||||
|
||||
JFrame frame = new JFrame("bug6192422");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
/*
|
||||
* Add a menu bar to the frame using setJMenuBar. The setJMenuBar
|
||||
* method add the menu bar to the JLayeredPane.
|
||||
*/
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar.add(new JMenu("foo"));
|
||||
menuBar.add(new JMenu("bar"));
|
||||
menuBar.add(new JMenu("baz"));
|
||||
frame.setJMenuBar(menuBar);
|
||||
|
||||
findJMenuBar(frame.getAccessibleContext());
|
||||
return foundJMenuBar;
|
||||
}
|
||||
|
||||
/*
|
||||
* Finds the JMenuBar in the Accessibility hierarchy
|
||||
*/
|
||||
private static void findJMenuBar(AccessibleContext ac) {
|
||||
if (ac != null) {
|
||||
System.err.println("findJMenuBar: ac = "+ac.getClass());
|
||||
int num = ac.getAccessibleChildrenCount();
|
||||
System.err.println(" #children "+num);
|
||||
|
||||
for (int i = 0; i < num; i++) {
|
||||
System.err.println(" child #"+i);
|
||||
Accessible a = ac.getAccessibleChild(i);
|
||||
AccessibleContext child = a.getAccessibleContext();
|
||||
AccessibleRole role = child.getAccessibleRole();
|
||||
System.err.println(" role "+role);
|
||||
if (role == AccessibleRole.MENU_BAR) {
|
||||
foundJMenuBar = true;
|
||||
return;
|
||||
}
|
||||
if (child.getAccessibleChildrenCount() > 0) {
|
||||
findJMenuBar(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
110
test/jdk/javax/accessibility/6714324/TabbedPaneMemLeak.java
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* Copyright (c) 2018, 2020, 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
|
||||
* @bug 6714324
|
||||
* @summary tests if removing a Tab from JTabbedComponent, clears the reference
|
||||
* to the Page (AccessibleContext) object.
|
||||
* @modules java.desktop/java.awt:open
|
||||
* @run main TabbedPaneMemLeak
|
||||
*/
|
||||
import javax.accessibility.Accessible;
|
||||
import javax.accessibility.AccessibleContext;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Hashtable;
|
||||
|
||||
public class TabbedPaneMemLeak
|
||||
{
|
||||
private static void checkAccessibleParent(Component component) {
|
||||
//Use reflection to check the value of accessibleContext, since directly calling getAccessibleContext()
|
||||
//creates one, if not already present.
|
||||
try {
|
||||
Field field =
|
||||
component.getClass().getSuperclass().getSuperclass().getSuperclass().getSuperclass().getDeclaredField(
|
||||
"accessibleContext");
|
||||
field.setAccessible(true);
|
||||
AccessibleContext ctx = (AccessibleContext)field.get(component);
|
||||
if (ctx != null) {
|
||||
Field accessibleParentField = field.getType().getDeclaredField("accessibleParent");
|
||||
accessibleParentField.setAccessible(true);
|
||||
Accessible parent = (Accessible)accessibleParentField.get(ctx);
|
||||
if (parent != null) {
|
||||
throw new RuntimeException("Test failed: AccessibleContext added on the wrong codepath.");
|
||||
}
|
||||
}
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new RuntimeException("Test failed: Unable to fetch AccessibleContext");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
JTabbedPane tabbedPane = new JTabbedPane();
|
||||
if (tabbedPane.getAccessibleContext() != null) { // Ensure that the JTabbedPane has an AccessibleContext
|
||||
JComponent component = new JPanel();
|
||||
System.out.println(component.getAccessibleContext().getAccessibleParent()); // null
|
||||
tabbedPane.addTab("Component", component);
|
||||
System.out.println(component.getAccessibleContext().getAccessibleParent()); // JTabbedPane$Page
|
||||
|
||||
JComponent component1 = new JPanel();
|
||||
JComponent component2 = new JPanel();
|
||||
|
||||
tabbedPane.addTab("Component1", component1);
|
||||
tabbedPane.setComponentAt(1, component2);
|
||||
|
||||
if (component1.getAccessibleContext().getAccessibleParent() != null) {
|
||||
throw new RuntimeException("Test failed: Parent AccessibleContext not cleared from the child component");
|
||||
}
|
||||
|
||||
tabbedPane.removeAll(); // Could also be tabbedPane.remove(component) or tabbedPane.removeTabAt(0)
|
||||
if (component.getAccessibleContext().getAccessibleParent() != null) {
|
||||
throw new RuntimeException("Test failed: Parent AccessibleContext not cleared from the child " +
|
||||
"component");
|
||||
}
|
||||
|
||||
JSlider slider = new JSlider(0, 10);
|
||||
Hashtable<Integer, JComponent> labels = slider.createStandardLabels(5, 2);
|
||||
|
||||
JComponent labelComp = labels.get(labels.keys().nextElement());
|
||||
|
||||
tabbedPane.add(labelComp);
|
||||
|
||||
checkAccessibleParent(labelComp);
|
||||
|
||||
tabbedPane.remove(labelComp);
|
||||
|
||||
checkAccessibleParent(labelComp);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
47
test/jdk/javax/accessibility/6986385/bug6986385.java
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 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
|
||||
@bug 6986385
|
||||
@summary JLayer should implement accessible interface
|
||||
@author Alexander Potochkin
|
||||
@run main bug6986385
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.accessibility.AccessibleContext;
|
||||
import javax.accessibility.AccessibleRole;
|
||||
|
||||
public class bug6986385 {
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
JLayer l = new JLayer();
|
||||
AccessibleContext acc = l.getAccessibleContext();
|
||||
if (acc == null) {
|
||||
throw new RuntimeException("JLayer's AccessibleContext is null");
|
||||
}
|
||||
if (acc.getAccessibleRole() != AccessibleRole.PANEL) {
|
||||
throw new RuntimeException("JLayer's AccessibleRole must be PANEL");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 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.Component;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.accessibility.Accessible;
|
||||
import javax.accessibility.AccessibleContext;
|
||||
/*
|
||||
* @test
|
||||
* @bug 8017112
|
||||
* @summary JTabbedPane components have inconsistent accessibility tree
|
||||
* @run main AccessibleIndexInParentTest
|
||||
*/
|
||||
|
||||
public class AccessibleIndexInParentTest {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeAndWait(AccessibleIndexInParentTest::test);
|
||||
}
|
||||
|
||||
private static void test() {
|
||||
|
||||
int N = 5;
|
||||
JTabbedPane tabbedPane = new JTabbedPane();
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
tabbedPane.addTab("Title: " + i, new JLabel("Component: " + i));
|
||||
}
|
||||
|
||||
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
|
||||
Component child = tabbedPane.getComponentAt(i);
|
||||
|
||||
AccessibleContext ac = child.getAccessibleContext();
|
||||
if (ac == null) {
|
||||
throw new RuntimeException("Accessible Context is null!");
|
||||
}
|
||||
|
||||
int index = ac.getAccessibleIndexInParent();
|
||||
Accessible parent = ac.getAccessibleParent();
|
||||
|
||||
if (parent.getAccessibleContext().getAccessibleChild(index) != child) {
|
||||
throw new RuntimeException("Wrong getAccessibleIndexInParent!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
59
test/jdk/javax/accessibility/8069268/bug8069268.java
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 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
|
||||
@bug 8069268
|
||||
@summary Tests that only one ContainerListener exists for AccessibleJComponent of JRootPane
|
||||
@author Vivi An
|
||||
*/
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
import javax.accessibility.*;
|
||||
|
||||
public class bug8069268{
|
||||
public static void main(String[] args) throws Exception {
|
||||
TestableRootPane rootPane = new TestableRootPane();
|
||||
|
||||
// Get accesibleContext and then AccessibleJComponent, call the function
|
||||
// addPropertyChangeListener to trigger container listener to be added
|
||||
AccessibleContext acc = rootPane.getAccessibleContext();
|
||||
JComponent.AccessibleJComponent accJ = (JComponent.AccessibleJComponent) acc;
|
||||
accJ.addPropertyChangeListener(null);
|
||||
|
||||
// Test how many container listener(s) exist(s), should only have 1
|
||||
if (!rootPane.testContainerListener())
|
||||
throw new RuntimeException("Failed test for bug 8069268");
|
||||
}
|
||||
|
||||
private static class TestableRootPane extends JRootPane {
|
||||
public boolean testContainerListener() {
|
||||
boolean result = false;
|
||||
ContainerListener[] listeners = getContainerListeners();
|
||||
System.out.println("ContainerListener number is " + listeners.length);
|
||||
result = (listeners.length == 1) ? true : false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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
|
||||
* @bug 4715496
|
||||
* @summary AccessibleJTableCell.getAccessible name incorrectly returns
|
||||
* cell instance string instead of cell text.
|
||||
* @run main AccessibleJTableCellNameTest
|
||||
*/
|
||||
|
||||
import java.awt.Robot;
|
||||
|
||||
import javax.accessibility.Accessible;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public class AccessibleJTableCellNameTest {
|
||||
private static JTable jTable;
|
||||
private static JFrame jFrame;
|
||||
private static volatile Accessible accessible;
|
||||
|
||||
private static Object[][] rowData = {
|
||||
{ "01", "02", "03", "04", "05" },
|
||||
{ "11", "12", "13", "14", "15" },
|
||||
{ "21", "22", "23", "24", "25" },
|
||||
{ "31", "32", "33", "34", "35" },
|
||||
{ "41", "42", "43", "44", "45" } };
|
||||
|
||||
private static Object[] colNames = { "1", "2", "3", "4", "5" };
|
||||
|
||||
private static void doTest() throws Exception {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> createGUI());
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(500);
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
for (int i = 0; i <= colNames.length - 1; i++) {
|
||||
Accessible accessible = jTable.getAccessibleContext().getAccessibleTable()
|
||||
.getAccessibleColumnHeader().getAccessibleAt(0, i);
|
||||
|
||||
if (!(accessible.getAccessibleContext().getAccessibleName().equals(colNames[i]))) {
|
||||
throw new RuntimeException(
|
||||
"AccessibleJTableCell.getAccessibleName returns correct name for header cells");
|
||||
}
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(() -> jFrame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
private static void createGUI() {
|
||||
jTable = new JTable(rowData, colNames);
|
||||
jFrame = new JFrame();
|
||||
jFrame.setBounds(100, 100, 300, 300);
|
||||
jFrame.getContentPane().add(jTable);
|
||||
jFrame.setVisible(true);
|
||||
}
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
doTest();
|
||||
System.out.println("Test Passed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
* Copyright (c) 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 javax.accessibility.AccessibleComponent;
|
||||
import javax.accessibility.AccessibleContext;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 8377428
|
||||
* @summary manual test for VoiceOver reading hidden components
|
||||
* @requires os.family == "mac"
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @run main/manual TestVoiceOverHiddenComponentNavigation
|
||||
*/
|
||||
|
||||
public class TestVoiceOverHiddenComponentNavigation {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String INSTRUCTIONS = """
|
||||
Test UI contains four rows. Each row contains a JButton.
|
||||
Two of the rows are hidden, and two are visible.
|
||||
|
||||
Follow these steps to test the behaviour:
|
||||
|
||||
1. Start the VoiceOver (Press Command + F5) application
|
||||
2. Move VoiceOver cursor to one of the visible buttons.
|
||||
3. Press CTRL + ALT + LEFT to move the VoiceOver cursor back
|
||||
4. Repeat step 3 until you reach the "Close" button.
|
||||
|
||||
If VoiceOver ever references a "Hidden Button": then this test
|
||||
fails.
|
||||
""";
|
||||
|
||||
PassFailJFrame.builder()
|
||||
.title("TestVoiceOverHiddenComponentNavigation Instruction")
|
||||
.instructions(INSTRUCTIONS)
|
||||
.columns(40)
|
||||
.testUI(TestVoiceOverHiddenComponentNavigation::createUI)
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
private static JFrame createUI() {
|
||||
JPanel rows = new JPanel();
|
||||
rows.setLayout(new BoxLayout(rows, BoxLayout.Y_AXIS));
|
||||
rows.add(createRow("Hidden Button", "Row 1", false, false));
|
||||
rows.add(createRow("Hidden Button", "Row 2", false, true));
|
||||
rows.add(createRow("Visible Button", "Row 3", true, false));
|
||||
rows.add(createRow("Visible Button", "Row 4", true, true));
|
||||
|
||||
JFrame frame = new JFrame("A Frame hidden JButtons");
|
||||
frame.getContentPane().add(rows);
|
||||
frame.pack();
|
||||
return frame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a row to add to this demo frame.
|
||||
*
|
||||
* @param buttonText the button name/text
|
||||
* @param panelAXName the panel accessible name
|
||||
* @param isVisible whether JPanel.isVisible() should be true
|
||||
* @param useNullAXComponent if true then
|
||||
* AccessibleJPanel.getAccessibleComponent
|
||||
* returns null. This was added to test a
|
||||
* particular code path.
|
||||
* @return a row for the demo frame
|
||||
*/
|
||||
private static JPanel createRow(String buttonText, String panelAXName,
|
||||
boolean isVisible,
|
||||
boolean useNullAXComponent) {
|
||||
JPanel returnValue = new JPanel() {
|
||||
@Override
|
||||
public AccessibleContext getAccessibleContext() {
|
||||
if (accessibleContext == null) {
|
||||
accessibleContext = new AccessibleJPanel() {
|
||||
@Override
|
||||
public AccessibleComponent getAccessibleComponent() {
|
||||
if (useNullAXComponent) {
|
||||
return null;
|
||||
} else {
|
||||
return super.getAccessibleComponent();
|
||||
}
|
||||
}
|
||||
};
|
||||
accessibleContext.setAccessibleName(panelAXName);
|
||||
}
|
||||
return accessibleContext;
|
||||
}
|
||||
};
|
||||
returnValue.setVisible(isVisible);
|
||||
JButton button = new JButton(buttonText);
|
||||
returnValue.add(button);
|
||||
return returnValue;
|
||||
}
|
||||
}
|
||||
119
test/jdk/javax/accessibility/8377745/VoiceOverHyperlinkRole.java
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* Copyright (c) 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 javax.accessibility.AccessibleContext;
|
||||
import javax.accessibility.AccessibleRole;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 8377745
|
||||
* @summary manual test for VoiceOver reading links correctly
|
||||
* @requires os.family == "mac"
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @run main/manual VoiceOverHyperlinkRole
|
||||
*/
|
||||
|
||||
public class VoiceOverHyperlinkRole {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String INSTRUCTIONS = "INSTRUCTIONS (Mac-only):\n" +
|
||||
"1. Open VoiceOver\n" +
|
||||
"2. Move the VoiceOver cursor over the link.\n" +
|
||||
"3. Observe how VoiceOver identifies the link.\n\n" +
|
||||
"Expected behavior: VoiceOver should identify it as a " +
|
||||
"\"link\". It should not say \"text element\", \"text\" " +
|
||||
"or \"hyperlink\".\n\n" +
|
||||
"If you select the link using \"Accessibility " +
|
||||
"Inspector\": it should identify its role as AXLink.";
|
||||
|
||||
PassFailJFrame.builder()
|
||||
.title("VoiceOverHyperlinkRole Instruction")
|
||||
.instructions(INSTRUCTIONS)
|
||||
.columns(40)
|
||||
.testUI(VoiceOverHyperlinkRole::createUI)
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
private static JFrame createUI() {
|
||||
JPanel p = new JPanel();
|
||||
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
|
||||
|
||||
p.add(createText("This button uses `AccessibleRole.HYPERLINK:`"));
|
||||
p.add(createLink(AccessibleRole.HYPERLINK));
|
||||
|
||||
// for debugging / experimentation:
|
||||
boolean tryOtherRoles = false;
|
||||
if (tryOtherRoles) {
|
||||
p.add(createText(
|
||||
"This button uses `new AccessibleRole(\"Link\") {}`:"));
|
||||
p.add(createLink(new AccessibleRole("Link") {}));
|
||||
p.add(createText(
|
||||
"This button uses `new AccessibleRole(\"link\") {}`:"));
|
||||
p.add(createLink(new AccessibleRole("link") {}));
|
||||
p.add(createText(
|
||||
"This button uses `new AccessibleRole(\"AXLink\") {}`:"));
|
||||
p.add(createLink(new AccessibleRole("AXLink") {}));
|
||||
}
|
||||
|
||||
JFrame frame = new JFrame();
|
||||
frame.getContentPane().add(p);
|
||||
frame.pack();
|
||||
return frame;
|
||||
}
|
||||
|
||||
private static JTextArea createText(String text) {
|
||||
JTextArea textArea = new JTextArea(text);
|
||||
textArea.setOpaque(false);
|
||||
textArea.setEditable(false);
|
||||
textArea.setBorder(new EmptyBorder(20, 10, 3, 10));
|
||||
return textArea;
|
||||
}
|
||||
|
||||
private static JButton createLink(AccessibleRole role) {
|
||||
String text = "<html><u>https://bugs.openjdk.org/</u></html>";
|
||||
JButton button = new JButton(text) {
|
||||
public AccessibleContext getAccessibleContext() {
|
||||
if (accessibleContext == null) {
|
||||
accessibleContext = new AccessibleJButton() {
|
||||
@Override
|
||||
public AccessibleRole getAccessibleRole() {
|
||||
return role;
|
||||
}
|
||||
};
|
||||
}
|
||||
return accessibleContext;
|
||||
}
|
||||
};
|
||||
button.setContentAreaFilled(false);
|
||||
button.setBorderPainted(false);
|
||||
return button;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 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.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UncheckedIOException;
|
||||
import javax.accessibility.AccessibilityProvider;
|
||||
|
||||
public final class BarProvider extends AccessibilityProvider {
|
||||
private final String name = "BarProvider";
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void activate() {
|
||||
// Write to log to indicate activate was called.
|
||||
try (PrintWriter writer = new PrintWriter("BarProvider.txt")) {
|
||||
writer.println(" BarProvider-activated");
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 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 javax.accessibility.AccessibilityProvider;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
public final class FooProvider extends AccessibilityProvider {
|
||||
|
||||
private final String name = "FooProvider";
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void activate() {
|
||||
// Write to log to indicate activate was called.
|
||||
try (PrintWriter writer = new PrintWriter("FooProvider.txt")) {
|
||||
writer.println("FooProvider-activated");
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
89
test/jdk/javax/accessibility/AccessibilityProvider/Load.java
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 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.AWTError;
|
||||
import java.awt.Toolkit;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.accessibility.AccessibilityProvider;
|
||||
|
||||
public class Load {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// args[0]: "pass" or "fail" (the expected result)
|
||||
// args[1]: "<first provider name>"
|
||||
// args[2]: "<optional second provider name>"
|
||||
|
||||
boolean passExpected = args[0].equals("pass");
|
||||
|
||||
// Fill Set with provider names that were requested.
|
||||
// The providers may or may not be available:
|
||||
// - available: FooProvider, BarProvider
|
||||
// - not available: NoProvider
|
||||
List<String> requestedNames = new ArrayList<>();
|
||||
for (int i = 1; i < args.length; ++i) {
|
||||
requestedNames.add(args[i]);
|
||||
}
|
||||
// cleanup files from any prior run
|
||||
for (String name : requestedNames) {
|
||||
File f = new File(name + ".txt");
|
||||
f.delete();
|
||||
}
|
||||
// Activate getDefaultToolkit which will in turn activate the providers
|
||||
try {
|
||||
Toolkit.getDefaultToolkit();
|
||||
} catch (AWTError e) {
|
||||
if (passExpected) {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
// Toolkit.getDefaultToolkit() already went through all the service
|
||||
// providers, loading and activating the requested ones, but now we need
|
||||
// to see if they actually got activated.
|
||||
// Go through the providers that were requested, for each one:
|
||||
// If it was activated pass
|
||||
// else fail (throw exception)
|
||||
boolean failure = false;
|
||||
String failingName = "";
|
||||
for (String name : requestedNames) {
|
||||
File f = new File(name + ".txt");
|
||||
if (!f.exists()) {
|
||||
failure = true;
|
||||
failingName = name;
|
||||
break;
|
||||
}
|
||||
} // if get to here, no issues, so try next provider
|
||||
if (failure && passExpected) {
|
||||
throw new RuntimeException(failingName + " was not activated");
|
||||
}
|
||||
if (!failure && !passExpected) {
|
||||
String s = "Test passed but a failure was expected. ";
|
||||
s += "The requested providers were:\n";
|
||||
for (String name : requestedNames) {
|
||||
s += (" " + name + "\n");
|
||||
}
|
||||
throw new RuntimeException(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 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.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UncheckedIOException;
|
||||
import javax.accessibility.AccessibilityProvider;
|
||||
|
||||
public final class UnusedProvider extends AccessibilityProvider {
|
||||
|
||||
private static final String name = "UnusedProvider";
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void activate() {
|
||||
// Write to log to indicate activate was called.
|
||||
try (PrintWriter writer = new PrintWriter("UnusedProvider.txt")) {
|
||||
writer.println("UnusedProvider-activated");
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
115
test/jdk/javax/accessibility/AccessibilityProvider/basic.sh
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
#
|
||||
# Copyright (c) 2015, 2024, 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
|
||||
# @bug 8055160 8216008
|
||||
# @summary Unit test for javax.accessibility.AccessibilitySPI
|
||||
#
|
||||
# @build Load FooProvider BarProvider UnusedProvider
|
||||
# @run shell basic.sh
|
||||
|
||||
# Command-line usage: sh basic.sh /path/to/build
|
||||
|
||||
if [ -z "$TESTJAVA" ]; then
|
||||
if [ $# -lt 1 ]; then exit 1; fi
|
||||
TESTJAVA="$1"
|
||||
TESTSRC=`pwd`
|
||||
TESTCLASSES="`pwd`"
|
||||
fi
|
||||
|
||||
JAVA="$TESTJAVA/bin/java"
|
||||
|
||||
OS=`uname -s`
|
||||
case "$OS" in
|
||||
Darwin | AIX )
|
||||
FS='/'
|
||||
SEP=':' ;;
|
||||
Linux )
|
||||
FS='/'
|
||||
SEP=':' ;;
|
||||
* )
|
||||
FS='\\'
|
||||
SEP='\;' ;;
|
||||
esac
|
||||
|
||||
TESTD=x.test
|
||||
rm -rf $TESTD
|
||||
mkdir -p $TESTD
|
||||
|
||||
mv $TESTCLASSES/FooProvider.class $TESTD
|
||||
mv $TESTCLASSES/BarProvider.class $TESTD
|
||||
mv $TESTCLASSES/UnusedProvider.class $TESTD
|
||||
mkdir -p $TESTD/META-INF/services
|
||||
echo FooProvider >$TESTD/META-INF/services/javax.accessibility.AccessibilityProvider
|
||||
echo BarProvider >>$TESTD/META-INF/services/javax.accessibility.AccessibilityProvider
|
||||
echo UnusedProvider >>$TESTD/META-INF/services/javax.accessibility.AccessibilityProvider
|
||||
|
||||
|
||||
failures=0
|
||||
|
||||
go() {
|
||||
CP="$TESTCLASSES$SEP$TESTD"
|
||||
echo ''
|
||||
sh -xc "$JAVA -Djavax.accessibility.assistive_technologies=$PROVIDER1$COMMA$PROVIDER2 -cp $CP Load $1 $2 $3" 2>&1
|
||||
if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
|
||||
}
|
||||
|
||||
# find one provider
|
||||
PROVIDER1="FooProvider"
|
||||
go pass $PROVIDER1
|
||||
|
||||
# fail if no provider found
|
||||
PROVIDER1="NoProvider"
|
||||
go fail $PROVIDER1
|
||||
|
||||
# pass if none provider found
|
||||
PROVIDER1=
|
||||
go pass $PROVIDER1
|
||||
|
||||
PROVIDER1=" "
|
||||
go pass $PROVIDER1
|
||||
|
||||
# setup for two providers
|
||||
COMMA=","
|
||||
|
||||
# find two providers, both exist
|
||||
PROVIDER1="FooProvider"
|
||||
PROVIDER2="BarProvider"
|
||||
go pass $PROVIDER1 $PROVIDER2
|
||||
|
||||
# find two providers, where second one doesn't exist
|
||||
PROVIDER1="FooProvider"
|
||||
PROVIDER2="NoProvider"
|
||||
go fail $PROVIDER1 $PROVIDER2
|
||||
|
||||
# find two providers, where first one doesn't exist
|
||||
PROVIDER1="NoProvider"
|
||||
PROVIDER2="BarProvider"
|
||||
go fail $PROVIDER1 $PROVIDER2
|
||||
|
||||
echo ''
|
||||
if [ $failures -gt 0 ];
|
||||
then echo "$failures case(s) failed";
|
||||
else echo "All cases passed"; fi
|
||||
exit $failures
|
||||
|
||||
76
test/jdk/javax/accessibility/AccessibleBundle/Basic.java
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (c) 2019, 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.util.Locale;
|
||||
|
||||
import javax.accessibility.AccessibleBundle;
|
||||
|
||||
import static javax.accessibility.AccessibleRole.ALERT;
|
||||
import static javax.accessibility.AccessibleRole.LABEL;
|
||||
import static javax.accessibility.AccessibleRole.PANEL;
|
||||
import static javax.accessibility.AccessibleState.MANAGES_DESCENDANTS;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8213516
|
||||
* @summary Checks basic functionality of AccessibleBundle class
|
||||
*/
|
||||
public final class Basic extends AccessibleBundle {
|
||||
|
||||
private Basic(final String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public static void main(final String[] args) {
|
||||
testStandardResource();
|
||||
testCustomResource();
|
||||
}
|
||||
|
||||
private static void testCustomResource() {
|
||||
final Basic bundle = new Basic("managesDescendants");
|
||||
test(bundle.toDisplayString(Locale.ENGLISH), "manages descendants");
|
||||
test(bundle.toDisplayString("NonExistedBundle", Locale.ENGLISH),
|
||||
"managesDescendants");
|
||||
}
|
||||
|
||||
private static void testStandardResource() {
|
||||
test(ALERT.toDisplayString(Locale.ENGLISH), "alert");
|
||||
test(ALERT.toDisplayString(Locale.JAPAN), "\u30a2\u30e9\u30fc\u30c8");
|
||||
test(LABEL.toDisplayString(Locale.ENGLISH), "label");
|
||||
test(LABEL.toDisplayString(Locale.JAPAN), "\u30e9\u30d9\u30eb");
|
||||
test(PANEL.toDisplayString(Locale.ENGLISH), "panel");
|
||||
test(PANEL.toDisplayString(Locale.JAPAN), "\u30D1\u30CD\u30EB");
|
||||
test(MANAGES_DESCENDANTS.toDisplayString(Locale.ENGLISH),
|
||||
"manages descendants");
|
||||
test(MANAGES_DESCENDANTS.toDisplayString(Locale.JAPAN),
|
||||
"\u5B50\u5B6B\u3092\u7BA1\u7406");
|
||||
}
|
||||
|
||||
private static void test(final String actual, final String expected) {
|
||||
if (!actual.equals(expected)) {
|
||||
System.err.println("Expected: " + expected);
|
||||
System.err.println("Actual: " + actual);
|
||||
throw new RuntimeException("Wrong text");
|
||||
}
|
||||
}
|
||||
}
|
||||
173
test/jdk/javax/accessibility/AccessibleJTableSelectionTest.java
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
/*
|
||||
* Copyright (c) 2010, 2022, 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
|
||||
* @bug 4495286
|
||||
* @summary Verify that AccessibleJTable.setAccessibleSelction
|
||||
* selects rows/cols if getCellSelectionEnabled() is false
|
||||
* @run main AccessibleJTableSelectionTest
|
||||
*/
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Robot;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public final class AccessibleJTableSelectionTest {
|
||||
|
||||
private static JTable jTable;
|
||||
private static JFrame jFrame;
|
||||
|
||||
private static Robot robot;
|
||||
|
||||
private static void createGUI() {
|
||||
|
||||
Object[][] rowData = { { "RowData1", Integer.valueOf(1) },
|
||||
{ "RowData2", Integer.valueOf(2) },
|
||||
{ "RowData3", Integer.valueOf(3) } };
|
||||
Object[] columnData = { "Column One", "Column Two" };
|
||||
|
||||
jTable = new JTable(rowData, columnData);
|
||||
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
jTable.setRowSelectionAllowed(false);
|
||||
jTable.setColumnSelectionAllowed(false);
|
||||
jTable.setCellSelectionEnabled(true);
|
||||
|
||||
jFrame = new JFrame();
|
||||
jFrame.add(new JScrollPane(jTable), BorderLayout.CENTER);
|
||||
jFrame.setSize(200, 200);
|
||||
jFrame.setLocationRelativeTo(null);
|
||||
jFrame.setVisible(true);
|
||||
}
|
||||
|
||||
private static void doTest() throws Exception {
|
||||
SwingUtilities.invokeAndWait(() -> createGUI());
|
||||
|
||||
robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
jTable.requestFocus();
|
||||
jTable.getAccessibleContext().getAccessibleSelection()
|
||||
.addAccessibleSelection(1);
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (!jTable.isRowSelected(0) || !jTable.isColumnSelected(1)) {
|
||||
throw new RuntimeException(
|
||||
"Unexpected selection state of "
|
||||
+ "Table Row & Column");
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
jTable.setRowSelectionAllowed(true);
|
||||
jTable.setColumnSelectionAllowed(false);
|
||||
jTable.setCellSelectionEnabled(false);
|
||||
jTable.requestFocus();
|
||||
jTable.getAccessibleContext().getAccessibleSelection()
|
||||
.addAccessibleSelection(3);
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (!jTable.isRowSelected(1)) {
|
||||
throw new RuntimeException(
|
||||
"Unexpected selection state of "
|
||||
+ "Table Row & Column");
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
jTable.setRowSelectionAllowed(false);
|
||||
jTable.setColumnSelectionAllowed(true);
|
||||
jTable.setCellSelectionEnabled(false);
|
||||
jTable.requestFocus();
|
||||
jTable.getAccessibleContext().getAccessibleSelection()
|
||||
.addAccessibleSelection(4);
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (!jTable.isColumnSelected(0)) {
|
||||
throw new RuntimeException(
|
||||
"Unexpected selection state of "
|
||||
+ "Table Row & Column");
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
jTable.setRowSelectionAllowed(true);
|
||||
jTable.setColumnSelectionAllowed(true);
|
||||
jTable.setCellSelectionEnabled(false);
|
||||
jTable.requestFocus();
|
||||
jTable.getAccessibleContext().getAccessibleSelection()
|
||||
.addAccessibleSelection(5);
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (!(jTable.isRowSelected(2) && jTable.isColumnSelected(1))) {
|
||||
throw new RuntimeException(
|
||||
"Unexpected selection state of "
|
||||
+ "Table Row & Column");
|
||||
}
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
jTable.setCellSelectionEnabled(true);
|
||||
jTable.setColumnSelectionAllowed(true);
|
||||
jTable.setRowSelectionAllowed(true);
|
||||
jTable.requestFocus();
|
||||
jTable.getAccessibleContext().getAccessibleSelection()
|
||||
.addAccessibleSelection(4);
|
||||
});
|
||||
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (!(jTable.isRowSelected(2) && jTable.isColumnSelected(0)
|
||||
&& jTable.isCellSelected(2, 0))) {
|
||||
throw new RuntimeException(
|
||||
"Unexpected selection state of "
|
||||
+ "Table Row & Column");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void main(final String[] argv) throws Exception {
|
||||
doTest();
|
||||
SwingUtilities.invokeAndWait(() -> jFrame.dispose());
|
||||
System.out.println("Test Passed.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* Copyright (c) 2019, 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 javax.accessibility.AccessibleContext;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JRadioButtonMenuItem;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.SwingUtilities;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4949105
|
||||
* @summary Access Bridge lacks html tags parsing
|
||||
* @run main GetAccessibleNameTest
|
||||
*/
|
||||
|
||||
public class GetAccessibleNameTest {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
testConstructor();
|
||||
testSetText();
|
||||
testAccessibleProperty();
|
||||
}
|
||||
|
||||
private static void testConstructor() {
|
||||
Class[] testClass = new Class[] {
|
||||
JLabel.class, JButton.class, JMenuItem.class,
|
||||
JMenu.class, JCheckBoxMenuItem.class, JRadioButtonMenuItem.class,
|
||||
JToggleButton.class, JRadioButton.class, JCheckBox.class };
|
||||
|
||||
Class[] ctorArg = new Class[1];
|
||||
ctorArg[0] = String.class;
|
||||
String expectedText = "bold italic em mark del small big sup sub ins strong code strike";
|
||||
String inputText = "<html><style>{color:#FF0000;}</style><body>" +
|
||||
"<b>bold</b> <i>italic</i> <em>em</em> <mark>mark</mark> <del>del</del> " +
|
||||
"<small>small</small> <big>big</big> <sup>sup</sup> <sub>sub</sub> <ins>ins</ins> " +
|
||||
"<strong>strong</strong> <code>code</code> <strike>strike</strike>" +
|
||||
"</body></html>";
|
||||
|
||||
for (Class aClass : testClass) {
|
||||
try {
|
||||
Constructor constructor = aClass.getDeclaredConstructor(ctorArg);
|
||||
JComponent comp = (JComponent) constructor.newInstance(inputText);
|
||||
if (!expectedText.equals(comp.getAccessibleContext().getAccessibleName())) {
|
||||
throw new RuntimeException("AccessibleName of " + aClass.getName() + " is incorrect." +
|
||||
" Expected: " + expectedText +
|
||||
" Actual: " + comp.getAccessibleContext().getAccessibleName());
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(aClass.getName() + " does not have a constructor accepting" +
|
||||
"String parameter.", e.getCause());
|
||||
} catch (InstantiationException e) {
|
||||
throw new RuntimeException(aClass.getName() + " could not be instantiated.",
|
||||
e.getCause());
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(aClass.getName() + " constructor cannot be accessed.",
|
||||
e.getCause());
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new RuntimeException(aClass.getName() + " constructor cannot be invoked.",
|
||||
e.getCause());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void testSetText() {
|
||||
String text = "html text";
|
||||
JLabel testLabel = new JLabel("<html>" + text + "</html>");
|
||||
if (!text.equals(testLabel.getAccessibleContext().getAccessibleName())) {
|
||||
throw new RuntimeException("Incorrect AccessibleName," +
|
||||
" Expected: " + text +
|
||||
" Actual: " + testLabel.getAccessibleContext().getAccessibleName());
|
||||
}
|
||||
|
||||
text = "Non html text";
|
||||
testLabel.setText(text);
|
||||
if (!text.equals(testLabel.getAccessibleContext().getAccessibleName())) {
|
||||
throw new RuntimeException("Incorrect AccessibleName," +
|
||||
" Expected: " + text +
|
||||
" Actual: " + testLabel.getAccessibleContext().getAccessibleName());
|
||||
}
|
||||
}
|
||||
|
||||
private static void testAccessibleProperty() {
|
||||
String text = "html text";
|
||||
JLabel testLabel = new JLabel("<html>" + text + "</html>");
|
||||
if (!text.equals(testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY))) {
|
||||
throw new RuntimeException("Incorrect ACCESSIBLE_NAME_PROPERTY," +
|
||||
" Expected: " + text +
|
||||
" Actual: " + testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY));
|
||||
}
|
||||
|
||||
String namePropertyText = "name property";
|
||||
testLabel.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, namePropertyText);
|
||||
if (!namePropertyText.equals(testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY))) {
|
||||
throw new RuntimeException("Incorrect ACCESSIBLE_NAME_PROPERTY," +
|
||||
" Expected: " + namePropertyText +
|
||||
" Actual: " + testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY));
|
||||
}
|
||||
|
||||
text = "different html text";
|
||||
testLabel.setText("<html>" + text + "</html>");
|
||||
if (!namePropertyText.equals(testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY))) {
|
||||
throw new RuntimeException("Incorrect ACCESSIBLE_NAME_PROPERTY," +
|
||||
" Expected: " + namePropertyText +
|
||||
" Actual: " + testLabel.getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright (c) 2023, 2024, 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.BorderLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8283214
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @requires (os.family == "mac")
|
||||
* @summary Verifies if item selected in JComboBox magnifies using
|
||||
* screen magnifier a11y tool
|
||||
* @run main/manual TestJComboBoxScreenMagnifier
|
||||
*/
|
||||
|
||||
public class TestJComboBoxScreenMagnifier {
|
||||
private static JFrame frame;
|
||||
private static final String INSTRUCTIONS =
|
||||
"1) Enable Screen magnifier on the Mac\n\n" +
|
||||
"System Preference -> Accessibility -> Zoom -> " +
|
||||
"Select \"Enable Hover Text\"\n\n" +
|
||||
"2) Move the mouse over the combo box and press " +
|
||||
"\"Command\" button.\n\n" +
|
||||
"3) If magnified label is visible, press Pass else Fail.";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
PassFailJFrame passFailJFrame = PassFailJFrame.builder()
|
||||
.title("JComboBox Screen Magnifier Test Instructions")
|
||||
.instructions(INSTRUCTIONS)
|
||||
.testTimeOut(5)
|
||||
.rows(12)
|
||||
.columns(40)
|
||||
.screenCapture()
|
||||
.build();
|
||||
|
||||
SwingUtilities.invokeAndWait(TestJComboBoxScreenMagnifier::createAndShowUI);
|
||||
passFailJFrame.awaitAndCheck();
|
||||
}
|
||||
|
||||
private static void createAndShowUI() {
|
||||
frame = new JFrame("JComboBox A11Y Screen Magnifier Test");
|
||||
|
||||
String[] fruits = new String[] {"Apple", "Orange",
|
||||
"Mango", "Pineapple", "Banana"};
|
||||
JComboBox<String> comboBox = new JComboBox<String>(fruits);
|
||||
JPanel fruitPanel = new JPanel(new GridLayout(1, 2));
|
||||
JLabel fruitLabel = new JLabel("Fruits:", JLabel.CENTER);
|
||||
fruitLabel.getAccessibleContext().setAccessibleName("Fruits Label");
|
||||
fruitPanel.add(fruitLabel);
|
||||
fruitPanel.add(comboBox);
|
||||
comboBox.getAccessibleContext().setAccessibleName("Fruit Combo box");
|
||||
frame.getContentPane().add(fruitPanel, BorderLayout.CENTER);
|
||||
|
||||
PassFailJFrame.addTestWindow(frame);
|
||||
PassFailJFrame.positionTestWindow(frame,
|
||||
PassFailJFrame.Position.HORIZONTAL);
|
||||
frame.pack();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* Copyright (c) 2023, 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
|
||||
* @bug 8273986
|
||||
* @key headful
|
||||
* @requires (os.family == "windows")
|
||||
* @summary Verifies if accessible child count for JEditorPane HTML demo
|
||||
* returns correct child count.
|
||||
* @run main TestEditorPaneAccessibleChildCount
|
||||
*/
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import javax.accessibility.AccessibleContext;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.text.html.HTMLEditorKit;
|
||||
|
||||
public class TestEditorPaneAccessibleChildCount {
|
||||
private static JEditorPane jep;
|
||||
private static AccessibleContext ac;
|
||||
private static JFrame frame;
|
||||
private static int childCount1 = 0;
|
||||
private static int childCount2 = 0;
|
||||
|
||||
|
||||
public TestEditorPaneAccessibleChildCount() {
|
||||
createAndShowUI();
|
||||
}
|
||||
|
||||
public void createAndShowUI() {
|
||||
frame = new JFrame("JEditorPane A11Y Child Count Test");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
JPanel panel = new JPanel();
|
||||
jep = new JEditorPane();
|
||||
jep.setEditable(false);
|
||||
jep.setEditorKit(new HTMLEditorKit());
|
||||
URL url = TestEditorPaneAccessibleChildCount.class.
|
||||
getResource("test1.html");
|
||||
loadHtmlPage(url);
|
||||
JScrollPane jScrollPane = new JScrollPane(jep);
|
||||
jScrollPane.setPreferredSize(new Dimension(540,400));
|
||||
panel.add(jScrollPane);
|
||||
frame.getContentPane().add(panel, BorderLayout.CENTER);
|
||||
frame.setSize(560, 450);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
public static void loadHtmlPage(URL url) {
|
||||
try {
|
||||
jep.setPage(url);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void addDelay(int mSec) {
|
||||
try {
|
||||
Thread.sleep(mSec);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
new TestEditorPaneAccessibleChildCount();
|
||||
});
|
||||
|
||||
addDelay(500);
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
ac = jep.getAccessibleContext();
|
||||
childCount1 = ac.getAccessibleChildrenCount();
|
||||
});
|
||||
|
||||
URL url = TestEditorPaneAccessibleChildCount.class.
|
||||
getResource("test2.html");
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
loadHtmlPage(url);
|
||||
});
|
||||
addDelay(500);
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
childCount2 = ac.getAccessibleChildrenCount();
|
||||
if ((childCount1 != childCount2) &&
|
||||
(childCount1 != 0 && childCount2 != 0)) {
|
||||
System.out.println("passed");
|
||||
} else {
|
||||
System.out.println("Test1 html page accessible children" +
|
||||
" count is: " + childCount1);
|
||||
System.out.println("Test2 html page accessible children" +
|
||||
" count is: " + childCount2);
|
||||
throw new RuntimeException("getAccessibleChildrenCount" +
|
||||
" returned wrong child count");
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
10
test/jdk/javax/accessibility/JEditorPane/test1.html
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>Welcome to Java World</h1>
|
||||
<h2>Chapter 1</h2>
|
||||
<P>Introduction to Java</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
12
test/jdk/javax/accessibility/JEditorPane/test2.html
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
<h1>Welcome to Java World</h1>
|
||||
<h2>Chapter 1</h2>
|
||||
<P>Introduction to Java</p>
|
||||
<h2>Chapter 2</h2>
|
||||
<P>Data Types in Java</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2022, 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
|
||||
* @bug 4515031
|
||||
* @key headful
|
||||
* @summary The JFileChooser Dialog itself has no accessible description.
|
||||
* @run main JFileChooserAccessibleDescriptionTest
|
||||
*/
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public class JFileChooserAccessibleDescriptionTest {
|
||||
private static JFrame jFrame;
|
||||
private static JFileChooser jFileChooser;
|
||||
private static JButton jButton;
|
||||
|
||||
private static Robot robot;
|
||||
private static volatile String description;
|
||||
private static volatile int xLocn;
|
||||
private static volatile int yLocn;
|
||||
private static volatile int width;
|
||||
private static volatile int height;
|
||||
|
||||
public static void createGUI() {
|
||||
jFrame = new JFrame("bug4515031 Frame");
|
||||
jFileChooser = new JFileChooser();
|
||||
|
||||
jButton = new JButton("Show FileChooser");
|
||||
jButton.addActionListener(e -> jFileChooser.showDialog(jFrame, null));
|
||||
jFrame.getContentPane().add(jButton);
|
||||
jFrame.setSize(200, 100);
|
||||
jFrame.setLocationRelativeTo(null);
|
||||
jFrame.setVisible(true);
|
||||
}
|
||||
|
||||
public static void doTest() throws Exception {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> createGUI());
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(200);
|
||||
robot.setAutoWaitForIdle(true);
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
xLocn = jButton.getLocationOnScreen().x;
|
||||
yLocn = jButton.getLocationOnScreen().y;
|
||||
width = jButton.getSize().width;
|
||||
height = jButton.getSize().height;
|
||||
});
|
||||
|
||||
robot.mouseMove(xLocn + width / 2, yLocn + height / 2);
|
||||
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> description =
|
||||
jFileChooser.getAccessibleContext().getAccessibleDescription());
|
||||
|
||||
if (description != null) {
|
||||
System.out.println(
|
||||
"Accessibility Description " + "for JFileChooser is Set");
|
||||
} else {
|
||||
throw new RuntimeException("Accessibility Description for"
|
||||
+ "JFileChooser is not Set");
|
||||
}
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(() -> jFrame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 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.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.accessibility.Accessible;
|
||||
import javax.accessibility.AccessibleContext;
|
||||
import javax.swing.AbstractListModel;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
/* @test
|
||||
@key headful
|
||||
@bug 8076249
|
||||
@summary NPE in AccessBridge while editing JList model
|
||||
@author Mikhail Cherkasov
|
||||
@run main AccessibleJListChildNPETest
|
||||
*/
|
||||
public class AccessibleJListChildNPETest {
|
||||
|
||||
private static String[] model = { "1", "2", "3", "4", "5", "6" };
|
||||
private static JList<String> list;
|
||||
|
||||
public static void main(String[] args) throws InvocationTargetException, InterruptedException {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
JFrame frame = new JFrame();
|
||||
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
final MyModel dataModel = new MyModel(Arrays.asList(model));
|
||||
list = new JList<>(dataModel);
|
||||
frame.getContentPane().add(list);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AccessibleContext ac = list.getAccessibleContext();
|
||||
MyModel model = (MyModel)list.getModel();
|
||||
Accessible accessibleChild = ac.getAccessibleChild(model.getSize()-1);
|
||||
model.removeFirst();
|
||||
accessibleChild.getAccessibleContext().getAccessibleSelection();
|
||||
accessibleChild.getAccessibleContext().getAccessibleText();
|
||||
accessibleChild.getAccessibleContext().getAccessibleValue();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected static class MyModel extends AbstractListModel<String> {
|
||||
private List<String> items = new ArrayList<>();
|
||||
|
||||
MyModel(final List<String> newItems) {
|
||||
super();
|
||||
items.addAll(newItems);
|
||||
fireIntervalAdded(this, 0, getSize() - 1);
|
||||
}
|
||||
|
||||
void removeFirst() {
|
||||
if(getSize() > 0) {
|
||||
items.remove(0);
|
||||
fireIntervalRemoved(this, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementAt(int index) {
|
||||
return items.get(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
105
test/jdk/javax/accessibility/JMenu/TestJMenuScreenMagnifier.java
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Copyright (c) 2023, 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
|
||||
* @bug 8283404
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @requires (os.family == "mac")
|
||||
* @summary Verifies if JMenu accessibility label magnifies using
|
||||
* screen magnifier a11y tool.
|
||||
* @run main/manual TestJMenuScreenMagnifier
|
||||
*/
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public class TestJMenuScreenMagnifier {
|
||||
private static JFrame frame;
|
||||
private static final String INSTRUCTIONS =
|
||||
"1) Enable Screen magnifier on theMac \n\n" +
|
||||
"System Preference -> Accessibility -> Zoom -> " +
|
||||
"Select ( Enable Hover Text) \n\n" +
|
||||
"2) Move the mouse over the \"File\" or \"Edit\" menu by pressing " +
|
||||
"\"cmd\" button.\n\n" +
|
||||
"3) If magnified label is visible, Press Pass else Fail.";
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
PassFailJFrame passFailJFrame = new PassFailJFrame(
|
||||
"JMenu Screen Magnifier Test Instructions", INSTRUCTIONS, 5, 12, 40);
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(
|
||||
TestJMenuScreenMagnifier::createAndShowUI);
|
||||
passFailJFrame.awaitAndCheck();
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
private static void createAndShowUI() {
|
||||
frame = new JFrame("JMenu A11Y Screen Magnifier Test");
|
||||
|
||||
JMenu file = new JMenu("File");
|
||||
file.getAccessibleContext().setAccessibleName("File Menu");
|
||||
|
||||
JMenuItem open = new JMenuItem("Open");
|
||||
open.getAccessibleContext().setAccessibleName("Open MenuItem");
|
||||
|
||||
JMenuItem quit = new JMenuItem("Quit");
|
||||
quit.getAccessibleContext().setAccessibleName("Quit MenuItem");
|
||||
|
||||
file.add(open);
|
||||
file.add(quit);
|
||||
|
||||
JMenu edit = new JMenu("Edit");
|
||||
edit.getAccessibleContext().setAccessibleName("Edit Menu");
|
||||
|
||||
JMenuItem cut = new JMenuItem("Cut");
|
||||
cut.getAccessibleContext().setAccessibleName("Cut MenuItem");
|
||||
|
||||
edit.add(cut);
|
||||
|
||||
JMenuBar jMenuBar = new JMenuBar();
|
||||
|
||||
jMenuBar.add(file);
|
||||
jMenuBar.add(edit);
|
||||
|
||||
|
||||
PassFailJFrame.addTestWindow(frame);
|
||||
PassFailJFrame.positionTestWindow(frame,
|
||||
PassFailJFrame.Position.HORIZONTAL);
|
||||
frame.setJMenuBar(jMenuBar);
|
||||
frame.setSize(300, 100);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
}
|
||||
58
test/jdk/javax/accessibility/JRootPaneAccessiblAtTest.java
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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
|
||||
* @bug 4699544
|
||||
* @key headful
|
||||
* @summary AccessibleJRootPane always returns null for getAccessibleAt
|
||||
* @run main JRootPaneAccessiblAtTest
|
||||
*/
|
||||
import javax.accessibility.Accessible;
|
||||
import javax.accessibility.AccessibleComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JRootPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public class JRootPaneAccessiblAtTest extends JFrame {
|
||||
|
||||
public JRootPaneAccessiblAtTest() {
|
||||
JRootPane rootPane = getRootPane();
|
||||
AccessibleComponent accessibleComponent =
|
||||
rootPane.getAccessibleContext().getAccessibleComponent();
|
||||
Accessible accessible = accessibleComponent
|
||||
.getAccessibleAt(accessibleComponent.getLocation());
|
||||
if (accessible == null) {
|
||||
throw new RuntimeException("Test Failed: AccessibleJRootPane "
|
||||
+ "always returns null for getAccessibleAt()");
|
||||
} else {
|
||||
System.out.println("Test Passed: AccessibilityJRootPane returns "
|
||||
+ accessible + " for getAccessibleAt()");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
SwingUtilities.invokeAndWait(() -> new JRootPaneAccessiblAtTest());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2022, 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
|
||||
* @bug 4702690
|
||||
* @key headful
|
||||
* @summary Make an automatic AccessibleRelation between
|
||||
* JScrollBars and what they scroll (TP)
|
||||
* @run main JScrollPaneAccessibleRelationsTest
|
||||
*/
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
import javax.accessibility.AccessibleRelation;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JScrollBar;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public class JScrollPaneAccessibleRelationsTest
|
||||
implements PropertyChangeListener {
|
||||
|
||||
private static JFrame jFrame;
|
||||
private static JScrollPane jScrollPane;
|
||||
private static JScrollBar horizontalScrollBar;
|
||||
private static JScrollBar verticalScrollBar;
|
||||
|
||||
private static Object[] jScrollPaneTarget;
|
||||
private static Object[] horizontalScrollBarTarget;
|
||||
private static Object[] verticalScrollBarTarget;
|
||||
|
||||
public static void createGUI() {
|
||||
jFrame = new JFrame();
|
||||
|
||||
jScrollPane = new JScrollPane();
|
||||
horizontalScrollBar = jScrollPane.createHorizontalScrollBar();
|
||||
verticalScrollBar = jScrollPane.createVerticalScrollBar();
|
||||
jScrollPane.setHorizontalScrollBar(horizontalScrollBar);
|
||||
jScrollPane.setVerticalScrollBar(verticalScrollBar);
|
||||
|
||||
jFrame.getContentPane().add(jScrollPane);
|
||||
}
|
||||
|
||||
public static void doTest() throws Exception {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> createGUI());
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> jScrollPaneTarget =
|
||||
jScrollPane.getAccessibleContext().getAccessibleRelationSet()
|
||||
.get(AccessibleRelation.CONTROLLED_BY).getTarget());
|
||||
SwingUtilities.invokeAndWait(
|
||||
() -> horizontalScrollBarTarget = horizontalScrollBar
|
||||
.getAccessibleContext().getAccessibleRelationSet()
|
||||
.get(AccessibleRelation.CONTROLLER_FOR).getTarget());
|
||||
SwingUtilities
|
||||
.invokeAndWait(() -> verticalScrollBarTarget = verticalScrollBar
|
||||
.getAccessibleContext().getAccessibleRelationSet()
|
||||
.get(AccessibleRelation.CONTROLLER_FOR).getTarget());
|
||||
|
||||
if (!(jScrollPaneTarget[0] instanceof javax.swing.JScrollBar)) {
|
||||
throw new RuntimeException("JScrollPane doesn't have "
|
||||
+ "JScrollBar as target for CONTROLLED_BY");
|
||||
}
|
||||
if (!(jScrollPaneTarget[1] instanceof javax.swing.JScrollBar)) {
|
||||
throw new RuntimeException("JScrollPane doesn't have "
|
||||
+ "JScrollBar as target for CONTROLLED_BY");
|
||||
}
|
||||
if (!(horizontalScrollBarTarget[0] instanceof JScrollPane)) {
|
||||
throw new RuntimeException("HorizontalScrollBar doesn't have "
|
||||
+ "JScrollPane as target for CONTROLLER_FOR");
|
||||
}
|
||||
if (!(verticalScrollBarTarget[0] instanceof JScrollPane)) {
|
||||
throw new RuntimeException("VerticalScrollBar doesn't have "
|
||||
+ "JScrollPane as target for CONTROLLER_FOR");
|
||||
}
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(() -> jFrame.dispose());
|
||||
}
|
||||
}
|
||||
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
if (!("AccessibleActiveDescendant".equals(e.getPropertyName()))) {
|
||||
throw new RuntimeException(
|
||||
"Active Descendant of JScrollBar has not changed");
|
||||
}
|
||||
if (!("AccessibleSelection".equals(e.getPropertyName()))) {
|
||||
throw new RuntimeException(
|
||||
"Accessible Selection of JScrollBar has not changed");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
doTest();
|
||||
System.out.println("Test Passed.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,282 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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
|
||||
* @bug 8262981
|
||||
* @key headful
|
||||
* @summary Test JSlider Accessibility doAccessibleAction(int)
|
||||
* @run main JSliderAccessibleAction
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Container;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javax.accessibility.AccessibleAction;
|
||||
import javax.accessibility.AccessibleContext;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
public class JSliderAccessibleAction {
|
||||
|
||||
private static JFrame jFrame;
|
||||
private static JSlider jSlider;
|
||||
private static JButton decrementBtn;
|
||||
private static JButton incrementBtn;
|
||||
private static JButton invalidDecrementBtn;
|
||||
private static JButton invalidIncrementBtn;
|
||||
private static final int INVALID_DECREMENT = 2;
|
||||
private static final int INVALID_INCREMENT = -1;
|
||||
private static final int VALID_DECREMENT = 1;
|
||||
private static final int VALID_INCREMENT = 0;
|
||||
private static volatile int currentJSliderValue;
|
||||
private static volatile int jSliderInitialValue;
|
||||
private static volatile CountDownLatch invalidDecrementCountDownLatch;
|
||||
private static volatile CountDownLatch invalidIncrementCountDownLatch;
|
||||
private static volatile CountDownLatch validDecrementCountDownLatch;
|
||||
private static volatile CountDownLatch validIncrementCountDownLatch;
|
||||
|
||||
private static void createTestUI() {
|
||||
jFrame = new JFrame("Test JSlider Accessible Action");
|
||||
jSlider = new JSlider();
|
||||
AccessibleContext ac = jSlider.getAccessibleContext();
|
||||
ac.setAccessibleName("JSlider Accessible Test");
|
||||
|
||||
AccessibleContext accessibleContext = jSlider.getAccessibleContext();
|
||||
AccessibleAction accessibleAction =
|
||||
accessibleContext.getAccessibleAction();
|
||||
|
||||
if (accessibleAction == null) {
|
||||
throw new RuntimeException("JSlider getAccessibleAction() should " +
|
||||
"not be null");
|
||||
}
|
||||
|
||||
if (accessibleAction.getAccessibleActionCount() != 2) {
|
||||
throw new RuntimeException("JSlider AccessibleAction supports " +
|
||||
"only two actions ( AccessibleAction.DECREMENT & " +
|
||||
"AccessibleAction.INCREMENT ) but got " + accessibleAction.getAccessibleActionCount());
|
||||
}
|
||||
|
||||
JLabel jSliderValueLbl = new JLabel("JSlider value : " + jSlider.getValue() + "%",
|
||||
JLabel.CENTER);
|
||||
Container container = jFrame.getContentPane();
|
||||
|
||||
container.add(jSliderValueLbl, BorderLayout.NORTH);
|
||||
container.add(jSlider, BorderLayout.CENTER);
|
||||
|
||||
jSlider.addChangeListener((changeEvent) -> {
|
||||
currentJSliderValue = jSlider.getValue();
|
||||
jSliderValueLbl.setText("JSlider value : " + currentJSliderValue + "%");
|
||||
System.out.println("changed : " + changeEvent);
|
||||
});
|
||||
|
||||
invalidDecrementBtn = new JButton("Invalid Decrement");
|
||||
invalidDecrementBtn.addActionListener((actionEvent) -> {
|
||||
invalidDecrementCountDownLatch.countDown();
|
||||
accessibleAction.doAccessibleAction(INVALID_DECREMENT);
|
||||
});
|
||||
|
||||
invalidIncrementBtn = new JButton("Invalid Increment");
|
||||
invalidIncrementBtn.addActionListener((actionEvent) -> {
|
||||
invalidIncrementCountDownLatch.countDown();
|
||||
accessibleAction.doAccessibleAction(INVALID_INCREMENT);
|
||||
});
|
||||
|
||||
decrementBtn = new JButton("Decrement");
|
||||
decrementBtn.addActionListener((actionEvent) -> {
|
||||
validDecrementCountDownLatch.countDown();
|
||||
accessibleAction.doAccessibleAction(VALID_DECREMENT);
|
||||
});
|
||||
|
||||
incrementBtn = new JButton("Increment");
|
||||
incrementBtn.addActionListener((actionEvent) -> {
|
||||
accessibleAction.doAccessibleAction(VALID_INCREMENT);
|
||||
validIncrementCountDownLatch.countDown();
|
||||
});
|
||||
|
||||
JPanel buttonPanel = new JPanel(new GridLayout(4, 1));
|
||||
buttonPanel.add(invalidDecrementBtn);
|
||||
buttonPanel.add(invalidIncrementBtn);
|
||||
buttonPanel.add(decrementBtn);
|
||||
buttonPanel.add(incrementBtn);
|
||||
container.add(buttonPanel, BorderLayout.SOUTH);
|
||||
|
||||
jFrame.pack();
|
||||
jFrame.setLocationRelativeTo(null);
|
||||
jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
jFrame.setVisible(true);
|
||||
}
|
||||
|
||||
private static boolean setLookAndFeel(String lafName) {
|
||||
try {
|
||||
UIManager.setLookAndFeel(lafName);
|
||||
} catch (UnsupportedLookAndFeelException unsupportedLookAndFeelException) {
|
||||
System.out.println("Ignoring Unsupported laf : " + lafName);
|
||||
return false;
|
||||
} catch (ClassNotFoundException | InstantiationException
|
||||
| IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void testJSliderAccessibleAction() throws AWTException,
|
||||
InterruptedException, InvocationTargetException {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(300);
|
||||
robot.waitForIdle();
|
||||
|
||||
List<String> installedLookAndFeels =
|
||||
Arrays.stream(UIManager.getInstalledLookAndFeels())
|
||||
.map(UIManager.LookAndFeelInfo::getClassName).collect(toList());
|
||||
|
||||
for (String lookAndFeel : installedLookAndFeels) {
|
||||
try {
|
||||
invalidDecrementCountDownLatch = new CountDownLatch(1);
|
||||
invalidIncrementCountDownLatch = new CountDownLatch(1);
|
||||
validDecrementCountDownLatch = new CountDownLatch(1);
|
||||
validIncrementCountDownLatch = new CountDownLatch(1);
|
||||
currentJSliderValue = 0;
|
||||
jSliderInitialValue = 0;
|
||||
System.out.println("Testing JSliderAccessibleAction in " + lookAndFeel +
|
||||
" look and feel");
|
||||
|
||||
AtomicBoolean lafSetSuccess = new AtomicBoolean(false);
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
lafSetSuccess.set(setLookAndFeel(lookAndFeel));
|
||||
if (lafSetSuccess.get()) {
|
||||
createTestUI();
|
||||
}
|
||||
});
|
||||
if (!lafSetSuccess.get()) continue;
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
jSliderInitialValue = jSlider.getValue();
|
||||
currentJSliderValue = jSlider.getValue();
|
||||
});
|
||||
robot.waitForIdle();
|
||||
mouseAction(robot, invalidDecrementBtn);
|
||||
if (!invalidDecrementCountDownLatch.await(30,
|
||||
TimeUnit.SECONDS)) {
|
||||
throw new RuntimeException("Failed to perform action on Invalid " +
|
||||
"Decrement button");
|
||||
}
|
||||
|
||||
if (jSliderInitialValue != currentJSliderValue ) {
|
||||
throw new RuntimeException("Expected that JSlider value is not " +
|
||||
"changed when invalid decrement value 2 is passed to " +
|
||||
"doAccessibleAction(2) jSliderInitialValue = "
|
||||
+ jSliderInitialValue + " currentJSliderValue = " + currentJSliderValue);
|
||||
}
|
||||
|
||||
mouseAction(robot, invalidIncrementBtn);
|
||||
if (!invalidIncrementCountDownLatch.await(30,
|
||||
TimeUnit.SECONDS)) {
|
||||
throw new RuntimeException("Failed to perform action on Invalid " +
|
||||
"Increment button");
|
||||
}
|
||||
if (jSliderInitialValue != currentJSliderValue) {
|
||||
throw new RuntimeException("Expected that JSlider value is not " +
|
||||
"changed when invalid decrement value -1 is passed to " +
|
||||
"doAccessibleAction(-1) jSliderInitialValue = "
|
||||
+ jSliderInitialValue + " currentJSliderValue = " + currentJSliderValue);
|
||||
}
|
||||
|
||||
// JSlider value is decremented
|
||||
mouseAction(robot, decrementBtn);
|
||||
if (!validDecrementCountDownLatch.await(30, TimeUnit.SECONDS)) {
|
||||
throw new RuntimeException("Failed to perform action on valid " +
|
||||
"decrement button");
|
||||
}
|
||||
if (jSliderInitialValue == currentJSliderValue ) {
|
||||
throw new RuntimeException("Expected that JSlider value is " +
|
||||
"decremented when value 1 is passed to " +
|
||||
"doAccessibleAction(1) jSliderInitialValue = "
|
||||
+ jSliderInitialValue + " currentJSliderValue = " + currentJSliderValue);
|
||||
}
|
||||
|
||||
// JSlider value is incremented
|
||||
mouseAction(robot, incrementBtn);
|
||||
if (!validIncrementCountDownLatch.await(30, TimeUnit.SECONDS)) {
|
||||
throw new RuntimeException("Failed to perform action on valid " +
|
||||
"Increment button");
|
||||
}
|
||||
if (jSliderInitialValue != currentJSliderValue ) {
|
||||
throw new RuntimeException("Expected that JSlider value is " +
|
||||
"incremented when value 0 is passed to " +
|
||||
"doAccessibleAction(0) jSliderInitialValue = "
|
||||
+ jSliderInitialValue + " currentJSliderValue = " + currentJSliderValue);
|
||||
}
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (jFrame != null) {
|
||||
jFrame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void mouseAction(Robot robot, JButton button) throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
robot.waitForIdle();
|
||||
Point[] point = new Point[1];
|
||||
Rectangle[] rect = new Rectangle[1];
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
point[0] = button.getLocationOnScreen();
|
||||
rect[0] = button.getBounds();
|
||||
});
|
||||
|
||||
robot.mouseMove(point[0].x + rect[0].width / 2,
|
||||
point[0].y + rect[0].height / 2);
|
||||
robot.waitForIdle();
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.waitForIdle();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException, InvocationTargetException, AWTException {
|
||||
testJSliderAccessibleAction();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* Copyright (c) 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.GridLayout;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.SpinnerListModel;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8286258
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @requires (os.family == "mac")
|
||||
* @summary Checks that JSpinner with custom model announces
|
||||
* the value every time it is changed
|
||||
* @run main/manual CustomSpinnerAccessibilityTest
|
||||
*/
|
||||
|
||||
public class CustomSpinnerAccessibilityTest extends JPanel {
|
||||
private static final String INSTRUCTIONS = """
|
||||
1. Turn on VoiceOver
|
||||
2. In the window named "Test UI" click on the text editor inside the
|
||||
spinner component
|
||||
3. Using up and down arrows change current month
|
||||
4. Wait for the VoiceOver to finish speaking
|
||||
5. Repeat steps 3 and 4 couple more times
|
||||
|
||||
If every time value of the spinner is changed VoiceOver
|
||||
announces the new value click "Pass".
|
||||
If instead the value is narrated only partially
|
||||
and the new value is never fully narrated press "Fail".
|
||||
""";
|
||||
|
||||
public CustomSpinnerAccessibilityTest() {
|
||||
super(new GridLayout(0, 2));
|
||||
String[] monthStrings = new java.text.DateFormatSymbols().getMonths();
|
||||
int lastIndex = monthStrings.length - 1;
|
||||
if (monthStrings[lastIndex] == null
|
||||
|| monthStrings[lastIndex].length() <= 0) {
|
||||
String[] tmp = new String[lastIndex];
|
||||
System.arraycopy(monthStrings, 0,
|
||||
tmp, 0, lastIndex);
|
||||
monthStrings = tmp;
|
||||
}
|
||||
|
||||
SpinnerListModel model = new SpinnerListModel(monthStrings);
|
||||
JLabel label = new JLabel("Month: ");
|
||||
add(label);
|
||||
JSpinner spinner = new JSpinner(model);
|
||||
label.setLabelFor(spinner);
|
||||
add(spinner);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException {
|
||||
PassFailJFrame.builder()
|
||||
.title("Custom Spinner Accessibility Test")
|
||||
.instructions(INSTRUCTIONS)
|
||||
.testUI(CustomSpinnerAccessibilityTest::new)
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright (c) 2025, 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.BorderLayout;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8361283
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @requires (os.family == "mac")
|
||||
* @summary VO shouldn't announce the tab items as RadioButton
|
||||
* @run main/manual AccessibleTabbedPaneRoleTest
|
||||
*/
|
||||
|
||||
public class AccessibleTabbedPaneRoleTest {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String INSTRUCTIONS = """
|
||||
This test is applicable only on macOS.
|
||||
|
||||
Test UI contains a JFrame containing JTabbedPane with multiple tabs.
|
||||
|
||||
Follow these steps to test the behaviour:
|
||||
|
||||
1. Start the VoiceOver (Press Command + F5) application.
|
||||
2. Test Frame should have focus. If not, then bring focus to test frame.
|
||||
3. Press Left / Right arrow key to move to next and prevoius tab.
|
||||
4. VO should announce "Tab" in stead of "RadioButton" for tab items.
|
||||
(For e.g. When Tab 1 is selected, VO should announce "Tab 1, selected,
|
||||
tab, group).
|
||||
5. Press Pass if you are able to hear correct announcements
|
||||
else Fail.""";
|
||||
|
||||
PassFailJFrame.builder()
|
||||
.instructions(INSTRUCTIONS)
|
||||
.columns(45)
|
||||
.testUI(AccessibleTabbedPaneRoleTest::createUI)
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
private static JFrame createUI() {
|
||||
int NUM_TABS = 6;
|
||||
JFrame frame = new JFrame("Test Frame");
|
||||
JTabbedPane tabPane = new JTabbedPane();
|
||||
tabPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
|
||||
tabPane.setTabPlacement(JTabbedPane.TOP);
|
||||
for (int i = 0; i < NUM_TABS; ++i) {
|
||||
tabPane.addTab("Tab " + i , new JLabel("Content Area"));
|
||||
}
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.add(tabPane, BorderLayout.CENTER);
|
||||
frame.add(panel);
|
||||
frame.setSize(400, 100);
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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 javax.accessibility.AccessibleValue;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8283387
|
||||
* @summary [macos] a11y : Screen magnifier does not show selected Tab
|
||||
* JTabbedPane accessible children had no AccessibleValue manipulation API
|
||||
* Testing this API since it was added in the fix for 8283387
|
||||
* @run main AccessibleTabbedPaneTest
|
||||
*/
|
||||
|
||||
public class AccessibleTabbedPaneTest {
|
||||
public static void main(String[] args) {
|
||||
JTabbedPane pane = new JTabbedPane();
|
||||
JPanel p1, p2, p3;
|
||||
p1 = new JPanel();
|
||||
p2 = new JPanel();
|
||||
p3 = new JPanel();
|
||||
pane.add("One", p1);
|
||||
pane.add("Two", p2);
|
||||
pane.add("Three", p3);
|
||||
for (int i = 0; i < pane.getAccessibleContext().getAccessibleChildrenCount(); i++) {
|
||||
if (pane.getAccessibleContext()
|
||||
.getAccessibleChild(i)
|
||||
.getAccessibleContext()
|
||||
.getAccessibleValue() == null) {
|
||||
throw new RuntimeException("Test failed, accessible value for tab "+ i + " is null");
|
||||
}
|
||||
}
|
||||
AccessibleValue p2a = pane.getAccessibleContext()
|
||||
.getAccessibleChild(1)
|
||||
.getAccessibleContext()
|
||||
.getAccessibleValue();
|
||||
// Select second tab using a11y API.
|
||||
if (p2a.setCurrentAccessibleValue(1)) {
|
||||
if (pane.getSelectedIndex() != 1) {
|
||||
throw new RuntimeException("Can not change tab selection using a11y API");
|
||||
}
|
||||
}
|
||||
|
||||
// Try to deselect it - that should not be allowed
|
||||
if (p2a.setCurrentAccessibleValue(0)) {
|
||||
throw new RuntimeException("We should not be able to deselect "
|
||||
+ "currently selected tab via a11y API");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,192 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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
|
||||
@bug 8277922
|
||||
@key headful
|
||||
@summary TableCellRenderer of JTable cell with Boolean data should not
|
||||
support any AccessibleAction.
|
||||
*/
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Robot;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import javax.accessibility.Accessible;
|
||||
import javax.accessibility.AccessibleAction;
|
||||
import javax.accessibility.AccessibleContext;
|
||||
import javax.accessibility.AccessibleTable;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
|
||||
public class BooleanRendererHasAccessibleActionTest {
|
||||
private volatile JFrame frame;
|
||||
private volatile JTable table;
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException, AWTException {
|
||||
final BooleanRendererHasAccessibleActionTest test =
|
||||
new BooleanRendererHasAccessibleActionTest();
|
||||
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
test.createGUI();
|
||||
}
|
||||
});
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
test.runTest();
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
test.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void createGUI() {
|
||||
frame = new JFrame("BooleanRendererHasAccessibleActionTest");
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
Container content = frame.getContentPane();
|
||||
content.setLayout(new BorderLayout());
|
||||
|
||||
String[] tblColNames = {"Column 1", "Column 2", "Column 3"};
|
||||
Object[][] tblData = {
|
||||
{Boolean.TRUE, "Text 1", Boolean.FALSE},
|
||||
{Boolean.FALSE, "Text 2", Boolean.TRUE}
|
||||
};
|
||||
final DefaultTableModel tblModel = new DefaultTableModel(
|
||||
tblData, tblColNames) {
|
||||
@Override
|
||||
public Class<?> getColumnClass(int column) {
|
||||
return getValueAt(0, column).getClass();
|
||||
}
|
||||
};
|
||||
table = new JTable(tblModel);
|
||||
table.setPreferredScrollableViewportSize(new Dimension(400, 100));
|
||||
|
||||
JScrollPane tblScroller = new JScrollPane(table);
|
||||
tblScroller.setHorizontalScrollBarPolicy(
|
||||
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||
tblScroller.setVerticalScrollBarPolicy(
|
||||
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS
|
||||
);
|
||||
content.add(tblScroller, BorderLayout.CENTER);
|
||||
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private void dispose() {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
frame = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void runTest() {
|
||||
if (table == null) {
|
||||
throw new RuntimeException("'table' should not be null");
|
||||
}
|
||||
|
||||
testAccessibleActionInCellRenderer(0, 0, true);
|
||||
testAccessibleActionInCellRenderer(1, 0, true);
|
||||
testAccessibleActionInCellRenderer(0, 2, true);
|
||||
testAccessibleActionInCellRenderer(1, 2, true);
|
||||
|
||||
testAccessibleActionInCell(0, 0, true);
|
||||
testAccessibleActionInCell(1, 0, true);
|
||||
testAccessibleActionInCell(0, 2, true);
|
||||
testAccessibleActionInCell(1, 2, true);
|
||||
|
||||
System.out.println("Test passed.");
|
||||
}
|
||||
|
||||
private void testAccessibleActionInCellRenderer(int row, int column,
|
||||
boolean shouldBeNull) {
|
||||
System.out.println(String.format(
|
||||
"testAccessibleActionInCellRenderer():" +
|
||||
" row='%d', column='%d', shouldBeNull='%b'",
|
||||
row, column, shouldBeNull));
|
||||
|
||||
TableCellRenderer cellRenderer = table.getCellRenderer(row, column);
|
||||
if (!(cellRenderer instanceof Accessible)) {
|
||||
throw new RuntimeException("'cellRenderer' is not Accessible");
|
||||
}
|
||||
|
||||
AccessibleContext cellRendererAc =
|
||||
((Accessible) cellRenderer).getAccessibleContext();
|
||||
if (cellRendererAc == null) {
|
||||
throw new RuntimeException("'cellRendererAc' should not be null");
|
||||
}
|
||||
|
||||
AccessibleAction cellRendererAa = cellRendererAc.getAccessibleAction();
|
||||
if ((shouldBeNull && (cellRendererAa != null)) ||
|
||||
(!shouldBeNull && (cellRendererAa == null))) {
|
||||
throw new RuntimeException(
|
||||
"Test failed. 'cellRendererAa' is not as should be");
|
||||
}
|
||||
}
|
||||
|
||||
private void testAccessibleActionInCell(int row, int column,
|
||||
boolean shouldBeNull) {
|
||||
System.out.println(String.format("testAccessibleActionInCell():" +
|
||||
" row='%d', column='%d', shouldBeNull='%b'",
|
||||
row, column, shouldBeNull));
|
||||
|
||||
AccessibleContext tblAc = table.getAccessibleContext();
|
||||
AccessibleTable accessibleTbl = tblAc.getAccessibleTable();
|
||||
if (accessibleTbl == null) {
|
||||
throw new RuntimeException("'accessibleTbl' should not be null");
|
||||
}
|
||||
|
||||
Accessible cellAccessible = accessibleTbl.getAccessibleAt(row, column);
|
||||
AccessibleContext cellAc = cellAccessible.getAccessibleContext();
|
||||
if (cellAc == null) {
|
||||
throw new RuntimeException("'cellAc' should not be null");
|
||||
}
|
||||
|
||||
AccessibleAction cellAa = cellAc.getAccessibleAction();
|
||||
if ((shouldBeNull && (cellAa != null)) ||
|
||||
(!shouldBeNull && (cellAa == null))) {
|
||||
throw new RuntimeException(
|
||||
"Test failed. 'cellAa' is not as should be");
|
||||
}
|
||||
}
|
||||
}
|
||||
91
test/jdk/javax/accessibility/JTable/JTableCellEditor.java
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright (c) 2019, 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.EventQueue;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.accessibility.AccessibleRole;
|
||||
import javax.accessibility.AccessibleTable;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8226653
|
||||
* @key headful
|
||||
* @summary The active cell editor should be reported as a child of the table.
|
||||
* Note that the accessibility API ignores the real children of the
|
||||
* table, but reports the "virtual" child per cell in the grid.
|
||||
*/
|
||||
public final class JTableCellEditor {
|
||||
|
||||
private static final int COUNT = 3;
|
||||
private static JTable table;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(final String[] args)
|
||||
throws InvocationTargetException, InterruptedException {
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
frame = new JFrame();
|
||||
table = new JTable(testSelectionWithFilterTable());
|
||||
frame.add(table);
|
||||
frame.pack();
|
||||
});
|
||||
EventQueue.invokeAndWait(() -> table.editCellAt(1, 1));
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
AccessibleTable aTable = table.getAccessibleContext()
|
||||
.getAccessibleTable();
|
||||
int aColumns = aTable.getAccessibleColumnCount();
|
||||
int aRows = aTable.getAccessibleRowCount();
|
||||
// We cannot assume which component will be used as an editor of the
|
||||
// table cell, but we can expect it will have the "text" role.
|
||||
AccessibleRole role = aTable.getAccessibleAt(1, 1)
|
||||
.getAccessibleContext()
|
||||
.getAccessibleRole();
|
||||
frame.dispose();
|
||||
if (!role.toDisplayString(Locale.ENGLISH).equals("text")) {
|
||||
throw new RuntimeException("Unexpected role: " + role);
|
||||
}
|
||||
if (aColumns != COUNT) {
|
||||
throw new RuntimeException("Wrong columns: " + aColumns);
|
||||
}
|
||||
if (aRows != COUNT) {
|
||||
throw new RuntimeException("Wrong rows: " + aRows);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a dummy table model.
|
||||
*/
|
||||
private static TableModel testSelectionWithFilterTable() {
|
||||
DefaultTableModel model = new DefaultTableModel(0, 3);
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
model.addRow(new Object[]{i + "x0", i + "x1", i + "x2"});
|
||||
}
|
||||
return model;
|
||||
}
|
||||
}
|
||||
71
test/jdk/javax/accessibility/MaximumAccessibleValueTest.java
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2022, 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
|
||||
* @bug 4422362
|
||||
* @summary Wrong Max Accessible Value with BoundedRangeModel components
|
||||
* @run main MaximumAccessibleValueTest
|
||||
*/
|
||||
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.JScrollBar;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public class MaximumAccessibleValueTest {
|
||||
|
||||
public static void doTest() {
|
||||
|
||||
JScrollBar jScrollBar = new JScrollBar();
|
||||
JProgressBar jProgressBar = new JProgressBar();
|
||||
JSlider jSlider = new JSlider();
|
||||
|
||||
if (((Integer) jScrollBar.getAccessibleContext().getAccessibleValue()
|
||||
.getMaximumAccessibleValue()).intValue() != jScrollBar.getMaximum()
|
||||
- jScrollBar.getVisibleAmount()) {
|
||||
throw new RuntimeException(
|
||||
"Wrong MaximumAccessibleValue returned by JScrollBar");
|
||||
}
|
||||
|
||||
if (((Integer) jProgressBar.getAccessibleContext().getAccessibleValue()
|
||||
.getMaximumAccessibleValue().intValue()) != (jProgressBar
|
||||
.getMaximum() - jProgressBar.getModel().getExtent())) {
|
||||
throw new RuntimeException(
|
||||
"Wrong MaximumAccessibleValue returned by JProgressBar");
|
||||
}
|
||||
|
||||
if (((Integer) jSlider.getAccessibleContext().getAccessibleValue()
|
||||
.getMaximumAccessibleValue()).intValue() != jSlider.getMaximum()
|
||||
- jSlider.getModel().getExtent()) {
|
||||
throw new RuntimeException(
|
||||
"Wrong MaximumAccessibleValue returned by JSlider");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeAndWait(() -> doTest());
|
||||
System.out.println("Test Passed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2022, 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
|
||||
* @bug 4422535
|
||||
* @summary setCurrentAccessibleValue returns true only for an Integer
|
||||
* @run main SetCurrentAccessibleValueTest
|
||||
*/
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JInternalFrame;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.JScrollBar;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public class SetCurrentAccessibleValueTest {
|
||||
|
||||
public static void doTest() {
|
||||
JComponent[] jComponents =
|
||||
{ new JButton(), new JInternalFrame(), new JSplitPane(),
|
||||
new JScrollBar(), new JProgressBar(), new JSlider() };
|
||||
|
||||
for (JComponent jComponent : jComponents) {
|
||||
testIt(jComponent, (Float.valueOf(5)));
|
||||
testIt(jComponent, (Double.valueOf(37.266)));
|
||||
testIt(jComponent, (Integer.valueOf(10)));
|
||||
testIt(jComponent, (Long.valueOf(123L)));
|
||||
testIt(jComponent, (Short.valueOf((short) 123)));
|
||||
testIt(jComponent, (BigInteger.ONE));
|
||||
testIt(jComponent, (new BigDecimal(BigInteger.ONE)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void testIt(JComponent jComponent, Number number) {
|
||||
if (!jComponent.getAccessibleContext().getAccessibleValue()
|
||||
.setCurrentAccessibleValue(number)) {
|
||||
throw new RuntimeException(jComponent.getClass().getName()
|
||||
+ " Accessible Value implementation doesn't accept "
|
||||
+ number.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeAndWait(() -> doTest());
|
||||
System.out.println("Test Passed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* Copyright (c) 2018, 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.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 8202768
|
||||
* @summary we should not hang when lots of panels are used
|
||||
*/
|
||||
public final class SlowPanelIteration {
|
||||
|
||||
private static JFrame frame;
|
||||
private static Point center = new Point();
|
||||
private static volatile CountDownLatch go;
|
||||
|
||||
public static void main(final String[] args) throws Exception {
|
||||
Robot r = new Robot();
|
||||
// accessibility tool will need time to react to our clicks
|
||||
r.setAutoDelay(200);
|
||||
try {
|
||||
EventQueue.invokeAndWait(SlowPanelIteration::showUI);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
go = new CountDownLatch(1);
|
||||
r.mouseMove(center.x, center.y);
|
||||
r.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
if (!go.await(10, TimeUnit.SECONDS)) {
|
||||
throw new RuntimeException("Too slow operation");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
EventQueue.invokeAndWait(SlowPanelIteration::dispose);
|
||||
}
|
||||
}
|
||||
|
||||
private static void showUI() {
|
||||
frame = new JFrame();
|
||||
frame.setSize(new Dimension(400, 400));
|
||||
frame.setLocationRelativeTo(null);
|
||||
|
||||
final Container content = frame.getContentPane();
|
||||
content.setLayout(new BorderLayout(0, 0));
|
||||
Container lastPanel = content;
|
||||
for (int i = 0; i < 500; i++) {
|
||||
final JPanel p = new JPanel();
|
||||
p.setLayout(new BorderLayout(0, 0));
|
||||
lastPanel.add(p);
|
||||
lastPanel.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
System.out.println("click");
|
||||
go.countDown();
|
||||
}
|
||||
});
|
||||
lastPanel = p;
|
||||
}
|
||||
|
||||
lastPanel.setBackground(Color.GREEN);
|
||||
frame.setVisible(true);
|
||||
|
||||
Point loc = frame.getLocationOnScreen();
|
||||
center.x = loc.x + frame.getWidth() / 2;
|
||||
center.y = loc.y + frame.getHeight() / 2;
|
||||
}
|
||||
|
||||
private static void dispose() {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
2
test/jdk/javax/accessibility/TEST.properties
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
modules=java.desktop
|
||||
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* Copyright (c) 2025, 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.BorderLayout;
|
||||
import java.awt.GridLayout;
|
||||
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JToggleButton;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8348936 8345728
|
||||
* @summary Verifies that VoiceOver announces the untick state of CheckBox and
|
||||
* ToggleButton when space key is pressed. Also verifies that CheckBox
|
||||
* and ToggleButton untick state is magnified with Screen Magnifier.
|
||||
* @requires os.family == "mac"
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @run main/manual TestJCheckBoxToggleAccessibility
|
||||
*/
|
||||
|
||||
public class TestJCheckBoxToggleAccessibility {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String INSTRUCTIONS = """
|
||||
<html><body>
|
||||
<p><b>Testing with VoiceOver</b></p>
|
||||
|
||||
<ol>
|
||||
<li>Start the VoiceOver application
|
||||
(Press <kbd>Command</kbd> + <kbd>F5</kbd>)
|
||||
<li>Click on the <i>Frame with CheckBox and ToggleButton</i>
|
||||
window to move focus
|
||||
<li>Press <kbd>Spacebar</kbd>
|
||||
<li>VO should announce the checked state
|
||||
<li>Press <kbd>Spacebar</kbd> again
|
||||
<li>VO should announce the unchecked state
|
||||
<li>Press <kbd>Tab</kbd> to move focus to <i>ToggleButton</i>
|
||||
<li>Repeat steps 3 to 6 and listen the announcement
|
||||
<li>If announcements are incorrect, press <b>Fail</b>
|
||||
<li>Stop the VoiceOver application
|
||||
(Press <kbd>Command</kbd> + <kbd>F5</kbd> again)
|
||||
</ol>
|
||||
|
||||
<p><b>Testing with Screen Magnifier</b></p>
|
||||
<ol style="margin-bottom: 0">
|
||||
<li>Enable Screen magnifier on the Mac:
|
||||
<b>System Settings</b> -> <b>Accessibility</b> ->
|
||||
<b>Hover Text</b> -> Enable <b>Hover Text</b><br>
|
||||
Default Hover Text Activation Modifier is <kbd>Command</kbd> key
|
||||
<li>Move focus back to the test application and perform the following tests
|
||||
|
||||
<ul style="margin-bottom: 0">
|
||||
<li>Test <i>CheckBox</i> states with Screen Magnifier
|
||||
<ol style="list-style-type: lower-alpha; margin-top: 0; margin-bottom: 0">
|
||||
<li>Click on <i>CheckBox</i> to select it
|
||||
<li>Press the <kbd>Command</kbd> key and
|
||||
hover mouse over <i>CheckBox</i>
|
||||
<li>CheckBox ticked state along with its label should be magnified
|
||||
<li>Keep the <kbd>Command</kbd> key pressed and
|
||||
click <i>CheckBox</i> to deselect it
|
||||
<li>CheckBox unticked state along with its label should be magnified
|
||||
<li>Release the <kbd>Command</kbd> key
|
||||
<li>If Screen Magnifier behaviour is incorrect, press <b>Fail</b>
|
||||
</ol>
|
||||
<li>Test <i>ToggleButton</i> states with Screen Magnifier
|
||||
<ol style="list-style-type: lower-alpha; margin-top: 0; margin-bottom: 0">
|
||||
<li>Click on <i>ToggleButton</i> to select it
|
||||
<li>Press the <kbd>Command</kbd> key and
|
||||
hover mouse over <i>ToggleButton</i>
|
||||
<li>Ticked state along with label should be magnified
|
||||
<li>Keep the <kbd>Command</kbd> button pressed and
|
||||
click <i>ToggleButton</i> to deselect it
|
||||
<li>Unticked state along with its label should be magnified
|
||||
<li>Release the <kbd>Command</kbd> key
|
||||
<li>If Screen Magnifier behaviour is incorrect, press <b>Fail</b>
|
||||
</ol>
|
||||
</ul>
|
||||
<li>Disable <b>Hover Text</b> (optionally) in the Settings
|
||||
</ol>
|
||||
|
||||
<p>Press <b>Pass</b> if you are able to hear correct VoiceOver announcements and
|
||||
able to see the correct screen magnifier behaviour.</p></body></html>""";
|
||||
|
||||
PassFailJFrame.builder()
|
||||
.title("TestJCheckBoxToggleAccessibility Instruction")
|
||||
.instructions(INSTRUCTIONS)
|
||||
.columns(40)
|
||||
.rows(25)
|
||||
.testUI(TestJCheckBoxToggleAccessibility::createUI)
|
||||
.testTimeOut(8)
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
private static JFrame createUI() {
|
||||
JFrame frame = new JFrame("A Frame with CheckBox and ToggleButton");
|
||||
JCheckBox cb = new JCheckBox("CheckBox", false);
|
||||
JToggleButton tb = new JToggleButton("ToggleButton");
|
||||
|
||||
JPanel p = new JPanel(new GridLayout(2, 1));
|
||||
p.add(cb);
|
||||
p.add(tb);
|
||||
frame.getContentPane().add(p, BorderLayout.CENTER);
|
||||
frame.setSize(400, 400);
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* Copyright (c) 2025, 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.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8339728
|
||||
* @summary Tests that JAWS announce the shortcuts for JMenuItems.
|
||||
* @requires os.family == "windows"
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @run main/manual TestJMenuItemShortcutAccessibility
|
||||
*/
|
||||
|
||||
public class TestJMenuItemShortcutAccessibility {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String INSTRUCTIONS = """
|
||||
1. Start the JAWS application
|
||||
2. Press Alt + M to open application Menu
|
||||
3. Navigate the Menu Items by using UP / DOWN arrow key
|
||||
4. Press Pass if you are able to hear correct JAWS announcements
|
||||
(JAWS should read full shortcut text and not only the 1st
|
||||
character of shortcut text for each menu item) else Fail
|
||||
""";
|
||||
|
||||
PassFailJFrame.builder()
|
||||
.title("TestJMenuItemShortcutAccessibility Instruction")
|
||||
.instructions(INSTRUCTIONS)
|
||||
.columns(35)
|
||||
.testUI(TestJMenuItemShortcutAccessibility::createUI)
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
private static JFrame createUI() {
|
||||
JFrame frame = new JFrame("A Frame with Menu");
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
JMenu menu = new JMenu("Menu with shortcuts");
|
||||
menu.setMnemonic(KeyEvent.VK_M);
|
||||
menuBar.add(menu);
|
||||
|
||||
KeyStroke keyStroke1 = KeyStroke.getKeyStroke(KeyEvent.VK_F,
|
||||
InputEvent.CTRL_DOWN_MASK);
|
||||
KeyStroke keyStroke2 = KeyStroke.getKeyStroke(KeyEvent.VK_2,
|
||||
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK);
|
||||
KeyStroke keyStroke3 = KeyStroke.getKeyStroke(KeyEvent.VK_F1,
|
||||
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK);
|
||||
KeyStroke keyStroke4 = KeyStroke.getKeyStroke(KeyEvent.VK_COMMA,
|
||||
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK);
|
||||
KeyStroke keyStroke5 = KeyStroke.getKeyStroke(KeyEvent.VK_PERIOD,
|
||||
InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK);
|
||||
KeyStroke keyStroke6 = KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
|
||||
InputEvent.CTRL_DOWN_MASK);
|
||||
KeyStroke keyStroke7 = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE,
|
||||
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK);
|
||||
|
||||
JMenuItem menuItem1 = new JMenuItem("First Menu Item");
|
||||
menuItem1.setAccelerator(keyStroke1);
|
||||
JMenuItem menuItem2 = new JMenuItem("Second Menu Item");
|
||||
menuItem2.setAccelerator(keyStroke2);
|
||||
JMenuItem menuItem3 = new JMenuItem("Third Menu Item");
|
||||
menuItem3.setAccelerator(keyStroke3);
|
||||
JMenuItem menuItem4 = new JMenuItem("Fourth Menu Item");
|
||||
menuItem4.setAccelerator(keyStroke4);
|
||||
JMenuItem menuItem5 = new JMenuItem("Fifth Menu Item");
|
||||
menuItem5.setAccelerator(keyStroke5);
|
||||
JMenuItem menuItem6 = new JMenuItem("Sixth Menu Item");
|
||||
menuItem6.setAccelerator(keyStroke6);
|
||||
JMenuItem menuItem7 = new JMenuItem("Seventh Menu Item");
|
||||
menuItem7.setAccelerator(keyStroke7);
|
||||
|
||||
menu.add(menuItem1);
|
||||
menu.add(menuItem2);
|
||||
menu.add(menuItem3);
|
||||
menu.add(menuItem4);
|
||||
menu.add(menuItem5);
|
||||
menu.add(menuItem6);
|
||||
menu.add(menuItem7);
|
||||
|
||||
frame.setJMenuBar(menuBar);
|
||||
frame.setSize(300, 200);
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
75
test/jdk/javax/accessibility/TestJSpinnerAccessibility.java
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright (c) 2025, 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.BorderLayout;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.SpinnerModel;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8286204
|
||||
* @summary Verifies that VoiceOver announces the JSpinner's value correctly
|
||||
* @requires os.family == "mac"
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @run main/manual TestJSpinnerAccessibility
|
||||
*/
|
||||
|
||||
public class TestJSpinnerAccessibility {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String INSTRUCTIONS = """
|
||||
Test UI contains a JSpinner with minimum value 0, maximum value 20
|
||||
and current value 5. On press of up / down arrow, value will be
|
||||
incremented / decremented by 1.
|
||||
|
||||
Follow these steps to test the behaviour:
|
||||
|
||||
1. Start the VoiceOver (Press Command + F5) application
|
||||
2. Move focus on test window if it is not focused
|
||||
3. Press Up / Down arrow to increase / decrease Spinner value
|
||||
4. VO should announce correct values in terms of percentage
|
||||
(e.g. For JSpinner's value 10, VO should announce 50%)
|
||||
5. Press Pass if you are able to hear correct announcements
|
||||
else Fail""";
|
||||
|
||||
PassFailJFrame.builder()
|
||||
.title("TestJSpinnerAccessibility Instruction")
|
||||
.instructions(INSTRUCTIONS)
|
||||
.columns(40)
|
||||
.testUI(TestJSpinnerAccessibility::createUI)
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
private static JFrame createUI() {
|
||||
JFrame frame = new JFrame("A Frame with JSpinner");
|
||||
SpinnerModel spinnerModel = new SpinnerNumberModel(5, 0, 20, 1);
|
||||
JSpinner spinner = new JSpinner(spinnerModel);
|
||||
frame.getContentPane().add(spinner, BorderLayout.CENTER);
|
||||
frame.setSize(200, 100);
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
109
test/jdk/javax/accessibility/TestPopupMenuChildCount.java
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* Copyright (c) 2025, 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.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8341311
|
||||
* @summary Verifies that VoiceOver announces correct number of child for PopupMenu on macOS
|
||||
* @requires os.family == "mac"
|
||||
* @library /java/awt/regtesthelpers
|
||||
* @build PassFailJFrame
|
||||
* @run main/manual TestPopupMenuChildCount
|
||||
*/
|
||||
|
||||
public class TestPopupMenuChildCount {
|
||||
public static void main(String[] args) throws Exception {
|
||||
String INSTRUCTIONS = """
|
||||
This test is applicable only on macOS.
|
||||
|
||||
Test UI contains an empty JFrame. On press of left/right mouse button,
|
||||
a PopupMenu will be visible.
|
||||
|
||||
Follow these steps to test the behaviour:
|
||||
|
||||
1. Start the VoiceOver (Press Command + F5) application
|
||||
2. Press Left/Right mouse button inside test frame window to open
|
||||
the PopupMenu
|
||||
3. VO should announce "Menu" with number of child items of the Popupmenu
|
||||
4. Press Up/Down arrow to traverse popupmenu child items
|
||||
5. Press Right arrow key to open submenu
|
||||
6. VO should announce "Menu" with correct number of child items
|
||||
for the submenu (For e.g. When Submenu-1 is open, VO should announce
|
||||
"Menu 4 items")
|
||||
7. Repeat the process for other submenus
|
||||
8. Press Pass if you are able to hear correct announcements
|
||||
else Fail""";
|
||||
|
||||
PassFailJFrame.builder()
|
||||
.instructions(INSTRUCTIONS)
|
||||
.columns(45)
|
||||
.testUI(TestPopupMenuChildCount::createUI)
|
||||
.build()
|
||||
.awaitAndCheck();
|
||||
}
|
||||
|
||||
private static JFrame createUI() {
|
||||
JFrame frame = new JFrame("Test Frame");
|
||||
|
||||
JPopupMenu popupmenu = new JPopupMenu();
|
||||
JMenuItem mi1 = new JMenuItem("MenuItem-1");
|
||||
JMenuItem mi2 = new JMenuItem("MenuItem-2");
|
||||
JMenuItem mi3 = new JMenuItem("MenuItem-3");
|
||||
popupmenu.add(mi1);
|
||||
popupmenu.add(mi2);
|
||||
popupmenu.add(mi3);
|
||||
|
||||
JMenu submenu1 = new JMenu("Submenu-1");
|
||||
submenu1.add("subOne");
|
||||
submenu1.add("subTwo");
|
||||
submenu1.add("subThree");
|
||||
|
||||
JMenu submenu2 = new JMenu("Submenu-2");
|
||||
submenu2.add("subOne");
|
||||
submenu2.add("subTwo");
|
||||
|
||||
JMenu submenu3 = new JMenu ("Submenu-3");
|
||||
submenu3.add("subOne");
|
||||
submenu1.add(submenu3);
|
||||
|
||||
popupmenu.add(submenu1);
|
||||
popupmenu.add(submenu2);
|
||||
|
||||
frame.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
popupmenu.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
frame.setSize(300, 300);
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
79
test/jdk/javax/accessibility/manual/ButtonDemo.html
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<!--
|
||||
Copyright (c) 2022, 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.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
table, th, td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:5%;">S.No</th>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:25%;">Test</th>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:75%;">Scenario</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>Button Demo</td>
|
||||
<td>
|
||||
<ol>
|
||||
<li>Press Left/Right arrow key until the Button Demo icon <img src="./resource/rbtn.png"> has focus. Press 'space' to
|
||||
choose.<br>
|
||||
<li> Tab until the "Button Demo" tab has focus. Press 'space'. Press 'tab'.<br>
|
||||
<li> Use the arrow keys to navigate between "Buttons", "Radio Buttons", and "Check Boxes".<br>
|
||||
<li> Tab to enter the demo pane. Tab & Shift-Tab to move between each button.<br>
|
||||
<li> Press 'space' to trigger (i.e. "press") a button.<br>
|
||||
<li> Repeat steps 1 through 5 for the <b>Radio Button</b> & <b>Check Boxes</b> tabs.<br>
|
||||
</ol>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3"><b>Expected Result</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3">
|
||||
<ol>
|
||||
<li>Verify that as you navigate, the focus is shown, e.g.</li>
|
||||
<img src="./resource/btn.png">
|
||||
<li>As you press 'space' to trigger each button, verify that you see each button visually depress.
|
||||
e.g.:
|
||||
</li>
|
||||
<img src="./resource/dep.png">
|
||||
</ol>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3"><b>Note: actual component appearence may vary depending on look and
|
||||
feel.</b></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
28
test/jdk/javax/accessibility/manual/ButtonDemo.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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 manual test for accessibility button demo
|
||||
@run main/manual SwingSetTest ButtonDemo
|
||||
*/
|
||||
73
test/jdk/javax/accessibility/manual/ComboBoxDemo.html
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<!--
|
||||
Copyright (c) 2022, 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.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
table, th, td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:5%;">S.No</th>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:25%;">Test</th>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:75%;">Scenario</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>ComboBox Demo</td>
|
||||
<td>
|
||||
<ol>
|
||||
<li>Press Left/Right arrow key until ComboBox icon<img src="./resource/cmb.png"> has focus. Press 'Space' to choose.</li>
|
||||
<li>Tab until the "ComboBox Demo" tab has focus. Press 'space'. Press 'tab'.</li>
|
||||
<li> Use Tab and Shift-Tab to move between the four ComboBox widgets.
|
||||
<li>Use the space and down arrow keys to bring up the drop-down list.</li>
|
||||
<li> Use the up and down arrows to navigate up and down the list.</li>
|
||||
<li>Use the 'space' key to make the selection.</li>
|
||||
<li> Repeat 4,5 but hit Esc key to cancel the drop-down.</li>
|
||||
</ol>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3"><b>Expected Result</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3">
|
||||
<ol>
|
||||
<li>Verify that space and down arrow bring up the drop-down list.</li>
|
||||
<img src="./resource/list.png">
|
||||
<li>Verify that up and down arrows move up and down the list.</li>
|
||||
<li>Verify that 'space' makes the selection (the drop-down list should collapse).</li>
|
||||
</ol>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
28
test/jdk/javax/accessibility/manual/ComboBoxDemo.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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 manual test for accessibility button demo
|
||||
@run main/manual SwingSetTest ComboBoxDemo
|
||||
*/
|
||||
66
test/jdk/javax/accessibility/manual/DemoSelection.html
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<!--
|
||||
Copyright (c) 2022, 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.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
table, th, td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:5%;">S.No</th>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:25%;">Test</th>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:75%;">Scenario</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>Demo Selection</td>
|
||||
<td>Move between demos with 'tab' and 'shift-tab', and left and right arrows. Type 'space' to activate a demo.
|
||||
<img src="./resource/dms.png">
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3"><b>Expected Result</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3">
|
||||
Verify that there is visible focus as you tab (or arrow) between demo icons. Typing 'space' should change
|
||||
the selected demo.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3"><b>Note: actual component appearence may vary depending on look and
|
||||
feel.</b></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
28
test/jdk/javax/accessibility/manual/DemoSelection.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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 manual test for accessibility button demo
|
||||
@run main/manual SwingSetTest DemoSelection
|
||||
*/
|
||||
76
test/jdk/javax/accessibility/manual/OptionPaneDemo.html
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<!--
|
||||
Copyright (c) 2022, 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.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
table, th, td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:5%;">S.No</th>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:25%;">Test</th>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:75%;">Scenario</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>OptionPane Demo</td>
|
||||
<td>
|
||||
<ol>
|
||||
<li>Press Left/Right arrow key until the OptionPane icon <img src="./resource/op.png">has focus. Press 'space' to choose.
|
||||
<li>Tab until the "OptionPane Demo" tab has focus. Press 'space'. Press 'tab'. The 'Show Input Dialog'
|
||||
button should have focus.
|
||||
<li>Press 'space'. An Input dialog should pop up. Type some text, and hit return. The dialog should
|
||||
change to a Message dialog with text saying "That was a pretty good movie!" Press return.
|
||||
<li>Bring up the dialog again (space). Press 'esc' and confirm that the dialog goes away without the
|
||||
Message from above.
|
||||
<li>Press Tab to move down through the buttons, and select "Component Dialog Example" (press space). A
|
||||
dialog should appear. Tab to ensure that you can navigate through all the components:<br>
|
||||
a. Textfield<br>
|
||||
b. ComboBox<br>
|
||||
c. All 4 buttons: "Cancel", "Probably", "Maybe", "No", "Yes".<br>
|
||||
d. Press 'esc' to cancel the dialog.<br>
|
||||
</ol>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3">
|
||||
<b>Expected Result</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3">
|
||||
When a popup window is created, focus must be on the popup window; when the window is closed, focus must
|
||||
return to the previous focus point.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
29
test/jdk/javax/accessibility/manual/OptionPaneDemo.java
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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 manual test for accessibility button demo
|
||||
@run main/manual SwingSetTest OptionPaneDemo
|
||||
*/
|
||||
|
||||
79
test/jdk/javax/accessibility/manual/README.md
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<!--
|
||||
Copyright (c) 2022, 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.
|
||||
-->
|
||||
|
||||
# Manual javax.accessibility test suite
|
||||
|
||||
## Configure environment
|
||||
|
||||
### Swing Set 2
|
||||
|
||||
Prepare an appropriate version of Swing Set 2 from JDK demos.
|
||||
|
||||
### Acessibility frameworks
|
||||
|
||||
Testing can be performed without an accessibility framework or with one of these frameworks:
|
||||
|
||||
1. Windows
|
||||
1. JAWS
|
||||
2. NVDA
|
||||
2. Mac OS X
|
||||
1. Voice over
|
||||
|
||||
## Executing a test run
|
||||
|
||||
* Start the required accessibility framework, if necessary
|
||||
* Swing Set 2 jar default location is
|
||||
<code><tested jdk>/demo/jfc/SwingSet2/SwingSet2.jar</code>
|
||||
* To override Swing Set 2 jar use <code>SWINGSET2_JAR</code> environment variable:
|
||||
|
||||
|
||||
jtreg ... -e:SWINGSET2_JAR=<file location> -m .../javax/accessibility/manual/...
|
||||
|
||||
|
||||
## Performing tests
|
||||
|
||||
When a test a started, a UI appears consisting of two frames: test framework frame and Swing Set 2 frame. Test framework
|
||||
frame will contain a name of the test in the title and detailed instructions.
|
||||
|
||||
1. Follow the test instructions
|
||||
2. If everything goes as expected
|
||||
1. Push "Pass"
|
||||
2. UI for this test closes
|
||||
3. If something goes not accordding to the instructions:
|
||||
1. Push "Fail"
|
||||
2. A screenshot is taken automatically
|
||||
3. Describe the problem
|
||||
4. Retake the screenshot, if necessary
|
||||
1. Interract with the Swing Set 2 UI to make it showing the failure. Hit "Retake screenshot"
|
||||
2. If to demonstrate the failure the UI need to be in a state which prevents using test framework UI, such as model dialogs need to be opened or menu expanded
|
||||
1. Enter delay (in seconds)
|
||||
2. Push "Retake screenshot"
|
||||
3. Prepare the UI
|
||||
4. Wait for the screenshot to be retaken
|
||||
5. Push "Fail" button again
|
||||
6. Screenshot and the description are saved for further analysis
|
||||
7. Test UI closes
|
||||
|
||||
**Wasning: Do not close any window directly, all windows will be closed once the test is finished as passed or failed.**
|
||||
|
||||
**Note: Keyboard navigation is supported throughout the test framework UI.**
|
||||
79
test/jdk/javax/accessibility/manual/SliderDemo.html
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<!--
|
||||
Copyright (c) 2022, 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.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
table, th, td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:5%;">S.No</th>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:25%;">Test</th>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:75%;">Scenario</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>Test Slider Demo (test different Sliders and its values should changing when
|
||||
different keys are pressed and mouse drag and click action are performed).</td>
|
||||
<td>
|
||||
<ol>
|
||||
<li>Tab or use array keys until the Slider icon <img src="./resource/jsliderIcon.gif"> has focus on it.</li>
|
||||
<li>Press 'space' to choose Slider Demo. Press tab key to move the focus on the slider.</li>
|
||||
<li>Pressing Left / Down arrow keys will decrease the Slider value.</li>
|
||||
<li>Pressing Right / Up arrow keys will increase the Slider value.</li>
|
||||
<li>Pressing Home key Slider value is set to initial value</li>
|
||||
<li>Pressing End key Slider value is set to final or maximum value</li>
|
||||
<li>Pressing PageUp / PageDown key Slider value is jump to the value range
|
||||
value set.</li>
|
||||
<li>Use mouse to drag the slider head or thumb to increase or decrease the slider value.</li>
|
||||
<li>Disabled Slider value will not change.</li>
|
||||
</ol>
|
||||
<img src="./resource/Slider.png">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3">
|
||||
<b>Expected Result</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3">
|
||||
Verify that Slider value should change according to the Key press key release and mouse
|
||||
action.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3"><b>Note: actual component appearence may vary depending on look and
|
||||
feel.</b></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
28
test/jdk/javax/accessibility/manual/SliderDemo.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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 manual test for accessibility Slider demo
|
||||
@run main/manual SwingSetTest SliderDemo
|
||||
*/
|
||||
56
test/jdk/javax/accessibility/manual/SwingSetTest.java
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||
*/
|
||||
|
||||
import lib.ManualTestFrame;
|
||||
import lib.TestResult;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.function.Supplier;
|
||||
import javax.swing.JEditorPane;
|
||||
|
||||
import static java.io.File.separator;
|
||||
|
||||
public class SwingSetTest {
|
||||
|
||||
public static void main(String[] args) throws IOException, InterruptedException,
|
||||
ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||
System.out.println("test image " + System.getenv("TEST_IMAGE_DIR"));
|
||||
|
||||
Consumer<JEditorPane> testInstructionProvider = e -> {
|
||||
try {
|
||||
e.setContentType("text/html");
|
||||
e.setPage(SwingSetTest.class.getResource(args[0] + ".html"));
|
||||
} catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
};
|
||||
|
||||
Supplier<TestResult> resultSupplier = ManualTestFrame.showUI(args[0],
|
||||
"Wait for SwingSet2 to load, follow the instructions, select pass or fail. " +
|
||||
"Do not close windows manually.",
|
||||
testInstructionProvider);
|
||||
|
||||
String swingSetJar = System.getenv("SWINGSET2_JAR");
|
||||
if (swingSetJar == null) {
|
||||
swingSetJar = "file://" + System.getProperty("java.home") +
|
||||
separator + "demo" +
|
||||
separator + "jfc" +
|
||||
separator + "SwingSet2" +
|
||||
separator + "SwingSet2.jar";
|
||||
}
|
||||
System.out.println("Loading SwingSet2 from " + swingSetJar);
|
||||
ClassLoader ss = new URLClassLoader(new URL[]{new URL(swingSetJar)});
|
||||
ss.loadClass("SwingSet2").getMethod("main", String[].class).invoke(null, (Object)new String[0]);
|
||||
|
||||
//this will block until user decision to pass or fail the test
|
||||
TestResult result = resultSupplier.get();
|
||||
ManualTestFrame.handleResult(result, args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
79
test/jdk/javax/accessibility/manual/TableDemo.html
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<!--
|
||||
Copyright (c) 2022, 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.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
table, th, td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:5%;">S.No</th>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:25%;">Test</th>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:75%;">Scenario</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>Table Demo (tests table navigation, as well as textfield input)</td>
|
||||
<td>
|
||||
<ol>
|
||||
<li>Press Left/Right arrow key until the Table icon <img src="./resource/tbld.png"> has focus. Press 'space' to choose.
|
||||
<li>Tab until the "Table Demo" tab has focus. Press 'space'. Press 'tab'. "Reordering allowed" should
|
||||
have focus.
|
||||
<li>Tab to the Printing/Header textfield. Verify that you can type in some text.
|
||||
<li>Continue tabbing until focus moves to the table. The table should show focus.
|
||||
<li>Press the down arrow. "Mike Albers" should have focus.
|
||||
<li>Use the right and left arrow keys to navigate between cells.
|
||||
<li>Set focus to a text cell (e.g. someone's first name). Press space to edit. Type some text. Hit
|
||||
'enter' and verify the text has been changed. After editing a text cell and hitting 'enter', the
|
||||
focus could remain on the current cell or go to the next line.
|
||||
<li>Press the 'Page Up' and 'Page Down' keys (if available on your keyboard); verify that the Table
|
||||
scrolls up and down, page by page.
|
||||
<ol><br>
|
||||
<img src="./resource/tbl.png">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3">
|
||||
<b>Expected Result</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3">
|
||||
See above test description.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3"><b>Note: actual component appearence may vary depending on look and
|
||||
feel.</b></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
28
test/jdk/javax/accessibility/manual/TableDemo.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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 manual test for accessibility button demo
|
||||
@run main/manual SwingSetTest TableDemo
|
||||
*/
|
||||
67
test/jdk/javax/accessibility/manual/TabsDemo.html
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<!--
|
||||
Copyright (c) 2022, 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.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
table, th, td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:5%;">S.No</th>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:25%;">Test</th>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:75%;">Scenario</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>Tabs within demos (tests table navigation, as well as textfield input)</td>
|
||||
<td>
|
||||
Continue tabbing to enter a demo's pane. When the top demo tabs have focus, the left and right arrow keys
|
||||
move between tabs.<br>
|
||||
<img src="./resource/ifm.png">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3">
|
||||
<b>Expected Result</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3">
|
||||
Verify that the selected tab changes, e.g. between 'Internal Frame Demo' and "Source Code'.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3"><b>Note: actual component appearence may vary depending on look and
|
||||
feel.</b></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
29
test/jdk/javax/accessibility/manual/TabsDemo.java
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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 manual test for accessibility button demo
|
||||
@run main/manual SwingSetTest TabsDemo
|
||||
*/
|
||||
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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 manual test for accessibility JProgressBar
|
||||
@run main/manual TestJProgressBarAccessibility
|
||||
*/
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import javax.accessibility.AccessibleContext;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import lib.ManualTestFrame;
|
||||
import lib.TestResult;
|
||||
|
||||
public class TestJProgressBarAccessibility {
|
||||
|
||||
private static JFrame frame;
|
||||
private static volatile int value = 10;
|
||||
private static final String instruction = """
|
||||
Aim : Check whether JProgressBar value is read in case of VoiceOver or
|
||||
Screen magnifier shows the magnified value in case of Screen magnifier is enabled
|
||||
1) Move the mouse pointer over the JProgressBar and if you
|
||||
hear the JProgressBar value in case of VoiceOver then the test pass else fail.
|
||||
2) Move the mouse pointer over the JProgressBar and if you see the magnified value
|
||||
when Screen magnifier is enabled then the test pass else fail.
|
||||
""";
|
||||
|
||||
private static void createTestUI() throws InterruptedException, InvocationTargetException {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
frame = new JFrame("Test JProgressBar accessibility");
|
||||
JProgressBar progressBar = new JProgressBar();
|
||||
progressBar.setValue(value);
|
||||
progressBar.setStringPainted(true);
|
||||
|
||||
progressBar.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
super.mouseClicked(e);
|
||||
if ( value == 100) {
|
||||
value = 0;
|
||||
} else {
|
||||
value += 5;
|
||||
}
|
||||
progressBar.setValue(value);
|
||||
}
|
||||
});
|
||||
|
||||
AccessibleContext accessibleContext =
|
||||
progressBar.getAccessibleContext();
|
||||
accessibleContext.setAccessibleName("JProgressBar accessibility name");
|
||||
accessibleContext.setAccessibleDescription("Jprogress accessibility " +
|
||||
"description");
|
||||
|
||||
frame.getContentPane().add(progressBar, BorderLayout.CENTER);
|
||||
|
||||
frame.setSize(200,200);
|
||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
});
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException,
|
||||
InvocationTargetException, IOException {
|
||||
|
||||
Consumer<JEditorPane> testInstProvider = e -> {
|
||||
e.setContentType("text/plain");
|
||||
e.setText(instruction);
|
||||
};
|
||||
|
||||
Supplier<TestResult> resultSupplier = ManualTestFrame.showUI(
|
||||
"JProgressBar " +
|
||||
"Accessibility Test", "Wait until the Test UI is " +
|
||||
"seen", testInstProvider);
|
||||
|
||||
// Create and show TestUI
|
||||
createTestUI();
|
||||
|
||||
//this will block until user decision to pass or fail the test
|
||||
TestResult testResult = resultSupplier.get();
|
||||
ManualTestFrame.handleResult(testResult,"TestJProgressBarAccessibility");
|
||||
}
|
||||
}
|
||||
|
||||
65
test/jdk/javax/accessibility/manual/TreeDemo.html
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<!--
|
||||
Copyright (c) 2022, 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.
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
table, th, td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:5%;">S.No</th>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:25%;">Test</th>
|
||||
<th style="background-color:rgb(204,255,255); font-weight:bold; width:75%;">Scenario</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td>Tree Demo</td>
|
||||
<td>
|
||||
Press Left/Right arrow key until the Tree icon <img src="./resource/tree.png"> has focus. Press 'space' to choose.
|
||||
Tab until the "Tree Demo" tab has focus. Press 'space'. Press 'tab'. Press the down arrow. "Music" should
|
||||
have focus.
|
||||
Navigate up and down the tree using the up and down arrow keys.
|
||||
Expand and collapse folders using the right and left arrow keys.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3">
|
||||
<b>Expected Result</b>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="Width:100%;" colspan="3">
|
||||
See above test description.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
28
test/jdk/javax/accessibility/manual/TreeDemo.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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 manual test for accessibility button demo
|
||||
@run main/manual SwingSetTest TreeDemo
|
||||
*/
|
||||
54
test/jdk/javax/accessibility/manual/lib/DescriptionPane.java
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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.
|
||||
*/
|
||||
|
||||
package lib;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.io.IOException;
|
||||
import java.util.function.Consumer;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
/**
|
||||
* Displays instructions provided through a URL.
|
||||
*/
|
||||
class DescriptionPane extends JPanel {
|
||||
|
||||
DescriptionPane(Consumer<JEditorPane> instructions) {
|
||||
JEditorPane editorPane = new JEditorPane();
|
||||
editorPane.setFocusable(false);
|
||||
instructions.accept(editorPane);
|
||||
editorPane.setEditable(false);
|
||||
|
||||
JScrollPane esp = new JScrollPane(editorPane);
|
||||
esp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
esp.setPreferredSize(new Dimension(250, 350));
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
add(esp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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.
|
||||
*/
|
||||
package lib;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import java.awt.BorderLayout;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static java.awt.BorderLayout.CENTER;
|
||||
import static java.awt.BorderLayout.NORTH;
|
||||
|
||||
/**
|
||||
* Allows to enter reason for the test failure.
|
||||
*/
|
||||
class FailureReasonPane extends JPanel {
|
||||
|
||||
private final JTextArea text;
|
||||
|
||||
FailureReasonPane(Consumer<String> listener) {
|
||||
setLayout(new BorderLayout(10, 10));
|
||||
add(new JLabel("Failure reason:"), NORTH);
|
||||
text = new JTextArea(3, 10);
|
||||
text.getDocument().addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
listener.accept(text.getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
listener.accept(text.getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
listener.accept(text.getText());
|
||||
}
|
||||
});
|
||||
add(text, CENTER);
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return text.getText();
|
||||
}
|
||||
|
||||
public void requestFocus() {
|
||||
text.requestFocus();
|
||||
}
|
||||
}
|
||||
204
test/jdk/javax/accessibility/manual/lib/ManualTestFrame.java
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
/*
|
||||
* Copyright (c) 2021, 2022, 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.
|
||||
*/
|
||||
package lib;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridLayout;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.border.BevelBorder;
|
||||
|
||||
import static java.awt.BorderLayout.CENTER;
|
||||
import static java.awt.BorderLayout.NORTH;
|
||||
import static java.awt.BorderLayout.SOUTH;
|
||||
import static java.io.File.separator;
|
||||
import static javax.swing.SwingUtilities.invokeAndWait;
|
||||
|
||||
/**
|
||||
* A frame which can be used to display manual test descriptions as well as, in case of a failure,
|
||||
* enter failure reason and capture the screen.
|
||||
*/
|
||||
public class ManualTestFrame extends JFrame {
|
||||
|
||||
private boolean alreadyFailed = false;
|
||||
|
||||
private ManualTestFrame(String testName, String headerText,
|
||||
Consumer<JEditorPane> instructions,
|
||||
Consumer<TestResult> listener) throws IOException {
|
||||
|
||||
super(testName);
|
||||
|
||||
JLabel statusLabel = new JLabel("Follow test description, select \"Pass\" or \"Fail\"");
|
||||
statusLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
|
||||
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
||||
PassFailPane[] passFail = new PassFailPane[1];
|
||||
FailureReasonPane failureReason = new FailureReasonPane(reason -> {
|
||||
passFail[0].setFailEnabled(!reason.isEmpty());
|
||||
});
|
||||
ScreenImagePane image = new ScreenImagePane(e -> {
|
||||
listener.accept(new TestResult(e));
|
||||
dispose();
|
||||
});
|
||||
|
||||
JPanel failureInfoPane = new JPanel();
|
||||
failureInfoPane.setLayout(new GridLayout(1, 2, 10, 10));
|
||||
failureInfoPane.add(failureReason);
|
||||
failureInfoPane.add(image);
|
||||
failureInfoPane.setVisible(false);
|
||||
|
||||
JPanel main = new JPanel();
|
||||
main.setLayout(new BorderLayout(10, 10));
|
||||
DescriptionPane description = new DescriptionPane(instructions);
|
||||
main.add(description, CENTER);
|
||||
passFail[0] = new PassFailPane((status) -> {
|
||||
if (status) {
|
||||
listener.accept(new TestResult());
|
||||
dispose();
|
||||
} else {
|
||||
if (!alreadyFailed) {
|
||||
alreadyFailed = true;
|
||||
split.setDividerLocation(.5);
|
||||
failureInfoPane.setVisible(true);
|
||||
pack();
|
||||
image.capture();
|
||||
failureReason.requestFocus();
|
||||
statusLabel.setText("Enter failure reason, re-take screenshot, push \"Fail\"");
|
||||
} else {
|
||||
listener.accept(new TestResult(failureReason.getReason(), image.getImage()));
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
main.add(passFail[0], SOUTH);
|
||||
|
||||
split.setLeftComponent(main);
|
||||
split.setRightComponent(failureInfoPane);
|
||||
split.setDividerLocation(1.);
|
||||
|
||||
getContentPane().setLayout(new BorderLayout());
|
||||
|
||||
if (headerText != null) {
|
||||
JTextArea warningLabel = new JTextArea(headerText);
|
||||
warningLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
|
||||
warningLabel.setEditable(false);
|
||||
warningLabel.setFocusable(false);
|
||||
getContentPane().add(warningLabel, NORTH);
|
||||
}
|
||||
|
||||
getContentPane().add(statusLabel, SOUTH);
|
||||
getContentPane().add(split, CENTER);
|
||||
|
||||
setPreferredSize(new Dimension(800, 600));
|
||||
pack();
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a test control frame which allows a user to either pass or fail the test.
|
||||
*
|
||||
* @param testName name of the testcase
|
||||
* @param headerText information to the user to wait for the test frame.
|
||||
* @param instructions test instruction for the user
|
||||
* @return Returning supplier blocks till the test is passed or failed by the user.
|
||||
* @throws InterruptedException exception
|
||||
* @throws InvocationTargetException exception
|
||||
*/
|
||||
public static Supplier<TestResult> showUI(String testName,
|
||||
String headerText,
|
||||
Consumer<JEditorPane> instructions)
|
||||
throws InterruptedException, InvocationTargetException {
|
||||
AtomicReference<TestResult> resultContainer = new AtomicReference<>();
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
invokeAndWait(() -> {
|
||||
try {
|
||||
new ManualTestFrame(testName, headerText, instructions, (status) -> {
|
||||
resultContainer.set(status);
|
||||
latch.countDown();
|
||||
});
|
||||
} catch (IOException e) {
|
||||
resultContainer.set(new TestResult(e));
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
return () -> {
|
||||
try {
|
||||
int timeout = Integer.getInteger("timeout", 10);
|
||||
System.out.println("timeout value : " + timeout);
|
||||
if (!latch.await(timeout, TimeUnit.MINUTES)) {
|
||||
throw new RuntimeException("Timeout : User failed to " +
|
||||
"take decision on the test result.");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
return new TestResult(e);
|
||||
}
|
||||
return resultContainer.get();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the TestResult after user interacted with the manual TestFrame
|
||||
* and the test UI.
|
||||
*
|
||||
* @param result Instance of the TestResult
|
||||
* @param testName name of the testcase
|
||||
* @throws IOException exception
|
||||
*/
|
||||
public static void handleResult(TestResult result, String testName) throws IOException {
|
||||
if (result != null) {
|
||||
System.err.println("Failure reason: \n" + result.getFailureDescription());
|
||||
if (result.getScreenCapture() != null) {
|
||||
File screenDump = new File(System.getProperty("test.classes") + separator + testName + ".png");
|
||||
System.err.println("Saving screen image to " + screenDump.getAbsolutePath());
|
||||
ImageIO.write(result.getScreenCapture(), "png", screenDump);
|
||||
}
|
||||
Throwable e = result.getException();
|
||||
if (e != null) {
|
||||
throw new RuntimeException(e);
|
||||
} else {
|
||||
if (!result.getStatus())
|
||||
throw new RuntimeException("Test failed!");
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("No result returned!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
74
test/jdk/javax/accessibility/manual/lib/PassFailPane.java
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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.
|
||||
*/
|
||||
package lib;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
import java.awt.HeadlessException;
|
||||
import java.io.IOException;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Allows to chose if a test fails or passes. It is a multi-use component. A chosen answer can be confirmed later
|
||||
* upon providing additional information.
|
||||
*/
|
||||
class PassFailPane extends JPanel {
|
||||
private final Consumer<Boolean> listener;
|
||||
|
||||
private final JButton btnPass = new JButton("Pass");
|
||||
private final JButton btnFail = new JButton("Fail");
|
||||
|
||||
/**
|
||||
* @param listener gets called with true (pass) or false (fail).
|
||||
* @throws HeadlessException
|
||||
*/
|
||||
PassFailPane(Consumer<Boolean> listener)
|
||||
throws HeadlessException, IOException {
|
||||
this.listener = listener;
|
||||
|
||||
add(btnPass);
|
||||
add(btnFail);
|
||||
|
||||
btnPass.requestFocus();
|
||||
|
||||
btnPass.addActionListener((e) -> {
|
||||
disableButtons();
|
||||
listener.accept(true);
|
||||
});
|
||||
|
||||
btnFail.addActionListener((e) -> {
|
||||
disableButtons();
|
||||
listener.accept(false);
|
||||
});
|
||||
}
|
||||
|
||||
private void disableButtons() {
|
||||
btnFail.setEnabled(false);
|
||||
btnPass.setEnabled(false);
|
||||
}
|
||||
|
||||
public void setFailEnabled(boolean enabled) {
|
||||
btnFail.setEnabled(enabled);
|
||||
}
|
||||
|
||||
}
|
||||
124
test/jdk/javax/accessibility/manual/lib/ScreenImagePane.java
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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.
|
||||
*/
|
||||
package lib;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFormattedTextField;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static java.awt.BorderLayout.CENTER;
|
||||
import static java.awt.BorderLayout.NORTH;
|
||||
import static java.lang.String.format;
|
||||
import static javax.swing.SwingUtilities.invokeAndWait;
|
||||
import static javax.swing.SwingUtilities.invokeLater;
|
||||
|
||||
/**
|
||||
* Allows ti take screenshot, possible with a delay to preapare the UI.
|
||||
*/
|
||||
class ScreenImagePane extends JPanel {
|
||||
private final JPanel imagePanel;
|
||||
private final JLabel imageLabel;
|
||||
private final AtomicReference<BufferedImage> image = new AtomicReference<>();
|
||||
private final Rectangle screenRect;
|
||||
private final JFormattedTextField delayField;
|
||||
private final Consumer<Throwable> exceptionHandler;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param handler should an exception appear on other threads
|
||||
*/
|
||||
ScreenImagePane(Consumer<Throwable> handler) {
|
||||
exceptionHandler = handler;
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
screenRect = new Rectangle(0, 0, screenSize.width, screenSize.height);
|
||||
JPanel controls = new JPanel();
|
||||
delayField = new JFormattedTextField(NumberFormat.getNumberInstance());
|
||||
delayField.setText("0");
|
||||
delayField.setColumns(3);
|
||||
JButton capture = new JButton("Retake screenshot");
|
||||
controls.add(new JLabel("in "));
|
||||
controls.add(delayField);
|
||||
controls.add(new JLabel(" seconds "));
|
||||
controls.add(capture);
|
||||
capture.addActionListener((e) -> capture());
|
||||
imagePanel = new JPanel();
|
||||
imageLabel = new JLabel();
|
||||
imagePanel.add(imageLabel);
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
add(controls, NORTH);
|
||||
add(imagePanel, CENTER);
|
||||
}
|
||||
|
||||
public void capture() {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
int delay = Integer.parseInt(delayField.getText());
|
||||
invokeAndWait(() -> imageLabel.setIcon(null));
|
||||
while (delay > 0) {
|
||||
String message = format("Retaking screenshot in %d seconds", delay);
|
||||
invokeLater(() -> imageLabel.setText(message));
|
||||
delay--;
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
BufferedImage image = new Robot().createScreenCapture(screenRect);
|
||||
ScreenImagePane.this.image.set(image);
|
||||
int newWidth = imagePanel.getWidth();
|
||||
int newHeight = imagePanel.getHeight();
|
||||
float xratio = (float) newWidth / (float) image.getWidth();
|
||||
float yratio = (float) newHeight / (float) image.getHeight();
|
||||
if (xratio < yratio) {
|
||||
newHeight = (int) (image.getHeight() * xratio);
|
||||
} else {
|
||||
newWidth = (int) (image.getWidth() * yratio);
|
||||
}
|
||||
Image scaled = image.getScaledInstance(newWidth, newHeight, Image.SCALE_FAST);
|
||||
invokeAndWait(() -> {
|
||||
imageLabel.setText(null);
|
||||
imageLabel.setIcon(new ImageIcon(scaled));
|
||||
});
|
||||
} catch (Throwable e) {
|
||||
exceptionHandler.accept(e);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public BufferedImage getImage() {
|
||||
return image.get();
|
||||
}
|
||||
}
|
||||
79
test/jdk/javax/accessibility/manual/lib/TestResult.java
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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.
|
||||
*/
|
||||
package lib;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public final class TestResult {
|
||||
private final boolean status;
|
||||
private final String failureDescription;
|
||||
private final BufferedImage screenCapture;
|
||||
private final Throwable exception;
|
||||
|
||||
/**
|
||||
* Failed due to an exception.
|
||||
*/
|
||||
public TestResult(Throwable exception) {
|
||||
status = false;
|
||||
failureDescription = exception.getMessage();
|
||||
screenCapture = null;
|
||||
this.exception = exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* Failed by used decision.
|
||||
*/
|
||||
public TestResult(String description, BufferedImage capture) {
|
||||
status = false;
|
||||
failureDescription = description;
|
||||
screenCapture = capture;
|
||||
exception = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passed.
|
||||
*/
|
||||
public TestResult() {
|
||||
this.status = true;
|
||||
failureDescription = null;
|
||||
screenCapture = null;
|
||||
exception = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* true - pass, false - no pass.
|
||||
*/
|
||||
public boolean getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public String getFailureDescription() {
|
||||
return failureDescription;
|
||||
}
|
||||
|
||||
public BufferedImage getScreenCapture() {
|
||||
return screenCapture;
|
||||
}
|
||||
|
||||
public Throwable getException() {return exception;}
|
||||
}
|
||||
BIN
test/jdk/javax/accessibility/manual/resource/Slider.png
Normal file
|
After Width: | Height: | Size: 57 KiB |
BIN
test/jdk/javax/accessibility/manual/resource/btn.png
Normal file
|
After Width: | Height: | Size: 560 B |
BIN
test/jdk/javax/accessibility/manual/resource/cmb.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
test/jdk/javax/accessibility/manual/resource/dep.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
BIN
test/jdk/javax/accessibility/manual/resource/dms.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
test/jdk/javax/accessibility/manual/resource/hc.jpg
Normal file
|
After Width: | Height: | Size: 88 KiB |
BIN
test/jdk/javax/accessibility/manual/resource/if.png
Normal file
|
After Width: | Height: | Size: 94 KiB |
BIN
test/jdk/javax/accessibility/manual/resource/ifm.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
test/jdk/javax/accessibility/manual/resource/jsliderIcon.gif
Normal file
|
After Width: | Height: | Size: 426 B |
BIN
test/jdk/javax/accessibility/manual/resource/list.png
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
test/jdk/javax/accessibility/manual/resource/op.png
Normal file
|
After Width: | Height: | Size: 759 B |
BIN
test/jdk/javax/accessibility/manual/resource/rbtn.png
Normal file
|
After Width: | Height: | Size: 780 B |
BIN
test/jdk/javax/accessibility/manual/resource/tbl.png
Normal file
|
After Width: | Height: | Size: 151 KiB |
BIN
test/jdk/javax/accessibility/manual/resource/tbld.png
Normal file
|
After Width: | Height: | Size: 185 B |
BIN
test/jdk/javax/accessibility/manual/resource/tree.png
Normal file
|
After Width: | Height: | Size: 264 B |
116
test/jdk/javax/crypto/Cipher/ByteBuffers.java
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2024, 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
|
||||
* @bug 4844847
|
||||
* @summary Test the Cipher.update/doFinal(ByteBuffer, ByteBuffer) methods
|
||||
* @author Andreas Sterbenz
|
||||
* @key randomness
|
||||
* @run main ByteBuffers DES 8
|
||||
* @run main ByteBuffers AES 16
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.nio.*;
|
||||
|
||||
import java.security.*;
|
||||
|
||||
import javax.crypto.*;
|
||||
import javax.crypto.spec.*;
|
||||
|
||||
public class ByteBuffers {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Provider p = Security.getProvider(
|
||||
System.getProperty("test.provider.name", "SunJCE"));
|
||||
Random random = new Random();
|
||||
int n = 10 * 1024;
|
||||
byte[] t = new byte[n];
|
||||
random.nextBytes(t);
|
||||
|
||||
int keyInt = Integer.parseInt(args[1]);
|
||||
byte[] keyBytes = new byte[keyInt];
|
||||
random.nextBytes(keyBytes);
|
||||
String algo = args[0];
|
||||
SecretKey key = new SecretKeySpec(keyBytes, algo);
|
||||
|
||||
Cipher cipher = Cipher.getInstance(algo + "/ECB/NoPadding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, key);
|
||||
|
||||
byte[] outBytes = cipher.doFinal(t);
|
||||
|
||||
// create ByteBuffers for input (i1, i2, i3) and fill them
|
||||
ByteBuffer i0 = ByteBuffer.allocate(n + 256);
|
||||
i0.position(random.nextInt(256));
|
||||
i0.limit(i0.position() + n);
|
||||
ByteBuffer i1 = i0.slice();
|
||||
i1.put(t);
|
||||
|
||||
ByteBuffer i2 = ByteBuffer.allocateDirect(t.length);
|
||||
i2.put(t);
|
||||
|
||||
i1.clear();
|
||||
ByteBuffer i3 = i1.asReadOnlyBuffer();
|
||||
|
||||
ByteBuffer o0 = ByteBuffer.allocate(n + 512);
|
||||
o0.position(random.nextInt(256));
|
||||
o0.limit(o0.position() + n + 256);
|
||||
ByteBuffer o1 = o0.slice();
|
||||
|
||||
ByteBuffer o2 = ByteBuffer.allocateDirect(t.length + 256);
|
||||
|
||||
crypt(cipher, i1, o1, outBytes, random);
|
||||
crypt(cipher, i2, o1, outBytes, random);
|
||||
crypt(cipher, i3, o1, outBytes, random);
|
||||
crypt(cipher, i1, o2, outBytes, random);
|
||||
crypt(cipher, i2, o2, outBytes, random);
|
||||
crypt(cipher, i3, o2, outBytes, random);
|
||||
|
||||
System.out.println("All tests passed");
|
||||
}
|
||||
|
||||
private static void crypt(Cipher cipher, ByteBuffer in, ByteBuffer out, byte[] outBytes, Random random) throws Exception {
|
||||
in.clear();
|
||||
out.clear();
|
||||
out.put(new byte[out.remaining()]);
|
||||
out.clear();
|
||||
int lim = in.limit();
|
||||
in.limit(random.nextInt(lim));
|
||||
cipher.update(in, out);
|
||||
if (in.hasRemaining()) {
|
||||
throw new Exception("Buffer not consumed");
|
||||
}
|
||||
in.limit(lim);
|
||||
cipher.doFinal(in, out);
|
||||
if (in.hasRemaining()) {
|
||||
throw new Exception("Buffer not consumed");
|
||||
}
|
||||
out.flip();
|
||||
byte[] b = new byte[out.remaining()];
|
||||
out.get(b);
|
||||
if (Arrays.equals(outBytes, b) == false) {
|
||||
throw new Exception("Encryption output mismatch");
|
||||
}
|
||||
}
|
||||
}
|
||||
212
test/jdk/javax/crypto/Cipher/ByteBuffersNull.java
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
/*
|
||||
* Copyright (c) 2004, 2007, 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
|
||||
* @bug 5000980
|
||||
* @summary Check NullPointerException for cipherSpi.engineUpdate(x, null)
|
||||
*/
|
||||
|
||||
import javax.crypto.CipherSpi;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.AlgorithmParameters;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.security.Key;
|
||||
import java.security.Security;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.ShortBufferException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class ByteBuffersNull {
|
||||
|
||||
static final int bufSize = 1024;
|
||||
|
||||
public void testCase010() throws Exception {
|
||||
CipherSpiImpl c = new CipherSpiImpl();
|
||||
BufferDescr[] inBuffers = getByteBuffersForTest(bufSize);
|
||||
int failureCount = 0;
|
||||
|
||||
for (int i = 0; i < inBuffers.length; i++) {
|
||||
String key = inBuffers[i].descr;
|
||||
ByteBuffer bb = inBuffers[i].buf;
|
||||
|
||||
try {
|
||||
|
||||
c.engineUpdate(bb, null);
|
||||
|
||||
throw new Exception("No Exception?!");
|
||||
} catch (NullPointerException npe) {
|
||||
// Expected behaviour - pass
|
||||
System.out.println("OK: " + npe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a ByteBuffer with a desired properties
|
||||
ByteBuffer getByteBuffer(int capacity, int position,
|
||||
boolean limitAt0) {
|
||||
ByteBuffer bb = ByteBuffer.allocate(capacity);
|
||||
|
||||
bb.position(position);
|
||||
|
||||
if (limitAt0)
|
||||
bb.limit(0);
|
||||
|
||||
return bb;
|
||||
}
|
||||
|
||||
BufferDescr[] getByteBuffersForTest(int defaultSize) {
|
||||
int caseNum = 4;
|
||||
|
||||
BufferDescr[] buffers = new BufferDescr[caseNum];
|
||||
|
||||
// ByteBuffer with capacity 0
|
||||
buffers[0]= new BufferDescr("ByteBuffer with capacity == 0",
|
||||
getByteBuffer(0,0,false));
|
||||
|
||||
// ByteBuffer with some space but limit = 0
|
||||
buffers[1] = new BufferDescr(
|
||||
"ByteBuffer with some capacity but limit == 0",
|
||||
getByteBuffer(defaultSize, 0, true));
|
||||
|
||||
// ByteBuffer with some remaining data (limit = capacity)
|
||||
buffers[2] = new BufferDescr("ByteBuffer with some data",
|
||||
getByteBuffer(defaultSize,0,false));
|
||||
|
||||
// ByteBuffer with some data but position is at the limit
|
||||
buffers[3] = new BufferDescr(
|
||||
"ByteBuffer with data but position at the limit",
|
||||
getByteBuffer(defaultSize, defaultSize,false));
|
||||
|
||||
return buffers;
|
||||
}
|
||||
|
||||
public static void main(String argv[]) throws Exception {
|
||||
ByteBuffersNull test = new ByteBuffersNull();
|
||||
test.testCase010();
|
||||
}
|
||||
|
||||
class BufferDescr {
|
||||
BufferDescr(String d, ByteBuffer b) {
|
||||
descr = d;
|
||||
buf = b;
|
||||
}
|
||||
|
||||
public String descr;
|
||||
public ByteBuffer buf;
|
||||
}
|
||||
|
||||
public class CipherSpiImpl extends CipherSpi {
|
||||
|
||||
public CipherSpiImpl() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void engineSetMode(String mode)
|
||||
throws NoSuchAlgorithmException { }
|
||||
|
||||
public void engineSetPadding(String padding)
|
||||
throws NoSuchPaddingException { }
|
||||
|
||||
public int engineGetBlockSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int engineGetOutputSize(int inputLen) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public byte[] engineGetIV() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public AlgorithmParameters engineGetParameters() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void engineInit(int opmode, Key key, SecureRandom random)
|
||||
throws InvalidKeyException { }
|
||||
|
||||
public void engineInit(int opmode, Key key,
|
||||
AlgorithmParameterSpec params, SecureRandom random)
|
||||
throws InvalidKeyException, InvalidAlgorithmParameterException { }
|
||||
|
||||
public void engineInit(int opmode, Key key, AlgorithmParameters params,
|
||||
SecureRandom random)
|
||||
throws InvalidKeyException, InvalidAlgorithmParameterException { }
|
||||
|
||||
public byte[] engineUpdate(byte[] input, int offset, int len) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int engineUpdate(byte[] input, int inputOffset, int inputLen,
|
||||
byte[] output, int outputOffset)
|
||||
throws ShortBufferException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen)
|
||||
throws IllegalBlockSizeException, BadPaddingException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int engineDoFinal(byte[] input, int inputOffset, int inputLen,
|
||||
byte[] output, int outputOffset)
|
||||
throws ShortBufferException, IllegalBlockSizeException,
|
||||
BadPaddingException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public byte[] engineWrap(Key key)
|
||||
throws IllegalBlockSizeException, InvalidKeyException {
|
||||
return super.engineWrap(key);
|
||||
}
|
||||
|
||||
public Key engineUnwrap(byte[] wKey, String wKeyAlgorithm,
|
||||
int wKeyType) throws InvalidKeyException,
|
||||
NoSuchAlgorithmException {
|
||||
return super.engineUnwrap(wKey, wKeyAlgorithm, wKeyType);
|
||||
}
|
||||
|
||||
public int engineGetKeySize(Key key) throws InvalidKeyException {
|
||||
return super.engineGetKeySize(key);
|
||||
}
|
||||
|
||||
public int engineDoFinal(ByteBuffer input, ByteBuffer output)
|
||||
throws ShortBufferException, IllegalBlockSizeException,
|
||||
BadPaddingException {
|
||||
return super.engineDoFinal(input, output);
|
||||
}
|
||||
|
||||
public int engineUpdate(ByteBuffer input, ByteBuffer output)
|
||||
throws ShortBufferException {
|
||||
return super.engineUpdate(input, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
419
test/jdk/javax/crypto/Cipher/CipherInputStreamExceptions.java
Normal file
|
|
@ -0,0 +1,419 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2024, 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
|
||||
* @bug 8064546
|
||||
* @summary Throw exceptions during reading but not closing of a
|
||||
* CipherInputStream:
|
||||
* - Make sure authenticated algorithms continue to throwing exceptions
|
||||
* when the authentication tag fails verification.
|
||||
* - Make sure other algorithms do not throw exceptions when the stream
|
||||
* calls close() and only throw when read() errors.
|
||||
*/
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.Exception;
|
||||
import java.lang.RuntimeException;
|
||||
import java.lang.Throwable;
|
||||
import java.security.AlgorithmParameters;
|
||||
import javax.crypto.AEADBadTagException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.CipherInputStream;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.crypto.spec.GCMParameterSpec;
|
||||
|
||||
public class CipherInputStreamExceptions {
|
||||
|
||||
static SecretKeySpec key = new SecretKeySpec(new byte[16], "AES");
|
||||
static GCMParameterSpec gcmspec = new GCMParameterSpec(128, new byte[16]);
|
||||
static IvParameterSpec iv = new IvParameterSpec(new byte[16]);
|
||||
static boolean failure = false;
|
||||
|
||||
/* Full read stream, check that getMoreData() is throwing an exception
|
||||
* This test
|
||||
* 1) Encrypt 100 bytes with AES/GCM/NoPadding
|
||||
* 2) Changes the last byte to invalidate the authetication tag.
|
||||
* 3) Fully reads CipherInputStream to decrypt the message and closes
|
||||
*/
|
||||
|
||||
static void gcm_AEADBadTag() throws Exception {
|
||||
Cipher c;
|
||||
byte[] read = new byte[200];
|
||||
|
||||
System.out.println("Running gcm_AEADBadTag");
|
||||
|
||||
// Encrypt 100 bytes with AES/GCM/NoPadding
|
||||
byte[] ct = encryptedText("GCM", 100);
|
||||
// Corrupt the encrypted message
|
||||
ct = corruptGCM(ct);
|
||||
// Create stream for decryption
|
||||
CipherInputStream in = getStream("GCM", ct);
|
||||
|
||||
try {
|
||||
int size = in.read(read);
|
||||
throw new RuntimeException("Fail: CipherInputStream.read() " +
|
||||
"returned " + size + " and didn't throw an exception.");
|
||||
} catch (IOException e) {
|
||||
Throwable ec = e.getCause();
|
||||
if (ec instanceof AEADBadTagException) {
|
||||
System.out.println(" Pass.");
|
||||
} else {
|
||||
System.out.println(" Fail: " + ec.getMessage());
|
||||
throw new RuntimeException(ec);
|
||||
}
|
||||
} finally {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
||||
/* Short read stream,
|
||||
* This test
|
||||
* 1) Encrypt 100 bytes with AES/GCM/NoPadding
|
||||
* 2) Reads 100 bytes from stream to decrypt the message and closes
|
||||
* 3) Make sure no value is returned by read()
|
||||
* 4) Make sure no exception is thrown
|
||||
*/
|
||||
|
||||
static void gcm_shortReadAEAD() throws Exception {
|
||||
Cipher c;
|
||||
byte[] read = new byte[100];
|
||||
|
||||
System.out.println("Running gcm_shortReadAEAD");
|
||||
|
||||
byte[] pt = new byte[600];
|
||||
pt[0] = 1;
|
||||
// Encrypt provided 600 bytes with AES/GCM/NoPadding
|
||||
byte[] ct = encryptedText("GCM", pt);
|
||||
// Create stream for decryption
|
||||
CipherInputStream in = getStream("GCM", ct);
|
||||
|
||||
int size = 0;
|
||||
try {
|
||||
size = in.read(read);
|
||||
in.close();
|
||||
if (read.length != 100) {
|
||||
throw new RuntimeException("Fail: read size = " + read.length +
|
||||
"should be 100.");
|
||||
}
|
||||
if (read[0] != 1) {
|
||||
throw new RuntimeException("Fail: The decrypted text does " +
|
||||
"not match the plaintext: '" + read[0] +"'");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.out.println(" Fail: " + e.getMessage());
|
||||
throw new RuntimeException(e.getCause());
|
||||
}
|
||||
System.out.println(" Pass.");
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify doFinal() exception is suppressed when input stream is not
|
||||
* read before it is closed.
|
||||
* This test:
|
||||
* 1) Encrypt 100 bytes with AES/GCM/NoPadding
|
||||
* 2) Changes the last byte to invalidate the authetication tag.
|
||||
* 3) Opens a CipherInputStream and the closes it. Never reads from it.
|
||||
*
|
||||
* There should be no exception thrown.
|
||||
*/
|
||||
static void gcm_suppressUnreadCorrupt() throws Exception {
|
||||
Cipher c;
|
||||
byte[] read = new byte[200];
|
||||
|
||||
System.out.println("Running supressUnreadCorrupt test");
|
||||
|
||||
// Encrypt 100 bytes with AES/GCM/NoPadding
|
||||
byte[] ct = encryptedText("GCM", 100);
|
||||
// Corrupt the encrypted message
|
||||
ct = corruptGCM(ct);
|
||||
// Create stream for decryption
|
||||
CipherInputStream in = getStream("GCM", ct);
|
||||
|
||||
try {
|
||||
in.close();
|
||||
System.out.println(" Pass.");
|
||||
} catch (IOException e) {
|
||||
System.out.println(" Fail: " + e.getMessage());
|
||||
throw new RuntimeException(e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify noexception thrown when 1 byte is read from a GCM stream
|
||||
* and then closed
|
||||
* This test:
|
||||
* 1) Encrypt 100 bytes with AES/GCM/NoPadding
|
||||
* 2) Read one byte from the stream, expect no exception thrown.
|
||||
* 4) Close stream,expect no exception thrown.
|
||||
*/
|
||||
static void gcm_oneReadByte() throws Exception {
|
||||
|
||||
System.out.println("Running gcm_oneReadByte test");
|
||||
|
||||
// Encrypt 100 bytes with AES/GCM/NoPadding
|
||||
byte[] ct = encryptedText("GCM", 100);
|
||||
// Create stream for decryption
|
||||
CipherInputStream in = getStream("GCM", ct);
|
||||
|
||||
try {
|
||||
in.read();
|
||||
System.out.println(" Pass.");
|
||||
} catch (Exception e) {
|
||||
System.out.println(" Fail: " + e.getMessage());
|
||||
throw new RuntimeException(e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify exception thrown when 1 byte is read from a corrupted GCM stream
|
||||
* and then closed
|
||||
* This test:
|
||||
* 1) Encrypt 100 bytes with AES/GCM/NoPadding
|
||||
* 2) Changes the last byte to invalidate the authetication tag.
|
||||
* 3) Read one byte from the stream, expect exception thrown.
|
||||
* 4) Close stream,expect no exception thrown.
|
||||
*/
|
||||
static void gcm_oneReadByteCorrupt() throws Exception {
|
||||
|
||||
System.out.println("Running gcm_oneReadByteCorrupt test");
|
||||
|
||||
// Encrypt 100 bytes with AES/GCM/NoPadding
|
||||
byte[] ct = encryptedText("GCM", 100);
|
||||
// Corrupt the encrypted message
|
||||
ct = corruptGCM(ct);
|
||||
// Create stream for decryption
|
||||
CipherInputStream in = getStream("GCM", ct);
|
||||
|
||||
try {
|
||||
in.read();
|
||||
System.out.println(" Fail. No exception thrown.");
|
||||
} catch (IOException e) {
|
||||
Throwable ec = e.getCause();
|
||||
if (ec instanceof AEADBadTagException) {
|
||||
System.out.println(" Pass.");
|
||||
} else {
|
||||
System.out.println(" Fail: " + ec.getMessage());
|
||||
throw new RuntimeException(ec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check that close() does not throw an exception with full message in
|
||||
* CipherInputStream's ibuffer.
|
||||
* This test:
|
||||
* 1) Encrypts a 97 byte message with AES/CBC/PKCS5Padding
|
||||
* 2) Create a stream that sends 96 bytes.
|
||||
* 3) Read stream once,
|
||||
* 4) Close and expect no exception
|
||||
*/
|
||||
|
||||
static void cbc_shortStream() throws Exception {
|
||||
Cipher c;
|
||||
AlgorithmParameters params;
|
||||
byte[] read = new byte[200];
|
||||
|
||||
System.out.println("Running cbc_shortStream");
|
||||
|
||||
// Encrypt 97 byte with AES/CBC/PKCS5Padding
|
||||
byte[] ct = encryptedText("CBC", 97);
|
||||
// Create stream with only 96 bytes of encrypted data
|
||||
CipherInputStream in = getStream("CBC", ct, 96);
|
||||
|
||||
try {
|
||||
int size = in.read(read);
|
||||
in.close();
|
||||
if (size != 80) {
|
||||
throw new RuntimeException("Fail: CipherInputStream.read() " +
|
||||
"returned " + size + ". Should have been 80");
|
||||
}
|
||||
System.out.println(" Pass.");
|
||||
} catch (IOException e) {
|
||||
System.out.println(" Fail: " + e.getMessage());
|
||||
throw new RuntimeException(e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
/* Check that close() does not throw an exception when the whole message is
|
||||
* inside the internal buffer (ibuffer) in CipherInputStream and we read
|
||||
* one byte and close the stream.
|
||||
* This test:
|
||||
* 1) Encrypts a 400 byte message with AES/CBC/PKCS5Padding
|
||||
* 2) Read one byte from the stream
|
||||
* 3) Close and expect no exception
|
||||
*/
|
||||
|
||||
static void cbc_shortRead400() throws Exception {
|
||||
System.out.println("Running cbc_shortRead400");
|
||||
|
||||
// Encrypt 400 byte with AES/CBC/PKCS5Padding
|
||||
byte[] ct = encryptedText("CBC", 400);
|
||||
// Create stream with encrypted data
|
||||
CipherInputStream in = getStream("CBC", ct);
|
||||
|
||||
try {
|
||||
in.read();
|
||||
in.close();
|
||||
System.out.println(" Pass.");
|
||||
} catch (IOException e) {
|
||||
System.out.println(" Fail: " + e.getMessage());
|
||||
throw new RuntimeException(e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
/* Check that close() does not throw an exception when the inside the
|
||||
* internal buffer (ibuffer) in CipherInputStream does not contain the
|
||||
* whole message.
|
||||
* This test:
|
||||
* 1) Encrypts a 600 byte message with AES/CBC/PKCS5Padding
|
||||
* 2) Read one byte from the stream
|
||||
* 3) Close and expect no exception
|
||||
*/
|
||||
|
||||
static void cbc_shortRead600() throws Exception {
|
||||
System.out.println("Running cbc_shortRead600");
|
||||
|
||||
// Encrypt 600 byte with AES/CBC/PKCS5Padding
|
||||
byte[] ct = encryptedText("CBC", 600);
|
||||
// Create stream with encrypted data
|
||||
CipherInputStream in = getStream("CBC", ct);
|
||||
|
||||
try {
|
||||
in.read();
|
||||
in.close();
|
||||
System.out.println(" Pass.");
|
||||
} catch (IOException e) {
|
||||
System.out.println(" Fail: " + e.getMessage());
|
||||
throw new RuntimeException(e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
/* Check that exception is thrown when message is fully read
|
||||
* This test:
|
||||
* 1) Encrypts a 96 byte message with AES/CBC/PKCS5Padding
|
||||
* 2) Create a stream that sends 95 bytes.
|
||||
* 3) Read stream to the end
|
||||
* 4) Expect IllegalBlockSizeException thrown
|
||||
*/
|
||||
|
||||
static void cbc_readAllIllegalBlockSize() throws Exception {
|
||||
byte[] read = new byte[200];
|
||||
|
||||
System.out.println("Running cbc_readAllIllegalBlockSize test");
|
||||
|
||||
// Encrypt 96 byte with AES/CBC/PKCS5Padding
|
||||
byte[] ct = encryptedText("CBC", 96);
|
||||
// Create a stream with only 95 bytes of encrypted data
|
||||
CipherInputStream in = getStream("CBC", ct, 95);
|
||||
|
||||
try {
|
||||
int s, size = 0;
|
||||
while ((s = in.read(read)) != -1) {
|
||||
size += s;
|
||||
}
|
||||
throw new RuntimeException("Fail: No IllegalBlockSizeException. " +
|
||||
"CipherInputStream.read() returned " + size);
|
||||
|
||||
} catch (IOException e) {
|
||||
Throwable ec = e.getCause();
|
||||
if (ec instanceof IllegalBlockSizeException) {
|
||||
System.out.println(" Pass.");
|
||||
} else {
|
||||
System.out.println(" Fail: " + ec.getMessage());
|
||||
throw new RuntimeException(ec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Generic method to create encrypted text */
|
||||
static byte[] encryptedText(String mode, int length) throws Exception{
|
||||
return encryptedText(mode, new byte[length]);
|
||||
}
|
||||
|
||||
/* Generic method to create encrypted text */
|
||||
static byte[] encryptedText(String mode, byte[] pt) throws Exception{
|
||||
Cipher c;
|
||||
if (mode.compareTo("GCM") == 0) {
|
||||
c = Cipher.getInstance("AES/GCM/NoPadding",
|
||||
System.getProperty("test.provider.name", "SunJCE"));
|
||||
c.init(Cipher.ENCRYPT_MODE, key, gcmspec);
|
||||
} else if (mode.compareTo("CBC") == 0) {
|
||||
c = Cipher.getInstance("AES/CBC/PKCS5Padding",
|
||||
System.getProperty("test.provider.name", "SunJCE"));
|
||||
c.init(Cipher.ENCRYPT_MODE, key, iv);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return c.doFinal(pt);
|
||||
}
|
||||
|
||||
/* Generic method to get a properly setup CipherInputStream */
|
||||
static CipherInputStream getStream(String mode, byte[] ct) throws Exception {
|
||||
return getStream(mode, ct, ct.length);
|
||||
}
|
||||
|
||||
/* Generic method to get a properly setup CipherInputStream */
|
||||
static CipherInputStream getStream(String mode, byte[] ct, int length)
|
||||
throws Exception {
|
||||
Cipher c;
|
||||
|
||||
if (mode.compareTo("GCM") == 0) {
|
||||
c = Cipher.getInstance("AES/GCM/NoPadding",
|
||||
System.getProperty("test.provider.name", "SunJCE"));
|
||||
c.init(Cipher.DECRYPT_MODE, key, gcmspec);
|
||||
} else if (mode.compareTo("CBC") == 0) {
|
||||
c = Cipher.getInstance("AES/CBC/PKCS5Padding",
|
||||
System.getProperty("test.provider.name", "SunJCE"));
|
||||
c.init(Cipher.DECRYPT_MODE, key, iv);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new CipherInputStream(new ByteArrayInputStream(ct, 0, length), c);
|
||||
|
||||
}
|
||||
|
||||
/* Generic method for corrupting a GCM message. Change the last
|
||||
* byte on of the authentication tag
|
||||
*/
|
||||
static byte[] corruptGCM(byte[] ct) {
|
||||
ct[ct.length - 1] = (byte) (ct[ct.length - 1] + 1);
|
||||
return ct;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
gcm_AEADBadTag();
|
||||
gcm_shortReadAEAD();
|
||||
gcm_suppressUnreadCorrupt();
|
||||
gcm_oneReadByte();
|
||||
gcm_oneReadByteCorrupt();
|
||||
cbc_shortStream();
|
||||
cbc_shortRead400();
|
||||
cbc_shortRead600();
|
||||
cbc_readAllIllegalBlockSize();
|
||||
}
|
||||
}
|
||||
213
test/jdk/javax/crypto/Cipher/CipherStreamClose.java
Normal file
|
|
@ -0,0 +1,213 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2018, 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
|
||||
* @bug 7160837
|
||||
* @summary Make sure Cipher IO streams doesn't call extra doFinal if close()
|
||||
* is called multiple times. Additionally, verify the input and output streams
|
||||
* match with encryption and decryption with non-stream crypto.
|
||||
* @run main CipherStreamClose
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.security.DigestOutputStream;
|
||||
import java.security.DigestInputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.CipherOutputStream;
|
||||
import javax.crypto.CipherInputStream;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
public class CipherStreamClose {
|
||||
private static final String message = "This is the sample message";
|
||||
static boolean debug = false;
|
||||
|
||||
/*
|
||||
* This method does encryption by cipher.doFinal(), and not with
|
||||
* CipherOutputStream
|
||||
*/
|
||||
public static byte[] blockEncrypt(String message, SecretKey key)
|
||||
throws Exception {
|
||||
|
||||
byte[] data;
|
||||
Cipher encCipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
encCipher.init(Cipher.ENCRYPT_MODE, key);
|
||||
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
|
||||
try (ObjectOutputStream oos = new ObjectOutputStream(bos)) {
|
||||
oos.writeObject(message);
|
||||
}
|
||||
data = bos.toByteArray();
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
System.out.println(printHexBinary(data));
|
||||
}
|
||||
return encCipher.doFinal(data);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* This method does decryption by cipher.doFinal(), and not with
|
||||
* CipherIntputStream
|
||||
*/
|
||||
public static Object blockDecrypt(byte[] data, SecretKey key)
|
||||
throws Exception {
|
||||
|
||||
Cipher c = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
c.init(Cipher.DECRYPT_MODE, key);
|
||||
data = c.doFinal(data);
|
||||
try (ByteArrayInputStream bis = new ByteArrayInputStream(data)) {
|
||||
try (ObjectInputStream ois = new ObjectInputStream(bis)) {
|
||||
return ois.readObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] streamEncrypt(String message, SecretKey key,
|
||||
MessageDigest digest)
|
||||
throws Exception {
|
||||
|
||||
byte[] data;
|
||||
Cipher encCipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
encCipher.init(Cipher.ENCRYPT_MODE, key);
|
||||
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
DigestOutputStream dos = new DigestOutputStream(bos, digest);
|
||||
CipherOutputStream cos = new CipherOutputStream(dos, encCipher)) {
|
||||
try (ObjectOutputStream oos = new ObjectOutputStream(cos)) {
|
||||
oos.writeObject(message);
|
||||
}
|
||||
data = bos.toByteArray();
|
||||
}
|
||||
|
||||
if (debug) {
|
||||
System.out.println(printHexBinary(data));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public static Object streamDecrypt(byte[] data, SecretKey key,
|
||||
MessageDigest digest) throws Exception {
|
||||
|
||||
Cipher decCipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
decCipher.init(Cipher.DECRYPT_MODE, key);
|
||||
digest.reset();
|
||||
try (ByteArrayInputStream bis = new ByteArrayInputStream(data);
|
||||
DigestInputStream dis = new DigestInputStream(bis, digest);
|
||||
CipherInputStream cis = new CipherInputStream(dis, decCipher)) {
|
||||
|
||||
try (ObjectInputStream ois = new ObjectInputStream(cis)) {
|
||||
return ois.readObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA1");
|
||||
SecretKeySpec key = new SecretKeySpec(
|
||||
parseHexBinary(
|
||||
"12345678123456781234567812345678"), "AES");
|
||||
|
||||
// Run 'message' through streamEncrypt
|
||||
byte[] se = streamEncrypt(message, key, digest);
|
||||
// 'digest' already has the value from the stream, just finish the op
|
||||
byte[] sd = digest.digest();
|
||||
digest.reset();
|
||||
// Run 'message' through blockEncrypt
|
||||
byte[] be = blockEncrypt(message, key);
|
||||
// Take digest of encrypted blockEncrypt result
|
||||
byte[] bd = digest.digest(be);
|
||||
// Verify both returned the same value
|
||||
if (!Arrays.equals(sd, bd)) {
|
||||
System.err.println("Stream: "+ printHexBinary(se)+
|
||||
"\t Digest: "+ printHexBinary(sd));
|
||||
System.err.println("Block : "+printHexBinary(be)+
|
||||
"\t Digest: "+ printHexBinary(bd));
|
||||
throw new Exception("stream & block encryption does not match");
|
||||
}
|
||||
|
||||
digest.reset();
|
||||
// Sanity check: Decrypt separately from stream to verify operations
|
||||
String bm = (String) blockDecrypt(be, key);
|
||||
if (message.compareTo(bm) != 0) {
|
||||
System.err.println("Expected: "+message+"\nBlock: "+bm);
|
||||
throw new Exception("Block decryption does not match expected");
|
||||
}
|
||||
|
||||
// Have decryption and digest included in the object stream
|
||||
String sm = (String) streamDecrypt(se, key, digest);
|
||||
if (message.compareTo(sm) != 0) {
|
||||
System.err.println("Expected: "+message+"\nStream: "+sm);
|
||||
throw new Exception("Stream decryption does not match expected.");
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] parseHexBinary(String s) {
|
||||
final int len = s.length();
|
||||
|
||||
// "111" is not a valid hex encoding.
|
||||
if (len % 2 != 0) {
|
||||
throw new IllegalArgumentException("hexBinary needs to be even-length: " + s);
|
||||
}
|
||||
|
||||
byte[] out = new byte[len / 2];
|
||||
|
||||
for (int i = 0; i < len; i += 2) {
|
||||
int h = hexToBin(s.charAt(i));
|
||||
int l = hexToBin(s.charAt(i + 1));
|
||||
if (h == -1 || l == -1) {
|
||||
throw new IllegalArgumentException("contains illegal character for hexBinary: " + s);
|
||||
}
|
||||
|
||||
out[i / 2] = (byte) (h * 16 + l);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
private static int hexToBin(char ch) {
|
||||
if ('0' <= ch && ch <= '9') {
|
||||
return ch - '0';
|
||||
}
|
||||
if ('A' <= ch && ch <= 'F') {
|
||||
return ch - 'A' + 10;
|
||||
}
|
||||
if ('a' <= ch && ch <= 'f') {
|
||||
return ch - 'a' + 10;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
private static final char[] hexCode = "0123456789ABCDEF".toCharArray();
|
||||
|
||||
public static String printHexBinary(byte[] data) {
|
||||
StringBuilder r = new StringBuilder(data.length * 2);
|
||||
for (byte b : data) {
|
||||
r.append(hexCode[(b >> 4) & 0xF]);
|
||||
r.append(hexCode[(b & 0xF)]);
|
||||
}
|
||||
return r.toString();
|
||||
}
|
||||
}
|
||||
85
test/jdk/javax/crypto/Cipher/EmptyFinalBuffer.java
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* @bug 6946830
|
||||
* @summary Test the Cipher.doFinal() with 0-length buffer
|
||||
* @key randomness
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.nio.*;
|
||||
|
||||
import java.security.*;
|
||||
|
||||
import javax.crypto.*;
|
||||
import javax.crypto.spec.*;
|
||||
|
||||
public class EmptyFinalBuffer {
|
||||
|
||||
private static final String[] ALGOS = {
|
||||
"AES/ECB/PKCS5Padding", "AES/CBC/PKCS5Padding"
|
||||
};
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
Provider[] provs = Security.getProviders();
|
||||
|
||||
SecretKey key = new SecretKeySpec(new byte[16], "AES");
|
||||
|
||||
boolean testFailed = false;
|
||||
for (Provider p : provs) {
|
||||
System.out.println("Testing: " + p.getName());
|
||||
for (String algo : ALGOS) {
|
||||
System.out.print("Algo: " + algo);
|
||||
Cipher c;
|
||||
try {
|
||||
c = Cipher.getInstance(algo, p);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
// skip
|
||||
System.out.println("=> No Support");
|
||||
continue;
|
||||
}
|
||||
c.init(Cipher.ENCRYPT_MODE, key);
|
||||
AlgorithmParameters params = c.getParameters();
|
||||
c.init(Cipher.DECRYPT_MODE, key, params);
|
||||
try {
|
||||
byte[] out = c.doFinal(new byte[0]);
|
||||
System.out.println("=> Accepted w/ " +
|
||||
(out == null? "null" : (out.length + "-byte")) +
|
||||
" output");
|
||||
} catch (Exception e) {
|
||||
testFailed = true;
|
||||
System.out.println("=> Rejected w/ Exception");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (testFailed) {
|
||||
throw new Exception("One or more tests failed");
|
||||
} else {
|
||||
System.out.println("All tests passed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,246 @@
|
|||
/*
|
||||
* Copyright (c) 2017, 2018, 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
|
||||
* @bug 8006259
|
||||
* @summary Test several modes of operation using vectors from SP 800-38A
|
||||
* @run main CheckExampleVectors
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.security.*;
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
import javax.crypto.*;
|
||||
import javax.crypto.spec.*;
|
||||
|
||||
public class CheckExampleVectors {
|
||||
|
||||
private enum Mode {
|
||||
ECB,
|
||||
CBC,
|
||||
CFB1,
|
||||
CFB8,
|
||||
CFB128,
|
||||
OFB,
|
||||
CTR
|
||||
}
|
||||
|
||||
private enum Operation {
|
||||
Encrypt,
|
||||
Decrypt
|
||||
}
|
||||
|
||||
private static class Block {
|
||||
private byte[] input;
|
||||
private byte[] output;
|
||||
|
||||
public Block() {
|
||||
|
||||
}
|
||||
public Block(String settings) {
|
||||
String[] settingsParts = settings.split(",");
|
||||
input = stringToBytes(settingsParts[0]);
|
||||
output = stringToBytes(settingsParts[1]);
|
||||
}
|
||||
public byte[] getInput() {
|
||||
return input;
|
||||
}
|
||||
public byte[] getOutput() {
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
private static class TestVector {
|
||||
private Mode mode;
|
||||
private Operation operation;
|
||||
private byte[] key;
|
||||
private byte[] iv;
|
||||
private List<Block> blocks = new ArrayList<Block>();
|
||||
|
||||
public TestVector(String settings) {
|
||||
String[] settingsParts = settings.split(",");
|
||||
mode = Mode.valueOf(settingsParts[0]);
|
||||
operation = Operation.valueOf(settingsParts[1]);
|
||||
key = stringToBytes(settingsParts[2]);
|
||||
if (settingsParts.length > 3) {
|
||||
iv = stringToBytes(settingsParts[3]);
|
||||
}
|
||||
}
|
||||
|
||||
public Mode getMode() {
|
||||
return mode;
|
||||
}
|
||||
public Operation getOperation() {
|
||||
return operation;
|
||||
}
|
||||
public byte[] getKey() {
|
||||
return key;
|
||||
}
|
||||
public byte[] getIv() {
|
||||
return iv;
|
||||
}
|
||||
public void addBlock (Block b) {
|
||||
blocks.add(b);
|
||||
}
|
||||
public Iterable<Block> getBlocks() {
|
||||
return blocks;
|
||||
}
|
||||
}
|
||||
|
||||
private static final String VECTOR_FILE_NAME = "NIST_800_38A_vectors.txt";
|
||||
private static final Mode[] REQUIRED_MODES = {Mode.ECB, Mode.CBC, Mode.CTR};
|
||||
private static Set<Mode> supportedModes = new HashSet<Mode>();
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
checkAllProviders();
|
||||
checkSupportedModes();
|
||||
}
|
||||
|
||||
private static byte[] stringToBytes(String v) {
|
||||
if (v.equals("")) {
|
||||
return null;
|
||||
}
|
||||
return Base64.getDecoder().decode(v);
|
||||
}
|
||||
|
||||
private static String toModeString(Mode mode) {
|
||||
return mode.toString();
|
||||
}
|
||||
|
||||
private static int toCipherOperation(Operation op) {
|
||||
switch (op) {
|
||||
case Encrypt:
|
||||
return Cipher.ENCRYPT_MODE;
|
||||
case Decrypt:
|
||||
return Cipher.DECRYPT_MODE;
|
||||
}
|
||||
|
||||
throw new RuntimeException("Unknown operation: " + op);
|
||||
}
|
||||
|
||||
private static void log(String str) {
|
||||
System.out.println(str);
|
||||
}
|
||||
|
||||
private static void checkVector(String providerName, TestVector test) {
|
||||
|
||||
String modeString = toModeString(test.getMode());
|
||||
String cipherString = "AES" + "/" + modeString + "/" + "NoPadding";
|
||||
log("checking: " + cipherString + " on " + providerName);
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance(cipherString, providerName);
|
||||
SecretKeySpec key = new SecretKeySpec(test.getKey(), "AES");
|
||||
if (test.getIv() != null) {
|
||||
IvParameterSpec iv = new IvParameterSpec(test.getIv());
|
||||
cipher.init(toCipherOperation(test.getOperation()), key, iv);
|
||||
}
|
||||
else {
|
||||
cipher.init(toCipherOperation(test.getOperation()), key);
|
||||
}
|
||||
int blockIndex = 0;
|
||||
for (Block curBlock : test.getBlocks()) {
|
||||
byte[] blockOutput = cipher.update(curBlock.getInput());
|
||||
byte[] expectedBlockOutput = curBlock.getOutput();
|
||||
if (!Arrays.equals(blockOutput, expectedBlockOutput)) {
|
||||
throw new RuntimeException("Blocks do not match at index "
|
||||
+ blockIndex);
|
||||
}
|
||||
blockIndex++;
|
||||
}
|
||||
log("success");
|
||||
supportedModes.add(test.getMode());
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
log("algorithm not supported");
|
||||
} catch (NoSuchProviderException | NoSuchPaddingException
|
||||
| InvalidKeyException | InvalidAlgorithmParameterException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isComment(String line) {
|
||||
return (line != null) && line.startsWith("//");
|
||||
}
|
||||
|
||||
private static TestVector readVector(BufferedReader in) throws IOException {
|
||||
String line;
|
||||
while (isComment(line = in.readLine())) {
|
||||
// skip comment lines
|
||||
}
|
||||
if (line == null || line.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
TestVector newVector = new TestVector(line);
|
||||
String numBlocksStr = in.readLine();
|
||||
int numBlocks = Integer.parseInt(numBlocksStr);
|
||||
for (int i = 0; i < numBlocks; i++) {
|
||||
Block newBlock = new Block(in.readLine());
|
||||
newVector.addBlock(newBlock);
|
||||
}
|
||||
|
||||
return newVector;
|
||||
}
|
||||
|
||||
private static void checkAllProviders() throws IOException {
|
||||
File dataFile = new File(System.getProperty("test.src", "."),
|
||||
VECTOR_FILE_NAME);
|
||||
BufferedReader in = new BufferedReader(new FileReader(dataFile));
|
||||
List<TestVector> allTests = new ArrayList<>();
|
||||
TestVector newTest;
|
||||
while ((newTest = readVector(in)) != null) {
|
||||
allTests.add(newTest);
|
||||
}
|
||||
|
||||
for (Provider provider : Security.getProviders()) {
|
||||
checkProvider(provider.getName(), allTests);
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkProvider(String providerName,
|
||||
List<TestVector> allVectors)
|
||||
throws IOException {
|
||||
|
||||
for (TestVector curVector : allVectors) {
|
||||
checkVector(providerName, curVector);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This method helps ensure that the test is working properly by
|
||||
* verifying that the test was able to check the test vectors for
|
||||
* some of the modes of operation.
|
||||
*/
|
||||
private static void checkSupportedModes() {
|
||||
for (Mode curMode : REQUIRED_MODES) {
|
||||
if (!supportedModes.contains(curMode)) {
|
||||
throw new RuntimeException(
|
||||
"Mode not supported by any provider: " + curMode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,418 @@
|
|||
// Example vectors from NIST Special Publication 800-38A
|
||||
// Recommentation for Block Cipher Modes of Operation
|
||||
//
|
||||
// format for each vector entry is as follows:
|
||||
// mode,encrypt/decrypt,key,initialization vector
|
||||
// number of blocks
|
||||
// (for each block) input,output
|
||||
// All key, IV, input, and output values are encoded in Base64
|
||||
//
|
||||
ECB,Encrypt,K34VFiiu0qar9xWICc9PPA==,
|
||||
4
|
||||
a8G+4i5An5bpPX4Rc5MXKg==,Otd7tA16NmConsrzJGbvlw==
|
||||
ri2KVx4DrJyet2+sRa+OUQ==,9dPVhQO5aZ3nhYlalv26rw==
|
||||
MMgcRqNc5BHl+8EZGgpS7w==,Q7HNf1mOziOIGwDj7QMGiA==
|
||||
9p8kRd9PmxetK0F75mw3EA==,ewx4XiforT+CIyBxBHJd1A==
|
||||
ECB,Decrypt,K34VFiiu0qar9xWICc9PPA==,
|
||||
4
|
||||
Otd7tA16NmConsrzJGbvlw==,a8G+4i5An5bpPX4Rc5MXKg==
|
||||
9dPVhQO5aZ3nhYlalv26rw==,ri2KVx4DrJyet2+sRa+OUQ==
|
||||
Q7HNf1mOziOIGwDj7QMGiA==,MMgcRqNc5BHl+8EZGgpS7w==
|
||||
ewx4XiforT+CIyBxBHJd1A==,9p8kRd9PmxetK0F75mw3EA==
|
||||
ECB,Encrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,
|
||||
4
|
||||
a8G+4i5An5bpPX4Rc5MXKg==,vTNPHW5F8l/3EqIUVx+lzA==
|
||||
ri2KVx4DrJyet2+sRa+OUQ==,l0EEhG0K0613NOyz7O5O7w==
|
||||
MMgcRqNc5BHl+8EZGgpS7w==,73r9InDi5grc4LovrOZETg==
|
||||
9p8kRd9PmxetK0F75mw3EA==,mktBunONbHL7FmkWA8GODg==
|
||||
ECB,Decrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,
|
||||
4
|
||||
vTNPHW5F8l/3EqIUVx+lzA==,a8G+4i5An5bpPX4Rc5MXKg==
|
||||
l0EEhG0K0613NOyz7O5O7w==,ri2KVx4DrJyet2+sRa+OUQ==
|
||||
73r9InDi5grc4LovrOZETg==,MMgcRqNc5BHl+8EZGgpS7w==
|
||||
mktBunONbHL7FmkWA8GODg==,9p8kRd9PmxetK0F75mw3EA==
|
||||
ECB,Encrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,
|
||||
4
|
||||
a8G+4i5An5bpPX4Rc5MXKg==,8+7RvbXSoDwGS1p+PbGB+A==
|
||||
ri2KVx4DrJyet2+sRa+OUQ==,WRzLENQQ7SbcW6dKMTYocA==
|
||||
MMgcRqNc5BHl+8EZGgpS7w==,tu0huZym9PnxU+exvq/tHQ==
|
||||
9p8kRd9PmxetK0F75mw3EA==,IzBLejn58/8GfY2PniTsxw==
|
||||
ECB,Decrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,
|
||||
4
|
||||
8+7RvbXSoDwGS1p+PbGB+A==,a8G+4i5An5bpPX4Rc5MXKg==
|
||||
WRzLENQQ7SbcW6dKMTYocA==,ri2KVx4DrJyet2+sRa+OUQ==
|
||||
tu0huZym9PnxU+exvq/tHQ==,MMgcRqNc5BHl+8EZGgpS7w==
|
||||
IzBLejn58/8GfY2PniTsxw==,9p8kRd9PmxetK0F75mw3EA==
|
||||
CBC,Encrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
a8G+4i5An5bpPX4Rc5MXKg==,dkmrrIEZskbO6Y6bEukZfQ==
|
||||
ri2KVx4DrJyet2+sRa+OUQ==,UIbLm1ByGe6V2xE6kXZ4sg==
|
||||
MMgcRqNc5BHl+8EZGgpS7w==,c77WuOPBdDtxFuaeIiKVFg==
|
||||
9p8kRd9PmxetK0F75mw3EA==,P/HKoWgfrAkSDsowdYbhpw==
|
||||
CBC,Decrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
dkmrrIEZskbO6Y6bEukZfQ==,a8G+4i5An5bpPX4Rc5MXKg==
|
||||
UIbLm1ByGe6V2xE6kXZ4sg==,ri2KVx4DrJyet2+sRa+OUQ==
|
||||
c77WuOPBdDtxFuaeIiKVFg==,MMgcRqNc5BHl+8EZGgpS7w==
|
||||
P/HKoWgfrAkSDsowdYbhpw==,9p8kRd9PmxetK0F75mw3EA==
|
||||
CBC,Encrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
a8G+4i5An5bpPX4Rc5MXKg==,TwIdskO8Yz1xeBg6n6Bx6A==
|
||||
ri2KVx4DrJyet2+sRa+OUQ==,tNmtqa197fTl5zh2P2kUWg==
|
||||
MMgcRqNc5BHl+8EZGgpS7w==,VxskIBL7euB/qbqsPfEC4A==
|
||||
9p8kRd9PmxetK0F75mw3EA==,CLDieYhZiIHZIKnmT1YVzQ==
|
||||
CBC,Decrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
TwIdskO8Yz1xeBg6n6Bx6A==,a8G+4i5An5bpPX4Rc5MXKg==
|
||||
tNmtqa197fTl5zh2P2kUWg==,ri2KVx4DrJyet2+sRa+OUQ==
|
||||
VxskIBL7euB/qbqsPfEC4A==,MMgcRqNc5BHl+8EZGgpS7w==
|
||||
CLDieYhZiIHZIKnmT1YVzQ==,9p8kRd9PmxetK0F75mw3EA==
|
||||
CBC,Encrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
a8G+4i5An5bpPX4Rc5MXKg==,9YxMBNbl8bp3nqv7X3v71g==
|
||||
ri2KVx4DrJyet2+sRa+OUQ==,nPxOln7bgI1nn3d7xnAsfQ==
|
||||
MMgcRqNc5BHl+8EZGgpS7w==,OfIzaanZus+lMOJjBCMUYQ==
|
||||
9p8kRd9PmxetK0F75mw3EA==,susF4sOb6fzabBkHjGqdGw==
|
||||
CBC,Decrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
9YxMBNbl8bp3nqv7X3v71g==,a8G+4i5An5bpPX4Rc5MXKg==
|
||||
nPxOln7bgI1nn3d7xnAsfQ==,ri2KVx4DrJyet2+sRa+OUQ==
|
||||
OfIzaanZus+lMOJjBCMUYQ==,MMgcRqNc5BHl+8EZGgpS7w==
|
||||
susF4sOb6fzabBkHjGqdGw==,9p8kRd9PmxetK0F75mw3EA==
|
||||
CFB1,Encrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
|
||||
16
|
||||
AA==,AA==
|
||||
AQ==,AQ==
|
||||
AQ==,AQ==
|
||||
AA==,AA==
|
||||
AQ==,AQ==
|
||||
AA==,AA==
|
||||
AQ==,AQ==
|
||||
AQ==,AA==
|
||||
AQ==,AQ==
|
||||
AQ==,AA==
|
||||
AA==,AQ==
|
||||
AA==,AQ==
|
||||
AA==,AA==
|
||||
AA==,AA==
|
||||
AA==,AQ==
|
||||
AQ==,AQ==
|
||||
CFB1,Decrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
|
||||
16
|
||||
AA==,AA==
|
||||
AQ==,AQ==
|
||||
AQ==,AQ==
|
||||
AA==,AA==
|
||||
AQ==,AQ==
|
||||
AA==,AA==
|
||||
AA==,AQ==
|
||||
AA==,AQ==
|
||||
AQ==,AQ==
|
||||
AA==,AQ==
|
||||
AQ==,AA==
|
||||
AQ==,AA==
|
||||
AA==,AA==
|
||||
AA==,AA==
|
||||
AQ==,AA==
|
||||
AQ==,AQ==
|
||||
CFB1,Encrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
|
||||
16
|
||||
AA==,AQ==
|
||||
AQ==,AA==
|
||||
AQ==,AA==
|
||||
AA==,AQ==
|
||||
AQ==,AA==
|
||||
AA==,AA==
|
||||
AQ==,AQ==
|
||||
AQ==,AQ==
|
||||
AQ==,AA==
|
||||
AQ==,AQ==
|
||||
AA==,AA==
|
||||
AA==,AQ==
|
||||
AA==,AQ==
|
||||
AA==,AA==
|
||||
AA==,AA==
|
||||
AQ==,AQ==
|
||||
CFB1,Decrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
|
||||
16
|
||||
AQ==,AA==
|
||||
AA==,AQ==
|
||||
AA==,AQ==
|
||||
AQ==,AA==
|
||||
AA==,AQ==
|
||||
AA==,AA==
|
||||
AQ==,AQ==
|
||||
AQ==,AQ==
|
||||
AA==,AQ==
|
||||
AQ==,AQ==
|
||||
AA==,AA==
|
||||
AQ==,AA==
|
||||
AQ==,AA==
|
||||
AA==,AA==
|
||||
AA==,AA==
|
||||
AQ==,AQ==
|
||||
CFB1,Encrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
|
||||
16
|
||||
AA==,AQ==
|
||||
AQ==,AA==
|
||||
AQ==,AA==
|
||||
AA==,AQ==
|
||||
AQ==,AA==
|
||||
AA==,AA==
|
||||
AQ==,AA==
|
||||
AQ==,AA==
|
||||
AQ==,AA==
|
||||
AQ==,AA==
|
||||
AA==,AQ==
|
||||
AA==,AA==
|
||||
AA==,AQ==
|
||||
AA==,AA==
|
||||
AA==,AA==
|
||||
AQ==,AQ==
|
||||
CFB1,Decrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
|
||||
16
|
||||
AQ==,AA==
|
||||
AA==,AQ==
|
||||
AA==,AQ==
|
||||
AQ==,AA==
|
||||
AA==,AQ==
|
||||
AA==,AA==
|
||||
AA==,AQ==
|
||||
AA==,AQ==
|
||||
AA==,AQ==
|
||||
AA==,AQ==
|
||||
AQ==,AA==
|
||||
AA==,AA==
|
||||
AQ==,AA==
|
||||
AA==,AA==
|
||||
AA==,AA==
|
||||
AQ==,AQ==
|
||||
CFB8,Encrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
|
||||
18
|
||||
aw==,Ow==
|
||||
wQ==,eQ==
|
||||
vg==,Qg==
|
||||
4g==,TA==
|
||||
Lg==,nA==
|
||||
QA==,DQ==
|
||||
nw==,1A==
|
||||
lg==,Ng==
|
||||
6Q==,ug==
|
||||
PQ==,zg==
|
||||
fg==,ng==
|
||||
EQ==,Dg==
|
||||
cw==,1A==
|
||||
kw==,WA==
|
||||
Fw==,ag==
|
||||
Kg==,Tw==
|
||||
rg==,Mg==
|
||||
LQ==,uQ==
|
||||
CFB8,Decrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
|
||||
18
|
||||
Ow==,aw==
|
||||
eQ==,wQ==
|
||||
Qg==,vg==
|
||||
TA==,4g==
|
||||
nA==,Lg==
|
||||
DQ==,QA==
|
||||
1A==,nw==
|
||||
Ng==,lg==
|
||||
ug==,6Q==
|
||||
zg==,PQ==
|
||||
ng==,fg==
|
||||
Dg==,EQ==
|
||||
1A==,cw==
|
||||
WA==,kw==
|
||||
ag==,Fw==
|
||||
Tw==,Kg==
|
||||
Mg==,rg==
|
||||
uQ==,LQ==
|
||||
CFB8,Encrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
|
||||
18
|
||||
aw==,zQ==
|
||||
wQ==,og==
|
||||
vg==,Ug==
|
||||
4g==,Hg==
|
||||
Lg==,8A==
|
||||
QA==,qQ==
|
||||
nw==,BQ==
|
||||
lg==,yg==
|
||||
6Q==,RA==
|
||||
PQ==,zQ==
|
||||
fg==,BQ==
|
||||
EQ==,fA==
|
||||
cw==,vw==
|
||||
kw==,DQ==
|
||||
Fw==,Rw==
|
||||
Kg==,oA==
|
||||
rg==,Zw==
|
||||
LQ==,ig==
|
||||
CFB8,Decrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
|
||||
18
|
||||
zQ==,aw==
|
||||
og==,wQ==
|
||||
Ug==,vg==
|
||||
Hg==,4g==
|
||||
8A==,Lg==
|
||||
qQ==,QA==
|
||||
BQ==,nw==
|
||||
yg==,lg==
|
||||
RA==,6Q==
|
||||
zQ==,PQ==
|
||||
BQ==,fg==
|
||||
fA==,EQ==
|
||||
vw==,cw==
|
||||
DQ==,kw==
|
||||
Rw==,Fw==
|
||||
oA==,Kg==
|
||||
Zw==,rg==
|
||||
ig==,LQ==
|
||||
CFB8,Encrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
|
||||
18
|
||||
aw==,3A==
|
||||
wQ==,Hw==
|
||||
vg==,Gg==
|
||||
4g==,hQ==
|
||||
Lg==,IA==
|
||||
QA==,pg==
|
||||
nw==,TQ==
|
||||
lg==,tQ==
|
||||
6Q==,Xw==
|
||||
PQ==,zA==
|
||||
fg==,ig==
|
||||
EQ==,xQ==
|
||||
cw==,VA==
|
||||
kw==,hA==
|
||||
Fw==,Tg==
|
||||
Kg==,iA==
|
||||
rg==,lw==
|
||||
LQ==,AA==
|
||||
CFB8,Decrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
|
||||
18
|
||||
3A==,aw==
|
||||
Hw==,wQ==
|
||||
Gg==,vg==
|
||||
hQ==,4g==
|
||||
IA==,Lg==
|
||||
pg==,QA==
|
||||
TQ==,nw==
|
||||
tQ==,lg==
|
||||
Xw==,6Q==
|
||||
zA==,PQ==
|
||||
ig==,fg==
|
||||
xQ==,EQ==
|
||||
VA==,cw==
|
||||
hA==,kw==
|
||||
Tg==,Fw==
|
||||
iA==,Kg==
|
||||
lw==,rg==
|
||||
AA==,LQ==
|
||||
CFB128,Encrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
a8G+4i5An5bpPX4Rc5MXKg==,Oz/ZLrctrSAzNEn46Dz7Sg==
|
||||
ri2KVx4DrJyet2+sRa+OUQ==,yKZFN6CzqT/N482tnxzliw==
|
||||
MMgcRqNc5BHl+8EZGgpS7w==,JnUfZ6PLsUCxgIzxh6T03w==
|
||||
9p8kRd9PmxetK0F75mw3EA==,wEsFNXxdHA7qxMZvn/fy5g==
|
||||
CFB128,Decrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
Oz/ZLrctrSAzNEn46Dz7Sg==,a8G+4i5An5bpPX4Rc5MXKg==
|
||||
yKZFN6CzqT/N482tnxzliw==,ri2KVx4DrJyet2+sRa+OUQ==
|
||||
JnUfZ6PLsUCxgIzxh6T03w==,MMgcRqNc5BHl+8EZGgpS7w==
|
||||
wEsFNXxdHA7qxMZvn/fy5g==,9p8kRd9PmxetK0F75mw3EA==
|
||||
CFB128,Encrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
a8G+4i5An5bpPX4Rc5MXKg==,zcgNb93xjKs0wlkJyZpBdA==
|
||||
ri2KVx4DrJyet2+sRa+OUQ==,Z85/f4EXNiGWGitwFx09eg==
|
||||
MMgcRqNc5BHl+8EZGgpS7w==,Lh6KHdWbiLHI5g/tHvrEyQ==
|
||||
9p8kRd9PmxetK0F75mw3EA==,wF+fnKmDT6BCro+6WEsJ/w==
|
||||
CFB128,Decrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
zcgNb93xjKs0wlkJyZpBdA==,a8G+4i5An5bpPX4Rc5MXKg==
|
||||
Z85/f4EXNiGWGitwFx09eg==,ri2KVx4DrJyet2+sRa+OUQ==
|
||||
Lh6KHdWbiLHI5g/tHvrEyQ==,MMgcRqNc5BHl+8EZGgpS7w==
|
||||
wF+fnKmDT6BCro+6WEsJ/w==,9p8kRd9PmxetK0F75mw3EA==
|
||||
CFB128,Encrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
a8G+4i5An5bpPX4Rc5MXKg==,3H6Ev9p5Fkt+zYSGmF04YA==
|
||||
ri2KVx4DrJyet2+sRa+OUQ==,Of/tFDsoscgyETxjMeVAew==
|
||||
MMgcRqNc5BHl+8EZGgpS7w==,3xATJBXlS5KhPtCoJnri+Q==
|
||||
9p8kRd9PmxetK0F75mw3EA==,daOFdBq5zvggMWI9VbHkcQ==
|
||||
CFB128,Decrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
3H6Ev9p5Fkt+zYSGmF04YA==,a8G+4i5An5bpPX4Rc5MXKg==
|
||||
Of/tFDsoscgyETxjMeVAew==,ri2KVx4DrJyet2+sRa+OUQ==
|
||||
3xATJBXlS5KhPtCoJnri+Q==,MMgcRqNc5BHl+8EZGgpS7w==
|
||||
daOFdBq5zvggMWI9VbHkcQ==,9p8kRd9PmxetK0F75mw3EA==
|
||||
OFB,Encrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
a8G+4i5An5bpPX4Rc5MXKg==,Oz/ZLrctrSAzNEn46Dz7Sg==
|
||||
ri2KVx4DrJyet2+sRa+OUQ==,d4lQjRaRjwP1PFLaxU7YJQ==
|
||||
MMgcRqNc5BHl+8EZGgpS7w==,l0AFHpxf7PZDRPeoImDtzA==
|
||||
9p8kRd9PmxetK0F75mw3EA==,MExlKPZZx3hmpRDZwdauXg==
|
||||
OFB,Decrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
Oz/ZLrctrSAzNEn46Dz7Sg==,a8G+4i5An5bpPX4Rc5MXKg==
|
||||
d4lQjRaRjwP1PFLaxU7YJQ==,ri2KVx4DrJyet2+sRa+OUQ==
|
||||
l0AFHpxf7PZDRPeoImDtzA==,MMgcRqNc5BHl+8EZGgpS7w==
|
||||
MExlKPZZx3hmpRDZwdauXg==,9p8kRd9PmxetK0F75mw3EA==
|
||||
OFB,Encrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
a8G+4i5An5bpPX4Rc5MXKg==,zcgNb93xjKs0wlkJyZpBdA==
|
||||
ri2KVx4DrJyet2+sRa+OUQ==,/MKLjUxjg3wJ6BcAwRAEAQ==
|
||||
MMgcRqNc5BHl+8EZGgpS7w==,jZqa6sD2WW9VnG1Nr1ml8g==
|
||||
9p8kRd9PmxetK0F75mw3EA==,bZ8gCFfKbD6crFJL2azJKg==
|
||||
OFB,Decrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
zcgNb93xjKs0wlkJyZpBdA==,a8G+4i5An5bpPX4Rc5MXKg==
|
||||
/MKLjUxjg3wJ6BcAwRAEAQ==,ri2KVx4DrJyet2+sRa+OUQ==
|
||||
jZqa6sD2WW9VnG1Nr1ml8g==,MMgcRqNc5BHl+8EZGgpS7w==
|
||||
bZ8gCFfKbD6crFJL2azJKg==,9p8kRd9PmxetK0F75mw3EA==
|
||||
OFB,Encrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
a8G+4i5An5bpPX4Rc5MXKg==,3H6Ev9p5Fkt+zYSGmF04YA==
|
||||
ri2KVx4DrJyet2+sRa+OUQ==,T+vcZ0DSCzrIj2rYKk+wjQ==
|
||||
MMgcRqNc5BHl+8EZGgpS7w==,catHoIbobu3znRxbupfECA==
|
||||
9p8kRd9PmxetK0F75mw3EA==,ASYUHWfze+hTj1qL50DkhA==
|
||||
OFB,Decrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
|
||||
4
|
||||
3H6Ev9p5Fkt+zYSGmF04YA==,a8G+4i5An5bpPX4Rc5MXKg==
|
||||
T+vcZ0DSCzrIj2rYKk+wjQ==,ri2KVx4DrJyet2+sRa+OUQ==
|
||||
catHoIbobu3znRxbupfECA==,MMgcRqNc5BHl+8EZGgpS7w==
|
||||
ASYUHWfze+hTj1qL50DkhA==,9p8kRd9PmxetK0F75mw3EA==
|
||||
CTR,Encrypt,K34VFiiu0qar9xWICc9PPA==,8PHy8/T19vf4+fr7/P3+/w==
|
||||
4
|
||||
a8G+4i5An5bpPX4Rc5MXKg==,h01hkbYg4yYb72hkmQ22zg==
|
||||
ri2KVx4DrJyet2+sRa+OUQ==,mAb2a3lw/f+GFxh7uf/9/w==
|
||||
MMgcRqNc5BHl+8EZGgpS7w==,WuTfPtvV015bTwkCDbA+qw==
|
||||
9p8kRd9PmxetK0F75mw3EA==,HgMd2i++A9F5IXCg8wCc7g==
|
||||
CTR,Decrypt,K34VFiiu0qar9xWICc9PPA==,8PHy8/T19vf4+fr7/P3+/w==
|
||||
4
|
||||
h01hkbYg4yYb72hkmQ22zg==,a8G+4i5An5bpPX4Rc5MXKg==
|
||||
mAb2a3lw/f+GFxh7uf/9/w==,ri2KVx4DrJyet2+sRa+OUQ==
|
||||
WuTfPtvV015bTwkCDbA+qw==,MMgcRqNc5BHl+8EZGgpS7w==
|
||||
HgMd2i++A9F5IXCg8wCc7g==,9p8kRd9PmxetK0F75mw3EA==
|
||||
CTR,Encrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,8PHy8/T19vf4+fr7/P3+/w==
|
||||
4
|
||||
a8G+4i5An5bpPX4Rc5MXKg==,GryTJBdSHKJPKwRZ/n5uCw==
|
||||
ri2KVx4DrJyet2+sRa+OUQ==,CQM57Aqm+u/VzMLG9M6OlA==
|
||||
MMgcRqNc5BHl+8EZGgpS7w==,Hjaya9HrxnDRvR1mViCr9w==
|
||||
9p8kRd9PmxetK0F75mw3EA==,T3in9tKYCVhal9rsWMawUA==
|
||||
CTR,Decrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,8PHy8/T19vf4+fr7/P3+/w==
|
||||
4
|
||||
GryTJBdSHKJPKwRZ/n5uCw==,a8G+4i5An5bpPX4Rc5MXKg==
|
||||
CQM57Aqm+u/VzMLG9M6OlA==,ri2KVx4DrJyet2+sRa+OUQ==
|
||||
Hjaya9HrxnDRvR1mViCr9w==,MMgcRqNc5BHl+8EZGgpS7w==
|
||||
T3in9tKYCVhal9rsWMawUA==,9p8kRd9PmxetK0F75mw3EA==
|
||||
CTR,Encrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,8PHy8/T19vf4+fr7/P3+/w==
|
||||
4
|
||||
a8G+4i5An5bpPX4Rc5MXKg==,YB7DE3dXiaW3p/UEu/PSKA==
|
||||
ri2KVx4DrJyet2+sRa+OUQ==,9EPjyk1itZrKhOmQysr1xQ==
|
||||
MMgcRqNc5BHl+8EZGgpS7w==,Kwkw2qI96UzocBe6LYSYjQ==
|
||||
9p8kRd9PmxetK0F75mw3EA==,38nFjbZ6raYTwt0IRXlBpg==
|
||||
CTR,Decrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,8PHy8/T19vf4+fr7/P3+/w==
|
||||
4
|
||||
YB7DE3dXiaW3p/UEu/PSKA==,a8G+4i5An5bpPX4Rc5MXKg==
|
||||
9EPjyk1itZrKhOmQysr1xQ==,ri2KVx4DrJyet2+sRa+OUQ==
|
||||
Kwkw2qI96UzocBe6LYSYjQ==,MMgcRqNc5BHl+8EZGgpS7w==
|
||||
38nFjbZ6raYTwt0IRXlBpg==,9p8kRd9PmxetK0F75mw3EA==
|
||||
|
||||
144
test/jdk/javax/crypto/Cipher/GCMAPI.java
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* Copyright (c) 2011, 2013, 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
|
||||
* @bug 7031343
|
||||
* @summary Provide API changes to support GCM AEAD ciphers
|
||||
* @author Brad Wetmore
|
||||
*/
|
||||
|
||||
import javax.crypto.*;
|
||||
import javax.crypto.spec.*;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/*
|
||||
* At this point in time, we can't really do any testing since only the API
|
||||
* is available, the underlying implementation doesn't exist yet. Test
|
||||
* what we can...
|
||||
*/
|
||||
public class GCMAPI {
|
||||
|
||||
// 16 elements
|
||||
private static byte[] bytes = new byte[] {
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f };
|
||||
|
||||
private static int failed = 0;
|
||||
private static Cipher c;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
c = Cipher.getInstance("AES");
|
||||
c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(new byte[16], "AES"));
|
||||
|
||||
updateAADFail((byte[]) null);
|
||||
updateAADPass(bytes);
|
||||
|
||||
updateAADFail(null, 2, 4);
|
||||
updateAADFail(bytes, -2, 4);
|
||||
updateAADFail(bytes, 2, -4);
|
||||
updateAADFail(bytes, 2, 15); // one too many
|
||||
|
||||
updateAADPass(bytes, 2, 14); // ok.
|
||||
updateAADPass(bytes, 4, 4);
|
||||
updateAADPass(bytes, 0, 0);
|
||||
|
||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||
|
||||
updateAADFail((ByteBuffer) null);
|
||||
updateAADPass(bb);
|
||||
|
||||
if (failed != 0) {
|
||||
throw new Exception("Test(s) failed");
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateAADPass(byte[] src) {
|
||||
try {
|
||||
c.updateAAD(src);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
// swallow
|
||||
} catch (IllegalStateException ise) {
|
||||
// swallow
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
failed++;
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateAADFail(byte[] src) {
|
||||
try {
|
||||
c.updateAAD(src);
|
||||
new Exception("Didn't Fail as Expected").printStackTrace();
|
||||
failed++;
|
||||
} catch (IllegalArgumentException e) {
|
||||
// swallow
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateAADPass(byte[] src, int offset, int len) {
|
||||
try {
|
||||
c.updateAAD(src, offset, len);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
// swallow
|
||||
} catch (IllegalStateException ise) {
|
||||
// swallow
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
failed++;
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateAADFail(byte[] src, int offset, int len) {
|
||||
try {
|
||||
c.updateAAD(src, offset, len);
|
||||
new Exception("Didn't Fail as Expected").printStackTrace();
|
||||
failed++;
|
||||
} catch (IllegalArgumentException e) {
|
||||
// swallow
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateAADPass(ByteBuffer src) {
|
||||
try {
|
||||
c.updateAAD(src);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
// swallow
|
||||
} catch (IllegalStateException ise) {
|
||||
// swallow
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
failed++;
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateAADFail(ByteBuffer src) {
|
||||
try {
|
||||
c.updateAAD(src);
|
||||
new Exception("Didn't Fail as Expected").printStackTrace();
|
||||
failed++;
|
||||
} catch (IllegalArgumentException e) {
|
||||
// swallow
|
||||
}
|
||||
}
|
||||
}
|
||||
111
test/jdk/javax/crypto/Cipher/GetMaxAllowed.java
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2024, 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
|
||||
* @bug 4807942 7033170
|
||||
* @summary Test the Cipher.getMaxAllowedKeyLength(String) and
|
||||
* getMaxAllowedParameterSpec(String) methods
|
||||
* @author Valerie Peng
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.nio.*;
|
||||
|
||||
import java.security.*;
|
||||
import java.security.spec.*;
|
||||
|
||||
import javax.crypto.*;
|
||||
import javax.crypto.spec.*;
|
||||
|
||||
public class GetMaxAllowed {
|
||||
|
||||
private static void runTest1(boolean isUnlimited) throws Exception {
|
||||
System.out.println("Testing " + (isUnlimited? "un":"") +
|
||||
"limited policy...");
|
||||
|
||||
String algo = "Blowfish";
|
||||
int keyLength = Cipher.getMaxAllowedKeyLength(algo);
|
||||
AlgorithmParameterSpec spec = Cipher.getMaxAllowedParameterSpec(algo);
|
||||
if (isUnlimited) {
|
||||
if ((keyLength != Integer.MAX_VALUE) || (spec != null)) {
|
||||
throw new Exception("Check for " + algo +
|
||||
" failed under unlimited policy");
|
||||
}
|
||||
} else {
|
||||
if ((keyLength != 128) || (spec != null)) {
|
||||
throw new Exception("Check for " + algo +
|
||||
" failed under default policy");
|
||||
}
|
||||
}
|
||||
algo = "RC5";
|
||||
keyLength = Cipher.getMaxAllowedKeyLength(algo);
|
||||
RC5ParameterSpec rc5param = (RC5ParameterSpec)
|
||||
Cipher.getMaxAllowedParameterSpec(algo);
|
||||
if (isUnlimited) {
|
||||
if ((keyLength != Integer.MAX_VALUE) || (rc5param != null)) {
|
||||
throw new Exception("Check for " + algo +
|
||||
" failed under unlimited policy");
|
||||
}
|
||||
} else {
|
||||
if ((keyLength != 128) || (rc5param.getRounds() != 12) ||
|
||||
(rc5param.getVersion() != Integer.MAX_VALUE) ||
|
||||
(rc5param.getWordSize() != Integer.MAX_VALUE)) {
|
||||
throw new Exception("Check for " + algo +
|
||||
" failed under default policy");
|
||||
}
|
||||
}
|
||||
System.out.println("All tests passed");
|
||||
}
|
||||
|
||||
private static void runTest2() throws Exception {
|
||||
System.out.println("Testing against Security.getAlgorithms()");
|
||||
|
||||
Set<String> algorithms = Security.getAlgorithms("Cipher");
|
||||
|
||||
for (String algorithm: algorithms) {
|
||||
int keylength = -1;
|
||||
|
||||
// if 7033170 is not fixed, NoSuchAlgorithmException is thrown
|
||||
keylength = Cipher.getMaxAllowedKeyLength(algorithm);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// decide if the installed jurisdiction policy file is the
|
||||
// unlimited version
|
||||
boolean isUnlimited = true;
|
||||
Cipher c = Cipher.getInstance("AES",
|
||||
System.getProperty("test.provider.name", "SunJCE"));
|
||||
try {
|
||||
c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(new byte[24], "AES"));
|
||||
} catch (InvalidKeyException ike) {
|
||||
isUnlimited = false;
|
||||
}
|
||||
runTest1(isUnlimited);
|
||||
|
||||
// test using the set of algorithms returned by Security.getAlgorithms()
|
||||
runTest2();
|
||||
}
|
||||
}
|
||||