Skip to content

Commit

Permalink
8260035: Deproblemlist few problemlisted test
Browse files Browse the repository at this point in the history
Reviewed-by: lucy
Backport-of: 7f7166d
  • Loading branch information
GoeLin committed Nov 13, 2023
1 parent 4aa3196 commit 1b6ff86
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 84 deletions.
2 changes: 0 additions & 2 deletions test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,6 @@ javax/swing/JTabbedPane/8007563/Test8007563.java 8051591 generic-all
javax/swing/JTabbedPane/4624207/bug4624207.java 8064922 macosx-all
javax/swing/JTabbedPane/7024235/Test7024235.java 8028281 macosx-all
javax/swing/SwingUtilities/TestBadBreak/TestBadBreak.java 8160720 generic-all
javax/swing/plaf/basic/Test6984643.java 8198340 windows-all
javax/swing/text/CSSBorder/6796710/bug6796710.java 8196099 windows-all
javax/swing/text/DefaultCaret/HidingSelection/HidingSelectionTest.java 8194048 windows-all
javax/swing/JFileChooser/6798062/bug6798062.java 8146446 windows-all
Expand All @@ -724,7 +723,6 @@ javax/swing/DataTransfer/8059739/bug8059739.java 8199074 generic-all
javax/swing/JTabbedPane/TabProb.java 8236635 linux-all
javax/swing/text/GlyphPainter2/6427244/bug6427244.java 8208566 macosx-all
javax/swing/JRootPane/4670486/bug4670486.java 8042381 macosx-all
javax/swing/JMenuItem/6249972/bug6249972.java 8233640 macosx-all
javax/swing/JButton/8151303/PressedIconTest.java 8266246 macosx-aarch64
javax/swing/plaf/synth/7158712/bug7158712.java 8238720 windows-all
javax/swing/plaf/basic/BasicComboPopup/JComboBoxPopupLocation/JComboBoxPopupLocation.java 8238720 windows-all
Expand Down
85 changes: 49 additions & 36 deletions test/jdk/javax/swing/JMenuItem/6249972/bug6249972.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
* @key headful
* @bug 6249972
* @summary Tests that JMenuItem(String,int) handles lower-case mnemonics properly.
* @library ../../../../lib/testlibrary
* @build ExtendedRobot
* @author Mikhail Lapshin
* @run main bug6249972
*/
Expand All @@ -36,61 +34,76 @@
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.InputEvent;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Robot;

public class bug6249972 implements ActionListener {


private JFrame frame;
private static JFrame frame;
private static Robot robot;
private JMenu menu;
private volatile boolean testPassed = false;
private volatile Point p = null;
private volatile Dimension size = null;

public static void main(String[] args) throws Exception {
bug6249972 bugTest = new bug6249972();
bugTest.test();
try {
robot = new Robot();
robot.setAutoDelay(100);
bug6249972 bugTest = new bug6249972();
robot.waitForIdle();
robot.delay(1000);
bugTest.test();
} finally {
if (frame != null) {
SwingUtilities.invokeAndWait(() -> frame.dispose());
}
}
}

public bug6249972() throws Exception {
SwingUtilities.invokeAndWait(
new Runnable() {
public void run() {
frame = new JFrame("bug6249972");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JMenuBar bar = new JMenuBar();
frame.setJMenuBar(bar);

menu = new JMenu("Problem");
bar.add(menu);

JMenuItem item = new JMenuItem("JMenuItem(String,'z')", 'z');
item.addActionListener(bug6249972.this);
menu.add(item);

frame.setLocationRelativeTo(null);
frame.pack();
frame.setVisible(true);
}
}
);
SwingUtilities.invokeAndWait(() -> {
frame = new JFrame("bug6249972");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JMenuBar bar = new JMenuBar();
frame.setJMenuBar(bar);

menu = new JMenu("Problem");
bar.add(menu);

JMenuItem item = new JMenuItem("JMenuItem(String,'z')", 'z');
item.addActionListener(bug6249972.this);
menu.add(item);

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


private void test() throws Exception {
ExtendedRobot robot = new ExtendedRobot();
robot.waitForIdle();
java.awt.Point p = menu.getLocationOnScreen();
java.awt.Dimension size = menu.getSize();
SwingUtilities.invokeAndWait(() -> {
p = menu.getLocationOnScreen();
size = menu.getSize();
});
p.x += size.width / 2;
p.y += size.height / 2;
robot.mouseMove(p.x, p.y);
robot.click();
robot.delay(100);
robot.waitForIdle();
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

robot.waitForIdle();
robot.type(KeyEvent.VK_Z);
robot.delay(100);
robot.keyPress(KeyEvent.VK_Z);
robot.keyRelease(KeyEvent.VK_Z);

robot.waitForIdle();
frame.dispose(); // Try to stop the event dispatch thread
robot.delay(1000);

if (!testPassed) {
throw new RuntimeException("JMenuItem(String,int) does not handle " +
Expand Down
100 changes: 55 additions & 45 deletions test/jdk/javax/swing/JTree/6263446/bug6263446.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,83 +43,92 @@ public class bug6263446 {
private static final String ALL = FIRST + " " + SECOND;
private static JTree tree;
private static Robot robot;
private static JFrame frame;

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

SwingUtilities.invokeAndWait(new Runnable() {

@Override
public void run() {
createAndShowGUI();
}
});

robot.waitForIdle();
robot.delay(1000);

Point point = getClickPoint();
robot.mouseMove(point.x, point.y);
try {
Point point = getClickPoint();
robot.mouseMove(point.x, point.y);

// click count 3
click(1);
assertNotEditing();
// click count 3
click(1);
assertNotEditing();

click(2);
assertNotEditing();
click(2);
assertNotEditing();

click(3);
assertEditing();
cancelCellEditing();
assertNotEditing();
click(3);
assertEditing();
cancelCellEditing();
assertNotEditing();

click(4);
checkSelectedText(FIRST);
click(4);
checkSelectedText(FIRST);

click(5);
checkSelectedText(ALL);
click(5);
checkSelectedText(ALL);

// click count 4
setClickCountToStart(4);
// click count 4
setClickCountToStart(4);

click(1);
assertNotEditing();
click(1);
assertNotEditing();

click(2);
assertNotEditing();
click(2);
assertNotEditing();

click(3);
assertNotEditing();
click(3);
assertNotEditing();

click(4);
assertEditing();
cancelCellEditing();
assertNotEditing();
click(4);
assertEditing();
cancelCellEditing();
assertNotEditing();

click(5);
checkSelectedText(FIRST);
click(5);
checkSelectedText(FIRST);

click(6);
checkSelectedText(ALL);
click(6);
checkSelectedText(ALL);

// start path editing
startPathEditing();
assertEditing();
// start path editing
startPathEditing();
assertEditing();

click(1);
checkSelection(null);
click(1);
checkSelection(null);

click(2);
checkSelection(FIRST);
click(2);
checkSelection(FIRST);

click(3);
checkSelection(ALL);
click(3);
checkSelection(ALL);
} finally {
if (frame != null) {
SwingUtilities.invokeAndWait(() -> frame.dispose());
}
}
}

private static void click(int times) {
robot.delay(500);
for (int i = 0; i < times; i++) {
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.waitForIdle();
}
}

Expand Down Expand Up @@ -148,7 +157,7 @@ private static TreeModel createTreeModel() {

private static void createAndShowGUI() {

JFrame frame = new JFrame();
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

tree = new JTree(createTreeModel());
Expand All @@ -158,6 +167,7 @@ private static void createAndShowGUI() {

frame.getContentPane().add(tree);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}

Expand Down
2 changes: 1 addition & 1 deletion test/jdk/javax/swing/plaf/basic/Test6984643.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public boolean isSupportedLookAndFeel() {
}
});

SwingUtilities.invokeLater(new Runnable() {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
new JFileChooser();
}
Expand Down

0 comments on commit 1b6ff86

Please sign in to comment.