mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-23 13:11:28 +00:00
use single method to initialize JavaFX
This commit is contained in:
20
src/main/java/org/cryptomator/JavaFXUtil.java
Normal file
20
src/main/java/org/cryptomator/JavaFXUtil.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package org.cryptomator;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class JavaFXUtil {
|
||||
|
||||
public static boolean startPlatform() throws InterruptedException {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
try {
|
||||
Platform.startup(latch::countDown);
|
||||
} catch (IllegalStateException e) {
|
||||
//already initialized
|
||||
latch.countDown();
|
||||
}
|
||||
return latch.await(5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.cryptomator.common.keychain;
|
||||
|
||||
|
||||
import org.cryptomator.JavaFXUtil;
|
||||
import org.cryptomator.integrations.keychain.KeychainAccessException;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
@@ -21,15 +22,8 @@ public class KeychainManagerTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void startup() throws InterruptedException {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
try {
|
||||
Platform.startup(latch::countDown);
|
||||
} catch (IllegalStateException e) {
|
||||
//already initialized
|
||||
latch.countDown();
|
||||
}
|
||||
var javafxStarted = latch.await(5, TimeUnit.SECONDS);
|
||||
Assumptions.assumeTrue(javafxStarted);
|
||||
var isRunning = JavaFXUtil.startPlatform();
|
||||
Assumptions.assumeTrue(isRunning);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.cryptomator.ui.controls;
|
||||
|
||||
import org.cryptomator.JavaFXUtil;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
@@ -18,10 +19,8 @@ public class SecurePasswordFieldTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void initJavaFx() throws InterruptedException {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
Platform.startup(latch::countDown);
|
||||
var javafxStarted = latch.await(5, TimeUnit.SECONDS);
|
||||
Assumptions.assumeTrue(javafxStarted);
|
||||
var isRunning = JavaFXUtil.startPlatform();
|
||||
Assumptions.assumeTrue(isRunning);
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
Reference in New Issue
Block a user