Skip to content

Commit 319faa5

Browse files
committed
8296084: javax/swing/JSpinner/4788637/bug4788637.java fails intermittently on a VM
Reviewed-by: tr, serb
1 parent b73363f commit 319faa5

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

test/jdk/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,6 @@ javax/swing/JWindow/ShapedAndTranslucentWindows/TranslucentJComboBox.java 802462
649649
# The next test below is an intermittent failure
650650
javax/swing/JTree/DnD/LastNodeLowerHalfDrop.java 8159131 linux-all
651651
javax/swing/JTree/4633594/JTreeFocusTest.java 7105441 macosx-all
652-
javax/swing/JSpinner/4788637/bug4788637.java 8296084 linux-all
653652
javax/swing/AbstractButton/6711682/bug6711682.java 8060765 windows-all,macosx-all
654653
javax/swing/JFileChooser/6396844/TwentyThousandTest.java 8198003 generic-all
655654
javax/swing/JPopupMenu/6800513/bug6800513.java 7184956 macosx-all

test/jdk/javax/swing/JSpinner/4788637/bug4788637.java

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@
2121
* questions.
2222
*/
2323

24+
import java.io.File;
25+
26+
import java.awt.image.BufferedImage;
27+
import java.awt.Dimension;
2428
import java.awt.GridBagConstraints;
2529
import java.awt.GridBagLayout;
2630
import java.awt.Point;
2731
import java.awt.Rectangle;
2832
import java.awt.Robot;
33+
import java.awt.Toolkit;
2934
import java.awt.event.InputEvent;
3035

3136
import javax.swing.JFrame;
@@ -38,8 +43,10 @@
3843
import javax.swing.event.ChangeEvent;
3944
import javax.swing.event.ChangeListener;
4045

46+
import javax.imageio.ImageIO;
4147
import static javax.swing.UIManager.getInstalledLookAndFeels;
4248

49+
4350
/**
4451
* @test
4552
* @bug 4788637 7124307
@@ -52,22 +59,23 @@ public final class bug4788637 {
5259
private static JFrame fr;
5360

5461
private static Robot robot;
55-
private int step;
56-
private boolean spinnerValueChanged[] = {false, false, false};
62+
private int step = 0;
63+
private volatile boolean spinnerValueChanged[] = {false, false, false};
5764

58-
private static Point p;
59-
private static Rectangle rect;
65+
private static volatile Point p;
66+
private static volatile Rectangle rect;
6067

6168
public static void main(final String[] args) throws Exception {
6269
robot = new Robot();
63-
robot.setAutoDelay(50);
70+
robot.setAutoDelay(100);
6471
robot.setAutoWaitForIdle(true);
6572
for (final UIManager.LookAndFeelInfo laf : getInstalledLookAndFeels()) {
6673
SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf));
6774
bug4788637 app = new bug4788637();
6875
try {
6976
SwingUtilities.invokeAndWait(app::createAndShowGUI);
7077
robot.waitForIdle();
78+
robot.delay(1000);
7179
SwingUtilities.invokeAndWait(()-> {
7280
spinner.requestFocus();
7381
p = spinner.getLocationOnScreen();
@@ -106,9 +114,11 @@ public void stateChanged(ChangeEvent e) {
106114
public void start() {
107115
try {
108116
Thread.sleep(1000);
117+
System.out.println("p " + p + " rect " + rect);
109118
// Move mouse to the up arrow button
110119
robot.mouseMove(p.x+rect.width-3, p.y+3);
111-
robot.mousePress(InputEvent.BUTTON1_MASK);
120+
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
121+
112122
synchronized (bug4788637.this) {
113123
if (!spinnerValueChanged[step]) {
114124
bug4788637.this.wait(3000);
@@ -123,6 +133,7 @@ public void start() {
123133
bug4788637.this.wait(3000);
124134
}
125135
}
136+
robot.waitForIdle();
126137

127138
// Move mouse to the up arrow button
128139
robot.mouseMove(p.x+rect.width-3, p.y+3);
@@ -132,8 +143,10 @@ public void start() {
132143
bug4788637.this.wait(3000);
133144
}
134145
}
146+
robot.waitForIdle();
135147

136-
robot.mouseRelease(InputEvent.BUTTON1_MASK);
148+
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
149+
robot.waitForIdle();
137150
} catch(Throwable t) {
138151
throw new RuntimeException(t);
139152
}
@@ -145,6 +158,15 @@ public void destroy() {
145158
if (!spinnerValueChanged[0] ||
146159
spinnerValueChanged[1] ||
147160
!spinnerValueChanged[2]) {
161+
System.out.println("!spinnerValueChanged[0] " + !spinnerValueChanged[0] +
162+
" spinnerValueChanged[1] " + spinnerValueChanged[1] +
163+
" !spinnerValueChanged[2] " + !spinnerValueChanged[2]);
164+
try {
165+
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
166+
Rectangle screen = new Rectangle(0, 0, (int) screenSize.getWidth(), (int) screenSize.getHeight());
167+
BufferedImage fullScreen = robot.createScreenCapture(screen);
168+
ImageIO.write(fullScreen, "png", new File("fullScreen.png"));
169+
} catch (Exception e) {}
148170
throw new Error("JSpinner buttons don't conform to most platform conventions");
149171
}
150172
}

0 commit comments

Comments
 (0)