Skip to content

Commit

Permalink
8300405: Screen capture for test JFileChooserSetLocationTest.java, fa…
Browse files Browse the repository at this point in the history
…ilure case

Backport-of: db8fa1be052c8558398ea5fea2105458f1a3cd16
  • Loading branch information
amosshi authored and GoeLin committed Oct 11, 2023
1 parent 6e34daa commit 75b7c79
Showing 1 changed file with 13 additions and 1 deletion.
Expand Up @@ -23,17 +23,23 @@

import java.awt.Component;
import java.awt.Dimension;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
Expand Down Expand Up @@ -175,12 +181,18 @@ private static Point getActualLocation(final MyFileChooser fcoo)
return pt.get();
}

public static void verify(int x1, int x2, int y1, int y2) {
public static void verify(int x1, int x2, int y1, int y2) throws Exception {
System.out.println("verify " + x1 + "==" + x2 + "; " + y1 + "==" + y2);
if ((Math.abs(x1 - x2) < TOLERANCE_LEVEL) &&
(Math.abs(y1 - y2) < TOLERANCE_LEVEL)) {
System.out.println("Test passed");
} else {
GraphicsConfiguration gc = GraphicsEnvironment.
getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
Rectangle gcBounds = gc.getBounds();
BufferedImage bufferedImage = robot.createScreenCapture(
new Rectangle(gcBounds));
ImageIO.write(bufferedImage, "png",new File("FailureImage.png"));
throw new RuntimeException(
"Test Failed, setLocation() is not working properly");
}
Expand Down

1 comment on commit 75b7c79

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.