Commit 68e89d60 authored by Hallvard Trætteberg's avatar Hallvard Trætteberg
Browse files

Test that todosettings panel opens

parent dcbf8dea
......@@ -9,7 +9,7 @@
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.collections.FXCollections?>
<VBox xmlns:fx="http://javafx.com/fxml" fx:controller="todolist.ui.TodoSettingsController">
<VBox fx:id="todoSettingsRoot" xmlns:fx="http://javafx.com/fxml" fx:controller="todolist.ui.TodoSettingsController">
<Label text="Settings"/>
<GridPane alignment="center" hgap="10" vgap="10">
<!-- <padding><Insets top="25" right="25" bottom="25" left="25"/></padding> -->
......
......@@ -4,6 +4,7 @@ import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.Window;
import todolist.json.TodoPersistence;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;
......@@ -15,6 +16,7 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.testfx.framework.junit5.ApplicationTest;
import org.testfx.util.WaitForAsyncUtils;
public class TodoAppTest extends ApplicationTest {
......@@ -55,4 +57,23 @@ public class TodoAppTest extends ApplicationTest {
public void testSelectedTodoList_initial() {
assertNotNull(this.controller.getSelectedTodoList());
}
@Test
public void testTodoSettings() {
clickOn("#todoSettingsButton");
WaitForAsyncUtils.waitForFxEvents();
assertNotNull(findSceneRootWithId("todoSettingsRoot"));
}
private Parent findSceneRootWithId(String id) {
for (Window window : Window.getWindows()) {
if (window instanceof Stage && window.isShowing()) {
var root = window.getScene().getRoot();
if (id.equals(root.getId())) {
return root;
}
}
}
return null;
}
}
......@@ -3,10 +3,12 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Button?>
<VBox xmlns:fx="http://javafx.com/fxml/1" fx:controller="todolist.ui.TodoModelController">
<HBox>
<ComboBox fx:id="todoListsView"/>
<Button fx:id="todoSettingsButton" onAction="#handleSettingsAction"/>
</HBox>
<fx:include fx:id="todoListView" source="TodoList_test.fxml"/>
</VBox>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment