8196090: javax/swing/JComboBox/6559152/bug6559152.java fails

Reviewed-by: serb
This commit is contained in:
Prasanta Sadhukhan 2020-12-11 04:54:27 +00:00
parent 1d15ebe19e
commit b90b7f50df
5 changed files with 57 additions and 35 deletions

View file

@ -738,7 +738,6 @@ javax/swing/JSplitPane/4201995/bug4201995.java 8079127 generic-all
javax/swing/JTree/DnD/LastNodeLowerHalfDrop.java 8159131 linux-all javax/swing/JTree/DnD/LastNodeLowerHalfDrop.java 8159131 linux-all
javax/swing/JTree/4633594/JTreeFocusTest.java 8173125 macosx-all javax/swing/JTree/4633594/JTreeFocusTest.java 8173125 macosx-all
javax/swing/AbstractButton/6711682/bug6711682.java 8060765 windows-all,macosx-all javax/swing/AbstractButton/6711682/bug6711682.java 8060765 windows-all,macosx-all
javax/swing/JComboBox/6559152/bug6559152.java 8196090 windows-all,macosx-all
javax/swing/JComboBox/8032878/bug8032878.java 8196092,8196439 windows-all,macosx-all,linux-all javax/swing/JComboBox/8032878/bug8032878.java 8196092,8196439 windows-all,macosx-all,linux-all
javax/swing/JComboBox/8072767/bug8072767.java 8196093 windows-all,macosx-all javax/swing/JComboBox/8072767/bug8072767.java 8196093 windows-all,macosx-all
javax/swing/JFileChooser/4524490/bug4524490.java 8042380 generic-all javax/swing/JFileChooser/4524490/bug4524490.java 8042380 generic-all

View file

@ -68,6 +68,7 @@ public class bug4199622 extends JFrame implements ActionListener {
setSize(300, 300); setSize(300, 300);
pack(); pack();
setLocationRelativeTo(null);
} }
@Override @Override
@ -83,7 +84,7 @@ public class bug4199622 extends JFrame implements ActionListener {
if (robot == null) { if (robot == null) {
try { try {
robot = new Robot(); robot = new Robot();
robot.setAutoDelay(20); robot.setAutoDelay(100);
} catch (AWTException e) { } catch (AWTException e) {
throw new RuntimeException("Can't create robot. Test failed", e); throw new RuntimeException("Can't create robot. Test failed", e);
} }

View file

@ -59,6 +59,7 @@ public class DefaultButtonTest extends JFrame implements ActionListener {
getContentPane().add(new DefaultPanel(this)); getContentPane().add(new DefaultPanel(this));
pack(); pack();
setVisible(true); setVisible(true);
setLocationRelativeTo(null);
} }
public static void test() { public static void test() {
@ -108,16 +109,12 @@ public class DefaultButtonTest extends JFrame implements ActionListener {
// Change value, changing focus should fire an ActionEvent. // Change value, changing focus should fire an ActionEvent.
robot.waitForIdle(); robot.waitForIdle();
robot.keyPress(KeyEvent.VK_BACK_SPACE); robot.keyPress(KeyEvent.VK_BACK_SPACE);
robot.waitForIdle();
robot.keyRelease(KeyEvent.VK_BACK_SPACE); robot.keyRelease(KeyEvent.VK_BACK_SPACE);
robot.waitForIdle(); robot.waitForIdle();
robot.keyPress(KeyEvent.VK_SHIFT); robot.keyPress(KeyEvent.VK_SHIFT);
robot.waitForIdle();
robot.keyPress(KeyEvent.VK_TAB); robot.keyPress(KeyEvent.VK_TAB);
robot.waitForIdle();
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.waitForIdle();
robot.keyRelease(KeyEvent.VK_TAB); robot.keyRelease(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.waitForIdle(); robot.waitForIdle();
testEditChange(true); testEditChange(true);
robot.waitForIdle(); robot.waitForIdle();

View file

@ -63,6 +63,7 @@ public class bug4743225 extends JFrame {
}); });
add(cb); add(cb);
pack(); pack();
setLocationRelativeTo(null);
} }
public static BasicComboPopup getPopup() { public static BasicComboPopup getPopup() {
@ -78,7 +79,7 @@ public class bug4743225 extends JFrame {
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
Robot robot = new Robot(); Robot robot = new Robot();
robot.setAutoDelay(20); robot.setAutoDelay(100);
SwingUtilities.invokeAndWait(new Runnable() { SwingUtilities.invokeAndWait(new Runnable() {
public void run() { public void run() {

View file

@ -27,39 +27,59 @@
* @bug 6559152 * @bug 6559152
* @summary Checks that you can select an item in JComboBox with keyboard * @summary Checks that you can select an item in JComboBox with keyboard
* when it is a JTable cell editor. * when it is a JTable cell editor.
* @author Mikhail Lapshin
* @library /lib/client
* @build ExtendedRobot
* @run main bug6559152 * @run main bug6559152
*/ */
import javax.swing.*; import javax.swing.DefaultCellEditor;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JComboBox;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel; import javax.swing.table.DefaultTableModel;
import java.awt.*; import javax.swing.JTable;
import java.awt.Point;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.InputEvent;
import java.awt.Robot;
public class bug6559152 { public class bug6559152 {
private JFrame frame; private static JFrame frame;
private JComboBox cb; private static JComboBox cb;
private ExtendedRobot robot; private static Robot robot;
private static Point p = null;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
final bug6559152 test = new bug6559152(); robot = new Robot();
robot.setAutoDelay(100);
try { try {
SwingUtilities.invokeAndWait(new Runnable() { SwingUtilities.invokeAndWait(() -> setupUI());
public void run() { blockTillDisplayed(cb);
test.setupUI(); robot.waitForIdle();
} robot.delay(1000);
}); test();
test.test();
} finally { } finally {
if (test.frame != null) { if (frame != null) {
test.frame.dispose(); SwingUtilities.invokeAndWait(() -> frame.dispose());
} }
} }
} }
private void setupUI() { static void blockTillDisplayed(JComponent comp) throws Exception {
while (p == null) {
try {
SwingUtilities.invokeAndWait(() -> {
p = comp.getLocationOnScreen();
});
} catch (IllegalStateException e) {
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {
}
}
}
}
private static void setupUI() {
frame = new JFrame(); frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@ -72,27 +92,31 @@ public class bug6559152 {
frame.add(cb); frame.add(cb);
frame.pack(); frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true); frame.setVisible(true);
frame.setLocationRelativeTo(null);
} }
private void test() throws Exception { private static void test() throws Exception {
robot = new ExtendedRobot(); robot.mouseMove(p.x, p.y);
robot.waitForIdle(); robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
testImpl(); testImpl();
robot.waitForIdle(); robot.waitForIdle();
checkResult(); checkResult();
} }
private void testImpl() throws Exception { private static void testImpl() throws Exception {
robot.type(KeyEvent.VK_DOWN); robot.keyPress(KeyEvent.VK_DOWN);
robot.keyRelease(KeyEvent.VK_DOWN);
robot.waitForIdle(); robot.waitForIdle();
robot.type(KeyEvent.VK_DOWN); robot.keyPress(KeyEvent.VK_DOWN);
robot.keyRelease(KeyEvent.VK_DOWN);
robot.waitForIdle(); robot.waitForIdle();
robot.type(KeyEvent.VK_ENTER); robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
} }
private void checkResult() { private static void checkResult() {
if (cb.getSelectedItem().equals("two")) { if (cb.getSelectedItem().equals("two")) {
System.out.println("Test passed"); System.out.println("Test passed");
} else { } else {