Skip to content

Commit 1f618ab

Browse files
Victor RudometovPaul Hohensee
authored andcommitted
8285373: Create an automated test for JDK-4702233
8285373: Create an automated test for JDK-4702233 Backport-of: 6f526e1bc3e0af4189fbb7d3b48d614717f266b0
1 parent b9b5e52 commit 1f618ab

File tree

6 files changed

+415
-0
lines changed

6 files changed

+415
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @summary Constant for testing public fields in AccessibleAction.
26+
*/
27+
28+
public interface AccessibleActionConstants {
29+
30+
String CLASS_NAME = "javax.accessibility.AccessibleAction";
31+
32+
/**
33+
* Public fields values in AccessibleAction class.
34+
*/
35+
String[][] FIELDS =
36+
new String[][] { { "CLICK", "click" }, { "DECREMENT", "decrement" },
37+
{ "INCREMENT", "increment" }, { "TOGGLE_EXPAND", "toggleexpand" },
38+
{ "TOGGLE_POPUP", "toggle popup" } };
39+
/**
40+
* Old(removed) fields in AccessibleAction class.
41+
*/
42+
String[] OLD_FIELDS = new String[] {};
43+
}
44+
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @summary Constant for testing public fields in AccessibleContext.
26+
*/
27+
28+
public interface AccessibleContextConstants {
29+
30+
String CLASS_NAME = "javax.accessibility.AccessibleContext";
31+
32+
/**
33+
* Public fields values in AccessibleContext class.
34+
*/
35+
String[][] FIELDS = new String[][] {
36+
{ "ACCESSIBLE_NAME_PROPERTY", "AccessibleName" },
37+
{ "ACCESSIBLE_DESCRIPTION_PROPERTY", "AccessibleDescription" },
38+
{ "ACCESSIBLE_STATE_PROPERTY", "AccessibleState" },
39+
{ "ACCESSIBLE_VALUE_PROPERTY", "AccessibleValue" },
40+
{ "ACCESSIBLE_SELECTION_PROPERTY", "AccessibleSelection" },
41+
{ "ACCESSIBLE_CARET_PROPERTY", "AccessibleCaret" },
42+
{ "ACCESSIBLE_VISIBLE_DATA_PROPERTY", "AccessibleVisibleData" },
43+
{ "ACCESSIBLE_CHILD_PROPERTY", "AccessibleChild" },
44+
{ "ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY",
45+
"AccessibleActiveDescendant" },
46+
{ "ACCESSIBLE_TABLE_CAPTION_CHANGED", "accessibleTableCaptionChanged" },
47+
{ "ACCESSIBLE_TABLE_SUMMARY_CHANGED", "accessibleTableSummaryChanged" },
48+
{ "ACCESSIBLE_TABLE_MODEL_CHANGED", "accessibleTableModelChanged" },
49+
{ "ACCESSIBLE_TABLE_ROW_HEADER_CHANGED",
50+
"accessibleTableRowHeaderChanged" },
51+
{ "ACCESSIBLE_TABLE_ROW_DESCRIPTION_CHANGED",
52+
"accessibleTableRowDescriptionChanged" },
53+
{ "ACCESSIBLE_TABLE_COLUMN_HEADER_CHANGED",
54+
"accessibleTableColumnHeaderChanged" },
55+
{ "ACCESSIBLE_TABLE_COLUMN_DESCRIPTION_CHANGED",
56+
"accessibleTableColumnDescriptionChanged" },
57+
{ "ACCESSIBLE_ACTION_PROPERTY", "accessibleActionProperty" },
58+
{ "ACCESSIBLE_HYPERTEXT_OFFSET", "AccessibleHypertextOffset" },
59+
{ "ACCESSIBLE_TEXT_PROPERTY", "AccessibleText" },
60+
{ "ACCESSIBLE_INVALIDATE_CHILDREN", "accessibleInvalidateChildren" },
61+
{ "ACCESSIBLE_TEXT_ATTRIBUTES_CHANGED",
62+
"accessibleTextAttributesChanged" },
63+
{ "ACCESSIBLE_COMPONENT_BOUNDS_CHANGED",
64+
"accessibleComponentBoundsChanged" } };
65+
66+
/**
67+
* Old(removed) fields in AccessibleContext class.
68+
*/
69+
String[] OLD_FIELDS = new String[] {};
70+
}
71+
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 4702233
27+
* @summary Testing current and old(removed) public fields in AccessibleAction,
28+
* AccessibleContext, AccessibleRelation, AccessibleRole and AccessibleState.
29+
* @run main AccessiblePropertiesTest
30+
*/
31+
32+
import java.lang.reflect.Field;
33+
34+
public class AccessiblePropertiesTest {
35+
36+
private static void checkFields(String className, String[][] fields,
37+
String[] oldFields) {
38+
try {
39+
Class<?> klass = Class.forName(className);
40+
41+
if (klass.getFields().length != fields.length) {
42+
throw new RuntimeException("Fields in " + className
43+
+ " were changed. Test should be updated!");
44+
}
45+
46+
for (int i = 0; i < fields.length; ++i) {
47+
String key = fields[i][0];
48+
String value = fields[i][1];
49+
Field field = klass.getDeclaredField(key);
50+
String current = field.get(String.class).toString();
51+
52+
if (!current.equals(value)) {
53+
throw new RuntimeException(
54+
"Field " + field.getName() + " current value=" + current
55+
+ " , expected value=" + value);
56+
}
57+
}
58+
59+
for (int i = 0; i < oldFields.length; ++i) {
60+
String key = oldFields[i];
61+
62+
try {
63+
klass.getDeclaredField(key);
64+
65+
throw new RuntimeException(key + " exists in " + klass);
66+
} catch (NoSuchFieldException ignored) {
67+
}
68+
}
69+
} catch (Exception e) {
70+
e.printStackTrace();
71+
}
72+
}
73+
74+
public static void main(String[] args) {
75+
76+
checkFields(AccessibleActionConstants.CLASS_NAME,
77+
AccessibleActionConstants.FIELDS,
78+
AccessibleActionConstants.OLD_FIELDS);
79+
80+
checkFields(AccessibleRelationConstants.CLASS_NAME,
81+
AccessibleRelationConstants.FIELDS,
82+
AccessibleRelationConstants.OLD_FIELDS);
83+
84+
checkFields(AccessibleRoleConstants.CLASS_NAME,
85+
AccessibleRoleConstants.FIELDS, AccessibleRoleConstants.OLD_FIELDS);
86+
87+
checkFields(AccessibleStateConstants.CLASS_NAME,
88+
AccessibleStateConstants.FIELDS,
89+
AccessibleStateConstants.OLD_FIELDS);
90+
91+
checkFields(AccessibleContextConstants.CLASS_NAME,
92+
AccessibleContextConstants.FIELDS,
93+
AccessibleContextConstants.OLD_FIELDS);
94+
}
95+
}
96+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @summary Constant for testing public fields in AccessibleRelation.
26+
*/
27+
public interface AccessibleRelationConstants {
28+
29+
/**
30+
* Fully-qualified name of the class.
31+
*/
32+
String CLASS_NAME = "javax.accessibility.AccessibleRelation";
33+
34+
/**
35+
* Public fields values in AccessibleRelation class.
36+
*/
37+
String[][] FIELDS = new String[][] { { "CHILD_NODE_OF", "childNodeOf" },
38+
{ "CHILD_NODE_OF_PROPERTY", "childNodeOfProperty" },
39+
{ "CONTROLLED_BY", "controlledBy" },
40+
{ "CONTROLLED_BY_PROPERTY", "controlledByProperty" },
41+
{ "CONTROLLER_FOR", "controllerFor" },
42+
{ "CONTROLLER_FOR_PROPERTY", "controllerForProperty" },
43+
{ "EMBEDDED_BY", "embeddedBy" },
44+
{ "EMBEDDED_BY_PROPERTY", "embeddedByProperty" },
45+
{ "EMBEDS", "embeds" }, { "EMBEDS_PROPERTY", "embedsProperty" },
46+
{ "FLOWS_FROM", "flowsFrom" },
47+
{ "FLOWS_FROM_PROPERTY", "flowsFromProperty" },
48+
{ "FLOWS_TO", "flowsTo" }, { "FLOWS_TO_PROPERTY", "flowsToProperty" },
49+
{ "LABELED_BY", "labeledBy" },
50+
{ "LABELED_BY_PROPERTY", "labeledByProperty" },
51+
{ "LABEL_FOR", "labelFor" },
52+
{ "LABEL_FOR_PROPERTY", "labelForProperty" },
53+
{ "MEMBER_OF", "memberOf" },
54+
{ "MEMBER_OF_PROPERTY", "memberOfProperty" },
55+
{ "PARENT_WINDOW_OF", "parentWindowOf" },
56+
{ "PARENT_WINDOW_OF_PROPERTY", "parentWindowOfProperty" },
57+
{ "SUBWINDOW_OF", "subwindowOf" },
58+
{ "SUBWINDOW_OF_PROPERTY", "subwindowOfProperty" }, };
59+
60+
/**
61+
* Old(removed) fields in AccessibleRelation class.
62+
*/
63+
String[] OLD_FIELDS = new String[] {};
64+
}
65+
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package bug4702233;
2+
3+
/*
4+
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
5+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6+
*
7+
* This code is free software; you can redistribute it and/or modify it
8+
* under the terms of the GNU General Public License version 2 only, as
9+
* published by the Free Software Foundation.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
/*
27+
* @summary Constant for testing public fields in AccessibleRole.
28+
*/
29+
30+
public interface AccessibleRoleConstants {
31+
32+
/**
33+
* Fully-qualified name of the class.
34+
*/
35+
String CLASS_NAME = "javax.accessibility.AccessibleRole";
36+
37+
/**
38+
* Public fields values in AccessibleRole class.
39+
*/
40+
String[][] FIELDS = new String[][] { { "ALERT", "alert" },
41+
{ "AWT_COMPONENT", "AWT component" }, { "CANVAS", "canvas" },
42+
{ "CHECK_BOX", "check box" }, { "COLOR_CHOOSER", "color chooser" },
43+
{ "COLUMN_HEADER", "column header" }, { "COMBO_BOX", "combo box" },
44+
{ "DATE_EDITOR", "dateeditor" }, { "DESKTOP_ICON", "desktop icon" },
45+
{ "DESKTOP_PANE", "desktop pane" }, { "DIALOG", "dialog" },
46+
{ "DIRECTORY_PANE", "directory pane" }, { "EDITBAR", "editbar" },
47+
{ "FILE_CHOOSER", "file chooser" }, { "FILLER", "filler" },
48+
{ "FONT_CHOOSER", "fontchooser" }, { "FOOTER", "footer" },
49+
{ "FRAME", "frame" }, { "GLASS_PANE", "glass pane" },
50+
{ "GROUP_BOX", "groupbox" }, { "HEADER", "header" },
51+
{ "HTML_CONTAINER", "HTML container" }, { "HYPERLINK", "hyperlink" },
52+
{ "ICON", "icon" }, { "INTERNAL_FRAME", "internal frame" },
53+
{ "LABEL", "label" }, { "LAYERED_PANE", "layered pane" },
54+
{ "LIST", "list" }, { "LIST_ITEM", "list item" }, { "MENU", "menu" },
55+
{ "MENU_BAR", "menu bar" }, { "MENU_ITEM", "menu item" },
56+
{ "OPTION_PANE", "option pane" }, { "PAGE_TAB", "page tab" },
57+
{ "PAGE_TAB_LIST", "page tab list" }, { "PANEL", "panel" },
58+
{ "PARAGRAPH", "paragraph" }, { "PASSWORD_TEXT", "password text" },
59+
{ "POPUP_MENU", "popup menu" }, { "PROGRESS_BAR", "progress bar" },
60+
{ "PROGRESS_MONITOR", "progress monitor" },
61+
{ "PUSH_BUTTON", "push JButton" }, { "RADIO_BUTTON", "radio JButton" },
62+
{ "ROOT_PANE", "root pane" }, { "ROW_HEADER", "row header" },
63+
{ "RULER", "ruler" }, { "SCROLL_BAR", "scroll bar" },
64+
{ "SCROLL_PANE", "scroll pane" }, { "SEPARATOR", "separator" },
65+
{ "SLIDER", "slider" }, { "SPIN_BOX", "spinbox" },
66+
{ "SPLIT_PANE", "split pane" }, { "STATUS_BAR", "statusbar" },
67+
{ "SWING_COMPONENT", "swing component" }, { "TABLE", "table" },
68+
{ "TEXT", "text" }, { "TOGGLE_BUTTON", "toggle JButton" },
69+
{ "TOOL_BAR", "tool bar" }, { "TOOL_TIP", "tool tip" },
70+
{ "TREE", "tree" }, { "UNKNOWN", "unknown" },
71+
{ "VIEWPORT", "viewport" }, { "WINDOW", "window" } };
72+
73+
/**
74+
* Old(removed) fields in AccessibleRole class.
75+
*/
76+
String[] OLD_FIELDS = new String[] {};
77+
}

0 commit comments

Comments
 (0)