Merge branch 'tempBranch' of https://gitlab.stud.idi.ntnu.no/oysteikt/h20-tdt4100-project into tempBranch
This commit is contained in:
@@ -1,44 +0,0 @@
|
|||||||
package app;
|
|
||||||
|
|
||||||
import javafx.scene.Node;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.testfx.api.FxToolkit;
|
|
||||||
import org.testfx.framework.junit5.ApplicationTest;
|
|
||||||
import org.testfx.util.WaitForAsyncUtils;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
public class FxTestTemplate extends ApplicationTest {
|
|
||||||
|
|
||||||
private Stage stage;
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
public void runAppToTests() throws Exception {
|
|
||||||
FxToolkit.registerPrimaryStage();
|
|
||||||
FxToolkit.setupApplication(Main::new);
|
|
||||||
FxToolkit.showStage();
|
|
||||||
WaitForAsyncUtils.waitForFxEvents(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
public void stopApp() throws TimeoutException {
|
|
||||||
FxToolkit.cleanupStages();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start(Stage primaryStage){
|
|
||||||
this.stage = primaryStage;
|
|
||||||
primaryStage.toFront();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Stage getStage() {
|
|
||||||
return stage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T extends Node> T find(final String query) {
|
|
||||||
/** TestFX provides many operations to retrieve elements from the loaded GUI. */
|
|
||||||
return lookup(query).query();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -64,7 +64,7 @@ public class EditorControllerTest extends FxTestTemplate {
|
|||||||
|
|
||||||
private String mockContent = """
|
private String mockContent = """
|
||||||
class HelloWorld {
|
class HelloWorld {
|
||||||
private String message = "Hello world";
|
private String message = \"Hello world\";
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
@@ -108,7 +108,7 @@ public class EditorControllerTest extends FxTestTemplate {
|
|||||||
String brokenFilePath = "/doesNotExist.txt";
|
String brokenFilePath = "/doesNotExist.txt";
|
||||||
eventBus.post(new OpenFileEvent(Optional.ofNullable(Paths.get(brokenFilePath))));
|
eventBus.post(new OpenFileEvent(Optional.ofNullable(Paths.get(brokenFilePath))));
|
||||||
|
|
||||||
verify(editor, never()).clear();
|
verify(editor).appendText("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user