diff --git a/cobigen/gui/pom.xml b/cobigen/gui/pom.xml index c0ba4cf6c1..8a822e0a2f 100644 --- a/cobigen/gui/pom.xml +++ b/cobigen/gui/pom.xml @@ -30,6 +30,23 @@ javafx-fxml ${javafx.version} + + junit + junit + 4.13.1 + + + org.testfx + testfx-core + 4.0.16-alpha + test + + + org.testfx + testfx-junit + 4.0.15-alpha + test + diff --git a/cobigen/gui/src/main/java/module-info.java b/cobigen/gui/src/main/java/module-info.java index 1d520c990e..5ccd640e6f 100644 --- a/cobigen/gui/src/main/java/module-info.java +++ b/cobigen/gui/src/main/java/module-info.java @@ -1,3 +1,7 @@ +/** + * @author nneuhaus + * + */ module gui { requires javafx.controls; @@ -5,6 +9,8 @@ requires transitive javafx.graphics; + requires junit; + opens com.devonfw.cobigen.gui to javafx.fxml; exports com.devonfw.cobigen.gui; diff --git a/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/FilterTest.java b/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/FilterTest.java new file mode 100644 index 0000000000..026f30512c --- /dev/null +++ b/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/FilterTest.java @@ -0,0 +1,9 @@ +package com.devonfw.cobigen.gui; + +/** + * TODO nneuhaus This type ... + * + */ +public class FilterTest extends TestFXBase { + +} diff --git a/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/HomePageTest.java b/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/HomePageTest.java new file mode 100644 index 0000000000..5c8b9e8166 --- /dev/null +++ b/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/HomePageTest.java @@ -0,0 +1,21 @@ +package com.devonfw.cobigen.gui; + +import org.junit.Test; +import org.testfx.api.FxRobotException; + +/** + * TODO nneuhaus This type ... + * + */ +public class HomePageTest extends TestFXBase { + + /** + * Test if exception is thrown, when the bot tries to click a not existing element + */ + @Test(expected = FxRobotException.class) + public void clickOnBogusElement() { + + clickOn("#NotExisting"); + } + +} diff --git a/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/ProcessTemplateSetTest.java b/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/ProcessTemplateSetTest.java new file mode 100644 index 0000000000..a38a557963 --- /dev/null +++ b/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/ProcessTemplateSetTest.java @@ -0,0 +1,9 @@ +package com.devonfw.cobigen.gui; + +/** + * TODO nneuhaus This type ... + * + */ +public class ProcessTemplateSetTest extends TestFXBase { + +} diff --git a/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/SearchTest.java b/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/SearchTest.java new file mode 100644 index 0000000000..39d55e96c5 --- /dev/null +++ b/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/SearchTest.java @@ -0,0 +1,8 @@ +package com.devonfw.cobigen.gui; + +/** + * TODO nneuhaus This type ... + * + */ +public class SearchTest extends TestFXBase { +} diff --git a/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/TemplateSetDetailsTest.java b/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/TemplateSetDetailsTest.java new file mode 100644 index 0000000000..8d43e9375a --- /dev/null +++ b/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/TemplateSetDetailsTest.java @@ -0,0 +1,9 @@ +package com.devonfw.cobigen.gui; + +/** + * TODO nneuhaus This type ... + * + */ +public class TemplateSetDetailsTest extends TestFXBase { + +} diff --git a/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/TestFXBase.java b/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/TestFXBase.java new file mode 100644 index 0000000000..e25b7c4e9b --- /dev/null +++ b/cobigen/gui/src/test/java/com/devonfw/cobigen/gui/TestFXBase.java @@ -0,0 +1,63 @@ +package com.devonfw.cobigen.gui; + +import java.util.concurrent.TimeoutException; + +import org.junit.After; +import org.junit.Before; +import org.testfx.api.FxToolkit; +import org.testfx.framework.junit.ApplicationTest; + +import javafx.scene.Node; +import javafx.scene.input.KeyCode; +import javafx.scene.input.MouseButton; +import javafx.stage.Stage; + +/** + * TODO nneuhaus This type ... + * + */ +public class TestFXBase extends ApplicationTest { + + /** + * @throws Exception + */ + @SuppressWarnings("javadoc") + @Before + public void setUpClass() throws Exception { + + ApplicationTest.launch(App.class); + } + + @Override + public void start(Stage stage) throws Exception { + + // TODO Auto-generated method stub + + } + + /** + * @throws TimeoutException + */ + @SuppressWarnings("javadoc") + @After + public void afterEachTest() throws TimeoutException { + + FxToolkit.hideStage(); + release(new KeyCode[] {}); + release(new MouseButton[] {}); + } + + /** + * Helper method to retrieve Java FX GUI components + * + * @param + * @param query + * @return + */ + @SuppressWarnings("unchecked") + public T find(final String query) { + + return (T) lookup(query).queryAll().iterator().next(); + } + +} diff --git a/pom.xml b/pom.xml index 65cf1a927f..c12d5682ab 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,6 @@ cobigen cobigen-plugins cobigen-cli - cobigen-gui cobigen-eclipse cobigen-maven cobigen-templates