8067986: Test javax/swing/JComboBox/ConsumedKeyTest/ConsumedKeyTest.java fails

Reviewed-by: serb
This commit is contained in:
Prasanta Sadhukhan 2020-05-21 12:02:18 +05:30
parent b58735ea76
commit af85c26514
3 changed files with 20 additions and 6 deletions

View File

@ -1709,8 +1709,20 @@ public class BasicComboBoxUI extends ComboBoxUI {
@Override
public boolean accept(Object c) {
if (getName() == HIDE) {
if (getName() == HIDE ) {
return (c != null && ((JComboBox)c).isPopupVisible());
} else if (getName() == ENTER) {
JRootPane root = SwingUtilities.getRootPane((JComboBox)c);
if (root != null) {
InputMap im = root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
ActionMap am = root.getActionMap();
if (im != null && am != null) {
Object obj = im.get(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
if (obj == null) {
return false;
}
}
}
}
return true;
}

View File

@ -738,7 +738,6 @@ javax/swing/plaf/basic/BasicTextUI/8001470/bug8001470.java 8233177 linux-all,win
javax/swing/border/TestTitledBorderLeak.java 8213531 linux-all
javax/swing/JComponent/7154030/bug7154030.java 7190978 generic-all
javax/swing/JComboBox/ConsumedKeyTest/ConsumedKeyTest.java 8067986 generic-all
javax/swing/JComponent/6683775/bug6683775.java 8172337 generic-all
javax/swing/JComboBox/6236162/bug6236162.java 8028707 windows-all,macosx-all
javax/swing/text/html/parser/Test8017492.java 8022535 generic-all

View File

@ -28,7 +28,7 @@ import java.awt.event.KeyEvent;
/*
@test
@key headful
@bug 8031485 8058193
@bug 8031485 8058193 8067986
@summary Combo box consuming escape and enter key events
@author Petr Pchelko
@library /lib/client/
@ -36,8 +36,9 @@ import java.awt.event.KeyEvent;
@run main ConsumedKeyTest
*/
public class ConsumedKeyTest {
private static volatile JFrame frame;
private static JFrame frame;
private static volatile boolean passed;
static ExtendedRobot robot;
public static void main(String... args) throws Exception {
test(KeyEvent.VK_ESCAPE);
@ -46,6 +47,7 @@ public class ConsumedKeyTest {
private static void test(final int key) throws Exception {
passed = false;
robot = new ExtendedRobot();
try {
SwingUtilities.invokeAndWait(() -> {
frame = new JFrame();
@ -57,10 +59,11 @@ public class ConsumedKeyTest {
addAction(panel, key);
frame.add(panel);
frame.setVisible(true);
frame.setAlwaysOnTop(true);
});
ExtendedRobot robot = new ExtendedRobot();
robot.waitForIdle();
robot.delay(500);
robot.type(key);
robot.waitForIdle();
if (!passed) {
@ -71,7 +74,7 @@ public class ConsumedKeyTest {
frame.dispose();
}
}
robot.delay(1000);
}
private static void addAction(JComponent comp, final int key) {