Skip to content
Permalink
Browse files

8234149: Several regression tests do not dispose Frame at end

Reviewed-by: serb
  • Loading branch information
prsadhuk committed Dec 2, 2019
1 parent 0ee193c commit 55f3fd95e617995ce04de33d5de9fae4485df400
Showing with 1,852 additions and 1,614 deletions.
  1. +41 −36 test/jdk/javax/swing/AbstractButton/6711682/bug6711682.java
  2. +8 −3 test/jdk/javax/swing/Action/8133039/bug8133039.java
  3. +20 −15 test/jdk/javax/swing/JButton/4368790/bug4368790.java
  4. +10 −4 test/jdk/javax/swing/JButton/4796987/bug4796987.java
  5. +9 −4 test/jdk/javax/swing/JColorChooser/Test8051548.java
  6. +4 −2 test/jdk/javax/swing/JComboBox/4523758/bug4523758.java
  7. +12 −8 test/jdk/javax/swing/JComboBox/6236162/bug6236162.java
  8. +33 −28 test/jdk/javax/swing/JComboBox/7195179/Test7195179.java
  9. +3 −1 test/jdk/javax/swing/JComboBox/8057893/bug8057893.java
  10. +23 −20 test/jdk/javax/swing/JComponent/4337267/bug4337267.java
  11. +59 −54 test/jdk/javax/swing/JComponent/6989617/bug6989617.java
  12. +93 −89 test/jdk/javax/swing/JComponent/7154030/bug7154030.java
  13. +30 −26 test/jdk/javax/swing/JEditorPane/4492274/bug4492274.java
  14. +9 −5 test/jdk/javax/swing/JFrame/4962534/bug4962534.java
  15. +33 −30 test/jdk/javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java
  16. +16 −12 test/jdk/javax/swing/JInternalFrame/5066752/bug5066752.java
  17. +28 −25 test/jdk/javax/swing/JInternalFrame/8160248/JInternalFrameDraggingTest.java
  18. +30 −25 test/jdk/javax/swing/JInternalFrame/InternalFrameIsNotCollectedTest.java
  19. +47 −43 test/jdk/javax/swing/JLabel/6596966/bug6596966.java
  20. +40 −35 test/jdk/javax/swing/JLayer/6824395/bug6824395.java
  21. +23 −18 test/jdk/javax/swing/JList/6462008/bug6462008.java
  22. +19 −14 test/jdk/javax/swing/JList/6510999/bug6510999.java
  23. +3 −1 test/jdk/javax/swing/JMenu/4417601/bug4417601.java
  24. +52 −47 test/jdk/javax/swing/JMenu/4515762/bug4515762.java
  25. +32 −29 test/jdk/javax/swing/JMenu/4692443/bug4692443.java
  26. +38 −34 test/jdk/javax/swing/JMenu/6359669/bug6359669.java
  27. +41 −37 test/jdk/javax/swing/JMenu/6470128/bug6470128.java
  28. +34 −29 test/jdk/javax/swing/JMenu/6538132/bug6538132.java
  29. +23 −19 test/jdk/javax/swing/JMenuBar/4750590/bug4750590.java
  30. +20 −15 test/jdk/javax/swing/JMenuItem/4171437/bug4171437.java
  31. +72 −67 test/jdk/javax/swing/JMenuItem/4654927/bug4654927.java
  32. +27 −23 test/jdk/javax/swing/JMenuItem/6209975/bug6209975.java
  33. +9 −5 test/jdk/javax/swing/JPopupMenu/4634626/bug4634626.java
  34. +43 −38 test/jdk/javax/swing/JPopupMenu/6217905/bug6217905.java
  35. +45 −40 test/jdk/javax/swing/JPopupMenu/6515446/bug6515446.java
  36. +54 −50 test/jdk/javax/swing/JPopupMenu/6580930/bug6580930.java
  37. +45 −41 test/jdk/javax/swing/JPopupMenu/6827786/bug6827786.java
  38. +45 −40 test/jdk/javax/swing/JPopupMenu/6987844/bug6987844.java
  39. +34 −30 test/jdk/javax/swing/JRadioButton/8041561/bug8041561.java
  40. +16 −11 test/jdk/javax/swing/JRadioButton/8075609/bug8075609.java
  41. +44 −39 test/jdk/javax/swing/JRootPane/4670486/bug4670486.java
  42. +44 −39 test/jdk/javax/swing/JScrollBar/4708809/bug4708809.java
  43. +23 −19 test/jdk/javax/swing/JScrollBar/4865918/bug4865918.java
  44. +46 −41 test/jdk/javax/swing/JScrollBar/6542335/bug6542335.java
  45. +43 −38 test/jdk/javax/swing/JScrollBar/bug4202954/bug4202954.java
  46. +48 −43 test/jdk/javax/swing/JSpinner/4973721/bug4973721.java
  47. +44 −39 test/jdk/javax/swing/JSplitPane/4885629/bug4885629.java
  48. +28 −23 test/jdk/javax/swing/JTabbedPane/4361477/bug4361477.java
  49. +38 −33 test/jdk/javax/swing/JTabbedPane/4624207/bug4624207.java
  50. +36 −31 test/jdk/javax/swing/JTabbedPane/6495408/bug6495408.java
  51. +26 −21 test/jdk/javax/swing/JTabbedPane/7161568/bug7161568.java
  52. +136 −131 test/jdk/javax/swing/JTabbedPane/8134116/Bug8134116.java
  53. +35 −30 test/jdk/javax/swing/JTable/4220171/bug4220171.java
  54. +38 −34 test/jdk/javax/swing/JTable/6777378/bug6777378.java
@@ -43,53 +43,58 @@
private static JCheckBox editorCb;
private static JCheckBox rendererCb;
private static JTable table;
private static JFrame f;

public static void main(String[] args) throws Exception {
Robot robot = new Robot();
robot.setAutoDelay(50);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
try {
Robot robot = new Robot();
robot.setAutoDelay(50);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
robot.waitForIdle();
Point l = table.getLocationOnScreen();
int h = table.getRowHeight();
for (int i = 0; i < 3; i++) {
robot.mouseMove(l.x + 5, l.y + 5 + i * h);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
});
robot.waitForIdle();
Point l = table.getLocationOnScreen();
int h = table.getRowHeight();
for (int i = 0; i < 3; i++) {
robot.mouseMove(l.x + 5, l.y + 5 + i * h);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
// Without pressing F2 the last table's cell
// reported <code>false</code> value
// note that I can't press it inside the for loop
// because it doesn't reproduce the bug
robot.keyPress(KeyEvent.VK_F2);
robot.keyRelease(KeyEvent.VK_F2);

for (int i = 0; i < 3; i++) {
if (!Boolean.TRUE.equals(table.getValueAt(i, 0))) {
throw new RuntimeException("Row #" + i + " checkbox is not selected");
// Without pressing F2 the last table's cell
// reported <code>false</code> value
// note that I can't press it inside the for loop
// because it doesn't reproduce the bug
robot.keyPress(KeyEvent.VK_F2);
robot.keyRelease(KeyEvent.VK_F2);

for (int i = 0; i < 3; i++) {
if (!Boolean.TRUE.equals(table.getValueAt(i, 0))) {
throw new RuntimeException("Row #" + i + " checkbox is not selected");
}
}
}
for (int i = 2; i >= 0; i--) {
robot.mouseMove(l.x + 5, l.y + 5 + i * h);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
robot.keyPress(KeyEvent.VK_F2);
robot.keyRelease(KeyEvent.VK_F2);
for (int i = 0; i < 3; i++) {
if (Boolean.TRUE.equals(table.getValueAt(i, 0))) {
throw new RuntimeException("Row #" + i + " checkbox is selected");
for (int i = 2; i >= 0; i--) {
robot.mouseMove(l.x + 5, l.y + 5 + i * h);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
robot.keyPress(KeyEvent.VK_F2);
robot.keyRelease(KeyEvent.VK_F2);
for (int i = 0; i < 3; i++) {
if (Boolean.TRUE.equals(table.getValueAt(i, 0))) {
throw new RuntimeException("Row #" + i + " checkbox is selected");
}
}
} finally {
if (f != null) SwingUtilities.invokeAndWait(() -> f.dispose());
}
}

private static void createAndShowGUI() {
editorCb = new JCheckBox();
rendererCb = new JCheckBox();
JFrame f = new JFrame("Table with CheckBox");
f = new JFrame("Table with CheckBox");
Container p = f.getContentPane();
p.setLayout(new BorderLayout());
table = new JTable(new Object[][]{{false}, {false}, {false}}, new Object[]{"CheckBox"});
@@ -45,10 +45,15 @@

private static volatile int ACTION_PERFORMED_CALLS = 0;
private static volatile int ACTION_ACCEPTED_CALLS = 0;
private static JFrame frame;

public static void main(String[] args) throws Exception {
testActionNotification();
testPopupAction();
try {
testActionNotification();
testPopupAction();
} finally {
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
}
}

private static void testActionNotification() {
@@ -114,7 +119,7 @@ private static void testPopupAction() throws Exception {

private static void createAndShowGUI() {

JFrame frame = new JFrame();
frame = new JFrame();
frame.setSize(300, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

@@ -36,9 +36,10 @@

public class bug4368790 {
private static JButton b1;
private static JFrame frame;

private static void createGui() {
final JFrame frame = new JFrame();
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new FlowLayout());

@@ -53,21 +54,25 @@ private static void createGui() {
}

public static void main(String[] args) throws Exception {
Robot robot = new Robot();
robot.setAutoDelay(50);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
bug4368790.createGui();
try {
Robot robot = new Robot();
robot.setAutoDelay(50);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
bug4368790.createGui();
}
});
robot.waitForIdle();
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_SPACE);
robot.waitForIdle();
if (b1.getModel().isPressed()) {
throw new RuntimeException("The button is unexpectedly pressed");
}
});
robot.waitForIdle();
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_SPACE);
robot.waitForIdle();
if (b1.getModel().isPressed()) {
throw new RuntimeException("The button is unexpectedly pressed");
} finally {
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
}
}
}
@@ -24,6 +24,7 @@
/*
* @test
* @bug 4796987
* @key headful
* @requires (os.family == "windows")
* @summary XP Only: JButton.setBorderPainted() does not work with XP L&F
* @author Alexander Scherbatiy
@@ -46,12 +47,17 @@

private static JButton button1;
private static JButton button2;
private static JFrame frame;

public static void main(String[] args) throws Exception {
if (Platform.isWindows()
try {
if (Platform.isWindows()
&& OSVersion.current().equals(OSVersion.WINDOWS_XP)) {
UIManager.setLookAndFeel(new WindowsLookAndFeel());
testButtonBorder();
UIManager.setLookAndFeel(new WindowsLookAndFeel());
testButtonBorder();
}
} finally {
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
}
}

@@ -89,7 +95,7 @@ private static JButton getButton() {
}

private static void createAndShowGUI() {
JFrame frame = new JFrame("Test");
frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 200);

@@ -56,11 +56,16 @@
private static JColorChooser colorChooser;
private static boolean propertyChangeListenerInvoked;
private static volatile Color color;
private static JFrame frame;

public static void main(String[] args) throws Exception {
testColorPanels();
testShowDialog(true);
testShowDialog(false);
try {
testColorPanels();
testShowDialog(true);
testShowDialog(false);
} finally {
if(frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
}
}

private static void testColorPanels() throws Exception {
@@ -182,7 +187,7 @@ private static boolean colorHasAlpha(){
}

private static void createAndShowGUI() {
JFrame frame = new JFrame();
frame = new JFrame();
frame.setSize(700, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
colorChooser = new JColorChooser();
@@ -43,7 +43,7 @@

public class bug4523758 {

private JFrame frame;
private static JFrame frame;
private JToolBar tools;
private JComboBox combo;

@@ -153,13 +153,15 @@ public void run() {
}
}

public static void main(String[] args) {
public static void main(String[] args) throws Exception {
try {
bug4523758 test = new bug4523758();
test.doTest();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("FAIL");
} finally {
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
}
}

@@ -46,14 +46,18 @@
private static MyComboUI comboUI;

public static void main(String[] args) throws Exception {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
test();
System.out.println("Test passed");
try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
test();
System.out.println("Test passed");
} finally {
if (frame != null) SwingUtilities.invokeAndWait(() -> frame.dispose());
}
}

private static void createAndShowGUI() {
@@ -42,43 +42,48 @@
*/

public class Test7195179 {
private static JFrame frame;
public static void main(String[] args) throws Exception {
invokeAndWait(new Runnable() {
@Override
public void run() {
Integer[] items = {null, 1, 2, 3};
JComboBox<Integer> combo = new JComboBox<>(items);
JLabel label = new JLabel("choose:");
JPanel panel = new JPanel();
GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
label.setLabelFor(combo);
combo.setSelectedIndex(0);
combo.setRenderer(new ListCellRenderer<Integer>() {
private final BasicComboBoxRenderer renderer = new BasicComboBoxRenderer();
try {
Integer[] items = {null, 1, 2, 3};
JComboBox<Integer> combo = new JComboBox<>(items);
JLabel label = new JLabel("choose:");
JPanel panel = new JPanel();
GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
label.setLabelFor(combo);
combo.setSelectedIndex(0);
combo.setRenderer(new ListCellRenderer<Integer>() {
private final BasicComboBoxRenderer renderer = new BasicComboBoxRenderer();

@Override
public Component getListCellRendererComponent(JList<? extends Integer> list, Integer value, int index, boolean isSelected, boolean cellHasFocus) {
return this.renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(true);
layout.setHorizontalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup().addComponent(label))
.addGroup(layout.createParallelGroup().addComponent(combo)));
layout.setVerticalGroup(layout
.createSequentialGroup()
.addGroup(layout
@Override
public Component getListCellRendererComponent(JList<? extends Integer> list, Integer value, int index, boolean isSelected, boolean cellHasFocus) {
return this.renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
});
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(true);
layout.setHorizontalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup().addComponent(label))
.addGroup(layout.createParallelGroup().addComponent(combo)));
layout.setVerticalGroup(layout
.createSequentialGroup()
.addGroup(layout
.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(label)
.addComponent(combo)));

JFrame frame = new JFrame(getClass().getSimpleName());
frame.add(panel);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setVisible(true);
frame = new JFrame(getClass().getSimpleName());
frame.add(panel);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setVisible(true);
} finally {
if (frame != null) frame.dispose();
}
}
});
}
@@ -43,13 +43,14 @@
public class bug8057893 {

private static volatile boolean isComboBoxEdited = false;
private static JFrame frame;

public static void main(String[] args) throws Exception {
Robot robot = new Robot();
robot.setAutoDelay(50);

EventQueue.invokeAndWait(() -> {
JFrame frame = new JFrame();
frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JComboBox<String> comboBox = new JComboBox<>(new String[]{"one", "two"});
comboBox.setEditable(true);
@@ -76,6 +77,7 @@ public void actionPerformed(ActionEvent e) {
robot.keyRelease(KeyEvent.VK_ENTER);
robot.waitForIdle();

if (frame != null) EventQueue.invokeAndWait(() -> frame.dispose());
if(!isComboBoxEdited){
throw new RuntimeException("ComboBoxEdited event is not fired!");
}

0 comments on commit 55f3fd9

Please sign in to comment.
You can’t perform that action at this time.