Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7190978: javax/swing/JComponent/7154030/bug7154030.java fails on mac #955

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,6 @@ javax/sound/midi/Sequencer/MetaCallback.java 8178698 linux-all
javax/swing/plaf/basic/BasicTextUI/8001470/bug8001470.java 8233177 linux-all,windows-all

javax/swing/border/TestTitledBorderLeak.java 8213531 linux-all
javax/swing/JComponent/7154030/bug7154030.java 7190978 generic-all
javax/swing/JComponent/6683775/bug6683775.java 8172337 generic-all
javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedTranslucentPerPixelTranslucentGradient.java 8233582 linux-all
javax/swing/JWindow/ShapedAndTranslucentWindows/ShapedPerPixelTranslucentGradient.java 8233582 linux-all
Expand Down
32 changes: 24 additions & 8 deletions test/jdk/javax/swing/JComponent/7154030/bug7154030.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;

/*
* @test
Expand All @@ -57,6 +59,7 @@ public class bug7154030 {

private static JButton button = null;
private static JFrame frame;
private static int locx, locy;

public static void main(String[] args) throws Exception {
try {
Expand Down Expand Up @@ -86,14 +89,19 @@ public void run() {

frame.setContentPane(desktop);
frame.setSize(300, 300);
frame.setLocation(0, 0);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
});

robot.waitForIdle(500);
imageInit = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usage of size 300x300 has the same issues as locx/locy before. It is part of the window bounds.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but 300x300 is set in frame setSize..if I use frame getBounds instead of already set 300x300, that will not be right, according to me...What if getBounds() has some bug (in some platform) and return some other width/height (say 1 pixel less, we might have similar bug in 8196465) that what is set in setSize, then the test might pass even though robot is capturing wrong bounds.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but 300x300 is set in frame setSize..if I use frame getBounds instead of already set 300x300, that will not be right, according to me...

The test should set the size 300,300 to the frame and then request and use the real bounds of the frame.

What if getBounds() has some bug (in some platform) and return some other width/height (say 1 pixel less, we might have similar bug in 8196465) that what is set in setSize, then the test might pass even though robot is capturing wrong bounds.

The getBounds() simply returns the size which was set by the native system, so is it a bug in getBounds() or the real bounds of the frame "say 1 pixel less"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any further feedback?

robot.waitForIdle(1000);

Rectangle bounds = frame.getBounds();
locx = bounds.x;
locy = bounds.y;

imageInit = robot.createScreenCapture(new Rectangle(locx, locy, 300, 300));

SwingUtilities.invokeAndWait(new Runnable() {

Expand All @@ -104,8 +112,10 @@ public void run() {
});

robot.waitForIdle(500);
imageShow = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
imageShow = robot.createScreenCapture(new Rectangle(locx, locy, 300, 300));
if (Util.compareBufferedImages(imageInit, imageShow)) {
ImageIO.write(imageInit, "png", new File("imageInit.png"));
ImageIO.write(imageShow, "png", new File("imageShow.png"));
throw new Exception("Failed to show opaque button");
}

Expand All @@ -119,9 +129,11 @@ public void run() {
});

robot.waitForIdle(500);
imageHide = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
imageHide = robot.createScreenCapture(new Rectangle(locx, locy, 300, 300));

if (!Util.compareBufferedImages(imageInit, imageHide)) {
ImageIO.write(imageInit, "png", new File("imageInit.png"));
ImageIO.write(imageHide, "png", new File("imageHide.png"));
throw new Exception("Failed to hide opaque button");
}

Expand All @@ -136,7 +148,7 @@ public void run() {
});

robot.waitForIdle(500);
imageInit = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
imageInit = robot.createScreenCapture(new Rectangle(locx, locy, 300, 300));

SwingUtilities.invokeAndWait(new Runnable() {

Expand All @@ -147,7 +159,7 @@ public void run() {
});

robot.waitForIdle(500);
imageShow = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
imageShow = robot.createScreenCapture(new Rectangle(locx, locy, 300, 300));

SwingUtilities.invokeAndWait(new Runnable() {

Expand All @@ -158,13 +170,17 @@ public void run() {
});

if (Util.compareBufferedImages(imageInit, imageShow)) {
ImageIO.write(imageInit, "png", new File("imageInit.png"));
ImageIO.write(imageShow, "png", new File("imageShow.png"));
throw new Exception("Failed to show non-opaque button");
}

robot.waitForIdle(500);
imageHide = robot.createScreenCapture(new Rectangle(0, 0, 300, 300));
imageHide = robot.createScreenCapture(new Rectangle(locx, locy, 300, 300));

if (!Util.compareBufferedImages(imageInit, imageHide)) {
ImageIO.write(imageInit, "png", new File("imageInit.png"));
ImageIO.write(imageHide, "png", new File("imageHide.png"));
throw new Exception("Failed to hide non-opaque button");
}
} finally {
Expand Down