Skip to content

Commit 960ef4b

Browse files
authored
CompareScreenshotTest: mitigate a race condition causing tests to fail (#1)
* CompareScreenshotTest: mitigate a race condition causing tests to fail * replace yield() with sleep() as suggested by Gemini Code Assist
1 parent ed89db3 commit 960ef4b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

test/org/lwjgl/opengl/awt/CompareScreenshotTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,14 @@ public void run() {
283283
BufferedImage background = rbt.createScreenCapture(frameBounds);
284284
// Some Operating Systems have a window open/close animation, so we wait until the screenshot is stable
285285
while (true) {
286+
// Pause at least 500 milliseconds between captures
287+
try {
288+
Thread.sleep(500);
289+
} catch (InterruptedException e) {
290+
Thread.currentThread().interrupt();
291+
throw new RuntimeException("Thread interrupted during screenshot delay", e);
292+
}
293+
286294
BufferedImage s = rbt.createScreenCapture(frameBounds);
287295
if (new ImageComparison(background, s).compareImages().getDifferencePercent() == 0) {
288296
break;

0 commit comments

Comments
 (0)