Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,6 @@ javax/swing/JSplitPane/4201995/bug4201995.java 8079127 generic-all
javax/swing/JTree/DnD/LastNodeLowerHalfDrop.java 8159131 linux-all
javax/swing/JTree/4633594/JTreeFocusTest.java 8173125 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/8072767/bug8072767.java 8196093 windows-all,macosx-all
javax/swing/JFileChooser/4524490/bug4524490.java 8042380 generic-all
Expand Down
3 changes: 2 additions & 1 deletion test/jdk/javax/swing/JComboBox/4199622/bug4199622.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class bug4199622 extends JFrame implements ActionListener {

setSize(300, 300);
pack();
setLocationRelativeTo(null);
}

@Override
Expand All @@ -83,7 +84,7 @@ static void doTest() {
if (robot == null) {
try {
robot = new Robot();
robot.setAutoDelay(20);
robot.setAutoDelay(100);
} catch (AWTException e) {
throw new RuntimeException("Can't create robot. Test failed", e);
}
Expand Down
7 changes: 2 additions & 5 deletions test/jdk/javax/swing/JComboBox/4515752/DefaultButtonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public DefaultButtonTest() {
getContentPane().add(new DefaultPanel(this));
pack();
setVisible(true);
setLocationRelativeTo(null);
}

public static void test() {
Expand Down Expand Up @@ -108,16 +109,12 @@ public static void test() {
// Change value, changing focus should fire an ActionEvent.
robot.waitForIdle();
robot.keyPress(KeyEvent.VK_BACK_SPACE);
robot.waitForIdle();
robot.keyRelease(KeyEvent.VK_BACK_SPACE);
robot.waitForIdle();
robot.keyPress(KeyEvent.VK_SHIFT);
robot.waitForIdle();
robot.keyPress(KeyEvent.VK_TAB);
robot.waitForIdle();
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.waitForIdle();
robot.keyRelease(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.waitForIdle();
testEditChange(true);
robot.waitForIdle();
Expand Down
3 changes: 2 additions & 1 deletion test/jdk/javax/swing/JComboBox/4743225/bug4743225.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void popupMenuCanceled(PopupMenuEvent e) {
});
add(cb);
pack();
setLocationRelativeTo(null);
}

public static BasicComboPopup getPopup() {
Expand All @@ -78,7 +79,7 @@ public static BasicComboPopup getPopup() {
public static void main(String... args) throws Exception {

Robot robot = new Robot();
robot.setAutoDelay(20);
robot.setAutoDelay(100);

SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
Expand Down
78 changes: 51 additions & 27 deletions test/jdk/javax/swing/JComboBox/6559152/bug6559152.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,59 @@
* @bug 6559152
* @summary Checks that you can select an item in JComboBox with keyboard
* when it is a JTable cell editor.
* @author Mikhail Lapshin
* @library /lib/client
* @build ExtendedRobot
* @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 java.awt.*;
import javax.swing.JTable;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.InputEvent;
import java.awt.Robot;

public class bug6559152 {
private JFrame frame;
private JComboBox cb;
private ExtendedRobot robot;
private static JFrame frame;
private static JComboBox cb;
private static Robot robot;
private static Point p = null;

public static void main(String[] args) throws Exception {
final bug6559152 test = new bug6559152();
robot = new Robot();
robot.setAutoDelay(100);
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
test.setupUI();
}
});
test.test();
SwingUtilities.invokeAndWait(() -> setupUI());
blockTillDisplayed(cb);
robot.waitForIdle();
robot.delay(1000);
test();
} finally {
if (test.frame != null) {
test.frame.dispose();
if (frame != null) {
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.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Expand All @@ -72,27 +92,31 @@ private void setupUI() {
frame.add(cb);

frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setLocationRelativeTo(null);
}

private void test() throws Exception {
robot = new ExtendedRobot();
robot.waitForIdle();
private static void test() throws Exception {
robot.mouseMove(p.x, p.y);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
testImpl();
robot.waitForIdle();
checkResult();
}

private void testImpl() throws Exception {
robot.type(KeyEvent.VK_DOWN);
private static void testImpl() throws Exception {
robot.keyPress(KeyEvent.VK_DOWN);
robot.keyRelease(KeyEvent.VK_DOWN);
robot.waitForIdle();
robot.type(KeyEvent.VK_DOWN);
robot.keyPress(KeyEvent.VK_DOWN);
robot.keyRelease(KeyEvent.VK_DOWN);
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")) {
System.out.println("Test passed");
} else {
Expand Down