8167160: [TEST_BUG][PIT] failure of javax/swing/JRadioButton/8033699/bug8033699.java

Reviewed-by: psadhukhan, serb
This commit is contained in:
Avik Niyogi 2016-11-24 14:11:32 +05:30
parent f04a27dbdc
commit b61b0b8c00

View File

@ -26,22 +26,31 @@
* @key headful
* @library ../../regtesthelpers
* @build Util
* @bug 8033699 8154043
* @bug 8033699 8154043 8167160
* @summary Incorrect radio button behavior when pressing tab key
* @author Vivi An
* @run main bug8033699
*/
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
import java.awt.KeyboardFocusManager;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class bug8033699 {
private static Robot robot;
private static JFrame mainFrame;
private static Robot robot;
private static JButton btnStart;
private static ButtonGroup btnGrp;
private static JButton btnEnd;
private static JButton btnMiddle;
private static JRadioButton radioBtn1;
@ -51,7 +60,9 @@ public class bug8033699 {
public static void main(String args[]) throws Throwable {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
changeLAF();
createAndShowGUI();
}
});
@ -84,11 +95,30 @@ public class bug8033699 {
// down key circle back to first button in grouped radio button
runTest8();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
mainFrame.dispose();
}
});
}
private static void changeLAF() {
String currentLAF = UIManager.getLookAndFeel().toString();
System.out.println(currentLAF);
currentLAF = currentLAF.toLowerCase();
if (currentLAF.contains("aqua") || currentLAF.contains("nimbus")) {
try {
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
private static void createAndShowGUI() {
JFrame mainFrame = new JFrame("Bug 8033699 - 8 Tests for Grouped/Non Group Radio Buttons");
mainFrame = new JFrame("Bug 8033699 - 8 Tests for Grouped/Non Group Radio Buttons");
btnStart = new JButton("Start");
btnEnd = new JButton("End");
btnMiddle = new JButton("Middle");
@ -138,6 +168,7 @@ public class bug8033699 {
hitKey(robot, KeyEvent.VK_TAB);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtnSingle) {
System.out.println("Radio Button Group Go To Next Component through Tab Key failed");
@ -151,6 +182,7 @@ public class bug8033699 {
private static void runTest2() throws Exception {
hitKey(robot, KeyEvent.VK_TAB);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != btnEnd) {
System.out.println("Non Grouped Radio Button Go To Next Component through Tab Key failed");
@ -166,6 +198,7 @@ public class bug8033699 {
hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB);
hitKey(robot, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn1) {
System.out.println("Radio button Group/Non Grouped Radio Button SHIFT-Tab Key Test failed");
@ -180,6 +213,7 @@ public class bug8033699 {
hitKey(robot, KeyEvent.VK_DOWN);
hitKey(robot, KeyEvent.VK_RIGHT);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn3) {
System.out.println("Radio button Group UP/LEFT Arrow Key Move Focus Failed");
@ -193,6 +227,7 @@ public class bug8033699 {
hitKey(robot, KeyEvent.VK_UP);
hitKey(robot, KeyEvent.VK_LEFT);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn1) {
System.out.println("Radio button Group Left/Up Arrow Key Move Focus Failed");
@ -206,6 +241,7 @@ public class bug8033699 {
hitKey(robot, KeyEvent.VK_UP);
hitKey(robot, KeyEvent.VK_UP);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtn2) {
System.out.println("Radio button Group Circle Back To First Button Test");
@ -218,6 +254,7 @@ public class bug8033699 {
private static void runTest7() throws Exception {
hitKey(robot, KeyEvent.VK_TAB);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != btnMiddle) {
System.out.println("Separate Component added in button group layout");
@ -230,6 +267,7 @@ public class bug8033699 {
private static void runTest8() throws Exception {
hitKey(robot, KeyEvent.VK_TAB);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() != radioBtnSingle) {
System.out.println("Separate Component added in button group layout");