Skip to content

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tbee committed Apr 29, 2018
1 parent d2746b2 commit c9a18a6
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package jfxtras.scene.control.agenda.test;

package jfxtras.scene.control.agenda.test;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.LinkedHashMap;
Expand All @@ -42,41 +42,42 @@
import javafx.util.Callback;
import jfxtras.scene.control.agenda.Agenda;
import jfxtras.scene.control.agenda.Agenda.Appointment;
import jfxtras.test.JFXtrasGuiTest;

public class AbstractAgendaTestBase extends JFXtrasGuiTest {

/**
*
*/
public Parent getRootNode()
{
Locale.setDefault(Locale.ENGLISH);

vbox = new VBox();

agenda = new Agenda();
agenda.setDisplayedLocalDateTime(LocalDate.of(2014, 1, 1).atStartOfDay());
agenda.setPrefSize(1000, 800);

// setup appointment groups
for (Agenda.AppointmentGroup lAppointmentGroup : agenda.appointmentGroups()) {
appointmentGroupMap.put(lAppointmentGroup.getDescription(), lAppointmentGroup);
}

// accept new appointments
agenda.newAppointmentCallbackProperty().set(new Callback<Agenda.LocalDateTimeRange, Agenda.Appointment>()
{
@Override
public Agenda.Appointment call(Agenda.LocalDateTimeRange calendarRange)
{
return new Agenda.AppointmentImplLocal()
.withStartLocalDateTime(calendarRange.getStartLocalDateTime())
.withEndLocalDateTime(calendarRange.getEndLocalDateTime())
.withSummary("new")
.withDescription("new")
.withAppointmentGroup(appointmentGroupMap.get("group01"));
}
import jfxtras.test.JFXtrasGuiTest;
import jfxtras.test.TestUtil;

public class AbstractAgendaTestBase extends JFXtrasGuiTest {

/**
*
*/
public Parent getRootNode()
{
Locale.setDefault(Locale.ENGLISH);

vbox = new VBox();

agenda = new Agenda();
agenda.setDisplayedLocalDateTime(LocalDate.of(2014, 1, 1).atStartOfDay());
agenda.setPrefSize(1000, 800);

// setup appointment groups
for (Agenda.AppointmentGroup lAppointmentGroup : agenda.appointmentGroups()) {
appointmentGroupMap.put(lAppointmentGroup.getDescription(), lAppointmentGroup);
}

// accept new appointments
agenda.newAppointmentCallbackProperty().set(new Callback<Agenda.LocalDateTimeRange, Agenda.Appointment>()
{
@Override
public Agenda.Appointment call(Agenda.LocalDateTimeRange calendarRange)
{
return new Agenda.AppointmentImplLocal()
.withStartLocalDateTime(calendarRange.getStartLocalDateTime())
.withEndLocalDateTime(calendarRange.getEndLocalDateTime())
.withSummary("new")
.withDescription("new")
.withAppointmentGroup(appointmentGroupMap.get("group01"));
}
});

// tick callbacks
Expand All @@ -90,14 +91,17 @@ public Agenda.Appointment call(Agenda.LocalDateTimeRange calendarRange)
}
appointmentChangedCallbackMap.put(identityHashCode, appointmentChangedCallbackMap.get(identityHashCode) + 1);
return null;
});

vbox.getChildren().add(agenda);
return vbox;
}
protected VBox vbox = null; // cannot make this final and assign upon construction
final protected Map<String, Agenda.AppointmentGroup> appointmentGroupMap = new TreeMap<String, Agenda.AppointmentGroup>();
protected Agenda agenda = null; // cannot make this final and assign upon construction
});

vbox.getChildren().add(agenda);

TestUtil.sleep(500); // delay because otherwise the click ends up in the dos window... Can be removed with a higher version of TestFX?

return vbox;
}
protected VBox vbox = null; // cannot make this final and assign upon construction
final protected Map<String, Agenda.AppointmentGroup> appointmentGroupMap = new TreeMap<String, Agenda.AppointmentGroup>();
protected Agenda agenda = null; // cannot make this final and assign upon construction
final protected List<Appointment> appointmentChangedCallbackList = new ArrayList<>();
final protected Map<Integer, Integer> appointmentChangedCallbackMap = new LinkedHashMap<>();
}
final protected Map<Integer, Integer> appointmentChangedCallbackMap = new LinkedHashMap<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void showAppointmentMenu()
.withAppointmentGroup(appointmentGroupMap.get("group01"))
);
});

clickOn("#AppointmentRegularBodyPane2014-01-01/0 .MenuIcon");
assertPopupIsVisible(find("#AppointmentRegularBodyPane2014-01-01/0"));
//TestUtil.sleep(3000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package jfxtras.scene.layout.test;

package jfxtras.scene.layout.test;

import org.junit.Test;

import javafx.geometry.HPos;
Expand All @@ -39,17 +39,20 @@
import jfxtras.scene.layout.GridPane;
import jfxtras.test.AssertNode;
import jfxtras.test.JFXtrasGuiTest;

/**
* Created by Tom Eugelink on 26-12-13.
*/
public class GridPaneTest extends JFXtrasGuiTest {

/**
*
*/
public Parent getRootNode()
{

/**
* Created by Tom Eugelink on 26-12-13.
*/
public class GridPaneTest extends JFXtrasGuiTest {

/**
*
*/
public Parent getRootNode()
{
stage.setWidth(800.0);
stage.setHeight(600.0);

gridPane = new GridPane()
.withHGap(5)
.withVGap(5)
Expand All @@ -69,18 +72,18 @@ public Parent getRootNode()
gridPane.add(new Label("BOTTOM"), new GridPane.C().col(0).row(3).valignment(VPos.BOTTOM));

gridPane.add(new Label("TOP"), new GridPane.C().col(3).row(3).valignment(VPos.TOP));

return gridPane;
}
private GridPane gridPane = null;

/**
*
*/
@Test
public void checkPositions()

return gridPane;
}
private GridPane gridPane = null;

/**
*
*/
@Test
public void checkPositions()
{
//AssertNode.generateSource("gridPane", gridPane.getChildren(), null, false, A.XYWH, A.CLASS);
AssertNode.generateSource("gridPane", gridPane.getChildren(), null, false, AssertNode.A.XYWH, AssertNode.A.CLASS);
new AssertNode(gridPane.getChildren().get(1)).assertXYWH(71.0, 10.0, 52.0, 17.0, 0.01).assertClass(javafx.scene.control.Label.class);
new AssertNode(gridPane.getChildren().get(2)).assertXYWH(199.0, 10.0, 34.0, 17.0, 0.01).assertClass(javafx.scene.control.Label.class);
new AssertNode(gridPane.getChildren().get(3)).assertXYWH(10.0, 10.0, 56.0, 51.0, 0.01).assertClass(javafx.scene.control.Label.class);
Expand All @@ -89,5 +92,5 @@ public void checkPositions()
new AssertNode(gridPane.getChildren().get(6)).assertXYWH(95.0, 66.0, 115.0, 85.0, 0.01).assertClass(javafx.scene.control.Label.class);
new AssertNode(gridPane.getChildren().get(7)).assertXYWH(10.0, 134.0, 49.0, 17.0, 0.01).assertClass(javafx.scene.control.Label.class);
new AssertNode(gridPane.getChildren().get(8)).assertXYWH(238.0, 88.0, 23.0, 17.0, 0.01).assertClass(javafx.scene.control.Label.class);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package jfxtras.scene.layout.test;

package jfxtras.scene.layout.test;

import jfxtras.test.TestUtil;
import org.junit.Test;

import javafx.geometry.Insets;
Expand All @@ -38,41 +39,44 @@
import jfxtras.scene.layout.HBox;
import jfxtras.test.AssertNode;
import jfxtras.test.JFXtrasGuiTest;

/**
* Created by Tom Eugelink on 26-12-13.
*/
public class HBoxTest extends JFXtrasGuiTest {

/**
*

/**
* Created by Tom Eugelink on 26-12-13.
*/
public class HBoxTest extends JFXtrasGuiTest {

/**
*
*/
@Override
public Parent getRootNode()
{
stage.setWidth(800.0);
stage.setHeight(600.0);

hbox = new HBox(5.0);
hbox.add(new Button("grow"), new HBox.C().hgrow(Priority.ALWAYS));
hbox.add(new Button("margin 5 grow"), new HBox.C().margin(new Insets(5.0)).hgrow(Priority.ALWAYS));
hbox.getChildren().add(new Button("old style"));
hbox.add(new Button("margin 20 nogrow"), new HBox.C().margin(new Insets(20.0)));
hbox.add(new Button("grow maxheight 50"), new HBox.C().hgrow(Priority.ALWAYS).maxHeight(50.0));

return hbox;
}
private HBox hbox = null;

/**
*
*/
@Override
public Parent getRootNode()
{
hbox = new HBox(5.0);
hbox.add(new Button("grow"), new HBox.C().hgrow(Priority.ALWAYS));
hbox.add(new Button("margin 5 grow"), new HBox.C().margin(new Insets(5.0)).hgrow(Priority.ALWAYS));
hbox.getChildren().add(new Button("old style"));
hbox.add(new Button("margin 20 nogrow"), new HBox.C().margin(new Insets(20.0)));
hbox.add(new Button("grow maxheight 50"), new HBox.C().hgrow(Priority.ALWAYS).maxHeight(50.0));

return hbox;
}
private HBox hbox = null;

/**
*
*/
@Test
public void checkPositions()
@Test
public void checkPositions()
{
//AssertNode.generateSource("hbox", hbox.getChildren(), null, false, A.XYWH, A.CLASS);
new AssertNode(hbox.getChildren().get(0)).assertXYWH(0.0, 0.0, 43.0, 25.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(hbox.getChildren().get(1)).assertXYWH(53.0, 5.0, 94.0, 25.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(hbox.getChildren().get(2)).assertXYWH(157.0, 0.0, 61.0, 25.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(hbox.getChildren().get(3)).assertXYWH(243.0, 20.0, 114.0, 25.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(hbox.getChildren().get(4)).assertXYWH(382.0, 0.0, 119.0, 50.0, 0.01).assertClass(javafx.scene.control.Button.class);
}

}
AssertNode.generateSource("hbox", hbox.getChildren(), null, false, AssertNode.A.XYWH, AssertNode.A.CLASS);
new AssertNode(hbox.getChildren().get(0)).assertXYWH(0.0, 0.0, 143.0, 25.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(hbox.getChildren().get(1)).assertXYWH(153.0, 5.0, 194.0, 25.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(hbox.getChildren().get(2)).assertXYWH(357.0, 0.0, 61.0, 25.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(hbox.getChildren().get(3)).assertXYWH(443.0, 20.0, 114.0, 25.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(hbox.getChildren().get(4)).assertXYWH(582.0, 0.0, 218.0, 50.0, 0.01).assertClass(javafx.scene.control.Button.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package jfxtras.scene.layout.test;

package jfxtras.scene.layout.test;

import jfxtras.test.TestUtil;
import org.junit.Test;

import javafx.geometry.Insets;
Expand All @@ -39,44 +40,47 @@
import jfxtras.test.AssertNode;
import jfxtras.test.AssertNode.A;
import jfxtras.test.JFXtrasGuiTest;

/**
* Created by Tom Eugelink on 26-12-13.
*/
public class VBoxTest extends JFXtrasGuiTest {

/**
*
*/
public Parent getRootNode()
{
vbox = new VBox(5.0);

/**
* Created by Tom Eugelink on 26-12-13.
*/
public class VBoxTest extends JFXtrasGuiTest {

/**
*
*/
public Parent getRootNode()
{
stage.setWidth(800.0);
stage.setHeight(600.0);

vbox = new VBox(5.0);
vbox.add(new Button("short"), new VBox.C().vgrow(Priority.ALWAYS));
vbox.add(new Button("medium length"), new VBox.C().vgrow(Priority.ALWAYS));
vbox.add(new Button("a longer description in order to test things"), new VBox.C().vgrow(Priority.ALWAYS));
vbox.add(new Button("margin 5 grow"), new VBox.C().margin(new Insets(5.0)).vgrow(Priority.ALWAYS));
vbox.getChildren().add(new Button("old style"));
vbox.add(new Button("margin 20 nogrow"), new VBox.C().margin(new Insets(20.0)));
vbox.add(new Button("grow maxwidth 150"), new VBox.C().vgrow(Priority.ALWAYS).maxWidth(150.0));

return vbox;
}
private VBox vbox = null;

/**
*
*/
@Test
public void checkPositions()

return vbox;
}
private VBox vbox = null;

/**
*
*/
@Test
public void checkPositions()
{
AssertNode.generateSource("vbox", vbox.getChildren(), null, false, A.XYWH, A.CLASS);
new AssertNode(vbox.getChildren().get(0)).assertXYWH(0.0, 0.0, 44.0, 25.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(vbox.getChildren().get(1)).assertXYWH(0.0, 30.0, 97.0, 25.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(vbox.getChildren().get(2)).assertXYWH(0.0, 60.0, 240.0, 25.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(vbox.getChildren().get(3)).assertXYWH(5.0, 95.0, 94.0, 25.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(vbox.getChildren().get(4)).assertXYWH(0.0, 130.0, 61.0, 25.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(vbox.getChildren().get(5)).assertXYWH(20.0, 180.0, 114.0, 25.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(vbox.getChildren().get(6)).assertXYWH(0.0, 230.0, 150.0, 25.0, 0.01).assertClass(javafx.scene.control.Button.class);
}

}
new AssertNode(vbox.getChildren().get(0)).assertXYWH(0.0, 0.0, 44.0, 94.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(vbox.getChildren().get(1)).assertXYWH(0.0, 99.0, 97.0, 94.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(vbox.getChildren().get(2)).assertXYWH(0.0, 198.0, 240.0, 94.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(vbox.getChildren().get(3)).assertXYWH(5.0, 302.0, 94.0, 94.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(vbox.getChildren().get(4)).assertXYWH(0.0, 406.0, 61.0, 25.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(vbox.getChildren().get(5)).assertXYWH(20.0, 456.0, 114.0, 25.0, 0.01).assertClass(javafx.scene.control.Button.class);
new AssertNode(vbox.getChildren().get(6)).assertXYWH(0.0, 506.0, 150.0, 94.0, 0.01).assertClass(javafx.scene.control.Button.class);
}

}
Loading

0 comments on commit c9a18a6

Please sign in to comment.