author | arapte |
Wed, 30 Oct 2019 16:59:40 +0530 | |
changeset 59173 | 0fa6b6461451 |
parent 51454 | 06417e487a28 |
permissions | -rw-r--r-- |
27270 | 1 |
/* |
59173
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
2 |
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. |
27270 | 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 |
|
40128
e635645d2a8a
8160974: [TESTBUG] Mark more headful tests with @key headful.
goetz
parents:
28071
diff
changeset
|
26 |
* @key headful |
27270 | 27 |
* @library ../../regtesthelpers |
28 |
* @build Util |
|
59173
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
29 |
* @bug 8033699 8154043 8167160 8208640 8226892 |
27270 | 30 |
* @summary Incorrect radio button behavior when pressing tab key |
31 |
* @run main bug8033699 |
|
32 |
*/ |
|
42723
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
33 |
import java.awt.KeyboardFocusManager; |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
34 |
import java.awt.Robot; |
59173
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
35 |
import java.awt.event.ActionListener; |
42723
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
36 |
import java.awt.event.KeyEvent; |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
37 |
import java.util.logging.Level; |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
38 |
import java.util.logging.Logger; |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
39 |
import javax.swing.BorderFactory; |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
40 |
import javax.swing.BoxLayout; |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
41 |
import javax.swing.ButtonGroup; |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
42 |
import javax.swing.JButton; |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
43 |
import javax.swing.JFrame; |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
44 |
import javax.swing.JPanel; |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
45 |
import javax.swing.JRadioButton; |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
46 |
import javax.swing.SwingUtilities; |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
47 |
import javax.swing.UIManager; |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
48 |
import javax.swing.UnsupportedLookAndFeelException; |
27270 | 49 |
|
50 |
public class bug8033699 { |
|
42723
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
51 |
|
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
52 |
private static JFrame mainFrame; |
27270 | 53 |
private static Robot robot; |
54 |
private static JButton btnStart; |
|
55 |
private static JButton btnEnd; |
|
56 |
private static JButton btnMiddle; |
|
57 |
private static JRadioButton radioBtn1; |
|
58 |
private static JRadioButton radioBtn2; |
|
59 |
private static JRadioButton radioBtn3; |
|
60 |
private static JRadioButton radioBtnSingle; |
|
61 |
||
62 |
public static void main(String args[]) throws Throwable { |
|
51454
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
63 |
SwingUtilities.invokeAndWait(() -> { |
42723
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
64 |
changeLAF(); |
27270 | 65 |
createAndShowGUI(); |
66 |
}); |
|
67 |
||
68 |
robot = new Robot(); |
|
69 |
Thread.sleep(100); |
|
70 |
||
71 |
robot.setAutoDelay(100); |
|
72 |
||
73 |
// tab key test grouped radio button |
|
74 |
runTest1(); |
|
75 |
||
76 |
// tab key test non-grouped radio button |
|
77 |
runTest2(); |
|
78 |
||
79 |
// shift tab key test grouped and non grouped radio button |
|
80 |
runTest3(); |
|
81 |
||
82 |
// left/up key test in grouped radio button |
|
83 |
runTest4(); |
|
84 |
||
85 |
// down/right key test in grouped radio button |
|
86 |
runTest5(); |
|
87 |
||
88 |
// tab from radio button in group to next component in the middle of button group layout |
|
89 |
runTest6(); |
|
90 |
||
91 |
// tab to radio button in group from component in the middle of button group layout |
|
92 |
runTest7(); |
|
93 |
||
94 |
// down key circle back to first button in grouped radio button |
|
95 |
runTest8(); |
|
42723
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
96 |
|
59173
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
97 |
// Verify that ActionListener is called when a RadioButton is selected using arrow key. |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
98 |
runTest9(); |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
99 |
|
51454
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
100 |
SwingUtilities.invokeAndWait(() -> mainFrame.dispose()); |
42723
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
101 |
} |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
102 |
|
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
103 |
private static void changeLAF() { |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
104 |
String currentLAF = UIManager.getLookAndFeel().toString(); |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
105 |
System.out.println(currentLAF); |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
106 |
currentLAF = currentLAF.toLowerCase(); |
51454
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
107 |
if (currentLAF.contains("nimbus")) { |
42723
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
108 |
try { |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
109 |
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
110 |
} catch (Exception ex) { |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
111 |
ex.printStackTrace(); |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
112 |
} |
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
113 |
} |
27270 | 114 |
} |
115 |
||
116 |
private static void createAndShowGUI() { |
|
42723
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
117 |
mainFrame = new JFrame("Bug 8033699 - 8 Tests for Grouped/Non Group Radio Buttons"); |
27270 | 118 |
btnStart = new JButton("Start"); |
119 |
btnEnd = new JButton("End"); |
|
120 |
btnMiddle = new JButton("Middle"); |
|
121 |
||
122 |
JPanel box = new JPanel(); |
|
123 |
box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS)); |
|
124 |
box.setBorder(BorderFactory.createTitledBorder("Grouped Radio Buttons")); |
|
125 |
radioBtn1 = new JRadioButton("A"); |
|
126 |
radioBtn2 = new JRadioButton("B"); |
|
127 |
radioBtn3 = new JRadioButton("C"); |
|
128 |
||
129 |
ButtonGroup btnGrp = new ButtonGroup(); |
|
130 |
btnGrp.add(radioBtn1); |
|
131 |
btnGrp.add(radioBtn2); |
|
132 |
btnGrp.add(radioBtn3); |
|
133 |
radioBtn1.setSelected(true); |
|
134 |
||
135 |
box.add(radioBtn1); |
|
136 |
box.add(radioBtn2); |
|
137 |
box.add(btnMiddle); |
|
138 |
box.add(radioBtn3); |
|
139 |
||
140 |
radioBtnSingle = new JRadioButton("Not Grouped"); |
|
141 |
radioBtnSingle.setSelected(true); |
|
142 |
||
143 |
mainFrame.getContentPane().add(btnStart); |
|
144 |
mainFrame.getContentPane().add(box); |
|
145 |
mainFrame.getContentPane().add(radioBtnSingle); |
|
146 |
mainFrame.getContentPane().add(btnEnd); |
|
147 |
||
148 |
mainFrame.getRootPane().setDefaultButton(btnStart); |
|
149 |
btnStart.requestFocus(); |
|
150 |
||
151 |
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
152 |
mainFrame.setLayout(new BoxLayout(mainFrame.getContentPane(), BoxLayout.Y_AXIS)); |
|
153 |
||
154 |
mainFrame.setSize(300, 300); |
|
155 |
mainFrame.setLocation(200, 200); |
|
156 |
mainFrame.setVisible(true); |
|
157 |
mainFrame.toFront(); |
|
158 |
} |
|
159 |
||
160 |
// Radio button Group as a single component when traversing through tab key |
|
42723
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
161 |
private static void runTest1() throws Exception { |
27270 | 162 |
hitKey(robot, KeyEvent.VK_TAB); |
163 |
hitKey(robot, KeyEvent.VK_TAB); |
|
41396
d72f3a09b3ae
8154043: Fields not reachable anymore by tab-key, because of new tabbing behaviour of radio button groups.
ssadetsky
parents:
40128
diff
changeset
|
164 |
hitKey(robot, KeyEvent.VK_TAB); |
27270 | 165 |
|
51454
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
166 |
SwingUtilities.invokeAndWait(() -> { |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
167 |
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtnSingle) { |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
168 |
System.out.println("Radio Button Group Go To Next Component through Tab Key failed"); |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
169 |
throw new RuntimeException("Focus is not on Radio Button Single as Expected"); |
27270 | 170 |
} |
171 |
}); |
|
172 |
} |
|
173 |
||
174 |
// Non-Grouped Radio button as a single component when traversing through tab key |
|
42723
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
175 |
private static void runTest2() throws Exception { |
27270 | 176 |
hitKey(robot, KeyEvent.VK_TAB); |
51454
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
177 |
SwingUtilities.invokeAndWait(() -> { |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
178 |
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != btnEnd) { |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
179 |
System.out.println("Non Grouped Radio Button Go To Next Component through Tab Key failed"); |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
180 |
throw new RuntimeException("Focus is not on Button End as Expected"); |
27270 | 181 |
} |
182 |
}); |
|
183 |
} |
|
184 |
||
185 |
// Non-Grouped Radio button and Group Radio button as a single component when traversing through shift-tab key |
|
42723
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
186 |
private static void runTest3() throws Exception { |
27270 | 187 |
hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB); |
188 |
hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB); |
|
41396
d72f3a09b3ae
8154043: Fields not reachable anymore by tab-key, because of new tabbing behaviour of radio button groups.
ssadetsky
parents:
40128
diff
changeset
|
189 |
hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB); |
51454
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
190 |
SwingUtilities.invokeAndWait(() -> { |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
191 |
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn1) { |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
192 |
System.out.println("Radio button Group/Non Grouped Radio Button SHIFT-Tab Key Test failed"); |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
193 |
throw new RuntimeException("Focus is not on Radio Button A as Expected"); |
27270 | 194 |
} |
195 |
}); |
|
196 |
} |
|
197 |
||
198 |
// Using arrow key to move focus in radio button group |
|
42723
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
199 |
private static void runTest4() throws Exception { |
41396
d72f3a09b3ae
8154043: Fields not reachable anymore by tab-key, because of new tabbing behaviour of radio button groups.
ssadetsky
parents:
40128
diff
changeset
|
200 |
hitKey(robot, KeyEvent.VK_DOWN); |
d72f3a09b3ae
8154043: Fields not reachable anymore by tab-key, because of new tabbing behaviour of radio button groups.
ssadetsky
parents:
40128
diff
changeset
|
201 |
hitKey(robot, KeyEvent.VK_RIGHT); |
51454
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
202 |
SwingUtilities.invokeAndWait(() -> { |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
203 |
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn3) { |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
204 |
System.out.println("Radio button Group UP/LEFT Arrow Key Move Focus Failed"); |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
205 |
throw new RuntimeException("Focus is not on Radio Button C as Expected"); |
27270 | 206 |
} |
207 |
}); |
|
208 |
} |
|
209 |
||
42723
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
210 |
private static void runTest5() throws Exception { |
41396
d72f3a09b3ae
8154043: Fields not reachable anymore by tab-key, because of new tabbing behaviour of radio button groups.
ssadetsky
parents:
40128
diff
changeset
|
211 |
hitKey(robot, KeyEvent.VK_UP); |
d72f3a09b3ae
8154043: Fields not reachable anymore by tab-key, because of new tabbing behaviour of radio button groups.
ssadetsky
parents:
40128
diff
changeset
|
212 |
hitKey(robot, KeyEvent.VK_LEFT); |
51454
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
213 |
SwingUtilities.invokeAndWait(() -> { |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
214 |
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn1) { |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
215 |
System.out.println("Radio button Group Left/Up Arrow Key Move Focus Failed"); |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
216 |
throw new RuntimeException("Focus is not on Radio Button A as Expected"); |
27270 | 217 |
} |
218 |
}); |
|
219 |
} |
|
220 |
||
42723
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
221 |
private static void runTest6() throws Exception { |
41396
d72f3a09b3ae
8154043: Fields not reachable anymore by tab-key, because of new tabbing behaviour of radio button groups.
ssadetsky
parents:
40128
diff
changeset
|
222 |
hitKey(robot, KeyEvent.VK_UP); |
d72f3a09b3ae
8154043: Fields not reachable anymore by tab-key, because of new tabbing behaviour of radio button groups.
ssadetsky
parents:
40128
diff
changeset
|
223 |
hitKey(robot, KeyEvent.VK_UP); |
51454
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
224 |
SwingUtilities.invokeAndWait(() -> { |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
225 |
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn2) { |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
226 |
System.out.println("Radio button Group Circle Back To First Button Test"); |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
227 |
throw new RuntimeException("Focus is not on Radio Button B as Expected"); |
27270 | 228 |
} |
229 |
}); |
|
230 |
} |
|
231 |
||
42723
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
232 |
private static void runTest7() throws Exception { |
27270 | 233 |
hitKey(robot, KeyEvent.VK_TAB); |
51454
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
234 |
SwingUtilities.invokeAndWait(() -> { |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
235 |
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != btnMiddle) { |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
236 |
System.out.println("Separate Component added in button group layout"); |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
237 |
throw new RuntimeException("Focus is not on Middle Button as Expected"); |
27270 | 238 |
} |
239 |
}); |
|
240 |
} |
|
241 |
||
42723
830c2a93d94f
8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java
aniyogi
parents:
41396
diff
changeset
|
242 |
private static void runTest8() throws Exception { |
27270 | 243 |
hitKey(robot, KeyEvent.VK_TAB); |
51454
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
244 |
SwingUtilities.invokeAndWait(() -> { |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
245 |
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtnSingle) { |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
246 |
System.out.println("Separate Component added in button group layout"); |
06417e487a28
8208640: [a11y] [macos] Unable to navigate between Radiobuttons in Radio group using keyboard.
kaddepalli
parents:
47216
diff
changeset
|
247 |
throw new RuntimeException("Focus is not on Radio Button Single as Expected"); |
27270 | 248 |
} |
249 |
}); |
|
250 |
} |
|
251 |
||
59173
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
252 |
private static Boolean actRB1 = false; |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
253 |
private static Boolean actRB2 = false; |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
254 |
private static Boolean actRB3 = false; |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
255 |
|
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
256 |
// JDK-8226892: Verify that ActionListener is called when a RadioButton is selected using arrow key. |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
257 |
private static void runTest9() throws Exception { |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
258 |
SwingUtilities.invokeAndWait(() -> { |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
259 |
radioBtn1.setSelected(true); |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
260 |
radioBtn1.requestFocusInWindow(); |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
261 |
}); |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
262 |
|
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
263 |
ActionListener actLrRB1 = e -> actRB1 = true; |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
264 |
ActionListener actLrRB2 = e -> actRB2 = true; |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
265 |
ActionListener actLrRB3 = e -> actRB3 = true; |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
266 |
|
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
267 |
radioBtn1.addActionListener(actLrRB1); |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
268 |
radioBtn2.addActionListener(actLrRB2); |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
269 |
radioBtn3.addActionListener(actLrRB3); |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
270 |
|
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
271 |
hitKey(robot, KeyEvent.VK_DOWN); |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
272 |
hitKey(robot, KeyEvent.VK_DOWN); |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
273 |
hitKey(robot, KeyEvent.VK_DOWN); |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
274 |
|
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
275 |
String failMessage = "ActionListener not invoked when selected using arrow key."; |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
276 |
if (!actRB2) { |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
277 |
throw new RuntimeException("RadioButton 2: " + failMessage); |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
278 |
} |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
279 |
if (!actRB3) { |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
280 |
throw new RuntimeException("RadioButton 3: " + failMessage); |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
281 |
} |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
282 |
if (!actRB1) { |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
283 |
throw new RuntimeException("RadioButton 1: " + failMessage); |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
284 |
} |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
285 |
|
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
286 |
radioBtn1.removeActionListener(actLrRB1); |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
287 |
radioBtn2.removeActionListener(actLrRB2); |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
288 |
radioBtn3.removeActionListener(actLrRB3); |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
289 |
} |
0fa6b6461451
8226892: ActionListeners on JRadioButtons don't get notified when selection is changed with arrow keys
arapte
parents:
51454
diff
changeset
|
290 |
|
27270 | 291 |
private static void hitKey(Robot robot, int keycode) { |
292 |
robot.keyPress(keycode); |
|
293 |
robot.keyRelease(keycode); |
|
28071
3acb75b8df45
8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
27270
diff
changeset
|
294 |
robot.waitForIdle(); |
27270 | 295 |
} |
296 |
||
297 |
private static void hitKey(Robot robot, int mode, int keycode) { |
|
298 |
robot.keyPress(mode); |
|
299 |
robot.keyPress(keycode); |
|
300 |
robot.keyRelease(mode); |
|
301 |
robot.keyRelease(keycode); |
|
28071
3acb75b8df45
8063107: Change open swing regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
27270
diff
changeset
|
302 |
robot.waitForIdle(); |
27270 | 303 |
} |
304 |
} |