Skip to content
Snippets Groups Projects
Commit 87066860 authored by Hallvard Trætteberg's avatar Hallvard Trætteberg
Browse files

Support headless, should work in gitlab CI

parent ef1306b8
Branches
No related tags found
No related merge requests found
......@@ -11,11 +11,6 @@
<artifactId>fxui</artifactId>
<properties>
<skipUiTests>false</skipUiTests>
<headlessTests>false</headlessTests>
</properties>
<dependencies>
<dependency>
<groupId>it1901.todolist</groupId>
......@@ -203,6 +198,7 @@
@{jaCoCoArgLine}
--add-opens todolist.ui/todolist.ui=ALL-UNNAMED --add-exports javafx.graphics/com.sun.javafx.application=ALL-UNNAMED
--add-opens javafx.graphics/com.sun.glass.ui=ALL-UNNAMED --add-exports javafx.graphics/com.sun.glass.ui=ALL-UNNAMED
--add-exports javafx.graphics/com.sun.glass.ui.delegate=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
......
......@@ -11,6 +11,16 @@ import javafx.stage.Stage;
*/
public class TodoApp extends Application {
public static void supportHeadless() {
if (Boolean.getBoolean("headless")) {
System.setProperty("testfx.robot", "glass");
System.setProperty("testfx.headless", "true");
System.setProperty("prism.order", "sw");
System.setProperty("prism.text", "t2k");
System.setProperty("java.awt.headless", "true");
}
}
@Override
public void start(Stage stage) throws Exception {
Parent parent = FXMLLoader.load(getClass().getResource("TodoApp.fxml"));
......
......@@ -18,19 +18,9 @@ import org.testfx.framework.junit5.ApplicationTest;
public class TodoAppTest extends ApplicationTest {
static void supportHeadlessTest() {
if (Boolean.getBoolean("headless")) {
System.setProperty("testfx.robot", "glass");
System.setProperty("testfx.headless", "true");
System.setProperty("prism.order", "sw");
System.setProperty("prism.text", "t2k");
System.setProperty("java.awt.headless", "true");
}
}
@BeforeAll
public static void setupHeadless() {
supportHeadlessTest();
TodoApp.supportHeadless();
}
private TodoModelController controller;
......
......@@ -21,7 +21,6 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.testfx.framework.junit5.ApplicationTest;
import org.testfx.util.WaitForAsyncUtils;
import todolist.core.AbstractTodoList;
......@@ -35,7 +34,7 @@ public class TodoListControllerTest extends ApplicationTest {
@BeforeAll
public static void setupHeadless() {
TodoAppTest.supportHeadlessTest();
TodoApp.supportHeadless();
}
private TodoListController controller;
......@@ -130,7 +129,6 @@ public class TodoListControllerTest extends ApplicationTest {
/** Test - virker ikke i gitpod */
@Test
@DisplayName("Test dragging a ToDo list item")
@DisabledIfEnvironmentVariable(named = "GITPOD_WORKSPACE_ID", matches = ".*")
public void testDragTodoItem() {
Predicate<TodoItemListCell> draggableCell = cell -> cell.lookup(".label") != null;
// drag the first item in the list view, which is the second item in the model
......
......@@ -75,6 +75,24 @@
</dependency>
</dependencies>
<profiles>
<profile>
<id>headless</id>
<properties>
<headlessTests>true</headlessTests>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.testfx/openjfx-monocle -->
<dependency>
<groupId>org.testfx</groupId>
<artifactId>openjfx-monocle</artifactId>
<version>jdk-12.0.1+2</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
<build>
<plugins>
<plugin>
......@@ -149,6 +167,7 @@
<configuration>
<!-- System.getProperty("todo.port") gir riktig port -->
<systemPropertyVariables>
<headless>${headlessTests}</headless>
<todo.port>${jetty.port}</todo.port>
</systemPropertyVariables>
</configuration>
......
......@@ -11,12 +11,18 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URI;
import java.net.URISyntaxException;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.testfx.framework.junit5.ApplicationTest;
public class TodoAppIT extends ApplicationTest {
@BeforeAll
public static void setupHeadless() {
TodoApp.supportHeadless();
}
private TodoModelController controller;
@Override
......
......@@ -12,6 +12,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jupiter.version>5.8.1</jupiter.version>
<jackson.version>2.12.5</jackson.version>
<skipUiTests>false</skipUiTests>
<headlessTests>false</headlessTests>
</properties>
<dependencyManagement>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment