Skip to content

Commit 5181f9c

Browse files
committed
7190978: javax/swing/JComponent/7154030/bug7154030.java fails on mac
Reviewed-by: serb
1 parent 35284e4 commit 5181f9c

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

test/jdk/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,6 @@ javax/sound/midi/Sequencer/MetaCallback.java 8178698 linux-all
730730
javax/swing/plaf/basic/BasicTextUI/8001470/bug8001470.java 8233177 linux-all,windows-all
731731

732732
javax/swing/border/TestTitledBorderLeak.java 8213531 linux-all
733-
javax/swing/JComponent/7154030/bug7154030.java 7190978 generic-all
734733
javax/swing/JComponent/6683775/bug6683775.java 8172337 generic-all
735734
javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedTranslucentPerPixelTranslucentGradient.java 8233582 linux-all
736735
javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedPerPixelTranslucentGradient.java 8233582 linux-all

test/jdk/javax/swing/JComponent/7154030/bug7154030.java

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import java.awt.Robot;
4040
import java.awt.Toolkit;
4141
import java.awt.image.BufferedImage;
42+
import javax.imageio.ImageIO;
43+
import java.io.File;
4244

4345
/*
4446
* @test
@@ -57,6 +59,7 @@ public class bug7154030 {
5759

5860
private static JButton button = null;
5961
private static JFrame frame;
62+
private static int locx, locy, frw, frh;
6063

6164
public static void main(String[] args) throws Exception {
6265
try {
@@ -86,14 +89,21 @@ public void run() {
8689

8790
frame.setContentPane(desktop);
8891
frame.setSize(300, 300);
89-
frame.setLocation(0, 0);
92+
frame.setLocationRelativeTo(null);
9093
frame.setVisible(true);
9194
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
9295
}
9396
});
9497

95-
robot.waitForIdle(500);
96-
imageInit = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
98+
robot.waitForIdle(1000);
99+
100+
Rectangle bounds = frame.getBounds();
101+
locx = bounds.x;
102+
locy = bounds.y;
103+
frw = bounds.width;
104+
frh = bounds.height;
105+
106+
imageInit = robot.createScreenCapture(new Rectangle(locx, locy, frw, frh));
97107

98108
SwingUtilities.invokeAndWait(new Runnable() {
99109

@@ -104,8 +114,10 @@ public void run() {
104114
});
105115

106116
robot.waitForIdle(500);
107-
imageShow = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
117+
imageShow = robot.createScreenCapture(new Rectangle(locx, locy, frw, frh));
108118
if (Util.compareBufferedImages(imageInit, imageShow)) {
119+
ImageIO.write(imageInit, "png", new File("imageInit.png"));
120+
ImageIO.write(imageShow, "png", new File("imageShow.png"));
109121
throw new Exception("Failed to show opaque button");
110122
}
111123

@@ -119,9 +131,11 @@ public void run() {
119131
});
120132

121133
robot.waitForIdle(500);
122-
imageHide = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
134+
imageHide = robot.createScreenCapture(new Rectangle(locx, locy, frw, frh));
123135

124136
if (!Util.compareBufferedImages(imageInit, imageHide)) {
137+
ImageIO.write(imageInit, "png", new File("imageInit.png"));
138+
ImageIO.write(imageHide, "png", new File("imageHide.png"));
125139
throw new Exception("Failed to hide opaque button");
126140
}
127141

@@ -136,7 +150,7 @@ public void run() {
136150
});
137151

138152
robot.waitForIdle(500);
139-
imageInit = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
153+
imageInit = robot.createScreenCapture(new Rectangle(locx, locy, frw, frh));
140154

141155
SwingUtilities.invokeAndWait(new Runnable() {
142156

@@ -147,7 +161,7 @@ public void run() {
147161
});
148162

149163
robot.waitForIdle(500);
150-
imageShow = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
164+
imageShow = robot.createScreenCapture(new Rectangle(locx, locy, frw, frh));
151165

152166
SwingUtilities.invokeAndWait(new Runnable() {
153167

@@ -158,13 +172,17 @@ public void run() {
158172
});
159173

160174
if (Util.compareBufferedImages(imageInit, imageShow)) {
175+
ImageIO.write(imageInit, "png", new File("imageInit.png"));
176+
ImageIO.write(imageShow, "png", new File("imageShow.png"));
161177
throw new Exception("Failed to show non-opaque button");
162178
}
163179

164180
robot.waitForIdle(500);
165-
imageHide = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
181+
imageHide = robot.createScreenCapture(new Rectangle(locx, locy, frw, frh));
166182

167183
if (!Util.compareBufferedImages(imageInit, imageHide)) {
184+
ImageIO.write(imageInit, "png", new File("imageInit.png"));
185+
ImageIO.write(imageHide, "png", new File("imageHide.png"));
168186
throw new Exception("Failed to hide non-opaque button");
169187
}
170188
} finally {

0 commit comments

Comments
 (0)