165 private static void runTest1() throws Exception { |
157 private static void runTest1() throws Exception { |
166 hitKey(robot, KeyEvent.VK_TAB); |
158 hitKey(robot, KeyEvent.VK_TAB); |
167 hitKey(robot, KeyEvent.VK_TAB); |
159 hitKey(robot, KeyEvent.VK_TAB); |
168 hitKey(robot, KeyEvent.VK_TAB); |
160 hitKey(robot, KeyEvent.VK_TAB); |
169 |
161 |
170 SwingUtilities.invokeAndWait(new Runnable() { |
162 SwingUtilities.invokeAndWait(() -> { |
171 @Override |
163 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtnSingle) { |
172 public void run() { |
164 System.out.println("Radio Button Group Go To Next Component through Tab Key failed"); |
173 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtnSingle) { |
165 throw new RuntimeException("Focus is not on Radio Button Single as Expected"); |
174 System.out.println("Radio Button Group Go To Next Component through Tab Key failed"); |
|
175 throw new RuntimeException("Focus is not on Radio Button Single as Expected"); |
|
176 } |
|
177 } |
166 } |
178 }); |
167 }); |
179 } |
168 } |
180 |
169 |
181 // Non-Grouped Radio button as a single component when traversing through tab key |
170 // Non-Grouped Radio button as a single component when traversing through tab key |
182 private static void runTest2() throws Exception { |
171 private static void runTest2() throws Exception { |
183 hitKey(robot, KeyEvent.VK_TAB); |
172 hitKey(robot, KeyEvent.VK_TAB); |
184 SwingUtilities.invokeAndWait(new Runnable() { |
173 SwingUtilities.invokeAndWait(() -> { |
185 @Override |
174 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != btnEnd) { |
186 public void run() { |
175 System.out.println("Non Grouped Radio Button Go To Next Component through Tab Key failed"); |
187 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != btnEnd) { |
176 throw new RuntimeException("Focus is not on Button End as Expected"); |
188 System.out.println("Non Grouped Radio Button Go To Next Component through Tab Key failed"); |
|
189 throw new RuntimeException("Focus is not on Button End as Expected"); |
|
190 } |
|
191 } |
177 } |
192 }); |
178 }); |
193 } |
179 } |
194 |
180 |
195 // Non-Grouped Radio button and Group Radio button as a single component when traversing through shift-tab key |
181 // Non-Grouped Radio button and Group Radio button as a single component when traversing through shift-tab key |
196 private static void runTest3() throws Exception { |
182 private static void runTest3() throws Exception { |
197 hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB); |
183 hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB); |
198 hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB); |
184 hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB); |
199 hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB); |
185 hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB); |
200 SwingUtilities.invokeAndWait(new Runnable() { |
186 SwingUtilities.invokeAndWait(() -> { |
201 @Override |
187 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn1) { |
202 public void run() { |
188 System.out.println("Radio button Group/Non Grouped Radio Button SHIFT-Tab Key Test failed"); |
203 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn1) { |
189 throw new RuntimeException("Focus is not on Radio Button A as Expected"); |
204 System.out.println("Radio button Group/Non Grouped Radio Button SHIFT-Tab Key Test failed"); |
|
205 throw new RuntimeException("Focus is not on Radio Button A as Expected"); |
|
206 } |
|
207 } |
190 } |
208 }); |
191 }); |
209 } |
192 } |
210 |
193 |
211 // Using arrow key to move focus in radio button group |
194 // Using arrow key to move focus in radio button group |
212 private static void runTest4() throws Exception { |
195 private static void runTest4() throws Exception { |
213 hitKey(robot, KeyEvent.VK_DOWN); |
196 hitKey(robot, KeyEvent.VK_DOWN); |
214 hitKey(robot, KeyEvent.VK_RIGHT); |
197 hitKey(robot, KeyEvent.VK_RIGHT); |
215 SwingUtilities.invokeAndWait(new Runnable() { |
198 SwingUtilities.invokeAndWait(() -> { |
216 @Override |
199 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn3) { |
217 public void run() { |
200 System.out.println("Radio button Group UP/LEFT Arrow Key Move Focus Failed"); |
218 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn3) { |
201 throw new RuntimeException("Focus is not on Radio Button C as Expected"); |
219 System.out.println("Radio button Group UP/LEFT Arrow Key Move Focus Failed"); |
|
220 throw new RuntimeException("Focus is not on Radio Button C as Expected"); |
|
221 } |
|
222 } |
202 } |
223 }); |
203 }); |
224 } |
204 } |
225 |
205 |
226 private static void runTest5() throws Exception { |
206 private static void runTest5() throws Exception { |
227 hitKey(robot, KeyEvent.VK_UP); |
207 hitKey(robot, KeyEvent.VK_UP); |
228 hitKey(robot, KeyEvent.VK_LEFT); |
208 hitKey(robot, KeyEvent.VK_LEFT); |
229 SwingUtilities.invokeAndWait(new Runnable() { |
209 SwingUtilities.invokeAndWait(() -> { |
230 @Override |
210 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn1) { |
231 public void run() { |
211 System.out.println("Radio button Group Left/Up Arrow Key Move Focus Failed"); |
232 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn1) { |
212 throw new RuntimeException("Focus is not on Radio Button A as Expected"); |
233 System.out.println("Radio button Group Left/Up Arrow Key Move Focus Failed"); |
|
234 throw new RuntimeException("Focus is not on Radio Button A as Expected"); |
|
235 } |
|
236 } |
213 } |
237 }); |
214 }); |
238 } |
215 } |
239 |
216 |
240 private static void runTest6() throws Exception { |
217 private static void runTest6() throws Exception { |
241 hitKey(robot, KeyEvent.VK_UP); |
218 hitKey(robot, KeyEvent.VK_UP); |
242 hitKey(robot, KeyEvent.VK_UP); |
219 hitKey(robot, KeyEvent.VK_UP); |
243 SwingUtilities.invokeAndWait(new Runnable() { |
220 SwingUtilities.invokeAndWait(() -> { |
244 @Override |
221 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn2) { |
245 public void run() { |
222 System.out.println("Radio button Group Circle Back To First Button Test"); |
246 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn2) { |
223 throw new RuntimeException("Focus is not on Radio Button B as Expected"); |
247 System.out.println("Radio button Group Circle Back To First Button Test"); |
|
248 throw new RuntimeException("Focus is not on Radio Button B as Expected"); |
|
249 } |
|
250 } |
224 } |
251 }); |
225 }); |
252 } |
226 } |
253 |
227 |
254 private static void runTest7() throws Exception { |
228 private static void runTest7() throws Exception { |
255 hitKey(robot, KeyEvent.VK_TAB); |
229 hitKey(robot, KeyEvent.VK_TAB); |
256 SwingUtilities.invokeAndWait(new Runnable() { |
230 SwingUtilities.invokeAndWait(() -> { |
257 @Override |
231 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != btnMiddle) { |
258 public void run() { |
232 System.out.println("Separate Component added in button group layout"); |
259 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != btnMiddle) { |
233 throw new RuntimeException("Focus is not on Middle Button as Expected"); |
260 System.out.println("Separate Component added in button group layout"); |
|
261 throw new RuntimeException("Focus is not on Middle Button as Expected"); |
|
262 } |
|
263 } |
234 } |
264 }); |
235 }); |
265 } |
236 } |
266 |
237 |
267 private static void runTest8() throws Exception { |
238 private static void runTest8() throws Exception { |
268 hitKey(robot, KeyEvent.VK_TAB); |
239 hitKey(robot, KeyEvent.VK_TAB); |
269 SwingUtilities.invokeAndWait(new Runnable() { |
240 SwingUtilities.invokeAndWait(() -> { |
270 @Override |
241 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtnSingle) { |
271 public void run() { |
242 System.out.println("Separate Component added in button group layout"); |
272 if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtnSingle) { |
243 throw new RuntimeException("Focus is not on Radio Button Single as Expected"); |
273 System.out.println("Separate Component added in button group layout"); |
|
274 throw new RuntimeException("Focus is not on Radio Button Single as Expected"); |
|
275 } |
|
276 } |
244 } |
277 }); |
245 }); |
278 } |
246 } |
279 |
247 |
280 private static void hitKey(Robot robot, int keycode) { |
248 private static void hitKey(Robot robot, int keycode) { |