8233559: [TESTBUG] TestNimbusOverride.java is failing on macos

Reviewed-by: psadhukhan, pbansal
This commit is contained in:
Tejpal Rebari 2020-05-27 09:08:08 +05:30
parent 04b3bf6024
commit c638618814
2 changed files with 28 additions and 26 deletions
test/jdk

@ -835,7 +835,6 @@ javax/swing/text/StyledEditorKit/4506788/bug4506788.java 8233562 macosx-all
javax/swing/text/JTextComponent/6361367/bug6361367.java 8233569 macosx-all
javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java 233570 macosx-all
javax/swing/ProgressMonitor/ProgressMonitorEscapeKeyPress.java 8233635 macosx-all
javax/swing/plaf/nimbus/TestNimbusOverride.java 8233559 macosx-all
javax/swing/JTable/7124218/SelectEditTableCell.java 8233551 macosx-all
javax/swing/JRootPane/4670486/bug4670486.java 8042381 macosx-all
javax/swing/JRadioButton/ButtonGroupFocus/ButtonGroupFocusTest.java 8233555 macosx-all

@ -31,9 +31,7 @@
*/
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.Robot;
import java.awt.event.KeyEvent;
@ -41,7 +39,6 @@ import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
@ -56,27 +53,32 @@ public class TestNimbusOverride extends JFrame
private static boolean passed = false;
public static void main(String [] args) throws Exception {
Robot robot = new Robot();
SwingUtilities.invokeAndWait(() -> {
try {
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Exception e) {
throw new RuntimeException(e);
}
tf = new TestNimbusOverride();
tf.pack();
tf.setVisible(true);
});
robot.setAutoDelay(100);
robot.waitForIdle();
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyRelease(KeyEvent.VK_SPACE);
robot.waitForIdle();
SwingUtilities.invokeAndWait(() -> tf.dispose());
if (!passed) {
try {
Robot robot = new Robot();
SwingUtilities.invokeAndWait(() -> {
try {
UIManager.setLookAndFeel(
"javax.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Exception e) {
throw new RuntimeException(e);
}
tf = new TestNimbusOverride();
tf.pack();
tf.setVisible(true);
});
robot.setAutoDelay(100);
robot.waitForIdle();
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyRelease(KeyEvent.VK_SPACE);
robot.waitForIdle();
if (!passed) {
throw new RuntimeException(
"Setting Nimbus.Overrides property affects custom keymap installation");
"Setting Nimbus.Overrides property affects custom" +
" keymap installation");
}
} finally {
SwingUtilities.invokeAndWait(() -> tf.dispose());
}
}
public TestNimbusOverride()
@ -84,8 +86,8 @@ public class TestNimbusOverride extends JFrame
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
/*
* Create a frame containing a JEditorPane, and override the action for the space bar to show
* a dialog.
* Create a frame containing a JEditorPane, and override the action for
* the space bar to show a dialog.
*/
JEditorPane pp = new JEditorPane();
UIDefaults defaults = new UIDefaults();
@ -102,7 +104,8 @@ public class TestNimbusOverride extends JFrame
Keymap origKeymap = pp.getKeymap();
Keymap km = JEditorPane.addKeymap("Test keymap", origKeymap);
km.addActionForKeyStroke(KeyStroke.getKeyStroke(' '), new AbstractAction("SHOW_SPACE") {
km.addActionForKeyStroke(KeyStroke.getKeyStroke(' '),
new AbstractAction("SHOW_SPACE") {
@Override
public void actionPerformed(ActionEvent e)
{