Skip to content

Commit

Permalink
devonfw#1454 Completed HomePageTest 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonNew committed Dec 9, 2022
1 parent c68b053 commit bf1f2f2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>

<AnchorPane fx:id="homePane" prefHeight="459.0" prefWidth="450.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.devonfw.cobigen.gui.controllers.HomeController">
<AnchorPane prefHeight="459.0" prefWidth="450.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.devonfw.cobigen.gui.controllers.HomeController">
<children>
<SplitPane fx:id="horizontalSplitPane" dividerPositions="0.1119186046511628" orientation="VERTICAL" prefHeight="459.0" prefWidth="450.0">
<items>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<AnchorPane fx:id="menuBarPane" layoutY="1.0" prefHeight="25.0" prefWidth="207.0" styleClass="menu-bar" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<Label fx:id="templateSetsLabel" text="Template Sets" AnchorPane.leftAnchor="5.0" AnchorPane.topAnchor="4.0" />

<Button fx:id="homeButton" layoutX="82.0" layoutY="2.0" maxHeight="15.0" maxWidth="15.0" minHeight="25.0" minWidth="25.0" mnemonicParsing="false" prefHeight="15.0" prefWidth="15.0" AnchorPane.rightAnchor="86.0">
<tooltip>
<Tooltip fx:id="homeTooltip" text="Home" />
Expand Down Expand Up @@ -72,13 +71,11 @@
<ScrollPane fitToWidth="true" prefHeight="303.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="28.0">
<content>
<ListView id="searchResultsView" fx:id="searchResultsView" prefWidth="184.0" />
</content></ScrollPane>
</content>
</ScrollPane>
</children>
</AnchorPane>
</children>
</AnchorPane>

<!-- TODO: Search Results as ListView of HBox -->

</children>
</AnchorPane>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.ListView;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;

Expand Down Expand Up @@ -37,7 +38,7 @@ public void clickOnBogusElement() {
@Test
public void ensureHomePageIsShownOnStartUp() {

Assertions.assertThat(this.mainRoot.lookup("#homePane").getParent().equals(this.mainRoot.lookup("#detailsPane")));
Assertions.assertThat(this.home);
}

/**
Expand All @@ -46,12 +47,15 @@ public void ensureHomePageIsShownOnStartUp() {
@Test
public void ensureHomePageIsShownOnHomeButtonClicked() {

// TODO: Switch to a Template Set before switching back to Home
String TEMPLATE_SET = "#templateSet";
clickOn(TEMPLATE_SET);
String HOME_BUTTON = "#homeButton";
clickOn(HOME_BUTTON);
Assertions.assertThat(this.mainRoot.lookup("#homePane").getParent().equals(this.mainRoot.lookup("#detailsPane")));
ListView<TemplateSet> searchResultsView = find("#searchResultsView");
searchResultsView.getSelectionModel().select(0);
Assertions.assertThat(searchResultsView.getSelectionModel().getSelectedIndex() == 0);
Assertions.assertThat(this.details.isVisible());
Assertions.assertThat(!this.home.isVisible());
// Switch back to Home
clickOn("#homeButton");
Assertions.assertThat(this.home.isVisible());
Assertions.assertThat(!this.details.isVisible());
}

/**
Expand All @@ -61,7 +65,7 @@ public void ensureHomePageIsShownOnHomeButtonClicked() {
public void testLinkToCobigenWiki() {

String COBIGEN_WIKI_LINK = "#wikilink";
this.wikilink = (Hyperlink) this.mainRoot.lookup(COBIGEN_WIKI_LINK);
this.wikilink = find(COBIGEN_WIKI_LINK);
Assertions.assertThat(!this.wikilink.isPressed());
clickOn(COBIGEN_WIKI_LINK);
Assertions.assertThat(this.wikilink.isPressed());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.input.MouseButton;
Expand All @@ -29,6 +30,10 @@ public class TestFXBase extends ApplicationTest {

Controller controller;

Parent home;

Parent details;

protected static ResourceBundle bundle;

/**
Expand Down Expand Up @@ -66,6 +71,9 @@ public void start(Stage stage) throws Exception {
stage.setScene(new Scene(this.mainRoot));
stage.show();
stage.toFront();

this.home = find("#home");
this.details = find("#details");
}

/**
Expand Down

0 comments on commit bf1f2f2

Please sign in to comment.