|
23 | 23 |
|
24 | 24 | import java.awt.Component;
|
25 | 25 | import java.awt.Dimension;
|
| 26 | +import java.awt.GraphicsConfiguration; |
| 27 | +import java.awt.GraphicsEnvironment; |
26 | 28 | import java.awt.HeadlessException;
|
27 | 29 | import java.awt.Point;
|
| 30 | +import java.awt.Rectangle; |
28 | 31 | import java.awt.Robot;
|
29 | 32 | import java.awt.event.ActionListener;
|
30 | 33 | import java.awt.event.InputEvent;
|
31 | 34 | import java.awt.event.KeyEvent;
|
| 35 | +import java.awt.image.BufferedImage; |
| 36 | +import java.io.File; |
32 | 37 | import java.util.Arrays;
|
33 | 38 | import java.util.List;
|
34 | 39 | import java.util.concurrent.atomic.AtomicBoolean;
|
35 | 40 | import java.util.concurrent.atomic.AtomicReference;
|
36 | 41 | import java.util.stream.Collectors;
|
| 42 | +import javax.imageio.ImageIO; |
37 | 43 | import javax.swing.JButton;
|
38 | 44 | import javax.swing.JDialog;
|
39 | 45 | import javax.swing.JFileChooser;
|
@@ -175,12 +181,18 @@ private static Point getActualLocation(final MyFileChooser fcoo)
|
175 | 181 | return pt.get();
|
176 | 182 | }
|
177 | 183 |
|
178 |
| - public static void verify(int x1, int x2, int y1, int y2) { |
| 184 | + public static void verify(int x1, int x2, int y1, int y2) throws Exception { |
179 | 185 | System.out.println("verify " + x1 + "==" + x2 + "; " + y1 + "==" + y2);
|
180 | 186 | if ((Math.abs(x1 - x2) < TOLERANCE_LEVEL) &&
|
181 | 187 | (Math.abs(y1 - y2) < TOLERANCE_LEVEL)) {
|
182 | 188 | System.out.println("Test passed");
|
183 | 189 | } else {
|
| 190 | + GraphicsConfiguration gc = GraphicsEnvironment. |
| 191 | + getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); |
| 192 | + Rectangle gcBounds = gc.getBounds(); |
| 193 | + BufferedImage bufferedImage = robot.createScreenCapture( |
| 194 | + new Rectangle(gcBounds)); |
| 195 | + ImageIO.write(bufferedImage, "png",new File("FailureImage.png")); |
184 | 196 | throw new RuntimeException(
|
185 | 197 | "Test Failed, setLocation() is not working properly");
|
186 | 198 | }
|
|
0 commit comments