Skip to content

Commit

Permalink
Use fx2j loader for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheikah45 committed Dec 1, 2023
1 parent 5a09291 commit a4a23af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ install4j {
fx2j {
modularizeIfPossible = false
basePackage = "com.faforever.client.fx2j"
strict = true
}

tasks.register('buildInstall4jMediaFiles', Install4jTask) {
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/com/faforever/client/test/PlatformTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import com.faforever.client.fx.AttachedUtil;
import com.faforever.client.fx.Controller;
import com.faforever.client.fx.FxApplicationThreadExecutor;
import io.github.sheikah45.fx2j.api.Fx2jLoader;
import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.control.MenuItem;
import javafx.scene.control.Tab;
import javafx.util.Callback;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -30,6 +29,7 @@
import java.io.IOException;
import java.net.URL;
import java.util.Locale;
import java.util.function.Function;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mockStatic;
Expand Down Expand Up @@ -71,11 +71,11 @@ public static void setupPlatform() {
}

protected void loadFxml(String fileName,
Callback<Class<?>, Object> controllerFactory) throws IOException, InterruptedException {
Function<Class<?>, Object> controllerFactory) throws IOException, InterruptedException {
loadFxml(fileName, controllerFactory, null);
}

protected void loadFxml(String fileName, Callback<Class<?>, Object> controllerFactory,
protected void loadFxml(String fileName, Function<Class<?>, Object> controllerFactory,
Controller<?> controller) throws IOException, InterruptedException {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("i18n.messages");
Expand All @@ -87,7 +87,7 @@ class ExceptionWrapper {

ExceptionWrapper loadExceptionWrapper = new ExceptionWrapper();

FXMLLoader loader = new FXMLLoader();
Fx2jLoader loader = new Fx2jLoader();
loader.setLocation(getThemeFileUrl(fileName));
loader.setResources(new MessageSourceResourceBundle(messageSource, Locale.US));
loader.setControllerFactory(controllerFactory);
Expand Down

0 comments on commit a4a23af

Please sign in to comment.