Dialog Manager GUI Test
parent
3d3aa472d9
commit
1ad76212f6
|
|
@ -0,0 +1,78 @@
|
||||||
|
import domain.HitoriBoardLoader;
|
||||||
|
import GUI.HitoriDialogManager;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import org.junit.jupiter.api.*;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.testfx.framework.junit5.ApplicationExtension;
|
||||||
|
import org.testfx.framework.junit5.Start;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
@ExtendWith(ApplicationExtension.class)
|
||||||
|
class HitoriDialogManagerTest {
|
||||||
|
private HitoriDialogManager dialogManager;
|
||||||
|
private Stage stage;
|
||||||
|
private HitoriBoardLoader boardLoader;
|
||||||
|
|
||||||
|
@Start
|
||||||
|
private void start(Stage stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
boardLoader = mock(HitoriBoardLoader.class);
|
||||||
|
dialogManager = new HitoriDialogManager(stage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testShowAlert() {
|
||||||
|
// Cannot directly test Alert dialogs in headless mode
|
||||||
|
assertDoesNotThrow(() ->
|
||||||
|
dialogManager.showAlert("Test", "Test Message")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testConfirmDeleteHighScores() {
|
||||||
|
// Cannot directly test confirmation dialogs in headless mode
|
||||||
|
assertDoesNotThrow(() ->
|
||||||
|
dialogManager.confirmDeleteHighScores()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testConfirmNewGame() {
|
||||||
|
// Cannot directly test confirmation dialogs in headless mode
|
||||||
|
assertDoesNotThrow(() ->
|
||||||
|
dialogManager.confirmNewGame()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testAskForPlayerName() {
|
||||||
|
// Cannot directly test input dialogs in headless mode
|
||||||
|
assertDoesNotThrow(() ->
|
||||||
|
dialogManager.askForPlayerName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testConfirmLoadSavedGame() {
|
||||||
|
// Cannot directly test confirmation dialogs in headless mode
|
||||||
|
assertDoesNotThrow(() ->
|
||||||
|
dialogManager.confirmLoadSavedGame()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testShowBoardSelectionDialog() {
|
||||||
|
// Cannot directly test choice dialogs in headless mode
|
||||||
|
when(boardLoader.getAvailableBoardNames())
|
||||||
|
.thenReturn(java.util.Arrays.asList("Board1", "Board2"));
|
||||||
|
|
||||||
|
assertDoesNotThrow(() ->
|
||||||
|
dialogManager.showBoardSelectionDialog(boardLoader)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue