Skip to content

Commit f2194b3

Browse files
committed
Updated screenshot process to use native screenshots
1 parent c0992f3 commit f2194b3

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

scripts/device-runner-app/tests/Cn1ssDeviceRunnerHelper.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,24 @@ static boolean emitCurrentFormScreenshot(String testName) {
4343
}
4444
int width = Math.max(1, current.getWidth());
4545
int height = Math.max(1, current.getHeight());
46-
Image screenshot = Image.createImage(width, height);
46+
Image[] img = new Image[1];
47+
Display.getInstance().screenshot(screen -> img[0] = screen);
48+
long time = System.currentTimeMillis();
49+
Display.getInstance().invokeAndBlock(() -> {
50+
while(img[0] == null) {
51+
Util.sleep(50);
52+
// timeout
53+
if (System.currentTimeMillis() - time > 2000) {
54+
return;
55+
}
56+
}
57+
});
58+
if (img[0] == null) {
59+
println("CN1SS:ERR:test=" + safeName + " message=Screenshot process timed out");
60+
println("CN1SS:END:" + safeName);
61+
return false;
62+
}
63+
Image screenshot = img[0];
4764
current.paintComponent(screenshot.getGraphics(), true);
4865
try {
4966
ImageIO io = ImageIO.getImageIO();

0 commit comments

Comments
 (0)