From ab131d0b9dba821f73625c0bc84de1bb876ba98e Mon Sep 17 00:00:00 2001 From: Aleksandr Zvegintsev Date: Sat, 16 Nov 2024 20:34:20 +0100 Subject: [PATCH] ParameterizedTest --- .../swing/LinuxScreencastHangCrashTest.java | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/tests/system/src/test/java/test/robot/javafx/embed/swing/LinuxScreencastHangCrashTest.java b/tests/system/src/test/java/test/robot/javafx/embed/swing/LinuxScreencastHangCrashTest.java index f2e238fa335..565c1deab0c 100644 --- a/tests/system/src/test/java/test/robot/javafx/embed/swing/LinuxScreencastHangCrashTest.java +++ b/tests/system/src/test/java/test/robot/javafx/embed/swing/LinuxScreencastHangCrashTest.java @@ -26,7 +26,6 @@ package test.robot.javafx.embed.swing; import java.awt.Robot; -import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -39,6 +38,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import test.util.Util; @TestMethodOrder(OrderAnnotation.class) @@ -98,9 +99,7 @@ private static void fxPixel() throws InterruptedException { private static void initFX() { if (!isFxStarted) { System.out.println("Platform.startup"); - Platform.startup(() -> { - jfxRobot = new javafx.scene.robot.Robot(); - }); + Platform.startup(() -> jfxRobot = new javafx.scene.robot.Robot()); isFxStarted = true; } } @@ -130,27 +129,22 @@ public void testHang() throws Exception { robot.delay(DELAY_WAIT_FOR_SESSION_TO_CLOSE); } - @Test + @ParameterizedTest @Order(2) @Timeout(value=60) - public void testCrash() { - List.of( - DELAY_KEEP_SESSION, - DELAY_BEFORE_SESSION_CLOSE, // 3 following are just in case - DELAY_BEFORE_SESSION_CLOSE - 25, - DELAY_BEFORE_SESSION_CLOSE + 25 - ).forEach(delay -> { - System.out.println("Testing with delay: " + delay); - try { - awtPixel(); - robot.delay(delay); - fxPixel(); - robot.delay(delay); - awtPixelOnFxThread(); - robot.delay(delay); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); + @ValueSource(ints = { + DELAY_KEEP_SESSION, + DELAY_BEFORE_SESSION_CLOSE, // 3 following are just in case + DELAY_BEFORE_SESSION_CLOSE - 25, + DELAY_BEFORE_SESSION_CLOSE + 25 + }) + public void testCrash(int delay) throws Exception { + System.out.println("Testing with delay: " + delay); + awtPixel(); + robot.delay(delay); + fxPixel(); + robot.delay(delay); + awtPixelOnFxThread(); + robot.delay(delay); } }